\frac{x + y}{1 - \frac{y}{z}}\frac{1}{\frac{1}{y + x} - \frac{\frac{y}{y + x}}{z}}double code(double x, double y, double z) {
return (((double) (x + y)) / ((double) (1.0 - (y / z))));
}
double code(double x, double y, double z) {
return (1.0 / ((double) ((1.0 / ((double) (y + x))) - ((y / ((double) (y + x))) / z))));
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.4 |
|---|---|
| Target | 3.8 |
| Herbie | 1.6 |
Initial program 7.4
rmApplied clear-num7.6
rmApplied div-sub7.6
Simplified7.6
Simplified6.8
rmApplied associate-/r*1.6
Final simplification1.6
herbie shell --seed 2020182
(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))))