Since you don't say what h is supposed to do, it is hard to say whether it
is working or not.
Is it a proper result that h(sin(x)) produces an error message?
Should h(cos(x)) return cos(x) ?
Is the benefit solely on expressions that are of the form f1(f2(f3.... x))
where f1,f2,... are in {sin,tan,sinh,tanh,^)
And not, for example, h(sin(y^2))?
How would your program fit into a more general limit procedure?
There is a modest literature on computing limits symbolically. You may find
that your idea is already described and refined. Implementing a better
limit program using these ideas might be educational and an improvement on
the current program.
Your example:
taylor(sin(sin(sin(sin(sin(sin(sin(x^3)^5)))))),x,0,20);
takes a long time. But this calculation:
sin(sin(sin(sin(sin(sin(taylor (sin(x^3)^5,x,0,20)))))) gives the same
result in 0.00 seconds.
RJF
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu [mailto:maxima-
> bounces at math.utexas.edu] On Behalf Of miguel lopez
> Sent: Friday, December 22, 2006 11:54 AM
> To: maxima at math.utexas.edu
> Subject: Re: [Maxima] infinitesimal limit wizard
>
> 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
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima