Average Error: 0.0 → 0.0
Time: 11.9s
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
Error22.4
Cost2528
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ t_3 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -6.1 \cdot 10^{+97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.9 \cdot 10^{+61}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -6.5 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -6.3 \cdot 10^{-24}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.6 \cdot 10^{-278}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq 5.9 \cdot 10^{-151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.55 \cdot 10^{-77}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq 2.7 \cdot 10^{+53}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]
Alternative 2
Error22.4
Cost2008
\[\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 -1.8 \cdot 10^{+43}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -5.2 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 4.7 \cdot 10^{-278}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 9.5 \cdot 10^{-152}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 7 \cdot 10^{-76}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 4.4 \cdot 10^{+51}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Error22.4
Cost2008
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1.75 \cdot 10^{+43}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq -3.5 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 2.5 \cdot 10^{-278}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.8 \cdot 10^{-151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 3 \cdot 10^{-77}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 2.1 \cdot 10^{+52}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]
Alternative 4
Error38.5
Cost1752
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -7 \cdot 10^{+34}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -3.8 \cdot 10^{-308}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 1.6 \cdot 10^{-276}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{-118}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 10^{-91}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 7 \cdot 10^{+112}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 5
Error38.9
Cost1752
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -4.1 \cdot 10^{-98}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -4 \cdot 10^{-314}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{-322}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 6.1 \cdot 10^{-176}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 7.4 \cdot 10^{-54}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 1.7 \cdot 10^{-28}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 6
Error32.8
Cost1240
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;z \leq -6 \cdot 10^{+200}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \leq -1.4 \cdot 10^{+108}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.7 \cdot 10^{+46}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-40}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 9.6 \cdot 10^{-55}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 7
Error8.6
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.06 \cdot 10^{+106} \lor \neg \left(c \cdot i \leq 7.8 \cdot 10^{+80}\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(z \cdot t + x \cdot y\right)\\ \end{array} \]
Alternative 8
Error6.2
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -8.2 \cdot 10^{+42} \lor \neg \left(c \cdot i \leq 7.4 \cdot 10^{+65}\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
Error22.4
Cost969
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.75 \cdot 10^{-32} \lor \neg \left(c \cdot i \leq 60000000000000\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 10
Error0.0
Cost960
\[c \cdot i + \left(a \cdot b + \left(z \cdot t + x \cdot y\right)\right) \]
Alternative 11
Error38.5
Cost712
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -4.9 \cdot 10^{+34}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 1.9 \cdot 10^{+113}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 12
Error47.5
Cost192
\[a \cdot b \]

Error

Reproduce

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