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




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 12.3 |
|---|---|
| Target | 3.0 |
| Herbie | 2.2 |
if (/.f64 (*.f64 x (+.f64 y z)) z) < -inf.0 or 1.4901022506184445e44 < (/.f64 (*.f64 x (+.f64 y z)) z) Initial program 28.9
Simplified5.2
Taylor expanded in x around 0 5.2
Simplified5.2
if -inf.0 < (/.f64 (*.f64 x (+.f64 y z)) z) < -1.8899164894020197e138Initial program 0.2
if -1.8899164894020197e138 < (/.f64 (*.f64 x (+.f64 y z)) z) < 1.4901022506184445e44Initial program 5.1
Simplified0.9
Final simplification2.2
herbie shell --seed 2022150
(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))