Samuel Lelièvre on Wed, 06 Apr 2022 12:04:56 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Problem with mateigen() command.


The returned eigenmatrix seems correct to me.

Each column `v` of the eigenmatrix `em` is an eigenvector:
`m * v` is `a * v` where `a` is the corresponding eigenvalue.

```
? m = [1, 0, -1; 0, 1, 0; -1, 0, -1]
%1 =
[ 1 0 -1]
[ 0 1  0]
[-1 0 -1]

? em = mateigen(m)
%2 =
[0   0.414   -2.414]
[1       0        0]
[0       1        1]

? m * em
%3 =
[0   -0.585   -3.414]
[1        0        0]
[0   -1.414    1.414]
```

Eigenvectors being normalized to have their last nonzero entry one,
eigenvalues are the last nonzero entry in the columns of `m * em`.

You can also get the eigenvalues using `flag=1`.

```
? aem = mateigen(m, flag=1)
%4 = [[1, -1.414, 1.414], [0, 0.414, -2.414; 1, 0, 0; 0, 1, 1]]
```

Maybe you expected the rows to be eigenvectors, so that
for each row `u`, we get `u * m = a * u`; in that case,
take the transpose of `em` as your eigenmatrix.

Or maybe you expected the diagonal matrix with the eigenvalues
on the diagonal? It can be obtained as:
```
? matdiagonal(aem[1])
%5 =
[1        0       0]
[0   -1.414       0]
[0        0   1.414]
```