Average Error: 15.1 → 0.0
Time: 2.4s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -24215928678.961597442626953125 \lor \neg \left(x \le 3853.575133649498638988006860017776489258\right):\\ \;\;\;\;\left(\frac{1}{x} - 1 \cdot \frac{1}{{x}^{3}}\right) + \frac{1}{{x}^{5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot x + 1}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -24215928678.961597442626953125 \lor \neg \left(x \le 3853.575133649498638988006860017776489258\right):\\
\;\;\;\;\left(\frac{1}{x} - 1 \cdot \frac{1}{{x}^{3}}\right) + \frac{1}{{x}^{5}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{x \cdot x + 1}\\

\end{array}
double f(double x) {
        double r67391 = x;
        double r67392 = r67391 * r67391;
        double r67393 = 1.0;
        double r67394 = r67392 + r67393;
        double r67395 = r67391 / r67394;
        return r67395;
}

double f(double x) {
        double r67396 = x;
        double r67397 = -24215928678.961597;
        bool r67398 = r67396 <= r67397;
        double r67399 = 3853.5751336494986;
        bool r67400 = r67396 <= r67399;
        double r67401 = !r67400;
        bool r67402 = r67398 || r67401;
        double r67403 = 1.0;
        double r67404 = r67403 / r67396;
        double r67405 = 1.0;
        double r67406 = 3.0;
        double r67407 = pow(r67396, r67406);
        double r67408 = r67403 / r67407;
        double r67409 = r67405 * r67408;
        double r67410 = r67404 - r67409;
        double r67411 = 5.0;
        double r67412 = pow(r67396, r67411);
        double r67413 = r67405 / r67412;
        double r67414 = r67410 + r67413;
        double r67415 = r67396 * r67396;
        double r67416 = r67415 + r67405;
        double r67417 = r67396 / r67416;
        double r67418 = r67402 ? r67414 : r67417;
        return r67418;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -24215928678.961597 or 3853.5751336494986 < x

    1. Initial program 30.8

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt30.8

      \[\leadsto \frac{x}{\color{blue}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}}\]
    4. Applied associate-/r*30.7

      \[\leadsto \color{blue}{\frac{\frac{x}{\sqrt{x \cdot x + 1}}}{\sqrt{x \cdot x + 1}}}\]
    5. Taylor expanded around inf 0.0

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

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

    if -24215928678.961597 < x < 3853.5751336494986

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.0

      \[\leadsto \frac{x}{\color{blue}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}}\]
    4. Applied associate-/r*0.0

      \[\leadsto \color{blue}{\frac{\frac{x}{\sqrt{x \cdot x + 1}}}{\sqrt{x \cdot x + 1}}}\]
    5. Using strategy rm
    6. Applied div-inv0.0

      \[\leadsto \frac{\color{blue}{x \cdot \frac{1}{\sqrt{x \cdot x + 1}}}}{\sqrt{x \cdot x + 1}}\]
    7. Applied associate-/l*0.0

      \[\leadsto \color{blue}{\frac{x}{\frac{\sqrt{x \cdot x + 1}}{\frac{1}{\sqrt{x \cdot x + 1}}}}}\]
    8. Simplified0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -24215928678.961597442626953125 \lor \neg \left(x \le 3853.575133649498638988006860017776489258\right):\\ \;\;\;\;\left(\frac{1}{x} - 1 \cdot \frac{1}{{x}^{3}}\right) + \frac{1}{{x}^{5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot x + 1}\\ \end{array}\]

Reproduce

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

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

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