0
$\begingroup$

I have an expression that is a product of two symbolic sums.

Sum[a[k], {k, 1, n}]*Sum[b[k], {k, 1, n}]

How can I expand this expression? I want to see something like this:

Sum[Sum[a[k1]*b[k2], {k2, 1, n}], {k1, 1, n}]

If the running indices weren't the same, I would try to fashion a transformation rule to match the situation above. But here, I'd have to create a new symbol, so I am unsure where to even start.

$\endgroup$
1
  • $\begingroup$ "I'd have to create a new symbol" - this is where the built-in dummy variable K comes in handy; you can just systematically replace indices with K[1], K[2], etc. $\endgroup$ Jan 4, 2021 at 14:21

1 Answer 1

3
$\begingroup$

Note, a double sum can be written with a single Sum. With this we make a replacement:

   Sum[a[k], {k, 1, n}]*Sum[b[k], {k, 1, n}] /. 
     Sum[a1_, {a2_, 1, n}] Sum[b1_, {b2_, 1, n}] :> 
      Sum[(a1 /. a2 -> k1) (b1 /. b2 -> k2), {k1, 1, n}, {k2, 1, n}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.