The fact that animate uses subs when replacing the animation parameter with a number in the animation range can cause problems when the expression to be animated is only evaluated when the animation parameter is replaced by a numeric value. This is shown in the simple example below My suggestion is that in the procedure `plots/animate` the three subs's are replaced by eval's. Is there any problem with that? Preben Alsholm The following does not work at all, apparently because animate uses subs instead of eval in 3 places, lines 29, 43, and 64 (using showstat(`plots/animate`). N:=0: p:=proc(a) global N; if type(a,numeric) then print(a); N:=N+1; a*x else 'procname'(a) end if end proc: plots:-animate(plot,[p(a),x=0..1,numpoints=5,adaptive=false],a=-1..1,frames=3); `Number of calls with numeric input`=N; Changing subs into eval cures the problem: EVAL:=(x,y)->eval(y,x); EVAL(x=6,x^2); myanimate:=subs(subs=EVAL,eval(`plots/animate`)): N:=0: myanimate(plot,[p(a),x=0..1,numpoints=5,adaptive=false],a=-1..1,frames=3); `Number of calls with numeric input`=N; myanimate(plot,[p(a),x=0..1],a=-1..1); However, in the following situation animate works. The output from the procedure pp is a procedure, thus the input to plot in animate is a procedure which is handled differently. Notice though that the number of calls to the procedure is 15 = 5*3, where it ought to be 3. This problem could be remedied by using 'option remember' in pp, but the problem seems to solved in a cleaner way by replacing subs by eval in `plots/animate`. N:=0: pp:=proc(a) global N; if type(a,numeric) then print(a); N:=N+1; x->a*x else 'procname'(a) end if end proc: plots:-animate(plot,[pp(a),0..1,numpoints=5,adaptive=false],a=-1..1,frames=3); `Number of calls with numeric input`=N; N:=0: myanimate(plot,[pp(a),0..1,numpoints=5,adaptive=false],a=-1..1,frames=3); `Number of calls with numeric input`=N;

Please Wait...