Re: Simplifying Finite Sums With A Variable # of Terms
- To: mathgroup at smc.vnet.net
- Subject: [mg21771] Re: [mg21744] Simplifying Finite Sums With A Variable # of Terms
- From: "Tomas Garza" <tgarza at mail.internet.com.mx>
- Date: Thu, 27 Jan 2000 22:56:52 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Wretch [arc at astro.columbia.edu] wrote: > Hello. I'm a user of Mathematica 3.0. A simple example of > what I'd like to do is as follows: > > Suppose you have the finite series > > S[i_]=Sum[x[k],{k,1,i}] > > which is equal to x[1]+x[2]+...+x[i], where the total # of > terms i is left variable. > > I'd like mathematica to calculate the difference > > S[N]-S[N-1] = x[N]-x[0] . > > I've tried commands like > > Expand[S[N]-S[N-1]] and Simplify[S[N]-S[N-1]] , > > but mathematica doesn't simplify it as you would expect. > It basically does nothing. I suspect that it needs some > sort of clarification as to the nature of N (i.e. it's a > positive integer), but I'm not sure. Is there an easy > way for me to do what I'd like? To start with, there is no way to incorporate x[0] into your results, since it is not included in the definition of S (the iterator therein is {k,1,i}). Then, using e.g. CumulativeSums in the Statistics`DataManipulation` AddOn to define the sums, In[1]:= << Statistics`DataManipulation` In[2]:= s[q_List] := CumulativeSums[q] In[3]:= z[q_List] := Prepend[Drop[s[q], -1], 0] so that, for any list q, the difference s[q] - z[q] will give the list {S[1], S[2] - S[1],S[3] - S[2],..., S[k] - S[k-1]} = q. Take, for example, In[4]:= q = {a, b, c, d} Out[4] {a, b, c, d} In[5]:= s[u] Out[5]= {a, a + b, a + b + c, a + b + c + d} In[6]:= s[q] - z[q] Out[6]= {a, b, c, d} Tomas Garza Mexico City