Average Error: 0.0 → 0.0
Time: 13.1s
Precision: binary64
Cost: 19776
\[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
\[\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, 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 a b (fma c i (fma x y (* 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(a, b, fma(c, i, fma(x, y, (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(a, b, fma(c, i, fma(x, y, 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[(a * b + N[(c * i + N[(x * y + 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(a, b, \mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right)

Error

Derivation

  1. Initial program 0.0

    \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
  2. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right)} \]
    Proof

    [Start]0.0

    \[ \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]

    +-commutative [=>]0.0

    \[ \color{blue}{\left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right)} + c \cdot i \]

    associate-+l+ [=>]0.0

    \[ \color{blue}{a \cdot b + \left(\left(x \cdot y + z \cdot t\right) + c \cdot i\right)} \]

    fma-def [=>]0.0

    \[ \color{blue}{\mathsf{fma}\left(a, b, \left(x \cdot y + z \cdot t\right) + c \cdot i\right)} \]

    +-commutative [=>]0.0

    \[ \mathsf{fma}\left(a, b, \color{blue}{c \cdot i + \left(x \cdot y + z \cdot t\right)}\right) \]

    fma-def [=>]0.0

    \[ \mathsf{fma}\left(a, b, \color{blue}{\mathsf{fma}\left(c, i, x \cdot y + z \cdot t\right)}\right) \]

    fma-def [=>]0.0

    \[ \mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right)}\right)\right) \]
  3. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right) \]

Alternatives

Alternative 1
Error38.2
Cost3052
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.05 \cdot 10^{+129}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.45 \cdot 10^{+57}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq -4.8 \cdot 10^{+33}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1 \cdot 10^{-137}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq -1.4 \cdot 10^{-208}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 1.5 \cdot 10^{-298}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 9.5 \cdot 10^{-179}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 5.6 \cdot 10^{-146}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.05 \cdot 10^{-88}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 2.05 \cdot 10^{-79}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 7.5 \cdot 10^{+60}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 2
Error27.0
Cost2560
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := z \cdot t + x \cdot y\\ t_3 := c \cdot i + x \cdot y\\ t_4 := a \cdot b + c \cdot i\\ \mathbf{if}\;a \leq -1.45 \cdot 10^{+173}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \leq -1.75 \cdot 10^{+169}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -2 \cdot 10^{+113}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \leq -7 \cdot 10^{+44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1.45 \cdot 10^{-49}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -1.9 \cdot 10^{-74}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -2.45 \cdot 10^{-88}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -6.2 \cdot 10^{-135}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1 \cdot 10^{-142}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -7.2 \cdot 10^{-168}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1.05 \cdot 10^{-208}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 1.08 \cdot 10^{-307}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.65 \cdot 10^{-136}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 3.9 \cdot 10^{-81}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.2 \cdot 10^{-44}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 4.5 \cdot 10^{-13}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error24.5
Cost2008
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + c \cdot i\\ \mathbf{if}\;c \cdot i \leq -1.35 \cdot 10^{+122}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -8 \cdot 10^{-76}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.25 \cdot 10^{-137}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.8 \cdot 10^{-178}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{-149}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 3.6 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error22.0
Cost2008
\[\begin{array}{l} t_1 := c \cdot i + x \cdot y\\ t_2 := a \cdot b + z \cdot t\\ t_3 := c \cdot i + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -3300:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -1.4 \cdot 10^{-308}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 2.5 \cdot 10^{-284}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 2.6 \cdot 10^{-179}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 8.5 \cdot 10^{-34}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{+59}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error27.1
Cost1900
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ t_3 := a \cdot b + c \cdot i\\ t_4 := c \cdot i + z \cdot t\\ \mathbf{if}\;z \leq -1.65 \cdot 10^{+99}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq -1.02 \cdot 10^{+67}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{+16}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq -140:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.5 \cdot 10^{-10}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1.85 \cdot 10^{-162}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.35 \cdot 10^{-196}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1.9 \cdot 10^{-271}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{-274}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-258}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.38 \cdot 10^{-95}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error23.7
Cost1748
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := a \cdot b + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -1.95 \cdot 10^{+23}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -1.55 \cdot 10^{-206}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -1.05 \cdot 10^{-301}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-33}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 1.22 \cdot 10^{+43}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error33.4
Cost1505
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;b \leq -9.8 \cdot 10^{-146}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -4.5 \cdot 10^{-190}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \leq -2.3 \cdot 10^{-308}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{-259}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \leq 1.6 \cdot 10^{-220}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 4.2 \cdot 10^{-156}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;b \leq 2 \cdot 10^{+61} \lor \neg \left(b \leq 2.2 \cdot 10^{+92}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 8
Error6.4
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.15 \cdot 10^{+32} \lor \neg \left(c \cdot i \leq 7.6 \cdot 10^{-47}\right):\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(z \cdot t + x \cdot y\right)\\ \end{array} \]
Alternative 9
Error9.2
Cost1224
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -3.8 \cdot 10^{+140}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 4.5 \cdot 10^{+133}:\\ \;\;\;\;a \cdot b + \left(z \cdot t + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]
Alternative 10
Error38.2
Cost972
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -2.2 \cdot 10^{+64}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 6 \cdot 10^{-275}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.1 \cdot 10^{+53}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 11
Error0.0
Cost960
\[c \cdot i + \left(a \cdot b + \left(z \cdot t + x \cdot y\right)\right) \]
Alternative 12
Error38.0
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+18}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 1.25 \cdot 10^{+57}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 13
Error47.9
Cost192
\[a \cdot b \]

Error

Reproduce

herbie shell --seed 2022364 
(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)))