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

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

\end{array}
double f(double x) {
        double r60857 = x;
        double r60858 = r60857 * r60857;
        double r60859 = 1.0;
        double r60860 = r60858 + r60859;
        double r60861 = r60857 / r60860;
        return r60861;
}

double f(double x) {
        double r60862 = x;
        double r60863 = -6092285729639.722;
        bool r60864 = r60862 <= r60863;
        double r60865 = 897.3710299305061;
        bool r60866 = r60862 <= r60865;
        double r60867 = !r60866;
        bool r60868 = r60864 || r60867;
        double r60869 = 1.0;
        double r60870 = r60869 / r60862;
        double r60871 = 1.0;
        double r60872 = 3.0;
        double r60873 = pow(r60862, r60872);
        double r60874 = r60871 / r60873;
        double r60875 = r60870 - r60874;
        double r60876 = 5.0;
        double r60877 = pow(r60862, r60876);
        double r60878 = r60871 / r60877;
        double r60879 = r60875 + r60878;
        double r60880 = r60862 * r60862;
        double r60881 = r60880 + r60871;
        double r60882 = r60869 / r60881;
        double r60883 = r60862 * r60882;
        double r60884 = r60868 ? r60879 : r60883;
        return r60884;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -6092285729639.722 or 897.3710299305061 < x

    1. Initial program 30.2

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied div-inv30.2

      \[\leadsto \color{blue}{x \cdot \frac{1}{x \cdot x + 1}}\]
    4. 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}}}\]
    5. Simplified0.0

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

    if -6092285729639.722 < x < 897.3710299305061

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied div-inv0.0

      \[\leadsto \color{blue}{x \cdot \frac{1}{x \cdot x + 1}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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

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

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