Average Error: 15.3 → 0.0
Time: 12.4s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1117.275627842930816768785007297992706299:\\ \;\;\;\;\frac{1}{x} - \left(\frac{1}{x \cdot \left(x \cdot x\right)} - \frac{1}{{x}^{5}}\right)\\ \mathbf{elif}\;x \le 207140092.4427032172679901123046875:\\ \;\;\;\;\left(1 - x \cdot x\right) \cdot \frac{x}{\left(1 + x \cdot x\right) \cdot \left(1 - x \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} - \left(\frac{1}{x \cdot \left(x \cdot x\right)} - \frac{1}{{x}^{5}}\right)\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -1117.275627842930816768785007297992706299:\\
\;\;\;\;\frac{1}{x} - \left(\frac{1}{x \cdot \left(x \cdot x\right)} - \frac{1}{{x}^{5}}\right)\\

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

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

\end{array}
double f(double x) {
        double r3479118 = x;
        double r3479119 = r3479118 * r3479118;
        double r3479120 = 1.0;
        double r3479121 = r3479119 + r3479120;
        double r3479122 = r3479118 / r3479121;
        return r3479122;
}

double f(double x) {
        double r3479123 = x;
        double r3479124 = -1117.2756278429308;
        bool r3479125 = r3479123 <= r3479124;
        double r3479126 = 1.0;
        double r3479127 = r3479126 / r3479123;
        double r3479128 = 1.0;
        double r3479129 = r3479123 * r3479123;
        double r3479130 = r3479123 * r3479129;
        double r3479131 = r3479128 / r3479130;
        double r3479132 = 5.0;
        double r3479133 = pow(r3479123, r3479132);
        double r3479134 = r3479128 / r3479133;
        double r3479135 = r3479131 - r3479134;
        double r3479136 = r3479127 - r3479135;
        double r3479137 = 207140092.44270322;
        bool r3479138 = r3479123 <= r3479137;
        double r3479139 = r3479128 - r3479129;
        double r3479140 = r3479128 + r3479129;
        double r3479141 = r3479140 * r3479139;
        double r3479142 = r3479123 / r3479141;
        double r3479143 = r3479139 * r3479142;
        double r3479144 = r3479138 ? r3479143 : r3479136;
        double r3479145 = r3479125 ? r3479136 : r3479144;
        return r3479145;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -1117.2756278429308 or 207140092.44270322 < x

    1. Initial program 30.9

      \[\frac{x}{x \cdot x + 1}\]
    2. 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}}}\]
    3. Simplified0.0

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

    if -1117.2756278429308 < x < 207140092.44270322

    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 *-un-lft-identity0.0

      \[\leadsto \frac{\frac{x}{\sqrt{x \cdot x + 1}}}{\sqrt{\color{blue}{1 \cdot \left(x \cdot x + 1\right)}}}\]
    7. Applied sqrt-prod0.0

      \[\leadsto \frac{\frac{x}{\sqrt{x \cdot x + 1}}}{\color{blue}{\sqrt{1} \cdot \sqrt{x \cdot x + 1}}}\]
    8. Applied div-inv0.0

      \[\leadsto \frac{\color{blue}{x \cdot \frac{1}{\sqrt{x \cdot x + 1}}}}{\sqrt{1} \cdot \sqrt{x \cdot x + 1}}\]
    9. Applied times-frac0.0

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

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

      \[\leadsto x \cdot \color{blue}{\frac{1}{1 + x \cdot x}}\]
    12. Using strategy rm
    13. Applied flip-+0.0

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

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

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

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

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

Reproduce

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

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

  (/ x (+ (* x x) 1.0)))