       Re: How to Extract a common factor from a Sum

• To: mathgroup at smc.vnet.net
• Subject: [mg12950] 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:43 -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.

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