Average Error: 20.4 → 0.0
Time: 4.3s
Precision: 64
\[0.0 \lt x \lt 1 \land y \lt 1\]
\[\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\]
\[\sqrt[3]{\sqrt[3]{{\left({\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \frac{1}{x + y}\right)}\right)}^{3}\right)}^{3}}}\]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\sqrt[3]{\sqrt[3]{{\left({\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \frac{1}{x + y}\right)}\right)}^{3}\right)}^{3}}}
double f(double x, double y) {
        double r92744 = x;
        double r92745 = y;
        double r92746 = r92744 - r92745;
        double r92747 = r92744 + r92745;
        double r92748 = r92746 * r92747;
        double r92749 = r92744 * r92744;
        double r92750 = r92745 * r92745;
        double r92751 = r92749 + r92750;
        double r92752 = r92748 / r92751;
        return r92752;
}

double f(double x, double y) {
        double r92753 = x;
        double r92754 = y;
        double r92755 = r92753 - r92754;
        double r92756 = hypot(r92753, r92754);
        double r92757 = 1.0;
        double r92758 = r92753 + r92754;
        double r92759 = r92757 / r92758;
        double r92760 = r92756 * r92759;
        double r92761 = r92756 * r92760;
        double r92762 = r92755 / r92761;
        double r92763 = 3.0;
        double r92764 = pow(r92762, r92763);
        double r92765 = pow(r92764, r92763);
        double r92766 = cbrt(r92765);
        double r92767 = cbrt(r92766);
        return r92767;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.4
Target0.0
Herbie0.0
\[\begin{array}{l} \mathbf{if}\;0.5 \lt \left|\frac{x}{y}\right| \lt 2:\\ \;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{2}{1 + \frac{x}{y} \cdot \frac{x}{y}}\\ \end{array}\]

Derivation

  1. Initial program 20.4

    \[\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\]
  2. Simplified20.5

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

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

    \[\leadsto \frac{x - y}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)} \cdot \sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}}}{1 \cdot \left(x + y\right)}}\]
  6. Applied times-frac20.5

    \[\leadsto \frac{x - y}{\color{blue}{\frac{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}}{x + y}}}\]
  7. Simplified20.5

    \[\leadsto \frac{x - y}{\color{blue}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}}{x + y}}\]
  8. Simplified0.0

    \[\leadsto \frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\frac{\mathsf{hypot}\left(x, y\right)}{x + y}}}\]
  9. Using strategy rm
  10. Applied add-cbrt-cube32.7

    \[\leadsto \frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{\mathsf{hypot}\left(x, y\right)}{\color{blue}{\sqrt[3]{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}}}}\]
  11. Applied add-cbrt-cube32.6

    \[\leadsto \frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{\color{blue}{\sqrt[3]{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}}}{\sqrt[3]{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}}}\]
  12. Applied cbrt-undiv32.6

    \[\leadsto \frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\sqrt[3]{\frac{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}}}}\]
  13. Applied add-cbrt-cube33.2

    \[\leadsto \frac{x - y}{\color{blue}{\sqrt[3]{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}} \cdot \sqrt[3]{\frac{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}}}\]
  14. Applied cbrt-unprod33.2

    \[\leadsto \frac{x - y}{\color{blue}{\sqrt[3]{\left(\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \frac{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}}}}\]
  15. Applied add-cbrt-cube32.6

    \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}}}{\sqrt[3]{\left(\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \frac{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}}}\]
  16. Applied cbrt-undiv32.6

    \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}{\left(\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \frac{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}}}}\]
  17. Simplified0.0

    \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{\mathsf{hypot}\left(x, y\right)}{x + y}}\right)}^{3}}}\]
  18. Using strategy rm
  19. Applied add-cbrt-cube0.0

    \[\leadsto \sqrt[3]{\color{blue}{\sqrt[3]{\left({\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{\mathsf{hypot}\left(x, y\right)}{x + y}}\right)}^{3} \cdot {\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{\mathsf{hypot}\left(x, y\right)}{x + y}}\right)}^{3}\right) \cdot {\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{\mathsf{hypot}\left(x, y\right)}{x + y}}\right)}^{3}}}}\]
  20. Simplified0.0

    \[\leadsto \sqrt[3]{\sqrt[3]{\color{blue}{{\left({\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{\mathsf{hypot}\left(x, y\right)}{x + y}}\right)}^{3}\right)}^{3}}}}\]
  21. Using strategy rm
  22. Applied div-inv0.0

    \[\leadsto \sqrt[3]{\sqrt[3]{{\left({\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \color{blue}{\left(\mathsf{hypot}\left(x, y\right) \cdot \frac{1}{x + y}\right)}}\right)}^{3}\right)}^{3}}}\]
  23. Final simplification0.0

    \[\leadsto \sqrt[3]{\sqrt[3]{{\left({\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \left(\mathsf{hypot}\left(x, y\right) \cdot \frac{1}{x + y}\right)}\right)}^{3}\right)}^{3}}}\]

Reproduce

herbie shell --seed 2020002 +o rules:numerics
(FPCore (x y)
  :name "Kahan p9 Example"
  :precision binary64
  :pre (and (< 0.0 x 1) (< y 1))

  :herbie-target
  (if (< 0.5 (fabs (/ x y)) 2) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1 (/ 2 (+ 1 (* (/ x y) (/ x y))))))

  (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))