alternating sum
- To: mathgroup at smc.vnet.net
- Subject: [mg6842] alternating sum
- From: murray at math.umass.edu (Murray Eisenberg)
- Date: Tue, 22 Apr 1997 02:33:32 -0400 (EDT)
- Organization: University of Massachusetts, Amherst
- Sender: owner-wri-mathgroup at wolfram.com
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}]
The reason I consider the preceding as non-simple is the appearance of
powers of -1; intrinsically, forming powers of anything and then
multiplying by them should have absolutely nothing whatsoever to do
with forming an alternating sum.
(The sort of simplicity I'm after is that given by the APL and J
languages, where the alternating sum of a list v is merely -/v, just
as the sum of the list is +/v. Of course, the result of -/v there
happens to be the alternating sum because of the non-hierarchical,
left-to-right evaluation of functions in APL and J.)
--
Murray Eisenberg Internet: murray at math.umass.edu
Mathematics & Statistics Dept. Voice: 413-545-2859 (W)
University of Massachusetts 413-549-1020 (H)
Amherst, MA 01003 Fax: 413-545-1801