double sum?



Yes, you can write this:
n:5$
s:0$
for i from 1 thru n do for j from i+1 thru n do s:s+a[i]*b[j]$
s;

If you mean "oh, I don't want to have specific values like n=5",
then you can write this:

KostasSum(exp, [i,i1,i2], [j,j1,j2], ....).

If you then say "oh, I want it to be simplified if possible",

then you have to specify what simplifications you have in mind, and 
program them, or get someone else to program them, perhaps using 
tellsimp or tellsimpafter.

If you want to do operations on sets, you could look at
http://www.cs.berkeley.edu/~fateman/papers/sets.pdf

Note that the notation  {1<=i<j<=n} is a shorthand for some set of pairs 
of integers, perhaps more explicitly written as something like

{ <a,b>  |  a in [1,n]  and  b in [a+1,n]}

And from there you can get more explicit, and perhaps even specify 
special cases or simplifications.
You don't have to write programs, but you have to be so explicit that 
writing the programs does not require the programmer to disambiguate 
your specifications.

If all you want to do is transform
KostasSum(.....)  into  sum(sum(...)..), then this is trivial but 
probably pointless unless you
expect that the inner sum will be simplified.  If you have such 
expectations, why not just write the original item as sum(sum(...)....)

RJF



Kostas Oikonomou wrote:

>Handling implicit sets would be very nice, but perhaps a bit ambitious 
>for a first effort.  I would be satisfied if Maxima could handle the 
>kind of explicit multiple sum that Mathematica handles, i.e. an 
>expression of the form
>
>	Sum(expr, {i,i1,i2}, {j,j1,j2}, {k,k1,k2}, ...)
>
>where the limits of the indices are not restricted to be constants, but 
>later ones can depend on the indices appearing earlier in the list.  (Or 
>the opposite convention).
>
>Robert Dodier wrote:
>  
>
>>On 3/13/07, Kostas Oikonomou <ko at research.att.com> wrote:
>>
>>    
>>
>>>Is there a way to write a double sum in Maxima?  E.g.,
>>>
>>>sum_{1 <= i < j <= n} a[i] * b[j]
>>>      
>>>
>>Unfortunately no. I would be very interested to have such a thing.
>>One solution is to allow something like sum(expr, i, S) where S is
>>a set, either explicit (like {a, b, c}) or implicit (like {(i, j) s.t.
>>1 <= i < j <= n}).
>>Maxima doesn't recognize implicit sets; I'd like to see that too.
>>There remains the problem of telling Maxima what to do with such
>>summations, but first we have pick a representation, and just that
>>would be a step in the right direction.
>>
>>FWIW
>>Robert
>>    
>>
>_______________________________________________
>Maxima mailing list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima
>  
>