Lab 10: HW for Section 4.6
Gram-Schmidt Procedure
Name:

Upload completed labs to Moodle by 1pm Wednesday: https://lms.ats.amherst.edu/mod/assign/view.php?id=314456

Today we want to look at the Gram-Schmidt procedure, which creates an orthonormal basis from a given non-orthonormal basis.  Mathematica can streamline the process by doing the messy arithmetic for us.

The basic idea is to take each vector in the given basis and subtract from it the parts that duplicate the previous vectors.  Please work through the following example that shows how to do the Gram-Schmidt procedure before doing the exercises.

Consider the basis { (({{({{1}, {0}})}, {1}})) , (({{({{1}, {1}})}, {0}})) , (({{({{2}, {1}})}, {2}})) } for (R^3).  We can first verify that this is indeed a basis by checking that the matrix with these vectors as columns reduces to the identity matrix:

RowReduce[{{1,1,2},{0,1,1},{1,0,2}}]//MatrixForm

Alternatively, you could check that the determinant is nonzero :

Det[{{1,1,2},{0,1,1},{1,0,2}}]

Enter the 3 vectors into Mathematica:

v1={1,0,1};
v2={1,1,0};
v3={2,1,2};

Now we’ll create a new orthogonal basis {w1,w2,w3}. 

At each step, take the next vector in the given basis and subtract off the projections of that vector onto all previous vectors.

1) Start with v1 as the first vector w1.
2) Next take v2 and subtract off the projection of v2 onto w1 to obtain w2.
3) Then take v3 and subtract off the projections of v3 onto w1 and onto w2 to obtain w3.

The resulting set {w1,w2,w3} will be an orthogonal basis.

w1=v1

proj1=(v2.w1)w1/(w1.w1);
w2=v2-proj1

proj1=(v3.w1)w1/(w1.w1);
proj2=(v3.w2)w2/(w2.w2);
w3=v3-proj1-proj2

Now if we divide each vector by its length, we get unit vectors, resulting in an orthonormal basis:

u1=w1/Norm[w1]
u2=w2/Norm[w2]
u3=w3/Norm[w3]

u1.u2       (* to check that u1 and u2 are orthogonal *)
u1.u3       (* to check that u1 and u3 are orthogonal *)
u2.u3       (* to check that u2 and u3 are orthogonal *)

The resulting orthonormal basis for (R^3) is {(({{(1/(Sqrt[2]))}, {0}, {(1/(Sqrt[2]))}})),(({{(1/(Sqrt[6]))}, {(Sqrt[(2/3)])}, {-(1/(Sqrt[6]))}})),(({{-(1/(Sqrt[3]))}, {(1/(Sqrt[3]))}, {(1/(Sqrt[3]))}}))}.

Exercise 1.  Apply the Gram-Schmidt procedure to the basis { (({{1}, {1}})) , (({{3}, {2}}))} to obtain an orthonormal basis for (R^2).  (If necessary, use the Simplify command to clean up messy results.)

Exercise 2.  Apply the Gram-Schmidt procedure to the basis { (({{({{0}, {3}})}, {4}})) , (({{({{-20}, {27}})}, {11}})) , (({{({{-14}, {-4}})}, {-2}})) } to obtain an orthonormal basis for (R^3).  Check that the vectors are indeed orthogonal by evaluating the dot products of each pair of vectors (so you’ll check 3 dot products).

Exercise 3.  Apply the Gram-Schmidt procedure to the basis { (({{({{1}, {0}})}, {({{0}, {-1}})}})) , (({{({{1}, {2}})}, {({{0}, {-1}})}})) , (({{({{3}, {1}})}, {({{1}, {-1}})}})) , (({{({{0}, {1}})}, {({{1}, {-1}})}})) } to obtain an orthonormal basis for (R^4).  Check that the vectors are indeed orthogonal by evaluating the dot products of each pair of vectors (so you’ll check 6 dot products).