next up previous index
Next: E407 Summation of Up: CERNLIB Previous: E255 Least-Squares Fit

E406 Chebyshev Series Coefficients of a Function

Routine ID: E406
Author(s): T. HåvieLibrary: MATHLIB
Submitter: K.S. KölbigSubmitted: 24.01.1986
Language: FortranRevised: 01.12.1994

Subroutine subprograms RCHECF, DCHECF and QCHECF calculate coefficients for a finite sum of Chebyshev polynomials approximating a function f(x) over an interval a≤x≤b to accuracy ε . It returns an integer n and coefficients c0,c1,...,cn such that the sum f*(x) = ∑j=0ncjTj(t)

where t = (2x - a - b)/(b - a) and Tj(t) is the Chebyshev polynomial of degree j, satisfies for a≤x≤b the relation |f*(x) - f(x)| < ε.

Subsequent evaluation of the approximation (1) can be done by calling CHSUM (E407) with the appropriate value of its argument MODE.

On computers other than CDC and Cray, only the double- and quadruple-precision versions DCHECF and QCHECF are available. On CDC and Cray computers, only the single- and double-precision versions RCHECF and DCHECF are available.

Structure:

SUBROUTINE subprogram
User Entry Names: RCHECF, DCHECF, QCHECF
Obsolete User Entry Names: CHECF RCHECF
Files Referenced: Unit 6
External References: MTLMTR (N002), ABEND (Z035), user-supplied FUNCTION subprogram

Usage:

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

    CALL tCHECF(F,A,B,EPS,C,N,DELTA)
F
(type according to t) Name of a user-supplied FUNCTION subprogram, declared EXTERNAL in the calling program.
A,B
(type according to t) End-points a,b of the approximation interval.
EPS
(type according to t) Requested accuracy.
C
(type according to t) One-dimensional array with dimension (0:d), d ≥128 . On exit, C(j)= cj,(j = 0,1,...,N) .
N
( INTEGER) On exit, N is equal to the subscript of the last computed coefficient.
DELTA
(type according to t) On exit, DELTA is such that the relation |f*(x) - f(x)| < DELTA

is almost certainly true for x ∈[a,b] . (See Error Handling.)

Method:

The interval [a,b] is subdivided successively into sets of subintervals of length 2-k(b-a),(k = 0,1,2...) . After each subdivision the orthogonality properties of the Chebyshev polynomials with respect to summation over equally-spaced points are used to compute two sets of approximate values of the coefficients cj : one set computed using the end-points of the subintervals, and one set using the mid-points. The mean of these two values is taken as the best estimate of the cj , which are then tested to see (a) whether certain rate-of-convergence criteria are satisfied, (b) whether there is some n for which the sum for j>n of the available cj is less than ε . If both conditions are satisfied the subroutine terminates.

Error handling:

Error E406.1: If the requested accuracy cannot be obtained with 65 coefficients (i.e., N = 64 ) a message is written on Unit 6, unless subroutine MTLSET (N002) has been called. In this case, values of f* computed from (1) with N = 64

should still be in error by less than DELTA.

Notes:

  1. This subroutine is intended for use with functions f(x) which can be computed to full machine accuracy, and which are sufficiently smooth to ensure fairly rapid decrease of the cj with increasing j. Functions defined by experimental data can usually be approximated better by least-squares methods, using ordinary polynomials.
  2. Note that some authors use a different definition for the constant term in (1), i.e. c0/2 instead of c0 . Here, the definition of Ref. 1 is used.

References:

  1. Y.L. Luke, Mathematical functions and their approximations, (Academic Press, New York 1975)

E407



next up previous index
Next: E407 Summation of Up: CERNLIB Previous: E255 Least-Squares Fit


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