comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Better Root Finder
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Better Root Finder [message #53390] Sun, 15 April 2007 17:01 Go to previous message
wlandsman@jhu.edu is currently offline  wlandsman@jhu.edu
Messages: 12
Registered: September 2006
Junior Member
<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.

--Wayne
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: 3D congrid without interpolation
Next Topic: IDL crash without warning

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 14:54:28 PDT 2025

Total time taken to generate the page: 0.47979 seconds