JuliaSymbolics / Symbolics.jl

Symbolic programming for the next generation of numerical software
https://docs.sciml.ai/Symbolics/stable/
Other
1.37k stars 154 forks source link

Symbolic matrix exponential #690

Closed Kaguro19 closed 2 years ago

Kaguro19 commented 2 years ago

I wanted to calculate the matrix exponential of a symbolic matrix. But the following code 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()

It gives the error: MethodError: no method matching exp(::Matrix{Num})

I asked this on here https://discourse.julialang.org/t/symbolic-matrix-exponential/85435. And I was told to open an issue. It would be very helpful if this is implemented.

ChrisRackauckas commented 2 years ago

SymPy uses the Jordan normal form for this.

https://github.com/sympy/sympy/blob/77f1d79c705da5e9b3dee456a14b1b4e92dd620c/sympy/matrices/matrices.py#L1649

YingboMa commented 2 years ago

Duplicate of https://github.com/JuliaSymbolics/Symbolics.jl/issues/220