\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t_0 \leq -1.4564281761318297 \cdot 10^{-249} \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-\left(\frac{x \cdot {z}^{2}}{{y}^{2}} + \left(\frac{{z}^{2}}{y} + \left(\frac{x \cdot z}{y} + \left(z + \frac{{z}^{3}}{{y}^{2}}\right)\right)\right)\right)\\
\end{array}
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (+ x y) (- 1.0 (/ y z)))))
(if (or (<= t_0 -1.4564281761318297e-249) (not (<= t_0 0.0)))
t_0
(-
(+
(/ (* x (pow z 2.0)) (pow y 2.0))
(+
(/ (pow z 2.0) y)
(+ (/ (* x z) y) (+ z (/ (pow z 3.0) (pow y 2.0))))))))))double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if ((t_0 <= -1.4564281761318297e-249) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = -(((x * pow(z, 2.0)) / pow(y, 2.0)) + ((pow(z, 2.0) / y) + (((x * z) / y) + (z + (pow(z, 3.0) / pow(y, 2.0))))));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.6 |
|---|---|
| Target | 3.9 |
| Herbie | 0.5 |
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -1.4564281761318297e-249 or -0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 0.1
if -1.4564281761318297e-249 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -0.0Initial program 54.9
Taylor expanded in y around inf 2.8
Final simplification0.5
herbie shell --seed 2021307
(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.0 (/ y z))) (* (/ (+ y x) (- y)) z)))
(/ (+ x y) (- 1.0 (/ y z))))