NAG Library Routine Document

e02acf  (withdraw_1dmmax)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

e02acf calculates a minimax polynomial fit to a set of data points.

2
Specification

Fortran Interface
Subroutine e02acf ( x, y, n, a, m1, ref)
Integer, Intent (In):: n, m1
Real (Kind=nag_wp), Intent (In):: x(n), y(n)
Real (Kind=nag_wp), Intent (Out):: a(m1), ref
C Header Interface
#include nagmk26.h
void  e02acf_ ( const double x[], const double y[], const Integer *n, double a[], const Integer *m1, double *ref)

3
Description

Given a set of data points xi,yi, for i=1,2,,n, e02acf uses the exchange algorithm to compute an mth-order polynomial
Px=a1+a2x+a3x2++am+1xm  
such that maxi2Pxi-yi is a minimum.
The routine also returns a number whose absolute value is the final reference deviation (see Section 6). The routine 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:     xn – Real (Kind=nag_wp) arrayInput
On entry: the values of the x coordinates, xi, for i=1,2,,n.
Constraint: x1<x2<<xn.
2:     yn – Real (Kind=nag_wp) arrayInput
On entry: the values of the y coordinates, yi, for i=1,2,,n.
3:     n – IntegerInput
On entry: the number n of data points.
4:     am1 – Real (Kind=nag_wp) arrayOutput
On exit: the coefficients ai of the final polynomial, for i=1,2,,m+1.
5:     m1 – IntegerInput
On entry: m+1, where m is the order of the polynomial to be found.
Constraint: m1<minn,100.
6:     ref – Real (Kind=nag_wp)Output
On exit: the final reference deviation (see Section 6).

6
Error Indicators and Warnings

If an error is detected in an input argument e02acf will act as if a soft noisy exit has been requested (see Section 3.4.4 in How to Use the NAG Library and its Documentation).

7
Accuracy

This is wholly dependent on the given data points.

8
Parallelism and Performance

e02acf 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 routine. 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 (e02acfe.f90)

10.2
Program Data

None.

10.3
Program Results

Program Results (e02acfe.r)

GnuplotProduced by GNUPLOT 4.6 patchlevel 3 0 0.5 1 1.5 2 2.5 3 0 0.2 0.4 0.6 0.8 1 1e−07 1e−06 1e−05 0.0001 0.001 Polynomial P(x) |P(x) -exp(x)| x Example Program Minimax Fit to the Exponential Function on the Interval [0,1] using a Degree Five Polynomial, P(x), given exp(x) Evaluated at 21 Points |P(x) - exp(x)| polynomial fit gnuplot_plot_1 points on exp(x) gnuplot_plot_2 gnuplot_plot_3
© The Numerical Algorithms Group Ltd, Oxford, UK. 2017