Average Error: 14.9 → 0.0
Time: 16.1s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -236646845.7820609:\\ \;\;\;\;\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 465.1323802232794:\\ \;\;\;\;\frac{x}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right) + 1} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left(1 - x \cdot x\right)\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 -236646845.7820609:\\
\;\;\;\;\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 465.1323802232794:\\
\;\;\;\;\frac{x}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right) + 1} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left(1 - x \cdot x\right)\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 r1509475 = x;
        double r1509476 = r1509475 * r1509475;
        double r1509477 = 1.0;
        double r1509478 = r1509476 + r1509477;
        double r1509479 = r1509475 / r1509478;
        return r1509479;
}

double f(double x) {
        double r1509480 = x;
        double r1509481 = -236646845.7820609;
        bool r1509482 = r1509480 <= r1509481;
        double r1509483 = 1.0;
        double r1509484 = r1509483 / r1509480;
        double r1509485 = r1509480 * r1509480;
        double r1509486 = r1509484 / r1509485;
        double r1509487 = r1509484 - r1509486;
        double r1509488 = r1509485 * r1509480;
        double r1509489 = r1509488 * r1509485;
        double r1509490 = r1509483 / r1509489;
        double r1509491 = r1509487 + r1509490;
        double r1509492 = 465.1323802232794;
        bool r1509493 = r1509480 <= r1509492;
        double r1509494 = r1509488 * r1509488;
        double r1509495 = r1509494 + r1509483;
        double r1509496 = r1509480 / r1509495;
        double r1509497 = r1509485 * r1509485;
        double r1509498 = r1509483 - r1509485;
        double r1509499 = r1509497 + r1509498;
        double r1509500 = r1509496 * r1509499;
        double r1509501 = r1509493 ? r1509500 : r1509491;
        double r1509502 = r1509482 ? r1509491 : r1509501;
        return r1509502;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -236646845.7820609 or 465.1323802232794 < x

    1. Initial program 30.5

      \[\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 -236646845.7820609 < x < 465.1323802232794

    1. Initial program 0.0

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

      \[\leadsto \frac{x}{\color{blue}{\frac{{\left(x \cdot x\right)}^{3} + {1}^{3}}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left(1 \cdot 1 - \left(x \cdot x\right) \cdot 1\right)}}}\]
    4. Applied associate-/r/0.0

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

      \[\leadsto \color{blue}{\frac{x}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right) + 1}} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left(1 \cdot 1 - \left(x \cdot x\right) \cdot 1\right)\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -236646845.7820609:\\ \;\;\;\;\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 465.1323802232794:\\ \;\;\;\;\frac{x}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right) + 1} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left(1 - x \cdot x\right)\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 2019149 
(FPCore (x)
  :name "x / (x^2 + 1)"

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

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