nag_1d_minimax_polynomial (e02alc) (PDF version)
e02 Chapter Contents
e02 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_1d_minimax_polynomial (e02alc)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_1d_minimax_polynomial (e02alc) calculates a minimax polynomial fit to a set of data points.

2  Specification

#include <nag.h>
#include <nage02.h>
void  nag_1d_minimax_polynomial (Integer n, const double x[], const double y[], Integer m, double a[], double *ref, NagError *fail)

3  Description

Given a set of data points xi,yi, for i=1,2,,n, nag_1d_minimax_polynomial (e02alc) uses the exchange algorithm to compute an mth-degree polynomial
Px = a0 + a1x + a2 x2 + + am xm  
such that maxiPxi-yi is a minimum.
The function also returns a number whose absolute value is the final reference deviation (see Section 5). The function is an adaptation of Boothroyd (1967).

4  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

5  Arguments

1:     n IntegerInput
On entry: n, the number of data points.
Constraint: n1.
2:     x[n] const doubleInput
On entry: the values of the x coordinates, xi, for i=1,2,,n.
Constraint: x1<x2<<xn.
3:     y[n] const doubleInput
On entry: the values of the y coordinates, yi, for i=1,2,,n.
4:     m IntegerInput
On entry: m, where m is the degree of the polynomial to be found.
Constraint: 0m<min100,n-1.
5:     a[m+1] doubleOutput
On exit: the coefficients ai of the minimax polynomial, for i=0,1,,m.
6:     ref double *Output
On exit: the final reference deviation, i.e., the maximum deviation of the computed polynomial evaluated at xi from the reference values yi, for i=1,2,,n. ref may return a negative value which indicates that the algorithm started to cycle due to round-off errors.
7:     fail NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.2.1.2 in the Essential Introduction for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, m=value.
Constraint: m<100.
On entry, m=value.
Constraint: m0.
On entry, n=value.
Constraint: n1.
NE_INT_2
On entry, m=value and n=value.
Constraint: m<n-1.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 3.6.6 in the Essential Introduction for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 3.6.5 in the Essential Introduction for further information.
NE_NOT_STRICTLY_INCREASING
On entry, i=value, x[i]=value and x[i-1]=value.
Constraint: x[i]>x[i-1].

7  Accuracy

This is dependent on the given data points and on the degree of the polynomial. The data points should represent a fairly smooth function which does not contain regions with markedly different behaviours. For large numbers of data points (n>100, say), rounding error will affect the computation regardless of the quality of the data; in this case, relatively small degree polynomials (mn) may be used when this is consistent with the required approximation. A limit of 99 is placed on the degree of polynomial since it is known from experiment that a complete loss of accuracy often results from using such high degree polynomials in this form of the algorithm.

8  Parallelism and Performance

nag_1d_minimax_polynomial (e02alc) is not threaded by NAG in any implementation.
nag_1d_minimax_polynomial (e02alc) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9  Further Comments

The time taken increases with m.

10  Example

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.

10.1  Program Text

Program Text (e02alce.c)

10.2  Program Data

Program Data (e02alce.d)

10.3  Program Results

Program Results (e02alce.r)


nag_1d_minimax_polynomial (e02alc) (PDF version)
e02 Chapter Contents
e02 Chapter Introduction
NAG Library Manual

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