Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2012

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

Search the Archive

Re: Splitting sums in mathematica

  • To: mathgroup at
  • Subject: [mg126832] Re: Splitting sums in mathematica
  • From: Ray Koopman <koopman at>
  • Date: Mon, 11 Jun 2012 00:02:27 -0400 (EDT)
  • Delivered-to:
  • References: <jqusrg$rnm$> <jr1dvt$73t$>

On Jun 9, 11:14 pm, Ray Koopman <koop... at> wrote:
> On Jun 9, 12:09 am, jimbo <james.a.gord... at> wrote:
>> Hello,
>> Does anyone know of a way to algebraically split sums (if that is the
>> correct name for it) in mathematica? I need to do the following (and
>> higher-order versions of the same)...
>> Sum_over_p [  Sum_over_q (  a_p * a_q  )   ] = Sum_over_p_equal_q
>> (a_p^2) + Sum_over_p_not_equal_q (a_p*a_q)
>> other words, turn a nested sum running over two indices into two
>> sum, one for when the indices are equal, and one for when they are
>> different?
>> I then need to make some substitutions once there are no nested sums
>> and simplify my answer. I have an equation with many hundreds of terms
>> in it, so doing it by hand is not an option. I can send a typeset
>> example if anyone needs clarification
>> I have version 5.2 for students
>> Thanks in advance
>> James
> Let a = {a1,a2,...}. Then a.a gives the sum of the terms with p == q,
> and 2*Dot@@Transpose@Subsets[a,{2}] gives the sum of the terms with
> p != q.

If you have to do that many times then you might want to define
{p,q} = Transpose@Subsets[Range@Length@a,{2}]  once, and then
use  2*a[[p]].a[[q]]  to sum the terms whose subscripts differ.

  • Prev by Date: Re: Any efficient way to make complete homogeneous symmetric functions in Mathematica?
  • Next by Date: WRI Curve and Filling Colors
  • Previous by thread: Re: Splitting sums in mathematica
  • Next by thread: Re: Splitting sums in mathematica