Divide by zero error

162 Views Asked by At

In my textbook they describe the power method for finding the largest eigenvalue for a nonsingular matrix A. They present the following algorithm

input n, A, x, M  
output 0,x  
for k=1 to M do  
    y <- Ax
    r <- y_1 / x_1
    x <- y / ||y||
    output k, x, r
end do

There is then an assignment where you should run this algorithm on the following input $$Z = \left[\begin{array}{ccc}{3} & {2} & {1} \\ {0} & {2} & {0} \\ {0} & {0} & {1}\end{array}\right], \quad x=(0,0,6)^{T}, \quad M=50, \quad n=3$$

I dont understand how this should work, or if i am misreading the pseudocode?

1

There are 1 best solutions below

4
On

There are two caveats to the algorithm. First is that the starting vector $x$ should have a non-zero projection on the eigenvector with the eigenvalue of largest absolute value. The algorithm is based on the assumption that a geometric progression with constant ratio the largest absolute value will dominate all of the other geometric progressions with the other eigenvalues assuming that they have strictly smaller absolute values. Picking a random starting vector $x$ will almost certainly be sufficient to avoid the problem.

Second is that in the limit, the vector $y$ will be a multiple of $x$ with ratio the desired eigenvalue. That means that any coordinate of $y$ will approximately be a constant multiple of the same coordinate of $x$. If the coordinate of $x$ is zero, then division by it is not possible, so you have to pick a nonzero coordinate (which must exist assuming nonsingular $A$) instead. There can be other variations which work.