In Calculus I we spend a fair amount of time talking about how nicely the tangent line fits a smooth curve.
But truth be told, it fits only near the point of tangency. How can we find the best approximating line for a function on a given interval?
A natural measure of quality of approximation is the maximum deviation of the curve from the line, where are the coefficients in the line equation, to be determined. We need that minimize .
The Chebyshev equioscillation theorem is quite useful here. For one thing, its name contains the letter combination uio, which Scrabble players may appreciate. (Can you think of other words with this combination?) Also, its statement does not involve concepts outside of Calculus I. Specialized to the case of linear fit, it says that are optimal if and only if there exist three numbers in such that the deviations
- are equal to in absolute value: for
- have alternating signs:
Let’s consider what this means. First, unless is an endpoint of . Since cannot be an endpoint, we have .
Furthermore, takes the same value at and . This gives an equation for
which can be rewritten in the form resembling the Mean Value Theorem:
If is strictly monotone, there can be only one with . Hence and in this case, and we find by solving (2). This gives , and then is not hard to find.
Here is how I did this in Sage:
var('x a b') f = sin(x) # or another function df = f.diff(x) a = # left endpoint b = # right endpoint
That was the setup. Now the actual computation:
var('x1 x2 x3') x1 = a x3 = b x2 = find_root(f(x=x1)-df(x=x2)*x1 == f(x=x3)-df(x=x2)*x3, a, b) alpha = df(x=x2) beta = 1/2*(f(x=x1)-alpha*x1 + f(x=x2)-alpha*x2) show(plot(f,a,b)+plot(alpha*x+beta,a,b,color='red'))
However, the algorithm fails to properly fit a line to the sine function on :
The problem is, is no longer monotone, making it possible for two of to be interior points. Recalling the identities for cosine, we see that these points must be symmetric about . One of must still be an endpoint, so either (and ) or (and ). The first option works:
This same line is also the best fit on the full period . It passes through and has the slope of which is not a number I can recognize.
On the interval , all three of the above approaches fail:
Luckily we don’t need a computer in this case. Whenever has at least three points of maximum with alternating signs of , the Chebyshev equioscillation theorem implies that the best linear fit is the zero function.