Average Error: 14.3 → 0.0
Time: 8.8s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -267060974.6176845133304595947265625:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{x}\\ \mathbf{elif}\;x \le 508.8749887332332946243695914745330810547:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \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 -267060974.6176845133304595947265625:\\
\;\;\;\;\left(\frac{1}{{x}^{5}} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{x}\\

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

\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 r3126528 = x;
        double r3126529 = r3126528 * r3126528;
        double r3126530 = 1.0;
        double r3126531 = r3126529 + r3126530;
        double r3126532 = r3126528 / r3126531;
        return r3126532;
}

double f(double x) {
        double r3126533 = x;
        double r3126534 = -267060974.6176845;
        bool r3126535 = r3126533 <= r3126534;
        double r3126536 = 1.0;
        double r3126537 = 5.0;
        double r3126538 = pow(r3126533, r3126537);
        double r3126539 = r3126536 / r3126538;
        double r3126540 = r3126533 * r3126533;
        double r3126541 = r3126540 * r3126533;
        double r3126542 = r3126536 / r3126541;
        double r3126543 = r3126539 - r3126542;
        double r3126544 = 1.0;
        double r3126545 = r3126544 / r3126533;
        double r3126546 = r3126543 + r3126545;
        double r3126547 = 508.8749887332333;
        bool r3126548 = r3126533 <= r3126547;
        double r3126549 = r3126536 + r3126540;
        double r3126550 = r3126533 / r3126549;
        double r3126551 = r3126548 ? r3126550 : r3126546;
        double r3126552 = r3126535 ? r3126546 : r3126551;
        return r3126552;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -267060974.6176845 or 508.8749887332333 < x

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

    if -267060974.6176845 < x < 508.8749887332333

    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 -267060974.6176845133304595947265625:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} - \frac{1}{\left(x \cdot x\right) \cdot x}\right) + \frac{1}{x}\\ \mathbf{elif}\;x \le 508.8749887332332946243695914745330810547:\\ \;\;\;\;\frac{x}{1 + x \cdot x}\\ \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 2019172 
(FPCore (x)
  :name "x / (x^2 + 1)"

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

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