\frac{x \cdot \left(y + z\right)}{z}\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \leq -\infty:\\
\;\;\;\;x \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq -9.265470348424293 \cdot 10^{-272}:\\
\;\;\;\;x + \frac{x \cdot y}{z}\\
\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 1.3380029843894863 \cdot 10^{+106}:\\
\;\;\;\;x \cdot \left(1 + \frac{y}{z}\right)\\
\mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq 3.7319691449889546 \cdot 10^{+292}:\\
\;\;\;\;x + \frac{x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\frac{z}{y + z}}} \cdot \frac{x}{\sqrt{\frac{z}{y + z}}}\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
:precision binary64
(if (<= (/ (* x (+ y z)) z) (- INFINITY))
(* x (+ 1.0 (/ y z)))
(if (<= (/ (* x (+ y z)) z) -9.265470348424293e-272)
(+ x (/ (* x y) z))
(if (<= (/ (* x (+ y z)) z) 1.3380029843894863e+106)
(* x (+ 1.0 (/ y z)))
(if (<= (/ (* x (+ y z)) z) 3.7319691449889546e+292)
(+ x (/ (* x y) z))
(* (/ 1.0 (sqrt (/ z (+ y z)))) (/ x (sqrt (/ z (+ y 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) <= -((double) INFINITY)) {
tmp = x * (1.0 + (y / z));
} else if (((x * (y + z)) / z) <= -9.265470348424293e-272) {
tmp = x + ((x * y) / z);
} else if (((x * (y + z)) / z) <= 1.3380029843894863e+106) {
tmp = x * (1.0 + (y / z));
} else if (((x * (y + z)) / z) <= 3.7319691449889546e+292) {
tmp = x + ((x * y) / z);
} else {
tmp = (1.0 / sqrt(z / (y + z))) * (x / sqrt(z / (y + z)));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 12.8 |
|---|---|
| Target | 3.2 |
| Herbie | 0.9 |
if (/.f64 (*.f64 x (+.f64 y z)) z) < -inf.0 or -9.26547034842429255e-272 < (/.f64 (*.f64 x (+.f64 y z)) z) < 1.33800298438948625e106Initial program 19.3
rmApplied *-un-lft-identity_binary6419.3
Applied times-frac_binary640.6
Simplified0.6
Taylor expanded around 0 0.6
Simplified0.6
if -inf.0 < (/.f64 (*.f64 x (+.f64 y z)) z) < -9.26547034842429255e-272 or 1.33800298438948625e106 < (/.f64 (*.f64 x (+.f64 y z)) z) < 3.7319691449889546e292Initial program 0.3
Taylor expanded around 0 0.2
if 3.7319691449889546e292 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 58.6
rmApplied associate-/l*_binary641.9
rmApplied add-sqr-sqrt_binary647.4
Applied *-un-lft-identity_binary647.4
Applied times-frac_binary647.4
Simplified7.4
Simplified7.4
Final simplification0.9
herbie shell --seed 2020260
(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))