Average Error: 15.1 → 0.0
Time: 2.4s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -6272088098.2590008 \lor \neg \left(x \le 460.75227704809595\right):\\ \;\;\;\;\mathsf{fma}\left(1, \frac{1}{{x}^{5}}, \frac{1}{x} - 1 \cdot \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 -6272088098.2590008 \lor \neg \left(x \le 460.75227704809595\right):\\
\;\;\;\;\mathsf{fma}\left(1, \frac{1}{{x}^{5}}, \frac{1}{x} - 1 \cdot \frac{1}{{x}^{3}}\right)\\

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

\end{array}
double f(double x) {
        double r70428 = x;
        double r70429 = r70428 * r70428;
        double r70430 = 1.0;
        double r70431 = r70429 + r70430;
        double r70432 = r70428 / r70431;
        return r70432;
}

double f(double x) {
        double r70433 = x;
        double r70434 = -6272088098.259001;
        bool r70435 = r70433 <= r70434;
        double r70436 = 460.75227704809595;
        bool r70437 = r70433 <= r70436;
        double r70438 = !r70437;
        bool r70439 = r70435 || r70438;
        double r70440 = 1.0;
        double r70441 = 1.0;
        double r70442 = 5.0;
        double r70443 = pow(r70433, r70442);
        double r70444 = r70441 / r70443;
        double r70445 = r70441 / r70433;
        double r70446 = 3.0;
        double r70447 = pow(r70433, r70446);
        double r70448 = r70441 / r70447;
        double r70449 = r70440 * r70448;
        double r70450 = r70445 - r70449;
        double r70451 = fma(r70440, r70444, r70450);
        double r70452 = r70433 * r70433;
        double r70453 = r70452 + r70440;
        double r70454 = r70433 / r70453;
        double r70455 = r70439 ? r70451 : r70454;
        return r70455;
}

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -6272088098.259001 or 460.75227704809595 < x

    1. Initial program 30.6

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

      \[\leadsto \frac{x}{\color{blue}{\left(\sqrt[3]{x \cdot x + 1} \cdot \sqrt[3]{x \cdot x + 1}\right) \cdot \sqrt[3]{x \cdot x + 1}}}\]
    4. Applied *-un-lft-identity31.1

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\left(\sqrt[3]{x \cdot x + 1} \cdot \sqrt[3]{x \cdot x + 1}\right) \cdot \sqrt[3]{x \cdot x + 1}}\]
    5. Applied times-frac31.1

      \[\leadsto \color{blue}{\frac{1}{\sqrt[3]{x \cdot x + 1} \cdot \sqrt[3]{x \cdot x + 1}} \cdot \frac{x}{\sqrt[3]{x \cdot x + 1}}}\]
    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}{\mathsf{fma}\left(1, \frac{1}{{x}^{5}}, \frac{1}{x} - 1 \cdot \frac{1}{{x}^{3}}\right)}\]

    if -6272088098.259001 < x < 460.75227704809595

    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 -6272088098.2590008 \lor \neg \left(x \le 460.75227704809595\right):\\ \;\;\;\;\mathsf{fma}\left(1, \frac{1}{{x}^{5}}, \frac{1}{x} - 1 \cdot \frac{1}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot x + 1}\\ \end{array}\]

Reproduce

herbie shell --seed 2020056 +o rules:numerics
(FPCore (x)
  :name "x / (x^2 + 1)"
  :precision binary64

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

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