Average Error: 15.5 → 0.0
Time: 2.9s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -361128223798.23687744140625 \lor \neg \left(x \le 422.2996736029814428547979332506656646729\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 -361128223798.23687744140625 \lor \neg \left(x \le 422.2996736029814428547979332506656646729\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 r64751 = x;
        double r64752 = r64751 * r64751;
        double r64753 = 1.0;
        double r64754 = r64752 + r64753;
        double r64755 = r64751 / r64754;
        return r64755;
}

double f(double x) {
        double r64756 = x;
        double r64757 = -361128223798.2369;
        bool r64758 = r64756 <= r64757;
        double r64759 = 422.29967360298144;
        bool r64760 = r64756 <= r64759;
        double r64761 = !r64760;
        bool r64762 = r64758 || r64761;
        double r64763 = 1.0;
        double r64764 = r64763 / r64756;
        double r64765 = 1.0;
        double r64766 = 5.0;
        double r64767 = pow(r64756, r64766);
        double r64768 = r64765 / r64767;
        double r64769 = 3.0;
        double r64770 = pow(r64756, r64769);
        double r64771 = r64765 / r64770;
        double r64772 = r64768 - r64771;
        double r64773 = r64764 + r64772;
        double r64774 = r64756 * r64756;
        double r64775 = r64774 + r64765;
        double r64776 = r64756 / r64775;
        double r64777 = r64762 ? r64773 : r64776;
        return r64777;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -361128223798.2369 or 422.29967360298144 < x

    1. Initial program 31.0

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

      \[\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.1

      \[\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.1

      \[\leadsto \color{blue}{\frac{x}{\mathsf{fma}\left(-1, 1, {x}^{4}\right)}} \cdot \left(x \cdot x - 1\right)\]
    6. 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}}}\]
    7. Simplified0.0

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

    if -361128223798.2369 < x < 422.29967360298144

    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 -361128223798.23687744140625 \lor \neg \left(x \le 422.2996736029814428547979332506656646729\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 2020002 +o rules:numerics
(FPCore (x)
  :name "x / (x^2 + 1)"
  :precision binary64

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

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