Average Error: 20.5 → 0.0
Time: 2.9m
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(\frac{x + y}{\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 \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)}\]
\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(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 \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)}
double f(double x, double y) {
        double r28424509 = x;
        double r28424510 = y;
        double r28424511 = r28424509 - r28424510;
        double r28424512 = r28424509 + r28424510;
        double r28424513 = r28424511 * r28424512;
        double r28424514 = r28424509 * r28424509;
        double r28424515 = r28424510 * r28424510;
        double r28424516 = r28424514 + r28424515;
        double r28424517 = r28424513 / r28424516;
        return r28424517;
}

double f(double x, double y) {
        double r28424518 = x;
        double r28424519 = y;
        double r28424520 = r28424518 + r28424519;
        double r28424521 = hypot(r28424519, r28424518);
        double r28424522 = r28424520 / r28424521;
        double r28424523 = r28424522 * r28424522;
        double r28424524 = r28424518 - r28424519;
        double r28424525 = hypot(r28424518, r28424519);
        double r28424526 = r28424524 / r28424525;
        double r28424527 = r28424522 * r28424526;
        double r28424528 = r28424526 * r28424526;
        double r28424529 = r28424527 * r28424528;
        double r28424530 = r28424523 * r28424529;
        double r28424531 = cbrt(r28424530);
        return r28424531;
}

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

    \[\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-cube32.3

    \[\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-cube32.3

    \[\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-undiv32.3

    \[\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-unprod32.3

    \[\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. Final simplification0.0

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

Reproduce

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