Re: alternating sum
- To: mathgroup at smc.vnet.net
- Subject: [mg6871] Re: [mg6842] alternating sum
- From: jpk at max.mpae.gwdg.de
- Date: Fri, 25 Apr 1997 02:31:39 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
> From murray at math.umass.edu Tue Apr 22 11:47:15 1997
> Date: Tue, 22 Apr 1997 02:33:32 -0400 (EDT)
> From: murray at math.umass.edu (Murray Eisenberg)
> To: mathgroup at smc.vnet.net
> Subject: [mg6842] alternating sum
>
> Is there some simple way to form the alternating sum
>
> v[[1]] - v[[2]] + v[[3]] - v[[4]] + ... + (-1)^(n+1) v[[n]]
>
> of entries in a list v? When I say "simple", I mean simpler -- I hope
> MUCH simpler -- than:
>
> Sum[(-1)^(j+1) v[[j]], {j, 1, n}]
Hi Murray
say Your list v is even and
Plus @@(#1-#2 & @@ Transpose[Partition[v,2]])
will do the job. Is this that what You mean with simpler?
Hope that helps
Jens