Average Error: 15.4 → 0.0
Time: 11.7s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -243329265348.2015:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\\ \mathbf{elif}\;x \le 517.3933217180979:\\ \;\;\;\;\frac{1}{1 + x \cdot x} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -243329265348.2015:\\
\;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\\

\mathbf{elif}\;x \le 517.3933217180979:\\
\;\;\;\;\frac{1}{1 + x \cdot x} \cdot x\\

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

\end{array}
double f(double x) {
        double r1307731 = x;
        double r1307732 = r1307731 * r1307731;
        double r1307733 = 1.0;
        double r1307734 = r1307732 + r1307733;
        double r1307735 = r1307731 / r1307734;
        return r1307735;
}

double f(double x) {
        double r1307736 = x;
        double r1307737 = -243329265348.2015;
        bool r1307738 = r1307736 <= r1307737;
        double r1307739 = 1.0;
        double r1307740 = r1307739 / r1307736;
        double r1307741 = r1307736 * r1307736;
        double r1307742 = r1307740 / r1307741;
        double r1307743 = r1307740 - r1307742;
        double r1307744 = r1307741 * r1307736;
        double r1307745 = r1307744 * r1307741;
        double r1307746 = r1307739 / r1307745;
        double r1307747 = r1307743 + r1307746;
        double r1307748 = 517.3933217180979;
        bool r1307749 = r1307736 <= r1307748;
        double r1307750 = r1307739 + r1307741;
        double r1307751 = r1307739 / r1307750;
        double r1307752 = r1307751 * r1307736;
        double r1307753 = r1307749 ? r1307752 : r1307747;
        double r1307754 = r1307738 ? r1307747 : r1307753;
        return r1307754;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.4
Target0.1
Herbie0.0
\[\frac{1}{x + \frac{1}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -243329265348.2015 or 517.3933217180979 < x

    1. Initial program 31.6

      \[\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}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}}\]

    if -243329265348.2015 < x < 517.3933217180979

    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 -243329265348.2015:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\\ \mathbf{elif}\;x \le 517.3933217180979:\\ \;\;\;\;\frac{1}{1 + x \cdot x} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} - \frac{\frac{1}{x}}{x \cdot x}\right) + \frac{1}{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(x \cdot x\right)}\\ \end{array}\]

Reproduce

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

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

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