Re: Splitting sums in mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg126841] Re: Splitting sums in mathematica
- From: Dana DeLouis <dana01 at me.com>
- Date: Tue, 12 Jun 2012 02:59:38 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
Hi. As a side note, if your data is a range of numbers, there appears to be a closed form if you are using Ray's excellent idea. diff[a_,b_]:=1/12 (b-a) (-a+b+1) (3 (a+b)^2+a-b-2) equal[a_,b_]:=1/6 (((3-2 a) a-1) a+(b+1) (2 b+1) b) // Here's a range of numbers: rng=Range[12, 9768]; // Indices are equal rng.rng //Timing {0.004522, 310715118978} equal[12, 9768]//Timing {0.000038, 310715118978} // Indices are not equal 2*Dot@@Transpose@Subsets[rng,{2}]//Timing {34.2524, 2276098464473922} diff[12,9768]//Timing {0.000035, 2276098464473922} = = = = = = = = = = HTH :>) Dana DeLouis Mac & Math 8 = = = = = = = = = = On Jun 9, 3:09 am, jimbo <james.a.gord... at googlemail.com> 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) > > ...in 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