\frac{x \cdot \left(y + z\right)}{z}\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \leq 9.178964882172369 \cdot 10^{-26}:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\
\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 2.6136428524201943 \cdot 10^{+301}:\\
\;\;\;\;\frac{x \cdot \left(y + z\right)}{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 (+ y z)) z) 9.178964882172369e-26)
(/ x (/ z (+ y z)))
(if (<= (/ (* x (+ y z)) z) 2.6136428524201943e+301)
(/ (* x (+ y z)) 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 * (y + z)) / z) <= 9.178964882172369e-26) {
tmp = x / (z / (y + z));
} else if (((x * (y + z)) / z) <= 2.6136428524201943e+301) {
tmp = (x * (y + z)) / z;
} else {
tmp = x * ((y + z) / z);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 12.8 |
|---|---|
| Target | 3.1 |
| Herbie | 1.7 |
if (/.f64 (*.f64 x (+.f64 y z)) z) < 9.1789648821723689e-26Initial program 11.3
rmApplied associate-/l*_binary642.2
if 9.1789648821723689e-26 < (/.f64 (*.f64 x (+.f64 y z)) z) < 2.6136428524201943e301Initial program 0.2
if 2.6136428524201943e301 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 61.7
rmApplied *-un-lft-identity_binary6461.7
Applied times-frac_binary640.8
Simplified0.8
Final simplification1.7
herbie shell --seed 2020233
(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))