A curve is a list of heights, one at every point. Watch the best constant, line, parabola and cubic close in on .
Projecting a curve
The best constant, line, parabola and cubic for e^x on −1 to 1.
The curve e^x from −1 to 1: a vector with a height at every x.
Describe this picture
A plot of the curve from to . Over about 13 s four fits appear in turn, each growing out of the one before and drawn over the curve with the gap between them shaded: the best constant, 1.1752; the best line, ; the best parabola, ; and the best cubic. The shaded gap shrinks at each step, and a readout gives its length, : 0.930, 0.229, 0.038 and 0.0047. A second readout lists the coefficients on the Legendre building blocks , , , used so far, , which keep their earlier values as each new one joins. The step buttons move from fit to fit. There is no other control.
A curve is a long list
A vector in three dimensions is a list of three numbers. A sampled signal of 1000 samples is a list of 1000 numbers, a vector in 1000 dimensions. Now let the samples get closer and closer together. In the end there is a height at every point of an interval, and the list has become a curve.
Curves can be added and scaled like vectors: adds the heights at each point, and doubles them. So a curve is a vector with a height at every point. The question is how to measure lengths and angles between them.
The inner product
For two lists, the dot product multiplies matching entries and adds them up. For two curves on an interval from to , multiply the heights at each point and add them up with an integral:
This is the inner product of the two functions. The angle brackets replace the dot. The length follows as before, . On the interval from to , the constant function 1 has , so its length is .
Two functions are orthogonal when their inner product is zero. That does not mean their curves cross at a right angle. It means that where is positive and where it is negative, the areas cancel.
Two waves do not overlap
The inner product of two functions is the area under their product.
Two waves on −π to π: sin x and sin 2x.
Describe this picture
Two panels, one above the other, on the interval from to . Above, the curves and . Below, their product, drawn from left to right with the areas above the axis shaded in one colour and the areas below in another. A readout adds up the signed area, which comes to 0. Then the second curve slides over into itself, the product becomes , all above the axis, and the readout gives its area, . The picture has no control.
So and are orthogonal on , while . On , the functions 1 and are orthogonal: , because the area left of 0 cancels the area right of it. The same reason makes and orthogonal on : their product is odd.
Orthogonal polynomials
The powers are not orthogonal on : for example . Run Gram–Schmidt on them, with the integral as the dot product, and you get the Legendre polynomials:
with . They are written with an argument, , so they are not confused with a projection matrix. This page keeps their usual scale, which is not length 1.
Projecting a curve
The best fit to by a combination of orthogonal functions is the projection of Projections, with integrals in place of dot products:
“Best” means that , the length of the gap, is as small as any combination can make it. Each coefficient is a separate shadow, so adding a new never changes the earlier coefficients. That is the second readout in the picture at the top of the page.
Here is on :
- On : , divided by 2: . The best constant is the average height of the curve.
- On : , divided by : .
- On : , divided by : .
- On : the coefficient is .
Written in powers of , the best parabola is . The coefficients in powers of do change from fit to fit, because the powers are not orthogonal; only the coefficients on the stay fixed.
The gap shrinks fast. Its squared length is after the constant, after the line, and after the parabola. Each step removes the square of the new shadow’s length, the right-angle rule again. The lengths in the readout are the square roots: 0.930, 0.229, 0.038, and 0.0047 after the cubic.
Compare a Taylor parabola, , which copies perfectly near . At it gives , while the projection gives and the truth is . Over the whole interval, the largest miss of the Taylor parabola is , and of the projection only . Taylor is best at one point; the projection is best across the interval.
Worked example
- Orthogonal. On , , and .
- Sines. On , and ; and are orthogonal, odd times even.
- The best constant. For on , the best constant is its average, .
- The best parabola. , with a gap of length .
- A straight line by sines. Project on onto , , . Each coefficient is : , and . The squared length of is . After one, two and three sines, the squared gap is , and : each sine removes times its coefficient squared.
Where you’ll meet this
A maths library computes or by first moving into a short interval, then evaluating a polynomial chosen to be close to best there. A Fourier series is a projection onto sines and cosines, and keeping more of them shrinks the gap, as item 5 does for a straight line.
In signal processing · projections onto harmonics
Convergence and the Gibbs phenomenon shows a Fourier series as a projection onto the harmonics: the closest fit in this page’s sense, with an overshoot at every jump. Analog prototype filters builds its Chebyshev filters on Chebyshev polynomials, another family of orthogonal polynomials.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Inner product | the dot product for curves | |
| Length | ||
| Orthogonal | areas of cancel | |
| Legendre | orthogonal on ; | |
| Projection | orthogonal | |
| Gap | shrinks as terms are added | |
| on | gaps 0.930, 0.229, 0.038, 0.0047 | constant, line, parabola, cubic |