?

Average Accuracy: 100.0% → 100.0%
Time: 17.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 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(a, b, \mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, z \cdot t\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}{\left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right)} + c \cdot i \]

    associate-+l+ [=>]100.0

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

    fma-def [=>]100.0

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

    +-commutative [=>]100.0

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

    fma-def [=>]100.0

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

    fma-def [=>]100.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 simplification100.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
Accuracy58.9%
Cost1768
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := z \cdot t + c \cdot i\\ t_3 := z \cdot t + a \cdot b\\ \mathbf{if}\;c \leq -1.8 \cdot 10^{+181}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -8.8 \cdot 10^{+164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -7 \cdot 10^{+126}:\\ \;\;\;\;c \cdot i + a \cdot b\\ \mathbf{elif}\;c \leq -2.05 \cdot 10^{+116}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -4.5 \cdot 10^{+14}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -2.5 \cdot 10^{-68}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -7.5 \cdot 10^{-194}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 2.7 \cdot 10^{-267}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 4.3 \cdot 10^{-212}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 4 \cdot 10^{-124}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Accuracy57.3%
Cost1636
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := z \cdot t + c \cdot i\\ t_3 := z \cdot t + a \cdot b\\ \mathbf{if}\;c \leq -3.3 \cdot 10^{+179}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -8.8 \cdot 10^{+164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.8 \cdot 10^{+126}:\\ \;\;\;\;c \cdot i + a \cdot b\\ \mathbf{elif}\;c \leq -3.2 \cdot 10^{+115}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -2.7 \cdot 10^{+14}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -9.5 \cdot 10^{-69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -6.2 \cdot 10^{-203}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{-268}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.05 \cdot 10^{-198}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \end{array} \]
Alternative 3
Accuracy57.2%
Cost1636
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := z \cdot t + c \cdot i\\ t_3 := z \cdot t + a \cdot b\\ \mathbf{if}\;c \leq -3.2 \cdot 10^{+179}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -8.8 \cdot 10^{+164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -5.5 \cdot 10^{+126}:\\ \;\;\;\;c \cdot i + a \cdot b\\ \mathbf{elif}\;c \leq -2.05 \cdot 10^{+116}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -5.8 \cdot 10^{+14}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -2.8 \cdot 10^{-85}:\\ \;\;\;\;z \cdot t + x \cdot y\\ \mathbf{elif}\;c \leq -6 \cdot 10^{-202}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 4.5 \cdot 10^{-268}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.06 \cdot 10^{-198}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \end{array} \]
Alternative 4
Accuracy41.1%
Cost1492
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -6.2 \cdot 10^{+20}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.5 \cdot 10^{-93}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -2.35 \cdot 10^{-307}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 1.05 \cdot 10^{-123}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 4.4 \cdot 10^{+38}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 5
Accuracy41.1%
Cost1492
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.2 \cdot 10^{+25}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -2.1 \cdot 10^{-264}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 2.1 \cdot 10^{-238}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 6.8 \cdot 10^{-124}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 4.2 \cdot 10^{+33}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 6
Accuracy65.5%
Cost1488
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := c \cdot i + a \cdot b\\ \mathbf{if}\;c \cdot i \leq -1.7 \cdot 10^{+24}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -3.1 \cdot 10^{-264}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.5 \cdot 10^{-246}:\\ \;\;\;\;z \cdot t + a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 3.5 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Accuracy90.0%
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -6.8 \cdot 10^{+36} \lor \neg \left(c \cdot i \leq 1.22 \cdot 10^{+31}\right):\\ \;\;\;\;z \cdot t + \left(c \cdot i + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(z \cdot t + x \cdot y\right)\\ \end{array} \]
Alternative 8
Accuracy85.6%
Cost1224
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -4.4 \cdot 10^{+98}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 9.2 \cdot 10^{+50}:\\ \;\;\;\;a \cdot b + \left(z \cdot t + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot t + c \cdot i\\ \end{array} \]
Alternative 9
Accuracy65.5%
Cost969
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+24} \lor \neg \left(c \cdot i \leq 3.5 \cdot 10^{-58}\right):\\ \;\;\;\;c \cdot i + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
Alternative 10
Accuracy100.0%
Cost960
\[z \cdot t + \left(x \cdot y + \left(c \cdot i + a \cdot b\right)\right) \]
Alternative 11
Accuracy48.9%
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{-107}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+62}:\\ \;\;\;\;c \cdot i + a \cdot b\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{+185}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 1.06 \cdot 10^{+206}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 12
Accuracy42.0%
Cost712
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+35}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 1.95 \cdot 10^{+32}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 13
Accuracy27.3%
Cost192
\[a \cdot b \]

Error

Reproduce?

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