For AI agents: use /llms.txt for the Nakafa content index.
Imagine you have a complex optimization problem, but it turns out there's an elegant shortcut. In least squares problems, instead of doing direct optimization, we can transform it into a system of equations that's easier to solve.
When we want to minimize
it turns out the solution can be found by solving the following system of equations
This equation is called the normal equation system because it involves the concept of orthogonality or "normal" (perpendicular) state in vector space.
There's a very interesting relationship between the minimization problem and this normal equation system. Vector x^∈Rn is a solution to the least squares problem if and only if that vector satisfies the normal equation system.
In other words, finding x^ that makes ∥A⋅x−b∥22 minimal is exactly the same as finding x^ that satisfies ATA⋅x^=ATb.
To understand why this relationship holds, we need to look at it from a geometric perspective.
When x^ gives the minimum value for ∥Ax^−b∥22, then the error vector Ax^−b must be orthogonal to all vectors in the column space of matrix A.
This column space consists of all vectors that can be written as Ax for x∈Rn. The orthogonality condition means
for every vector x∈Rn. Using the properties of inner product, we can write
Since this relationship must hold for all vectors x, then
This is what gives us the normal equation system.
We can also verify this result in a different way. Let x^ be the solution of the normal equation system and x be any vector in Rn.
Using the Pythagorean theorem, we can write
Since x^ satisfies the normal equation system, then ATAx^−ATb=0 and the squared norm is always non-negative. Therefore
This inequality proves that x^ indeed gives the minimum value.
Not all normal equation systems can be solved easily. There are special conditions that must be met.
For matrix A∈Rm×n with m≥n, the symmetric matrix ATA∈Rn×n can be inverted if and only if matrix A has full rank, that is Rank(A)=n.
This condition is very important because it determines whether the normal equation system has a unique solution. When ATA can be inverted, the solution can be written explicitly as
To understand when ATA can be inverted, we need to look at the relationship between null space (kernel) and rank.
If ATA can be inverted, then the null space of ATA contains only the zero vector. Since the null space of ATA includes the null space of A, then A also has only the zero vector in its null space. This means Rank(A)=n.
Conversely, if Rank(A)=n, then the equation Ax=0 has only the solution x=0. To see that ATA can be inverted, note that if ATAx=0, then
Since the inner product is only zero when Ax=0, and we know this only happens when x=0, then ATA is indeed invertible.
More than just being invertible, matrix ATA has a special property. When Rank(A)=n and x=0, we have Ax=0 and
This shows that ATA is a positive definite matrix. This property guarantees that the normal equation system not only has a unique solution, but is also numerically stable when solved with computational methods. Algorithms like Cholesky decomposition can be safely used to solve this system.