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_withdraw_1dmmax (e02ac)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


nag_fit_1dmmax (e02ac) calculates a minimax polynomial fit to a set of data points.


[a, ref] = e02ac(x, y, m1, 'n', n)
[a, ref] = nag_fit_withdraw_1dmmax(x, y, m1, 'n', n)


Given a set of data points xi,yi, for i=1,2,,n, nag_fit_1dmmax (e02ac) uses the exchange algorithm to compute an mth-order polynomial
such that maxi2Pxi-yi is a minimum.
The function also returns a number whose absolute value is the final reference deviation (see Error Indicators and Warnings). The function is an adaptation of Boothroyd (1967).


Boothroyd J B (1967) Algorithm 318 Comm. ACM 10 801
Stieffel E (1959) Numerical methods of Tchebycheff approximation On Numerical Approximation (ed R E Langer) 217–232 University of Wisconsin Press


Compulsory Input Parameters

1:     xn – double array
The values of the x coordinates, xi, for i=1,2,,n.
Constraint: x1<x2<<xn.
2:     yn – double array
The values of the y coordinates, yi, for i=1,2,,n.
3:     m1 int64int32nag_int scalar
m+1, where m is the order of the polynomial to be found.
Constraint: m1<minn,100.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the dimension of the arrays x, y. (An error is raised if these dimensions are not equal.)
The number n of data points.

Output Parameters

1:     am1 – double array
The coefficients ai of the final polynomial, for i=1,2,,m+1.
2:     ref – double scalar
The final reference deviation (see Error Indicators and Warnings).

Error Indicators and Warnings


This is wholly dependent on the given data points.

Further Comments

The time taken increases with m.


This example calculates a minimax fit with a polynomial of degree 5 to the exponential function evaluated at 21 points over the interval 0,1. It then prints values of the function and the fitted polynomial.
function e02ac_example

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

x = [0:0.05:1]';
y = exp(x);

m1 = int64(6);
[a, ref] = e02ac(x, y, m1);

disp('Polynomial coefficients');
fprintf('\nReference deviation = %10.2e\n\n',ref);

z = x(1:2:end);
pz = polyval(a(end:-1:1),z);
expz = exp(z);
resz = pz - expz;
fprintf('        x     Fit       exp(x) Residual(*10^-6)\n');
disp([z pz expz resz*10^6]);

e02ac example results

Polynomial coefficients

Reference deviation =   1.09e-06

        x     Fit       exp(x) Residual(*10^-6)
         0    1.0000    1.0000   -1.0915
    0.1000    1.1052    1.1052    0.9740
    0.2000    1.2214    1.2214   -0.7439
    0.3000    1.3499    1.3499   -0.9175
    0.4000    1.4918    1.4918    0.2988
    0.5000    1.6487    1.6487    1.0915
    0.6000    1.8221    1.8221    0.4586
    0.7000    2.0138    2.0138   -0.8163
    0.8000    2.2255    2.2255   -0.8419
    0.9000    2.4596    2.4596    0.8755
    1.0000    2.7183    2.7183   -1.0915

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