I want to find the matrix exponential of a symbolic matrix. How to do this?
When I use the Symbolics and LinearAlgebra packages together, it doesn’t work:
using Symbolics
using LinearAlgebra
function run()
@variables a b c t
M = [ -a b 0
1 c -a
0 1 0]
Mt = M*t
expMt = exp(Mt)
print(expMt[1,1])
end
@time run()
Open an issue on Symbolics.jl. This isn’t implemented, and I’m not convinced there is a general symbolic solution that can be given on this operation. It’s worth a dev discussion.
The Jordan form exists for all matrices. The only question is if it can be computed symbolically; this might require giving a name to solutions of polynomials of degree 5+ and work with them. Can Symbolics.jl do it?
Do you think Wolfram Alpha is spitting out the right results then? I was confused as to what “omega” meant in my screenshot of Wolfram Alpha - and in light of your comment, I suspect it’s a solution to some >5 degree polynomial.
From the image it look like ω are the solutions (plural) to a 3rd degree polynomial. The expressions in ω are being summed over all solutions to this polynomial. Didn’t check it, but this is probably the characteristic polynomial of the matrix M. For 3x3 matrix there is a closed form of the solution. For >=5 matrices this would be more problematic and will need exactly the sort of notation Wolfram Alpha uses.
This case would be a degree 3 polynomial. But Symbolics hasn’t specialized the <5 cases just because this breaks down at 5x5 so no one has had the motivation yet to write a scheme that works for and 4x4 and smaller matrix only.
Approximating the symbolic expression for exp(Mt)[1,1] might be enough for the application. In that case:
using TaylorSeries, LinearAlgebra, Symbolics
@variables a b c t m i
M = [ -a b 0
1 c -a
0 1 0 ]
Mt = M*t
k = Taylor1(Rational{Int}, 4)
ek = convert(Taylor1{Rational{Int}},exp(k))