using LinearAlgebra A=rand(5,5) .- 0.5 println("The random matrix is") display(A) x0=rand(5) x=x0 for n=1:10000 global x y=A*x x=y/norm(y) end println("\nAn approximate eigenvector is") display(x) e1=[1,0,0,0,0] v=(x-e1)/norm(x-e1) H=I - 2*v*v' println("\nThe Hausholder reflector is") display(H) HAH=H*A*H println("\nThe block matrix is") display(HAH) B=HAH[2:5,2:5] println("\nThe deflated matrix B is") display(B) println("\nChecking...") println("\nThe eigenvalues of A are") display(eigvals(A)) println("\nThe eigenvalues of B are") display(eigvals(B)) AA=copy(A) for k=1:10000 global AA z=qr(AA) AA=z.R*z.Q end println("\nTry the QR method on same matrix") display(AA)