\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \leq -1.3549382125738884 \cdot 10^{+154}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq -1.0976423163705755 \cdot 10^{-160}:\\
\;\;\;\;\sqrt[3]{{\left(\left(y + x\right) \cdot \frac{x - y}{x \cdot x + y \cdot y}\right)}^{3}}\\
\mathbf{elif}\;y \leq -4.569358268130714 \cdot 10^{-209}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \leq 7.111573363808515 \cdot 10^{-163}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x + y \cdot y}{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.3549382125738884e+154)
-1.0
(if (<= y -1.0976423163705755e-160)
(cbrt (pow (* (+ y x) (/ (- x y) (+ (* x x) (* y y)))) 3.0))
(if (<= y -4.569358268130714e-209)
-1.0
(if (<= y 7.111573363808515e-163)
1.0
(/ 1.0 (/ (+ (* x x) (* y y)) (- (* 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.3549382125738884e+154) {
tmp = -1.0;
} else if (y <= -1.0976423163705755e-160) {
tmp = cbrt(pow(((y + x) * ((x - y) / ((x * x) + (y * y)))), 3.0));
} else if (y <= -4.569358268130714e-209) {
tmp = -1.0;
} else if (y <= 7.111573363808515e-163) {
tmp = 1.0;
} else {
tmp = 1.0 / (((x * x) + (y * y)) / ((x * x) - (y * y)));
}
return tmp;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.8 |
|---|---|
| Target | 0.0 |
| Herbie | 5.6 |
if y < -1.35493821257388839e154 or -1.09764231637057547e-160 < y < -4.5693582681307142e-209Initial program 56.8
Taylor expanded around 0 8.2
if -1.35493821257388839e154 < y < -1.09764231637057547e-160Initial program 0.1
rmApplied add-cbrt-cube_binary64_11370.1
Simplified0.1
rmApplied *-un-lft-identity_binary64_11010.1
Applied difference-of-squares_binary64_10700.1
Applied times-frac_binary64_11070.2
Simplified0.2
if -4.5693582681307142e-209 < y < 7.11157336380851536e-163Initial program 29.8
Taylor expanded around inf 13.8
if 7.11157336380851536e-163 < y Initial program 0.2
rmApplied clear-num_binary64_11000.2
Simplified0.2
Final simplification5.6
herbie shell --seed 2020355
(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))))