Average Error: 14.3 → 0.0
Time: 8.3s
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 r3139240 = x;
        double r3139241 = r3139240 * r3139240;
        double r3139242 = 1.0;
        double r3139243 = r3139241 + r3139242;
        double r3139244 = r3139240 / r3139243;
        return r3139244;
}

double f(double x) {
        double r3139245 = x;
        double r3139246 = -267060974.6176845;
        bool r3139247 = r3139245 <= r3139246;
        double r3139248 = 1.0;
        double r3139249 = 5.0;
        double r3139250 = pow(r3139245, r3139249);
        double r3139251 = r3139248 / r3139250;
        double r3139252 = r3139245 * r3139245;
        double r3139253 = r3139252 * r3139245;
        double r3139254 = r3139248 / r3139253;
        double r3139255 = r3139251 - r3139254;
        double r3139256 = 1.0;
        double r3139257 = r3139256 / r3139245;
        double r3139258 = r3139255 + r3139257;
        double r3139259 = 508.8749887332333;
        bool r3139260 = r3139245 <= r3139259;
        double r3139261 = r3139248 + r3139252;
        double r3139262 = r3139245 / r3139261;
        double r3139263 = r3139260 ? r3139262 : r3139258;
        double r3139264 = r3139247 ? r3139258 : r3139263;
        return r3139264;
}

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)))