A Review of the FunctionApproximations package

Ken Levasseur
Mathematical Sciences
UMass Lowell
Kenneth_Levasseur@uml.edu

Introduction

The Approximations  package provides a variety of functions for approximating functions by rational functions.

Needs["FunctionApproximations`"]

Given a function f defined on an interval [a,b], the basic problem this addresses is that of finding a rational function  r(x) = ((p(x))/(q(x))), where p(x) and q(x) are polynomials with some specified maximal degrees, such that f and r are as close as possible in some sense.

In this review, we will approximate this function.  If you are reading a Mathematica Notebook, you can change the function to one you might prefer.

f[x_]:=(E^(- x))

Minimization of Relative Error

Here is how to approximate our function in the relative minimax sense.  First we approximate with polynomials of degree 2 or less.

r20=MiniMaxApproximation[f[x], {x, {0,1}, 2,0}]

The output has several parts.  The first part is the list of locations of relative maxima in the error.

r20[[1]]

The second part of the output has two parts.  The first is the approximating function itself.

r20[[2,1]]

The second part of the second part is the maximum error

r20[[2,2]]

Here is a plot of the error function

Plot[f[x]-r20[[2,1]],{x,0,1}]

Here is an approximation by a rational function with degrees 1 and 2 for the numerator and denominator.

r12=MiniMaxApproximation[f[x], {x, {0,1}, 1,2}]

Notice that the error is considerably smaller in this case.

Plot[f[x]-r12[[2,1]],{x,0,1}]

Minimization of Absolute Error

Minimization of absolute error is done with GeneralMiniMaxApproximation:

rg20=GeneralMiniMaxApproximation[{t,f[t],1}, {t, {0,1},2,0},x]

Notice how the maximum error is attained at all four extremes of the error function.

Plot[f[x]-rg20[[2,1]],{x,0,1}]

Other weight functions can be used in the third part of the first argument

rgw20=GeneralMiniMaxApproximation[{t,f[t],(E^(-3t))}, {t, {0,1},2,0},x]

Plot[f[x]-rgw20[[2,1]],{x,0,1}]

Not everything goes well

I haven't had a chance to experiment with the Brake option that is mentioned in the message below.

sinapprox=GeneralMiniMaxApproximation[{t,Sin[t],1}, {t, {0,Pi},2,0},x]

Plot[Sin[x]-sinapprox[[2]],{x,0,Pi}]