?

Average Error: 0.0 → 0.0
Time: 14.4s
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 0.0

    \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
  2. Simplified0.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]0.0

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

    +-commutative [=>]0.0

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

    associate-+l+ [=>]0.0

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

    fma-def [=>]0.0

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

    +-commutative [=>]0.0

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

    fma-def [=>]0.0

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

    fma-def [=>]0.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 simplification0.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
Error23.1
Cost3048
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := c \cdot i + x \cdot y\\ t_3 := a \cdot b + z \cdot t\\ t_4 := c \cdot i + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -3.3 \cdot 10^{-61}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -1.5 \cdot 10^{-182}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -3.7 \cdot 10^{-231}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq -2.05 \cdot 10^{-247}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-320}:\\ \;\;\;\;x \cdot y + z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.42 \cdot 10^{-70}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq 13.6:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.42 \cdot 10^{+71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 1.7 \cdot 10^{+78}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+92}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error39.8
Cost2792
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -9.5 \cdot 10^{+154}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -4 \cdot 10^{-60}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -6.8 \cdot 10^{-125}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq -3.8 \cdot 10^{-178}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq -3.5 \cdot 10^{-255}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-320}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 3.3 \cdot 10^{-121}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.1 \cdot 10^{-55}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 32:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 2.4 \cdot 10^{+140}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 3
Error23.0
Cost2268
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := a \cdot b + z \cdot t\\ t_3 := c \cdot i + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -4.1 \cdot 10^{-57}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -6.5 \cdot 10^{-183}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-71}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 8:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.42 \cdot 10^{+71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 4.5 \cdot 10^{+77}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 6.2 \cdot 10^{+92}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error38.9
Cost2012
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -9.5 \cdot 10^{+154}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-62}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -9 \cdot 10^{-254}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-320}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 3.5 \cdot 10^{-119}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.2 \cdot 10^{-55}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 15.6:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 5
Error25.0
Cost2009
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1.9 \cdot 10^{+66}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 4.4 \cdot 10^{-98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.6 \cdot 10^{-76}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.7 \cdot 10^{-26} \lor \neg \left(c \cdot i \leq 2.1 \cdot 10^{-15}\right) \land c \cdot i \leq 5.6 \cdot 10^{+90}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 6
Error8.8
Cost1745
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -3.15 \cdot 10^{+100}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 1.7 \cdot 10^{-26} \lor \neg \left(c \cdot i \leq 1.3 \cdot 10^{-17}\right) \land c \cdot i \leq 3.1 \cdot 10^{+90}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \end{array} \]
Alternative 7
Error26.1
Cost1372
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + c \cdot i\\ t_3 := a \cdot b + x \cdot y\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{+96}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -7 \cdot 10^{+50}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.75 \cdot 10^{+24}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{-227}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-294}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-186}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 8.4 \cdot 10^{-50}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 8
Error26.2
Cost1372
\[\begin{array}{l} t_1 := c \cdot i + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ t_3 := a \cdot b + z \cdot t\\ \mathbf{if}\;x \leq -2.9 \cdot 10^{+95}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-52}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-126}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{-224}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-296}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-186}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-50}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error27.0
Cost1240
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ \mathbf{if}\;x \leq -3.45 \cdot 10^{+44}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -7.5 \cdot 10^{-183}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.1 \cdot 10^{-224}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;x \leq 1.08 \cdot 10^{-212}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-190}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;x \leq 6.6 \cdot 10^{-50}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 10
Error11.5
Cost1234
\[\begin{array}{l} \mathbf{if}\;x \leq -7.2 \cdot 10^{+95} \lor \neg \left(x \leq -7.2 \cdot 10^{+50}\right) \land \left(x \leq -7.6 \cdot 10^{+25} \lor \neg \left(x \leq 5.2 \cdot 10^{-184}\right)\right):\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \end{array} \]
Alternative 11
Error6.7
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -35000000000 \lor \neg \left(c \cdot i \leq 1.25 \cdot 10^{-67}\right):\\ \;\;\;\;c \cdot i + \left(a \cdot b + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \end{array} \]
Alternative 12
Error0.0
Cost960
\[c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) \]
Alternative 13
Error38.2
Cost712
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.5 \cdot 10^{-56}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 22:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 14
Error47.3
Cost192
\[a \cdot b \]

Error

Reproduce?

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