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

Purpose

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

Syntax

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

Description

Given a set of data points (xi,yi)(xi,yi), for i = 1,2,,ni=1,2,,n, nag_fit_1dmmax (e02ac) uses the exchange algorithm to compute an mmth-order polynomial
P(x) = a1 + a2x + a3x2 + + am + 1xm
P(x)=a1+a2x+a3x2++am+1xm
such that maxi 2|P(xi)yi|maxi2|P(xi)-yi| is a minimum.
The function also returns a number whose absolute value is the final reference deviation (see Section [Error Indicators and Warnings]). The function is an adaptation of Boothroyd (1967).

References

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

Parameters

Compulsory Input Parameters

1:     x(n) – double array
The values of the xx coordinates, xixi, for i = 1,2,,ni=1,2,,n.
Constraint: x1 < x2 < < xnx1<x2<<xn.
2:     y(n) – double array
The values of the yy coordinates, yiyi, for i = 1,2,,ni=1,2,,n.
3:     m1 – int64int32nag_int scalar
m + 1m+1, where mm is the order of the polynomial to be found.
Constraint: m1 < min (n,100)m1<min(n,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 nn of data points.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     a(m1) – double array
The coefficients aiai of the final polynomial, for i = 1,2,,m + 1i=1,2,,m+1.
2:     ref – double scalar
The final reference deviation (see Section [Error Indicators and Warnings]).

Error Indicators and Warnings

With exact arithmetic the algorithm should terminate after a finite number of steps. This need not necessarily be the case using computer arithmetic. Should the function start cycling then an exit is made with ref given a negative value. This is by no means an indicator that a catastrophic error has occurred and does not preclude useful results being obtained.
The absolute value of ref is the final reference deviation. See Stieffel (1959) for an explanation of this term.
If an error is detected in an input parameter nag_fit_1dmmax (e02ac) will act as if a soft noisy exit has been requested (see Section [Soft Fail Option] in the (essin)).

Accuracy

This is wholly dependent on the given data points.

Further Comments

The time taken increases with mm.

Example

function nag_fit_1dmmax_example
x = [0;
     0.05;
     0.1;
     0.15;
     0.2;
     0.25;
     0.3;
     0.35;
     0.4;
     0.45;
     0.5;
     0.55;
     0.6;
     0.65;
     0.7;
     0.75;
     0.8;
     0.85;
     0.9;
     0.95;
     1];
y = [1;
     1.051271096376024;
     1.105170918075648;
     1.161834242728283;
     1.22140275816017;
     1.284025416687741;
     1.349858807576003;
     1.419067548593257;
     1.49182469764127;
     1.568312185490169;
     1.648721270700128;
     1.733253017867395;
     1.822118800390509;
     1.915540829013896;
     2.013752707470477;
     2.117000016612675;
     2.225540928492468;
     2.339646851925991;
     2.45960311115695;
     2.585709659315846;
     2.718281828459045];
m1 = int64(6);
[a, ref] = nag_fit_1dmmax(x, y, m1)
 

a =

    1.0000
    1.0001
    0.4991
    0.1704
    0.0348
    0.0139


ref =

   1.0915e-06


function e02ac_example
x = [0;
     0.05;
     0.1;
     0.15;
     0.2;
     0.25;
     0.3;
     0.35;
     0.4;
     0.45;
     0.5;
     0.55;
     0.6;
     0.65;
     0.7;
     0.75;
     0.8;
     0.85;
     0.9;
     0.95;
     1];
y = [1;
     1.051271096376024;
     1.105170918075648;
     1.161834242728283;
     1.22140275816017;
     1.284025416687741;
     1.349858807576003;
     1.419067548593257;
     1.49182469764127;
     1.568312185490169;
     1.648721270700128;
     1.733253017867395;
     1.822118800390509;
     1.915540829013896;
     2.013752707470477;
     2.117000016612675;
     2.225540928492468;
     2.339646851925991;
     2.45960311115695;
     2.585709659315846;
     2.718281828459045];
m1 = int64(6);
[a, ref] = e02ac(x, y, m1)
 

a =

    1.0000
    1.0001
    0.4991
    0.1704
    0.0348
    0.0139


ref =

   1.0915e-06



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