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

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

\end{array}
double f(double x) {
        double r58877 = x;
        double r58878 = r58877 * r58877;
        double r58879 = 1.0;
        double r58880 = r58878 + r58879;
        double r58881 = r58877 / r58880;
        return r58881;
}

double f(double x) {
        double r58882 = x;
        double r58883 = -3.4087103630608475e+32;
        bool r58884 = r58882 <= r58883;
        double r58885 = 194132570.49501014;
        bool r58886 = r58882 <= r58885;
        double r58887 = !r58886;
        bool r58888 = r58884 || r58887;
        double r58889 = 1.0;
        double r58890 = 1.0;
        double r58891 = 5.0;
        double r58892 = pow(r58882, r58891);
        double r58893 = r58890 / r58892;
        double r58894 = 3.0;
        double r58895 = pow(r58882, r58894);
        double r58896 = r58890 / r58895;
        double r58897 = r58893 - r58896;
        double r58898 = r58889 * r58897;
        double r58899 = r58890 / r58882;
        double r58900 = r58898 + r58899;
        double r58901 = r58882 * r58882;
        double r58902 = r58901 + r58889;
        double r58903 = r58882 / r58902;
        double r58904 = r58888 ? r58900 : r58903;
        return r58904;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -3.4087103630608475e+32 or 194132570.49501014 < x

    1. Initial program 31.7

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

    if -3.4087103630608475e+32 < x < 194132570.49501014

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

Reproduce

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

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

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