Average Error: 19.7 → 0.0
Time: 25.1s
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(\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{y + x}{\mathsf{hypot}\left(x, y\right)}\right) \cdot \left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{y + x}{\mathsf{hypot}\left(x, y\right)}\right)\right) \cdot \left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{y + x}{\mathsf{hypot}\left(x, y\right)}\right)}\]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\sqrt[3]{\left(\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{y + x}{\mathsf{hypot}\left(x, y\right)}\right) \cdot \left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{y + x}{\mathsf{hypot}\left(x, y\right)}\right)\right) \cdot \left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{y + x}{\mathsf{hypot}\left(x, y\right)}\right)}
double f(double x, double y) {
        double r2962671 = x;
        double r2962672 = y;
        double r2962673 = r2962671 - r2962672;
        double r2962674 = r2962671 + r2962672;
        double r2962675 = r2962673 * r2962674;
        double r2962676 = r2962671 * r2962671;
        double r2962677 = r2962672 * r2962672;
        double r2962678 = r2962676 + r2962677;
        double r2962679 = r2962675 / r2962678;
        return r2962679;
}

double f(double x, double y) {
        double r2962680 = x;
        double r2962681 = y;
        double r2962682 = r2962680 - r2962681;
        double r2962683 = hypot(r2962680, r2962681);
        double r2962684 = r2962682 / r2962683;
        double r2962685 = r2962681 + r2962680;
        double r2962686 = r2962685 / r2962683;
        double r2962687 = r2962684 * r2962686;
        double r2962688 = r2962687 * r2962687;
        double r2962689 = r2962688 * r2962687;
        double r2962690 = cbrt(r2962689);
        return r2962690;
}

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.7
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.7

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

    \[\leadsto \frac{\left(x - y\right) \cdot \left(x + y\right)}{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}}}\]
  4. Applied times-frac19.7

    \[\leadsto \color{blue}{\frac{x - y}{\sqrt{x \cdot x + y \cdot y}} \cdot \frac{x + y}{\sqrt{x \cdot x + y \cdot y}}}\]
  5. Using strategy rm
  6. Applied add-cbrt-cube31.7

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

    \[\leadsto \frac{x - y}{\sqrt{x \cdot x + y \cdot y}} \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{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}\right) \cdot \sqrt{x \cdot x + y \cdot y}}}\]
  8. Applied cbrt-undiv31.6

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

    \[\leadsto \frac{x - y}{\color{blue}{\sqrt[3]{\left(\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}\right) \cdot \sqrt{x \cdot x + y \cdot y}}}} \cdot \sqrt[3]{\frac{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}{\left(\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}\right) \cdot \sqrt{x \cdot x + y \cdot y}}}\]
  10. Applied add-cbrt-cube31.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(\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}\right) \cdot \sqrt{x \cdot x + y \cdot y}}} \cdot \sqrt[3]{\frac{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}{\left(\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}\right) \cdot \sqrt{x \cdot x + y \cdot y}}}\]
  11. Applied cbrt-undiv31.6

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

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

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

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

Reproduce

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