New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong result from Matrix norm #11413

Closed
asmeurer opened this Issue Jul 20, 2016 · 8 comments

Comments

Projects
None yet
3 participants
@asmeurer
Copy link
Member

asmeurer commented Jul 20, 2016

Reported on the mailing list:

>>> v=symbols('v:3',real=True);v
(v0, v1, v2)
>>> V=Matrix(v);V
Matrix([
[v0],
[v1],
[v2]])
>>> U=V.normalized()
>>> U
Matrix([
[v0/sqrt(v0**2 + v1**2 + v2**2)],
[v1/sqrt(v0**2 + v1**2 + v2**2)],
[v2/sqrt(v0**2 + v1**2 + v2**2)]])
>>> U.norm()
sqrt(v0**2/(-v0**2 - v1**2 - v2**2) + v1**2/(-v0**2 - v1**2 - v2**2) + v2**2/(-v0**2 - v1**2 - v2**2))
>>> _.simplify()
I

The answer should be 1. Where are those minus signs coming from?

@kritkaran94

This comment has been minimized.

Copy link
Contributor

kritkaran94 commented Jul 20, 2016

How to work on this ? I want to take up this issue.

@jksuom

This comment has been minimized.

Copy link
Member

jksuom commented Jul 20, 2016

This line will change the sign when base = v0**2 + v1**2 + v2**2 is real but not known to be positive.

@asmeurer

This comment has been minimized.

Copy link
Member

asmeurer commented Jul 20, 2016

Is that line wrong?

Also, the check there should probably be for nonnegative, rather than positive. The square roots in the expression are not known to not be zero.

@jksuom

This comment has been minimized.

Copy link
Member

jksuom commented Jul 20, 2016

Maybe the sign should be left unchanged except when base is explicitly found to be negative.

@asmeurer

This comment has been minimized.

Copy link
Member

asmeurer commented Jul 20, 2016

Checking nonnegative instead of positive two lines above should be equivalent to that, since the whole block is only run if base.is_real.

@asmeurer

This comment has been minimized.

Copy link
Member

asmeurer commented Jul 20, 2016

Ah, no it won't because of None cases (which is the real problem for this issue). It needs to explicitly be

if base.is_negative:
    return (-base)**re(exponent)*exp(-S.Pi*im(exponent))
@kritkaran94

This comment has been minimized.

Copy link
Contributor

kritkaran94 commented Jul 21, 2016

I am working on this issue.

kritkaran94 added a commit to kritkaran94/sympy that referenced this issue Jul 21, 2016

skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 22, 2016

Correct Abs.eval when argument is Pow
Taken from comments in sympy/sympy#11413.  Also, a little
cleanup from test_complexes.py

Closes sympy/sympy#11413

skirpichev added a commit to skirpichev/diofant that referenced this issue Jul 22, 2016

Correct Abs.eval when argument is Pow
Taken from comments in sympy/sympy#11413.  Also, a little
cleanup from test_complexes.py

Closes sympy/sympy#11413
@jksuom

This comment has been minimized.

Copy link
Member

jksuom commented Jul 22, 2016

Fixed by #11417

@jksuom jksuom closed this Jul 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment