필터 지우기
필터 지우기

How do I determine if a matrix is nilpotent using matlab?

조회 수: 7 (최근 30일)
Amy Olivier
Amy Olivier 2017년 4월 10일
편집: Bruno Luong 2024년 4월 15일
I tried using matrix manipulation to determine x which will determine whether A is nilpotent by using the following code:
A =[0 1 2 3 4 5 6 7;0 0 8 9 10 11 12 13;0 0 0 1 2 3 4 5; 0 0 0 0 6 7 8 9;0 0 0 0 0 1 2 3;0 0 0 0 0 0 4 5; 0 0 0 0 0 0 0 1;0 0 0 0 0 0 0 0];
B_A = zeros(8);
syms x
eqn = A.^x == B_A
solx = solve(eqn,x)
But I keep getting solx = Empty sym: 0-by-1
How do I get a solid solution for x? Or any other method to calculate the nilpotent will be helpful.

채택된 답변

Torsten
Torsten 2017년 4월 10일
Your equation is wrong ; it must read
eqn = A^x==B_A
But you should not check for nilpotency this way.
In your case, it's obvious by inspection that A is nilpotent since it is upper triangular.
For the general case, I'd check whether A has only 0 as eigenvalue :
help eig
Or - provided n is small - just calculate A^n for an (nxn)-matrix A and see whether it's the null matrix.
Best wishes
Torsten.
  댓글 수: 11
Bruno Luong
Bruno Luong 2024년 4월 14일
Here is another way to find the degree of Nilpotet matrix, ie smallest x such that A^x = 0
A =[0 1 2 3 4 5 6 7;
0 0 8 9 10 11 12 13;
0 0 0 1 2 3 4 5;
0 0 0 0 6 7 8 9;
0 0 0 0 0 1 2 3;
0 0 0 0 0 0 4 5;
0 0 0 0 0 0 0 1;
0 0 0 0 0 0 0 0];
J = jordan(A); % required symbolic toolbox
d0 = diag(J);
isnilpotent = all(d0 == 0);
if isnilpotent
d1 = diag(J,1); %
% length of the longest sequence of nonzero above the diagonal
% == jordan block size
j = diff([0; d1~=0; 0]); % positions where transition to/from 0 occur
l = diff(find(j)); % length of consecutive non-zeros
maxl = max(l);
x = sum([maxl 1]); % it return 1 if l/maxl is empty, add 1 otherwise
else
x = [];
end
x
x = 8
Bruno Luong
Bruno Luong 2024년 4월 15일
편집: Bruno Luong 2024년 4월 15일
It looks to me the EIG methods (both standarc and generalized) is difficult to be used for middle/large size nilpotetnt matrix. They seem to have difficulty to estimate 0 eigenvalues with huge errors.
Multiple order eigen values estimation is challenging to handle numerically.
n = 100; % 1000
A = diag(ones(1,n-1), 1);
[P,~]=qr(randn(size(A)));
B=P*A*P';
% B should be nimpotetnt, this is small
max(abs(B^n), [], "all")/norm(B)
ans = 1.7070e-15
% check eigen value of A
lambdaA = eig(A,eye(n),'qz','vector');
abs(lambdaA) % ok they are all 0Z
ans = 100x1
0 0 0 0 0 0 0 0 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
norm(lambdaA,'inf')
ans = 0
% Do the same for B
% check eigen value of B, orthogonal transform of A
lambdaB = eig(B,eye(n),'qz','vector');
sort(abs(lambdaB)) % However none of them is close to 0!!!
ans = 100x1
0.4155 0.4155 0.5856 0.6826 0.6826 0.6879 0.6879 0.6891 0.6891 0.6922
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
norm(lambdaB,'inf')
ans = 0.7013

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by