Average Error: 14.4 → 0.0
Time: 7.7s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -525.1650773382436909741954877972602844238 \lor \neg \left(x \le 1516.039369452883647682028822600841522217\right):\\ \;\;\;\;\frac{1}{{x}^{5}} + \left(\frac{1}{x} - \frac{1}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{{x}^{4} - 1 \cdot 1} \cdot \left(x \cdot x - 1\right)\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -525.1650773382436909741954877972602844238 \lor \neg \left(x \le 1516.039369452883647682028822600841522217\right):\\
\;\;\;\;\frac{1}{{x}^{5}} + \left(\frac{1}{x} - \frac{1}{{x}^{3}}\right)\\

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

\end{array}
double f(double x) {
        double r74806 = x;
        double r74807 = r74806 * r74806;
        double r74808 = 1.0;
        double r74809 = r74807 + r74808;
        double r74810 = r74806 / r74809;
        return r74810;
}

double f(double x) {
        double r74811 = x;
        double r74812 = -525.1650773382437;
        bool r74813 = r74811 <= r74812;
        double r74814 = 1516.0393694528836;
        bool r74815 = r74811 <= r74814;
        double r74816 = !r74815;
        bool r74817 = r74813 || r74816;
        double r74818 = 1.0;
        double r74819 = 5.0;
        double r74820 = pow(r74811, r74819);
        double r74821 = r74818 / r74820;
        double r74822 = 1.0;
        double r74823 = r74822 / r74811;
        double r74824 = 3.0;
        double r74825 = pow(r74811, r74824);
        double r74826 = r74818 / r74825;
        double r74827 = r74823 - r74826;
        double r74828 = r74821 + r74827;
        double r74829 = 4.0;
        double r74830 = pow(r74811, r74829);
        double r74831 = r74818 * r74818;
        double r74832 = r74830 - r74831;
        double r74833 = r74811 / r74832;
        double r74834 = r74811 * r74811;
        double r74835 = r74834 - r74818;
        double r74836 = r74833 * r74835;
        double r74837 = r74817 ? r74828 : r74836;
        return r74837;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -525.1650773382437 or 1516.0393694528836 < x

    1. Initial program 29.6

      \[\frac{x}{x \cdot x + 1}\]
    2. 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}}}\]
    3. Simplified0.0

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

    if -525.1650773382437 < x < 1516.0393694528836

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

Reproduce

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

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

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