Average Error: 19.6 → 0.0
Time: 19.4s
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]{{\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{\mathsf{hypot}\left(x, y\right)}{x + y}}\right)}^{3}}\]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\sqrt[3]{{\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{\mathsf{hypot}\left(x, y\right)}{x + y}}\right)}^{3}}
double f(double x, double y) {
        double r96063 = x;
        double r96064 = y;
        double r96065 = r96063 - r96064;
        double r96066 = r96063 + r96064;
        double r96067 = r96065 * r96066;
        double r96068 = r96063 * r96063;
        double r96069 = r96064 * r96064;
        double r96070 = r96068 + r96069;
        double r96071 = r96067 / r96070;
        return r96071;
}

double f(double x, double y) {
        double r96072 = x;
        double r96073 = y;
        double r96074 = r96072 - r96073;
        double r96075 = hypot(r96072, r96073);
        double r96076 = r96072 + r96073;
        double r96077 = r96075 / r96076;
        double r96078 = r96075 * r96077;
        double r96079 = r96074 / r96078;
        double r96080 = 3.0;
        double r96081 = pow(r96079, r96080);
        double r96082 = cbrt(r96081);
        return r96082;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.6
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 19.6

    \[\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\]
  2. Using strategy rm
  3. Applied add-cbrt-cube46.2

    \[\leadsto \frac{\left(x - y\right) \cdot \left(x + y\right)}{\color{blue}{\sqrt[3]{\left(\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x + y \cdot y\right)\right) \cdot \left(x \cdot x + y \cdot y\right)}}}\]
  4. Applied add-cbrt-cube46.3

    \[\leadsto \frac{\left(x - y\right) \cdot \color{blue}{\sqrt[3]{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}}}{\sqrt[3]{\left(\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x + y \cdot y\right)\right) \cdot \left(x \cdot x + y \cdot y\right)}}\]
  5. Applied add-cbrt-cube46.4

    \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}} \cdot \sqrt[3]{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}}{\sqrt[3]{\left(\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x + y \cdot y\right)\right) \cdot \left(x \cdot x + y \cdot y\right)}}\]
  6. Applied cbrt-unprod46.1

    \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)\right) \cdot \left(\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)\right)}}}{\sqrt[3]{\left(\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x + y \cdot y\right)\right) \cdot \left(x \cdot x + y \cdot y\right)}}\]
  7. Applied cbrt-undiv46.0

    \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)\right) \cdot \left(\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)\right)}{\left(\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x + y \cdot y\right)\right) \cdot \left(x \cdot x + y \cdot y\right)}}}\]
  8. Simplified19.7

    \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{x - y}{\frac{\mathsf{fma}\left(x, x, {y}^{2}\right)}{x + y}}\right)}^{3}}}\]
  9. Using strategy rm
  10. Applied *-un-lft-identity19.7

    \[\leadsto \sqrt[3]{{\left(\frac{x - y}{\frac{\mathsf{fma}\left(x, x, {y}^{2}\right)}{\color{blue}{1 \cdot \left(x + y\right)}}}\right)}^{3}}\]
  11. Applied add-sqr-sqrt19.7

    \[\leadsto \sqrt[3]{{\left(\frac{x - y}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(x, x, {y}^{2}\right)} \cdot \sqrt{\mathsf{fma}\left(x, x, {y}^{2}\right)}}}{1 \cdot \left(x + y\right)}}\right)}^{3}}\]
  12. Applied times-frac19.7

    \[\leadsto \sqrt[3]{{\left(\frac{x - y}{\color{blue}{\frac{\sqrt{\mathsf{fma}\left(x, x, {y}^{2}\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(x, x, {y}^{2}\right)}}{x + y}}}\right)}^{3}}\]
  13. Simplified19.7

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

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

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

Reproduce

herbie shell --seed 2019209 +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))))