\frac{x \cdot \left(y + z\right)}{z}\begin{array}{l}
\mathbf{if}\;z \leq -2.4193787838886472 \cdot 10^{-12}:\\
\;\;\;\;x + x \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq -7.401115730235809 \cdot 10^{-203}:\\
\;\;\;\;x + \left(x \cdot y\right) \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{z + y}}\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
:precision binary64
(if (<= z -2.4193787838886472e-12)
(+ x (* x (/ y z)))
(if (<= z -7.401115730235809e-203)
(+ x (* (* x y) (/ 1.0 z)))
(/ x (/ z (+ z y))))))double code(double x, double y, double z) {
return (((double) (x * ((double) (y + z)))) / z);
}
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.4193787838886472e-12)) {
tmp = ((double) (x + ((double) (x * (y / z)))));
} else {
double tmp_1;
if ((z <= -7.401115730235809e-203)) {
tmp_1 = ((double) (x + ((double) (((double) (x * y)) * (1.0 / z)))));
} else {
tmp_1 = (x / (z / ((double) (z + y))));
}
tmp = tmp_1;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 12.5 |
|---|---|
| Target | 3.2 |
| Herbie | 2.7 |
if z < -2.41937878388864723e-12Initial program Error: 15.3 bits
SimplifiedError: 0.1 bits
if -2.41937878388864723e-12 < z < -7.40111573023580882e-203Initial program Error: 4.6 bits
SimplifiedError: 5.8 bits
rmApplied div-invError: 5.9 bits
Applied associate-*r*Error: 1.3 bits
if -7.40111573023580882e-203 < z Initial program Error: 13.0 bits
rmApplied associate-/l*Error: 4.5 bits
Final simplificationError: 2.7 bits
herbie shell --seed 2020203
(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))