Average Error: 15.1 → 0.0
Time: 16.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}^{5}}\right) - \frac{1}{{x}^{3}}\\ \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}^{5}}\right) - \frac{1}{{x}^{3}}\\

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

\end{array}
double f(double x) {
        double r49200 = x;
        double r49201 = r49200 * r49200;
        double r49202 = 1.0;
        double r49203 = r49201 + r49202;
        double r49204 = r49200 / r49203;
        return r49204;
}

double f(double x) {
        double r49205 = x;
        double r49206 = -853997951174.7607;
        bool r49207 = r49205 <= r49206;
        double r49208 = 529.597454464039;
        bool r49209 = r49205 <= r49208;
        double r49210 = !r49209;
        bool r49211 = r49207 || r49210;
        double r49212 = 1.0;
        double r49213 = r49212 / r49205;
        double r49214 = 1.0;
        double r49215 = 5.0;
        double r49216 = pow(r49205, r49215);
        double r49217 = r49214 / r49216;
        double r49218 = r49213 + r49217;
        double r49219 = 3.0;
        double r49220 = pow(r49205, r49219);
        double r49221 = r49214 / r49220;
        double r49222 = r49218 - r49221;
        double r49223 = r49205 * r49205;
        double r49224 = r49223 + r49214;
        double r49225 = r49205 / r49224;
        double r49226 = r49211 ? r49222 : r49225;
        return r49226;
}

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. Simplified30.4

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

      \[\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 -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}^{5}}\right) - \frac{1}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot x + 1}\\ \end{array}\]

Reproduce

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

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

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