Average Error: 14.9 → 0.0
Time: 24.8s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.182351251673564960881259272718336657084 \cdot 10^{51}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{x}\\ \mathbf{elif}\;x \le 268164.477104543824680149555206298828125:\\ \;\;\;\;\frac{x}{x \cdot x + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{x}\\ \end{array}\]
\frac{x}{x \cdot x + 1}
\begin{array}{l}
\mathbf{if}\;x \le -2.182351251673564960881259272718336657084 \cdot 10^{51}:\\
\;\;\;\;\left(\frac{1}{{x}^{5}} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{x}\\

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

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

\end{array}
double f(double x) {
        double r4008574 = x;
        double r4008575 = r4008574 * r4008574;
        double r4008576 = 1.0;
        double r4008577 = r4008575 + r4008576;
        double r4008578 = r4008574 / r4008577;
        return r4008578;
}

double f(double x) {
        double r4008579 = x;
        double r4008580 = -2.182351251673565e+51;
        bool r4008581 = r4008579 <= r4008580;
        double r4008582 = 1.0;
        double r4008583 = 5.0;
        double r4008584 = pow(r4008579, r4008583);
        double r4008585 = r4008582 / r4008584;
        double r4008586 = r4008579 * r4008579;
        double r4008587 = r4008586 * r4008579;
        double r4008588 = r4008582 / r4008587;
        double r4008589 = r4008585 - r4008588;
        double r4008590 = 1.0;
        double r4008591 = r4008590 / r4008579;
        double r4008592 = r4008589 + r4008591;
        double r4008593 = 268164.4771045438;
        bool r4008594 = r4008579 <= r4008593;
        double r4008595 = r4008586 + r4008582;
        double r4008596 = r4008579 / r4008595;
        double r4008597 = r4008594 ? r4008596 : r4008592;
        double r4008598 = r4008581 ? r4008592 : r4008597;
        return r4008598;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -2.182351251673565e+51 or 268164.4771045438 < x

    1. Initial program 32.5

      \[\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} + \left(\frac{1}{{x}^{5}} - \frac{1}{\left(x \cdot x\right) \cdot x}\right)}\]

    if -2.182351251673565e+51 < x < 268164.4771045438

    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 -2.182351251673564960881259272718336657084 \cdot 10^{51}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{x}\\ \mathbf{elif}\;x \le 268164.477104543824680149555206298828125:\\ \;\;\;\;\frac{x}{x \cdot x + 1}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{x}\\ \end{array}\]

Reproduce

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

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

  (/ x (+ (* x x) 1.0)))