Average Error: 14.9 → 0.0
Time: 16.2s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -4377789621347.087890625 \lor \neg \left(x \le 434.3260566585274204953748267143964767456\right):\\ \;\;\;\;\left(\frac{1}{x} + \frac{1}{{x}^{5}}\right) - \frac{1}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{{x}^{4} - 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 -4377789621347.087890625 \lor \neg \left(x \le 434.3260566585274204953748267143964767456\right):\\
\;\;\;\;\left(\frac{1}{x} + \frac{1}{{x}^{5}}\right) - \frac{1}{{x}^{3}}\\

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

\end{array}
double f(double x) {
        double r60390 = x;
        double r60391 = r60390 * r60390;
        double r60392 = 1.0;
        double r60393 = r60391 + r60392;
        double r60394 = r60390 / r60393;
        return r60394;
}

double f(double x) {
        double r60395 = x;
        double r60396 = -4377789621347.088;
        bool r60397 = r60395 <= r60396;
        double r60398 = 434.3260566585274;
        bool r60399 = r60395 <= r60398;
        double r60400 = !r60399;
        bool r60401 = r60397 || r60400;
        double r60402 = 1.0;
        double r60403 = r60402 / r60395;
        double r60404 = 1.0;
        double r60405 = 5.0;
        double r60406 = pow(r60395, r60405);
        double r60407 = r60404 / r60406;
        double r60408 = r60403 + r60407;
        double r60409 = 3.0;
        double r60410 = pow(r60395, r60409);
        double r60411 = r60404 / r60410;
        double r60412 = r60408 - r60411;
        double r60413 = 4.0;
        double r60414 = pow(r60395, r60413);
        double r60415 = r60404 * r60404;
        double r60416 = r60414 - r60415;
        double r60417 = r60395 / r60416;
        double r60418 = r60395 * r60395;
        double r60419 = r60418 - r60404;
        double r60420 = r60417 * r60419;
        double r60421 = r60401 ? r60412 : r60420;
        return r60421;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -4377789621347.088 or 434.3260566585274 < x

    1. Initial program 30.7

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt30.7

      \[\leadsto \frac{x}{\color{blue}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}}\]
    4. Applied *-un-lft-identity30.7

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}\]
    5. Applied times-frac30.5

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}}\]
    6. Simplified30.5

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\]
    7. Simplified30.5

      \[\leadsto \frac{1}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}} \cdot \color{blue}{\frac{x}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}}\]
    8. 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}}}\]
    9. Simplified0.0

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

    if -4377789621347.088 < x < 434.3260566585274

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

Reproduce

herbie shell --seed 2019326 +o rules:numerics
(FPCore (x)
  :name "x / (x^2 + 1)"
  :precision binary64

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

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