I’m trying to check a system of linear differential equations using symbolic variables:
X'(t)=R(\alpha)X(t)
This is my code
using Symbolics
using SymbolicUtils
using LinearAlgebra
@variables α t
R = [cos(α) -sin(α); sin(α) cos(α)]
X = [im*exp(exp(α*im)*t) -im*exp(exp(-α*im)*t);
exp(exp(α*im)*t) exp(exp(-α*im)*t)]
# Check the fundamental matrix
Dt = Differential(t)
dX = Dt.(X)
dX = expand_derivatives.(dX)
dX = expand.(dX)
H = simplify.(dX.-R*X)
display(H)
H = substitute.(H, (Dict(exp(0) => 1),))
display(H)
However the terms in the final output always contain things like “exp(0)”, eventhough the solution should be correct:
2×2 Matrix{Complex{Num}}:
0 cos(-α)*sin(t*exp(0)*sin(-α))*exp(t*exp(0)*cos(-α)) - cos(α)*sin(t*exp(0)*sin(-α))*exp(t*exp(0)*cos(-α)) + (sin(-α) + sin(α))*exp(t*exp(0)*cos(-α))*cos(t*exp(0)*sin(-α)) + im*(-cos(-α)*exp(t*exp(0)*cos(-α))*cos(t*exp(0)*sin(-α)) + cos(α)*exp(t*exp(0)*cos(-α))*cos(t*exp(0)*sin(-α)) + sin(t*exp(0)*sin(-α))*(sin(-α) + sin(α))*exp(t*exp(0)*cos(-α)))
0 cos(-α)*exp(t*exp(0)*cos(-α))*cos(t*exp(0)*sin(-α)) - cos(α)*exp(t*exp(0)*cos(-α))*cos(t*exp(0)*sin(-α)) - sin(t*exp(0)*sin(-α))*(sin(-α) + sin(α))*exp(t*exp(0)*cos(-α)) + im*(cos(-α)*sin(t*exp(0)*sin(-α))*exp(t*exp(0)*cos(-α)) - cos(α)*sin(t*exp(0)*sin(-α))*exp(t*exp(0)*cos(-α)) + (sin(-α) + sin(α))*exp(t*exp(0)*cos(-α))*cos(t*exp(0)*sin(-α)))
For the past hour I’ve tried every combination of “substitute.”, “expand.”, “simplify.” , but it doesn’t even get rid of the exp(0).
It would also be nice to have things like \cos(-\alpha) = \cos(\alpha) and \sin(-\alpha)=-\sin(\alpha).
Thanks for any help!