Average Error: 15.1 → 0.0
Time: 2.9s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -96697665796.7887421 \lor \neg \left(x \le 466.875941670613145\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 -96697665796.7887421 \lor \neg \left(x \le 466.875941670613145\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 r73921 = x;
        double r73922 = r73921 * r73921;
        double r73923 = 1.0;
        double r73924 = r73922 + r73923;
        double r73925 = r73921 / r73924;
        return r73925;
}

double f(double x) {
        double r73926 = x;
        double r73927 = -96697665796.78874;
        bool r73928 = r73926 <= r73927;
        double r73929 = 466.87594167061314;
        bool r73930 = r73926 <= r73929;
        double r73931 = !r73930;
        bool r73932 = r73928 || r73931;
        double r73933 = 1.0;
        double r73934 = r73933 / r73926;
        double r73935 = 1.0;
        double r73936 = 5.0;
        double r73937 = pow(r73926, r73936);
        double r73938 = r73935 / r73937;
        double r73939 = 3.0;
        double r73940 = pow(r73926, r73939);
        double r73941 = r73935 / r73940;
        double r73942 = r73938 - r73941;
        double r73943 = r73934 + r73942;
        double r73944 = -r73935;
        double r73945 = 4.0;
        double r73946 = pow(r73926, r73945);
        double r73947 = fma(r73944, r73935, r73946);
        double r73948 = r73926 / r73947;
        double r73949 = r73926 * r73926;
        double r73950 = r73949 - r73935;
        double r73951 = r73948 * r73950;
        double r73952 = r73932 ? r73943 : r73951;
        return r73952;
}

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 < -96697665796.78874 or 466.87594167061314 < x

    1. Initial program 30.2

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

      \[\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.6

      \[\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.6

      \[\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 -96697665796.78874 < x < 466.87594167061314

    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 -96697665796.7887421 \lor \neg \left(x \le 466.875941670613145\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 2020060 +o rules:numerics
(FPCore (x)
  :name "x / (x^2 + 1)"
  :precision binary64

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

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