?

Average Error: 0.0 → 0.0
Time: 12.8s
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
Error22.8
Cost2788
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := x \cdot y + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -2.7 \cdot 10^{+111}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -3.8 \cdot 10^{+85}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq -1.7 \cdot 10^{+37}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq -2.6 \cdot 10^{-131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 6.5 \cdot 10^{-145}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 3.4 \cdot 10^{-69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.35 \cdot 10^{-16}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 5.5 \cdot 10^{+35}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 1.55 \cdot 10^{+63}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \end{array} \]
Alternative 2
Error38.2
Cost1752
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -3.6 \cdot 10^{+111}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -3.5 \cdot 10^{-76}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 2.3 \cdot 10^{-261}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 3.8 \cdot 10^{-169}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 10^{-70}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 3.9 \cdot 10^{+77}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 3
Error23.0
Cost1748
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ t_3 := a \cdot b + c \cdot i\\ \mathbf{if}\;c \cdot i \leq -5.2 \cdot 10^{+168}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \cdot i \leq 2.25 \cdot 10^{-259}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 4 \cdot 10^{-149}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.2 \cdot 10^{-76}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.3 \cdot 10^{+73}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error22.4
Cost1748
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ \mathbf{if}\;c \cdot i \leq -2.5 \cdot 10^{+111}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 2.7 \cdot 10^{-260}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 3.2 \cdot 10^{-148}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 6.5 \cdot 10^{-71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 3.3 \cdot 10^{+75}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]
Alternative 5
Error22.0
Cost1748
\[\begin{array}{l} t_1 := a \cdot b + z \cdot t\\ t_2 := a \cdot b + x \cdot y\\ \mathbf{if}\;c \cdot i \leq -2.5 \cdot 10^{+111}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 2.1 \cdot 10^{-260}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.3 \cdot 10^{-147}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 1.6 \cdot 10^{-75}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 5.4 \cdot 10^{+47}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \end{array} \]
Alternative 6
Error38.0
Cost1492
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -3.1 \cdot 10^{+111}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -9.5 \cdot 10^{-80}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 8.8 \cdot 10^{-33}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 2.2 \cdot 10^{+33}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 4.2 \cdot 10^{+72}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 7
Error23.7
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 -5.2 \cdot 10^{+168}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 4.3 \cdot 10^{-259}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 8.6 \cdot 10^{-197}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 3.8 \cdot 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error35.1
Cost1240
\[\begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;z \leq -2.26 \cdot 10^{+80}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{+57}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq -2 \cdot 10^{+54}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-223}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -5.5 \cdot 10^{-241}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-222}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.35 \cdot 10^{-59}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 9
Error6.6
Cost1225
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.02 \cdot 10^{+113} \lor \neg \left(c \cdot i \leq 10^{+62}\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 10
Error8.9
Cost1224
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.55 \cdot 10^{+166}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.1 \cdot 10^{+64}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \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
Error37.6
Cost712
\[\begin{array}{l} \mathbf{if}\;c \cdot i \leq -2.5 \cdot 10^{+111}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 9 \cdot 10^{+73}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
Alternative 13
Error46.8
Cost192
\[a \cdot b \]

Error

Reproduce?

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