Average Error: 15.1 → 0.0
Time: 1.2s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.24131751724691352 \cdot 10^{31} \lor \neg \left(x \le 447.85106598207193\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 -1.24131751724691352 \cdot 10^{31} \lor \neg \left(x \le 447.85106598207193\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 r51171 = x;
        double r51172 = r51171 * r51171;
        double r51173 = 1.0;
        double r51174 = r51172 + r51173;
        double r51175 = r51171 / r51174;
        return r51175;
}

double f(double x) {
        double r51176 = x;
        double r51177 = -1.2413175172469135e+31;
        bool r51178 = r51176 <= r51177;
        double r51179 = 447.85106598207193;
        bool r51180 = r51176 <= r51179;
        double r51181 = !r51180;
        bool r51182 = r51178 || r51181;
        double r51183 = 1.0;
        double r51184 = 1.0;
        double r51185 = 5.0;
        double r51186 = pow(r51176, r51185);
        double r51187 = r51184 / r51186;
        double r51188 = 3.0;
        double r51189 = pow(r51176, r51188);
        double r51190 = r51184 / r51189;
        double r51191 = r51187 - r51190;
        double r51192 = r51183 * r51191;
        double r51193 = r51184 / r51176;
        double r51194 = r51192 + r51193;
        double r51195 = r51176 * r51176;
        double r51196 = r51195 + r51183;
        double r51197 = r51176 / r51196;
        double r51198 = r51182 ? r51194 : r51197;
        return r51198;
}

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 < -1.2413175172469135e+31 or 447.85106598207193 < x

    1. Initial program 32.0

      \[\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 -1.2413175172469135e+31 < x < 447.85106598207193

    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.24131751724691352 \cdot 10^{31} \lor \neg \left(x \le 447.85106598207193\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 2020062 
(FPCore (x)
  :name "x / (x^2 + 1)"
  :precision binary64

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

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