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

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

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

\end{array}
double f(double x) {
        double r6040467 = x;
        double r6040468 = r6040467 * r6040467;
        double r6040469 = 1.0;
        double r6040470 = r6040468 + r6040469;
        double r6040471 = r6040467 / r6040470;
        return r6040471;
}

double f(double x) {
        double r6040472 = x;
        double r6040473 = -2125041.416232987;
        bool r6040474 = r6040472 <= r6040473;
        double r6040475 = 1.0;
        double r6040476 = 5.0;
        double r6040477 = pow(r6040472, r6040476);
        double r6040478 = r6040475 / r6040477;
        double r6040479 = r6040475 / r6040472;
        double r6040480 = r6040478 + r6040479;
        double r6040481 = r6040472 * r6040472;
        double r6040482 = r6040481 * r6040472;
        double r6040483 = r6040475 / r6040482;
        double r6040484 = r6040480 - r6040483;
        double r6040485 = 406.12657832258094;
        bool r6040486 = r6040472 <= r6040485;
        double r6040487 = r6040481 * r6040481;
        double r6040488 = r6040487 - r6040475;
        double r6040489 = r6040472 / r6040488;
        double r6040490 = r6040481 - r6040475;
        double r6040491 = r6040489 * r6040490;
        double r6040492 = r6040486 ? r6040491 : r6040484;
        double r6040493 = r6040474 ? r6040484 : r6040492;
        return r6040493;
}

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 < -2125041.416232987 or 406.12657832258094 < x

    1. Initial program 30.5

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

    if -2125041.416232987 < x < 406.12657832258094

    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)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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

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

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