Wolfram ResearchProductsPurchasingServices & ResourcesAbout UsOur Sites
Mathematica Technical FAQs Services & Resources / Mathematica / Kernels & Programming
-----
 /
Symbols
*Mathematica
*Network Mathematica
*webMathematica
*gridMathematica
*Personal Grid Edition
*Wolfram Workbench
*Wolfram Education Group
*Application Packages
*Mathematica for Students
*Mathematica CalcCenter
*Publicon
*A New Kind of Science Explorer
*Mathematical Explorer
*Mathematica Teacher's Edition
*Calculus WIZ
*Mathematica Player
*Ask about this page
*Print this page
*Email this page
*Give us feedback
*
Sign up for our newsletter:

MatrixExp


Usage Message:

MatrixExp[mat] gives the matrix exponential of mat.

Attributes[MatrixExp] = {Protected}


Notes:

There is an error in the initial releases of Version 3.0 for Mathematica that will cause MatrixExp to return incorrect results for certain diagonal matrices. This error does not affect any matrices other than diagonal matrices.

Here is a typical example, showing an incorrect result.

In[1]:= m = DiagonalMatrix[{x, -x, x, -x}]

Out[1]= {{x, 0, 0, 0}, {0, -x, 0, 0}, {0, 0, x, 0}, {0, 0, 0, -x}}

In[2]:= MatrixExp[m]

           -x                 -x                 x                 x
Out[2]= {{E  , 0, 0, 0}, {0, E  , 0, 0}, {0, 0, E , 0}, {0, 0, 0, E }}
One simple way to correct this problem is to add a rule that simply computes the exponential of the diagonal elements if MatrixExp is used with diagonal matrices.
In[3]:= Unprotect[MatrixExp]

Out[3]= {MatrixExp}

In[4]:= MatrixExp[m_List] := With[{d = Dimensions[m]},
            (Print["Using diagonal MatrixExp rule"];
              DiagonalMatrix[Exp[Table[m[[i,i]],{i,d[[1]]}]]]) /;
            (Print["Checking diagonal MatrixExp rule"]; True) &&
            Length[d] === 2 && (SameQ @@ d) &&
            Catch[Do[If[i=!=j && !TrueQ[m[[i,j]]==0],
                       Throw[False]],
                       {i,d[[1]]},{j, d[[2]]}]; True]]

In[5]:= Protect[MatrixExp]

Out[5]= {MatrixExp}

In[6]:= MatrixExp[m]
Checking diagonal MatrixExp rule
Using diagonal MatrixExp rule

           x                 -x                 x                 -x
Out[6]= {{E , 0, 0, 0}, {0, E  , 0, 0}, {0, 0, E , 0}, {0, 0, 0, E  }}
If you use this rule, you may want to remove the Print statements after verifying that this rule has been installed correctly. You can have this workaround automatically loaded by placing

http://support.wolfram.com/mathematica/kernel/Symbols/System/MatrixExp.m

at the location given by

In[7]:= ToFileName[{$TopDirectory,"AddOns", "Autoload", 
		"MatrixExp", "Kernel"}, "init.m"]

We apologize for any difficulties caused by this error. For more information, contact the technical support group at Wolfram Research.


There is an error in Version 3.0 of Mathematica that can cause MatrixExp to return unnecessarily complicated results involving RootSum expressions. Here is a typical example.
In[1]:= result = MatrixExp[{{1,1,0},{-1,2,0},{0,0,1}}]

                                2     3
Out[1]= RootSum[-3 + 6 #1 - 4 #1  + #1  & , 
 
          #1      #1       #1   2     #1    #1
       2 E   - 3 E   #1 + E   #1    -E   + E   #1
>    {{--------------------------, ----------------, 0}, 
                           2                      2
            6 - 8 #1 + 3 #1        6 - 8 #1 + 3 #1
 
             #1    #1         #1      #1       #1   2
           -E   + E   #1     E   - 2 E   #1 + E   #1
>      {-(----------------), ------------------------, 0}, 
                         2                      2
          6 - 8 #1 + 3 #1        6 - 8 #1 + 3 #1
 
                 #1      #1       #1   2
              3 E   - 3 E   #1 + E   #1
>      {0, 0, --------------------------}} & ]
                                  2
                   6 - 8 #1 + 3 #1
The result is mathematically correct, but it is possible to give this result in a simpler form, without the use of RootSum . In most examples you can convert the result to a simpler form by using functions such as ToRadicals , Simplify , or Together .
In[2]:= Together[ToRadicals[result]]

                    3/2            3/2        3/2 + I Sqrt[3]
Out[2]= {{(2 (-3 I E    - Sqrt[3] E    - 3 I E                + 
 
                    3/2 + I Sqrt[3]
>          Sqrt[3] E               )) / 
 
                                          I/2 Sqrt[3]
>      ((-3 - I Sqrt[3]) (3 I + Sqrt[3]) E           ), 
 
                        3/2    3/2 + I Sqrt[3]
           4 Sqrt[3] (-E    + E               )
>     ----------------------------------------------, 0}, 
                                         I/2 Sqrt[3]
      (-3 + I Sqrt[3]) (-3 I + Sqrt[3]) E
 
                       3/2    3/2 + I Sqrt[3]
          4 Sqrt[3] (-E    + E               )
>    {---------------------------------------------, 
                                        I/2 Sqrt[3]
      (-3 - I Sqrt[3]) (3 I + Sqrt[3]) E
 
               3/2            3/2        3/2 + I Sqrt[3]
>     (2 (3 I E    - Sqrt[3] E    + 3 I E                + 
 
                    3/2 + I Sqrt[3]
>          Sqrt[3] E               )) / 
 
                                           I/2 Sqrt[3]
>      ((-3 + I Sqrt[3]) (-3 I + Sqrt[3]) E           ), 0}, 
 
                          12 E
>    {0, 0, --------------------------------}}
            (-3 I + Sqrt[3]) (3 I + Sqrt[3])
We anticipate that this error will be corrected for the next major release of Mathematica.


Additional Online Documentation:

Mathematica 3.0
http://documents.wolfram.com/v3/RefGuide/MatrixExp.html

Mathematica 4.0
http://documents.wolfram.com/v4/RefGuide/MatrixExp.html




 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy