You need to know that the method as it is explained in elementary books is useless in numerical applications. In the famous book by Press et al. 'Numerical Recipes in C' we read (p.66) "Numerically, however, because of the build-up of roundoff errors, naive Gram-Schmidt orthogonalization is t e r r i b l e ." They then describe how singular value decomposition (SVD) can be used to improve things. This improved version often goes under the name of 'principal component analysis'.