## maxima-bugs

 [Maxima-bugs] Lazy deferred evaluation of 'limit' causes endless loop From: arielCo - 2013-05-13 02:07:33 ```Hello everyone, I'm trying to use the limit of a function (special case) as another function, but apparently the limit is only evaluated on output. This is a simplified example: --EXAMPLE-- \$ maxima Maxima 5.29.1 http://maxima.sourceforge.net using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (a.k.a. GCL) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. The function bug_report() provides bug reporting information. (%i1) T(s) := 1/(C1*C2*R1*R2*s^2+(R1*C2+R1*C1+R2*C2)*s+1); 1 (%o1) T(s) := ---------------------------------------------- 2 C1 C2 R1 R2 s + (R1 C2 + R1 C1 + R2 C2) s + 1 (%i2) X(s) := ''(laplace(A*sin(2*%pi*f*t),t,s)); 2 %pi f A (%o2) X(s) := -------------- 2 2 2 4 %pi f + s (%i3) Y(s) := ''(ev(X(s)*T(s), C1=C, C2=C)); 2 %pi f A (%o3) Y(s) := ------------------------------------------------------ 2 2 2 2 2 (4 %pi f + s ) (1 + s C R1 R2 + s (2 C R1 + C R2)) (%i4) assume(t>0, C>0, f>0, R1>0, R2>0); (%o4) [t > 0, C > 0, f > 0, R1 > 0, R2 > 0] (%i5) y(t) := ''(ilt(Y(s),s,t)), fullratsimp; 2 (%o5) y(t) := ((8 %pi f A C R1 + 4 %pi f A C R1 R2 2 2 3 3 3 2 2 t sqrt(4 R1 + R2 ) + (2 %pi f A C + 16 %pi f A C R1 ) R2 ) sinh(-------------------) 2 C R1 R2 t ------ 2 C R1 + (((sin(2 %pi f t) A - 4 %pi f cos(2 %pi f t) A C R1) %e t ------ 2 2 2 2 C R1 + (- 2 %pi f cos(2 %pi f t) A C - 4 %pi f sin(2 %pi f t) A C R1) %e t ---- 2 2 C R2 t sqrt(4 R1 + R2 ) R2) %e + (4 %pi f A C R1 + 2 %pi f A C R2) cosh(-------------------)) 2 C R1 R2 t ------ 2 2 2 2 2 2 2 C R1 sqrt(4 R1 + R2 ))/(((1 + 16 %pi f C R1 ) %e t t ------ ------ 2 2 2 2 C R1 2 2 2 4 4 4 2 2 C R1 + 8 %pi f C R1 %e R2 + (4 %pi f C + 16 %pi f C R1 ) %e t ---- 2 C R2 2 2 R2 ) %e sqrt(4 R1 + R2 )) /* Here I define a special case as the limit of y(t) when R2 -> 0+ (evaluating y(t),R2=0 produces errors) */ (%i6) y0(t) := limit(y(t), R2, 0, plus); (%o6) y0(t) := limit(y(t), R2, 0, plus) /* Apparently it worked, but when I ask for the 'internal' representation, the limit has not been computed before assigning to y0 */ (%i7) y0(t); - sin(2 %pi f t) A + 4 %pi f cos(2 %pi f t) A C R1 (%o7) - -------------------------------------------------- 2 2 2 2 1 + 16 %pi f C R1 (%i8) :lisp (symbol-plist '\$y0) (MPROPS (NIL MEXPR ((LAMBDA) ((MLIST) \$T) ((\$LIMIT) ((\$Y) \$T) \$r2 0 \$PLUS))) PNAME \$Y0) (%i8) [R1, R2c, R2v, C, Vbr, A, f] : [10000.0, 56000.0, 500000.0, 10E-8, 32, 339, 60]; (%o8) [10000.0, 56000.0, 500000.0, 9.9999999999999995E-8, 32, 339, 60] /* The big general function works fine */ (%i9) float(y(0.003)), R2=53e3; (%o9) 43.1301686773795 /* y0() seems to do something with an argument that is _outside_ the call */ (%i10) float(y0(0.003)), R2=53e3; limit: second argument must be a variable, not a constant; found: 53000.0 #0: y0(t=0.003) -- an error. To debug this try: debugmode(true); /* This makes maxima hang in a loop: CPU usage shoots to 100% and resident memory slowly climbs */ (%i11) float(y0(0.003)); --END OF EXAMPLE-- I can send a .mac or .wxm file for your convenience. Maybe I'm doing something wrong (I'm a total newbie and the evaluation of the expressions still confuses me), but I still think it shouldn't behave like this and at any rate I'd like to understand the root cause. Thoughts? Best regards, Ariel Cornejo ```