Average Error: 20.1 → 0.1
Time: 30.8s
Precision: 64
\[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]{\left(\left(\left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right) \cdot \frac{1}{\mathsf{hypot}\left(y, x\right)}\right) \cdot \left(\left(\frac{x - y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{\sqrt[3]{y + x}}{\sqrt[3]{\mathsf{hypot}\left(y, x\right)}}\right) \cdot \frac{\sqrt[3]{y + x} \cdot \sqrt[3]{y + x}}{\sqrt[3]{\mathsf{hypot}\left(y, x\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(y, x\right)}}\right)\right) \cdot \left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}\right)}\]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\sqrt[3]{\left(\left(\left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right) \cdot \frac{1}{\mathsf{hypot}\left(y, x\right)}\right) \cdot \left(\left(\frac{x - y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{\sqrt[3]{y + x}}{\sqrt[3]{\mathsf{hypot}\left(y, x\right)}}\right) \cdot \frac{\sqrt[3]{y + x} \cdot \sqrt[3]{y + x}}{\sqrt[3]{\mathsf{hypot}\left(y, x\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(y, x\right)}}\right)\right) \cdot \left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}\right)}
double f(double x, double y) {
        double r3762901 = x;
        double r3762902 = y;
        double r3762903 = r3762901 - r3762902;
        double r3762904 = r3762901 + r3762902;
        double r3762905 = r3762903 * r3762904;
        double r3762906 = r3762901 * r3762901;
        double r3762907 = r3762902 * r3762902;
        double r3762908 = r3762906 + r3762907;
        double r3762909 = r3762905 / r3762908;
        return r3762909;
}

double f(double x, double y) {
        double r3762910 = y;
        double r3762911 = x;
        double r3762912 = r3762910 + r3762911;
        double r3762913 = hypot(r3762910, r3762911);
        double r3762914 = r3762912 / r3762913;
        double r3762915 = r3762911 - r3762910;
        double r3762916 = r3762914 * r3762915;
        double r3762917 = 1.0;
        double r3762918 = r3762917 / r3762913;
        double r3762919 = r3762916 * r3762918;
        double r3762920 = r3762915 / r3762913;
        double r3762921 = cbrt(r3762912);
        double r3762922 = cbrt(r3762913);
        double r3762923 = r3762921 / r3762922;
        double r3762924 = r3762920 * r3762923;
        double r3762925 = r3762921 * r3762921;
        double r3762926 = r3762922 * r3762922;
        double r3762927 = r3762925 / r3762926;
        double r3762928 = r3762924 * r3762927;
        double r3762929 = r3762919 * r3762928;
        double r3762930 = r3762914 * r3762920;
        double r3762931 = r3762929 * r3762930;
        double r3762932 = cbrt(r3762931);
        return r3762932;
}

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.1
Target0.0
Herbie0.1
\[\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.1

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

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

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

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

    \[\leadsto \frac{x + y}{\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}} \cdot \frac{x - y}{\color{blue}{\sqrt[3]{\left(\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)} \cdot \sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}\right) \cdot \sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}}}}\]
  8. Applied add-cbrt-cube31.9

    \[\leadsto \frac{x + y}{\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}} \cdot \frac{\color{blue}{\sqrt[3]{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}}}{\sqrt[3]{\left(\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)} \cdot \sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}\right) \cdot \sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}}}\]
  9. Applied cbrt-undiv31.9

    \[\leadsto \frac{x + y}{\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}} \cdot \color{blue}{\sqrt[3]{\frac{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}{\left(\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)} \cdot \sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}\right) \cdot \sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}}}}\]
  10. Applied add-cbrt-cube31.9

    \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{x + y}{\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}} \cdot \frac{x + y}{\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}}\right) \cdot \frac{x + y}{\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}}}} \cdot \sqrt[3]{\frac{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}{\left(\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)} \cdot \sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}\right) \cdot \sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}}}\]
  11. Applied cbrt-unprod31.9

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

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

    \[\leadsto \sqrt[3]{\left(\left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}\right) \cdot \left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \color{blue}{\left(\left(x - y\right) \cdot \frac{1}{\mathsf{hypot}\left(y, x\right)}\right)}\right)\right) \cdot \left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}\right)}\]
  15. Applied associate-*r*0.0

    \[\leadsto \sqrt[3]{\left(\left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}\right) \cdot \color{blue}{\left(\left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right) \cdot \frac{1}{\mathsf{hypot}\left(y, x\right)}\right)}\right) \cdot \left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}\right)}\]
  16. Using strategy rm
  17. Applied add-cube-cbrt0.2

    \[\leadsto \sqrt[3]{\left(\left(\frac{x + y}{\color{blue}{\left(\sqrt[3]{\mathsf{hypot}\left(y, x\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(y, x\right)}\right) \cdot \sqrt[3]{\mathsf{hypot}\left(y, x\right)}}} \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}\right) \cdot \left(\left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right) \cdot \frac{1}{\mathsf{hypot}\left(y, x\right)}\right)\right) \cdot \left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}\right)}\]
  18. Applied add-cube-cbrt0.0

    \[\leadsto \sqrt[3]{\left(\left(\frac{\color{blue}{\left(\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}\right) \cdot \sqrt[3]{x + y}}}{\left(\sqrt[3]{\mathsf{hypot}\left(y, x\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(y, x\right)}\right) \cdot \sqrt[3]{\mathsf{hypot}\left(y, x\right)}} \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}\right) \cdot \left(\left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right) \cdot \frac{1}{\mathsf{hypot}\left(y, x\right)}\right)\right) \cdot \left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}\right)}\]
  19. Applied times-frac0.0

    \[\leadsto \sqrt[3]{\left(\left(\color{blue}{\left(\frac{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}{\sqrt[3]{\mathsf{hypot}\left(y, x\right)} \cdot \sqrt[3]{\mathsf{hypot}\left(y, x\right)}} \cdot \frac{\sqrt[3]{x + y}}{\sqrt[3]{\mathsf{hypot}\left(y, x\right)}}\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}\right) \cdot \left(\left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right) \cdot \frac{1}{\mathsf{hypot}\left(y, x\right)}\right)\right) \cdot \left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}\right)}\]
  20. Applied associate-*l*0.1

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

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

Reproduce

herbie shell --seed 2019142 +o rules:numerics
(FPCore (x y)
  :name "Kahan p9 Example"
  :pre (and (< 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))))