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

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

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

\end{array}
double f(double x) {
        double r1660518 = x;
        double r1660519 = r1660518 * r1660518;
        double r1660520 = 1.0;
        double r1660521 = r1660519 + r1660520;
        double r1660522 = r1660518 / r1660521;
        return r1660522;
}

double f(double x) {
        double r1660523 = x;
        double r1660524 = -3717825341653.7866;
        bool r1660525 = r1660523 <= r1660524;
        double r1660526 = 1.0;
        double r1660527 = r1660526 / r1660523;
        double r1660528 = r1660523 * r1660523;
        double r1660529 = r1660527 / r1660528;
        double r1660530 = r1660528 * r1660523;
        double r1660531 = r1660530 * r1660528;
        double r1660532 = r1660526 / r1660531;
        double r1660533 = r1660529 - r1660532;
        double r1660534 = r1660527 - r1660533;
        double r1660535 = 117441.38660009087;
        bool r1660536 = r1660523 <= r1660535;
        double r1660537 = r1660528 * r1660528;
        double r1660538 = r1660537 - r1660526;
        double r1660539 = r1660523 / r1660538;
        double r1660540 = r1660528 - r1660526;
        double r1660541 = r1660539 * r1660540;
        double r1660542 = r1660536 ? r1660541 : r1660534;
        double r1660543 = r1660525 ? r1660534 : r1660542;
        return r1660543;
}

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 < -3717825341653.7866 or 117441.38660009087 < x

    1. Initial program 31.1

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

    if -3717825341653.7866 < x < 117441.38660009087

    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(x \cdot x\right) \cdot \left(x \cdot x\right) - 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 -3717825341653.7866:\\ \;\;\;\;\frac{1}{x} - \left(\frac{\frac{1}{x}}{x \cdot x} - \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\right)\\ \mathbf{elif}\;x \le 117441.38660009087:\\ \;\;\;\;\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1} \cdot \left(x \cdot x - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} - \left(\frac{\frac{1}{x}}{x \cdot x} - \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\right)\\ \end{array}\]

Reproduce

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

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

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