\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t_0 \leq -3.575824716202934 \cdot 10^{-270} \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-\left(\frac{x \cdot z}{y} + \left(z + \frac{{z}^{2}}{y}\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 -3.575824716202934e-270) (not (<= t_0 0.0)))
t_0
(- (+ (/ (* x z) y) (+ z (/ (pow z 2.0) y)))))))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 <= -3.575824716202934e-270) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
tmp = -(((x * z) / y) + (z + (pow(z, 2.0) / y)));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 7.6 |
|---|---|
| Target | 4.2 |
| Herbie | 0.2 |
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -3.57582471620293415e-270 or -0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 0.1
if -3.57582471620293415e-270 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -0.0Initial program 57.0
Taylor expanded in y around inf 0.9
Final simplification0.2
herbie shell --seed 2022068
(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))))