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

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

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

\end{array}
double f(double x) {
        double r3287069 = x;
        double r3287070 = r3287069 * r3287069;
        double r3287071 = 1.0;
        double r3287072 = r3287070 + r3287071;
        double r3287073 = r3287069 / r3287072;
        return r3287073;
}

double f(double x) {
        double r3287074 = x;
        double r3287075 = -1705237591405488.8;
        bool r3287076 = r3287074 <= r3287075;
        double r3287077 = 1.0;
        double r3287078 = r3287077 / r3287074;
        double r3287079 = 1.0;
        double r3287080 = r3287074 * r3287074;
        double r3287081 = r3287080 * r3287074;
        double r3287082 = r3287079 / r3287081;
        double r3287083 = r3287078 - r3287082;
        double r3287084 = 5.0;
        double r3287085 = pow(r3287074, r3287084);
        double r3287086 = r3287079 / r3287085;
        double r3287087 = r3287083 + r3287086;
        double r3287088 = 520.0181111297961;
        bool r3287089 = r3287074 <= r3287088;
        double r3287090 = r3287079 * r3287079;
        double r3287091 = r3287079 * r3287090;
        double r3287092 = r3287080 * r3287080;
        double r3287093 = r3287080 * r3287092;
        double r3287094 = r3287091 + r3287093;
        double r3287095 = r3287074 / r3287094;
        double r3287096 = r3287079 * r3287080;
        double r3287097 = r3287090 - r3287096;
        double r3287098 = r3287097 + r3287092;
        double r3287099 = r3287095 * r3287098;
        double r3287100 = r3287089 ? r3287099 : r3287087;
        double r3287101 = r3287076 ? r3287087 : r3287100;
        return r3287101;
}

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 < -1705237591405488.8 or 520.0181111297961 < x

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

    if -1705237591405488.8 < x < 520.0181111297961

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied flip3-+0.0

      \[\leadsto \frac{x}{\color{blue}{\frac{{\left(x \cdot x\right)}^{3} + {1}^{3}}{\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left(1 \cdot 1 - \left(x \cdot x\right) \cdot 1\right)}}}\]
    4. Applied associate-/r/0.0

      \[\leadsto \color{blue}{\frac{x}{{\left(x \cdot x\right)}^{3} + {1}^{3}} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left(1 \cdot 1 - \left(x \cdot x\right) \cdot 1\right)\right)}\]
    5. Simplified0.0

      \[\leadsto \color{blue}{\frac{x}{1 \cdot \left(1 \cdot 1\right) + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)}} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left(1 \cdot 1 - \left(x \cdot x\right) \cdot 1\right)\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.0

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

Reproduce

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

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

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