Math FPCore C Julia Wolfram TeX \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\]
↓
\[\begin{array}{l}
\mathbf{if}\;z \leq 10^{-39}:\\
\;\;\;\;\left(t \cdot a + \left(x + z \cdot y\right)\right) + \left(z \cdot a\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), \mathsf{fma}\left(t, a, x\right)\right)\\
\end{array}
\]
(FPCore (x y z t a b)
:precision binary64
(+ (+ (+ x (* y z)) (* t a)) (* (* a z) b))) ↓
(FPCore (x y z t a b)
:precision binary64
(if (<= z 1e-39)
(+ (+ (* t a) (+ x (* z y))) (* (* z a) b))
(fma z (fma a b y) (fma t a x)))) double code(double x, double y, double z, double t, double a, double b) {
return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
↓
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (z <= 1e-39) {
tmp = ((t * a) + (x + (z * y))) + ((z * a) * b);
} else {
tmp = fma(z, fma(a, b, y), fma(t, a, x));
}
return tmp;
}
function code(x, y, z, t, a, b)
return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b))
end
↓
function code(x, y, z, t, a, b)
tmp = 0.0
if (z <= 1e-39)
tmp = Float64(Float64(Float64(t * a) + Float64(x + Float64(z * y))) + Float64(Float64(z * a) * b));
else
tmp = fma(z, fma(a, b, y), fma(t, a, x));
end
return tmp
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
↓
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, 1e-39], N[(N[(N[(t * a), $MachinePrecision] + N[(x + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(z * a), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(z * N[(a * b + y), $MachinePrecision] + N[(t * a + x), $MachinePrecision]), $MachinePrecision]]
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
↓
\begin{array}{l}
\mathbf{if}\;z \leq 10^{-39}:\\
\;\;\;\;\left(t \cdot a + \left(x + z \cdot y\right)\right) + \left(z \cdot a\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, \mathsf{fma}\left(a, b, y\right), \mathsf{fma}\left(t, a, x\right)\right)\\
\end{array}
Alternatives Alternative 1 Error 1.4 Cost 1988
\[\begin{array}{l}
t_1 := x + z \cdot y\\
t_2 := \left(t \cdot a + t_1\right) + \left(z \cdot a\right) \cdot b\\
\mathbf{if}\;t_2 \leq 2 \cdot 10^{+298}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot \left(z \cdot b\right) + t \cdot a\right) + t_1\\
\end{array}
\]
Alternative 2 Error 22.2 Cost 1769
\[\begin{array}{l}
t_1 := x + z \cdot y\\
t_2 := z \cdot \left(y + a \cdot b\right)\\
t_3 := x + t \cdot a\\
\mathbf{if}\;z \leq -3.4 \cdot 10^{+192}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -5.2 \cdot 10^{+38}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq -7.6 \cdot 10^{-71}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -1.7 \cdot 10^{-117}:\\
\;\;\;\;a \cdot \left(z \cdot b\right)\\
\mathbf{elif}\;z \leq -4.6 \cdot 10^{-136}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{-149}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-46}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;z \leq 0.00021 \lor \neg \left(z \leq 2.15 \cdot 10^{+55}\right) \land z \leq 1.2 \cdot 10^{+130}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 3 Error 34.3 Cost 1244
\[\begin{array}{l}
t_1 := \left(z \cdot a\right) \cdot b\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{-6}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -7.8 \cdot 10^{-255}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-302}:\\
\;\;\;\;a \cdot \left(z \cdot b\right)\\
\mathbf{elif}\;x \leq 2.55 \cdot 10^{-291}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-70}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.15 \cdot 10^{-6}:\\
\;\;\;\;t \cdot a\\
\mathbf{elif}\;x \leq 6200:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\]
Alternative 4 Error 34.5 Cost 980
\[\begin{array}{l}
t_1 := a \cdot \left(z \cdot b\right)\\
\mathbf{if}\;x \leq -1.25 \cdot 10^{-7}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-255}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;x \leq -3.5 \cdot 10^{-306}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 5.1 \cdot 10^{-290}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;x \leq 0.0145:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\]
Alternative 5 Error 27.6 Cost 980
\[\begin{array}{l}
t_1 := x + t \cdot a\\
\mathbf{if}\;x \leq -1.7 \cdot 10^{-165}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.42 \cdot 10^{-247}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;x \leq -1.7 \cdot 10^{-303}:\\
\;\;\;\;a \cdot \left(z \cdot b\right)\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{-295}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;x \leq 6.5 \cdot 10^{-111}:\\
\;\;\;\;\left(z \cdot a\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 6 Error 2.7 Cost 960
\[\left(a \cdot \left(z \cdot b\right) + t \cdot a\right) + \left(x + z \cdot y\right)
\]
Alternative 7 Error 21.0 Cost 844
\[\begin{array}{l}
t_1 := a \cdot \left(t + z \cdot b\right)\\
\mathbf{if}\;a \leq -3.2 \cdot 10^{+156}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \leq -3.9 \cdot 10^{-31}:\\
\;\;\;\;x + \left(z \cdot a\right) \cdot b\\
\mathbf{elif}\;a \leq 4.8 \cdot 10^{-30}:\\
\;\;\;\;x + z \cdot y\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 8 Error 20.8 Cost 844
\[\begin{array}{l}
t_1 := a \cdot \left(t + z \cdot b\right)\\
\mathbf{if}\;a \leq -1.7 \cdot 10^{+161}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \leq -4 \cdot 10^{-31}:\\
\;\;\;\;x + a \cdot \left(z \cdot b\right)\\
\mathbf{elif}\;a \leq 2.55 \cdot 10^{-30}:\\
\;\;\;\;x + z \cdot y\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 9 Error 12.6 Cost 841
\[\begin{array}{l}
\mathbf{if}\;a \leq -2.3 \cdot 10^{-102} \lor \neg \left(a \leq 1.5 \cdot 10^{-30}\right):\\
\;\;\;\;x + a \cdot \left(t + z \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot y\\
\end{array}
\]
Alternative 10 Error 8.1 Cost 841
\[\begin{array}{l}
\mathbf{if}\;a \leq -7 \cdot 10^{-36} \lor \neg \left(a \leq 1.6 \cdot 10^{-30}\right):\\
\;\;\;\;x + a \cdot \left(t + z \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + t \cdot a\right) + z \cdot y\\
\end{array}
\]
Alternative 11 Error 20.8 Cost 713
\[\begin{array}{l}
\mathbf{if}\;a \leq -4.2 \cdot 10^{+105} \lor \neg \left(a \leq 4.8 \cdot 10^{-30}\right):\\
\;\;\;\;a \cdot \left(t + z \cdot b\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot y\\
\end{array}
\]
Alternative 12 Error 32.6 Cost 588
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \cdot 10^{-6}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-264}:\\
\;\;\;\;z \cdot y\\
\mathbf{elif}\;x \leq 12000:\\
\;\;\;\;t \cdot a\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\]
Alternative 13 Error 19.9 Cost 585
\[\begin{array}{l}
\mathbf{if}\;a \leq -1.1 \cdot 10^{-9} \lor \neg \left(a \leq 2 \cdot 10^{-30}\right):\\
\;\;\;\;x + t \cdot a\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot y\\
\end{array}
\]
Alternative 14 Error 33.0 Cost 456
\[\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{-43}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 78000:\\
\;\;\;\;t \cdot a\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\]
Alternative 15 Error 39.8 Cost 64
\[x
\]