?

Average Accuracy: 100.0% → 100.0%
Time: 18.8s
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
Accuracy100.0%
Cost7232
\[\mathsf{fma}\left(x, y, z \cdot t\right) + \left(a \cdot b + c \cdot i\right) \]
Alternative 2
Accuracy100.0%
Cost7232
\[\mathsf{fma}\left(z, t, x \cdot y\right) + \left(a \cdot b + c \cdot i\right) \]
Alternative 3
Accuracy64.7%
Cost3568
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ t_2 := x \cdot y + c \cdot i\\ t_3 := x \cdot y + a \cdot b\\ t_4 := c \cdot i + z \cdot t\\ t_5 := a \cdot b + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -3.5 \cdot 10^{+124}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -6.1 \cdot 10^{+39}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq -5500000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -1.4 \cdot 10^{-78}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq -4.7 \cdot 10^{-85}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;a \cdot b \leq 7 \cdot 10^{-267}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 2.6 \cdot 10^{-78}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq 6.2 \cdot 10^{-29}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 5.6 \cdot 10^{+31}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;a \cdot b \leq 6.3 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 3.9 \cdot 10^{+79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 4.2 \cdot 10^{+132}:\\ \;\;\;\;t_5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy63.9%
Cost3308
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ t_2 := c \cdot i + z \cdot t\\ t_3 := x \cdot y + c \cdot i\\ t_4 := a \cdot b + c \cdot i\\ \mathbf{if}\;a \cdot b \leq -3.5 \cdot 10^{+124}:\\ \;\;\;\;x \cdot y + a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -5.8 \cdot 10^{+39}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -0.00145:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq -7 \cdot 10^{-95}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -5.4 \cdot 10^{-149}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 5.5 \cdot 10^{-285}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-152}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 8 \cdot 10^{-73}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 1.75 \cdot 10^{-28}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 3.2 \cdot 10^{+54}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 3.2 \cdot 10^{+129}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 5
Accuracy57.3%
Cost2008
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1920:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -3 \cdot 10^{-212}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.45 \cdot 10^{-269}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 6 \cdot 10^{-195}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.55 \cdot 10^{-150}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 2600000000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 6
Accuracy60.1%
Cost2008
\[\begin{array}{l} t_1 := x \cdot y + a \cdot b\\ t_2 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1450000000:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -8.7 \cdot 10^{-271}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 2.7 \cdot 10^{-307}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 7.2 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.6 \cdot 10^{-38}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.5 \cdot 10^{+175}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 7
Accuracy40.8%
Cost1752
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1400000000:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.5 \cdot 10^{-282}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{-315}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.6 \cdot 10^{-257}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 2.5 \cdot 10^{-147}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 3.6 \cdot 10^{-58}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 8
Accuracy65.4%
Cost1748
\[\begin{array}{l} t_1 := x \cdot y + a \cdot b\\ t_2 := a \cdot b + z \cdot t\\ t_3 := a \cdot b + c \cdot i\\ \mathbf{if}\;c \cdot i \leq -8200000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -1.86 \cdot 10^{-268}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.7 \cdot 10^{-308}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 3.9 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 7.5 \cdot 10^{-36}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 9
Accuracy56.8%
Cost1505
\[\begin{array}{l} t_1 := x \cdot y + a \cdot b\\ t_2 := c \cdot i + z \cdot t\\ \mathbf{if}\;t \leq -9 \cdot 10^{-84}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1 \cdot 10^{-205}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -5 \cdot 10^{-231}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.3 \cdot 10^{-283}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1550:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;t \leq 7 \cdot 10^{+51} \lor \neg \left(t \leq 1.32 \cdot 10^{+90}\right) \land t \leq 4.8 \cdot 10^{+169}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 10
Accuracy90.1%
Cost1225
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -82000000 \lor \neg \left(c \cdot i \leq 1.25 \cdot 10^{-23}\right):\\ \;\;\;\;c \cdot i + t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + t_1\\ \end{array} \]
Alternative 11
Accuracy90.0%
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1300000 \lor \neg \left(c \cdot i \leq 5 \cdot 10^{-37}\right):\\ \;\;\;\;c \cdot i + \left(x \cdot y + a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \end{array} \]
Alternative 12
Accuracy84.4%
Cost1224
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1550000000:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 12800000000:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + c \cdot i\\ \end{array} \]
Alternative 13
Accuracy90.6%
Cost1224
\[\begin{array}{l} t_1 := x \cdot y + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -320000:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \mathbf{elif}\;c \cdot i \leq 1.15 \cdot 10^{-23}:\\ \;\;\;\;a \cdot b + t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + t_1\\ \end{array} \]
Alternative 14
Accuracy40.9%
Cost972
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -50:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{-315}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 3.6 \cdot 10^{-58}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 15
Accuracy100.0%
Cost960
\[c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) \]
Alternative 16
Accuracy40.9%
Cost712
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -34000:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 3.6 \cdot 10^{-58}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 17
Accuracy26.6%
Cost192
\[a \cdot b \]

Error

Reproduce?

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