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




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.4 |
|---|---|
| Target | 3.9 |
| Herbie | 7.4 |
Initial program 7.4
rmApplied div-inv7.4
Final simplification7.4
herbie shell --seed 2020102 +o rules:numerics
(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) (- y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1 (/ y z))) (* (/ (+ y x) (- y)) z)))
(/ (+ x y) (- 1 (/ y z))))