Skip to content

Eigenvectors of a general matrix #2478

@lpawela

Description

@lpawela

As of #2445 eigenvalue calculation seems to work correctly. Yet, sometimes there is a problem with eigenvector computation. Consider the following examples.

let A = [[1, 2, 3], [2, 4, 0], [3, 0, 1]];
let cnt = 0.1;
let Ath = math.multiply( math.exp(math.multiply(math.complex(0,1), -cnt)), AA );
let Hth = math.divide(math.add(Ath, math.ctranspose(Ath)), 2);
math.eigs(Hth)

This code works correctly and produces correct eigenvalues. But if I change

let Hth = math.divide(math.add(Ath, math.transpose(Ath)), 2);
math.eigs(Hth)

I get the following error

Uncaught Error: Failed to find eigenvectors for the following eigenvalues: -2.32076242897952 + 0.2328529372998936i, 2.7657291798020682 - 0.27749853033260213i, 5.525058240845601 - 0.5543549068482564i
    at complexEigs.js:461:19
    at complexEigs.js:49:17
    at j (eigs.js:100:12)
    at Function.Array (eigs.js:51:14)
    at Object.eigs (typed-function.js:1085:85)
    at <anonymous>:1:6

The expected output would be

julia> A = [1 2 3; 2 4 0; 3 0 1];

julia> cnt = 0.1;

julia> Ath = exp(-1im*cnt)*A;

julia> Hth = (Ath + transpose(Ath))/2;

julia> eigen(Hth)
Eigen{ComplexF64, ComplexF64, Matrix{ComplexF64}, Vector{ComplexF64}}
values:
3-element Vector{ComplexF64}:
 -2.320762428979524 + 0.23285293729989398im
 2.7657291798020984 - 0.27749853033260563im
  5.525058240845574 - 0.5543549068482575im
vectors:
3×3 Matrix{ComplexF64}:
  0.723537+0.0im           0.391404+4.34166e-17im  0.568592-7.08711e-17im
 -0.228519-3.1175e-17im   -0.641444-1.01409e-16im  0.732345+0.0im
 -0.651363-4.64016e-17im   0.659812+0.0im          0.374665+1.22787e-16im

The eigenvalues look correct, there is some problem with eigenvectors only. I tried some other examples and it seemed to work in that case. These were:

let A = [[3, -2], [math.complex(4, 2), -1]];
let Ah = math.ctranspose(A);
console.log(math.eigs(math.add(A, Ah)));
console.log(math.eigs(A));
console.log(math.eigs(Ah));

In this case there are no errors and the results are correct. I tried a handful of other Hermitian matrices and the error did not occur.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions