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

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

\end{array}
double f(double x) {
        double r40558 = x;
        double r40559 = r40558 * r40558;
        double r40560 = 1.0;
        double r40561 = r40559 + r40560;
        double r40562 = r40558 / r40561;
        return r40562;
}

double f(double x) {
        double r40563 = x;
        double r40564 = -3.83760315849384e+24;
        bool r40565 = r40563 <= r40564;
        double r40566 = 476.33445129265164;
        bool r40567 = r40563 <= r40566;
        double r40568 = !r40567;
        bool r40569 = r40565 || r40568;
        double r40570 = 1.0;
        double r40571 = r40570 / r40563;
        double r40572 = 1.0;
        double r40573 = 5.0;
        double r40574 = pow(r40563, r40573);
        double r40575 = r40572 / r40574;
        double r40576 = 3.0;
        double r40577 = pow(r40563, r40576);
        double r40578 = r40572 / r40577;
        double r40579 = r40575 - r40578;
        double r40580 = r40571 + r40579;
        double r40581 = r40563 * r40563;
        double r40582 = r40581 - r40572;
        double r40583 = r40563 * r40577;
        double r40584 = r40572 * r40572;
        double r40585 = r40583 - r40584;
        double r40586 = r40563 / r40585;
        double r40587 = r40582 * r40586;
        double r40588 = r40569 ? r40580 : r40587;
        return r40588;
}

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 < -3.83760315849384e+24 or 476.33445129265164 < x

    1. Initial program 31.5

      \[\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}{\left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right) + \frac{1}{x}}\]

    if -3.83760315849384e+24 < x < 476.33445129265164

    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}{{x}^{3} \cdot x - 1 \cdot 1}} \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 -3837603158493840185229312 \lor \neg \left(x \le 476.3344512926516358675144147127866744995\right):\\ \;\;\;\;\frac{1}{x} + \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x - 1\right) \cdot \frac{x}{x \cdot {x}^{3} - 1 \cdot 1}\\ \end{array}\]

Reproduce

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

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

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