\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.7781855660516165 \cdot 10^{-256} \lor \neg \left(t_0 \leq 0\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := \frac{z}{\sqrt[3]{-1}}\\
\mathsf{fma}\left(t_1, \frac{x}{y}, t_1\right) - \frac{z \cdot z}{y \cdot {\left(\sqrt[3]{-1}\right)}^{2}}
\end{array}\\
\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.7781855660516165e-256) (not (<= t_0 0.0)))
t_0
(let* ((t_1 (/ z (cbrt -1.0))))
(- (fma t_1 (/ x y) t_1) (/ (* z z) (* y (pow (cbrt -1.0) 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.7781855660516165e-256) || !(t_0 <= 0.0)) {
tmp = t_0;
} else {
double t_1 = z / cbrt(-1.0);
tmp = fma(t_1, (x / y), t_1) - ((z * z) / (y * pow(cbrt(-1.0), 2.0)));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 7.9 |
|---|---|
| Target | 4.0 |
| Herbie | 0.3 |
if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -1.7781855660516165e-256 or -0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) Initial program 0.1
if -1.7781855660516165e-256 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -0.0Initial program 55.8
Applied *-un-lft-identity_binary6455.8
Applied add-cube-cbrt_binary6455.9
Applied times-frac_binary6455.9
Applied cancel-sign-sub-inv_binary6455.9
Applied add-cbrt-cube_binary6456.6
Simplified56.5
Taylor expanded in y around -inf 1.6
Simplified1.4
Final simplification0.3
herbie shell --seed 2022088
(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))))