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

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

\end{array}
double f(double x) {
        double r70012 = x;
        double r70013 = r70012 * r70012;
        double r70014 = 1.0;
        double r70015 = r70013 + r70014;
        double r70016 = r70012 / r70015;
        return r70016;
}

double f(double x) {
        double r70017 = x;
        double r70018 = -4056411831943571.5;
        bool r70019 = r70017 <= r70018;
        double r70020 = 426.5716298019804;
        bool r70021 = r70017 <= r70020;
        double r70022 = !r70021;
        bool r70023 = r70019 || r70022;
        double r70024 = 1.0;
        double r70025 = r70024 / r70017;
        double r70026 = 1.0;
        double r70027 = 5.0;
        double r70028 = pow(r70017, r70027);
        double r70029 = r70026 / r70028;
        double r70030 = 3.0;
        double r70031 = pow(r70017, r70030);
        double r70032 = r70026 / r70031;
        double r70033 = r70029 - r70032;
        double r70034 = r70025 + r70033;
        double r70035 = r70017 * r70031;
        double r70036 = r70026 * r70026;
        double r70037 = r70035 - r70036;
        double r70038 = r70017 / r70037;
        double r70039 = r70017 * r70017;
        double r70040 = r70039 - r70026;
        double r70041 = r70038 * r70040;
        double r70042 = r70023 ? r70034 : r70041;
        return r70042;
}

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 < -4056411831943571.5 or 426.5716298019804 < x

    1. Initial program 31.1

      \[\frac{x}{x \cdot x + 1}\]
    2. 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}}}\]
    3. Simplified0.0

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

    if -4056411831943571.5 < x < 426.5716298019804

    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}{x \cdot {x}^{3} - 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 -4056411831943571.5 \lor \neg \left(x \le 426.571629801980407137307338416576385498\right):\\ \;\;\;\;\frac{1}{x} + \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot {x}^{3} - 1 \cdot 1} \cdot \left(x \cdot x - 1\right)\\ \end{array}\]

Reproduce

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

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

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