\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t_0 \leq 6.240358642528451 \cdot 10^{-273}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\mathbf{elif}\;t_0 \leq 4.160283441989339 \cdot 10^{+303}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\
\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x (- y z)) y)))
(if (<= t_0 6.240358642528451e-273)
(/ x (/ y (- y z)))
(if (<= t_0 4.160283441989339e+303)
(- x (/ (* x z) y))
(* x (- 1.0 (/ z y)))))))double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
double t_0 = (x * (y - z)) / y;
double tmp;
if (t_0 <= 6.240358642528451e-273) {
tmp = x / (y / (y - z));
} else if (t_0 <= 4.160283441989339e+303) {
tmp = x - ((x * z) / y);
} else {
tmp = x * (1.0 - (z / y));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 12.5 |
|---|---|
| Target | 2.8 |
| Herbie | 1.7 |
if (/.f64 (*.f64 x (-.f64 y z)) y) < 6.24035864252845103e-273Initial program 14.1
Applied egg-rr3.2
Applied egg-rr2.9
if 6.24035864252845103e-273 < (/.f64 (*.f64 x (-.f64 y z)) y) < 4.160283441989339e303Initial program 0.4
Taylor expanded in y around 0 0.2
if 4.160283441989339e303 < (/.f64 (*.f64 x (-.f64 y z)) y) Initial program 60.9
Taylor expanded in y around 0 19.1
Taylor expanded in x around 0 0.8
Final simplification1.7
herbie shell --seed 2022130
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:herbie-target
(if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))
(/ (* x (- y z)) y))