# Integer eigenvalues in Matlab

18 ビュー (過去 30 日間)
Iam Zain 2021 年 10 月 15 日
コメント済み: Walter Roberson 2021 年 10 月 15 日
I am trying to write a Matlab program which decides if a given (integer) matrix A has integer eigenvalues and if this is the case calculates the eigenvalues and their multiplicities. Any ideas how to get started?

サインインしてコメントする。

### 回答 (3 件)

Bjorn Gustavsson 2021 年 10 月 15 日
Since you have a matrix and want the eigenvalues then the best approach seems to be to actually calculate the eigenvalues. For that use the eig function, see the corresponding help and documentation. For simple extraction of the eigenvalues on the diagonal of the eigenvalue-matrix if you also ask for the eigenvector-matrix have a look at the help and documentation of diag. Then you simply have to check if any of the returned eigenvalues are integers.
HTH
##### 1 件のコメント表示非表示 なし
Walter Roberson 2021 年 10 月 15 日
The requirement seems to be to evaluate whether it could have integer eigenvalues first, and only calculate the actual eigenvalues if it turns out that they are possible.

サインインしてコメントする。

Walter Roberson 2021 年 10 月 15 日
Take the symbolic determinant of (matrix minus lambda) . Ask to factor() that. Look for the entries of the form (lambda +/- integer)
If you are not permitted to factor the polynomial directly, then do a long division by lambda - x, which would give you a sequence of terms. But every one of the terms must be integer, so you might be able to start using the Euclid algorithm or a relative of it to try to construct integers that the terms could hold for (waving hands vaguely here.)
##### 0 件のコメント表示非表示 -1 件の古いコメント

サインインしてコメントする。

Paul 2021 年 10 月 15 日
Asusming that "a given (integer) matrix A" means that you know the values of the elements of A, then you can just use eig on the symbolic form of the matrix:
M = sym([ 8, -1; 6, 3]);
e = eig(M)
e = isAlways(in(e,'integer')) % check in case it's not obvious from the solution.
ans = 2×1 logical array
1 1
M =sym([148544940, 4981764, -15351401, -3212785;
1508678, 105952055, 20746052, 8186704;
616678, -35314190, 162859163, 9445151;
5802184, 13354270, -16966896, 130282468]);
e=eig(M)
e = isAlways(in(e,'integer'))
ans = 4×1 logical array
1 1 1 1
I'm not sure that is "writing a program." If not, you could use it to compare to what you do write. I don't know how big symbolic M can get before eig() starts having trouble. i tested a 7 x 7 and it was no problem.

サインインしてコメントする。

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!