# Gram-Schmidt Process

I've discovered the Orthogonalize command:

Clear[x1, x2]
x1 = {1, 1, 0};
x2 = {-2, 0, 1};
Orthogonalize[{x1, x2}, Method -> "GramSchmidt"]


Which returns an orthonormal basis.

$$\left\{ \left\{\frac{1}{\sqrt2},\frac{1}{\sqrt2},0\right\} \left\{-\frac{1}{\sqrt3},\frac{1}{\sqrt3},\frac{1}{\sqrt3}\right\} \right\}$$

However, student textbooks that introduce the Gram-Schmidt Process return an orthogonal basis, not unit vectors.

I am wondering if there is a simple Mathematica command I am missing that will do the latter?

Granted, I can do this:

Clear[v1, v2]
v1 = x1;
v2 = x2 - ((x2.x1)/(x1.x1)) x1;
{v1, v2}


Which returns:

$$\left\{ \left\{1,1,0\right\}, \left\{-1,1,1\right\} \right\}$$

But what I am wondering is have I missed a single Mathematica command that will do this?

• I don't think I understand why one would not want orthonormalized vectors... in any event, you might be interested in Projection[]. – J. M.'s discontentment Jul 22 '16 at 5:45
• @J.M. Orthogonal component to a subspace, least squares solution? (I think it's a question of elementary theory vs computation.) In any case, the OP wishes to illustrate the textbook process. – Michael E2 Jul 22 '16 at 15:48

You might want to consider giving an appropriate second argument (inner product function) to Orthogonalize. For example,

In:= vs2 = Orthogonalize[{x1, x2}, Dot[##]*Norm[#] &, Method -> "GramSchmidt"]

Out= {{1/2^(3/4), 1/2^(3/4), 0}, {-(1/3^(3/4)), 1/3^(3/4), 1/3^(3/4)}}

In:= Outer[Dot, vs2, vs2, 1]

Out= {{1/Sqrt, 0}, {0, 1/Sqrt}}


If you want to take that route (instead of using Projection as J.M. suggests) it might be useful to examine the output of

Clear[f];
Orthogonalize[{x1, x2}, f, Method -> "GramSchmidt"]