\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
t_0 := x \cdot \left(y + z\right)\\
t_1 := \frac{t_0}{z}\\
t_2 := \mathsf{fma}\left(x, \frac{y}{z}, x\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq -6.928840578777105 \cdot 10^{+20}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq 5.5452176622010715 \cdot 10^{+41}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq 2.7293408556137423 \cdot 10^{+294}:\\
\;\;\;\;t_0 \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, x\right)\\
\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (+ y z))) (t_1 (/ t_0 z)) (t_2 (fma x (/ y z) x)))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 -6.928840578777105e+20)
t_1
(if (<= t_1 5.5452176622010715e+41)
t_2
(if (<= t_1 2.7293408556137423e+294)
(* t_0 (/ 1.0 z))
(fma (/ x z) y x)))))))double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
double t_0 = x * (y + z);
double t_1 = t_0 / z;
double t_2 = fma(x, (y / z), x);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= -6.928840578777105e+20) {
tmp = t_1;
} else if (t_1 <= 5.5452176622010715e+41) {
tmp = t_2;
} else if (t_1 <= 2.7293408556137423e+294) {
tmp = t_0 * (1.0 / z);
} else {
tmp = fma((x / z), y, x);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 12.1 |
|---|---|
| Target | 2.9 |
| Herbie | 0.4 |
if (/.f64 (*.f64 x (+.f64 y z)) z) < -inf.0 or -692884057877710504000 < (/.f64 (*.f64 x (+.f64 y z)) z) < 5.54521766220107147e41Initial program 13.4
Simplified0.2
if -inf.0 < (/.f64 (*.f64 x (+.f64 y z)) z) < -692884057877710504000Initial program 0.2
if 5.54521766220107147e41 < (/.f64 (*.f64 x (+.f64 y z)) z) < 2.72934085561374228e294Initial program 0.2
Applied div-inv_binary640.3
if 2.72934085561374228e294 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 59.5
Taylor expanded in y around 0 21.2
Simplified2.7
Final simplification0.4
herbie shell --seed 2022081
(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))