Average Error: 15.1 → 0.0
Time: 1.6s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -8789989068572990460 \lor \neg \left(x \le 14857.3789203431752\right):\\ \;\;\;\;1 \cdot \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right) + \frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot x + 1}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -8789989068572990460 \lor \neg \left(x \le 14857.3789203431752\right):\\
\;\;\;\;1 \cdot \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right) + \frac{1}{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{x \cdot x + 1}\\

\end{array}
double f(double x) {
        double r54747 = x;
        double r54748 = r54747 * r54747;
        double r54749 = 1.0;
        double r54750 = r54748 + r54749;
        double r54751 = r54747 / r54750;
        return r54751;
}

double f(double x) {
        double r54752 = x;
        double r54753 = -8.78998906857299e+18;
        bool r54754 = r54752 <= r54753;
        double r54755 = 14857.378920343175;
        bool r54756 = r54752 <= r54755;
        double r54757 = !r54756;
        bool r54758 = r54754 || r54757;
        double r54759 = 1.0;
        double r54760 = 1.0;
        double r54761 = 5.0;
        double r54762 = pow(r54752, r54761);
        double r54763 = r54760 / r54762;
        double r54764 = 3.0;
        double r54765 = pow(r54752, r54764);
        double r54766 = r54760 / r54765;
        double r54767 = r54763 - r54766;
        double r54768 = r54759 * r54767;
        double r54769 = r54760 / r54752;
        double r54770 = r54768 + r54769;
        double r54771 = r54752 * r54752;
        double r54772 = r54771 + r54759;
        double r54773 = r54752 / r54772;
        double r54774 = r54758 ? r54770 : r54773;
        return r54774;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -8.78998906857299e+18 or 14857.378920343175 < x

    1. Initial program 31.4

      \[\frac{x}{x \cdot x + 1}\]
    2. Taylor expanded around inf 0.0

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

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

    if -8.78998906857299e+18 < x < 14857.378920343175

    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 -8789989068572990460 \lor \neg \left(x \le 14857.3789203431752\right):\\ \;\;\;\;1 \cdot \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right) + \frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot x + 1}\\ \end{array}\]

Reproduce

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

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

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