Average Error: 20.4 → 0.0
Time: 1.4m
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{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(x, y\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{y + x}{\mathsf{hypot}\left(y, x\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{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(x, y\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{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(x, y\right)}\right)}
double f(double x, double y) {
        double r14936935 = x;
        double r14936936 = y;
        double r14936937 = r14936935 - r14936936;
        double r14936938 = r14936935 + r14936936;
        double r14936939 = r14936937 * r14936938;
        double r14936940 = r14936935 * r14936935;
        double r14936941 = r14936936 * r14936936;
        double r14936942 = r14936940 + r14936941;
        double r14936943 = r14936939 / r14936942;
        return r14936943;
}

double f(double x, double y) {
        double r14936944 = y;
        double r14936945 = x;
        double r14936946 = r14936944 + r14936945;
        double r14936947 = hypot(r14936944, r14936945);
        double r14936948 = r14936946 / r14936947;
        double r14936949 = r14936945 - r14936944;
        double r14936950 = hypot(r14936945, r14936944);
        double r14936951 = r14936949 / r14936950;
        double r14936952 = r14936948 * r14936951;
        double r14936953 = r14936952 * r14936952;
        double r14936954 = r14936953 * r14936952;
        double r14936955 = cbrt(r14936954);
        return r14936955;
}

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

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

    \[\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.4

    \[\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.4

    \[\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.4

    \[\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.4

    \[\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.4

    \[\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.4

    \[\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-cube0.1

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

    \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{x - y}{\mathsf{hypot}\left(x, y\right)}\right) \cdot \frac{x - y}{\mathsf{hypot}\left(x, y\right)}\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)}}\]
  16. Simplified0.0

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

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

Reproduce

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