Average Error: 14.7 → 0.0
Time: 1.7m
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -16681204427079.668:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \mathbf{elif}\;x \le 431.15614654341414:\\ \;\;\;\;\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + -1} \cdot \left(x \cdot x - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -16681204427079.668:\\
\;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\

\mathbf{elif}\;x \le 431.15614654341414:\\
\;\;\;\;\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + -1} \cdot \left(x \cdot x - 1\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\

\end{array}
double f(double x) {
        double r10645259 = x;
        double r10645260 = r10645259 * r10645259;
        double r10645261 = 1.0;
        double r10645262 = r10645260 + r10645261;
        double r10645263 = r10645259 / r10645262;
        return r10645263;
}

double f(double x) {
        double r10645264 = x;
        double r10645265 = -16681204427079.668;
        bool r10645266 = r10645264 <= r10645265;
        double r10645267 = 1.0;
        double r10645268 = 5.0;
        double r10645269 = pow(r10645264, r10645268);
        double r10645270 = r10645267 / r10645269;
        double r10645271 = r10645267 / r10645264;
        double r10645272 = r10645270 + r10645271;
        double r10645273 = r10645264 * r10645264;
        double r10645274 = r10645273 * r10645264;
        double r10645275 = r10645267 / r10645274;
        double r10645276 = r10645272 - r10645275;
        double r10645277 = 431.15614654341414;
        bool r10645278 = r10645264 <= r10645277;
        double r10645279 = r10645273 * r10645273;
        double r10645280 = -1.0;
        double r10645281 = r10645279 + r10645280;
        double r10645282 = r10645264 / r10645281;
        double r10645283 = r10645273 - r10645267;
        double r10645284 = r10645282 * r10645283;
        double r10645285 = r10645278 ? r10645284 : r10645276;
        double r10645286 = r10645266 ? r10645276 : r10645285;
        return r10645286;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.7
Target0.1
Herbie0.0
\[\frac{1}{x + \frac{1}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -16681204427079.668 or 431.15614654341414 < x

    1. Initial program 30.3

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied flip-+48.1

      \[\leadsto \frac{x}{\color{blue}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1}{x \cdot x - 1}}}\]
    4. Applied associate-/r/48.1

      \[\leadsto \color{blue}{\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1} \cdot \left(x \cdot x - 1\right)}\]
    5. Simplified48.1

      \[\leadsto \color{blue}{\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + -1}} \cdot \left(x \cdot x - 1\right)\]
    6. Taylor expanded around inf 0.0

      \[\leadsto \color{blue}{\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{{x}^{3}}}\]
    7. Simplified0.0

      \[\leadsto \color{blue}{\left(\frac{1}{x} + \frac{1}{{x}^{5}}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}}\]

    if -16681204427079.668 < x < 431.15614654341414

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied flip-+0.0

      \[\leadsto \frac{x}{\color{blue}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1}{x \cdot x - 1}}}\]
    4. Applied associate-/r/0.0

      \[\leadsto \color{blue}{\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1} \cdot \left(x \cdot x - 1\right)}\]
    5. Simplified0.0

      \[\leadsto \color{blue}{\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + -1}} \cdot \left(x \cdot x - 1\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -16681204427079.668:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \mathbf{elif}\;x \le 431.15614654341414:\\ \;\;\;\;\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + -1} \cdot \left(x \cdot x - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \end{array}\]

Reproduce

herbie shell --seed 2019128 
(FPCore (x)
  :name "x / (x^2 + 1)"

  :herbie-target
  (/ 1 (+ x (/ 1 x)))

  (/ x (+ (* x x) 1)))