I'm a noob into eigenvalues algorithms, but something call my attention. QR algorithm works with real/complex matrices producing real/complex eigenvalues. However, it can not produce complex eigenvalues from a real matrix. Here a simplistic example written in Julia and derivated from here and here:
using LinearAlgebra
A = [7 3 4 11 -9 -2;
-6 4 -5 7 1 12;
-1 -9 2 2 9 1;
-8 0 -1 5 0 8;
-4 3 -5 7 2 10;
6 1 4 -11 -7 -1]
M = copy(A)
for i=1:100
global M
Q,R = LinearAlgebra.qr(M);
M=R*Q;
end
display(diag(M))
display(eigvals(A))
6-element Array{Float64,1}:
-2.8415406888480472
8.675063708533656
3.658872985794657
6.3411270142053695
0.12201942568224483
3.0444575546321087
6-element Array{Complex{Float64},1}:
2.916761509842819 + 13.248032079355992im
2.916761509842819 - 13.248032079355992im
5.000000000000005 + 6.000000000000003im
5.000000000000005 - 6.000000000000003im
1.5832384901571723 + 1.4155521348117128im
1.5832384901571723 - 1.4155521348117128im
Defining matrix A as complex, with only real components, makes no difference.
My questions are :
- what is my conceptual misunderstanding on the subject ?
- what step am I doing wrong ?
- and how to fix it ?
Thank you