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

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

\end{array}
double f(double x) {
        double r42390 = x;
        double r42391 = r42390 * r42390;
        double r42392 = 1.0;
        double r42393 = r42391 + r42392;
        double r42394 = r42390 / r42393;
        return r42394;
}

double f(double x) {
        double r42395 = x;
        double r42396 = -1.2032692145665368e+31;
        bool r42397 = r42395 <= r42396;
        double r42398 = 470.1828671092737;
        bool r42399 = r42395 <= r42398;
        double r42400 = !r42399;
        bool r42401 = r42397 || r42400;
        double r42402 = 1.0;
        double r42403 = 5.0;
        double r42404 = pow(r42395, r42403);
        double r42405 = r42402 / r42404;
        double r42406 = 1.0;
        double r42407 = r42406 / r42395;
        double r42408 = r42405 + r42407;
        double r42409 = 3.0;
        double r42410 = pow(r42395, r42409);
        double r42411 = r42402 / r42410;
        double r42412 = r42408 - r42411;
        double r42413 = r42395 * r42395;
        double r42414 = r42413 + r42402;
        double r42415 = r42395 / r42414;
        double r42416 = r42406 * r42415;
        double r42417 = r42401 ? r42412 : r42416;
        return r42417;
}

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 < -1.2032692145665368e+31 or 470.1828671092737 < x

    1. Initial program 31.6

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}}\]
    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}{\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{{x}^{3}}}\]

    if -1.2032692145665368e+31 < x < 470.1828671092737

    1. Initial program 0.0

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

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

      \[\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}}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity0.0

      \[\leadsto \frac{1}{\sqrt{\color{blue}{1 \cdot \left(x \cdot x + 1\right)}}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\]
    8. Applied sqrt-prod0.0

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1} \cdot \sqrt{x \cdot x + 1}}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\]
    9. Applied add-cube-cbrt0.0

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\sqrt{1} \cdot \sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\]
    10. Applied times-frac0.0

      \[\leadsto \color{blue}{\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{1}} \cdot \frac{\sqrt[3]{1}}{\sqrt{x \cdot x + 1}}\right)} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\]
    11. Applied associate-*l*0.0

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{1}} \cdot \left(\frac{\sqrt[3]{1}}{\sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\right)}\]
    12. Simplified0.0

      \[\leadsto \frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt{1}} \cdot \color{blue}{\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 -12032692145665368408206631501824 \lor \neg \left(x \le 470.1828671092736726677685510367155075073\right):\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{x}{x \cdot x + 1}\\ \end{array}\]

Reproduce

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

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

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