Average Error: 15.4 → 0.0
Time: 15.1s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.3765989384353292 \cdot 10^{+154}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\\ \mathbf{elif}\;x \le 393.77334187402573:\\ \;\;\;\;\frac{x \cdot \frac{1}{\sqrt{1 + x \cdot x}}}{\sqrt{1 + x \cdot x}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -1.3765989384353292 \cdot 10^{+154}:\\
\;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\\

\mathbf{elif}\;x \le 393.77334187402573:\\
\;\;\;\;\frac{x \cdot \frac{1}{\sqrt{1 + x \cdot x}}}{\sqrt{1 + x \cdot x}}\\

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

\end{array}
double f(double x) {
        double r1747582 = x;
        double r1747583 = r1747582 * r1747582;
        double r1747584 = 1.0;
        double r1747585 = r1747583 + r1747584;
        double r1747586 = r1747582 / r1747585;
        return r1747586;
}

double f(double x) {
        double r1747587 = x;
        double r1747588 = -1.3765989384353292e+154;
        bool r1747589 = r1747587 <= r1747588;
        double r1747590 = 1.0;
        double r1747591 = r1747590 / r1747587;
        double r1747592 = r1747587 * r1747587;
        double r1747593 = r1747591 / r1747592;
        double r1747594 = r1747591 - r1747593;
        double r1747595 = r1747592 * r1747587;
        double r1747596 = r1747595 * r1747592;
        double r1747597 = r1747590 / r1747596;
        double r1747598 = r1747594 + r1747597;
        double r1747599 = 393.77334187402573;
        bool r1747600 = r1747587 <= r1747599;
        double r1747601 = r1747590 + r1747592;
        double r1747602 = sqrt(r1747601);
        double r1747603 = r1747590 / r1747602;
        double r1747604 = r1747587 * r1747603;
        double r1747605 = r1747604 / r1747602;
        double r1747606 = r1747600 ? r1747605 : r1747598;
        double r1747607 = r1747589 ? r1747598 : r1747606;
        return r1747607;
}

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 < -1.3765989384353292e+154 or 393.77334187402573 < x

    1. Initial program 41.4

      \[\frac{x}{x \cdot x + 1}\]
    2. Taylor expanded around -inf 0.0

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

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

    if -1.3765989384353292e+154 < x < 393.77334187402573

    1. Initial program 0.1

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

      \[\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}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.3765989384353292 \cdot 10^{+154}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\\ \mathbf{elif}\;x \le 393.77334187402573:\\ \;\;\;\;\frac{x \cdot \frac{1}{\sqrt{1 + x \cdot x}}}{\sqrt{1 + x \cdot x}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\\ \end{array}\]

Reproduce

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

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

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