Average Error: 15.0 → 0.1
Time: 1.9s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x}{x \cdot x + 1} \le -4.02113258990775235 \cdot 10^{-307} \lor \neg \left(\frac{x}{x \cdot x + 1} \le -0.0\right):\\ \;\;\;\;\frac{1}{\sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - 1 \cdot \frac{1}{{x}^{3}}\right) + \frac{1}{{x}^{5}}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;\frac{x}{x \cdot x + 1} \le -4.02113258990775235 \cdot 10^{-307} \lor \neg \left(\frac{x}{x \cdot x + 1} \le -0.0\right):\\
\;\;\;\;\frac{1}{\sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\\

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

\end{array}
double f(double x) {
        double r74503 = x;
        double r74504 = r74503 * r74503;
        double r74505 = 1.0;
        double r74506 = r74504 + r74505;
        double r74507 = r74503 / r74506;
        return r74507;
}

double f(double x) {
        double r74508 = x;
        double r74509 = r74508 * r74508;
        double r74510 = 1.0;
        double r74511 = r74509 + r74510;
        double r74512 = r74508 / r74511;
        double r74513 = -4.021132589907752e-307;
        bool r74514 = r74512 <= r74513;
        double r74515 = -0.0;
        bool r74516 = r74512 <= r74515;
        double r74517 = !r74516;
        bool r74518 = r74514 || r74517;
        double r74519 = 1.0;
        double r74520 = sqrt(r74511);
        double r74521 = r74519 / r74520;
        double r74522 = r74508 / r74520;
        double r74523 = r74521 * r74522;
        double r74524 = r74519 / r74508;
        double r74525 = 3.0;
        double r74526 = pow(r74508, r74525);
        double r74527 = r74519 / r74526;
        double r74528 = r74510 * r74527;
        double r74529 = r74524 - r74528;
        double r74530 = 5.0;
        double r74531 = pow(r74508, r74530);
        double r74532 = r74510 / r74531;
        double r74533 = r74529 + r74532;
        double r74534 = r74518 ? r74523 : r74533;
        return r74534;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if (/ x (+ (* x x) 1.0)) < -4.021132589907752e-307 or -0.0 < (/ x (+ (* x x) 1.0))

    1. Initial program 0.1

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.1

      \[\leadsto \frac{x}{\color{blue}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}}\]
    4. Applied *-un-lft-identity0.1

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}\]
    5. Applied times-frac0.0

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}}\]

    if -4.021132589907752e-307 < (/ x (+ (* x x) 1.0)) < -0.0

    1. Initial program 59.3

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt59.3

      \[\leadsto \frac{x}{\color{blue}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}}\]
    4. Applied *-un-lft-identity59.3

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}\]
    5. Applied times-frac59.3

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}}\]
    6. Taylor expanded around inf 0.3

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

      \[\leadsto \color{blue}{\left(\frac{1}{x} - 1 \cdot \frac{1}{{x}^{3}}\right) + \frac{1}{{x}^{5}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

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

Reproduce

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

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

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