>  Docs Center  >  IDL Reference  >  Advanced Math and Stats  >  IMSL_ZEROFCN



The IMSL_ZEROFCN function finds the real zeros of a real function using Müller’s method.

This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.

The IMSL_ZEROFCN function computes n real zeros of a real function f. Given a user-supplied function f(x) and an n-vector of initial guesses x0, x1, ..., xn–1, the function uses Müller's method to locate n real zeros of f. The function has two convergence criteria. The first criterion requires that | f (xi(m)) | be less than ERR_ABS. The second criterion requires that the relative change of any two successive approximations to an xi be less than ERR_REL. Here, xi(m)) is the m-th approximation to xi. Let ERR_ABS be denoted by e1, and ERR_REL be denoted by e2. The criteria can be stated mathematically as follows. IMSL_ZEROFCN has two convergence criteria; 'convergence' is the satisfaction of either criterion.

Criterion 1:

Criterion 2:

'Convergence' is the satisfaction of either criterion.


This example finds a real zero of the third-degree polynomial:

f(x) = x3 – 3x2 + 3x – 1

The results are shown in in the figure that follows.

; Define function f. FUNCTION f, x
  return, x^3 - 3 * x^2 + 3 * x - 1
zero = IMSL_ZEROFCN('f')
; Compute the real zero(s). x = 2 * FINDGEN(100)/99
PLOT, x, f(x)
; Plot results.
OPLOT, [zero], [f(zero)], Psym = 6
XYOUTS, .5, .5, 'Computed zero is at x = ' + $ 
  STRING(zero(0)), Charsize = 1.5


Warning Errors

MATH_NO_CONVERGE_MAX_ITER: Function failed to converge within ITMAX iterations for at least one of the N_ROOTS roots.


Result = IMSL_ZEROFCN(F [, /DOUBLE] [, ERR_ABS=value] [, ERR_REL=value] [, ETA=value] [, EPS=value] [, INFO=array] [, ITMAX=value] [, N_ROOTS=value] [, XGUESS=array])

Return Value

An array containing the zeros x of the function.



Scalar string specifying a user-supplied function for which the zeros are to be found. The F function accepts one scalar parameter from which the function is evaluated and returns a scalar of the same type.


DOUBLE (optional)

If present and nonzero, then double precision is used.

ERR_ABS (optional)

First stopping criterion. A zero, xi, is accepted if | f (xi) | < ERR_ABS. Default: SQRT(ε), where ε is the machine precision .

ERR_REL (optional)

Second stopping criterion. A zero, xi, is accepted if the relative change of two successive approximations to xi is less than ERR_REL. Default: SQRT(ε), where ε is the machine precision

ETA (optional)

Spread criteria for multiple zeros. If the zero, xi, has been computed and | xixj | < EPS, where xj is a previously computed zero, then the computation is restarted with a guess equal to xi + ETA. Default: 0.01

EPS (optional)

See ETA. Default: SQRT(ε), where ε is the machine precision.

INFO (optional)

Array of length N_ROOTS containing convergence information. The value INFO (j – 1) is the number of iterations used in finding the j-th zero when convergence is achieved. If convergence is not obtained in ITMAX iterations, INFO (j – 1) is greater than ITMAX.


Maximum number of iterations per zero. Default: 100.

N_ROOTS (optional)

Number of roots for IMSL_ZEROFCN to find. Default: 1.

XGUESS (optional)

Array with N_ROOTS components containing the initial guesses for the zeros. Default: 0

Version History



© 2019 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us