Fwd: Help about maxima



On Fri, 2006-05-26 at 08:57 +0200, Nicolas Pettiaux wrote:
> Could you please help me to provide some assistance to jihene.

> From: jihene zaghdoudi <jihene_zaghdoudi at yahoo.fr>
> The problem consiste to obtain the product of N matrix.
> I have tow matrixs M1([cos(a),(- %i/n1)*sin(a)],[(-%i*n1)*sin(a),
> cos(a)]) and M2([cos(b),(- %i/n2)*sin(b)],[(-%i*n2)*sin(b), cos(b)]);
> I want to obtain the product of N=34 matrix costructed us folwing
> M[n]:M[n-1 ].M[n-2]
> The matrix product is Mp:([a11,a12],[a21,a22]), then I want to obtain
> the elements of the matrix Mp

I'm not sure I understood the statement of the problem, but this might
get you a clue:

(%i1) display2d: false$
(%i2) M1 : matrix([cos(a),(- %i/n1)*sin(a)],[(-%i*n1)*sin(a),cos(a)])$
(%i3) M2 : matrix([cos(b),(- %i/n2)*sin(b)],[(-%i*n2)*sin(b), cos(b)])$
(%i4) Mp(n) := if (n>4) then Mp(n-1).Mp(n-2) else if (n>3) then
             Mp(n-1).M2 else if (n>2) then M2.M1 else print("unknown")$
(%i5) showtime: true$
Evaluation took 0.00 seconds (0.00 elapsed) using 96 bytes.
(%i6) M: Mp(10)$
Evaluation took 0.03 seconds (0.04 elapsed) using 115.094 KB.
(%i7) M: Mp(20)$
Evaluation took 4.19 seconds (4.21 elapsed) using 14.045 MB.
(%i8) M: Mp(25)$
Evaluation took 48.70 seconds (48.77 elapsed) using 155.781 MB.
(%i9) M[1][1];
Evaluation took 0.00 seconds (0.00 elapsed) using 128 bytes.
(%o9) [cos(a),-%i*sin(a)/n1]

Notice that the computation time increases quickly with n. I didn't
have time to try up to n=34.

Regards,
Jaime