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

\mathbf{else}:\\
\;\;\;\;\frac{x}{x \cdot x + 1}\\

\end{array}
double f(double x) {
        double r109435 = x;
        double r109436 = r109435 * r109435;
        double r109437 = 1.0;
        double r109438 = r109436 + r109437;
        double r109439 = r109435 / r109438;
        return r109439;
}

double f(double x) {
        double r109440 = x;
        double r109441 = -34917646116603.27;
        bool r109442 = r109440 <= r109441;
        double r109443 = 14991943.206268162;
        bool r109444 = r109440 <= r109443;
        double r109445 = !r109444;
        bool r109446 = r109442 || r109445;
        double r109447 = 1.0;
        double r109448 = r109447 / r109440;
        double r109449 = 1.0;
        double r109450 = 5.0;
        double r109451 = pow(r109440, r109450);
        double r109452 = r109449 / r109451;
        double r109453 = 3.0;
        double r109454 = pow(r109440, r109453);
        double r109455 = r109449 / r109454;
        double r109456 = r109452 - r109455;
        double r109457 = r109448 + r109456;
        double r109458 = r109440 * r109440;
        double r109459 = r109458 + r109449;
        double r109460 = r109440 / r109459;
        double r109461 = r109446 ? r109457 : r109460;
        return r109461;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -34917646116603.27 or 14991943.206268162 < x

    1. Initial program 30.7

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

      \[\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/49.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. Simplified49.0

      \[\leadsto \color{blue}{\frac{x}{\mathsf{fma}\left(-1, 1, {x}^{4}\right)}} \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}}}\]
    7. Simplified0.0

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

    if -34917646116603.27 < x < 14991943.206268162

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -34917646116603.26953125 \lor \neg \left(x \le 14991943.2062681615352630615234375\right):\\ \;\;\;\;\frac{1}{x} + \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot x + 1}\\ \end{array}\]

Reproduce

herbie shell --seed 2019362 +o rules:numerics
(FPCore (x)
  :name "x / (x^2 + 1)"
  :precision binary64

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

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