Average Error: 15.1 → 0.0
Time: 2.3s
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 r90619 = x;
        double r90620 = r90619 * r90619;
        double r90621 = 1.0;
        double r90622 = r90620 + r90621;
        double r90623 = r90619 / r90622;
        return r90623;
}

double f(double x) {
        double r90624 = x;
        double r90625 = -6272088098.259001;
        bool r90626 = r90624 <= r90625;
        double r90627 = 460.75227704809595;
        bool r90628 = r90624 <= r90627;
        double r90629 = !r90628;
        bool r90630 = r90626 || r90629;
        double r90631 = 1.0;
        double r90632 = 1.0;
        double r90633 = 5.0;
        double r90634 = pow(r90624, r90633);
        double r90635 = r90632 / r90634;
        double r90636 = r90632 / r90624;
        double r90637 = 3.0;
        double r90638 = pow(r90624, r90637);
        double r90639 = r90632 / r90638;
        double r90640 = r90631 * r90639;
        double r90641 = r90636 - r90640;
        double r90642 = fma(r90631, r90635, r90641);
        double r90643 = r90624 * r90624;
        double r90644 = r90643 + r90631;
        double r90645 = r90624 / r90644;
        double r90646 = r90630 ? r90642 : r90645;
        return r90646;
}

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)))