Average Error: 14.3 → 0.1
Time: 47.0s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\frac{1}{x + \frac{1}{x}}\]
double f(double x) {
        double r6935921 = x;
        double r6935922 = r6935921 * r6935921;
        double r6935923 = 1.0;
        double r6935924 = r6935922 + r6935923;
        double r6935925 = r6935921 / r6935924;
        return r6935925;
}

double f(double x) {
        double r6935926 = 1.0;
        double r6935927 = x;
        double r6935928 = r6935926 / r6935927;
        double r6935929 = r6935927 + r6935928;
        double r6935930 = r6935926 / r6935929;
        return r6935930;
}

\frac{x}{x \cdot x + 1}
\frac{1}{x + \frac{1}{x}}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 14.3

    \[\frac{x}{x \cdot x + 1}\]
  2. Using strategy rm
  3. Applied *-un-lft-identity14.3

    \[\leadsto \frac{\color{blue}{1 \cdot x}}{x \cdot x + 1}\]
  4. Applied associate-/l*14.3

    \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + 1}{x}}}\]
  5. Taylor expanded around 0 0.1

    \[\leadsto \frac{1}{\color{blue}{x + \frac{1}{x}}}\]
  6. Final simplification0.1

    \[\leadsto \frac{1}{x + \frac{1}{x}}\]

Reproduce

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

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

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