code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(x * y + N[(z * t + N[(c * i + N[(a * b), $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(z, t, \mathsf{fma}\left(c, i, a \cdot b\right)\right)\right)
Error
Derivation
Initial program 0.0
\[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\]
Simplified0.0
\[\leadsto \color{blue}{\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, \mathsf{fma}\left(c, i, a \cdot b\right)\right)\right)}
\]
Proof
(fma.f64 x y (fma.f64 z t (fma.f64 c i (*.f64 a b)))): 0 points increase in error, 0 points decrease in error
(fma.f64 x y (fma.f64 z t (Rewrite<= fma-def_binary64 (+.f64 (*.f64 c i) (*.f64 a b))))): 0 points increase in error, 0 points decrease in error
(fma.f64 x y (fma.f64 z t (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 a b) (*.f64 c i))))): 0 points increase in error, 0 points decrease in error
(fma.f64 x y (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z t) (+.f64 (*.f64 a b) (*.f64 c i))))): 0 points increase in error, 0 points decrease in error
(Rewrite<= fma-def_binary64 (+.f64 (*.f64 x y) (+.f64 (*.f64 z t) (+.f64 (*.f64 a b) (*.f64 c i))))): 3 points increase in error, 0 points decrease in error
(Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (+.f64 (*.f64 a b) (*.f64 c i)))): 0 points increase in error, 0 points decrease in error
(Rewrite<= associate-+l+_binary64 (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i))): 0 points increase in error, 0 points decrease in error
Final simplification0.0
\[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, \mathsf{fma}\left(c, i, a \cdot b\right)\right)\right)
\]
\[\begin{array}{l}
t_1 := c \cdot i + z \cdot t\\
t_2 := c \cdot i + x \cdot y\\
t_3 := a \cdot b + x \cdot y\\
t_4 := a \cdot b + z \cdot t\\
\mathbf{if}\;z \leq -1.1 \cdot 10^{+108}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;z \leq -1.6 \cdot 10^{+62}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq -3.633819394952762 \cdot 10^{-26}:\\
\;\;\;\;x \cdot y + z \cdot t\\
\mathbf{elif}\;z \leq -4.524989730031518 \cdot 10^{-91}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -3.254748266135068 \cdot 10^{-111}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;z \leq -2.201343148291517 \cdot 10^{-128}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -2.4753945096812134 \cdot 10^{-228}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;z \leq -2.3718968462187837 \cdot 10^{-294}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 3.746613471948433 \cdot 10^{-194}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;z \leq 2.920588260265729 \cdot 10^{-152}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.2382982087947776 \cdot 10^{-114}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;z \leq 1.1305807991024928 \cdot 10^{-26}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_4\\
\end{array}
\]
Alternative 4
Error
27.0
Cost
2032
\[\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
t_2 := a \cdot b + c \cdot i\\
t_3 := a \cdot b + z \cdot t\\
t_4 := c \cdot i + x \cdot y\\
\mathbf{if}\;c \leq -1 \cdot 10^{+253}:\\
\;\;\;\;c \cdot i + z \cdot t\\
\mathbf{elif}\;c \leq -1 \cdot 10^{+120}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \leq -7.5 \cdot 10^{+79}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;c \leq -4.416404699707867 \cdot 10^{+43}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\mathbf{elif}\;c \leq -1.3810584533796385 \cdot 10^{-11}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;c \leq -1.213348884728547 \cdot 10^{-43}:\\
\;\;\;\;t_4\\
\mathbf{elif}\;c \leq -2.5853453954942436 \cdot 10^{-98}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;c \leq -8.866393046620784 \cdot 10^{-116}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -9.935589498688963 \cdot 10^{-298}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;c \leq 1.3351196157635446 \cdot 10^{-170}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq 1.9911277113322299 \cdot 10^{-125}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \leq 6.683106745506148 \cdot 10^{-27}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
Alternative 5
Error
24.5
Cost
1748
\[\begin{array}{l}
t_1 := c \cdot i + z \cdot t\\
t_2 := c \cdot i + x \cdot y\\
\mathbf{if}\;a \cdot b \leq -1.2262941703047695 \cdot 10^{+137}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -2.295004615232815 \cdot 10^{-307}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 3.4524827158117685 \cdot 10^{-272}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq 5.597765517608566 \cdot 10^{-22}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 3.1637184468039277 \cdot 10^{+98}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\]
Alternative 6
Error
21.6
Cost
1748
\[\begin{array}{l}
t_1 := c \cdot i + z \cdot t\\
t_2 := c \cdot i + x \cdot y\\
t_3 := a \cdot b + z \cdot t\\
\mathbf{if}\;a \cdot b \leq -1.7133184715305773 \cdot 10^{-7}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;a \cdot b \leq -2.295004615232815 \cdot 10^{-307}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 3.4524827158117685 \cdot 10^{-272}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq 5.597765517608566 \cdot 10^{-22}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 647862829457.7161:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
\]
Alternative 7
Error
24.8
Cost
1488
\[\begin{array}{l}
t_1 := c \cdot i + z \cdot t\\
\mathbf{if}\;a \cdot b \leq -1.2262941703047695 \cdot 10^{+137}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq 5.597765517608566 \cdot 10^{-22}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 3.05383689775349 \cdot 10^{-5}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;a \cdot b \leq 3.1637184468039277 \cdot 10^{+98}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\]
\[\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.4033230368514006 \cdot 10^{+107}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 3.1637184468039277 \cdot 10^{+98}:\\
\;\;\;\;c \cdot i + \left(x \cdot y + z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + x \cdot y\\
\end{array}
\]
Alternative 10
Error
6.0
Cost
1224
\[\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
t_2 := a \cdot b + t_1\\
\mathbf{if}\;a \cdot b \leq -1.7133184715305773 \cdot 10^{-7}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq 647862829457.7161:\\
\;\;\;\;c \cdot i + t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
Alternative 11
Error
0.0
Cost
960
\[c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right)
\]
herbie shell --seed 2022308
(FPCore (x y z t a b c i)
:name "Linear.V4:$cdot from linear-1.19.1.3, C"
:precision binary64
(+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))