expm function problem for stiff matrix

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 commentaires

Matt J
Matt J le 10 Juin 2021
Modifié(e) : Matt J le 10 Juin 2021
I think the better question would be, why does the eigendecomposition method succeed. The matrix elements span 36 orders of magnitude, i.e., beyond what double float precision should be expected to handle.
Michal
Michal le 10 Juin 2021
Yes Matt, you are right :)
Michal
Michal le 10 Juin 2021
BTW, the crucial question is: What is the proper method to solve linear ODE systems with similar system matrix? These matrices are very common in nuclear decay kinetic problems, where decay constants may differ by many orders (10-30).
Matt J
Matt J le 10 Juin 2021
If they are linear ODEs, maybe you could solve them symbolically?
Michal
Michal le 10 Juin 2021
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 ... :)

Connectez-vous pour commenter.

 Réponse acceptée

Shadaab Siddiqie
Shadaab Siddiqie le 18 Juin 2021

0 votes

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 commentaire

Michal
Michal le 18 Juin 2021
OK ... great! I am looking forward for any news regarding this topic.

Connectez-vous pour commenter.

Plus de réponses (2)

Bobby Cheng
Bobby Cheng le 12 Août 2021
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

1 commentaire

Fangcheng Huang
Fangcheng Huang le 1 Juin 2022
Modifié(e) : Fangcheng Huang le 1 Juin 2022
last line, Strange, when use matlab2022 it is right, but when use matlab 2020a, need to change Q*diag(exp(diag(T)))*Q'

Connectez-vous pour commenter.

a = -1e20;
b = eps;
c = 1;
A = [a,0,b;0,c,0;-b,0,a];
B=vpa(A);
expmA=expm(B)
expmA = 

Catégories

En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange

Produits

Version

R2021a

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by