\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \leq -1.3482160583740896 \cdot 10^{+154}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -1.601462366399571 \cdot 10^{-162}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x - y \cdot y}{x \cdot x + y \cdot y}\right)}^{3}}\\
\mathbf{elif}\;y \leq 3.499968286662803 \cdot 10^{-175}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{\sqrt{x \cdot x + y \cdot y}} \cdot \frac{y + x}{\sqrt{x \cdot x + y \cdot y}}\\
\end{array}(FPCore (x y) :precision binary64 (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))
(FPCore (x y)
:precision binary64
(if (<= y -1.3482160583740896e+154)
-1.0
(if (<= y -1.601462366399571e-162)
(cbrt (pow (/ (- (* x x) (* y y)) (+ (* x x) (* y y))) 3.0))
(if (<= y 3.499968286662803e-175)
1.0
(*
(/ (- x y) (sqrt (+ (* x x) (* y y))))
(/ (+ y x) (sqrt (+ (* x x) (* y y)))))))))double code(double x, double y) {
return ((x - y) * (x + y)) / ((x * x) + (y * y));
}
double code(double x, double y) {
double tmp;
if (y <= -1.3482160583740896e+154) {
tmp = -1.0;
} else if (y <= -1.601462366399571e-162) {
tmp = cbrt(pow((((x * x) - (y * y)) / ((x * x) + (y * y))), 3.0));
} else if (y <= 3.499968286662803e-175) {
tmp = 1.0;
} else {
tmp = ((x - y) / sqrt((x * x) + (y * y))) * ((y + x) / sqrt((x * x) + (y * y)));
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.5 |
|---|---|
| Target | 0.1 |
| Herbie | 5.4 |
if y < -1.3482160583740896e154Initial program 64.0
Taylor expanded around 0 0
if -1.3482160583740896e154 < y < -1.6014623663995711e-162Initial program 0.0
rmApplied add-cbrt-cube_binary6439.2
Applied add-cbrt-cube_binary6439.6
Applied add-cbrt-cube_binary6439.7
Applied cbrt-unprod_binary6439.5
Applied cbrt-undiv_binary6439.4
Simplified0.1
if -1.6014623663995711e-162 < y < 3.49996828666280287e-175Initial program 31.2
Taylor expanded around inf 15.7
if 3.49996828666280287e-175 < y Initial program 2.6
rmApplied add-sqr-sqrt_binary642.6
Applied times-frac_binary643.1
Final simplification5.4
herbie shell --seed 2020224
(FPCore (x y)
:name "Kahan p9 Example"
:precision binary64
:pre (and (< 0.0 x 1.0) (< y 1.0))
:herbie-target
(if (< 0.5 (fabs (/ x y)) 2.0) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1.0 (/ 2.0 (+ 1.0 (* (/ x y) (/ x y))))))
(/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))