So I'm doing a MATLAB assignment where the objective is to write code to do the Gram Schmidt algorithm.
I just want to say, my code is almost certainly not the issue, as the same issue arises in other codes.
We're meant to do a GS algorithm, then check that we've done it correctly, given our inputted matrix V, by checking Z = transpose(W)*W is the identity matrix.
However, when I let V be a 3x3 matrix, and have the 9 terms be consecutive values. I.e. first row: 1,2,3, second row: 4,5,6, third row: 7,8,9 etc. The GS algorithm doesn't work? It works if the same values are used but not consecutive, it works if anyone of the values is changed. It works if it's descending not ascending. But it doesn't work if the values are 1,2,...,9 or 2,3,...,10.
Am I wrong? Is the GS algorithm valid for all matrices? Or is this an exception? And if so, why?
The GS algorithm requires that you start with linearly independent vectors. For an $n\times n$ matrix that means the rows should be linearly independent.