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

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

\end{array}
double f(double x) {
        double r46581 = x;
        double r46582 = r46581 * r46581;
        double r46583 = 1.0;
        double r46584 = r46582 + r46583;
        double r46585 = r46581 / r46584;
        return r46585;
}

double f(double x) {
        double r46586 = x;
        double r46587 = -8.469905839544406e+24;
        bool r46588 = r46586 <= r46587;
        double r46589 = 541.7290142511919;
        bool r46590 = r46586 <= r46589;
        double r46591 = !r46590;
        bool r46592 = r46588 || r46591;
        double r46593 = 1.0;
        double r46594 = r46593 / r46586;
        double r46595 = 1.0;
        double r46596 = 3.0;
        double r46597 = pow(r46586, r46596);
        double r46598 = r46595 / r46597;
        double r46599 = 5.0;
        double r46600 = pow(r46586, r46599);
        double r46601 = r46593 / r46600;
        double r46602 = r46595 * r46601;
        double r46603 = r46598 - r46602;
        double r46604 = r46594 - r46603;
        double r46605 = r46586 * r46586;
        double r46606 = r46605 + r46595;
        double r46607 = r46593 / r46606;
        double r46608 = r46586 * r46607;
        double r46609 = r46592 ? r46604 : r46608;
        return r46609;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -8.469905839544406e+24 or 541.7290142511919 < x

    1. Initial program 30.9

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied div-inv30.9

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

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

    if -8.469905839544406e+24 < x < 541.7290142511919

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied div-inv0.0

      \[\leadsto \color{blue}{x \cdot \frac{1}{x \cdot x + 1}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -8469905839544405724233728 \lor \neg \left(x \le 541.7290142511918702439288608729839324951\right):\\ \;\;\;\;\frac{1}{x} - \left(\frac{1}{{x}^{3}} - 1 \cdot \frac{1}{{x}^{5}}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1}{x \cdot x + 1}\\ \end{array}\]

Reproduce

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

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

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