Average Error: 15.1 → 0.0
Time: 15.2s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -484064.81338059285:\\ \;\;\;\;\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 8137.871959944802:\\ \;\;\;\;\left(x \cdot x - 1\right) \cdot \frac{x}{-1 + \left(x \cdot x\right) \cdot \left(x \cdot x\right)}\\ \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 -484064.81338059285:\\
\;\;\;\;\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 8137.871959944802:\\
\;\;\;\;\left(x \cdot x - 1\right) \cdot \frac{x}{-1 + \left(x \cdot x\right) \cdot \left(x \cdot x\right)}\\

\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 r2654526 = x;
        double r2654527 = r2654526 * r2654526;
        double r2654528 = 1.0;
        double r2654529 = r2654527 + r2654528;
        double r2654530 = r2654526 / r2654529;
        return r2654530;
}

double f(double x) {
        double r2654531 = x;
        double r2654532 = -484064.81338059285;
        bool r2654533 = r2654531 <= r2654532;
        double r2654534 = 1.0;
        double r2654535 = r2654534 / r2654531;
        double r2654536 = r2654531 * r2654531;
        double r2654537 = r2654535 / r2654536;
        double r2654538 = r2654535 - r2654537;
        double r2654539 = r2654536 * r2654531;
        double r2654540 = r2654539 * r2654536;
        double r2654541 = r2654534 / r2654540;
        double r2654542 = r2654538 + r2654541;
        double r2654543 = 8137.871959944802;
        bool r2654544 = r2654531 <= r2654543;
        double r2654545 = r2654536 - r2654534;
        double r2654546 = -1.0;
        double r2654547 = r2654536 * r2654536;
        double r2654548 = r2654546 + r2654547;
        double r2654549 = r2654531 / r2654548;
        double r2654550 = r2654545 * r2654549;
        double r2654551 = r2654544 ? r2654550 : r2654542;
        double r2654552 = r2654533 ? r2654542 : r2654551;
        return r2654552;
}

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 < -484064.81338059285 or 8137.871959944802 < x

    1. Initial program 30.8

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

      \[\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/47.8

      \[\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. Simplified47.8

      \[\leadsto \color{blue}{\frac{x}{-1 + \left(x \cdot x\right) \cdot \left(x \cdot x\right)}} \cdot \left(x \cdot x - 1\right)\]
    6. Using strategy rm
    7. Applied flip--48.2

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

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

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

      \[\leadsto \color{blue}{\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{{x}^{3}}}\]
    11. 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 -484064.81338059285 < x < 8137.871959944802

    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}{-1 + \left(x \cdot x\right) \cdot \left(x \cdot x\right)}} \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 -484064.81338059285:\\ \;\;\;\;\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 8137.871959944802:\\ \;\;\;\;\left(x \cdot x - 1\right) \cdot \frac{x}{-1 + \left(x \cdot x\right) \cdot \left(x \cdot x\right)}\\ \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 2019151 
(FPCore (x)
  :name "x / (x^2 + 1)"

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

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