Average Error: 20.5 → 0.0
Time: 4.0m
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(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(x, y\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(x, y\right)} \cdot \frac{x - y}{\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(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(x, y\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(x, y\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(x, y\right)}\right)}
double f(double x, double y) {
        double r32735365 = x;
        double r32735366 = y;
        double r32735367 = r32735365 - r32735366;
        double r32735368 = r32735365 + r32735366;
        double r32735369 = r32735367 * r32735368;
        double r32735370 = r32735365 * r32735365;
        double r32735371 = r32735366 * r32735366;
        double r32735372 = r32735370 + r32735371;
        double r32735373 = r32735369 / r32735372;
        return r32735373;
}

double f(double x, double y) {
        double r32735374 = x;
        double r32735375 = y;
        double r32735376 = r32735374 + r32735375;
        double r32735377 = hypot(r32735375, r32735374);
        double r32735378 = r32735376 / r32735377;
        double r32735379 = r32735374 - r32735375;
        double r32735380 = hypot(r32735374, r32735375);
        double r32735381 = r32735379 / r32735380;
        double r32735382 = r32735378 * r32735381;
        double r32735383 = r32735378 * r32735378;
        double r32735384 = r32735382 * r32735383;
        double r32735385 = r32735381 * r32735381;
        double r32735386 = r32735384 * r32735385;
        double r32735387 = cbrt(r32735386);
        return r32735387;
}

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.5
Target0.1
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.5

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

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

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

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

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

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

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

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

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

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

    \[\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]{\left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{y + x}{\mathsf{hypot}\left(y, x\right)}\right) \cdot \frac{y + x}{\mathsf{hypot}\left(y, x\right)}}\]
  15. Applied add-cbrt-cube31.8

    \[\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(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}} \cdot \sqrt[3]{\left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{y + x}{\mathsf{hypot}\left(y, x\right)}\right) \cdot \frac{y + x}{\mathsf{hypot}\left(y, x\right)}}\]
  16. Applied cbrt-undiv31.8

    \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}{\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]{\left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{y + x}{\mathsf{hypot}\left(y, x\right)}\right) \cdot \frac{y + x}{\mathsf{hypot}\left(y, x\right)}}\]
  17. Applied cbrt-unprod31.8

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

    \[\leadsto \sqrt[3]{\color{blue}{\left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{y + x}{\mathsf{hypot}\left(y, x\right)}\right) \cdot \left(\left(\frac{y + x}{\mathsf{hypot}\left(y, x\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)}}\]
  19. Using strategy rm
  20. Applied associate-*r*0.0

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

    \[\leadsto \sqrt[3]{\left(\left(\frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(x, y\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(x, y\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(x, y\right)}\right)}\]

Reproduce

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