Average Error: 14.8 → 0.0
Time: 2.7s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.186528525688685182001562549656678997394 \cdot 10^{63} \lor \neg \left(x \le 1818.985609970475707086734473705291748047\right):\\ \;\;\;\;\frac{1}{x} + 1 \cdot \left(\frac{1}{{x}^{5}} - \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 -1.186528525688685182001562549656678997394 \cdot 10^{63} \lor \neg \left(x \le 1818.985609970475707086734473705291748047\right):\\
\;\;\;\;\frac{1}{x} + 1 \cdot \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)\\

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

\end{array}
double f(double x) {
        double r56719 = x;
        double r56720 = r56719 * r56719;
        double r56721 = 1.0;
        double r56722 = r56720 + r56721;
        double r56723 = r56719 / r56722;
        return r56723;
}

double f(double x) {
        double r56724 = x;
        double r56725 = -1.1865285256886852e+63;
        bool r56726 = r56724 <= r56725;
        double r56727 = 1818.9856099704757;
        bool r56728 = r56724 <= r56727;
        double r56729 = !r56728;
        bool r56730 = r56726 || r56729;
        double r56731 = 1.0;
        double r56732 = r56731 / r56724;
        double r56733 = 1.0;
        double r56734 = 5.0;
        double r56735 = pow(r56724, r56734);
        double r56736 = r56731 / r56735;
        double r56737 = 3.0;
        double r56738 = pow(r56724, r56737);
        double r56739 = r56731 / r56738;
        double r56740 = r56736 - r56739;
        double r56741 = r56733 * r56740;
        double r56742 = r56732 + r56741;
        double r56743 = r56724 * r56724;
        double r56744 = r56743 + r56733;
        double r56745 = r56724 / r56744;
        double r56746 = r56730 ? r56742 : r56745;
        return r56746;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -1.1865285256886852e+63 or 1818.9856099704757 < x

    1. Initial program 32.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} + 1 \cdot \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)}\]

    if -1.1865285256886852e+63 < x < 1818.9856099704757

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

Reproduce

herbie shell --seed 2019308 
(FPCore (x)
  :name "x / (x^2 + 1)"
  :precision binary64

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

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