?

Average Accuracy: 100.0% → 100.0%
Time: 16.3s
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
Accuracy33.3%
Cost1776
\[\begin{array}{l} \mathbf{if}\;b \leq -3.4 \cdot 10^{-119}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;b \leq -3.1 \cdot 10^{-221}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \leq -8 \cdot 10^{-273}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \leq -3.8 \cdot 10^{-296}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \leq 10^{-72}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \leq 3.9 \cdot 10^{-18}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \leq 0.0065:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \leq 9 \cdot 10^{+68}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;b \leq 1.95 \cdot 10^{+122}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \leq 1.4 \cdot 10^{+163}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;b \leq 3.8 \cdot 10^{+171}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \leq 4 \cdot 10^{+192}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 3
Accuracy62.1%
Cost1490
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -6.5 \cdot 10^{+112} \lor \neg \left(c \cdot i \leq 2.95 \cdot 10^{+88}\right) \land \left(c \cdot i \leq 1.72 \cdot 10^{+131} \lor \neg \left(c \cdot i \leq 2.2 \cdot 10^{+150}\right)\right):\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
Alternative 4
Accuracy65.3%
Cost1488
\[\begin{array}{l} t_1 := c \cdot i + x \cdot y\\ t_2 := a \cdot b + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -6.5 \cdot 10^{+55}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 2.4 \cdot 10^{-212}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 2.1 \cdot 10^{-64}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 7.2 \cdot 10^{+18}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Accuracy33.4%
Cost1380
\[\begin{array}{l} \mathbf{if}\;b \leq -4.6 \cdot 10^{-119}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;b \leq -1.6 \cdot 10^{-222}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \leq -5.4 \cdot 10^{-273}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \leq -2.9 \cdot 10^{-296}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \leq 6 \cdot 10^{-73}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \leq 9.2 \cdot 10^{-19}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;b \leq 0.00102:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;b \leq 7 \cdot 10^{+68}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;b \leq 1.6 \cdot 10^{+192}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 6
Accuracy58.9%
Cost1372
\[\begin{array}{l} t_1 := z \cdot t + x \cdot y\\ t_2 := a \cdot b + c \cdot i\\ t_3 := a \cdot b + z \cdot t\\ \mathbf{if}\;z \leq -4 \cdot 10^{+207}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -6 \cdot 10^{+132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{+110}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -4.8 \cdot 10^{-36}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;z \leq -5.3 \cdot 10^{-95}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-221}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{-98}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Accuracy75.3%
Cost1234
\[\begin{array}{l} \mathbf{if}\;x \leq -1.06 \cdot 10^{+249} \lor \neg \left(x \leq -1.02 \cdot 10^{+198}\right) \land \left(x \leq -1.2 \cdot 10^{+124} \lor \neg \left(x \leq 2.65 \cdot 10^{-30}\right)\right):\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(c \cdot i + z \cdot t\right)\\ \end{array} \]
Alternative 8
Accuracy90.7%
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -6.5 \cdot 10^{+55} \lor \neg \left(a \cdot b \leq 820000000000\right):\\ \;\;\;\;a \cdot b + \left(c \cdot i + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + \left(z \cdot t + x \cdot y\right)\\ \end{array} \]
Alternative 9
Accuracy58.5%
Cost1108
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := a \cdot b + c \cdot i\\ \mathbf{if}\;z \leq -1.5 \cdot 10^{+109}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;z \leq -5.3 \cdot 10^{-36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.45 \cdot 10^{-97}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-149}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-90}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Accuracy57.6%
Cost976
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ t_2 := a \cdot b + z \cdot t\\ \mathbf{if}\;z \leq -750000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.45 \cdot 10^{-97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{-148}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-97}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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.9%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -7 \cdot 10^{+49}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 1.1 \cdot 10^{+19}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 13
Accuracy25.7%
Cost192
\[a \cdot b \]

Error

Reproduce?

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