14. Least Squares and Applications

Solving Approximation Problems

Solving Approximation Problems

students, in many real situations we do not get perfect data. A line may not pass through every point, a model may not match every measurement, and the β€œbest” answer may mean the closest possible answer rather than an exact one. That is the core idea behind least squares and approximation problems πŸ“ˆ

In this lesson, you will learn how linear algebra helps us solve problems where exact solutions are impossible or unnecessary. By the end, you should be able to:

  • explain what an approximation problem is and why it matters,
  • use linear algebra ideas to find the best approximate solution,
  • connect approximation problems to least squares,
  • describe how these methods are used in science, engineering, and data analysis,
  • use examples to show how the method works.

Why Approximation Problems Appear

Many systems in real life give us more information than can be satisfied exactly. For example, suppose a company measures the relationship between advertising spending and sales πŸ“Š The data points may look roughly linear, but no single line passes through every point. Or imagine trying to estimate a value using several sensors. Because of measurement errors, the readings will not all agree perfectly.

In linear algebra, an approximation problem often looks like this: we want to solve $A\mathbf{x}=\mathbf{b}$, but there is no exact solution. That happens when the equations are inconsistent, often because there are more equations than unknowns or because the data contain noise. Instead of demanding exact equality, we look for the vector $\mathbf{x}$ that makes $A\mathbf{x}$ as close as possible to $\mathbf{b}$.

The key idea is to minimize the error vector

$$\mathbf{r}=\mathbf{b}-A\mathbf{x}$$

which is called the residual. The goal is to make $\|\mathbf{r}\|$ as small as possible. The most common choice is the least squares solution, which minimizes $\|\mathbf{b}-A\mathbf{x}\|^2$.

The Big Idea of Least Squares

students, here is the main question: if no exact solution exists, what is the best possible one? The least squares method answers that question by choosing $\mathbf{x}$ so that the total squared error is as small as possible.

Why square the error? Squaring does two useful things. First, it makes all errors positive, so positive and negative differences do not cancel out. Second, it gives a smooth function that is easier to work with in algebra and calculus. For a system $A\mathbf{x}=\mathbf{b}$, the least squares problem is:

$$\min_{\mathbf{x}} \|A\mathbf{x}-\mathbf{b}\|^2$$

This means we search for the vector $\mathbf{x}$ that makes the output $A\mathbf{x}$ as close as possible to $\mathbf{b}$.

A very important geometric idea is projection. The vector $A\mathbf{x}$ is the point in the column space of $A$ closest to $\mathbf{b}$. In other words, we are projecting $\mathbf{b}$ onto the column space of $A$ πŸ” The residual $\mathbf{r}=\mathbf{b}-A\mathbf{x}$ is perpendicular to that column space.

That perpendicularity leads to the normal equations:

$$A^T A\mathbf{x}=A^T\mathbf{b}$$

These equations often let us compute the least squares solution even when the original system has no exact solution.

Solving a Simple Approximation Problem

Suppose we want to fit a line $y=mx+c$ to data points. The data may be inconsistent, so we cannot find a line through every point. Instead, we find the line that best fits the data in the least squares sense.

For example, imagine we have three points: $(1,2)$, $(2,2)$, and $(3,4)$. A line $y=mx+c$ gives the equations

$$m(1)+c=2$$

$$m(2)+c=2$$

$$m(3)+c=4$$

This is an overdetermined system: three equations but only two unknowns, $m$ and $c$. Since the points do not lie exactly on one line, there may be no exact solution.

We can write the system in matrix form as

$$\begin{bmatrix}1 & 1\\2 & 1\\3 & 1\end{bmatrix}\begin{bmatrix}m\c\end{bmatrix}=\begin{bmatrix}2\\2\\4\end{bmatrix}$$

Here, $A=\begin{bmatrix}1 & 1\\2 & 1\\3 & 1\end{bmatrix}$ and $\mathbf{b}=\begin{bmatrix}2\\2\\4\end{bmatrix}$. To find the least squares solution, we solve

$$A^T A\mathbf{x}=A^T\mathbf{b}$$

where $\mathbf{x}=\begin{bmatrix}m\c\end{bmatrix}$.

First compute

$$A^T A=\begin{bmatrix}14 & 6\\6 & 3\end{bmatrix}$$

and

$$A^T\mathbf{b}=\begin{bmatrix}18\\8\end{bmatrix}$$

So we solve

$$\begin{bmatrix}14 & 6\\6 & 3\end{bmatrix}\begin{bmatrix}m\c\end{bmatrix}=\begin{bmatrix}18\\8\end{bmatrix}$$

This gives the least squares line. The exact arithmetic is less important than the process: set up the matrix, form the normal equations, and solve for the best fit ✏️

Geometry of the Solution

The geometric meaning is one of the most important parts of this topic. The columns of $A$ span a subspace called the column space. Every vector of the form $A\mathbf{x}$ lies in that space. If $\mathbf{b}$ is not in that space, then no exact solution exists.

The least squares solution finds the point in the column space closest to $\mathbf{b}$. That closest point is $A\mathbf{x}$, and the difference $\mathbf{r}=\mathbf{b}-A\mathbf{x}$ is orthogonal to every column of $A$. This means

$$A^T\mathbf{r}=\mathbf{0}$$

which is the same as the normal equation

$$A^T(A\mathbf{x}-\mathbf{b})=\mathbf{0}$$

This orthogonality is powerful because it turns an approximation problem into an algebra problem. Instead of guessing a good answer, we use the structure of the matrix to find the closest one.

A real-world way to think about this is a map app trying to estimate your location from multiple signals πŸ“‘ The estimated position may not satisfy every signal exactly, so the app chooses the location that best balances all the information.

Applications in the Real World

Approximation problems appear everywhere in Linear Algebra.

In science, least squares helps fit models to experimental data. A researcher may measure how temperature changes over time and want a function that captures the trend.

In engineering, it is used to estimate unknown quantities from sensor data. If several measurements are slightly off, least squares gives the most consistent estimate.

In economics and business, it helps build prediction models. For example, a company may use past sales, price, and advertising data to estimate future sales.

In computer graphics, approximation is used to compress data and reconstruct smooth curves. In navigation systems, least squares helps combine noisy measurements from satellites.

These applications all share the same pattern: the data are not perfect, but a best-fit model is useful and often necessary.

Common Mistakes and How to Avoid Them

One common mistake is thinking that an approximate solution is β€œwrong.” In fact, when data contain noise or the system is inconsistent, approximation is the correct mathematical goal. The point is not exact equality but best fit.

Another mistake is confusing the residual $\mathbf{b}-A\mathbf{x}$ with the error in the variables themselves. The residual measures how far the model output is from the observed data. It is not always the same as the error in each parameter.

A third mistake is forgetting that least squares minimizes the squared length $\|\mathbf{b}-A\mathbf{x}\|^2$, not just the length itself. The square makes the optimization easier and changes the algebraic form of the solution.

When solving problems, students, always check these steps:

  1. Write the system in matrix form.
  2. Decide whether the system is consistent.
  3. If not, form the normal equations $A^T A\mathbf{x}=A^T\mathbf{b}$.
  4. Solve for the least squares solution.
  5. Interpret the result in the context of the problem.

Conclusion

Solving approximation problems is a central part of least squares and applications. It gives a way to work with imperfect data, inconsistent systems, and real-world measurements that do not line up exactly. The main idea is simple but powerful: when an exact solution does not exist, choose the one that makes the error as small as possible.

Through matrix form, residuals, projections, and the normal equations, linear algebra gives us a clear method for finding best-fit solutions. This is why least squares is used so widely in science, engineering, and data analysis. students, understanding approximation problems helps you see that mathematics is not only about perfect answers; it is also about the best possible answer in a messy world 🌍

Study Notes

  • An approximation problem asks for the best possible solution when an exact solution does not exist.
  • In least squares, we minimize $\|A\mathbf{x}-\mathbf{b}\|^2$.
  • The residual is $\mathbf{r}=\mathbf{b}-A\mathbf{x}$.
  • The least squares solution satisfies $A^T A\mathbf{x}=A^T\mathbf{b}$.
  • Geometrically, $A\mathbf{x}$ is the projection of $\mathbf{b}$ onto the column space of $A$.
  • The residual is orthogonal to the column space of $A$.
  • Approximation problems are common in fitting lines, predicting data, and estimating values from noisy measurements.
  • Least squares is important because it turns messy real-world data into a structured linear algebra problem.

Practice Quiz

5 questions to test your understanding

Solving Approximation Problems β€” Linear Algebra | A-Warded