Date: Jul 28, 2013 7:07 AM
Author: Erik
Subject: Symbolic matrix exponentiation


I am attempting to calculate the general form of an equation using symbolic math in the example below. This example, as shown, runs quickly and the result has already been very useful to me.

I am hoping to extend this example to the generalized case. If I allow one more parameter to be free, for example by removing a = 1, then calculating the expm never finishes. The problem goes from being solved in a few seconds to not completing within days.

Ideally I would like to allow all parameters to be free, including a, c, d, and f. Is there a trick that will make this exponentiation possible with additional free parameters? In other words, how can I remove a = 1 and still get the calculation to finish in reasonable time?

Thanks in advance,

syms u A G C T a b c d e f

a = 1; c = 1; d = 1; f = 1; % hoping to remove this line

% note that there are additional unused constraints:
% A + G + C + T = 1
% A, G, C, T > 0
% a, b, c, d, e, f > 0

Q=[0 a*C*u b*G*u c*T*u;
a*A*u 0 d*G*u e*T*u;
b*A*u d*C*u 0 f*T*u;
c*A*u e*C*u f*G*u 0];

for i=1:4
Q(i,i) = -1*sum(Q(i,:)); % set diagonal entries to negative row sums

Pt=expm(Q); % never finishes with additional free parameters a, c, d, or f