Re: alternating sums

• To: mathgroup at christensen.cybernetics.net
• Subject: [mg321] Re: [mg307] alternating sums
• From: Richard Mercer <richard at rmercer.wright.edu>
• Date: Mon, 12 Dec 1994 15:11:48 -0500

```>  Here's an elementary question that has me partially
>  stumped.  I often have occasion to convert  mylist =
>  {a1,a2,a3,...} into an alternating sum, a1-a2+a3-a4+...
>  . I find it aesthetically unsatisfactory to generate a
>  list of alternating plus and minus ones, multiply mylist
>  with the alternating list and then Apply Plus to the
>  product.  It works of course, but I have a feeling there
>  is a much better way to do this.  (This is clearly not
>  of earthshaking importance!!.  I'm just curious.) Jack
>  Goldberg Univ of Mich Mathematics

Jack,

Here's the best I could do off the top of my head. I suspect there's
something simpler still, but...

In[49]:=
mylist = {a1,a2,a3,a4,a5,a6};
Plus @@ Apply[Subtract,Partition[mylist,2],{1}]
Out[50]=
a1 - a2 + a3 - a4 + a5 - a6

Richard Mercer

```

• Prev by Date: Re: Generalized Eigenvector and Singular Value Decompositions
• Next by Date: Re: alternating sums
• Previous by thread: Re: alternating sums
• Next by thread: Re: alternating sums