double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
double code(double x, double y, double z) {
double tmp;
if ((((x + y) / (1.0 - (y / z))) <= -7.571671828713221e-294) || !(((x + y) / (1.0 - (y / z))) <= -0.0)) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = 1.0 / ((sqrt(1.0) + (sqrt(y) / sqrt(z))) * ((sqrt(1.0) - (sqrt(y) / sqrt(z))) / (x + y)));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.6 |
|---|---|
| Target | 4.0 |
| Herbie | 6.1 |
if (/ (+ x y) (- 1.0 (/ y z))) < -7.5716718287132213e-294 or -0.0 < (/ (+ x y) (- 1.0 (/ y z))) Initial program 0.1
if -7.5716718287132213e-294 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0Initial program 59.1
rmApplied clear-num59.1
rmApplied *-un-lft-identity59.1
Applied add-sqr-sqrt60.9
Applied add-sqr-sqrt62.6
Applied times-frac62.6
Applied add-sqr-sqrt62.6
Applied difference-of-squares62.6
Applied times-frac47.3
Simplified47.3
Simplified47.3
Final simplification6.1
herbie shell --seed 2020338
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:herbie-target
(if (< y -3.7429310762689856e+171) (* (/ (+ y x) (neg y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) (* (/ (+ y x) (neg y)) z)))
(/ (+ x y) (- 1.0 (/ y z))))