Question: How to shift the index in a sum

For example from

sum(a[k]*(k+r)*(k+r-1)*x^(k+r-1), k = 0 .. infinity)

sum(a[k]*(k+r)*(k+r-1)*x^(k+r-1), k = 0 .. infinity)

(1)

by substituting k by k+1 to

sum(a[k+1]*(k+1+r)*(k+r)*x^(k+r), k = -1 .. infinity)

sum(a[k+1]*(k+1+r)*(k+r)*x^(k+r), k = -1 .. infinity)

(2)

Doing

subs(k = k+1, sum(a[k]*(k+r)*(k+r-1)*x^(k+r-1), k = 0 .. infinity))

sum(a[k+1]*(k+1+r)*(k+r)*x^(k+r), k+1 = 0 .. infinity)

(3)

leads to output that can't be processed further  

subsop(2 = 'k = -1 .. infinity', sum(a[k+1]*(k+1+r)*(k+r)*x^(k+r), k+1 = 0 .. infinity))

Error, (in sum) second argument must be a name, name=a..b, name=RootOf, or name=algebraic

 

NULL

Doing it programmatically this way

shift := k = k+1; rsd := (lhs-rhs)(shift); subs(shift, [op(sum(a[k]*(k+r)*(k+r-1)*x^(k+r-1), k = 0 .. infinity))]); lhs(%[2])+rsd = map(`+`, rhs(%[2]), rsd); sum(subsop(2 = %, `%%`)[])

sum(a[k+1]*(k+1+r)*(k+r)*x^(k+r), k = -1 .. infinity)

(4)

is not realy elegant and easy to understand.

Download shifting_index_in_sums.mw

Are there better ways?

Please Wait...