Definitely a bug. A workaround is to use (-I/2*exp(I*theta) +
I/2*exp(-I*theta)).rewrite(sin), which will force the exponentials to
be rewritten in terms of sin and cos.

Aaron Meurer

On Mon, Mar 14, 2016 at 4:10 AM, Francesco Bonazzi
<franz.bona...@gmail.com> wrote:
> A related issue:
>
> In [6]: m = Matrix([[0, theta], [-theta, 0]])
>
> In [7]: exp(m)
> Out[7]:
> [   I*theta    -I*theta         I*theta      -I*theta]
> [  e          e              I*e          I*e        ]
> [  -------- + ---------    - ---------- + -----------]
> [     2           2              2             2     ]
> [                                                    ]
> [   I*theta      -I*theta      I*theta    -I*theta   ]
> [I*e          I*e             e          e           ]
> [---------- - -----------     -------- + ---------   ]
> [    2             2             2           2       ]
>
> In [8]: simplify(exp(m))
> Out[8]:
> [               /   2*I*theta    \  -I*theta]
> [             I*\- e          + 1/*e        ]
> [cos(theta)   ------------------------------]
> [                           2               ]
> [                                           ]
> [-sin(theta)            cos(theta)          ]
>
>
>
>
>
> On Sunday, 13 March 2016 18:14:16 UTC+1, Greg Grunberg wrote:
>>
>> I'm new to SymPy and this group.  My apologies if I'm submitting this to
>> the wrong group.  Please feel free to indicate a more appropriate alternate
>> group, if there is such.
>>
>> I ran into a behavior of the simplify function which strikes me as
>> strange.  Notice that in[4] and in[5] below are identical, except that the
>> expression to be simplified in the latter is the negative of the former.
>> out[4] is what I expected, but out[5] is not.  Shouldn't out[5] be the
>> negative of out[4]?  Can anyone explain?  Note that out[5] is not
>> mathematically incorrect but just not what one would expect.
>>
>>
>> Python 3.5.1 |Anaconda 2.5.0 (64-bit)| (default, Jan 29 2016, 15:01:46)
>> [MSC v.1900 64 bit (AMD64)]
>> Type "copyright", "credits" or "license" for more information.
>>
>> IPython 4.0.3 -- An enhanced Interactive Python.
>> ?         -> Introduction and overview of IPython's features.
>> %quickref -> Quick reference.
>> help      -> Python's own help system.
>> object?   -> Details about 'object', use 'object??' for extra details.
>>
>> In [1]: from sympy import *
>>
>> In [2]: init_session()
>> IPython console for SymPy 1.0 (Python 3.5.1-64-bit) (ground types: python)
>>
>> These commands were executed:
>> >>> from __future__ import division
>> >>> from sympy import *
>> >>> x, y, z, t = symbols('x y z t')
>> >>> k, m, n = symbols('k m n', integer=True)
>> >>> f, g, h = symbols('f g h', cls=Function)
>> >>> init_printing()
>>
>> Documentation can be found at http://docs.sympy.org/1.0/
>>
>> In [3]: theta = symbols('theta', real=True)
>>
>> In [4]: simplify(+I/2*exp(I*theta) - I/2*exp(-I*theta))
>> Out[4]: -sin(theta)
>>
>> In [5]: simplify(-I/2*exp(I*theta) + I/2*exp(-I*theta))
>> Out[5]:
>>   /   2*I*theta    \  -I*theta
>> I*\- e          + 1/*e
>> ------------------------------
>>               2
>>
>>
>> 
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/7b314244-e00e-4f51-992c-e253edb07127%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6K7dx4Q_To4KzvN6ME4oj4vN6gsTEBnkMv%3Dnw6xtwWgnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to