?

Average Accuracy: 100.0% → 100.0%
Time: 14.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(a, b, \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 c i (fma a b (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(c, i, fma(a, b, 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(c, i, fma(a, b, 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[(c * i + N[(a * b + 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(c, i, \mathsf{fma}\left(a, b, \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(c, i, \mathsf{fma}\left(a, b, \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}{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)} \]

    +-commutative [=>]100.0

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

    fma-def [=>]100.0

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

    fma-def [=>]100.0

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

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

Alternatives

Alternative 1
Accuracy57.2%
Cost2296
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := a \cdot b + z \cdot t\\ t_3 := c \cdot i + x \cdot y\\ t_4 := a \cdot b + x \cdot y\\ t_5 := a \cdot b + c \cdot i\\ \mathbf{if}\;y \leq -5.5 \cdot 10^{-123}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;y \leq -3 \cdot 10^{-159}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -4.8 \cdot 10^{-227}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;y \leq -5.2 \cdot 10^{-300}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{-224}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{-40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 98000:\\ \;\;\;\;t_4\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{+130}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{+179}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+198}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+202}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{+204}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{+221}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 2
Accuracy62.7%
Cost2268
\[\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}\;c \cdot i \leq -9 \cdot 10^{+126}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -260:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -2.5 \cdot 10^{-39}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-317}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 6 \cdot 10^{-309}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{-257}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.05 \cdot 10^{-66}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Accuracy58.3%
Cost2033
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ t_2 := c \cdot i + z \cdot t\\ t_3 := z \cdot t + x \cdot y\\ t_4 := c \cdot i + x \cdot y\\ \mathbf{if}\;y \leq -3.5 \cdot 10^{-156}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -2.55 \cdot 10^{-300}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-281}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;y \leq 10^{-266}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{-246}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-223}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-218}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-36}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 36000:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+48}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.12 \cdot 10^{+162} \lor \neg \left(y \leq 7 \cdot 10^{+199}\right):\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 4
Accuracy42.3%
Cost2012
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -6 \cdot 10^{+33}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -7.4 \cdot 10^{-45}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-121}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-315}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 8.5 \cdot 10^{-172}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.85 \cdot 10^{-44}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 4.4 \cdot 10^{+61}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 5
Accuracy65.0%
Cost1748
\[\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.45 \cdot 10^{+28}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-317}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 5.2 \cdot 10^{-308}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 5.4 \cdot 10^{-257}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.15 \cdot 10^{-54}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Accuracy56.5%
Cost1637
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ t_2 := a \cdot b + z \cdot t\\ \mathbf{if}\;t \leq -9.8 \cdot 10^{-123}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.3 \cdot 10^{-195}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{-148}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 1.35 \cdot 10^{+38}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.25 \cdot 10^{+63}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 9 \cdot 10^{+108}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6.5 \cdot 10^{+135}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 2.8 \cdot 10^{+146} \lor \neg \left(t \leq 1.7 \cdot 10^{+171}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Accuracy33.5%
Cost1380
\[\begin{array}{l} \mathbf{if}\;t \leq -9.5 \cdot 10^{-123}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;t \leq 3.55 \cdot 10^{-196}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;t \leq 9.2 \cdot 10^{-148}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 1.784 \cdot 10^{-124}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;t \leq 3.2 \cdot 10^{-32}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;t \leq 3 \cdot 10^{+49}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 8 \cdot 10^{+108}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;t \leq 1.55 \cdot 10^{+164}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{+171}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 8
Accuracy47.7%
Cost1240
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;t \leq -9 \cdot 10^{-123}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;t \leq 1.22 \cdot 10^{-195}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.8 \cdot 10^{-148}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 6 \cdot 10^{+105}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6.5 \cdot 10^{+136}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 4 \cdot 10^{+175}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 9
Accuracy84.4%
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -3.9 \cdot 10^{+128} \lor \neg \left(c \cdot i \leq 7.2 \cdot 10^{-8}\right):\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(z \cdot t + x \cdot y\right)\\ \end{array} \]
Alternative 10
Accuracy89.9%
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -2.55 \cdot 10^{+39} \lor \neg \left(c \cdot i \leq 5 \cdot 10^{-66}\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 11
Accuracy100.0%
Cost960
\[c \cdot i + \left(a \cdot b + \left(z \cdot t + x \cdot y\right)\right) \]
Alternative 12
Accuracy41.1%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -2.15 \cdot 10^{-32}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 6.2 \cdot 10^{+58}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 13
Accuracy26.9%
Cost192
\[a \cdot b \]

Error

Reproduce?

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