# Integer eigenvalues in Matlab

조회 수: 16(최근 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!

Translated by