Venkataraman Subramaniam on Thu, 07 Apr 2022 10:56:57 +0200


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

Re: Problem with mateigen() command.


Sorry, my bad. I forgot that the column vectors are the eigenvectors.  I was confused because there are two eigenvectors with integer entries. 
Best,

Sent from Yahoo Mail on Android

On Wed, Apr 6, 2022 at 3:35 PM, Samuel Lelièvre
<samuel.lelievre@gmail.com> wrote:
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]

```