Average Error: 14.6 → 0.0
Time: 9.0s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.195002563386160441668121103642730572028 \cdot 10^{62} \lor \neg \left(x \le 507.0100903930748472703271545469760894775\right):\\ \;\;\;\;\frac{1}{x} + \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot x + 1}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -3.195002563386160441668121103642730572028 \cdot 10^{62} \lor \neg \left(x \le 507.0100903930748472703271545469760894775\right):\\
\;\;\;\;\frac{1}{x} + \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)\\

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

\end{array}
double f(double x) {
        double r55718 = x;
        double r55719 = r55718 * r55718;
        double r55720 = 1.0;
        double r55721 = r55719 + r55720;
        double r55722 = r55718 / r55721;
        return r55722;
}

double f(double x) {
        double r55723 = x;
        double r55724 = -3.1950025633861604e+62;
        bool r55725 = r55723 <= r55724;
        double r55726 = 507.01009039307485;
        bool r55727 = r55723 <= r55726;
        double r55728 = !r55727;
        bool r55729 = r55725 || r55728;
        double r55730 = 1.0;
        double r55731 = r55730 / r55723;
        double r55732 = 1.0;
        double r55733 = 5.0;
        double r55734 = pow(r55723, r55733);
        double r55735 = r55732 / r55734;
        double r55736 = 3.0;
        double r55737 = pow(r55723, r55736);
        double r55738 = r55732 / r55737;
        double r55739 = r55735 - r55738;
        double r55740 = r55731 + r55739;
        double r55741 = r55723 * r55723;
        double r55742 = r55741 + r55732;
        double r55743 = r55723 / r55742;
        double r55744 = r55729 ? r55740 : r55743;
        return r55744;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -3.1950025633861604e+62 or 507.01009039307485 < x

    1. Initial program 33.3

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

    if -3.1950025633861604e+62 < x < 507.01009039307485

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

Reproduce

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

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

  (/ x (+ (* x x) 1.0)))