Skip to main content

Section 36 The Gram-Schmidt Process in Inner Product Spaces

Subsection Application: Gaussian Quadrature

Since integration of functions is difficult, approximation techniques for definite integrals are very important. In calculus we are introduced to various methods, e.g., the midpoint, trapezoid, and Simpson's rule, for approximating definite integrals. These methods divide the interval of integration into subintervals and then use values of the integrand at the endpoints to approximate the integral. These are useful methods when approximating integrals from tabulated data, but there are better methods for other types of integrands. If we make judicious choices in the points we use to evaluate the integrand, we can obtain more accurate results with less work. One such method is Gaussian quadrature (which, for example, is widely used in solving problems of radiation heat transfer in direct integration of the equation of transfer of radiation over space), which we explore later in this section. This method utilizes the Gram-Schmidt process to produce orthogonal polynomials.

Subsection Introduction

We have seen that orthogonal bases make computations very convenient, and the Gram-Schmidt process allowed us to create orthogonal bases in Rn using the dot product as inner product. In this section we will see how the Gram-Schmidt process works in any inner product space.

Subsection The Gram-Schmidt Process using Inner Products

Our goal is to understand how the Gram-Schmidt process works in any inner product space.

Preview Activity 36.1.

Let p1(t)=t, p2(t)=1+t+t2, and p3(t)=t3 in P3. Let B={p1(t),p2(t),p3(t)} and let W=Span B. Throughout this activity, use the inner product on P3 defined by

p(t),q(t)=11p(t)q(t)dt.

We want to construct an orthogonal basis C={q1(t),q2(t),q3(t)} from B so that Span C=Span B. To begin, we start by letting q1(t)=p1(t).

(a)

Now we want to find a polynomial in W that is orthogonal to q1(t). Let W1=Span{q1(t)}. Explain why q2(t)=projW1p2(t) is in W and is orthogonal to q1(t). Then calculate the polynomial q2(t).

(b)

Next we need to find a third polynomial q3(t) that is in W and is orthogonal to both q1(t) and q2(t). Let W2=Span{q1(t),q2(t)}. Explain why q3(t)=projW2p3(t) is in W and is orthogonal to both q1(t) and q2(t). Then calculate the polynomial q3(t).

(c)

Explain why the set {q1(t),q2(t),q3(t)} is an orthogonal basis for W.

Preview Activity 36.1 shows the first steps of the Gram-Schmidt process to construct an orthogonal basis from any basis of an inner product space. To understand how the process works in general, let {v1,v2,,vm} be a basis for a subspace W of an inner product space V. Let w1=v1 and let W1=Span{w1}. Since w1=v1 we have that W1=Span{w1}=Span{v1}. Now consider the subspace

W2=Span{v1,v2}

of W. The vectors v1=w1 and v2 are possibly not orthogonal, but we know the orthogonal projection of v2 onto W1 is orthogonal to w1. Let

w2=projW1v2=v2v2,w1w1,w1w1.

Then {w1,w2} is an orthogonal set. Note that w1=v10, and the fact that v2W1 implies that w20. So the set {w1,w2} is linearly independent, being a set of non-zero orthogonal vectors. Now the question is whether Span{w1,w2}=Span{v1,v2}. Note that w2 is a linear combination of v1 and v2, so w2 is in Span{v1,v2}. Since Span{w1,w2} is a 2-dimensional subspace of the 2-dimensional space W2, it must be true that Span{w1,w2}=W2=Span{v1,v2}.

Now we take the next step, adding v3 into the mix. Let

W3=Span{v1,v2,v3}=Span{w1,w2,v3}.

The vector

w3=projW2v3=v3v3,w1w1,w1w1v3,w2w2,w2w2

is orthogonal to both w1 and w2 and, by construction, w3 is a linear combination of v1, v2, and v3. So w3 is in W3. The fact that v3W2 implies that w30 and {w1,w2,w3} is a linearly independent set. Since Span{w1,w2,w3} is a 3-dimensional subspace of the 3-dimensional space W3, we conclude that Span{w1,w2,w3} equals Span{v1,v2,v3}.

We continue inductively in this same manner. If we have constructed a set {w1, w2, w3, , wk1} of k1 orthogonal vectors such that

Span{w1,w2,w3,,wk1}=Span{v1,v2,v3,,vk1},

then we let

wk=projWk1vk=vkvk,w1w1,w1w1vk,w2w2,w2w2vk,wk1wk1,wk1wk1,

where

Wk1=Span{w1,w2,w3,,wk1}.

We know that wk is orthogonal to w1, w2, , wk1. Since w1, w2, , wk1, and vk are all in Wk=Span{v1,v2,,vk} we see that wk is also in Wk. Since vkWk1 implies that wk0 and {w1,w2,,wk} is a linearly independent set. Then Span{w1,w2,w3,,wk} is a k-dimensional subspace of the k-dimensional space Wk, so it follows that

Span{w1,w2,w3,,wk}=Wk=Span{v1,v2,v3,,vk}.

This process will end when we have an orthogonal set {w1, w2, w3, , wm} with Span{w1, w2, w3, , wm} = W.

We summarize the process in the following theorem.

The Gram-Schmidt process builds an orthogonal basis {w1,w2,w3,,wm} for us from a given basis. To make an orthonormal basis {u1,u2,u3,,um}, all we need do is normalize each basis vector: that is, for each i, we let

ui=wi||wi||.

Activity 36.2.

Use the Gram-Schmidt process to find an orthogonal basis for

W=Span{[1001],[0102],[4010]}

using the inner product

[u1 u2 u3 u4]T,[v1 v2 v3 v4]T=u1v1+2u2v2+2u3v3+u4v4.

Subsection Examples

What follows are worked examples that use the concepts from this section.

Example 36.2.

Let W=Span{M1,M2,M3,M4}, where

M1=[101001000],M2=[002101010],M3=[000413000], and M4=[1200000100].

Find an orthonormal basis for W using the Frobenius inner product A,B=trace(ABT).

Solution.

Recall that the Frobenius inner product is just like a dot product for matrices. First note that M1, M2, M3, and M4 are linearly independent. We let N1=M1 and the Gram-Schmidt process gives us

N2=M2M2,N1N1,N1N1=[002101010]33[101001000]=[101100010]
N3=M3M3,N1N1,N1N1M3,N2N2,N2N2=[000413000]33[101001000]44[101100010]=[002312010]

and

N4=M4M4,N1N1,N1N1M4,N2N2,N2N2M4,N3N3,N3N3=[1200000100]123[101001000]124[101100010]019[002312010]=[501304130].

Then {N1,N2,N3,N4} is an orthogonal basis for W. An orthonormal basis is found by dividing each vector by its magnitude, so

{13[101001000],12[101100010],119[002312010],161[501304130]}

is an orthonormal basis for W.

Example 36.3.

Consider the space V=C[0,1] with inner product f,g=01f(x)g(x) dx.

(a)

Find the polynomial in P2 (considered as a subspace of V) that is closest to h(x)=x. Use technology to calculate any required integrals. Draw a graph of your approximation against the graph of h.

Solution.

Our job is to find projP2h(x). To do this, we need an orthogonal basis of P2. We apply the Gram-Schmidt process to the standard basis {1,t,t2} of P2 to obtain an orthogonal basis {p1(t),p2(t),p3(t)} of P2. We start with p1(t)=1, then

p2(t)=tt,11,1(1)=t12

and

p3(t)=t2t2,11,1(1)t2,t12t12,t12(t12)=t213112112(t12)=t2t+16.

Then

projP2x=x,11,1(1)+x,x12x12,x12(x12)+x,x2x+112x2x+16,x2x+16(x2x+16)=231(1)+115112(x12)13151180(x2x+16)=23+(45)(x12)47(x2x+16)=47x2+4835x+635.

A graph of the approximation and h are shown in Figure 36.4

Figure 36.4. The graphs of x and 47x2+4835x+635.

(b)

Provide a numeric measure of the error in approximating x by the polynomial you found in part (a).

Solution.

The norm of projP2x=x(47x2+4835x+635) tells us how well our projection 47x2+4835x+635 approximates x. Technology shows that

||projP2x||=projP2x,projP2x=2700.02.

Subsection Summary

  • The Gram-Schmidt process produces an orthogonal basis from any basis. It works as follows. Let {v1,v2,,vm} be a basis for a subspace W of Rn. The set {w1, w2, w3, , wm} defined by

    • w1=v1,

    • w2=v2v2w1w1w1w1,

    • w3=v3v3w1w1w1w1v3w2w2w2w2,

    • wm=vmvmw1w1w1w1vmw2w2w2w2vmwm1wm1wm1wm1.

    is an orthogonal basis for W. Moreover,

    Span{w1,w2,w3,,wk}=Span{v1,v2,v3,,vk}

    for each k between 1 and m.

Exercises Exercises

1.

Let V=C[0,1] with the inner product f(t),g(t)=01f(t)g(t)dt. Let W=P2. Note that W is a subspace of V.

(a)

Find the polynomial q(t) in W that is closest to the function h defined by h(t)=21+t2 in the least squares sense. That is, find the projection of h(t) onto W.

Hint.

Recall the work done in Activity 25.5.

(b)

Find the second order Taylor polynomial P2(t) for h(t) centered at 0.

(c)

Plot h(t), q(t), and P2(t) on the same set of axes. Which approximation provides a better fit to h on this interval. Why?

2.

Each set S is linearly independent. Use the Gram-Schmidt process to create an orthogonal set of vectors with the same span as S. Then find an orthonormal basis for the same span.

(a)

S={1+t,1t,tt2} in P2 using the inner product

p(t),q(t)=11p(t)q(t)dt
(b)

S={[102],[111],[110]} in R3 using the inner product u,v=(Au)(Av), where A=[101011110]

(c)

S={[1010101],[1230101],[1041201],[1111111]} in R7 with the weighted inner product

[u1 u2 u3 u4 u5 u6 u7]T,[v1 v2 v3 v4 v5 v6 v7]T=u1v1+u2v2+u3v3+2u4v4+2u5v5+u6v6+u7v7

3.

Let S={1,cos(t),sin(t)}.

(a)

Show that S is a linearly independent set in C[0,π].

Hint.

Evaluate an appropriate linear combination at several well chosen values to set up a linear system.

(b)

Use the Gram-Schmidt process to find an orthogonal basis from S using the inner product

f(t),g(t)=0πf(t)g(t)dt

4.

Find an orthonormal basis for the subspace W of P2 that consists of all polynomials of the form a+(a+b)t+bt2 using the inner product p(t),q(t)=01p(t)q(t)dt.

5.

The Legendre polynomials form an orthonormal basis for the infinite dimensional inner product space P of all polynomials using the inner product

p(t),q(t)=11p(t)q(t)dt.

The Legendre polynomials have applications to differential equations, statistics, numerical analysis, and physics (e.g., they appear when solving Schrödinger equation in three dimensions for a central force). The Legendre polynomials are found by using the Gram-Schmidt process to find an orthogonal basis from the standard basis {1,t,t2,} for P. Find the first four Legendre polynomials by creating a orthonormal basis from the set {1,t,t2,t3}.

6.

The sine integral function Si has applications in physics and engineering. We define Si as

Si(x)=0xsin(t)tdt.

Since we cannot find an elementary formula for Si(x), we use approximations. Find the best approximation to Si(x) in P3 with inner product p(t),q(t)=01p(t)q(t)dt. Use appropriate technology for computations and round output six places to the right of the decimal.

7.

Recall from Exercise 18 in Section 35 that any finite dimensional vector space V can be made into an inner product space by setting a basis B for V and defining

(36.1)u,wB=i=1nuiwi

if u=i=1nuivi and w=i=1nwivi in V. Let V=P2 and B={1+t,1+t2,t+t2}. (You may assume that B is a basis for V.)

(a)

Find an orthogonal basis for V containing the polynomial p1(t)=1 using the inner product (36.1).

(b)

Find the best approximation possible as measured by the inner product (36.1) to the polynomial 1+2t+3t2 by a polynomial in P1.

8.

Let a, b, and c be three distinct fixed real numbers and define  , :P2R by

(36.2)p(t),q(t)=p(a)q(a)+p(b)q(b)+p(c)q(c).
(a)

Show that  ,  as defined in (36.2) is an inner product on P2.

(b)

Is the mapping

(36.3)p(t),q(t)=p(a)q(a)+p(b)q(b)

an inner product on P2? Justify your answer.

(c)

Let a=1, b=1, and c=3. Find an orthogonal basis for P2 using the inner product (36.2).

(d)

Continue with a=1, b=1, and c=3. Find the best approximation possible as measured by the inner product (36.2) to the polynomial 1+2t+3t2 by a polynomial in P1.

(e)

If W=Span{1+t}, find W in P2 with respect to the inner product (36.2).

9.

Label each of the following statements as True or False. Provide justification for your response. Throughout, let V be a vector space.

(a) True/False.

If {w1,w2} is a basis for a subspace W of an inner product space V, then the vector vw1w1w1w1+vw2w2w2w2 is the vector in W closest to v.

(b) True/False.

If W is a subspace of an inner product space V, then the vector vprojWv is orthogonal to every vector in W.

(c) True/False.

If u1, u2, u3 are vectors in an inner product space V, then the Gram-Schmidt process constructs an orthogonal set of vectors {v1,v2,v3} with the same span as {u1,u2,u3}.

(d) True/False.

Any set {u1,u2,,uk} of orthogonal vectors in an inner product space V can be extended to an orthogonal basis of V.

(e) True/False.

Every nontrivial finite dimensional subspace of an inner product space has an orthogonal basis.

(f) True/False.

In any inner product space V, if W is a subspace satisfying W={0}, then W=V.

Subsection Project: Gaussian Quadrature and Legendre Polynomials

Simpson's rule is a reasonably accurate method for approximating definite integrals since it models the integrand on subintervals with quadratics. For that reason, Simpson's rule provides exact values for integrals of all polynomials of degree less than or equal to 2. In Gaussian quadrature, we will use a family of polynomials to determine points at which to evaluate an integral of the form 11f(t) dt. By allowing ourselves to select evaluation points that are not uniformly distributed across the interval of integration, we will be able to approximate our integrals much more efficiently. The method is constructed so as to obtain exact values for as large of degree polynomial integrands as possible. As a result, if we can approximate our integrand well with polynomials, we can obtain very good approximations with Gaussian quadrature with minimal effort.

The Gaussian quadrature approximation has the form

(36.4)11f(t) dtw1f(t1)+w2f(t2)++wnf(tn)=i=1nwif(ti),

where the wi (weights) and the ti (nodes) are points in the interval [1,1] 62 . Gaussian quadrature describes how to find the weights and the points in (36.4) to obtain suitable approximations. We begin to explore Gaussian quadrature with the simplest cases.

Project Activity 36.3.

In this activity we find through direct calculation the node and weight with n=1 so that

(36.5)w1f(t1)11f(t) dt.

There are two unknowns in this situation (w1 and t1) and so we will need 2 equations to find these unknowns. Keep in mind that we want to have the approximation (36.5) be exact for as large of degree polynomials as possible.

(a)

Assume equality in (36.5) if we choose f(t)=1. Use the resulting equation to find w1.

(b)

Assume equality in (36.5) if we choose f(t)=t. Use the resulting equation to find t1.

(c)

Verify that (36.5) is in fact an equality for any linear polynomial of the form f(t)=a0+a1t, using the values of w1 and t1 you found

We do one more specific case before considering the general case.

Project Activity 36.4.

In this problem we find through direct calculation the nodes and weights with n=2 so that

(36.6)w1f(t1)+w2f(t2)11f(t) dt.

There are four unknowns in this situation (w1,w2 and t1,t2) and so we will need 4 equations to find these unknowns. Keep in mind that we want to have the approximation (36.6) be exact for as large of degree polynomials as possible. In this case we will use f(t)=1, f(t)=t, f(t)=t2, and f(t)=t3.

(a)

Assume equality in (36.6) if we choose f(t)=1. This gives us an equation in w1 and w2. Find this equation.

(b)

Assume equality in (36.6) if we choose f(t)=t. This gives us an equation in w1,w2 and t1,t2. Find this equation.

(c)

Assume equality in (36.6) if we choose f(t)=t2. This gives us an equation in w1,w2 and t1,t2. Find this equation.

(d)

Assume equality in (36.6) if we choose f(t)=t3. This gives us an equation in w1,w2 and t1,t2. Find this equation.

(e)

Solve this system of 4 equations in 4 unknowns. You can do this by hand or with any other appropriate tool. Show that t1 and t2 are the roots of the polynomial t213.

(f)

Verify that (36.6) is in fact an equality with the values of w1,w2 and t1,t2 you found for any polynomial of the form f(t)=a0+a1t+a2t2+a3t3.

Other than solving a system of linear equations as in Project Activity 36.4, it might be reasonable to ask what the connection is between Gaussian quadrature and linear algebra. We explore that connection now.

In the general case, we want to find the weights and nodes to make the approximation exact for as large degree polynomials as possible. We have 2n unknowns w1, w2, , wn and t1, t2, , tn, so we need to impose 2n conditions to determine the unknowns. We will require equality for the 2n functions ti for i from 0 to 2n1. This yields the equations

w11+w21++wn1=111 dt=t|11=2w1t1+w2t2++wntn=11t dt=t22|11=0w1t12+w2t22++wntn2=11t2 dt=t33|11=23w1t12n1+w2t22n1++wntn2n1=11t2n1 dt=t2n2n|11=0.

In the ith equation the right hand side is

11ti dt=ti+1i+1|11={2i+1 if i is even ,0 if i is odd .

Project Activity 36.5.

It is inefficient to always solve these systems of equations to find the nodes and weights, especially since there is a more elegant way to find the nodes.

(a)

Use appropriate technology to find the equations satisfied by the ti for n=3, n=4, and n=5.

Now we will see the more elegant way to find the nodes. As we will show for some cases, the nodes can be found as roots of a set of orthogonal polynomials in Pn with the inner product f(t),g(t)=11f(t)g(t) dt. Begin with the basis Sn={1,t,t2,,tn} of Pn. Use appropriate technology to find an orthogonal basis B5 for P5 obtained by applying the Gram-Schmidt process to Sn. The polynomials in this basis are called Legendre polynomials. Check that the nodes are roots of the Legendre polynomials by finding roots of these polynomials using any method. Explain why the ti appear to be roots of the Legendre polynomials.

Although it would take us beyond the scope of this project to verify this fact, the nodes in the nth Gaussian quadrature approximation (36.4) are in fact the roots of the nth order Legendre polynomial. In other words, if pn(t) is the nth order Legendre polynomial, then t1, t2, , tn are the roots of pn(t) in [1,1]. Gaussian quadrature as described in (36.4) using the polynomial pn(t) is exact if the integrand f(t) is a polynomial of degree less than 2n.

We can find the corresponding weights, wi, using the formula 63 

(36.7)wi=2(1ti2)(qn(ti))2,

where qi(t) is the ith order Legendre polynomial scaled so that qi(1)=1.

Project Activity 36.6.

Let us see now how good the integral estimates are with Gaussian quadrature method using an example. Use Gaussian quadrature with the indicated value of n to approximate 11etcos(t) dt. Be sure to explain how you found your nodes and weights (approximate the nodes and weights to 8 decimal places). Compare the approximations with the actual value of the integral. Use technology as appropriate to help with calculations.

Our Gaussian quadrature formula was derived for integrals on the interval [1,1]. We conclude by seeing how a definite integral on an interval can be converted to one on the interval [1,1].

Project Activity 36.7.

Consider the problem of approximating an integral of the form I=abg(x) dx. Show that the change of variables x=(ba)t2+a+b2, f(t)=(ba)g(x)2 reduces the integral I to the form I=11f(t) dt. (This change of variables can be derived by finding a linear function that maps the interval [a,b] to the interval [1,1].)

As we will see later, integrations over [a,b] can be converted to an integral over [1,1] with a change of variable.
Abramowitz, Milton; Stegun, Irene A., eds. (1972), sec. 25.4, Integration, Handbook of Mathematical Functions (with Formulas, Graphs, and Mathematical Tables), Dover,