Message Boards Message Boards

1
|
13619 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

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

Posted 11 years ago
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=MatrixExp
FsASetx=MatrixExp

However, 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
POSTED BY: K Spak
4 Replies
Posted 11 years ago
Hi,

Thanks for the simplification tips- I will play with it this week and see what I can figure out.  Thanks!
POSTED BY: K Spak
Hello,
This is also a case where some simplification and symbolic manipulation of the result may be helpful:
FsASet = FullSimplify[TrigToExp[MatrixExp[Rationalize[FsA]]]]
Series[FsASet, {s, 0, 3}] (*example*)
If you are just learning to use Mathematica, you may be served well develop a widely recommended habit.: when defining your own expressions, use a lower case first letter. For example,
fsASet.
In this way, you won't collide with Mathematica's builtin symbols which always have an upper case first letter.
POSTED BY: W. Craig Carter
Posted 11 years ago
Hi,

Thanks very much for that rationalize tip- it worked to at least get me an answer for the matrix exponential, but the answer I get is vastly different from what I get with the same matrix using expm in Matlab.  Anyone have any idea why?  I know that there are a variety of ways to calculate exponential matrices, but I feel like I should at least get the same number of entries in the matrix- Matlab's answer is a fully populated matrix and Mathematica's answer has a few zero entries, which I don't think is right.  Anyone know why?

Kaitlin

PS- Not the same matrix I had listed above, similar, but different values and I put in a number for s to compare the answers.
POSTED BY: K Spak
Posted 11 years ago
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]}}
*)
POSTED BY: William Rummler
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract