Sorry for the second post but I should say the example is just to illustrate the problem.
From: Richard Hennessy
Sent: Sunday, December 27, 2009 5:16 PM
To: Maxima List
Subject: How to prevent evaluation.
I tried this to see the timing information.
load(pw)$
(%i3) showtime:true;
Evaluation took 0.0000 seconds (0.0000 elapsed)
(out3)
(%i4) for i : 1 thru 2000 do %if(i>0, expand((x-y)^100), expand((x-y)^100));
Evaluation took 13.0200 seconds (13.0200 elapsed)
(out4) done
%i5) for i : 1 thru 2000 do %if(i>0, expand((x-y)^100), 1);
Evaluation took 6.7700 seconds (6.7700 elapsed)
(out5) done
%i6) for i : 1 thru 2000 do %if(i>0, 1, expand((x-y)^100));
Evaluation took 7.0400 seconds (7.0400 elapsed)
(out6) done
%i7) for i : 1 thru 2000 do %if(i>0, expand((x-y)^100), 1);
Evaluation took 6.8200 seconds (6.8200 elapsed)
(out7) done
(%i8 for i : 1 thru 2000 do %if(i>0, 1, 1);
Evaluation took 0.1500 seconds (0.1500 elapsed)
(out8) done
(%i4)
It seems like in the %if function both the then part and the else part are always expanded even when only one needs to
be evaluated. Is there a way to stop evaluation of both parts? This would make possible major speed improvements
dealing with large expressions.
Rich