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

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

\end{array}
double f(double x) {
        double r100310 = x;
        double r100311 = r100310 * r100310;
        double r100312 = 1.0;
        double r100313 = r100311 + r100312;
        double r100314 = r100310 / r100313;
        return r100314;
}

double f(double x) {
        double r100315 = x;
        double r100316 = -64270072.71622895;
        bool r100317 = r100315 <= r100316;
        double r100318 = 454.92579415143206;
        bool r100319 = r100315 <= r100318;
        double r100320 = !r100319;
        bool r100321 = r100317 || r100320;
        double r100322 = 1.0;
        double r100323 = 5.0;
        double r100324 = pow(r100315, r100323);
        double r100325 = r100322 / r100324;
        double r100326 = 1.0;
        double r100327 = r100326 / r100315;
        double r100328 = 3.0;
        double r100329 = pow(r100315, r100328);
        double r100330 = r100322 / r100329;
        double r100331 = r100327 - r100330;
        double r100332 = r100325 + r100331;
        double r100333 = 6.0;
        double r100334 = pow(r100315, r100333);
        double r100335 = pow(r100322, r100328);
        double r100336 = r100334 + r100335;
        double r100337 = r100315 / r100336;
        double r100338 = r100315 * r100315;
        double r100339 = r100338 * r100338;
        double r100340 = r100322 * r100322;
        double r100341 = r100338 * r100322;
        double r100342 = r100340 - r100341;
        double r100343 = r100339 + r100342;
        double r100344 = r100337 * r100343;
        double r100345 = r100321 ? r100332 : r100344;
        return r100345;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -64270072.71622895 or 454.92579415143206 < x

    1. Initial program 31.2

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

      \[\leadsto \frac{x}{\color{blue}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}}\]
    4. Applied *-un-lft-identity31.2

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}\]
    5. Applied times-frac31.1

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}}\]
    6. Simplified31.1

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\]
    7. Simplified31.1

      \[\leadsto \frac{1}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}} \cdot \color{blue}{\frac{x}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}}\]
    8. 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}}}\]
    9. Simplified0.0

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

    if -64270072.71622895 < x < 454.92579415143206

    1. Initial program 0.0

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

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

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

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

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

Reproduce

herbie shell --seed 2019212 +o rules:numerics
(FPCore (x)
  :name "x / (x^2 + 1)"
  :precision binary64

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

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