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

\mathbf{else}:\\
\;\;\;\;\frac{x}{x \cdot {x}^{3} - 1 \cdot 1} \cdot \left(x \cdot x - 1\right)\\

\end{array}
double f(double x) {
        double r43288 = x;
        double r43289 = r43288 * r43288;
        double r43290 = 1.0;
        double r43291 = r43289 + r43290;
        double r43292 = r43288 / r43291;
        return r43292;
}

double f(double x) {
        double r43293 = x;
        double r43294 = -2.4658381815044797e+18;
        bool r43295 = r43293 <= r43294;
        double r43296 = 986.0371090468709;
        bool r43297 = r43293 <= r43296;
        double r43298 = !r43297;
        bool r43299 = r43295 || r43298;
        double r43300 = 1.0;
        double r43301 = r43300 / r43293;
        double r43302 = 1.0;
        double r43303 = 5.0;
        double r43304 = pow(r43293, r43303);
        double r43305 = r43302 / r43304;
        double r43306 = r43301 + r43305;
        double r43307 = 3.0;
        double r43308 = pow(r43293, r43307);
        double r43309 = r43302 / r43308;
        double r43310 = r43306 - r43309;
        double r43311 = r43293 * r43308;
        double r43312 = r43302 * r43302;
        double r43313 = r43311 - r43312;
        double r43314 = r43293 / r43313;
        double r43315 = r43293 * r43293;
        double r43316 = r43315 - r43302;
        double r43317 = r43314 * r43316;
        double r43318 = r43299 ? r43310 : r43317;
        return r43318;
}

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 < -2.4658381815044797e+18 or 986.0371090468709 < x

    1. Initial program 30.9

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied div-inv30.9

      \[\leadsto \color{blue}{x \cdot \frac{1}{x \cdot x + 1}}\]
    4. 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}}}\]
    5. Simplified0.0

      \[\leadsto \color{blue}{\left(\frac{1}{x} + \frac{1}{{x}^{5}}\right) - \frac{1}{{x}^{3}}}\]

    if -2.4658381815044797e+18 < x < 986.0371090468709

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied flip-+0.0

      \[\leadsto \frac{x}{\color{blue}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1}{x \cdot x - 1}}}\]
    4. Applied associate-/r/0.0

      \[\leadsto \color{blue}{\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1} \cdot \left(x \cdot x - 1\right)}\]
    5. Simplified0.0

      \[\leadsto \color{blue}{\frac{x}{x \cdot {x}^{3} - 1 \cdot 1}} \cdot \left(x \cdot x - 1\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2465838181504479744 \lor \neg \left(x \le 986.0371090468709098786348477005958557129\right):\\ \;\;\;\;\left(\frac{1}{x} + \frac{1}{{x}^{5}}\right) - \frac{1}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot {x}^{3} - 1 \cdot 1} \cdot \left(x \cdot x - 1\right)\\ \end{array}\]

Reproduce

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

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

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