MathGroup Archive 1994

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: alternating sums

  • To: mathgroup at
  • Subject: [mg321] Re: [mg307] alternating sums
  • From: Richard Mercer <richard at>
  • 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


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

mylist = {a1,a2,a3,a4,a5,a6};
Plus @@ Apply[Subtract,Partition[mylist,2],{1}]
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