Average Error: 14.4 → 0.0
Time: 5.3s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -7672388198.064882:\\ \;\;\;\;\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 433.55902965551593:\\ \;\;\;\;\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 -7672388198.064882:\\
\;\;\;\;\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 433.55902965551593:\\
\;\;\;\;\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 r1511304 = x;
        double r1511305 = r1511304 * r1511304;
        double r1511306 = 1.0;
        double r1511307 = r1511305 + r1511306;
        double r1511308 = r1511304 / r1511307;
        return r1511308;
}

double f(double x) {
        double r1511309 = x;
        double r1511310 = -7672388198.064882;
        bool r1511311 = r1511309 <= r1511310;
        double r1511312 = 1.0;
        double r1511313 = r1511312 / r1511309;
        double r1511314 = r1511309 * r1511309;
        double r1511315 = r1511313 / r1511314;
        double r1511316 = r1511314 * r1511309;
        double r1511317 = r1511316 * r1511314;
        double r1511318 = r1511312 / r1511317;
        double r1511319 = r1511315 - r1511318;
        double r1511320 = r1511313 - r1511319;
        double r1511321 = 433.55902965551593;
        bool r1511322 = r1511309 <= r1511321;
        double r1511323 = r1511312 + r1511314;
        double r1511324 = r1511309 / r1511323;
        double r1511325 = r1511322 ? r1511324 : r1511320;
        double r1511326 = r1511311 ? r1511320 : r1511325;
        return r1511326;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -7672388198.064882 or 433.55902965551593 < x

    1. Initial program 29.5

      \[\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 -7672388198.064882 < x < 433.55902965551593

    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 -7672388198.064882:\\ \;\;\;\;\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 433.55902965551593:\\ \;\;\;\;\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 2019132 
(FPCore (x)
  :name "x / (x^2 + 1)"

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

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