Issue 3109 in sympy: sqrt(exp(4*a)) != exp(2*a)

1 view
Skip to first unread message

sy...@googlecode.com

unread,
Feb 26, 2012, 9:16:42 PM2/26/12
to sympy-...@googlegroups.com
Status: Accepted
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 3109 by smi...@gmail.com: sqrt(exp(4*a)) != exp(2*a)
http://code.google.com/p/sympy/issues/detail?id=3109

Given the following,

>>> a.assumptions0
{}
>>> ai
I*pi/2
>>> e = exp(4*a)

These two should be the same:

>>> sqrt(e).subs(a,ai)
-1

>>> sqrt(e.subs(a,ai)) # subs before sqrt
1

>>> sqrt(e) # this is not a valid simplification
exp(2*a)


sy...@googlecode.com

unread,
Feb 28, 2012, 3:33:24 AM2/28/12
to sympy-...@googlegroups.com

Comment #1 on issue 3109 by smi...@gmail.com: sqrt(exp(4*a)) != exp(2*a)
http://code.google.com/p/sympy/issues/detail?id=3109

http://en.wikipedia.org/wiki/Exponentiation#Complex_powers_of_positive_real_numbers
says "the
identity (b**z)**u = b**(z*u) [where b is a positive real] is
valid...when z is real or u is an integer". (I wonder if |z| <= 1 is an
additional acceptable criteria.)

In the above we have b = E, z = 4*a and u = 1/2. u is not an integer and
4*I*pi/2 is 2*I*pi which is neither real nor less than 1 in magnitude.

sy...@googlecode.com

unread,
Mar 5, 2012, 2:15:02 AM3/5/12
to sympy-...@googlegroups.com

Comment #2 on issue 3109 by smi...@gmail.com: sqrt(exp(4*a)) != exp(2*a)
http://code.google.com/p/sympy/issues/detail?id=3109

https://github.com/sympy/sympy/pull/1105 has changes which modify power
rules. Tom might want to take a look since there are exp_polar related
changes; and it would be helpful if someone can prove that the
experimentally determined criteria `abs(e) < S.Pi/log(b)` is sufficient to
ensure that `(b**e)**a` == `b**(e*a)` when e is not real. I've done some
experimenting on my own and think it is right for b real or imaginary.

sy...@googlecode.com

unread,
Mar 5, 2012, 3:47:29 PM3/5/12
to sympy-...@googlegroups.com

Comment #3 on issue 3109 by asme...@gmail.com: sqrt(exp(4*a)) != exp(2*a)
http://code.google.com/p/sympy/issues/detail?id=3109

> it would be helpful if someone can prove that the experimentally

> determined criteria `abs(e) < S.Pi/log(b)` is sufficient to ensure that
> `(b**e)**a` == `b**(e*a)` when e is not real.

Are you making any assumptions on b?

sy...@googlecode.com

unread,
Mar 5, 2012, 3:52:35 PM3/5/12
to sympy-...@googlegroups.com

Comment #4 on issue 3109 by smi...@gmail.com: sqrt(exp(4*a)) != exp(2*a)
http://code.google.com/p/sympy/issues/detail?id=3109

No assumptions on b; it can be complex. And the rhs should be
abs(pi/log(b)).

sy...@googlecode.com

unread,
Mar 14, 2012, 3:05:13 PM3/14/12
to sympy-...@googlegroups.com
Updates:
Labels: -Priority-Medium Priority-Critical

Comment #5 on issue 3109 by smi...@gmail.com: sqrt(exp(4*a)) != exp(2*a)
http://code.google.com/p/sympy/issues/detail?id=3109

There are problems with how Pow.as_numer_denom works that leads to the
following error:

>>> print filldedent(str(m3))

-1484/375 - 4*(-12459439/52734375 + 114*sqrt(12657)/78125)**(1/3) -
172564/(140625*(-12459439/52734375 + 114*sqrt(12657)/78125)**(1/3))
>>> sqrt(m3).n()
0.221187120060844 + 2.51253478736008*I
>>> n,d=sqrt(m3).as_numer_denom()
>>> (n/d).n()
-0.221187120060844 - 2.51253478736008*I

This has also been fixed in https://github.com/sympy/sympy/pull/1105

sy...@googlecode.com

unread,
Mar 15, 2012, 12:14:40 PM3/15/12
to sympy-...@googlegroups.com

Comment #6 on issue 3109 by smi...@gmail.com: sqrt(exp(4*a)) != exp(2*a)
http://code.google.com/p/sympy/issues/detail?id=3109

Mul._eval_power also has an error that leads to the following failure:

>>> e=-sqrt(3)*(1+2*I)
>>> sqrt(e.n()).n()
1.03463339851334 - 1.6740720046904*I
>>> sqrt(e).n()
-1.03463339851334 + 1.6740720046904*I
>>> sqrt(e)
3**(1/4)*I*sqrt(1 + 2*I)

The negative sign should have been left inside. This is also fixed in
https://github.com/sympy/sympy/pull/1105

sy...@googlecode.com

unread,
Mar 20, 2012, 5:45:31 PM3/20/12
to sympy-...@googlegroups.com
Updates:
Status: Fixed

Comment #8 on issue 3109 by smi...@gmail.com: sqrt(exp(4*a)) != exp(2*a)
http://code.google.com/p/sympy/issues/detail?id=3109

(No comment was entered for this change.)

Reply all
Reply to author
Forward
0 new messages