MathGroup Archive 1998

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

Search the Archive

Re: How to Extract a common factor from a Sum

>I have a symbolical sum like
>expr = Sum[ a f[k], {k,1,N}] and I want to force Mathematica to write
>this as
>expr = a Sum[f[k], {k,1,N}]
>What ever I tried it did not work.
>Does anyone knows a solution?

Add the following definition to Sum:

Sum[a x_,y__]:=a Sum[x,y];

where the double blank __ allows multiple sums to be matched.

Now evaluate your expression

Sum[ a f[k], {k,1,N}]

to obtain the result

a Sum[f[k], {k, 1, N}]

Here is a double summation

Sum[ a  f[k,l], {k,1,N},{l,1,M}]

which yields the output

a Sum[f[k,l],{k,1,N},{l,1,M}]


Stephen P Luttrell
luttrell at
Adaptive Systems Theory                           01684-894046 (phone)
Room EX21, DERA                                    01684-894384 (fax)
Malvern, Worcs, WR14 3PS, U.K.

  • Prev by Date: Re: Piecewise defined functions
  • Next by Date: Re: Inconsistencies in pattern matching.
  • Previous by thread: Re: How to Extract a common factor from a Sum
  • Next by thread: Visual c++ mathematics