Section A.5 Inner product and projections
Note: 1–2 lectures
Subsection A.5.1 Inner product and orthogonality
To do basic geometry, we need length, and we need angles. We have already seen the euclidean length, so let us figure out how to compute angles. Mostly, we are worried about the right angle.
1
When Euclid defined angles in his Elements, the only angle he ever really defined was the right angle.
Given two (column) vectors in we define the (standard) inner product as the dot product:
Why do we seemingly give a new notation for the dot product ( instead of just )? Because there are other possible inner products, which are not the dot product, although we will not worry about others here. An inner product can even be defined on spaces of functions as we do in Chapter 4:
But we digress.
The inner product satisfies the following rules:
and if and only if and
Anything that satisfies the properties above can be called an inner product, although in this section we are concerned with the standard inner product in
You may recall from multivariable calculus, that in two or three dimensions, the standard inner product (the dot product) gives you the angle between the vectors:
In (any dimension), we are simply going to say that from the formula is what the angle is. This makes sense as any two vectors based at the origin lie in a 2-dimensional plane (subspace), and the formula works in 2 dimensions. In fact, one could even talk about angles between functions this way, and we do in Chapter 4, where we talk about orthogonal functions (functions at right angle to each other).
To compute the angle we compute
Our angles are always in radians. We are computing the cosine of the angle, which is really the best we can do. Given two vectors at an angle we can give the angle as etc., see Figure A.5. Fortunately, If we solve for using the inverse cosine we can just decree that
As we said, the most important angle is the right angle. A right angle is radians, and so the formula is particularly easy in this case. We say vectors and are orthogonal if they are at right angles, that is if
The vectors and are orthogonal. So are and However, and are not orthogonal as their inner product is and not 0.
Subsection A.5.2 Orthogonal projection
A typical application of linear algebra is to take a difficult problem, write everything in the right basis, and in this new basis the problem becomes simple. A particularly useful basis is an orthogonal basis, that is a basis where all the basis vectors are orthogonal. When we draw a coordinate system in two or three dimensions, we almost always draw our axes as orthogonal to each other.
Generalizing this concept to functions, it is particularly useful in Chapter 4 to express a function using a particular orthogonal basis, the Fourier series.
To express one vector in terms of an orthogonal basis, we need to first project one vector onto another. Given a nonzero vector we define the orthogonal projection of onto as
For the geometric idea, see Figure A.6. That is, we find the “shadow of ” on the line spanned by if the direction of the sun’s rays were exactly perpendicular to the line. Another way of thinking about it is that the tip of the arrow of is the closest point on the line spanned by to the tip of the arrow of In terms of euclidean distance, minimizes the distance among all vectors that are multiples of Because of this, this projection comes up often in applied mathematics in all sorts of contexts we cannot solve a problem exactly: We cannot always solve “Find as a multiple of ” but is the best “solution.”
The formula follows from basic trigonometry. The length of should be times the length of that is We take the unit vector in the direction of that is, and we multiply it by the length of the projection. In other words,
Example A.5.2.
Let us double check that the projection is orthogonal. That is ought to be orthogonal to see the right angle in Figure A.6. That is,
ought to be orthogonal to We compute the inner product and we had better get zero:
Subsection A.5.3 Orthogonal basis
As we said, a basis is an orthogonal basis if all vectors in the basis are orthogonal to each other, that is, if
for all choices of and where (a nonzero vector cannot be orthogonal to itself). A basis is furthermore called an orthonormal basis if all the vectors in a basis are also unit vectors, that is, if all the vectors have magnitude 1. For example, the standard basis is an orthonormal basis of Any pair is orthogonal, and each vector is of unit magnitude.
The reason why we are interested in orthogonal (or orthonormal) bases is that they make it really simple to represent a vector (or a projection onto a subspace) in the basis. The simple formula for the orthogonal projection onto a vector gives us the coefficients. In Chapter 4, we use the same idea by finding the correct orthogonal basis for the set of solutions of a differential equation. We are then able to find any particular solution by simply applying the orthogonal projection formula, which is just a couple of a inner products.
Let us come back to linear algebra. Suppose that we have a subspace and an orthogonal basis We wish to express in terms of the basis. If is not in the span of the basis (when it is not in the given subspace), then of course it is not possible, but the following formula gives us at least the orthogonal projection onto the subspace, or in other words, the best approximation in the subspace.
First suppose that is in the span. Then it is the sum of the orthogonal projections:
In other words, if we want to write then
Another way to derive this formula is to work in reverse. Suppose that Take an inner product with and use the properties of the inner product:
As the basis is orthogonal, then whenever That means that only one of the terms, the one, on the right-hand side is nonzero and we get
Example A.5.3.
If the basis is orthonormal rather than orthogonal, then all the denominators are one. It is easy to make a basis orthonormal—divide all the vectors by their size. If you want to decompose many vectors, it may be better to find an orthonormal basis. In the example above, the orthonormal basis we would thus create is
Then the computation would have been
Maybe the example is not so awe inspiring, but given vectors in rather than then surely one would much rather do 20 inner products (or 40 if we did not have an orthonormal basis) rather than solving a system of twenty equations in twenty unknowns using row reduction of a matrix.
As we said above, the formula still works even if is not in the subspace, although then it does not get us the vector but its projection. More concretely, suppose that is a subspace that is the span of and is any vector. Let be the vector in that is the closest to Then
Of course, if is in then as the closest vector in to is itself. But true utility is obtained when is not in In much of applied mathematics, we cannot find an exact solution to a problem, but we try to find the best solution out of a small subset (subspace). The partial sums of Fourier series from Chapter 4 are one example. Another example is least square approximation to fit a curve to data. Yet another example is given by the most commonly used numerical methods to solve partial differential equations, the finite element methods.
Example A.5.4.
Subsection A.5.4 The Gram–Schmidt process
Before leaving orthogonal bases, let us note a procedure for manufacturing them out of any old basis. It may not be difficult to come up with an orthogonal basis for a 2-dimensional subspace, but for a 20-dimensional subspace, it seems a daunting task. Fortunately, the orthogonal projection can be used to “project away” the bits of the vectors that are making them not orthogonal. It is called the Gram–Schmidt process.
Example A.5.5.
Exercises A.5.5 Exercises
A.5.1.
A.5.2.
A.5.3.
A.5.4.
Suppose Find
A.5.5.
- Check that the vectors are linearly independent and so form a basis.
- Check that the vectors are mutually orthogonal, and are therefore an orthogonal basis.
- Represent
as a linear combination of this basis. - Make the basis orthonormal.
A.5.6.
A.5.7.
A.5.8.
Find an orthogonal basis of such that is one of the vectors. Hint: First find two extra vectors to make a linearly independent set.
A.5.9.
A.5.101.
Answer.
A.5.102.
Answer.
A.5.103.
Answer.
a) -15 b) -1 c) 28
A.5.104.
Suppose Find
Answer.
a) b) c)
A.5.105.
Answer.
a) b) c)