Lets define matrix $M$ as
M = {{ Cos[
t ]^2, - (2 Cos[t ] +
I Sin[t ]) ((E^(-I t ) - E^(I 2 t )) (s + 2))}, { -8 I Sin[
2 t ], (2 Cos[t ] -
I Sin[t ]) ((E^(I t ) - E^(-I 2 t )) (-s + 2))}};
I'd like to find the matrix exponential of $B$, which can be done by MatrixExp
. It works for the above matrix, and the result is long and ugly. But the matrix of my problem is much more complicated. It is a 6 by 6 matrix, and each element includes the summations and subtractions of trigonometric and exponential terms, similar to (but more complicated than) the above matrix. Even worse, after finding the matrix exponential, I need to take an integral over each element, say, from $t_1$ to $t_2$, where $t_2>t_1$. If I use MatrixExp
it takes a very long time, and if I want to do the integration it becomes much longer. Especially, if I write Integrate[MatrixExp[M],{t,t1,t2}]
, I'm not sure whether it yields the results.
Do you know a faster alternative method that is suitable for more complicated functions?
Revise:
To clarify my problem well, I have a system of linear differential equations with "variable" coefficients: $$ \frac{d}{dt}c=M(t) c+\lambda(t)+n(t)$$ In other words, the elements of $M$ are time dependent.
I already know how to find the solution if the coefficients are constants, but for the variable case the only method I know is this:
Here $\mathcal{T}$ is called time-ordering operator and guarantees that earlier time acts first. As you see, this requires both integration and matrix exponential. Also, one should note that in the second term $\tau$ is the integration variable. So, if we can assign a number to $t$, we cannot do that for $\tau$.
MatrixExp
is already quite optimized. There are some implementations lying around the site, but ultimately you’re just doing different approximations of a matrix exponential thatMatrixExp
would do already. However, I will say two things: 1. Use numerical values, this speeds up evaluation by an incredible amount. And 2. Consider if you can apply a Magnus Expansion, and go that route. Much fewer instances of usingMatrixExp
and larger time steps. $\endgroup$ – CA Trevillian Dec 26 '19 at 8:14Integrate[ ]
and calculate then. Many orders of magnitude faster. $\endgroup$ – MikeY Dec 26 '19 at 16:06MatrixExp
do not give the "best" possibility. You could try doing it by hand using e.g. a Jordan decomposition, to see if that gives a better result. Also, would integrating first help? Or termwise integration of the Taylor expansion for the matrix exponential? $\endgroup$ – Daniel Lichtblau Dec 26 '19 at 16:43MatrixExp
as an integrator? $\endgroup$ – CA Trevillian Dec 26 '19 at 17:36