?

Average Error: 0.0 → 0.0
Time: 11.3s
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 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(c, i, \mathsf{fma}\left(a, b, \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}{c \cdot i + \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} \]

    fma-def [=>]0.0

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

    +-commutative [=>]0.0

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

    fma-def [=>]0.0

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

    fma-def [=>]0.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 simplification0.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
Error0.0
Cost7232
\[\mathsf{fma}\left(x, y, z \cdot t\right) + \left(a \cdot b + c \cdot i\right) \]
Alternative 2
Error22.2
Cost3568
\[\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 := x \cdot y + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1.02 \cdot 10^{+79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -6.2 \cdot 10^{+21}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -1.7 \cdot 10^{-16}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -9.6 \cdot 10^{-162}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -6 \cdot 10^{-191}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \cdot i \leq -1.52 \cdot 10^{-253}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-312}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 4 \cdot 10^{-167}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \cdot i \leq 3.6 \cdot 10^{-138}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 3.2 \cdot 10^{-24}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \cdot i \leq 2.4 \cdot 10^{+15}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 1.45 \cdot 10^{+64}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error23.7
Cost2269
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := c \cdot i + x \cdot y\\ \mathbf{if}\;c \cdot i \leq -2.8 \cdot 10^{+80}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -4.9 \cdot 10^{+14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -8.2 \cdot 10^{-25}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -1.05 \cdot 10^{-170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 3.1 \cdot 10^{-124}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 3.4 \cdot 10^{-13} \lor \neg \left(c \cdot i \leq 6.7 \cdot 10^{+21}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error38.8
Cost2012
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -6.2 \cdot 10^{+161}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -7.2 \cdot 10^{+18}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -9.5 \cdot 10^{-36}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -4.2 \cdot 10^{-46}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 1.45 \cdot 10^{-167}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 6.6 \cdot 10^{-138}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 1.8 \cdot 10^{+64}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 5
Error23.8
Cost1748
\[\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 -6.2 \cdot 10^{+161}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -7.2 \cdot 10^{-171}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -3.6 \cdot 10^{-202}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 6 \cdot 10^{+21}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.8 \cdot 10^{+64}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error43.1
Cost1512
\[\begin{array}{l} \mathbf{if}\;c \leq -6.2 \cdot 10^{+250}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \leq -1.25 \cdot 10^{+240}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \leq -8.1 \cdot 10^{+198}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \leq -6.4 \cdot 10^{+161}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq -3 \cdot 10^{+60}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \leq -2.1 \cdot 10^{-62}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \leq -5.6 \cdot 10^{-153}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq -2.1 \cdot 10^{-226}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \leq 8.2 \cdot 10^{-258}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-44}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 7
Error33.6
Cost1504
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;i \leq -2 \cdot 10^{-204}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq -1.06 \cdot 10^{-277}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;i \leq 6.8 \cdot 10^{-226}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;i \leq 3.8 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq 9.5 \cdot 10^{-108}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;i \leq 9.6 \cdot 10^{-108}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;i \leq 10^{-69}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;i \leq 1.55 \cdot 10^{-12}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error27.1
Cost1372
\[\begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := a \cdot b + c \cdot i\\ t_3 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \leq -8 \cdot 10^{+198}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -4.8 \cdot 10^{+161}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -8.5 \cdot 10^{+60}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -1.85 \cdot 10^{-56}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -5.5 \cdot 10^{-153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.1 \cdot 10^{-196}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 2.15 \cdot 10^{-44}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error39.2
Cost1234
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.3 \cdot 10^{-34} \lor \neg \left(c \cdot i \leq 3.1 \cdot 10^{-124}\right) \land \left(c \cdot i \leq 2.3 \cdot 10^{-20} \lor \neg \left(c \cdot i \leq 9 \cdot 10^{+62}\right)\right):\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
Alternative 10
Error9.2
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -6.2 \cdot 10^{+161} \lor \neg \left(c \cdot i \leq 7.2 \cdot 10^{+105}\right):\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \end{array} \]
Alternative 11
Error0.0
Cost960
\[c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) \]
Alternative 12
Error47.0
Cost192
\[a \cdot b \]

Error

Reproduce?

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