double code(double x, double y) {
return ((double) (((double) (((double) (x - y)) * ((double) (x + y)))) / ((double) (((double) (x * x)) + ((double) (y * y))))));
}
double code(double x, double y) {
double VAR;
if ((y <= -1.353645889848894e+154)) {
VAR = -1.0;
} else {
double VAR_1;
if (((y <= -1.57795570958839e-162) || !(y <= 2.9392210219802266e-187))) {
VAR_1 = ((double) (1.0 / ((double) (((double) (((double) (x * x)) + ((double) (y * y)))) / ((double) (((double) (x * x)) - ((double) (y * y))))))));
} else {
VAR_1 = 1.0;
}
VAR = VAR_1;
}
return VAR;
}




Bits error versus x




Bits error versus y
Results
| Original | 20.6 |
|---|---|
| Target | 0.1 |
| Herbie | 5.2 |
if y < -1.353645889848894e154Initial program 64.0
Taylor expanded around 0 0
if -1.353645889848894e154 < y < -1.57795570958839e-162 or 2.9392210219802266e-187 < y Initial program 1.5
rmApplied clear-num1.5
Simplified1.5
if -1.57795570958839e-162 < y < 2.9392210219802266e-187Initial program 30.3
Taylor expanded around inf 14.9
Final simplification5.2
herbie shell --seed 2020190
(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))))