This is basically the same answer as @Drew, but explained a bit differently.
If A is the matrix
1 2 0
2 1 4
0 4 1
then the eigenvalues are lambda = 1, 1+sqrt(20), 1-sqrt(20). Let us take for simplicity lambda = 1. Then the augmented matrix for the system (A - lambda*I) * x = 0
is
0 2 0 | 0
2 0 4 | 0
0 4 0 | 0
Now you do the Householder / Givens to reduce it to upper triangular form. As you say, you get something of the form
# # # | 0
0 # # | 0
0 0 # | 0
However, the last #
should be zero (or almost zero). Exactly what you get depends on the details of the transformations you do, but if I do it by hand I get
2 0 4 | 0
0 2 0 | 0
0 0 0 | 0
Now you do backsubstitution. In the first step, you solve the equation in the last row. However, this equation does not yield any information, so you can set x[2]
(the last element of the vector x
) to any value you want. If you set it to zero and continue the back-substitution with that value, you get the zero vector. If you set it to one (or any nonzero value), you get a nonzero vector. The idea behind Drew's answer is to replace the last row with 0 0 1 | 1
which sets x[2]
to 1.
Round-off error means that the last #
, which should be zero, is probably not quite zero but some small value like 1e-16. This can be ignored: just take it as zero and set x[2]
to one.
Obligatory warning: I assume you are implementing this for fun or educational purposes. If you need to find eigenvectors in serious code, you are better off using code written by others as this stuff is tricky to get right.