Richard Fateman <fateman <at> cs.berkeley.edu> writes:
>
> a more systematic approach would be better.>
> 1. define a class of limit problems that are not solved properly by the
> existing program. (either wrong answer or very slow).
For deeply nested functions limit and taylor are slow or wrong answer:
See the mail: limit needs some batteries for examples, also this one:
(%i35) taylor(sin(sin(sin(sin(sin(sin(sin(x^3)^5)))))),x,0,20);
Evaluation took 56.30 seconds (56.30 elapsed)(%o35)
x^15+...
(%i36) taylor(sin(sin(sin(sin(sin(sin(sin(sin(x^3)^5))))))),x,0,20);
Evaluation took 285.41 seconds (285.41 elapsed)
that is exponencial about 5^n increase in computation time with n the nested
level.
> 2. design an algorithm that will solve those problems, and explain (maybe
> prove) that it is correct.
The desing is completed, explain and prove to be done.
> 3. write the algorithm in detail, with comments, test and time it, comparing
> it to the previous one.
The algorithm is done, the rest to be done.
This seem to be a correct program:
h(x):= block([re],re:g(x), if re=false then x else re);
lst1:[sin,asin,sinh,tan,atan,tanh];
lst2:[cos,cot];
inflag:true;
var:x;
x0:0;
g(x):=block([o,u,re],
if atom(x) then return(x),
o: op(x),u:args(x)[1],
if o ="^" then
(re:g(u), if re = false then return(x) else return (re^args(x)[2])),
if op(x)="*" then return(map(h,x)),
if member(o,lst1) then return(try(u)),
if member(o,lst2) then return(try(%pi/2 - u)),
if o='log then return(try(u-1)) else return(x));
try(a):= block([ga],ga:g(a),
if ga # a then return (g(ga)),
if limit(a,var,x0)=0 then pr(a) else false);
pr(f):= block([re],re: ratdisrep(taylor(f,var,x0,20)),
if (re # 0) then mino(re) else f);
mino(f):=if (op(f)="+") then first(f) else f;
------------------------
small testing:
(%i38) h((sin(x^2)^4*tan(x^5+x^4)^3*sinh(1-(x^2+1)/(x^3+1))^10*
log(x^5/(x^5+x^6))*cos(x/(x +x^2)*(%pi/2))));
Evaluation took 00.10 seconds (00.10 elapsed)
(%o38) -(%pi*x^42)/2
(%i37) h(sin(sin(sin(sin(sin(sin(sin(sin(x^3)^5))))))));
Evaluation took 0.10 seconds (0.10 elapsed)
(%o37) x^15
Thanks a lot for your suggestions.
Best wishes
-M