Re: How to Extract a common factor from a Sum

*To*: mathgroup at smc.vnet.net*Subject*: [mg12952] Re: How to Extract a common factor from a Sum*From*: "Stephen P Luttrell" <luttrell at signal.dra.hmg.gb>*Date*: Sun, 28 Jun 1998 02:51:44 -0400*Organization*: Defence Evaluation and Research Agency*References*: <6mq9k4$2pi@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

>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: Unprotect[Sum]; Sum[a x_,y__]:=a Sum[x,y]; Protect[Sum]; 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 signal.dera.gov.uk Adaptive Systems Theory 01684-894046 (phone) Room EX21, DERA 01684-894384 (fax) Malvern, Worcs, WR14 3PS, U.K. http://www.dera.gov.uk/cis5pip/Welcome.html