# expm function problem for stiff matrix

조회 수: 11(최근 30일)
Michal Kvasnicka 2021년 6월 10일
답변: Bobby Cheng 2021년 8월 12일
For very specific matrix A:
a = -1e20;
b = eps;
c = 1;
A = [a,0,b;0,c,0;-b,0,a];
disp('A:'), disp(num2str(A))
A:
-1e+20 0 2.220446049250313e-16
0 1 0
-2.220446049250313e-16 0 -1e+20
is known exact matrix exponential as:
expA = exp(a)*( ...
[1,0,0;0,0,0;0,0,1]*cos(b)+ ...
[0,0,1;0,0,0;-1,0,0]*sin(b))+ ...
[0,0,0;0,exp(c),0;0,0,0];
expA =
0 0 0
0 2.7183 0
0 0 0
the Matlab function expm give wrong result:
expm(A)
ans =
0 0 0
0 1 0
0 0 0
but direct computing of expm(A) via definition gives again right result:
[V,D] = eig(A);
expmA = V*diag(exp(diag(D)))/V
expmA =
0 0 0
0 2.7183 0
0 0 0
So, what is wrong with expm function? Bad implementation of Pade's approximation?
##### 댓글 수: 5표시숨기기 이전 댓글 수: 4
Michal Kvasnicka 2021년 6월 10일
Symbolic solutions always ends on matrix exponentials and integration, which must be finally evaluated always numerically, so in this case by multi-precision arithmetic, which is sometimes very slow (especially with VPA in MATLAB). So, this problem is really hard ... :)

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

### 채택된 답변

From my understanding you are getting wrong result for certain cases wile using expm function. This issue has been forwarded to the development team for further investigation.
##### 댓글 수: 1표시숨기기 없음
Michal Kvasnicka 2021년 6월 18일
OK ... great! I am looking forward for any news regarding this topic.

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

### 추가 답변(1개)

Bobby Cheng 2021년 8월 12일
This is a weakness of the scaling and squaring algorithm. Inside EXPM, which you can read the implementation, there are special treatments for diagonal to deal with extreme cases, but it is only triggered if the input is of the Schur form due to performance. You can call SCHUR to create the Schur factorization, and pass the Schur form to EXPM to trigger the special diagonal treatment.
>> a = -1e20;
>> b = eps;
>> c = 1;
>> A = [a,0,b;0,c,0;-b,0,a];
>> [Q T] = schur(A);
>> Q*expm(T)*Q'
ans =
0 0 0
0 2.7183 0
0 0 0

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

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by