How to pass a power series to find_root



I have not studied your code in detail, but the basic problem appears to be
your use of 'f(...) as an argument and then 'at' and apply/ev to evaluate it
at given points.

The syntactic form 'f(...) creates a noun-form of f, which there is no
reason to have here.  The argument should be '( f(...) ).  You mention that
you couldn't get that to work, but that is the form you need to make work.
The complicated workaround of at/apply/ev should not be necessary.  What
problems did you have with the simple, ordinary approaches?

If you can't figure that out, please send us a *minimal* reproducible
example.  Surely most of the code in 'f' and 'bffind_root' is not necessary
to reproduce the problem, and is not the crux of the problem.

                   -s

On Sat, May 29, 2010 at 19:38, Richard Hennessy
<rich.hennessy at verizon.net>wrote:

> Okay I think I understand that nfloat() isn't helping but what about how to
> prevent evaluation of a function passed as a parameter to another function.
>  makelist(f(5.9b-9, e), e, 1, 100) does not take a long time.  In fact it is
> pretty fast. Something is different about makelist().  I think I remember
> reading that makelist was "designed for functions" in some of the documents
> on the Wiki.
>
> I have a bffind_root() function that I wrote and when I call it it takes so
> long that I have yet to see it complete. bffind_root() is defined in pw.mac.
>  It is just a simple binary search.  I have tried all kind of quoting of the
> f() like '(f(5.9,e)) but it does not work.  Typing in f(5.9b-9,e) also never
> completes which makes sense.
>
> I have changed bffind_root() to take the function name as an extra
> parameter and that works but I would prefer a better way.
>
> This is my power series.
>
> f(x,e):=sum(
>   block([hbar : bfloat(6.6260693b-34/(2*%pi)), mu : 1b15, m :
> 9.109389754b-31],
>       if  equal(_i ,0) then
>       (
>           a : 1,
>           acc : 1,
>           am2 : 0,
>           am4 : 0,
>           am6 : 0
>       )
>       elseif mod( _i , 2)=0 then
>       (
>           a : 2 * m / hbar^2 * (mu * am6 - am2 * e)/(_i * (_i - 1))
>       ),
>       if mod(_i , 2)=1 then
>       (
>           _num : 0
>       )
>       else
>       (
>           am6 : am4,
>           am4 : am2,
>           am2 : a,
>           tmp : a*acc,
>           acc : acc * x^2,
>           _num : tmp
>       ),
> _num
> ), _i, 0, 300)$
>
> bffind_root('f(5.9b-9, e), f, e, 4.047b-19,4.4947335b-19,30);  this works
> fine because I modified bffind_root() to pass the function name as the
> second parameter.
>
> bffind_root('f(5.9b-9, e), e, 4.047b-19,4.4947335b-19,30);  this takes
> forever.
>
> find_root('f(5.9e-9, e), e, 4.047e-19,4.4947335e-19);  this takes forever.
>
> Thanks for advance for any help.
>
> Rich
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>