Average Error: 15.0 → 0.1
Time: 4.8s
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}^{5}} + \frac{1}{x}\right) - \frac{1}{{x}^{3}}\\ \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}^{5}} + \frac{1}{x}\right) - \frac{1}{{x}^{3}}\\

\end{array}
double f(double x) {
        double r61825 = x;
        double r61826 = r61825 * r61825;
        double r61827 = 1.0;
        double r61828 = r61826 + r61827;
        double r61829 = r61825 / r61828;
        return r61829;
}

double f(double x) {
        double r61830 = x;
        double r61831 = r61830 * r61830;
        double r61832 = 1.0;
        double r61833 = r61831 + r61832;
        double r61834 = r61830 / r61833;
        double r61835 = -4.021132589907752e-307;
        bool r61836 = r61834 <= r61835;
        double r61837 = -0.0;
        bool r61838 = r61834 <= r61837;
        double r61839 = !r61838;
        bool r61840 = r61836 || r61839;
        double r61841 = 1.0;
        double r61842 = sqrt(r61833);
        double r61843 = r61841 / r61842;
        double r61844 = r61830 / r61842;
        double r61845 = r61843 * r61844;
        double r61846 = 5.0;
        double r61847 = pow(r61830, r61846);
        double r61848 = r61832 / r61847;
        double r61849 = r61841 / r61830;
        double r61850 = r61848 + r61849;
        double r61851 = 3.0;
        double r61852 = pow(r61830, r61851);
        double r61853 = r61832 / r61852;
        double r61854 = r61850 - r61853;
        double r61855 = r61840 ? r61845 : r61854;
        return r61855;
}

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. 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}}}\]
    3. Simplified0.3

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