Re: Sum of Products
- To: mathgroup at smc.vnet.net
- Subject: [mg126679] Re: Sum of Products
- From: Ray Koopman <koopman at sfu.ca>
- Date: Wed, 30 May 2012 05:25:51 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jq266k$6jv$1@smc.vnet.net>
On May 29, 2:51 am, "Harvey P. Dale" <h... at nyu.edu> wrote:
> If I have a list and want to sum the products of each possible
> grouping of two elements in the list, this program will do that:
>
> Total[Times @@@ Subsets[{a, b, c}, {2}]]
>
> Is there any other, shorter, built-in Mathematica object that will
> produce the same result?
>
> Thanks.
>
> Harvey
T = Transpose (* shorter ;) *);
x = {a,b,c,d,e};
SameQ[
Total[Times @@@ Subsets[x,{2}]],
Dot @@ T @ Subsets[x,{2}],
(Tr@x^2 - x.x)/2
//Expand]
True