Re: alternating sums

• To: mathgroup at christensen.Cybernetics.NET
• Subject: [mg334] Re: [mg307] alternating sums
• From: Ross Moore <ross at zeus.mpce.mq.edu.au>
• Date: Fri, 16 Dec 94 15:37:48 +1100

```
Lots of people have responded to this one ...

>>  stumped.  I often have occasion to convert  mylist =
>>  {a1,a2,a3,...} into an alternating sum, a1-a2+a3-a4+...

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

... so my contribution is illustrative of a more general technique:

mylist = {a1,a2,a3,a4,a5,a6};
sgn=-1; Plus@@((sgn *=-1;sgn #)&/@ mylist )

(zeus) Out[17]=
a1 - a2 + a3 - a4 + a5 - a6

Regards,
Ross Moore
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ross Moore                       Internet: ross at mpce.mq.edu.au
Mathematics Department              Work:       +61 2 850-8955
Macquarie University                Home:   please do not try
North Ryde, Sydney                   Fax:       +61 2 850-8114
Australia  2109
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

```

• Prev by Date: Combining pure functions
• Next by Date: Re: Web pages
• Previous by thread: Alternating sums
• Next by thread: Re: alternating sums