Math FPCore C Julia Wolfram TeX \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\]
↓
\[\mathsf{fma}\left(x, y, \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, z \cdot t\right)\right)\right)
\]
(FPCore (x y z t a b c i)
:precision binary64
(+ (+ (+ (* x y) (* z t)) (* a b)) (* c i))) ↓
(FPCore (x y z t a b c i)
:precision binary64
(fma x y (fma c i (fma a b (* z t))))) double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
↓
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(x, y, fma(c, i, fma(a, b, (z * t))));
}
function code(x, y, z, t, a, b, c, i)
return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i))
end
↓
function code(x, y, z, t, a, b, c, i)
return fma(x, y, fma(c, i, fma(a, b, Float64(z * t))))
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
↓
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(x * y + N[(c * i + N[(a * b + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
↓
\mathsf{fma}\left(x, y, \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, z \cdot t\right)\right)\right)
Alternatives Alternative 1 Accuracy 100.0% Cost 19776
\[\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right)
\]
Alternative 2 Accuracy 63.8% Cost 3568
\[\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
t_2 := c \cdot i + z \cdot t\\
t_3 := c \cdot i + x \cdot y\\
t_4 := a \cdot b + c \cdot i\\
\mathbf{if}\;a \cdot b \leq -8.2 \cdot 10^{+18}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;a \cdot b \leq -1.5 \cdot 10^{-32}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{elif}\;a \cdot b \leq -1.45 \cdot 10^{-171}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;a \cdot b \leq -6 \cdot 10^{-237}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq -7.5 \cdot 10^{-281}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-316}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{-324}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;a \cdot b \leq 6.5 \cdot 10^{-142}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 4.6 \cdot 10^{-51}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq 1.95 \cdot 10^{-19}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 6.5 \cdot 10^{-6}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq 4.8 \cdot 10^{+71}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_4\\
\end{array}
\]
Alternative 3 Accuracy 33.9% Cost 2833
\[\begin{array}{l}
\mathbf{if}\;i \leq -1.15 \cdot 10^{-18}:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;i \leq -2.6 \cdot 10^{-99}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;i \leq -6.7 \cdot 10^{-220}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;i \leq -1.05 \cdot 10^{-272}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;i \leq -9.6 \cdot 10^{-294}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;i \leq -9.6 \cdot 10^{-300}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;i \leq 6.8 \cdot 10^{-294}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;i \leq 1.05 \cdot 10^{-282}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;i \leq 3.8 \cdot 10^{-275}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;i \leq 1.3 \cdot 10^{-257}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;i \leq 1.42 \cdot 10^{-227}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;i \leq 1.7 \cdot 10^{-170}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;i \leq 1.85 \cdot 10^{-94}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;i \leq 9.7 \cdot 10^{-23}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;i \leq 5 \cdot 10^{+23}:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;i \leq 1.45 \cdot 10^{+32}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;i \leq 5.5 \cdot 10^{+53}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;i \leq 5.7 \cdot 10^{+94} \lor \neg \left(i \leq 1.35 \cdot 10^{+121}\right) \land i \leq 4.6 \cdot 10^{+153}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;c \cdot i\\
\end{array}
\]
Alternative 4 Accuracy 38.4% Cost 2532
\[\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -3.2 \cdot 10^{+127}:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;c \cdot i \leq -1.1 \cdot 10^{-12}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;c \cdot i \leq -9.5 \cdot 10^{-81}:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;c \cdot i \leq -4.4 \cdot 10^{-257}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;c \cdot i \leq 5.5 \cdot 10^{-225}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;c \cdot i \leq 1.55 \cdot 10^{-127}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;c \cdot i \leq 3.4 \cdot 10^{-19}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;c \cdot i \leq 7.2 \cdot 10^{+57}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;c \cdot i \leq 5.3 \cdot 10^{+81}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;c \cdot i\\
\end{array}
\]
Alternative 5 Accuracy 58.5% Cost 2165
\[\begin{array}{l}
t_1 := a \cdot b + z \cdot t\\
t_2 := c \cdot i + z \cdot t\\
t_3 := a \cdot b + x \cdot y\\
\mathbf{if}\;i \leq -0.65:\\
\;\;\;\;t_2\\
\mathbf{elif}\;i \leq -2.6 \cdot 10^{-146}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;i \leq -3.1 \cdot 10^{-217}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;i \leq -7.2 \cdot 10^{-300}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;i \leq 3.2 \cdot 10^{-144}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;i \leq 5 \cdot 10^{-95}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;i \leq 2.5 \cdot 10^{-22}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;i \leq 2400000:\\
\;\;\;\;t_2\\
\mathbf{elif}\;i \leq 1.55 \cdot 10^{+32}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;i \leq 1.05 \cdot 10^{+52}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;i \leq 4 \cdot 10^{+91} \lor \neg \left(i \leq 4.8 \cdot 10^{+120}\right) \land i \leq 1.95 \cdot 10^{+146}:\\
\;\;\;\;t_3\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
Alternative 6 Accuracy 58.3% Cost 2032
\[\begin{array}{l}
t_1 := a \cdot b + x \cdot y\\
t_2 := a \cdot b + z \cdot t\\
t_3 := c \cdot i + x \cdot y\\
t_4 := c \cdot i + z \cdot t\\
\mathbf{if}\;y \leq -2.8 \cdot 10^{-87}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{-296}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 4.3 \cdot 10^{-223}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{-204}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{-104}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-49}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-23}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;y \leq 0.00042:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{+136}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+162}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+256}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+276}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 7 Accuracy 65.4% Cost 2008
\[\begin{array}{l}
t_1 := a \cdot b + x \cdot y\\
t_2 := a \cdot b + z \cdot t\\
t_3 := a \cdot b + c \cdot i\\
\mathbf{if}\;c \cdot i \leq -6.5 \cdot 10^{+71}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;c \cdot i \leq -1.2 \cdot 10^{-89}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \cdot i \leq 0:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \cdot i \leq 2.4 \cdot 10^{-155}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \cdot i \leq 0.0225:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \cdot i \leq 1.22 \cdot 10^{+48}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
\]
Alternative 8 Accuracy 47.7% Cost 1638
\[\begin{array}{l}
t_1 := a \cdot b + c \cdot i\\
\mathbf{if}\;b \leq -3.4 \cdot 10^{-142}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;b \leq -1.26 \cdot 10^{-231}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;b \leq -9.4 \cdot 10^{-304}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;b \leq 1.7 \cdot 10^{-283}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-206}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;b \leq 5.8 \cdot 10^{-73} \lor \neg \left(b \leq 4.2 \cdot 10^{-36} \lor \neg \left(b \leq 3.7 \cdot 10^{+18}\right) \land b \leq 2.45 \cdot 10^{+67}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\]
Alternative 9 Accuracy 49.9% Cost 1504
\[\begin{array}{l}
t_1 := a \cdot b + z \cdot t\\
t_2 := a \cdot b + c \cdot i\\
\mathbf{if}\;y \leq -5.6 \cdot 10^{-73}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq -6 \cdot 10^{-309}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-273}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 0.000225:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+146}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+158}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+168}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq 1.12 \cdot 10^{+257}:\\
\;\;\;\;x \cdot y\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 10 Accuracy 86.0% Cost 1224
\[\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -6.5 \cdot 10^{+127}:\\
\;\;\;\;a \cdot b + c \cdot i\\
\mathbf{elif}\;c \cdot i \leq 4 \cdot 10^{+136}:\\
\;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;c \cdot i + x \cdot y\\
\end{array}
\]
Alternative 11 Accuracy 100.0% Cost 960
\[\left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) + c \cdot i
\]
Alternative 12 Accuracy 40.1% Cost 712
\[\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -3.2 \cdot 10^{+132}:\\
\;\;\;\;c \cdot i\\
\mathbf{elif}\;c \cdot i \leq 3.7 \cdot 10^{+56}:\\
\;\;\;\;a \cdot b\\
\mathbf{else}:\\
\;\;\;\;c \cdot i\\
\end{array}
\]
Alternative 13 Accuracy 26.1% Cost 192
\[a \cdot b
\]