On Fri, Mar 2, 2012 at 3:06 AM, kayhman <[email protected]> wrote:
>
>> It should be easy to implement such a class. I would suggest the name
>> MatExponential. We already have a MatPow for the case A**b (A a matrix, b a
>> scalar). I would suggest looking at MatPow and MatMul as examples. You'll
>> also have to change the __rpow__ operator in MatExpr (look at the
>> surrounding functions to see what to do). This should allow for the syntax
>> e**A but not exp(A).
>
> I've implemented such a class, and it seems to works. I can now manage
> to compute (e**(q*A)).diff(q).
>
> However, I still have a major problem : sympy does not manage to
> simplify e**A * (e**A)**-1, though it can simplify e**q * (e**q)**-1
> where A is a SymbolMatrix, and q a symbol.
>
> See the code below. Why is that ?
>
> from sympy import *
> from sympy.matrices import *
>
> e = Symbol('e')
>
> q1 = Symbol('q1')
> q2 = Symbol('q2')
> q3 = Symbol('q3')
>
>
> A = MatrixSymbol('A', 3, 3)
> B = MatrixSymbol('B', 3, 3)
>
> print (e**(q2*B)) * (e**(q2*B))**-1 # not simplified :(
> print (e**(q2*q1)) * (e**(q2*q1))**-1 # simplified to 1
Out of curiosity, why do you use Symbol('e') instead of E (i.e.,
exp(1))? They both behave the same here, but I think the latter is
what you really want.
I think it might have something to do with how MatrixExprs are not
automatically simplified in the core beyond those things the core
already knows about. Matthew will have to comment more. The solution
might be to make exp(A)**-1 automatically convert into exp(-A) like it
does in the normal core. I tried that and it seems there's a bug in
your branch:
In [22]: (e**(q2*B)) * (e**(-q2*B))
Out[22]: e
I also noticed that there's some strange pretty printing with this:
In [11]: (e**(q2*B)) * (e**(q2*B))**-1
Out[11]:
q₂⋅B ⎛ q₂⋅B⎞
e ⋅⎝e ⎠^-1
And by the way, to make it so you can use exp() instead of E**, I
think the best way would be to do what you're doing and fix
http://code.google.com/p/sympy/issues/detail?id=1799.
Aaron Meurer
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.