Average Error: 15.4 → 0.0
Time: 9.1s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -597812.2530236238:\\ \;\;\;\;\left(\frac{1}{x} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{{x}^{5}}\\ \mathbf{elif}\;x \le 471.29821069866506:\\ \;\;\;\;\left(\left(1 - x \cdot x\right) + \left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \frac{x}{\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{{x}^{5}}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -597812.2530236238:\\
\;\;\;\;\left(\frac{1}{x} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{{x}^{5}}\\

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

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

\end{array}
double f(double x) {
        double r2741400 = x;
        double r2741401 = r2741400 * r2741400;
        double r2741402 = 1.0;
        double r2741403 = r2741401 + r2741402;
        double r2741404 = r2741400 / r2741403;
        return r2741404;
}

double f(double x) {
        double r2741405 = x;
        double r2741406 = -597812.2530236238;
        bool r2741407 = r2741405 <= r2741406;
        double r2741408 = 1.0;
        double r2741409 = r2741408 / r2741405;
        double r2741410 = r2741405 * r2741405;
        double r2741411 = r2741410 * r2741405;
        double r2741412 = r2741408 / r2741411;
        double r2741413 = r2741409 - r2741412;
        double r2741414 = 5.0;
        double r2741415 = pow(r2741405, r2741414);
        double r2741416 = r2741408 / r2741415;
        double r2741417 = r2741413 + r2741416;
        double r2741418 = 471.29821069866506;
        bool r2741419 = r2741405 <= r2741418;
        double r2741420 = r2741408 - r2741410;
        double r2741421 = r2741410 * r2741410;
        double r2741422 = r2741420 + r2741421;
        double r2741423 = r2741410 * r2741421;
        double r2741424 = r2741423 + r2741408;
        double r2741425 = r2741405 / r2741424;
        double r2741426 = r2741422 * r2741425;
        double r2741427 = r2741419 ? r2741426 : r2741417;
        double r2741428 = r2741407 ? r2741417 : r2741427;
        return r2741428;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.4
Target0.1
Herbie0.0
\[\frac{1}{x + \frac{1}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -597812.2530236238 or 471.29821069866506 < x

    1. Initial program 30.9

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

    if -597812.2530236238 < x < 471.29821069866506

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

Reproduce

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

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

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