[Math] how to find the best polynomial approximation to discontinuous function on floating point domain

approximation-theory

I have several discontinuous functions on $f : \mathbb{R} -> \mathbb{R}$ for which I wish to find the best/Chebychev/minimax polynomial approximations in some interval $[a,b]$ for use in a computer program.

Currently Im using a best approximation to a continuous alternative $f'$ which is "close" to $f$, $|f(x)-f'(x)|<d$ where $d$ is half the largest discontinuity in $f$ on interval $[a,b]$.

This is suboptimal because the maximum error only occurs in the $\mathbb{R}$ domain while the approximation is only used on the floating point $\mathbb{F} \subset \mathbb{R}$ domain.

Question: How should I be finding the best (as in Chebychev/minimax) approximation of a discontinuous function on a discrete domain ?

The following contrived example may illustrate the problem as I perceive it. Consider a real valued step function using a cubic spline as the alternative continuous function.

discrete sampled step function

The optimal approximation (using a spline!) is one where the smoothing introduced by the spline exists between the discrete sampling points of the floating point domain so that it is correct at the sampling points.
However this is not the spline that would be chosen by choosing the "closest" spline when evaluated in the real domain.

Note: In my usage, the interval $[a,b]$ has consistent sign (either $a < b \le 0$ or $0 \le a < b$) so the precision of floating point discretisation is necessarily asymmetrical so I believe there is always some advantage to considering it.

Im assuing Im not the first to consider this problem, so the question is:

What techniques are recommended for finding the best (as in Chebychev/minimax) approximation of a discontinuous function on a discrete domain ?

Best Answer

While polynomials can be used for the job, you are much better off using two different functions on either side of the discontinuity, and performing a simple "if" test in your code to determine which one to use.

In fact, for reasons of computational efficiency, it is quite common for special function math libraries to use different expressions to evaluate functions in different argument regimes even when the function is well-behaved.