My find_root example I could not get to work before today.
I think I can get the rest.
(%i8) bffind_root('(f(5.9b-9,e)), [], e, 4.047b-19,4.4947335b-19,30);
Evaluation took 3.0700 seconds (3.0700 elapsed)
(out8) 4.09507811775768571897060610354b-19
Rich
From: Richard Hennessy
Sent: Sunday, May 30, 2010 1:03 PM
To: Stavros Macrakis
Cc: Maxima List ; Barton Willis
Subject: Re: [Maxima] How to pass a power series to find_root
I got it to work now.
(%i5) bffind_root('f(5.9b-9,e), f, e, 4.047b-19,4.4947335b-19,30);
Evaluation took 3.1600 seconds (3.1600 elapsed)
(out5) 4.09507811775768571897060610354b-19
(%i6) find_root('(f(5.9b-9,x)),x,4.047e-19,4.49e-19 );
Evaluation took 1.0300 seconds (1.0300 elapsed)
(out6) 4.0950781177607183*10^-19
(%i7) find_root('(f(5.9e-9,x)),x,4.047e-19,4.49e-19);
find_root: function has same sign at endpoints: f(4.047*10^-19)=3.1839205475930013*10^23,
f(4.4899999999999998*10^-19)=1.9111895122777875*10^24
-- an error. To debug this try: debugmode(true);
For some reason the third way does not work but I can live with that.
Thanks,
Rich
From: Stavros Macrakis
Sent: Sunday, May 30, 2010 8:26 AM
To: Richard Hennessy
Cc: Barton Willis ; Maxima List
Subject: Re: [Maxima] 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.
&n bsp; -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
--------------------------------------------------------------------------------
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima