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_2dcheb_eval (e02cb)

Purpose

nag_fit_2dcheb_eval (e02cb) evaluates a bivariate polynomial from the rectangular array of coefficients in its double Chebyshev series representation.

Syntax

[ff, ifail] = e02cb(mfirst, k, l, x, xmin, xmax, y, ymin, ymax, a, 'mlast', mlast)
[ff, ifail] = nag_fit_2dcheb_eval(mfirst, k, l, x, xmin, xmax, y, ymin, ymax, a, 'mlast', mlast)

Description

This function evaluates a bivariate polynomial (represented in double Chebyshev form) of degree kk in one variable, xx-, and degree ll in the other, yy-. The range of both variables is 1-1 to + 1+1. However, these normalized variables will usually have been derived (as when the polynomial has been computed by nag_fit_2dcheb_lines (e02ca), for example) from your original variables xx and yy by the transformations
x = (2x(xmax + xmin))/((xmaxxmin))  and  y = (2y(ymax + ymin))/((ymaxymin)).
x-=2x-(xmax+xmin) (xmax-xmin)   and  y-=2y-(ymax+ymin) (ymax-ymin) .
(Here xminxmin and xmaxxmax are the ends of the range of xx which has been transformed to the range 1-1 to + 1+1 of xx-. yminymin and ymaxymax are correspondingly for yy. See Section [Further Comments]). For this reason, the function has been designed to accept values of xx and yy rather than xx- and yy-, and so requires values of xminxmin, etc. to be supplied by you. In fact, for the sake of efficiency in appropriate cases, the function evaluates the polynomial for a sequence of values of xx, all associated with the same value of yy.
The double Chebyshev series can be written as
kl
aijTi(x)Tj(y),
i = 0j = 0
i=0kj=0laijTi(x-)Tj(y-),
where Ti(x)Ti(x-) is the Chebyshev polynomial of the first kind of degree ii and argument xx-, and Tj(y)Tj(y-) is similarly defined. However the standard convention, followed in this function, is that coefficients in the above expression which have either ii or jj zero are written (1/2)aij12aij, instead of simply aijaij, and the coefficient with both ii and jj zero is written (1/4)a0,014a0,0.
The function first forms ci = j = 0laijTj(y)ci=j=0laijTj(y-), with ai,0ai,0 replaced by (1/2)ai,012ai,0, for each of i = 0,1,,ki=0,1,,k. The value of the double series is then obtained for each value of xx, by summing ci × Ti(x)ci×Ti(x-), with c0c0 replaced by (1/2)c012c0, over i = 0,1,,ki=0,1,,k. The Clenshaw three term recurrence (see Clenshaw (1955)) with modifications due to Reinsch and Gentleman (1969) is used to form the sums.

References

Clenshaw C W (1955) A note on the summation of Chebyshev series Math. Tables Aids Comput. 9 118–120
Gentleman W M (1969) An error analysis of Goertzel's (Watt's) method for computing Fourier coefficients Comput. J. 12 160–165

Parameters

Compulsory Input Parameters

1:     mfirst – int64int32nag_int scalar
The index of the first and last xx value in the array xx at which the evaluation is required respectively (see Section [Further Comments]).
Constraint: mlastmfirstmlastmfirst.
2:     k – int64int32nag_int scalar
3:     l – int64int32nag_int scalar
The degree kk of xx and ll of yy, respectively, in the polynomial.
Constraint: k0k0 and l0l0.
4:     x(mlast) – double array
mlast, the dimension of the array, must satisfy the constraint mlastmfirstmlastmfirst.
x(i)xi, for i = mfirst,,mlasti=mfirst,,mlast, must contain the xx values at which the evaluation is required.
Constraint: xminx(i)xmaxxminxixmax, for all ii.
5:     xmin – double scalar
6:     xmax – double scalar
The lower and upper ends, xminxmin and xmaxxmax, of the range of the variable xx (see Section [Description]).
The values of xmin and xmax may depend on the value of yy (e.g., when the polynomial has been derived using nag_fit_2dcheb_lines (e02ca)).
Constraint: xmax > xminxmax>xmin.
7:     y – double scalar
The value of the yy coordinate of all the points at which the evaluation is required.
Constraint: yminyymaxyminyymax.
8:     ymin – double scalar
9:     ymax – double scalar
The lower and upper ends, yminymin and ymaxymax, of the range of the variable yy (see Section [Description]).
Constraint: ymax > yminymax>ymin.
10:   a(na) – double array
na, the dimension of the array, must satisfy the constraint na(k + 1) × (l + 1)na(k+1)×(l+1), the number of coefficients in a polynomial of the specified degree.
The Chebyshev coefficients of the polynomial. The coefficient aijaij defined according to the standard convention (see Section [Description]) must be in a(i × (l + 1) + j + 1)ai×(l+1)+j+1.

Optional Input Parameters

1:     mlast – int64int32nag_int scalar
Default: For mlast, the dimension of the array x.
The index of the first and last xx value in the array xx at which the evaluation is required respectively (see Section [Further Comments]).
Constraint: mlastmfirstmlastmfirst.

Input Parameters Omitted from the MATLAB Interface

na work nwork

Output Parameters

1:     ff(mlast) – double array
ff(i)ffi gives the value of the polynomial at the point (xi,y)(xi,y), for i = mfirst,,mlasti=mfirst,,mlast.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,mfirst > mlastmfirst>mlast,
ork < 0k<0,
orl < 0l<0,
orna < (k + 1) × (l + 1)na<(k+1)×(l+1),
ornwork < k + 1nwork<k+1.
  ifail = 2ifail=2
On entry,yminymaxyminymax,
ory < yminy<ymin,
ory > ymaxy>ymax.
  ifail = 3ifail=3
On entry,xminxmaxxminxmax,
orx(i) < xminxi<xmin, or x(i) > xmaxxi>xmax, for some i = mfirst,mfirst + 1,,mlasti=mfirst,mfirst+1,,mlast.

Accuracy

The method is numerically stable in the sense that the computed values of the polynomial are exact for a set of coefficients which differ from those supplied by only a modest multiple of machine precision.

Further Comments

The time taken is approximately proportional to (k + 1) × (m + l + 1)(k+1)×(m+l+1), where m = mlastmfirst + 1m=mlast-mfirst+1, the number of points at which the evaluation is required.
This function is suitable for evaluating the polynomial surface fits produced by the function nag_fit_2dcheb_lines (e02ca), which provides the double array a in the required form. For this use, the values of yminymin and ymaxymax supplied to the present function must be the same as those supplied to nag_fit_2dcheb_lines (e02ca). The same applies to xminxmin and xmaxxmax if they are independent of yy. If they vary with yy, their values must be consistent with those supplied to nag_fit_2dcheb_lines (e02ca) (see Section [Further Comments] in (e02ca)).
The parameters mfirst and mlast are intended to permit the selection of a segment of the array x which is to be associated with a particular value of yy, when, for example, other segments of x are associated with other values of yy. Such a case arises when, after using nag_fit_2dcheb_lines (e02ca) to fit a set of data, you wish to evaluate the resulting polynomial at all the data values. In this case, if the parameters x, y, mfirst and mlast of the present function are set respectively (in terms of parameters of nag_fit_2dcheb_lines (e02ca)) to x, y(S)y(S), 1 + i = 1s1m(i)1+i=1 s-1m(i) and i = 1sm(i)i=1sm(i), the function will compute values of the polynomial surface at all data points which have y(S)yS as their yy coordinate (from which values the residuals of the fit may be derived).

Example

function nag_fit_2dcheb_eval_example
mfirst = int64(1);
k = int64(3);
l = int64(2);
x = [0.5;
     1;
     1.5;
     2;
     2.5;
     3;
     3.5;
     4;
     4.5];
xmin = 0.1;
xmax = 4.5;
y = 1;
ymin = 0;
ymax = 4;
a = [15.3482;
     5.15073;
     0.1014;
     1.14719;
     0.14419;
     -0.10464;
     0.04901;
     -0.00314;
     -0.00699;
     0.00153;
     -0.00033;
     -0.00022];
[ff, ifail] = nag_fit_2dcheb_eval(mfirst, k, l, x, xmin, xmax, y, ymin, ymax, a)
 

ff =

    2.0812
    2.1888
    2.3018
    2.4204
    2.5450
    2.6758
    2.8131
    2.9572
    3.1084


ifail =

                    0


function e02cb_example
mfirst = int64(1);
k = int64(3);
l = int64(2);
x = [0.5;
     1;
     1.5;
     2;
     2.5;
     3;
     3.5;
     4;
     4.5];
xmin = 0.1;
xmax = 4.5;
y = 1;
ymin = 0;
ymax = 4;
a = [15.3482;
     5.15073;
     0.1014;
     1.14719;
     0.14419;
     -0.10464;
     0.04901;
     -0.00314;
     -0.00699;
     0.00153;
     -0.00033;
     -0.00022];
[ff, ifail] = e02cb(mfirst, k, l, x, xmin, xmax, y, ymin, ymax, a)
 

ff =

    2.0812
    2.1888
    2.3018
    2.4204
    2.5450
    2.6758
    2.8131
    2.9572
    3.1084


ifail =

                    0



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–2013