Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.8K Views
|
8 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Sum and Product a feature request

Wouldn't it be nice to have the following definitions for Sum and Product in order to get the sum resp. the product of a list/vector?

Unprotect[Product];
Product[a_] := Times @@ a
Protect[Product];
Unprotect[Sum];
Sum[a_] := Plus @@ a
Protect[Sum];

\[Sum]{a, b, c, d} == Sum[{a, b, c, d}] == Sum[e, {e, {a, b, c, d}}] ==
  Plus @@ {a, b, c, d} == a + b + c + d
\[Product]{a, b, c, d} == Product[e, {e, {a, b, c, d}}] == 
 Product[{a, b, c, d}] == Times @@ {a, b, c, d} == a*b*c*d


True

True
POSTED BY: Robert Nowak
8 Replies
POSTED BY: Michael Rogers

What about Sum[{{1,2},{3,4}}] ?

POSTED BY: Gianluca Gorni
POSTED BY: Robert Nowak

You are probably using your modified Sum. To me Sum[{{a, b}, {c, d}}] remains unevaluated, with the message "Sum called with 1 argument; 2 or more arguments are expected".

POSTED BY: Gianluca Gorni

....oooouch

you are right I evaluated with my proposed feature. With the feature activated this would be the correct desired behavior of summing up the 1st level elements.

Sum[{{a, b}, {c, d}}]

{a + c, b + d}

POSTED BY: Robert Nowak

The function Total does that too. You would like to incorporate Total into Sum?

POSTED BY: Gianluca Gorni

Total does more than simple summation. With Total you can control at which nesting level the summation happens.

POSTED BY: Robert Nowak
Σ{a,b,c,d}

a + b + c + d

Π{a,b,c,s} 

a * b * c * d

POSTED BY: Robert Nowak
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard