Average Error: 15.5 → 0.0
Time: 6.9s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -542649.79826615541242063045501708984375 \lor \neg \left(x \le 904431.560700487927533686161041259765625\right):\\ \;\;\;\;\frac{1}{x} + \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\mathsf{fma}\left(-1, 1, {x}^{4}\right)} \cdot \left(x \cdot x - 1\right)\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -542649.79826615541242063045501708984375 \lor \neg \left(x \le 904431.560700487927533686161041259765625\right):\\
\;\;\;\;\frac{1}{x} + \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\mathsf{fma}\left(-1, 1, {x}^{4}\right)} \cdot \left(x \cdot x - 1\right)\\

\end{array}
double f(double x) {
        double r91106 = x;
        double r91107 = r91106 * r91106;
        double r91108 = 1.0;
        double r91109 = r91107 + r91108;
        double r91110 = r91106 / r91109;
        return r91110;
}

double f(double x) {
        double r91111 = x;
        double r91112 = -542649.7982661554;
        bool r91113 = r91111 <= r91112;
        double r91114 = 904431.5607004879;
        bool r91115 = r91111 <= r91114;
        double r91116 = !r91115;
        bool r91117 = r91113 || r91116;
        double r91118 = 1.0;
        double r91119 = r91118 / r91111;
        double r91120 = 1.0;
        double r91121 = 5.0;
        double r91122 = pow(r91111, r91121);
        double r91123 = r91120 / r91122;
        double r91124 = 3.0;
        double r91125 = pow(r91111, r91124);
        double r91126 = r91120 / r91125;
        double r91127 = r91123 - r91126;
        double r91128 = r91119 + r91127;
        double r91129 = -r91120;
        double r91130 = 4.0;
        double r91131 = pow(r91111, r91130);
        double r91132 = fma(r91129, r91120, r91131);
        double r91133 = r91111 / r91132;
        double r91134 = r91111 * r91111;
        double r91135 = r91134 - r91120;
        double r91136 = r91133 * r91135;
        double r91137 = r91117 ? r91128 : r91136;
        return r91137;
}

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -542649.7982661554 or 904431.5607004879 < x

    1. Initial program 31.3

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied flip-+48.8

      \[\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/48.9

      \[\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. Simplified48.9

      \[\leadsto \color{blue}{\frac{x}{\mathsf{fma}\left(-1, 1, {x}^{4}\right)}} \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}}}\]
    7. Simplified0.0

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

    if -542649.7982661554 < x < 904431.5607004879

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied flip-+0.0

      \[\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/0.0

      \[\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. Simplified0.0

      \[\leadsto \color{blue}{\frac{x}{\mathsf{fma}\left(-1, 1, {x}^{4}\right)}} \cdot \left(x \cdot x - 1\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -542649.79826615541242063045501708984375 \lor \neg \left(x \le 904431.560700487927533686161041259765625\right):\\ \;\;\;\;\frac{1}{x} + \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\mathsf{fma}\left(-1, 1, {x}^{4}\right)} \cdot \left(x \cdot x - 1\right)\\ \end{array}\]

Reproduce

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

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

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