Re: Better Root Finder [message #53522 is a reply to message #53390] |
Mon, 16 April 2007 12:17  |
mmeron
Messages: 44 Registered: October 2003
|
Member |
|
|
In article <31zUh.663$0S1.610@trnddc01>, "Wayne Landsman" <wlandsman@jhu.edu> writes:
>
> <jschwab@gmail.com> wrote in message
> news:1176669683.157908.311410@b75g2000hsg.googlegroups.com.. .
>> On Apr 15, 12:55 am, "Max Watson" <max...@gmail.com> wrote:
>>> IDL's fx_root seems very limited; when I want to find the root of say
>>> x^3 - 8 with the initial guess vector [-1,-100,100], IDL returns a
>>> complex number: ( -1.00000, 1.73205). Is there a way that
>>> fx_root can be easily modified so that it can find the right answer
>>> with a bad initial guess?
>
> I think that the previous suggestion of using FZ_ROOTS if you have a
> polynomial, or is the way to go, but in the off-chance that you are only
> interested in cubic polynomial equations, as in your example, *and* you are
> only interested in the (one or three) real roots, then this can be solved
> analytically, e.g.
>
> http://idlastro.gsfc.nasa.gov/ftp/contrib/freudenreich/cuber oot.pro
>
> IDL> print, (cuberoot([-8,0,0,1]))(0)
> 2.0000000
>
> If you don't have any type of polynomial, but you know that a real root
> exists, then you can also find the zero using zbrent.pro in
> http://idlastro.gsfc.nasa.gov/ftp/pro/math/zbrent.pro to find the root
> numerically to within a specified tolerance.
>
Or, if you think you may have more than one real root, you can use my
ROOT routine and try to get them all.
Mati Meron | "When you argue with a fool,
meron@cars.uchicago.edu | chances are he is doing just the same"
|
|
|