The FX_ROOT function computes a real or complex root of a univariate nonlinear function using an optimal Müller’s method.

FX_ROOT uses an algorithm that is described in section 9.5 of Numerical Recipes in C: The Art of Scientific Computing (Second Edition), published by Cambridge University Press, and is used by permission.

This routine is written in the IDL language. Its source code can be found in the file in the lib subdirectory of the IDL distribution.


For example, suppose we wish to find the first root of the following function:

; Create a Lambda function containing the equation:
IDL> func = Lambda(x: sin(x^x)/2d^((x^x - !dpi/2)/!dpi))
; Provide a guess for the root using three X values
IDL> root = FX_ROOT([1.5d,1.8,1.9], func)
IDL> root

IDL prints:



Result = FX_ROOT(X, Func [, /DOUBLE] [, ITMAX=value] [, /STOP] [, TOL=value] )

Return Value

The return value is the real or complex root of a univariate nonlinear function. Which root results depends on the initial guess provided for this routine.



A 3-element real or complex initial guess vector. Real initial guesses may result in real or complex roots. Complex initial guesses will result in complex roots.


A scalar string specifying the name of a user-supplied IDL function that defines the univariate nonlinear function. This function must accept an input argument containing a three-element vector, and must return a three-element vector containing the function value at those X values.



Set this keyword to force the computation to be done in double-precision arithmetic.


The maximum allowed number of iterations. The default is 100.


Use this keyword to specify the stopping criterion used to judge the accuracy of a computed root r(k). Setting STOP = 0 (the default) checks whether the absolute value of the difference between two successively-computed roots, | r(k) - r(k+1) | is less than the stopping tolerance TOL. Setting STOP = 1 checks whether the absolute value of the function FUNC at the current root, | FUNC(r(k)) |, is less than TOL.


Use this keyword to specify the stopping error tolerance. The default is 1.0 x 10-4.

Version History

Pre 4.0


See Also