Average Error: 15.1 → 0.0
Time: 12.9s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -484064.81338059285:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{{x}^{5}}\\ \mathbf{elif}\;x \le 8137.871959944802:\\ \;\;\;\;\left(x \cdot x - 1\right) \cdot \frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{{x}^{5}}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -484064.81338059285:\\
\;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{{x}^{5}}\\

\mathbf{elif}\;x \le 8137.871959944802:\\
\;\;\;\;\left(x \cdot x - 1\right) \cdot \frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + -1}\\

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

\end{array}
double f(double x) {
        double r1143674 = x;
        double r1143675 = r1143674 * r1143674;
        double r1143676 = 1.0;
        double r1143677 = r1143675 + r1143676;
        double r1143678 = r1143674 / r1143677;
        return r1143678;
}

double f(double x) {
        double r1143679 = x;
        double r1143680 = -484064.81338059285;
        bool r1143681 = r1143679 <= r1143680;
        double r1143682 = 1.0;
        double r1143683 = r1143682 / r1143679;
        double r1143684 = r1143679 * r1143679;
        double r1143685 = r1143683 / r1143684;
        double r1143686 = r1143683 - r1143685;
        double r1143687 = 5.0;
        double r1143688 = pow(r1143679, r1143687);
        double r1143689 = r1143682 / r1143688;
        double r1143690 = r1143686 + r1143689;
        double r1143691 = 8137.871959944802;
        bool r1143692 = r1143679 <= r1143691;
        double r1143693 = r1143684 - r1143682;
        double r1143694 = r1143684 * r1143684;
        double r1143695 = -1.0;
        double r1143696 = r1143694 + r1143695;
        double r1143697 = r1143679 / r1143696;
        double r1143698 = r1143693 * r1143697;
        double r1143699 = r1143692 ? r1143698 : r1143690;
        double r1143700 = r1143681 ? r1143690 : r1143699;
        return r1143700;
}

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 < -484064.81338059285 or 8137.871959944802 < x

    1. Initial program 30.8

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

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

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

    if -484064.81338059285 < x < 8137.871959944802

    1. Initial program 0.0

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

      \[\leadsto \frac{x}{\color{blue}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1}{x \cdot x - 1}}}\]
    4. Applied associate-/r/0.0

      \[\leadsto \color{blue}{\frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1} \cdot \left(x \cdot x - 1\right)}\]
    5. Simplified0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -484064.81338059285:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{{x}^{5}}\\ \mathbf{elif}\;x \le 8137.871959944802:\\ \;\;\;\;\left(x \cdot x - 1\right) \cdot \frac{x}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + -1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{{x}^{5}}\\ \end{array}\]

Reproduce

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

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

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