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

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

\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 r11141068 = x;
        double r11141069 = r11141068 * r11141068;
        double r11141070 = 1.0;
        double r11141071 = r11141069 + r11141070;
        double r11141072 = r11141068 / r11141071;
        return r11141072;
}

double f(double x) {
        double r11141073 = x;
        double r11141074 = -61349745.21847331;
        bool r11141075 = r11141073 <= r11141074;
        double r11141076 = 1.0;
        double r11141077 = 5.0;
        double r11141078 = pow(r11141073, r11141077);
        double r11141079 = r11141076 / r11141078;
        double r11141080 = r11141076 / r11141073;
        double r11141081 = r11141079 + r11141080;
        double r11141082 = r11141073 * r11141073;
        double r11141083 = r11141082 * r11141073;
        double r11141084 = r11141076 / r11141083;
        double r11141085 = r11141081 - r11141084;
        double r11141086 = 405.32013382536394;
        bool r11141087 = r11141073 <= r11141086;
        double r11141088 = r11141076 + r11141082;
        double r11141089 = sqrt(r11141088);
        double r11141090 = r11141073 / r11141089;
        double r11141091 = r11141076 / r11141089;
        double r11141092 = r11141090 * r11141091;
        double r11141093 = r11141087 ? r11141092 : r11141085;
        double r11141094 = r11141075 ? r11141085 : r11141093;
        return r11141094;
}

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 < -61349745.21847331 or 405.32013382536394 < x

    1. Initial program 30.1

      \[\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 -61349745.21847331 < x < 405.32013382536394

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.0

      \[\leadsto \frac{x}{\color{blue}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}}\]
    4. Applied *-un-lft-identity0.0

      \[\leadsto \frac{\color{blue}{1 \cdot x}}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}\]
    5. Applied times-frac0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -61349745.21847331:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{\left(x \cdot x\right) \cdot x}\\ \mathbf{elif}\;x \le 405.32013382536394:\\ \;\;\;\;\frac{x}{\sqrt{1 + x \cdot x}} \cdot \frac{1}{\sqrt{1 + x \cdot x}}\\ \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 2019125 
(FPCore (x)
  :name "x / (x^2 + 1)"

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

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