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

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

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

\end{array}
double f(double x) {
        double r1091216 = x;
        double r1091217 = r1091216 * r1091216;
        double r1091218 = 1.0;
        double r1091219 = r1091217 + r1091218;
        double r1091220 = r1091216 / r1091219;
        return r1091220;
}

double f(double x) {
        double r1091221 = x;
        double r1091222 = -16681204427079.668;
        bool r1091223 = r1091221 <= r1091222;
        double r1091224 = 1.0;
        double r1091225 = r1091224 / r1091221;
        double r1091226 = r1091221 * r1091221;
        double r1091227 = r1091225 / r1091226;
        double r1091228 = r1091226 * r1091221;
        double r1091229 = r1091228 * r1091226;
        double r1091230 = r1091224 / r1091229;
        double r1091231 = r1091227 - r1091230;
        double r1091232 = r1091225 - r1091231;
        double r1091233 = 380.83448745307305;
        bool r1091234 = r1091221 <= r1091233;
        double r1091235 = r1091226 * r1091226;
        double r1091236 = r1091235 - r1091224;
        double r1091237 = r1091221 / r1091236;
        double r1091238 = r1091226 - r1091224;
        double r1091239 = r1091237 * r1091238;
        double r1091240 = r1091234 ? r1091239 : r1091232;
        double r1091241 = r1091223 ? r1091232 : r1091240;
        return r1091241;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -16681204427079.668 or 380.83448745307305 < x

    1. Initial program 30.3

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

    if -16681204427079.668 < x < 380.83448745307305

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

Reproduce

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

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

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