\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\begin{array}{l}
\mathbf{if}\;y \le -1.59242402324911205 \cdot 10^{150}:\\
\;\;\;\;-1\\
\mathbf{elif}\;y \le -1.73646478167851352 \cdot 10^{-159}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x + y \cdot y}{\left(x - y\right) \cdot \left(x + y\right)}}\\
\mathbf{elif}\;y \le 8.6481625694164188 \cdot 10^{-160}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x + y \cdot y}{\left(x - y\right) \cdot \left(x + y\right)}}\\
\end{array}double code(double x, double y) {
return (((x - y) * (x + y)) / ((x * x) + (y * y)));
}
double code(double x, double y) {
double temp;
if ((y <= -1.592424023249112e+150)) {
temp = -1.0;
} else {
double temp_1;
if ((y <= -1.7364647816785135e-159)) {
temp_1 = (1.0 / (((x * x) + (y * y)) / ((x - y) * (x + y))));
} else {
double temp_2;
if ((y <= 8.648162569416419e-160)) {
temp_2 = 1.0;
} else {
temp_2 = (1.0 / (((x * x) + (y * y)) / ((x - y) * (x + y))));
}
temp_1 = temp_2;
}
temp = temp_1;
}
return temp;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.4 |
|---|---|
| Target | 0.0 |
| Herbie | 5.2 |
if y < -1.592424023249112e+150Initial program 62.3
rmApplied clear-num62.3
Taylor expanded around 0 0
if -1.592424023249112e+150 < y < -1.7364647816785135e-159 or 8.648162569416419e-160 < y Initial program 0.0
rmApplied clear-num0.0
if -1.7364647816785135e-159 < y < 8.648162569416419e-160Initial program 30.5
rmApplied clear-num30.5
Taylor expanded around inf 16.5
Final simplification5.2
herbie shell --seed 2020049
(FPCore (x y)
:name "Kahan p9 Example"
:precision binary64
:pre (and (< 0.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))))