Average Error: 15.5 → 0.0
Time: 1.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):\\ \;\;\;\;\left(1 \cdot \frac{1}{{x}^{5}} + \frac{1}{x}\right) - 1 \cdot \frac{1}{{x}^{3}}\\ \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):\\
\;\;\;\;\left(1 \cdot \frac{1}{{x}^{5}} + \frac{1}{x}\right) - 1 \cdot \frac{1}{{x}^{3}}\\

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

\end{array}
double f(double x) {
        double r64698 = x;
        double r64699 = r64698 * r64698;
        double r64700 = 1.0;
        double r64701 = r64699 + r64700;
        double r64702 = r64698 / r64701;
        return r64702;
}

double f(double x) {
        double r64703 = x;
        double r64704 = -361128223798.2369;
        bool r64705 = r64703 <= r64704;
        double r64706 = 422.29967360298144;
        bool r64707 = r64703 <= r64706;
        double r64708 = !r64707;
        bool r64709 = r64705 || r64708;
        double r64710 = 1.0;
        double r64711 = 1.0;
        double r64712 = 5.0;
        double r64713 = pow(r64703, r64712);
        double r64714 = r64711 / r64713;
        double r64715 = r64710 * r64714;
        double r64716 = r64711 / r64703;
        double r64717 = r64715 + r64716;
        double r64718 = 3.0;
        double r64719 = pow(r64703, r64718);
        double r64720 = r64711 / r64719;
        double r64721 = r64710 * r64720;
        double r64722 = r64717 - r64721;
        double r64723 = r64703 * r64703;
        double r64724 = r64723 + r64710;
        double r64725 = r64703 / r64724;
        double r64726 = r64709 ? r64722 : r64725;
        return r64726;
}

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}{\left(-1 \cdot 1\right) + {x}^{4}}} \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}}}\]

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

Reproduce

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

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

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