\frac{x \cdot \left(y + z\right)}{z}\begin{array}{l}
\mathbf{if}\;x \leq -4.79817812939288 \cdot 10^{-228}:\\
\;\;\;\;x \cdot \frac{y + z}{z}\\
\mathbf{elif}\;x \leq 4.013452996809398 \cdot 10^{-24}:\\
\;\;\;\;x + \frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y + z}{z}\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z) :precision binary64 (if (<= x -4.79817812939288e-228) (* x (/ (+ y z) z)) (if (<= x 4.013452996809398e-24) (+ x (/ (* x y) z)) (* x (/ (+ y z) z)))))
double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
double tmp;
if (x <= -4.79817812939288e-228) {
tmp = x * ((y + z) / z);
} else if (x <= 4.013452996809398e-24) {
tmp = x + ((x * y) / z);
} else {
tmp = x * ((y + z) / z);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 12.2 |
|---|---|
| Target | 3.2 |
| Herbie | 2.1 |
if x < -4.79817812939287982e-228 or 4.01345299680939833e-24 < x Initial program 15.5
rmApplied *-un-lft-identity_binary6415.5
Applied times-frac_binary641.5
Simplified1.5
if -4.79817812939287982e-228 < x < 4.01345299680939833e-24Initial program 6.3
Taylor expanded around 0 3.1
Final simplification2.1
herbie shell --seed 2020273
(FPCore (x y z)
:name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(/ x (/ z (+ y z)))
(/ (* x (+ y z)) z))