Average Error: 14.8 → 0.0
Time: 30.2s
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 r6162858 = x;
        double r6162859 = r6162858 * r6162858;
        double r6162860 = 1.0;
        double r6162861 = r6162859 + r6162860;
        double r6162862 = r6162858 / r6162861;
        return r6162862;
}

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

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)))