Average Error: 15.2 → 0.0
Time: 15.1s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -16729132342.41712:\\ \;\;\;\;\frac{1}{x} - \left(\frac{\frac{1}{x}}{x \cdot x} - \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\right)\\ \mathbf{elif}\;x \le 419.2574900762654:\\ \;\;\;\;\frac{\sqrt{1 - \left(x \cdot x - \left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}{\sqrt{1 + x \cdot x}} \cdot \frac{x}{\sqrt{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right) + 1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} - \left(\frac{\frac{1}{x}}{x \cdot x} - \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\right)\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -16729132342.41712:\\
\;\;\;\;\frac{1}{x} - \left(\frac{\frac{1}{x}}{x \cdot x} - \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\right)\\

\mathbf{elif}\;x \le 419.2574900762654:\\
\;\;\;\;\frac{\sqrt{1 - \left(x \cdot x - \left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}{\sqrt{1 + x \cdot x}} \cdot \frac{x}{\sqrt{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right) + 1}}\\

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

\end{array}
double f(double x) {
        double r1845832 = x;
        double r1845833 = r1845832 * r1845832;
        double r1845834 = 1.0;
        double r1845835 = r1845833 + r1845834;
        double r1845836 = r1845832 / r1845835;
        return r1845836;
}

double f(double x) {
        double r1845837 = x;
        double r1845838 = -16729132342.41712;
        bool r1845839 = r1845837 <= r1845838;
        double r1845840 = 1.0;
        double r1845841 = r1845840 / r1845837;
        double r1845842 = r1845837 * r1845837;
        double r1845843 = r1845841 / r1845842;
        double r1845844 = r1845842 * r1845837;
        double r1845845 = r1845844 * r1845842;
        double r1845846 = r1845840 / r1845845;
        double r1845847 = r1845843 - r1845846;
        double r1845848 = r1845841 - r1845847;
        double r1845849 = 419.2574900762654;
        bool r1845850 = r1845837 <= r1845849;
        double r1845851 = r1845842 * r1845842;
        double r1845852 = r1845842 - r1845851;
        double r1845853 = r1845840 - r1845852;
        double r1845854 = sqrt(r1845853);
        double r1845855 = r1845840 + r1845842;
        double r1845856 = sqrt(r1845855);
        double r1845857 = r1845854 / r1845856;
        double r1845858 = r1845844 * r1845844;
        double r1845859 = r1845858 + r1845840;
        double r1845860 = sqrt(r1845859);
        double r1845861 = r1845837 / r1845860;
        double r1845862 = r1845857 * r1845861;
        double r1845863 = r1845850 ? r1845862 : r1845848;
        double r1845864 = r1845839 ? r1845848 : r1845863;
        return r1845864;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -16729132342.41712 or 419.2574900762654 < x

    1. Initial program 30.4

      \[\frac{x}{x \cdot x + 1}\]
    2. Taylor expanded around inf 0.0

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

      \[\leadsto \color{blue}{\frac{1}{x} - \left(\frac{\frac{1}{x}}{x \cdot x} - \frac{1}{\left(x \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)}\right)}\]

    if -16729132342.41712 < x < 419.2574900762654

    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 associate-/r*0.0

      \[\leadsto \color{blue}{\frac{\frac{x}{\sqrt{x \cdot x + 1}}}{\sqrt{x \cdot x + 1}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity0.0

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

      \[\leadsto \frac{\frac{x}{\sqrt{x \cdot x + 1}}}{\color{blue}{\sqrt{1} \cdot \sqrt{x \cdot x + 1}}}\]
    8. Applied flip3-+0.0

      \[\leadsto \frac{\frac{x}{\sqrt{\color{blue}{\frac{{\left(x \cdot x\right)}^{3} + {1}^{3}}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left(1 \cdot 1 - \left(x \cdot x\right) \cdot 1\right)}}}}}{\sqrt{1} \cdot \sqrt{x \cdot x + 1}}\]
    9. Applied sqrt-div0.0

      \[\leadsto \frac{\frac{x}{\color{blue}{\frac{\sqrt{{\left(x \cdot x\right)}^{3} + {1}^{3}}}{\sqrt{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left(1 \cdot 1 - \left(x \cdot x\right) \cdot 1\right)}}}}}{\sqrt{1} \cdot \sqrt{x \cdot x + 1}}\]
    10. Applied associate-/r/0.0

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -16729132342.41712:\\ \;\;\;\;\frac{1}{x} - \left(\frac{\frac{1}{x}}{x \cdot x} - \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\right)\\ \mathbf{elif}\;x \le 419.2574900762654:\\ \;\;\;\;\frac{\sqrt{1 - \left(x \cdot x - \left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}}{\sqrt{1 + x \cdot x}} \cdot \frac{x}{\sqrt{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right) + 1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} - \left(\frac{\frac{1}{x}}{x \cdot x} - \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\right)\\ \end{array}\]

Reproduce

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

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

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