Average Error: 15.3 → 0.0
Time: 39.7s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.198818778934885 \cdot 10^{+16}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \mathbf{elif}\;x \le 12790649.36660592:\\ \;\;\;\;\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1} \cdot \left(x \cdot x - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -6.198818778934885 \cdot 10^{+16}:\\
\;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\

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

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

\end{array}
double f(double x) {
        double r5356269 = x;
        double r5356270 = r5356269 * r5356269;
        double r5356271 = 1.0;
        double r5356272 = r5356270 + r5356271;
        double r5356273 = r5356269 / r5356272;
        return r5356273;
}

double f(double x) {
        double r5356274 = x;
        double r5356275 = -6.198818778934885e+16;
        bool r5356276 = r5356274 <= r5356275;
        double r5356277 = 1.0;
        double r5356278 = 5.0;
        double r5356279 = pow(r5356274, r5356278);
        double r5356280 = r5356277 / r5356279;
        double r5356281 = r5356277 / r5356274;
        double r5356282 = r5356280 + r5356281;
        double r5356283 = r5356274 * r5356274;
        double r5356284 = r5356283 * r5356274;
        double r5356285 = r5356277 / r5356284;
        double r5356286 = r5356282 - r5356285;
        double r5356287 = 12790649.36660592;
        bool r5356288 = r5356274 <= r5356287;
        double r5356289 = r5356283 * r5356283;
        double r5356290 = r5356289 - r5356277;
        double r5356291 = r5356274 / r5356290;
        double r5356292 = r5356283 - r5356277;
        double r5356293 = r5356291 * r5356292;
        double r5356294 = r5356288 ? r5356293 : r5356286;
        double r5356295 = r5356276 ? r5356286 : r5356294;
        return r5356295;
}

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 < -6.198818778934885e+16 or 12790649.36660592 < x

    1. Initial program 31.6

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

    if -6.198818778934885e+16 < x < 12790649.36660592

    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)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -6.198818778934885 \cdot 10^{+16}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \mathbf{elif}\;x \le 12790649.36660592:\\ \;\;\;\;\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1} \cdot \left(x \cdot x - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \end{array}\]

Reproduce

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

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

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