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

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

\end{array}
double f(double x) {
        double r54434 = x;
        double r54435 = r54434 * r54434;
        double r54436 = 1.0;
        double r54437 = r54435 + r54436;
        double r54438 = r54434 / r54437;
        return r54438;
}

double f(double x) {
        double r54439 = x;
        double r54440 = -853997951174.7607;
        bool r54441 = r54439 <= r54440;
        double r54442 = 529.597454464039;
        bool r54443 = r54439 <= r54442;
        double r54444 = !r54443;
        bool r54445 = r54441 || r54444;
        double r54446 = 1.0;
        double r54447 = r54446 / r54439;
        double r54448 = 1.0;
        double r54449 = 3.0;
        double r54450 = pow(r54439, r54449);
        double r54451 = r54448 / r54450;
        double r54452 = r54447 - r54451;
        double r54453 = 5.0;
        double r54454 = pow(r54439, r54453);
        double r54455 = r54448 / r54454;
        double r54456 = r54452 + r54455;
        double r54457 = r54439 * r54439;
        double r54458 = r54457 + r54448;
        double r54459 = r54439 / r54458;
        double r54460 = r54445 ? r54456 : r54459;
        return r54460;
}

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 < -853997951174.7607 or 529.597454464039 < x

    1. Initial program 30.5

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}}\]
    6. Using strategy rm
    7. Applied clear-num30.4

      \[\leadsto \frac{1}{\sqrt{x \cdot x + 1}} \cdot \color{blue}{\frac{1}{\frac{\sqrt{x \cdot x + 1}}{x}}}\]
    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}^{3}}\right) + \frac{1}{{x}^{5}}}\]

    if -853997951174.7607 < x < 529.597454464039

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

Reproduce

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

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

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