\frac{x \cdot \left(y + z\right)}{z}\begin{array}{l}
\mathbf{if}\;x \le 1.9254544708957993 \cdot 10^{-126}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, x, x\right)\\
\end{array}double code(double x, double y, double z) {
return ((x * (y + z)) / z);
}
double code(double x, double y, double z) {
double VAR;
if ((x <= 1.9254544708957993e-126)) {
VAR = fma((x / z), y, x);
} else {
VAR = fma((y / z), x, x);
}
return VAR;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 12.4 |
|---|---|
| Target | 3.1 |
| Herbie | 3.4 |
if x < 1.9254544708957993e-126Initial program 11.1
Taylor expanded around 0 4.5
Simplified4.6
if 1.9254544708957993e-126 < x Initial program 15.0
Simplified1.0
Final simplification3.4
herbie shell --seed 2020103 +o rules:numerics
(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))