Average Error: 14.3 → 0.0
Time: 32.8s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.450745238348297 \cdot 10^{+24}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{{x}^{5}}\\ \mathbf{elif}\;x \le 665.7378871081933:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{{x}^{5}}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -7.450745238348297 \cdot 10^{+24}:\\
\;\;\;\;\left(\frac{1}{x} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{{x}^{5}}\\

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

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

\end{array}
double f(double x) {
        double r4519081 = x;
        double r4519082 = r4519081 * r4519081;
        double r4519083 = 1.0;
        double r4519084 = r4519082 + r4519083;
        double r4519085 = r4519081 / r4519084;
        return r4519085;
}

double f(double x) {
        double r4519086 = x;
        double r4519087 = -7.450745238348297e+24;
        bool r4519088 = r4519086 <= r4519087;
        double r4519089 = 1.0;
        double r4519090 = r4519089 / r4519086;
        double r4519091 = r4519086 * r4519086;
        double r4519092 = r4519091 * r4519086;
        double r4519093 = r4519089 / r4519092;
        double r4519094 = r4519090 - r4519093;
        double r4519095 = 5.0;
        double r4519096 = pow(r4519086, r4519095);
        double r4519097 = r4519089 / r4519096;
        double r4519098 = r4519094 + r4519097;
        double r4519099 = 665.7378871081933;
        bool r4519100 = r4519086 <= r4519099;
        double r4519101 = r4519089 + r4519091;
        double r4519102 = r4519086 / r4519101;
        double r4519103 = r4519100 ? r4519102 : r4519098;
        double r4519104 = r4519088 ? r4519098 : r4519103;
        return r4519104;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.3
Target0.1
Herbie0.0
\[\frac{1}{x + \frac{1}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -7.450745238348297e+24 or 665.7378871081933 < 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}{\left(\frac{1}{x} - \frac{1}{x \cdot \left(x \cdot x\right)}\right) + \frac{1}{{x}^{5}}}\]

    if -7.450745238348297e+24 < x < 665.7378871081933

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

Reproduce

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

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

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