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?

  • 1
    $\begingroup$ I don't think I understand why one would not want orthonormalized vectors... in any event, you might be interested in Projection[]. $\endgroup$ Jul 22, 2016 at 5:45
  • $\begingroup$ @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. $\endgroup$
    – Michael E2
    Jul 22, 2016 at 15:48

1 Answer 1


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

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

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

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

Out[67]= {{1/Sqrt[2], 0}, {0, 1/Sqrt[3]}}

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

Orthogonalize[{x1, x2}, f, Method -> "GramSchmidt"] 
  • $\begingroup$ So the dot product you would "need" is Dot[##]/Norm[#1]/Norm[2], but that's not a dot product, hence unexpected results $\endgroup$ Jul 28, 2022 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.