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.


--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to sympy-issues@googlegroups.com.
To unsubscribe from this group, send email to 
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to