Average Error: 15.2 → 0.0
Time: 2.0s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -4.22741385849907756 \cdot 10^{28} \lor \neg \left(x \le 747.668589388476107\right):\\ \;\;\;\;\left(\frac{1}{x} - 1 \cdot \frac{1}{{x}^{3}}\right) + \frac{1}{{x}^{5}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot x + 1}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -4.22741385849907756 \cdot 10^{28} \lor \neg \left(x \le 747.668589388476107\right):\\
\;\;\;\;\left(\frac{1}{x} - 1 \cdot \frac{1}{{x}^{3}}\right) + \frac{1}{{x}^{5}}\\

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

\end{array}
double f(double x) {
        double r64597 = x;
        double r64598 = r64597 * r64597;
        double r64599 = 1.0;
        double r64600 = r64598 + r64599;
        double r64601 = r64597 / r64600;
        return r64601;
}

double f(double x) {
        double r64602 = x;
        double r64603 = -4.227413858499078e+28;
        bool r64604 = r64602 <= r64603;
        double r64605 = 747.6685893884761;
        bool r64606 = r64602 <= r64605;
        double r64607 = !r64606;
        bool r64608 = r64604 || r64607;
        double r64609 = 1.0;
        double r64610 = r64609 / r64602;
        double r64611 = 1.0;
        double r64612 = 3.0;
        double r64613 = pow(r64602, r64612);
        double r64614 = r64609 / r64613;
        double r64615 = r64611 * r64614;
        double r64616 = r64610 - r64615;
        double r64617 = 5.0;
        double r64618 = pow(r64602, r64617);
        double r64619 = r64611 / r64618;
        double r64620 = r64616 + r64619;
        double r64621 = r64602 * r64602;
        double r64622 = r64621 + r64611;
        double r64623 = r64602 / r64622;
        double r64624 = r64608 ? r64620 : r64623;
        return r64624;
}

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 < -4.227413858499078e+28 or 747.6685893884761 < x

    1. Initial program 31.3

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt31.3

      \[\leadsto \frac{x}{\color{blue}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}}\]
    4. Applied associate-/r*31.2

      \[\leadsto \color{blue}{\frac{\frac{x}{\sqrt{x \cdot x + 1}}}{\sqrt{x \cdot x + 1}}}\]
    5. 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}}}\]
    6. Simplified0.0

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

    if -4.227413858499078e+28 < x < 747.6685893884761

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

Reproduce

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

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

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