Orthonormality

vs 0.2, 25/1/08 © Niels Walet

In this notebook we tests the two orthonormalization procedures discussed in class. Everything will be demonstrated by 10 vectors in 10 dimensions.
Let's create 10 random vectors (Press Shift Return to execute a "cell")

vectors=Table[Table[Random[],{i,1,10}],{j,1,10}]

Overlap matrix method

Calculate a table (matrix) of overlaps (innerproducts) of these vectors

overlap=Table[vectors[[i]].vectors[[j]],{i,1,10},{j,1,10}]

Construct a list of eigenvalues

evs=Eigensystem[overlap][[1]]

And a matrix of eigenvectors

evmat=Eigensystem[overlap][[2]];

Check that we can reconstruct the overlap matrix from its eigensystem. (Chop equates small numbers ((10^(-14)) or so) to zero).

Chop[overlap-Transpose[evmat] . DiagonalMatrix[evs].evmat]

Now calculate the inverse square root as follows:

ovh=Transpose[evmat] . DiagonalMatrix[(evs^(-1/2))].evmat;

Check again:

Chop[ovh.overlap.ovh]

Transform the basis

newvec=ovh.vectors;

And show they are orthogonal (well, to numerical accuracy

Chop[Table[newvec[[i]].newvec[[j]],{i,1,10},{j,1,10}]]

Gramm-Schmidt Method

Define a place-holder for the vectors

nv=Table[{},{i,1,10}]

This is the whole algorithm!

Do[nv[[k]]=vectors[[k]]-(∑_(j=1)^(k-1))vectors[[k]].nv[[j]] nv[[j]];
nv[[k]]=nv[[k]]/Sqrt[nv[[k]].nv[[k]]];,{k,1,10}]

And check we have done the right thing

Chop[Table[nv[[i]].nv[[j]],{i,1,10},{j,1,10}]]