Average Error: 15.3 → 0.2
Time: 8.1s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x}{x \cdot x + 1} \le -8.305525141653350098708202002602406887923 \cdot 10^{-306} \lor \neg \left(\frac{x}{x \cdot x + 1} \le -0.0\right):\\ \;\;\;\;\frac{\frac{x}{\sqrt{x \cdot x + 1}}}{\sqrt{x \cdot x + 1}}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right) + \frac{1}{x}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;\frac{x}{x \cdot x + 1} \le -8.305525141653350098708202002602406887923 \cdot 10^{-306} \lor \neg \left(\frac{x}{x \cdot x + 1} \le -0.0\right):\\
\;\;\;\;\frac{\frac{x}{\sqrt{x \cdot x + 1}}}{\sqrt{x \cdot x + 1}}\\

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

\end{array}
double f(double x) {
        double r37457 = x;
        double r37458 = r37457 * r37457;
        double r37459 = 1.0;
        double r37460 = r37458 + r37459;
        double r37461 = r37457 / r37460;
        return r37461;
}

double f(double x) {
        double r37462 = x;
        double r37463 = r37462 * r37462;
        double r37464 = 1.0;
        double r37465 = r37463 + r37464;
        double r37466 = r37462 / r37465;
        double r37467 = -8.30552514165335e-306;
        bool r37468 = r37466 <= r37467;
        double r37469 = -0.0;
        bool r37470 = r37466 <= r37469;
        double r37471 = !r37470;
        bool r37472 = r37468 || r37471;
        double r37473 = sqrt(r37465);
        double r37474 = r37462 / r37473;
        double r37475 = r37474 / r37473;
        double r37476 = 1.0;
        double r37477 = 5.0;
        double r37478 = pow(r37462, r37477);
        double r37479 = r37476 / r37478;
        double r37480 = 3.0;
        double r37481 = pow(r37462, r37480);
        double r37482 = r37476 / r37481;
        double r37483 = r37479 - r37482;
        double r37484 = r37464 * r37483;
        double r37485 = r37476 / r37462;
        double r37486 = r37484 + r37485;
        double r37487 = r37472 ? r37475 : r37486;
        return r37487;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.3
Target0.1
Herbie0.2
\[\frac{1}{x + \frac{1}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ x (+ (* x x) 1.0)) < -8.30552514165335e-306 or -0.0 < (/ x (+ (* x x) 1.0))

    1. Initial program 8.8

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

      \[\leadsto \frac{x}{\color{blue}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}}\]
    4. Applied associate-/r*8.8

      \[\leadsto \color{blue}{\frac{\frac{x}{\sqrt{x \cdot x + 1}}}{\sqrt{x \cdot x + 1}}}\]

    if -8.30552514165335e-306 < (/ x (+ (* x x) 1.0)) < -0.0

    1. Initial program 57.9

      \[\frac{x}{x \cdot x + 1}\]
    2. Taylor expanded around inf 1.7

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

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

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

Reproduce

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

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

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