(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (fma x (/ y z) x)) (t_1 (+ x (/ (* x y) z))))
(if (<= x -2.041895623003483e-62)
t_0
(if (<= x -6.363410517185796e-300)
t_1
(if (<= x 3.162995441140994e-151)
(fma y (/ x z) x)
(if (<= x 1.1147993284127676e-87) t_1 t_0))))))double code(double x, double y, double z) {
return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
double t_0 = fma(x, (y / z), x);
double t_1 = x + ((x * y) / z);
double tmp;
if (x <= -2.041895623003483e-62) {
tmp = t_0;
} else if (x <= -6.363410517185796e-300) {
tmp = t_1;
} else if (x <= 3.162995441140994e-151) {
tmp = fma(y, (x / z), x);
} else if (x <= 1.1147993284127676e-87) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) return Float64(Float64(x * Float64(y + z)) / z) end
function code(x, y, z) t_0 = fma(x, Float64(y / z), x) t_1 = Float64(x + Float64(Float64(x * y) / z)) tmp = 0.0 if (x <= -2.041895623003483e-62) tmp = t_0; elseif (x <= -6.363410517185796e-300) tmp = t_1; elseif (x <= 3.162995441140994e-151) tmp = fma(y, Float64(x / z), x); elseif (x <= 1.1147993284127676e-87) tmp = t_1; else tmp = t_0; 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[(y / z), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.041895623003483e-62], t$95$0, If[LessEqual[x, -6.363410517185796e-300], t$95$1, If[LessEqual[x, 3.162995441140994e-151], N[(y * N[(x / z), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[x, 1.1147993284127676e-87], t$95$1, t$95$0]]]]]]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
t_0 := \mathsf{fma}\left(x, \frac{y}{z}, x\right)\\
t_1 := x + \frac{x \cdot y}{z}\\
\mathbf{if}\;x \leq -2.041895623003483 \cdot 10^{-62}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -6.363410517185796 \cdot 10^{-300}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.162995441140994 \cdot 10^{-151}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z}, x\right)\\
\mathbf{elif}\;x \leq 1.1147993284127676 \cdot 10^{-87}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 12.6 |
|---|---|
| Target | 3.1 |
| Herbie | 1.6 |
if x < -2.04189562300348299e-62 or 1.11479932841276762e-87 < x Initial program 17.7
Simplified0.4
if -2.04189562300348299e-62 < x < -6.3634105171857962e-300 or 3.16299544114099425e-151 < x < 1.11479932841276762e-87Initial program 4.8
Simplified6.5
Taylor expanded in y around 0 2.5
if -6.3634105171857962e-300 < x < 3.16299544114099425e-151Initial program 9.1
Simplified7.7
Taylor expanded in x around 0 7.7
Simplified3.9
Final simplification1.6
herbie shell --seed 2022153
(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))