Average Error: 15.2 → 0.0
Time: 12.5s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2532354690659.384:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{x \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}\\ \mathbf{elif}\;x \le 520.1081709356233:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{x \cdot \left(\left(x \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 -2532354690659.384:\\
\;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{x \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}\\

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

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

\end{array}
double f(double x) {
        double r1933903 = x;
        double r1933904 = r1933903 * r1933903;
        double r1933905 = 1.0;
        double r1933906 = r1933904 + r1933905;
        double r1933907 = r1933903 / r1933906;
        return r1933907;
}

double f(double x) {
        double r1933908 = x;
        double r1933909 = -2532354690659.384;
        bool r1933910 = r1933908 <= r1933909;
        double r1933911 = 1.0;
        double r1933912 = r1933911 / r1933908;
        double r1933913 = r1933908 * r1933908;
        double r1933914 = r1933912 / r1933913;
        double r1933915 = r1933912 - r1933914;
        double r1933916 = r1933913 * r1933913;
        double r1933917 = r1933908 * r1933916;
        double r1933918 = r1933911 / r1933917;
        double r1933919 = r1933915 + r1933918;
        double r1933920 = 520.1081709356233;
        bool r1933921 = r1933908 <= r1933920;
        double r1933922 = r1933911 + r1933913;
        double r1933923 = r1933908 / r1933922;
        double r1933924 = r1933921 ? r1933923 : r1933919;
        double r1933925 = r1933910 ? r1933919 : r1933924;
        return r1933925;
}

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 < -2532354690659.384 or 520.1081709356233 < x

    1. Initial program 30.6

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

    if -2532354690659.384 < x < 520.1081709356233

    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 -2532354690659.384:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{x \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}\\ \mathbf{elif}\;x \le 520.1081709356233:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{x \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}\\ \end{array}\]

Reproduce

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

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

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