Average Error: 14.8 → 0.0
Time: 30.5s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.004441307503856 \cdot 10^{+41}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \mathbf{elif}\;x \le 15952.080980852888:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -1.004441307503856 \cdot 10^{+41}:\\
\;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\

\mathbf{elif}\;x \le 15952.080980852888:\\
\;\;\;\;\frac{x}{1 + x \cdot x}\\

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

\end{array}
double f(double x) {
        double r6162853 = x;
        double r6162854 = r6162853 * r6162853;
        double r6162855 = 1.0;
        double r6162856 = r6162854 + r6162855;
        double r6162857 = r6162853 / r6162856;
        return r6162857;
}

double f(double x) {
        double r6162858 = x;
        double r6162859 = -1.004441307503856e+41;
        bool r6162860 = r6162858 <= r6162859;
        double r6162861 = 1.0;
        double r6162862 = 5.0;
        double r6162863 = pow(r6162858, r6162862);
        double r6162864 = r6162861 / r6162863;
        double r6162865 = r6162861 / r6162858;
        double r6162866 = r6162864 + r6162865;
        double r6162867 = r6162858 * r6162858;
        double r6162868 = r6162867 * r6162858;
        double r6162869 = r6162861 / r6162868;
        double r6162870 = r6162866 - r6162869;
        double r6162871 = 15952.080980852888;
        bool r6162872 = r6162858 <= r6162871;
        double r6162873 = r6162861 + r6162867;
        double r6162874 = r6162858 / r6162873;
        double r6162875 = r6162872 ? r6162874 : r6162870;
        double r6162876 = r6162860 ? r6162870 : r6162875;
        return r6162876;
}

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.004441307503856e+41 or 15952.080980852888 < x

    1. Initial program 31.9

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

    if -1.004441307503856e+41 < x < 15952.080980852888

    1. Initial program 0.0

      \[\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 -1.004441307503856 \cdot 10^{+41}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \mathbf{elif}\;x \le 15952.080980852888:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \end{array}\]

Reproduce

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

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

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