QR with Shift

The QRShift step is simple.  Here it is:

QRShiftStep[A_,μ_] := Module[
{Q,R, Id = IdentityMatrix[Length[A]]},
{Q,R}=QRDecomposition[A-μ Id];
(* Note MMa's QR decomp gives the transpose of the Q described in the text. *)
R.Transpose[Q] + μ Id
]

We need to test it.

m=4;
A=RandomReal[ {-1,1},{m,m}];
A=A + Transpose[A];
Eigenvalues[A]

The next question is how to choose the shifts.  Two different questioms: 
1) If we knew good approximations to the eigenvalues we would use one of these a shift! 
As  pointed out on Friday this looks useless untill we realize that the diagonal entries (particularly the last one) are good approximations to eigenvalues.

B=QRShiftStep[A,3.43967];
BB=QRShiftStep[A,0.21838];
BBB=QRShiftStep[A,0.391285];
MatrixForm[Map[Eigenvalues,{A,B,BB,BBB}]]
Map[MatrixForm,{B,BB,BBB}]

QRIterationNC[A_, NIter_] := Module[
{Q, R, AA=A,i=0},
Do[
Print[ 
"Iteration=",i++,
", Lower Triangular F Norm=",Norm[LowerTriangularize[AA,-1],"Frobenius"]];
Print[Diagonal[AA]];
(* Implementing a shift simply by the trailing entry *)
AA=QRShiftStep[AA,AA[[-1,-1]]],
{NIter}];
AA
]

Γ=QRIterationNC[A,18];
MatrixForm[Γ]

Other shifting startegies are possible.