(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (/ (* x y) z))) (t_1 (/ (* x (+ y z)) z)))
(if (<= t_1 (- INFINITY))
(/ x (/ z (+ y z)))
(if (<= t_1 -1e+80)
t_0
(if (<= t_1 5e-38)
(fma x (/ y z) x)
(if (<= t_1 5e+299) t_0 (fma y (/ x z) 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 + ((x * y) / z);
double t_1 = (x * (y + z)) / z;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x / (z / (y + z));
} else if (t_1 <= -1e+80) {
tmp = t_0;
} else if (t_1 <= 5e-38) {
tmp = fma(x, (y / z), x);
} else if (t_1 <= 5e+299) {
tmp = t_0;
} else {
tmp = fma(y, (x / z), x);
}
return tmp;
}
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function code(x, y, z) t_0 = Float64(x + Float64(Float64(x * y) / z)) t_1 = Float64(Float64(x * Float64(y + z)) / z) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x / Float64(z / Float64(y + z))); elseif (t_1 <= -1e+80) tmp = t_0; elseif (t_1 <= 5e-38) tmp = fma(x, Float64(y / z), x); elseif (t_1 <= 5e+299) tmp = t_0; else tmp = fma(y, Float64(x / z), x); end return tmp end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x / N[(z / N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e+80], t$95$0, If[LessEqual[t$95$1, 5e-38], N[(x * N[(y / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$1, 5e+299], t$95$0, N[(y * N[(x / z), $MachinePrecision] + x), $MachinePrecision]]]]]]]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
t_0 := x + \frac{x \cdot y}{z}\\
t_1 := \frac{x \cdot \left(y + z\right)}{z}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\
\mathbf{elif}\;t_1 \leq -1 \cdot 10^{+80}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{-38}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{y}{z}, x\right)\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+299}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z}, x\right)\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 12.0 |
|---|---|
| Target | 2.9 |
| Herbie | 0.4 |
if (/.f64 (*.f64 x (+.f64 y z)) z) < -inf.0Initial program 64.0
Applied egg-rr0.1
Applied egg-rr0.0
if -inf.0 < (/.f64 (*.f64 x (+.f64 y z)) z) < -1e80 or 5.00000000000000033e-38 < (/.f64 (*.f64 x (+.f64 y z)) z) < 5.0000000000000003e299Initial program 0.2
Applied egg-rr7.4
Taylor expanded in z around 0 0.2
if -1e80 < (/.f64 (*.f64 x (+.f64 y z)) z) < 5.00000000000000033e-38Initial program 5.8
Simplified0.5
if 5.0000000000000003e299 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 60.1
Simplified1.6
Taylor expanded in x around 0 1.6
Simplified1.8
Final simplification0.4
herbie shell --seed 2022166
(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))