Average Error: 15.1 → 0.0
Time: 2.3s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1604.9795860088566 \lor \neg \left(x \le 248836920.91487622\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 -1604.9795860088566 \lor \neg \left(x \le 248836920.91487622\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 r52530 = x;
        double r52531 = r52530 * r52530;
        double r52532 = 1.0;
        double r52533 = r52531 + r52532;
        double r52534 = r52530 / r52533;
        return r52534;
}

double f(double x) {
        double r52535 = x;
        double r52536 = -1604.9795860088566;
        bool r52537 = r52535 <= r52536;
        double r52538 = 248836920.91487622;
        bool r52539 = r52535 <= r52538;
        double r52540 = !r52539;
        bool r52541 = r52537 || r52540;
        double r52542 = 1.0;
        double r52543 = r52542 / r52535;
        double r52544 = 1.0;
        double r52545 = 3.0;
        double r52546 = pow(r52535, r52545);
        double r52547 = r52544 / r52546;
        double r52548 = 5.0;
        double r52549 = pow(r52535, r52548);
        double r52550 = r52542 / r52549;
        double r52551 = r52544 * r52550;
        double r52552 = r52547 - r52551;
        double r52553 = r52543 - r52552;
        double r52554 = r52535 * r52535;
        double r52555 = r52554 + r52544;
        double r52556 = r52542 / r52555;
        double r52557 = r52535 * r52556;
        double r52558 = r52541 ? r52553 : r52557;
        return r52558;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -1604.9795860088566 or 248836920.91487622 < x

    1. Initial program 31.0

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

      \[\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 -1604.9795860088566 < x < 248836920.91487622

    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 -1604.9795860088566 \lor \neg \left(x \le 248836920.91487622\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 2020020 
(FPCore (x)
  :name "x / (x^2 + 1)"
  :precision binary64

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

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