Average Error: 15.2 → 0.0
Time: 10.5s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.8453524061497666 \cdot 10^{+21}:\\ \;\;\;\;\frac{1}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot x} + \left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right)\\ \mathbf{elif}\;x \le 13951219.631737411:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot x} + \left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right)\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -1.8453524061497666 \cdot 10^{+21}:\\
\;\;\;\;\frac{1}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot x} + \left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right)\\

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

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

\end{array}
double f(double x) {
        double r1851804 = x;
        double r1851805 = r1851804 * r1851804;
        double r1851806 = 1.0;
        double r1851807 = r1851805 + r1851806;
        double r1851808 = r1851804 / r1851807;
        return r1851808;
}

double f(double x) {
        double r1851809 = x;
        double r1851810 = -1.8453524061497666e+21;
        bool r1851811 = r1851809 <= r1851810;
        double r1851812 = 1.0;
        double r1851813 = r1851809 * r1851809;
        double r1851814 = r1851813 * r1851813;
        double r1851815 = r1851814 * r1851809;
        double r1851816 = r1851812 / r1851815;
        double r1851817 = r1851812 / r1851809;
        double r1851818 = r1851817 / r1851813;
        double r1851819 = r1851817 - r1851818;
        double r1851820 = r1851816 + r1851819;
        double r1851821 = 13951219.631737411;
        bool r1851822 = r1851809 <= r1851821;
        double r1851823 = r1851812 + r1851813;
        double r1851824 = r1851809 / r1851823;
        double r1851825 = r1851822 ? r1851824 : r1851820;
        double r1851826 = r1851811 ? r1851820 : r1851825;
        return r1851826;
}

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 < -1.8453524061497666e+21 or 13951219.631737411 < x

    1. Initial program 31.5

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied flip-+49.3

      \[\leadsto \frac{x}{\color{blue}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1}{x \cdot x - 1}}}\]
    4. Applied associate-/r/49.3

      \[\leadsto \color{blue}{\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1} \cdot \left(x \cdot x - 1\right)}\]
    5. Simplified49.3

      \[\leadsto \color{blue}{\frac{x}{-1 + \left(x \cdot x\right) \cdot \left(x \cdot x\right)}} \cdot \left(x \cdot x - 1\right)\]
    6. Taylor expanded around inf 0.0

      \[\leadsto \color{blue}{\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{{x}^{3}}}\]
    7. Simplified0.0

      \[\leadsto \color{blue}{\frac{1}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot x} + \left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right)}\]

    if -1.8453524061497666e+21 < x < 13951219.631737411

    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.8453524061497666 \cdot 10^{+21}:\\ \;\;\;\;\frac{1}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot x} + \left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right)\\ \mathbf{elif}\;x \le 13951219.631737411:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot x} + \left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right)\\ \end{array}\]

Reproduce

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

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

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