# How can I evaluate the matrix exponential of a symbolic matrix?

GROUPS:
 K Spak 1 Vote Hi,I have a four by four matrix, FsA that is a function of the symbol s:FsA =10* {{0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}, {-(0.102)*s^2, 0, 0, 0}}I would like to take the matrix exponential of this matrix, and of this matrix multiplied by another symbol x:FsASet=MatrixExpFsASetx=MatrixExpHowever, when I type these commands in, I get the following error:MatrixExp::eivn: Incorrect number 0 of eigenvectors for eigenvalue with multiplicity 1.I can do this symbolically in Matlab- it's a messy result, but it at least works.  How can I tell Mathematica that I want the s kept as a symbol?  Why am I getting the error and how can I fix it?Thank you!Kaitlin
5 years ago
4 Replies
 William Rummler 1 Vote Hi Kaitlin,It seems like the message is due to an underlying call to JordanDecomposition, which doesn't like the approximate numeric value (-1.02) in your input matrix. I'm not sure why off the top of my head. There are others here who are more knowledgeable and who could probably explain.If you Rationalize your input matrix (converting the approximate number to the exact rational -102/100), you can avoid the message. The reason this works is likely that a wholly symbolic/exact matrix allows for use of a different internal method in MatrixExp or JordanDecomposition.  FsA =    10*{{0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}, {-(0.102)*s^2, 0, 0, 0}}    (* Out:  {{0, 10, 0, 0}, {0, 0, 10, 0}, {0, 0, 0, 10}, {-1.02 s^2, 0,     0, 0}}  *)    FsASet = MatrixExp[Rationalize[FsA]]  (* Out: {{1/    2 E^(-255^(1/4) Sqrt[s]) (1 + E^(2 255^(1/4) Sqrt[s])) Cos[     255^(1/4) Sqrt[s]], (1/(2 51^(1/4) Sqrt[s]))   5^(3/4) E^(-255^(1/4) Sqrt[     s]) (-Cos[255^(1/4) Sqrt[s]] +       E^(2 255^(1/4) Sqrt[s]) Cos[255^(1/4) Sqrt[s]] +       Sin[255^(1/4) Sqrt[s]] +       E^(2 255^(1/4) Sqrt[s]) Sin[255^(1/4) Sqrt[s]]), (   5 Sqrt[5/51]     E^(-255^(1/4) Sqrt[s]) (-1 + E^(2 255^(1/4) Sqrt[s])) Sin[     255^(1/4) Sqrt[s]])/   s, -(1/(51^(3/4) s^(3/2)))    25 5^(1/4)      E^(-255^(1/4) Sqrt[      s]) (-Cos[255^(1/4) Sqrt[s]] +        E^(2 255^(1/4) Sqrt[s]) Cos[255^(1/4) Sqrt[s]] -        Sin[255^(1/4) Sqrt[s]] -        E^(2 255^(1/4) Sqrt[s]) Sin[255^(1/4) Sqrt[s]])}, {(1/(   4 5^(3/4)))   51^(1/4) E^(-255^(1/4) Sqrt[s]) Sqrt[    s] (-Cos[255^(1/4) Sqrt[s]] +       E^(2 255^(1/4) Sqrt[s]) Cos[255^(1/4) Sqrt[s]] -       Sin[255^(1/4) Sqrt[s]] -       E^(2 255^(1/4) Sqrt[s]) Sin[255^(1/4) Sqrt[s]]),    1/2 E^(-255^(1/4) Sqrt[s]) (1 + E^(2 255^(1/4) Sqrt[s])) Cos[     255^(1/4) Sqrt[s]], (1/(2 51^(1/4) Sqrt[s]))   5^(3/4) E^(-255^(1/4) Sqrt[     s]) (-Cos[255^(1/4) Sqrt[s]] +       E^(2 255^(1/4) Sqrt[s]) Cos[255^(1/4) Sqrt[s]] +       Sin[255^(1/4) Sqrt[s]] +       E^(2 255^(1/4) Sqrt[s]) Sin[255^(1/4) Sqrt[s]]), (   5 Sqrt[5/51]     E^(-255^(1/4) Sqrt[s]) (-1 + E^(2 255^(1/4) Sqrt[s])) Sin[     255^(1/4) Sqrt[s]])/   s}, {-(1/20) Sqrt[51/5]     E^(-255^(1/4) Sqrt[s]) (-1 + E^(2 255^(1/4) Sqrt[s])) s Sin[     255^(1/4) Sqrt[s]], (1/(4 5^(3/4)))   51^(1/4) E^(-255^(1/4) Sqrt[s]) Sqrt[    s] (-Cos[255^(1/4) Sqrt[s]] +       E^(2 255^(1/4) Sqrt[s]) Cos[255^(1/4) Sqrt[s]] -       Sin[255^(1/4) Sqrt[s]] -       E^(2 255^(1/4) Sqrt[s]) Sin[255^(1/4) Sqrt[s]]),    1/2 E^(-255^(1/4) Sqrt[s]) (1 + E^(2 255^(1/4) Sqrt[s])) Cos[     255^(1/4) Sqrt[s]], (1/(2 51^(1/4) Sqrt[s]))   5^(3/4) E^(-255^(1/4) Sqrt[     s]) (-Cos[255^(1/4) Sqrt[s]] +       E^(2 255^(1/4) Sqrt[s]) Cos[255^(1/4) Sqrt[s]] +       Sin[255^(1/4) Sqrt[s]] +       E^(2 255^(1/4) Sqrt[s]) Sin[255^(1/4) Sqrt[s]])}, {-(1/(    200 5^(1/4)))    51^(3/4) E^(-255^(1/4) Sqrt[s]) s^(     3/2) (-Cos[255^(1/4) Sqrt[s]] +        E^(2 255^(1/4) Sqrt[s]) Cos[255^(1/4) Sqrt[s]] +        Sin[255^(1/4) Sqrt[s]] +        E^(2 255^(1/4) Sqrt[s]) Sin[255^(1/4) Sqrt[s]]), -(1/20) Sqrt[    51/5] E^(-255^(1/4) Sqrt[s]) (-1 + E^(2 255^(1/4) Sqrt[s])) s Sin[     255^(1/4) Sqrt[s]], (1/(4 5^(3/4)))   51^(1/4) E^(-255^(1/4) Sqrt[s]) Sqrt[    s] (-Cos[255^(1/4) Sqrt[s]] +       E^(2 255^(1/4) Sqrt[s]) Cos[255^(1/4) Sqrt[s]] -       Sin[255^(1/4) Sqrt[s]] -       E^(2 255^(1/4) Sqrt[s]) Sin[255^(1/4) Sqrt[s]]),    1/2 E^(-255^(1/4) Sqrt[s]) (1 + E^(2 255^(1/4) Sqrt[s])) Cos[     255^(1/4) Sqrt[s]]}} *)  FsASetx = MatrixExp[Rationalize[FsA x]]  (* Out: {{1/    2 E^(-255^(1/4) Sqrt[s] x) (1 + E^(2 255^(1/4) Sqrt[s] x)) Cos[     255^(1/4) Sqrt[s] x], (1/(2 51^(1/4) Sqrt[s]))   5^(3/4) E^(-255^(1/4) Sqrt[s]      x) (-Cos[255^(1/4) Sqrt[s] x] +       E^(2 255^(1/4) Sqrt[s] x) Cos[255^(1/4) Sqrt[s] x] +       Sin[255^(1/4) Sqrt[s] x] +       E^(2 255^(1/4) Sqrt[s] x) Sin[255^(1/4) Sqrt[s] x]), (   5 Sqrt[5/51]     E^(-255^(1/4) Sqrt[s] x) (-1 + E^(2 255^(1/4) Sqrt[s] x)) Sin[     255^(1/4) Sqrt[s] x])/   s, -(1/(51^(3/4) s^(3/2)))    25 5^(1/4)      E^(-255^(1/4) Sqrt[s]       x) (-Cos[255^(1/4) Sqrt[s] x] +        E^(2 255^(1/4) Sqrt[s] x) Cos[255^(1/4) Sqrt[s] x] -        Sin[255^(1/4) Sqrt[s] x] -        E^(2 255^(1/4) Sqrt[s] x) Sin[255^(1/4) Sqrt[s] x])}, {(1/(   4 5^(3/4)))  51^(1/4) E^(-255^(1/4) Sqrt[s] x) Sqrt[   s] (-Cos[255^(1/4) Sqrt[s] x] +      E^(2 255^(1/4) Sqrt[s] x) Cos[255^(1/4) Sqrt[s] x] -      Sin[255^(1/4) Sqrt[s] x] -      E^(2 255^(1/4) Sqrt[s] x) Sin[255^(1/4) Sqrt[s] x]),   1/2 E^(-255^(1/4) Sqrt[s] x) (1 + E^(2 255^(1/4) Sqrt[s] x)) Cos[    255^(1/4) Sqrt[s] x], (1/(2 51^(1/4) Sqrt[s]))  5^(3/4) E^(-255^(1/4) Sqrt[s]     x) (-Cos[255^(1/4) Sqrt[s] x] +      E^(2 255^(1/4) Sqrt[s] x) Cos[255^(1/4) Sqrt[s] x] +      Sin[255^(1/4) Sqrt[s] x] +      E^(2 255^(1/4) Sqrt[s] x) Sin[255^(1/4) Sqrt[s] x]), (  5 Sqrt[5/51]    E^(-255^(1/4) Sqrt[s] x) (-1 + E^(2 255^(1/4) Sqrt[s] x)) Sin[    255^(1/4) Sqrt[s] x])/  s}, {-(1/20) Sqrt[51/5]    E^(-255^(1/4) Sqrt[s] x) (-1 + E^(2 255^(1/4) Sqrt[s] x)) s Sin[    255^(1/4) Sqrt[s] x], (1/(4 5^(3/4)))  51^(1/4) E^(-255^(1/4) Sqrt[s] x) Sqrt[   s] (-Cos[255^(1/4) Sqrt[s] x] +      E^(2 255^(1/4) Sqrt[s] x) Cos[255^(1/4) Sqrt[s] x] -      Sin[255^(1/4) Sqrt[s] x] -      E^(2 255^(1/4) Sqrt[s] x) Sin[255^(1/4) Sqrt[s] x]),   1/2 E^(-255^(1/4) Sqrt[s] x) (1 + E^(2 255^(1/4) Sqrt[s] x)) Cos[    255^(1/4) Sqrt[s] x], (1/(2 51^(1/4) Sqrt[s]))  5^(3/4) E^(-255^(1/4) Sqrt[s]     x) (-Cos[255^(1/4) Sqrt[s] x] +      E^(2 255^(1/4) Sqrt[s] x) Cos[255^(1/4) Sqrt[s] x] +      Sin[255^(1/4) Sqrt[s] x] +      E^(2 255^(1/4) Sqrt[s] x) Sin[255^(1/4) Sqrt[s] x])}, {-(1/(   200 5^(1/4)))   51^(3/4) E^(-255^(1/4) Sqrt[s] x) s^(    3/2) (-Cos[255^(1/4) Sqrt[s] x] +       E^(2 255^(1/4) Sqrt[s] x) Cos[255^(1/4) Sqrt[s] x] +       Sin[255^(1/4) Sqrt[s] x] +       E^(2 255^(1/4) Sqrt[s] x) Sin[255^(1/4) Sqrt[s] x]), -(1/20)     Sqrt[51/5]    E^(-255^(1/4) Sqrt[s] x) (-1 + E^(2 255^(1/4) Sqrt[s] x)) s Sin[    255^(1/4) Sqrt[s] x], (1/(4 5^(3/4)))  51^(1/4) E^(-255^(1/4) Sqrt[s] x) Sqrt[   s] (-Cos[255^(1/4) Sqrt[s] x] +      E^(2 255^(1/4) Sqrt[s] x) Cos[255^(1/4) Sqrt[s] x] -      Sin[255^(1/4) Sqrt[s] x] -      E^(2 255^(1/4) Sqrt[s] x) Sin[255^(1/4) Sqrt[s] x]),   1/2 E^(-255^(1/4) Sqrt[s] x) (1 + E^(2 255^(1/4) Sqrt[s] x)) Cos[    255^(1/4) Sqrt[s] x]}}*)