Average Error: 15.1 → 0.0
Time: 1.3s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -8789989068572990460 \lor \neg \left(x \le 14857.3789203431752\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 -8789989068572990460 \lor \neg \left(x \le 14857.3789203431752\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 r57044 = x;
        double r57045 = r57044 * r57044;
        double r57046 = 1.0;
        double r57047 = r57045 + r57046;
        double r57048 = r57044 / r57047;
        return r57048;
}

double f(double x) {
        double r57049 = x;
        double r57050 = -8.78998906857299e+18;
        bool r57051 = r57049 <= r57050;
        double r57052 = 14857.378920343175;
        bool r57053 = r57049 <= r57052;
        double r57054 = !r57053;
        bool r57055 = r57051 || r57054;
        double r57056 = 1.0;
        double r57057 = 1.0;
        double r57058 = 5.0;
        double r57059 = pow(r57049, r57058);
        double r57060 = r57057 / r57059;
        double r57061 = 3.0;
        double r57062 = pow(r57049, r57061);
        double r57063 = r57057 / r57062;
        double r57064 = r57060 - r57063;
        double r57065 = r57056 * r57064;
        double r57066 = r57057 / r57049;
        double r57067 = r57065 + r57066;
        double r57068 = r57049 * r57049;
        double r57069 = r57068 + r57056;
        double r57070 = r57049 / r57069;
        double r57071 = r57055 ? r57067 : r57070;
        return r57071;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -8.78998906857299e+18 or 14857.378920343175 < x

    1. Initial program 31.4

      \[\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 -8.78998906857299e+18 < x < 14857.378920343175

    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 -8789989068572990460 \lor \neg \left(x \le 14857.3789203431752\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 2020036 
(FPCore (x)
  :name "x / (x^2 + 1)"
  :precision binary64

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

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