E02AHF (PDF version)
E02 Chapter Contents
E02 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

E02AHF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

E02AHF determines the coefficients in the Chebyshev series representation of the derivative of a polynomial given in Chebyshev series form.

2  Specification

SUBROUTINE E02AHF ( NP1, XMIN, XMAX, A, IA1, LA, PATM1, ADIF, IADIF1, LADIF, IFAIL)
INTEGER  NP1, IA1, LA, IADIF1, LADIF, IFAIL
REAL (KIND=nag_wp)  XMIN, XMAX, A(LA), PATM1, ADIF(LADIF)

3  Description

E02AHF forms the polynomial which is the derivative of a given polynomial. Both the original polynomial and its derivative are represented in Chebyshev series form. Given the coefficients ai, for i=0,1,,n, of a polynomial px of degree n, where
px=12a0+a1T1x-++anTnx-  
the routine returns the coefficients a-i, for i=0,1,,n-1, of the polynomial qx of degree n-1, where
qx=dpx dx =12a-0+a-1T1x-++a-n-1Tn-1x-.  
Here Tjx- denotes the Chebyshev polynomial of the first kind of degree j with argument x-. It is assumed that the normalized variable x- in the interval -1,+1 was obtained from your original variable x in the interval xmin,xmax by the linear transformation
x-=2x-xmax+xmin xmax-xmin  
and that you require the derivative to be with respect to the variable x. If the derivative with respect to x- is required, set xmax=1 and xmin=-1.
Values of the derivative can subsequently be computed, from the coefficients obtained, by using E02AKF.
The method employed is that of Chebyshev series (see Chapter 8 of Modern Computing Methods (1961)), modified to obtain the derivative with respect to x. Initially setting a-n+1=a-n=0, the routine forms successively
a-i-1=a-i+1+2xmax-xmin 2iai,  i=n,n-1,,1.  

4  References

Modern Computing Methods (1961) Chebyshev-series NPL Notes on Applied Science 16 (2nd Edition) HMSO

5  Parameters

1:     NP1 – INTEGERInput
On entry: n+1, where n is the degree of the given polynomial px. Thus NP1 is the number of coefficients in this polynomial.
Constraint: NP11.
2:     XMIN – REAL (KIND=nag_wp)Input
3:     XMAX – REAL (KIND=nag_wp)Input
On entry: the lower and upper end points respectively of the interval xmin,xmax. The Chebyshev series representation is in terms of the normalized variable x-, where
x-=2x-xmax+xmin xmax-xmin .  
Constraint: XMAX>XMIN.
4:     ALA – REAL (KIND=nag_wp) arrayInput
On entry: the Chebyshev coefficients of the polynomial px. Specifically, element i×IA1 of A must contain the coefficient ai, for i=0,1,,n. Only these n+1 elements will be accessed.
Unchanged on exit, but see ADIF, below.
5:     IA1 – INTEGERInput
On entry: the index increment of A. Most frequently the Chebyshev coefficients are stored in adjacent elements of A, and IA1 must be set to 1. However, if for example, they are stored in A1,A4,A7,, then the value of IA1 must be 3. See also Section 9.
Constraint: IA11.
6:     LA – INTEGERInput
On entry: the dimension of the array A as declared in the (sub)program from which E02AHF is called.
Constraint: LA1+NP1-1×IA1.
7:     PATM1 – REAL (KIND=nag_wp)Output
On exit: the value of pxmin. If this value is passed to the integration routine E02AJF with the coefficients of qx, then the original polynomial px is recovered, including its constant coefficient.
8:     ADIFLADIF – REAL (KIND=nag_wp) arrayOutput
On exit: the Chebyshev coefficients of the derived polynomial qx. (The differentiation is with respect to the variable x.) Specifically, element i×IADIF1+1 of ADIF contains the coefficient a-i, for i=0,1,,n-1. Additionally, element n×IADIF1+1 is set to zero. A call of the routine may have the array name ADIF the same as A, provided that note is taken of the order in which elements are overwritten, when choosing the starting elements and increments IA1 and IADIF1, i.e., the coefficients a0,a1,,ai-1 must be intact after coefficient a-i is stored. In particular, it is possible to overwrite the ai completely by having IA1=IADIF1, and the actual arrays for A and ADIF identical.
9:     IADIF1 – INTEGERInput
On entry: the index increment of ADIF. Most frequently the Chebyshev coefficients are required in adjacent elements of ADIF, and IADIF1 must be set to 1. However, if, for example, they are to be stored in ADIF1,ADIF4,ADIF7,, then the value of IADIF1 must be 3. See Section 9.
Constraint: IADIF11.
10:   LADIF – INTEGERInput
On entry: the dimension of the array ADIF as declared in the (sub)program from which E02AHF is called.
Constraint: LADIF1+NP1-1 ×IADIF1.
11:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry,NP1<1,
orXMAXXMIN,
orIA1<1,
orLANP1-1×IA1,
orIADIF1<1,
orLADIFNP1-1×IADIF1.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

There is always a loss of precision in numerical differentiation, in this case associated with the multiplication by 2i in the formula quoted in Section 3.

8  Parallelism and Performance

Not applicable.

9  Further Comments

The time taken is approximately proportional to n+1.
The increments IA1, IADIF1 are included as parameters to give a degree of flexibility which, for example, allows a polynomial in two variables to be differentiated with respect to either variable without rearranging the coefficients.

10  Example

Suppose a polynomial has been computed in Chebyshev series form to fit data over the interval -0.5,2.5. The following program evaluates the first and second derivatives of this polynomial at 4 equally spaced points over the interval. (For the purposes of this example, XMIN, XMAX and the Chebyshev coefficients are simply supplied in DATA statements. Normally a program would first read in or generate data and compute the fitted polynomial.)

10.1  Program Text

Program Text (e02ahfe.f90)

10.2  Program Data

None.

10.3  Program Results

Program Results (e02ahfe.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 0 0.5 1 1.5 2 2.5 3 −0.5 0 0.5 1 1.5 2 2.5 P(x), P'(x), P''(x) x Example Program Evaluation of Chebyshev Polynomial and its Derivatives P(x) P'(x) P''(x) gnuplot_plot_1 gnuplot_plot_2 gnuplot_plot_3

E02AHF (PDF version)
E02 Chapter Contents
E02 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2015