Efficient way of calculation matrix exponential in matlab

I am currently trying to solve a matrix exponential of a matrix that has the form of
[a 0 b 0]
[0 c 0 d]
[e 0 f g]
[0 h i j]
This is obviously not symmetry, and I am very sure this is hard to solve.
1)Is there a way to solve this more time efficiently on Matlab?
2)How complicated of a matrix can Matlab solve for matrix exponential? (I know "complicated" is a very qualitative word, but I really have no other way of expressing this)
3)How exactly do MATLAB try to solve matrix exponential?

1 Comment

You shouldn't use "i" or "j" as symbols because those are interpreted as imaginary units - just try typing one or the other at the command line to see the point.

Sign in to comment.

 Accepted Answer

If your matrix is symbolic, expect it to be difficult, and incredibly nasty looking even if you could obtain a solution. You might think that this should be easy, but to no surprise, it is not a trivial thing to compute. Even the simple case of the matrix exponential of a general 2x2 matrix is a bit of a mess. A 3x3 matrix exponential is right now completely bogging down one of the cores of my cpu in a test case.
If your matrix is purely numeric, so you have values for those elements, then it is trivial. Use expm.
Just wanting code to be more efficient is not sufficient. There is no magic to be found, unless your name is Harry Potter.

11 Comments

I know. I have actually entered the actual number and it was surely nasty looking.
However, I am currently writing an (chemistry) academic paper, and the answer must be as general as possible. Thus numerical values cannot be used.
But if there is no other way of solving it, then I guess that's the end of my paper.
Suppose that it could be written out explicitly in only (say) 500 Megabytes. What would you do with it then?
Does it matter to the discussion? Forget about that I'm writing a manuscript. I'm just asking whether if there's a way or not...
Now that I know that there is none, I guess that's about it for me.
I fail to see why you cannot simply write e^A in your paper, where A is the matrix in question. As has been pointed out, the actual solution will be huge, messy, and unreadable. Your readers won't gain anything from 100 pages of symbolic mess.
Yes, it can be done. It might take another few days for my system to finish calculating the solution. Or another 5 minutes... I don't know yet.
What format do you want the solution delivered in? I can guarantee that it will be multiple megabytes. If you have a word limit on the paper then including the solution will definitely exceed it.
One general method is to diagonalize the matrix into U * D * U^T and take U * exp(D) * U^T . Another general method involves finding the eigenvectors of the matrix. Are there any special properties known for the eigenvalues and eigenvectors of the matrices for your situation?
Dear Walter Roberson,
You have saved my life! (and my paper)
The calculation of the matrix exponential of your system just passed 24 hours on my system. The computation itself is only using about 50 megabytes of memory but the main Maple session is up to about 2.5 gigabytes. I am not sure what that signifies yet.
Your paper is not saved until you find a practical method of calculating the matrix exponential It is not going to be the diagonalization method. Do you have reason to know the eigenvectors?
63 hours of calculation on my system so far, but the memory has barely grown. I do not know how many more days (or weeks) the calculation will take.
102 hours of computation so far, and it is not obvious that it will end any week soon. Are you certain the output is going to be of benefit to you?
185 hours so far and there is no sign that it is getting closer to finding the solution. You need to confirm soon that you need me to keep running it and you need to tell me which output format you need the answer it.
(Eventually I gave up and canceled the calculation.)

Sign in to comment.

More Answers (1)

I do not know what you intend by ‘solve a matrix exponential’. The expm function will calculate the matrix exponential, and the logm function is the inverse. These functions also are in the Symbolic Math Toolbox if you are doing a symbolic calculation.

2 Comments

I left out few words in my question which completely changes the question. I apologize.
What I meant was I wanted to solve matrix exponential of a matrix shown above.
I know that I am supposed to use expm, but it is super time-consuming.
I know I can’t write any more efficient code than expm, so I can’t offer any further help.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!