Average Error: 15.2 → 0.0
Time: 13.7s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -955471611474.0786:\\ \;\;\;\;\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 129599.43046274735:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \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 -955471611474.0786:\\
\;\;\;\;\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 129599.43046274735:\\
\;\;\;\;\frac{x}{1 + x \cdot x}\\

\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 r1626875 = x;
        double r1626876 = r1626875 * r1626875;
        double r1626877 = 1.0;
        double r1626878 = r1626876 + r1626877;
        double r1626879 = r1626875 / r1626878;
        return r1626879;
}

double f(double x) {
        double r1626880 = x;
        double r1626881 = -955471611474.0786;
        bool r1626882 = r1626880 <= r1626881;
        double r1626883 = 1.0;
        double r1626884 = r1626883 / r1626880;
        double r1626885 = r1626880 * r1626880;
        double r1626886 = r1626884 / r1626885;
        double r1626887 = r1626885 * r1626880;
        double r1626888 = r1626887 * r1626885;
        double r1626889 = r1626883 / r1626888;
        double r1626890 = r1626886 - r1626889;
        double r1626891 = r1626884 - r1626890;
        double r1626892 = 129599.43046274735;
        bool r1626893 = r1626880 <= r1626892;
        double r1626894 = r1626883 + r1626885;
        double r1626895 = r1626880 / r1626894;
        double r1626896 = r1626893 ? r1626895 : r1626891;
        double r1626897 = r1626882 ? r1626891 : r1626896;
        return r1626897;
}

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 < -955471611474.0786 or 129599.43046274735 < x

    1. Initial program 30.7

      \[\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 -955471611474.0786 < x < 129599.43046274735

    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 -955471611474.0786:\\ \;\;\;\;\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 129599.43046274735:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \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 2019135 
(FPCore (x)
  :name "x / (x^2 + 1)"

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

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