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

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

\end{array}
double f(double x) {
        double r55530 = x;
        double r55531 = r55530 * r55530;
        double r55532 = 1.0;
        double r55533 = r55531 + r55532;
        double r55534 = r55530 / r55533;
        return r55534;
}

double f(double x) {
        double r55535 = x;
        double r55536 = -159825393.0444623;
        bool r55537 = r55535 <= r55536;
        double r55538 = 460.75784523236763;
        bool r55539 = r55535 <= r55538;
        double r55540 = !r55539;
        bool r55541 = r55537 || r55540;
        double r55542 = 1.0;
        double r55543 = 1.0;
        double r55544 = 5.0;
        double r55545 = pow(r55535, r55544);
        double r55546 = r55543 / r55545;
        double r55547 = r55542 * r55546;
        double r55548 = r55543 / r55535;
        double r55549 = r55547 + r55548;
        double r55550 = 3.0;
        double r55551 = pow(r55535, r55550);
        double r55552 = r55543 / r55551;
        double r55553 = r55542 * r55552;
        double r55554 = r55549 - r55553;
        double r55555 = r55542 * r55542;
        double r55556 = -r55555;
        double r55557 = 4.0;
        double r55558 = pow(r55535, r55557);
        double r55559 = r55556 + r55558;
        double r55560 = r55535 / r55559;
        double r55561 = r55535 * r55535;
        double r55562 = r55561 - r55542;
        double r55563 = r55560 * r55562;
        double r55564 = r55541 ? r55554 : r55563;
        return r55564;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.7
Target0.1
Herbie0.0
\[\frac{1}{x + \frac{1}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -159825393.0444623 or 460.75784523236763 < x

    1. Initial program 30.2

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied flip-+48.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/48.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. Simplified48.0

      \[\leadsto \color{blue}{\frac{x}{\left(-1 \cdot 1\right) + {x}^{4}}} \cdot \left(x \cdot x - 1\right)\]
    6. 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}}}\]

    if -159825393.0444623 < x < 460.75784523236763

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

Reproduce

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

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

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