MathGroup Archive 2000

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

Search the Archive

Re: Simplifying Finite Sums With A Variable # of Terms

Wretch [arc at] 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,

<< Statistics`DataManipulation`
s[q_List] := CumulativeSums[q]
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,

q = {a, b, c, d}
{a, b, c, d}

In[5]:= s[u]
{a, a + b, a + b + c, a + b + c + d}

s[q] - z[q]
{a, b, c, d}

Tomas Garza
Mexico City

  • Prev by Date: Re: Efficient Replacement Rules to Matrix?
  • Next by Date: Re: Could this be improved?
  • Previous by thread: Simplifying Finite Sums With A Variable # of Terms
  • Next by thread: RE: Simplifying Finite Sums With A Variable # of Terms