next up previous index
Next: C201 Numerical Solution Up: CERNLIB Previous: B300 An integral

C200 Zero of a Function of One Real Variable

Routine ID: C200
Author(s): K.S. KölbigLibrary: MATHLIB
Submitter: Submitted: 01.05.1990
Language: FortranRevised: 01.12.1994

Function subprograms RZEROX and DZEROX compute, to an attempted specified accuracy, a zero x0 of a real-valued function f(x) lying in a given interval [a,b] , where f(a)*f(b)≤0 .

On computers other than CDC or Cray, only the double precision version DZEROX is available. On CDC and Cray computers, only the single-precision version RZEROX is available.

Structure:

FUNCTION subprograms
User Entry Names: RZEROX, DZEROX
Obsolete User Entry Names: ZEROX RZEROX
Files Referenced: Unit 6
External References: User-supplied FUNCTION subprogram

Usage:

For t=R (type REAL), t=D (type DOUBLE PRECISION),

    tZEROX(A,B,EPS,MAXF,F,MODE)
has, in any arithmetic expression, the value x0 .
A,B
(type according to t) On entry, A and B must specify the end points of the search interval. Unchanged on exit.
EPS
(type according to t) On entry, EPS must be equal to the accuracy parameter (see Accuracy). Unchanged on exit.
MAXF
( INTEGER) On entry, MAXF must be equal to the maximum permitted number of references to the function F within the iteration loop. Unchanged on exit.
F
(type according to t) Name of a user-supplied FUNCTION subprogram, declared EXTERNAL in the calling program. This subprogram must set F(X)= f(X) .
MODE
( INTEGER) On entry, MODE=1 or MODE=2 defines the algorithm for finding x0 (see Method and Notes).

Method:

Two algorithims are incorporated in this subprogram. These are described in Ref. 1 as ``Algorithm M'' (MODE=1 ) and ``Algorithm R'' (MODE=2 ). Both are mixtures of linear interpolation, rational interpolation and bisection.

Accuracy:

These subprograms try to compute two numbers x0 and x1

lying in the interval [a,b] such that

  1. f(x0)f(x1)≤0

  2. |f(x0)| ≤|f(x1)|

  3. |x0- x1|≤2*EPS* (1+|x0|)
If successful, the value of x0 is assigned to the function name.

Notes:

  1. MODE=1 should be used for fairly simple functions whose evaluation is cheap in comparison with the calculations performed in one iteration step of RZEROX or DZEROX.
  2. MODE=2 should be used for more expensive functions. Convergence should be faster than for MODE=1 , but the evaluation steps are more expensive.
  3. For functions which have a pole near the exact zero, MODE=1 is recommended because of the special character of the interpolation formula which is used.

Error handling:

  1. F(A)* F(B)> 0 . The function value is set equal to zero.
  2. MODE has a value other than 1 or 2. The function value is set equal to zero.
  3. The number of references to F exceeds MAXF. The function value is set equal to the last computed value of x0

    (see Accuracy)

For each error a message is printed.

The subprogram is based on Algol programs described in Ref. 1.

References:

  1. J.C.P. Bus and T.J. Dekker, Two efficient algorithms with garanteed convergence for finding a zero of a function, ACM Trans. Math. Software 1 (1975) 330--345.

C201

J.J. Moré, M.Y. Cosnard



next up previous index
Next: C201 Numerical Solution Up: CERNLIB Previous: B300 An integral


Janne Saarela
Mon Apr 3 15:06:23 METDST 1995