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))))): 1 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))))): 1 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))))): 0 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)
\]
Alternatives
Alternative 1
Error
26.8
Cost
2008
\[\begin{array}{l}
t_1 := c \cdot i + x \cdot y\\
\mathbf{if}\;a \cdot b \leq -2.70639484167812 \cdot 10^{+55}:\\
\;\;\;\;a \cdot b\\
\mathbf{elif}\;a \cdot b \leq -3.216921093739587 \cdot 10^{-183}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-320}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 1.2963300845675692 \cdot 10^{-159}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 1.1477818983799606 \cdot 10^{-96}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 3.684930364342622 \cdot 10^{+76}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;a \cdot b\\
\end{array}
\]
Alternative 2
Error
24.2
Cost
2008
\[\begin{array}{l}
t_1 := c \cdot i + x \cdot y\\
t_2 := a \cdot b + c \cdot i\\
\mathbf{if}\;a \cdot b \leq -8.964551718449584 \cdot 10^{+21}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq -3.216921093739587 \cdot 10^{-183}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-320}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 1.2963300845675692 \cdot 10^{-159}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 1.1477818983799606 \cdot 10^{-96}:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;a \cdot b \leq 3.684930364342622 \cdot 10^{+76}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
Alternative 3
Error
22.5
Cost
2008
\[\begin{array}{l}
t_1 := c \cdot i + z \cdot t\\
t_2 := c \cdot i + x \cdot y\\
t_3 := a \cdot b + c \cdot i\\
\mathbf{if}\;a \cdot b \leq -2.70639484167812 \cdot 10^{+55}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-320}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 5.4 \cdot 10^{-173}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq 1.1477818983799606 \cdot 10^{-96}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 3.684930364342622 \cdot 10^{+76}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq 2.4995343008912378 \cdot 10^{+104}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\end{array}
\]
Alternative 4
Error
22.1
Cost
2008
\[\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 -2.70639484167812 \cdot 10^{+55}:\\
\;\;\;\;a \cdot b + c \cdot i\\
\mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-320}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 5.4 \cdot 10^{-173}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq 1.1477818983799606 \cdot 10^{-96}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;a \cdot b \leq 219660442780658.6:\\
\;\;\;\;t_2\\
\mathbf{elif}\;a \cdot b \leq 7.016688697307986 \cdot 10^{+45}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\
\end{array}
\]
Alternative 5
Error
21.9
Cost
2008
\[\begin{array}{l}
t_1 := a \cdot b + z \cdot t\\
t_2 := a \cdot b + x \cdot y\\
\mathbf{if}\;c \cdot i \leq -6.552475320183716 \cdot 10^{+67}:\\
\;\;\;\;a \cdot b + c \cdot i\\
\mathbf{elif}\;c \cdot i \leq -9.235571947182081 \cdot 10^{-87}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \cdot i \leq -1.1964602259079888 \cdot 10^{-224}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \cdot i \leq 1.788175022096186 \cdot 10^{-58}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \cdot i \leq 2.702253921001196 \cdot 10^{-32}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \cdot i \leq 2.955115648612862 \cdot 10^{+56}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;c \cdot i + x \cdot y\\
\end{array}
\]
\[\begin{array}{l}
t_1 := c \cdot i + \left(a \cdot b + z \cdot t\right)\\
t_2 := a \cdot b + x \cdot y\\
\mathbf{if}\;x \leq -1.25 \cdot 10^{+234}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq -1.05 \cdot 10^{+147}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -7.2 \cdot 10^{+130}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq 8.81942464379364 \cdot 10^{-123}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;c \cdot i + x \cdot y\\
\end{array}
\]
Alternative 9
Error
6.6
Cost
1224
\[\begin{array}{l}
t_1 := c \cdot i + \left(a \cdot b + z \cdot t\right)\\
\mathbf{if}\;c \cdot i \leq -497.7125978490741:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \cdot i \leq 2.855395496097922 \cdot 10^{+75}:\\
\;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
Alternative 10
Error
6.1
Cost
1224
\[\begin{array}{l}
t_1 := c \cdot i + \left(a \cdot b + x \cdot y\right)\\
\mathbf{if}\;c \cdot i \leq -6.552475320183716 \cdot 10^{+67}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \cdot i \leq 9.794129869804682 \cdot 10^{+65}:\\
\;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\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 2022295
(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)))