I have to apply "limit" to a 42x42 matrix. Altough it is a very simple
operation (matrix is simple and also sparse) it takes a lot of time and memory
(on an athlon xp-m 2800+).
(%i15) limit(K,bk,inf)$
Evaluation took 4.4963 seconds (4.5914 elapsed) using 29.406 MB.
and this:
(%i16) map(lambda([el],limit(el,bk,inf)),K)$
Evaluation took 4.5323 seconds (4.6274 elapsed) using 29.417 MB.
I have do do a loop with thiis, so at the end it takes 100 seconds and 1000 Mb
of memory on my system.
Why is limit so slow?
This is the matrix, if you want to try...
K:matrix([1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0],
[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0],
[0,0,4*E*I/l,0,0,0,3*sqrt(3)*E*I/l^2,-3*E*I/l^2,2*E*I/l,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,A*E/l+bk,0,0,0,0,0,0,0,0,0,0,0,-A*E/l,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,12*E*I/l^3+bk,6*E*I/l^2,0,0,0,0,0,0,0,0,0,0,
-12*E*I/l^3,6*E*I/l^2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0],
[0,0,0,0,6*E*I/l^2,4*E*I/l,0,0,0,0,0,0,0,0,0,0,-6*E*I/l^2,
2*E*I/l,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,3*sqrt(3)*E*I/l^2,0,0,0,9*E*I/l^3+A*E/(4*l)+bk,
sqrt(3)*A*E/(4*l)-3*sqrt(3)*E*I/l^3,3*sqrt(3)*E*I/l^2,-bk,0,0,
0,0,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