hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_fit_1dcheb_integ (e02aj)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


nag_fit_1dcheb_integ (e02aj) determines the coefficients in the Chebyshev series representation of the indefinite integral of a polynomial given in Chebyshev series form.


[aintc, ifail] = e02aj(n, xmin, xmax, a, ia1, qatm1, iaint1)
[aintc, ifail] = nag_fit_1dcheb_integ(n, xmin, xmax, a, ia1, qatm1, iaint1)


nag_fit_1dcheb_integ (e02aj) forms the polynomial which is the indefinite integral of a given polynomial. Both the original polynomial and its integral are represented in Chebyshev series form. If supplied with the coefficients ai, for i=0,1,,n, of a polynomial px of degree n, where
the function returns the coefficients ai, for i=0,1,,n+1, of the polynomial qx of degree n+1, where
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 integral to be with respect to the variable x. If the integral with respect to x- is required, set xmax=1 and xmin=-1.
Values of the integral can subsequently be computed, from the coefficients obtained, by using nag_fit_1dcheb_eval2 (e02ak).
The method employed is that of Chebyshev series (see Chapter 8 of Modern Computing Methods (1961)), modified for integrating with respect to x. Initially taking an+1=an+2=0, the function forms successively
ai=ai-1-ai+1 2i ×xmax-xmin2,  i=n+1,n,,1.  
The constant coefficient a0 is chosen so that qx is equal to a specified value, qatm1, at the lower end point of the interval on which it is defined, i.e., x-=-1, which corresponds to x=xmin.


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


Compulsory Input Parameters

1:     n int64int32nag_int scalar
n, the degree of the given polynomial px.
Constraint: n0.
2:     xmin – double scalar
3:     xmax – double scalar
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 – double array
la, the dimension of the array, must satisfy the constraint la1+np1-1×ia1.
The Chebyshev coefficients of the polynomial px. Specifically, element i×ia1+1 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 aintc, below.
5:     ia1 int64int32nag_int scalar
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 Further Comments.
Constraint: ia11.
6:     qatm1 – double scalar
The value that the integrated polynomial is required to have at the lower end point of its interval of definition, i.e., at x-=-1 which corresponds to x=xmin. Thus, qatm1 is a constant of integration and will normally be set to zero by you.
7:     iaint1 int64int32nag_int scalar
The index increment of aintc. Most frequently the Chebyshev coefficients are required in adjacent elements of aintc, and iaint1 must be set to 1. However, if, for example, they are to be stored in aintc1,aintc4,aintc7,, then the value of iaint1 must be 3. See also Further Comments.
Constraint: iaint11.

Optional Input Parameters


Output Parameters

1:     aintclaint – double array
laint=1+np1 ×iaint1.
The Chebyshev coefficients of the integral qx. (The integration is with respect to the variable x, and the constant coefficient is chosen so that qxmin equals qatm1). Specifically, element i×iaint1+1 of aintc contains the coefficient ai, for i=0,1,,n+1. A call of the function may have the array name aintc the same as a, provided that note is taken of the order in which elements are overwritten when choosing starting elements and increments ia1 and iaint1: i.e., the coefficients, a0,a1,,ai-2 must be intact after coefficient ai is stored. In particular it is possible to overwrite the ai entirely by having ia1=iaint1, and the actual array for a and aintc identical.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
On entry,np1<1,
An unexpected error has been triggered by this routine. Please contact NAG.
Your licence key may have expired or may not have been installed correctly.
Dynamic memory allocation failed.


In general there is a gain in precision in numerical integration, in this case associated with the division by 2i in the formula quoted in Description.

Further Comments

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


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 integral of the polynomial from 0.0 to 2.0. (For the purpose of this example, xmin, xmax and the Chebyshev coefficients are simply supplied . Normally a program would read in or generate data and compute the fitted polynomial).
function e02aj_example

fprintf('e02aj example results\n\n');

% Chebyshev coefficients for f(x) on [-0.5,2.5]
xmin = -0.5; xmax = 2.5;
a = [2.53213  1.13032  0.2715  0.04434   0.00547   0.00054  4e-05];

n = int64(6);
ia1 = int64(1);
qatm1 = 0;
iaint1 = int64(1);

% Get integral coefficients aint
[aint, ifail] = e02aj( ...
                       n, xmin, xmax, a, ia1, qatm1, iaint1);

% Evaluate integral from x=0 to x=2 by subtraction
xa = 0;
xb = 2;
[inta, ifail] = e02ak( ...
                       n+1, xmin, xmax, aint, ia1, xa);
[intb, ifail] = e02ak( ...
                       n+1, xmin, xmax, aint, ia1, xb);

res = intb - inta;

fprintf('Value of definite integral = %7.4f\n',res);

e02aj example results

Value of definite integral =  2.1515

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

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