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

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

\end{array}
double f(double x) {
        double r58255 = x;
        double r58256 = r58255 * r58255;
        double r58257 = 1.0;
        double r58258 = r58256 + r58257;
        double r58259 = r58255 / r58258;
        return r58259;
}

double f(double x) {
        double r58260 = x;
        double r58261 = -62379821099783.21;
        bool r58262 = r58260 <= r58261;
        double r58263 = 509.7156046843299;
        bool r58264 = r58260 <= r58263;
        double r58265 = !r58264;
        bool r58266 = r58262 || r58265;
        double r58267 = 1.0;
        double r58268 = r58267 / r58260;
        double r58269 = 1.0;
        double r58270 = 3.0;
        double r58271 = pow(r58260, r58270);
        double r58272 = r58269 / r58271;
        double r58273 = 5.0;
        double r58274 = pow(r58260, r58273);
        double r58275 = r58267 / r58274;
        double r58276 = r58269 * r58275;
        double r58277 = r58272 - r58276;
        double r58278 = r58268 - r58277;
        double r58279 = r58260 * r58260;
        double r58280 = r58279 + r58269;
        double r58281 = r58267 / r58280;
        double r58282 = r58260 * r58281;
        double r58283 = r58266 ? r58278 : r58282;
        return r58283;
}

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 < -62379821099783.21 or 509.7156046843299 < x

    1. Initial program 30.9

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

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

    if -62379821099783.21 < x < 509.7156046843299

    1. Initial program 0.0

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

      \[\leadsto \color{blue}{x \cdot \frac{1}{x \cdot x + 1}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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

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

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