?

Average Error: 0.04% → 0.03%
Time: 15.8s
Precision: binary64
Cost: 13504

?

\[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
\[\mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, a \cdot b\right)\right) + c \cdot i \]
(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 y x (fma 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 (((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(y, x, fma(z, t, (a * b))) + (c * i);
}
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 Float64(fma(y, x, fma(z, t, Float64(a * b))) + Float64(c * i))
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[(N[(y * x + N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, a \cdot b\right)\right) + c \cdot i

Error?

Derivation?

  1. Initial program 0.04

    \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
  2. Applied egg-rr0.03

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

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

Alternatives

Alternative 1
Error0.04%
Cost7232
\[c \cdot i + \left(\mathsf{fma}\left(z, t, a \cdot b\right) + y \cdot x\right) \]
Alternative 2
Error34.42%
Cost3309
\[\begin{array}{l} t_1 := a \cdot b + y \cdot x\\ t_2 := a \cdot b + z \cdot t\\ t_3 := c \cdot i + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1.1 \cdot 10^{+51}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -5.2 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.45 \cdot 10^{-43}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -1.4 \cdot 10^{-67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -4.2 \cdot 10^{-71}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -4 \cdot 10^{-297}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 3.3 \cdot 10^{-259}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{-167}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.7 \cdot 10^{+59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 6.1 \cdot 10^{+131} \lor \neg \left(c \cdot i \leq 1.55 \cdot 10^{+204}\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + y \cdot x\\ \end{array} \]
Alternative 3
Error33.46%
Cost2789
\[\begin{array}{l} t_1 := a \cdot b + y \cdot x\\ t_2 := c \cdot i + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1.45 \cdot 10^{+50}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -1.56 \cdot 10^{+27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -11:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -2.6 \cdot 10^{-303}:\\ \;\;\;\;y \cdot x + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 4.1 \cdot 10^{-259}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 9.2 \cdot 10^{-167}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.1 \cdot 10^{+56}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.45 \cdot 10^{+156} \lor \neg \left(c \cdot i \leq 2.3 \cdot 10^{+204}\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + y \cdot x\\ \end{array} \]
Alternative 4
Error34.68%
Cost2788
\[\begin{array}{l} t_1 := a \cdot b + y \cdot x\\ t_2 := a \cdot b + z \cdot t\\ t_3 := c \cdot i + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -4.1 \cdot 10^{+49}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -7.6 \cdot 10^{+26}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -8.5 \cdot 10^{-45}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -1.02 \cdot 10^{-67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -4.2 \cdot 10^{-71}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -2.8 \cdot 10^{-298}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.55 \cdot 10^{-258}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.1 \cdot 10^{-166}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+53}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]
Alternative 5
Error33.74%
Cost1748
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + y \cdot x\\ t_3 := a \cdot b + c \cdot i\\ \mathbf{if}\;c \cdot i \leq -2.8 \cdot 10^{+31}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -4.8 \cdot 10^{-298}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 8.8 \cdot 10^{-259}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.85 \cdot 10^{-167}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 7 \cdot 10^{+53}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Error9.38%
Cost1745
\[\begin{array}{l} t_1 := y \cdot x + z \cdot t\\ t_2 := c \cdot i + t_1\\ \mathbf{if}\;c \cdot i \leq -1.3 \cdot 10^{+51}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 2.5 \cdot 10^{+58}:\\ \;\;\;\;a \cdot b + t_1\\ \mathbf{elif}\;c \cdot i \leq 2.4 \cdot 10^{+151} \lor \neg \left(c \cdot i \leq 2.7 \cdot 10^{+204}\right):\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error58.84%
Cost1492
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -2.15 \cdot 10^{+24}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -2.9 \cdot 10^{-300}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.8 \cdot 10^{-248}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 5.2 \cdot 10^{-183}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 3.8 \cdot 10^{+133}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 8
Error58.29%
Cost1492
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -3.75 \cdot 10^{+24}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -8.2 \cdot 10^{-306}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.3 \cdot 10^{-258}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;c \cdot i \leq 1.3 \cdot 10^{-168}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 7.5 \cdot 10^{+56}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 9
Error13.82%
Cost1489
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -8.5 \cdot 10^{+48}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.55 \cdot 10^{+60}:\\ \;\;\;\;a \cdot b + \left(y \cdot x + z \cdot t\right)\\ \mathbf{elif}\;c \cdot i \leq 4.6 \cdot 10^{+126} \lor \neg \left(c \cdot i \leq 4 \cdot 10^{+203}\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + y \cdot x\\ \end{array} \]
Alternative 10
Error35.16%
Cost1488
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + c \cdot i\\ \mathbf{if}\;c \cdot i \leq -2.8 \cdot 10^{+29}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 9.5 \cdot 10^{-288}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 3.2 \cdot 10^{-259}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;c \cdot i \leq 7.6 \cdot 10^{+51}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error53.33%
Cost1374
\[\begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{-37}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -4.1 \cdot 10^{-212}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+47} \lor \neg \left(y \leq 1.65 \cdot 10^{+115}\right) \land \left(y \leq 4.2 \cdot 10^{+161} \lor \neg \left(y \leq 2.4 \cdot 10^{+186}\right) \land y \leq 2.05 \cdot 10^{+200}\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 12
Error9.81%
Cost1225
\[\begin{array}{l} \mathbf{if}\;y \cdot x \leq -1 \cdot 10^{+66} \lor \neg \left(y \cdot x \leq 5 \cdot 10^{+64}\right):\\ \;\;\;\;a \cdot b + \left(y \cdot x + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \end{array} \]
Alternative 13
Error0.04%
Cost960
\[y \cdot x + \left(\left(a \cdot b + c \cdot i\right) + z \cdot t\right) \]
Alternative 14
Error58.8%
Cost712
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -2.2 \cdot 10^{+33}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 4.8 \cdot 10^{+125}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 15
Error73.36%
Cost192
\[a \cdot b \]

Error

Reproduce?

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