PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_fit_1dcheb_integ (e02aj)
Purpose
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.
Syntax
Description
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
, for
, of a polynomial
of degree
, where
the function returns the coefficients
, for
, of the polynomial
of degree
, where
and
Here
denotes the Chebyshev polynomial of the first kind of degree
with argument
. It is assumed that the normalized variable
in the interval
was obtained from your original variable
in the interval
by the linear transformation
and that you require the integral to be with respect to the variable
. If the integral with respect to
is required, set
and
.
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
. Initially taking
, the function forms successively
The constant coefficient
is chosen so that
is equal to a specified value,
qatm1, at the lower end point of the interval on which it is defined, i.e.,
, which corresponds to
.
References
Modern Computing Methods (1961) Chebyshev-series NPL Notes on Applied Science 16 (2nd Edition) HMSO
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, the degree of the given polynomial .
Constraint:
.
- 2:
– double scalar
- 3:
– double scalar
-
The lower and upper end points respectively of the interval
. The Chebyshev series representation is in terms of the normalized variable
, where
Constraint:
.
- 4:
– double array
-
la, the dimension of the array, must satisfy the constraint
.
The Chebyshev coefficients of the polynomial
. Specifically, element
of
a must contain the coefficient
, for
. Only these
elements will be accessed.
Unchanged on exit, but see
aintc, below.
- 5:
– 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
. However, if for example, they are stored in
, then the value of
ia1 must be
. See also
Further Comments.
Constraint:
.
- 6:
– 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
which corresponds to
. Thus,
qatm1 is a constant of integration and will normally be set to zero by you.
- 7:
– 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
. However, if, for example, they are to be stored in
, then the value of
iaint1 must be
. See also
Further Comments.
Constraint:
.
Optional Input Parameters
None.
Output Parameters
- 1:
– double array
-
.
The Chebyshev coefficients of the integral
. (The integration is with respect to the variable
, and the constant coefficient is chosen so that
equals
qatm1). Specifically, element
of
aintc contains the coefficient
, for
. 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,
must be intact after coefficient
is stored. In particular it is possible to overwrite the
entirely by having
, and the actual array for
a and
aintc identical.
- 2:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | , |
or | , |
or | , |
or | , |
or | . |
-
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.
Accuracy
In general there is a gain in precision in numerical integration, in this case associated with the division by
in the formula quoted in
Description.
Further Comments
The time taken is approximately proportional to .
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.
Example
Suppose a polynomial has been computed in Chebyshev series form to fit data over the interval
. The following program evaluates the integral of the polynomial from
to
. (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).
Open in the MATLAB editor:
e02aj_example
function e02aj_example
fprintf('e02aj example results\n\n');
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);
[aint, ifail] = e02aj( ...
n, xmin, xmax, a, ia1, qatm1, iaint1);
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)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015