Average Error: 14.3 → 0.0
Time: 35.1s
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\frac{1}{\sqrt{1^2 + x^2}^*} \cdot \frac{x}{\sqrt{1^2 + x^2}^*}\]
double f(double x) {
        double r5662522 = x;
        double r5662523 = r5662522 * r5662522;
        double r5662524 = 1.0;
        double r5662525 = r5662523 + r5662524;
        double r5662526 = r5662522 / r5662525;
        return r5662526;
}

double f(double x) {
        double r5662527 = 1.0;
        double r5662528 = x;
        double r5662529 = hypot(r5662527, r5662528);
        double r5662530 = r5662527 / r5662529;
        double r5662531 = r5662528 / r5662529;
        double r5662532 = r5662530 * r5662531;
        return r5662532;
}

\frac{x}{x \cdot x + 1}
\frac{1}{\sqrt{1^2 + x^2}^*} \cdot \frac{x}{\sqrt{1^2 + x^2}^*}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 14.3

    \[\frac{x}{x \cdot x + 1}\]
  2. Simplified14.3

    \[\leadsto \color{blue}{\frac{x}{(x \cdot x + 1)_*}}\]
  3. Using strategy rm
  4. Applied *-un-lft-identity14.3

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

    \[\leadsto \color{blue}{\frac{1}{\frac{(x \cdot x + 1)_*}{x}}}\]
  6. Using strategy rm
  7. Applied *-un-lft-identity14.3

    \[\leadsto \frac{1}{\frac{(x \cdot x + 1)_*}{\color{blue}{1 \cdot x}}}\]
  8. Applied add-sqr-sqrt14.3

    \[\leadsto \frac{1}{\frac{\color{blue}{\sqrt{(x \cdot x + 1)_*} \cdot \sqrt{(x \cdot x + 1)_*}}}{1 \cdot x}}\]
  9. Applied times-frac14.3

    \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{(x \cdot x + 1)_*}}{1} \cdot \frac{\sqrt{(x \cdot x + 1)_*}}{x}}}\]
  10. Applied add-cube-cbrt14.3

    \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{\sqrt{(x \cdot x + 1)_*}}{1} \cdot \frac{\sqrt{(x \cdot x + 1)_*}}{x}}\]
  11. Applied times-frac14.3

    \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{\sqrt{(x \cdot x + 1)_*}}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{\sqrt{(x \cdot x + 1)_*}}{x}}}\]
  12. Simplified14.3

    \[\leadsto \color{blue}{\frac{1}{\sqrt{1^2 + x^2}^*}} \cdot \frac{\sqrt[3]{1}}{\frac{\sqrt{(x \cdot x + 1)_*}}{x}}\]
  13. Simplified0.0

    \[\leadsto \frac{1}{\sqrt{1^2 + x^2}^*} \cdot \color{blue}{\frac{x}{\sqrt{1^2 + x^2}^*}}\]
  14. Final simplification0.0

    \[\leadsto \frac{1}{\sqrt{1^2 + x^2}^*} \cdot \frac{x}{\sqrt{1^2 + x^2}^*}\]

Reproduce

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

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

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