Feeds:
Posts

## SAGE tip: Exponentiate a Matrix

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

Enjoy.

Dox

### 3 Responses

1. […] 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 […]

2. Hola!

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().

3. on September 22, 2014 at 5:01 pm | Reply all appliance repairs

Hello 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