?

Average Error: 0.0 → 0.0
Time: 15.2s
Precision: binary64
Cost: 19776

?

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

    associate-+l+ [=>]0.0

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

    associate-+l+ [=>]0.0

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

    fma-def [=>]0.0

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

    associate-+r+ [=>]0.0

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

    +-commutative [=>]0.0

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

    fma-def [=>]0.0

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

    +-commutative [=>]0.0

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

    fma-def [=>]0.0

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

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

Alternatives

Alternative 1
Error0.0
Cost19776
\[\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right) \]
Alternative 2
Error38.2
Cost2532
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -8.8 \cdot 10^{+46}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -3200000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq -4.6 \cdot 10^{-29}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -5.8 \cdot 10^{-152}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 2.35 \cdot 10^{-247}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 580:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 3.7 \cdot 10^{+36}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 2.35 \cdot 10^{+75}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 3
Error25.2
Cost2268
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1.6 \cdot 10^{+111}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -5.3 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.3 \cdot 10^{-98}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 3.8 \cdot 10^{-224}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 3.3 \cdot 10^{-126}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 7.5 \cdot 10^{-94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 9.2 \cdot 10^{+74}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 4
Error23.1
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 + a \cdot b\\ \mathbf{if}\;c \cdot i \leq -1.4 \cdot 10^{+111}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -4.2 \cdot 10^{-19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -8.5 \cdot 10^{-99}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 3.2 \cdot 10^{-224}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 7.6 \cdot 10^{-126}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 5.5 \cdot 10^{-94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 4.4 \cdot 10^{+38}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Error23.3
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 + a \cdot b\\ \mathbf{if}\;c \cdot i \leq -1.4 \cdot 10^{+111}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -6 \cdot 10^{-67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -1.9 \cdot 10^{-98}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.55 \cdot 10^{-223}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 4.6 \cdot 10^{-126}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 4.1 \cdot 10^{-94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 4.5 \cdot 10^{+38}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Error38.1
Cost2012
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -2.55 \cdot 10^{+33}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -2.2 \cdot 10^{-55}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq -1.02 \cdot 10^{-88}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 8.4 \cdot 10^{-94}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 6.2 \cdot 10^{-25}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 4 \cdot 10^{+20}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 2.95 \cdot 10^{+41}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 7
Error27.1
Cost1504
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := c \cdot i + z \cdot t\\ t_3 := c \cdot i + a \cdot b\\ \mathbf{if}\;a \leq -2 \cdot 10^{+204}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -1.05 \cdot 10^{+113}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;a \leq -7.5 \cdot 10^{+32}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -2.65 \cdot 10^{-45}:\\ \;\;\;\;x \cdot y + z \cdot t\\ \mathbf{elif}\;a \leq -4.2 \cdot 10^{-81}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1.8 \cdot 10^{-204}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 4 \cdot 10^{-264}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;a \leq 1.12 \cdot 10^{-148}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error25.7
Cost1488
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -2.05 \cdot 10^{+58}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -9.6 \cdot 10^{-229}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -2.75 \cdot 10^{-289}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 8.5 \cdot 10^{+74}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 9
Error8.9
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -4.6 \cdot 10^{+124} \lor \neg \left(c \cdot i \leq 1.6 \cdot 10^{+74}\right):\\ \;\;\;\;c \cdot i + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \end{array} \]
Alternative 10
Error8.9
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+124} \lor \neg \left(c \cdot i \leq 6.8 \cdot 10^{+73}\right):\\ \;\;\;\;c \cdot i + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + \left(a \cdot b + z \cdot t\right)\\ \end{array} \]
Alternative 11
Error7.4
Cost1225
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1.4 \cdot 10^{+111} \lor \neg \left(c \cdot i \leq 5 \cdot 10^{-34}\right):\\ \;\;\;\;c \cdot i + t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + t_1\\ \end{array} \]
Alternative 12
Error6.4
Cost1225
\[\begin{array}{l} \mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+97} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{+30}\right):\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + x \cdot y\right)\\ \end{array} \]
Alternative 13
Error0.0
Cost960
\[\left(\left(c \cdot i + a \cdot b\right) + z \cdot t\right) + x \cdot y \]
Alternative 14
Error38.1
Cost712
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -7.4 \cdot 10^{+40}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 1.26 \cdot 10^{+14}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 15
Error47.6
Cost192
\[a \cdot b \]

Error

Reproduce?

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