Average Error: 14.8 → 0.0
Time: 4.5s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -12032692145665368408206631501824 \lor \neg \left(x \le \frac{8271544473083267}{17592186044416}\right):\\ \;\;\;\;\frac{1}{x} + 1 \cdot \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1}} \cdot \frac{x}{x \cdot x + 1}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -12032692145665368408206631501824 \lor \neg \left(x \le \frac{8271544473083267}{17592186044416}\right):\\
\;\;\;\;\frac{1}{x} + 1 \cdot \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)\\

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

\end{array}
double f(double x) {
        double r45993 = x;
        double r45994 = r45993 * r45993;
        double r45995 = 1.0;
        double r45996 = r45994 + r45995;
        double r45997 = r45993 / r45996;
        return r45997;
}

double f(double x) {
        double r45998 = x;
        double r45999 = -1.2032692145665368e+31;
        bool r46000 = r45998 <= r45999;
        double r46001 = 8271544473083267.0;
        double r46002 = 17592186044416.0;
        double r46003 = r46001 / r46002;
        bool r46004 = r45998 <= r46003;
        double r46005 = !r46004;
        bool r46006 = r46000 || r46005;
        double r46007 = 1.0;
        double r46008 = r46007 / r45998;
        double r46009 = 1.0;
        double r46010 = 5.0;
        double r46011 = pow(r45998, r46010);
        double r46012 = r46007 / r46011;
        double r46013 = 3.0;
        double r46014 = pow(r45998, r46013);
        double r46015 = r46007 / r46014;
        double r46016 = r46012 - r46015;
        double r46017 = r46009 * r46016;
        double r46018 = r46008 + r46017;
        double r46019 = sqrt(r46007);
        double r46020 = r46007 / r46019;
        double r46021 = r45998 * r45998;
        double r46022 = r46021 + r46009;
        double r46023 = r45998 / r46022;
        double r46024 = r46020 * r46023;
        double r46025 = r46006 ? r46018 : r46024;
        return r46025;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -1.2032692145665368e+31 or 470.1828671092737 < x

    1. Initial program 31.6

      \[\frac{x}{x \cdot x + 1}\]
    2. 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}}}\]
    3. Simplified0.0

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

    if -1.2032692145665368e+31 < x < 470.1828671092737

    1. Initial program 0.0

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity0.0

      \[\leadsto \frac{1}{\sqrt{\color{blue}{1 \cdot \left(x \cdot x + 1\right)}}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\]
    8. Applied sqrt-prod0.0

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1} \cdot \sqrt{x \cdot x + 1}}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\]
    9. Applied *-un-lft-identity0.0

      \[\leadsto \frac{\color{blue}{1 \cdot 1}}{\sqrt{1} \cdot \sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\]
    10. Applied times-frac0.0

      \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{1}} \cdot \frac{1}{\sqrt{x \cdot x + 1}}\right)} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\]
    11. Applied associate-*l*0.0

      \[\leadsto \color{blue}{\frac{1}{\sqrt{1}} \cdot \left(\frac{1}{\sqrt{x \cdot x + 1}} \cdot \frac{x}{\sqrt{x \cdot x + 1}}\right)}\]
    12. Simplified0.0

      \[\leadsto \frac{1}{\sqrt{1}} \cdot \color{blue}{\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 -12032692145665368408206631501824 \lor \neg \left(x \le \frac{8271544473083267}{17592186044416}\right):\\ \;\;\;\;\frac{1}{x} + 1 \cdot \left(\frac{1}{{x}^{5}} - \frac{1}{{x}^{3}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\sqrt{1}} \cdot \frac{x}{x \cdot x + 1}\\ \end{array}\]

Reproduce

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

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

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