?

Average Accuracy: 100.0% → 100.0%
Time: 13.6s
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%
Cost7232
\[\mathsf{fma}\left(x, y, z \cdot t\right) + \left(a \cdot b + c \cdot i\right) \]
Alternative 2
Accuracy64.8%
Cost2268
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ \mathbf{if}\;c \cdot i \leq -7.4 \cdot 10^{-60}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -3.2 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -8.5 \cdot 10^{-121}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -7.2 \cdot 10^{-133}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq -2.15 \cdot 10^{-271}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 6 \cdot 10^{-229}:\\ \;\;\;\;x \cdot y + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 85000000000000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \end{array} \]
Alternative 3
Accuracy40.5%
Cost2012
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -3 \cdot 10^{+60}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -3.6 \cdot 10^{-135}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq -1.75 \cdot 10^{-203}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-113}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 2.4 \cdot 10^{-27}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 3.1 \cdot 10^{+22}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.7 \cdot 10^{+103}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 4
Accuracy39.1%
Cost1752
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -6.6 \cdot 10^{+60}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -4 \cdot 10^{-135}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq -1.1 \cdot 10^{-194}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 4.5 \cdot 10^{-9}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.9 \cdot 10^{+55}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{+154}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 5
Accuracy65.0%
Cost1748
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ t_3 := a \cdot b + c \cdot i\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+32}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 3.5 \cdot 10^{-102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 3 \cdot 10^{-42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 4.1 \cdot 10^{+26}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 8 \cdot 10^{+99}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Accuracy65.8%
Cost1748
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := a \cdot b + c \cdot i\\ \mathbf{if}\;a \cdot b \leq -5.8 \cdot 10^{+32}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -1.3 \cdot 10^{-213}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 3 \cdot 10^{-26}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 3.4 \cdot 10^{+26}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 10^{+101}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Accuracy84.3%
Cost1488
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;c \cdot i \leq -3.9 \cdot 10^{+15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.8 \cdot 10^{+42}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{elif}\;c \cdot i \leq 8 \cdot 10^{+135}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 5.7 \cdot 10^{+164}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Accuracy51.1%
Cost1242
\[\begin{array}{l} \mathbf{if}\;y \leq -28000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+60} \lor \neg \left(y \leq 4.2 \cdot 10^{+75}\right) \land \left(y \leq 8.5 \cdot 10^{+187} \lor \neg \left(y \leq 9.5 \cdot 10^{+202}\right) \land y \leq 1.14 \cdot 10^{+247}\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 9
Accuracy64.3%
Cost969
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -6 \cdot 10^{-95} \lor \neg \left(c \cdot i \leq 8 \cdot 10^{+41}\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 10
Accuracy64.7%
Cost969
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -4.2 \cdot 10^{-59} \lor \neg \left(c \cdot i \leq 660000000\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \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
Accuracy39.4%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -4.7 \cdot 10^{+60}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{+154}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 13
Accuracy25.9%
Cost192
\[a \cdot b \]

Error

Reproduce?

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