Issue 3119 in sympy: Matrix Exponential

2 views
Skip to first unread message

sy...@googlecode.com

unread,
Feb 29, 2012, 1:51:11 PM2/29/12
to sympy-...@googlegroups.com
Status: Accepted
Owner: MRock...@gmail.com
Labels: Type-Defect Priority-Medium Matrices

New issue 3119 by MRock...@gmail.com: Matrix Exponential
http://code.google.com/p/sympy/issues/detail?id=3119

We should be able to represent matrix exponentials - expressions of the
form a**B with a a scalar and B a matrix.

When asked to operate on this we could either use the eigenvalue
decomposition or represent it as an infinite sum.

http://en.wikipedia.org/wiki/Matrix_exponential

sy...@googlecode.com

unread,
Mar 4, 2012, 12:19:06 PM3/4/12
to sympy-...@googlegroups.com

Comment #1 on issue 3119 by someb...@bluewin.ch: Matrix Exponential
http://code.google.com/p/sympy/issues/detail?id=3119

For the special but very important case of an arbitrary 2x2 matrix we have
a simple formula. (Of course obtained by eigenvalue decomposition) I
implemented this
several times.


# M the original 2x2 matrix
a = M[0,0]
b = M[0,1]
c = M[1,0]
d = M[1,1]

D = sympy.sqrt((a-d)**2 + 4*b*c)/2
t = sympy.exp((a+d)/2)

M = sympy.Matrix([[0,0],[0,0]])

try:
D = sympy.simplify(D)
t = sympy.simplify(t)
except:
pass

if sympy.Eq(D,0):
# special case
M[0,0] = t * (1 + (a-d)/2)
M[0,1] = t * b
M[1,0] = t * c
M[1,1] = t * (1 - (a-d)/2)
else:
# general case
M[0,0] = t * (sympy.cosh(D) + (a-d)/2 * sympy.sinh(D)/D)
M[0,1] = t * (b * sympy.sinh(D)/D)
M[1,0] = t * (c * sympy.sinh(D)/D)
M[1,1] = t * (sympy.cosh(D) - (a-d)/2 * sympy.sinh(D)/D)

# M is now the result of exp(M)


There is also an old paper titled "Some explicit formulas for the matrix
exponential"
by Dennis Bernstein and Wasin So. They show some formulas for the 3x3 case
but only
for special cases.


sy...@googlecode.com

unread,
Mar 4, 2012, 3:34:58 PM3/4/12
to sympy-...@googlegroups.com

Comment #2 on issue 3119 by asme...@gmail.com: Matrix Exponential
http://code.google.com/p/sympy/issues/detail?id=3119

Matrix.exp works for the diagonalizable case, and shouldn't be too hard to
extend to the non-diagonalizable case.

Maple's version of this includes an extra argument for a parameter
(http://www.maplesoft.com/support/help/Maple/view.aspx?path=LinearAlgebra/MatrixExponential).
Do you think that would be helpful?

Reply all
Reply to author
Forward
0 new messages