Average Error: 14.8 → 0.0
Time: 4.5s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -57137068010548903280640 \lor \neg \left(x \le 8124.998191315608892182353883981704711914\right):\\ \;\;\;\;\frac{1}{x} + \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 -57137068010548903280640 \lor \neg \left(x \le 8124.998191315608892182353883981704711914\right):\\
\;\;\;\;\frac{1}{x} + \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 r42290 = x;
        double r42291 = r42290 * r42290;
        double r42292 = 1.0;
        double r42293 = r42291 + r42292;
        double r42294 = r42290 / r42293;
        return r42294;
}

double f(double x) {
        double r42295 = x;
        double r42296 = -5.71370680105489e+22;
        bool r42297 = r42295 <= r42296;
        double r42298 = 8124.998191315609;
        bool r42299 = r42295 <= r42298;
        double r42300 = !r42299;
        bool r42301 = r42297 || r42300;
        double r42302 = 1.0;
        double r42303 = r42302 / r42295;
        double r42304 = 1.0;
        double r42305 = 5.0;
        double r42306 = pow(r42295, r42305);
        double r42307 = r42304 / r42306;
        double r42308 = 3.0;
        double r42309 = pow(r42295, r42308);
        double r42310 = r42304 / r42309;
        double r42311 = r42307 - r42310;
        double r42312 = r42303 + r42311;
        double r42313 = r42295 * r42295;
        double r42314 = r42313 + r42304;
        double r42315 = r42295 / r42314;
        double r42316 = r42301 ? r42312 : r42315;
        return r42316;
}

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 < -5.71370680105489e+22 or 8124.998191315609 < x

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

    if -5.71370680105489e+22 < x < 8124.998191315609

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

Reproduce

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

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

  (/ x (+ (* x x) 1.0)))