## SAGE tip: Exponentiate a Matrix

February 24, 2011 by doxdrum

From time to time when one works with operators, such as in Quantum mechanics, something like an exponential of the operator appears (this is also the case in many areas of Mathematics like group theory of differential geometry). This exponentiation of a matrix should be understood as the series expansion of the exponential.

SAGE knows how to do this exponentiation,

sage: reset()
sage: var('a,b,c', domain=RR)
sage: A = a*I*matrix([[0,1],[1,0]])
sage: B = b*I*matrix([[0,-I],[I,0]])
sage: C = c*I*matrix([[1,0],[0,-1]])
sage: A.exp()
[1/2*(e^(2*I*a) + 1)*e^(-I*a) 1/2*(e^(2*I*a) - 1)*e^(-I*a)]
[1/2*(e^(2*I*a) - 1)*e^(-I*a) 1/2*(e^(2*I*a) + 1)*e^(-I*a)]
sage: B.exp()
[ 1/2*(e^(2*I*b) + 1)*e^(-I*b) -1/2*(I*e^(2*I*b) - I)*e^(-I*b)]
[ 1/2*(I*e^(2*I*b) - I)*e^(-I*b) 1/2*(e^(2*I*b) + 1)*e^(-I*b)]
sage: C.exp()
[ e^(I*c) 0]
[ 0 e^(-I*c)]

The only problem here is that, even when the relations are simple in this example, I’ve not found a `trivial’ way of simplifying the matrix elements of the exponentiation, not even with the procedure post in here. I didn’t try with the rewrite package

Comments are welcome!

Enjoy.

Dox

51.609574
-3.980685

### Like this:

Like Loading...

*Related*

Posted in Linux, Mathematics, Physics, Science | Tagged Differential, Exponentiate, Geometry, Groups, How to, HowTo, Linux, Maple, Mathematica, Mathematics, Matlab, Matrix, Mechanics, Notebook, Operator, Programming, Python, Quantum, Rewrite, Sage, Sage-dev, Sagemath, Simplify, Symbolic, Terminal, Theory, Tips and Tricks, Ubuntu, Web Browser | 3 Comments

on February 25, 2011 at 4:36 am |Tweets that mention SAGE tip: Exponentiate a Matrix « Doxdrum's Blog -- Topsy.com[…] This post was mentioned on Twitter by nicola torquati, sagemath.org. sagemath.org said: SAGE tip: Exponentiate a Matrix https://doxdrum.wordpress.com/2011/02/24/sage-tip-exponentiate-a-matrix/ #sageprimer http://fb.me/w7ezs42a […]

on February 25, 2011 at 5:07 am |Adam GetchellHola!

I wonder (it’s been awhile since I used Sage), but wouldn’t it be easier to get your exponentiated matrix via spectral decomposition?

Then you can use the fact that:

f(M) = f(e1)|e1>,<e#| are the right,left eigenvectors of the matrix M.

You may get numerical errors getting the eigenvectors, but they might be less than the ones you get from your power series expansion.

This is easily done using Apply[] in Mathematica; they banished that in Python, but you might be able to work around it with map().

on September 22, 2014 at 5:01 pm |all appliance repairsHello I am so excited I found your blog, I really found you

by accident, while I was looking on Google for something else,

Anyhow I am here now and would just like to say many thanks for

a tremendous post and a all round thrilling blog (I also love the theme/design),

I don’t have time to go through it all at the minute but I have bookmarked it and also

included your RSS feeds, so when I have time I will be back

to read much more, Please do keep up the excellent b.