Average Error: 14.6 → 0.0
Time: 7.8s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.0077749570590921 \cdot 10^{22} \lor \neg \left(x \le 444.820639026829951\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 -1.0077749570590921 \cdot 10^{22} \lor \neg \left(x \le 444.820639026829951\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 r53499 = x;
        double r53500 = r53499 * r53499;
        double r53501 = 1.0;
        double r53502 = r53500 + r53501;
        double r53503 = r53499 / r53502;
        return r53503;
}

double f(double x) {
        double r53504 = x;
        double r53505 = -1.007774957059092e+22;
        bool r53506 = r53504 <= r53505;
        double r53507 = 444.82063902682995;
        bool r53508 = r53504 <= r53507;
        double r53509 = !r53508;
        bool r53510 = r53506 || r53509;
        double r53511 = 1.0;
        double r53512 = r53511 / r53504;
        double r53513 = 1.0;
        double r53514 = 5.0;
        double r53515 = pow(r53504, r53514);
        double r53516 = r53513 / r53515;
        double r53517 = 3.0;
        double r53518 = pow(r53504, r53517);
        double r53519 = r53513 / r53518;
        double r53520 = r53516 - r53519;
        double r53521 = r53512 + r53520;
        double r53522 = r53504 * r53518;
        double r53523 = r53513 * r53513;
        double r53524 = r53522 - r53523;
        double r53525 = r53504 / r53524;
        double r53526 = r53504 * r53504;
        double r53527 = r53526 - r53513;
        double r53528 = r53525 * r53527;
        double r53529 = r53510 ? r53521 : r53528;
        return r53529;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -1.007774957059092e+22 or 444.82063902682995 < x

    1. Initial program 30.5

      \[\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 -1.007774957059092e+22 < x < 444.82063902682995

    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 -1.0077749570590921 \cdot 10^{22} \lor \neg \left(x \le 444.820639026829951\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 2019198 
(FPCore (x)
  :name "x / (x^2 + 1)"

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

  (/ x (+ (* x x) 1.0)))