?

Average Accuracy: 100.0% → 100.0%
Time: 12.1s
Precision: binary64
Cost: 19776

?

\[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
\[\mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\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 c i (fma x y (fma z t (* a b)))))
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(c, i, fma(x, y, fma(z, t, (a * b))));
}
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(c, i, fma(x, y, fma(z, t, Float64(a * b))))
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[(c * i + N[(x * y + N[(z * t + 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(c, i, \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\right)

Error?

Derivation?

  1. Initial program 100.0%

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

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

    [Start]100.0

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

    +-commutative [=>]100.0

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

    fma-def [=>]100.0

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

    associate-+l+ [=>]100.0

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

    fma-def [=>]100.0

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

    fma-def [=>]100.0

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

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

Alternatives

Alternative 1
Accuracy100.0%
Cost13504
\[\mathsf{fma}\left(z, t, \mathsf{fma}\left(a, b, c \cdot i\right)\right) + x \cdot y \]
Alternative 2
Accuracy40.3%
Cost2272
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.55 \cdot 10^{+54}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -1.06 \cdot 10^{-70}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq -6.4 \cdot 10^{-174}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq -8 \cdot 10^{-202}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-309}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.85 \cdot 10^{-194}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 3.5 \cdot 10^{-95}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.1 \cdot 10^{-6}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 3
Accuracy47.8%
Cost2268
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;a \cdot b \leq -6.6 \cdot 10^{+53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -3 \cdot 10^{-57}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq -5.8 \cdot 10^{-198}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-309}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-194}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 1.5 \cdot 10^{-100}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.55 \cdot 10^{-94}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy66.0%
Cost2268
\[\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\\ \mathbf{if}\;c \cdot i \leq -1.02 \cdot 10^{+31}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -9.5 \cdot 10^{-188}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -4.1 \cdot 10^{-244}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -1 \cdot 10^{-311}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 10^{-319}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 2.5 \cdot 10^{-190}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 3.5 \cdot 10^{+49}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Accuracy40.4%
Cost2012
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -650000:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -1.25 \cdot 10^{-200}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 4.3 \cdot 10^{-308}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 9.5 \cdot 10^{-228}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.6 \cdot 10^{-96}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 5.6 \cdot 10^{-12}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 4.6 \cdot 10^{+73}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 6
Accuracy64.1%
Cost1748
\[\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 -6.2 \cdot 10^{-60}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{-318}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 6.5 \cdot 10^{-194}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 2.8 \cdot 10^{-50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 0.00047:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 7
Accuracy64.1%
Cost1748
\[\begin{array}{l} t_1 := c \cdot i + x \cdot y\\ \mathbf{if}\;a \cdot b \leq -4.5 \cdot 10^{-61}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{-309}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.65 \cdot 10^{-226}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 8.5 \cdot 10^{-104}:\\ \;\;\;\;x \cdot y + z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 0.13:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 8
Accuracy58.4%
Cost1504
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ t_3 := c \cdot i + z \cdot t\\ \mathbf{if}\;a \leq -6.5 \cdot 10^{+109}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -5.3 \cdot 10^{+87}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -3.6 \cdot 10^{+41}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -82000000000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -5.5 \cdot 10^{-55}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.55 \cdot 10^{-156}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 1.2 \cdot 10^{-134}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \leq 2.6 \cdot 10^{+43}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Accuracy86.4%
Cost1224
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -7.6 \cdot 10^{+125}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 8.6 \cdot 10^{+50}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \end{array} \]
Alternative 10
Accuracy66.5%
Cost969
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -4.6 \cdot 10^{+29} \lor \neg \left(c \cdot i \leq 1.32 \cdot 10^{+47}\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 11
Accuracy100.0%
Cost960
\[c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) \]
Alternative 12
Accuracy40.7%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -3900:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 1.45 \cdot 10^{-12}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 13
Accuracy26.3%
Cost192
\[a \cdot b \]

Error

Reproduce?

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