I think you're making it more complicated than it need be. There's no need
to declare the a and b arrays (indeed, by doing so, you're preventing Maxima
from multiplying matrix elements with these symbols, subscripted, later on.)
Also, there's no function named scalar(), but in this case, you don't need
that functionality anyway.
If I understand your intent correctly (which is a big if of course), I
believe that these lines do what you want them to do:
s[0]:matrix([1,0],[0,1]);
s[1]:matrix([1,0],[0,-1]);
s[2]:matrix([0,1],[1,0]);
s[3]:matrix([0,%i],[-%i,0]);
bb:0;
for i:0 thru 3 do bb:bb+b[i]*s[i];
for i:1 thru 3 do ( aa[i]:0, for j:0 thru 3 do aa[i]:aa[i]+a[i,j]*s[j] );
aa[1].bb;
Curiously, ratsimp() makes the result uglier, not nicer, in this case.
Viktor
PS: BTW, while testing the development code is both appreciated and
encouraged, I recommend that for actual work, you use the released
production versions. We just released Maxima 5.12.0 a few days ago.
-----Original Message-----
From: maxima-bounces at math.utexas.edu [mailto:maxima-bounces at math.utexas.edu]
On Behalf Of David Ronis
Sent: Wednesday, May 09, 2007 9:58 PM
To: maxima at math.utexas.edu
Subject: What's wrong with this code II
Well now that the display problem is fixed in CVS I went back to the
problem I was really trying to solve:
s[0]:matrix([1,0],[0,1]);
s[1]:matrix([1,0],[0,-1]);
s[2]:matrix([0,1],[1,0]);
s[3]:matrix([0,%i],[-%i,0]);
array(b,4);
array(a,4,4);
for i:0 thru 4 do
block ( scalar(b[i]),
for j:0 thru 4 do
scalar(a[i,j])
);
bb:0;
for i:0 thru 3 do
bb:bb+b[i]*s[i];
for i:1 thru 3 do
block( aa[i]:0,
for j:0 thru 3 do
aa[i]:aa[i]+a[i,j]*s[j]
);
aa[1].bb$
ratsimp(%)
Which gives
[ 1 0 ] [ 1 0 ] [ 0 %i ]
(%o12) (a [ ] + a [ ] + a [ ]
1, 0 [ 0 1 ] 1, 1 [ 0 - 1 ] 1, 3 [ - %i 0 ]
[ 0 1 ] [ 1 0 ] [ 1 0 ] [ 0 %i ]
+ a [ ]) . (b [ ] + b [ ] + b [ ]
1, 2 [ 1 0 ] 0 [ 0 1 ] 1 [ 0 - 1 ] 3 [ - %i 0 ]
[ 0 1 ]
+ b [ ])
2 [ 1 0 ]
This isn't right, or rather it is right, but useless (This should give a
2x2 matrix whose elements contain a[1,j]*b[j']. It seems that it is
assuming noncommutative algebra for the a's and b's. I tried adding the
scalar definitions as shown above, but this didn't seem to help.
Similarly, moving the scalar define loops elsewhere didn't help.
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima