Average Error: 15.1 → 0.0
Time: 2.4m
Precision: 64
\[\frac{x}{x \cdot x + 1}\]
\[\frac{1}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{x}{\mathsf{hypot}\left(1, x\right)}\]
\frac{x}{x \cdot x + 1}
\frac{1}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{x}{\mathsf{hypot}\left(1, x\right)}
double f(double x) {
        double r1978612 = x;
        double r1978613 = r1978612 * r1978612;
        double r1978614 = 1.0;
        double r1978615 = r1978613 + r1978614;
        double r1978616 = r1978612 / r1978615;
        return r1978616;
}

double f(double x) {
        double r1978617 = 1.0;
        double r1978618 = x;
        double r1978619 = hypot(r1978617, r1978618);
        double r1978620 = r1978617 / r1978619;
        double r1978621 = r1978618 / r1978619;
        double r1978622 = r1978620 * r1978621;
        return r1978622;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 15.1

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

    \[\leadsto \color{blue}{\frac{x}{\mathsf{fma}\left(x, x, 1\right)}}\]
  3. Using strategy rm
  4. Applied *-un-lft-identity15.1

    \[\leadsto \frac{\color{blue}{1 \cdot x}}{\mathsf{fma}\left(x, x, 1\right)}\]
  5. Applied associate-/l*15.1

    \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(x, x, 1\right)}{x}}}\]
  6. Using strategy rm
  7. Applied *-un-lft-identity15.1

    \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(x, x, 1\right)}{\color{blue}{1 \cdot x}}}\]
  8. Applied add-sqr-sqrt15.1

    \[\leadsto \frac{1}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(x, x, 1\right)} \cdot \sqrt{\mathsf{fma}\left(x, x, 1\right)}}}{1 \cdot x}}\]
  9. Applied times-frac15.1

    \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}{x}}}\]
  10. Applied add-cube-cbrt15.1

    \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}{x}}\]
  11. Applied times-frac15.1

    \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}{x}}}\]
  12. Simplified15.1

    \[\leadsto \color{blue}{\frac{1}{\mathsf{hypot}\left(1, x\right)}} \cdot \frac{\sqrt[3]{1}}{\frac{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}{x}}\]
  13. Simplified0.0

    \[\leadsto \frac{1}{\mathsf{hypot}\left(1, x\right)} \cdot \color{blue}{\frac{x}{\mathsf{hypot}\left(1, x\right)}}\]
  14. Final simplification0.0

    \[\leadsto \frac{1}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{x}{\mathsf{hypot}\left(1, x\right)}\]

Reproduce

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

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

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