In Interpolation, we were given a set of points , , and asked to construct a polynomial exactly matching these points - more formally,

But this exact fit nature of interpolation isn’t always the best! In the real world, error is inevitable, and our interpolation would fit these errors precisely! In practical applications, this can give us really poor predictions.

Below, we examine various ways we can approximate our functions from given datapoints.

Approximating Given Noisy Data

Problem Defined

Suppose we have noisy data. How can we create a function to best approximate this data?

In general, we can express our datapoints as

Where is some sort of error offseting our true value.

Pick “known” set of functions . For constants , we want to find approximating function

Matching our data for all .

Note that to determine unknowns, we need at least datapoints. However, in most situations, we’ll have an overdetermined situation, where we have data points, meaning we’ll have more conditions than unknowns!

In such situations, it’s not possible to find a “solution” that perfectly fits our data. Thus, we need some notion of best fit! Given our function , we define the residual error at any datapoint to be

This gives us a residual vector

We want to find constants such that the magnitude of this residual vector is minimized (meaning we’ve minimized our residual error), given some norm .

This is known as the Linear Least Squares Problem! The solution is described below.

Linear Least Squares Problem

Let be our approximating function.

For all datapoints , we have approximations given by

We can represent these approximations in the matrix form where , and is our constant vector.

Now, given our vector of true datapoints , we can define our residual error in the matrix form

As mentioned before, we want to minimize the magnitude of this vector! We’ll use the norm to minimize our error. How can we minimize ?

Let’s define a function , where are our constants as

Note that when minimizing these distances, it’s often the case we square the term to get rid of the square root.

We wish to find minimizing , and to do this, we can find when our derivative is 0! Differentiating with respect to any , we find

Continuing this for all , we find that we want to find such that

Otherwise known as the normal equations.

We plug this back into our original equation to obtain

This is a linear system that we can solve for !

Thus, our algorithm for solving the linear least squares problem is as follows:

  1. First, construct from our ‘s and ‘s given.
  2. Then, construct and .
  3. Finally, solve .

Typically, we want to solve the normal equations ourselves, as solving them on a computer can lead to a highly unstable algorithm!

Theorem: Uniqueness of Solutions

If the columns of are linearly independent, then

  1. The normal equations have a unique solution for .
  2. If is this unique solution, then it minimizes the residual error - that is, for all .

Example: Deriving

Let , where

Say we have points . We want function

We are essentially finding a line that minimizes the square of the vertical distances to each point.

To find our constants, we first find as

We use this to find , as

We can use this to solve for !

Linear Least Squares Pros

Note that Linear Least Squares only works well if we know the following about the noise:

  • The average noise has no bias; as in, the average is 0.
  • The noise is uncorrelated.
  • The noise’s variance is approximately the same.

Approximating Given True

Problem Defined

Suppose we have a known function , but it is really complicated. Thus, in practical applications, it may be worth approximating it with a cleaner solution.

How can we create a polynomial of degree that best approximates our function?

In other words, given functions , we want to approximate as

How can we do this?

This is known as the weighted least squares problem.

Weighted Least Squares Problem

Linear Independence

Consider functions that we want to approximate with. These functions are linearly independent if

is only possible for .

Theorem: Independence of Distinct Degrees

If for , is a polynomial of degree , then is linearly independent on any .

We furthermore define as the set of all polynomials on with degree . We can use this to define what polynomials our functions can span.

Theorem: Linear Independence and Span

Let be a set of linearly independent polynomials in . Then, any polynomial in can be uniquely written as a linear combination of .

Weight Functions

We define to be a weight function on if it is continuous and non-negative in , and

In other words, has a positive max.

Given any weight function , the weighted norm of some function on is defined as

Note that if , then our weighted norm is the same as a normal norm!

Problem Solution

We can our weighted norm to get a measure of error / distance!

Let be a weight function, be the function we want to approximate. We want to construct a polynomial minimizing

Or in other words, the weighted distance to .

Let us have a set of polynomials with . Then, given our earlier theorems, we guarantee that any can be uniquely written as

Meaning we can use this set of polynomials to construct our mentioned earlier.

Thus, we want to find constants minimizing

To find this minimum, we’ll find where our derivative is equal to 0. For any , we differentiate with respect to to get

Note that we applied the chain rule here!

Continuing this for all , we get a linear system of equations!

where

Naive Solutions

Making the simplest choice of and , we can simplify this system of equations to

If , we get matrix

known as a Hilbert Matrix. While this matrix is simple, it’s really terrible for error, as it has a condition number that grows extremely fast!

Is there another matrix we could use that’s a better choice?

Note that for any linear system, the easiest matrix we could use to solve it is a diagonal matrix.

If we wanted this for our system, we’d need to define a set of functions that are orthogonal on with respect to . In other words,

We can furthermore say that these functions are orthonormal if the same conditions hold, but . Note that we can convert any orthogonal set into an orthonormal set by taking

We can find such a set using the Gram-Schmidt process of orthonormalization! See the below example.

Gram-Schmidt Orthonormalization (Example)

Suppose we have linearly independent set of functions .

Find the corresponding orthonormal set of functions, given a weight function .

  1. Start with .
  2. Let . Find such that
  3. Let . Find and such that
  4. …

Continue this for all to obtain an orthogonal set. Finally, orthonormalize each function to finish!

If we choose a set of functions to be orthonormal, then becomes the identity matrix, giving us

Which makes it super easy to find an approximation for !

Some important examples of these orthonormal polynomials are given as follows:

  • The Legendre Polynomials: Given , and applying Grahm Schmidt on , we have

    with norm given as

  • The Chebyshev Polynomials: Given on , we get

    With norm given as