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
Inconsistent behavior in evaluation of the absolute value #20266
Comments
I would prefer it if all the examples remained unevaluated so they could be manipulated like Pow: In [9]: x, y, z = symbols('x, y, z', positive=True)
In [10]: (x*y)**z
Out[10]:
z
(x⋅y)
In [11]: expand((x*y)**z)
Out[11]:
z z
x ⋅y
In [12]: powsimp(_)
Out[12]:
z
(x⋅y) |
Agreed. However, expand doesn't work with the absolute value. >>> x, y = symbols('x, y', real=True)
>>> expand(Abs(x*y))
Abs(x*y) |
I think it would be good if expand could work with |
Agreed. An absolute value on a field is multiplicative so >>> x, y = symbols('x, y', real=True)
>>> sqrt((x*y)**2)
Abs(x)*Abs(y) This doesn't seem to work with complex numbers because Sympy doesn't realize that >>> w, z = symbols('w, z')
>>> expand(sqrt((w*z)*conjugate(w*z)))
sqrt((w*z)*conjugate(w*z))
>>> expand(sqrt((w)*conjugate(w)*z*conjugate(z)))
sqrt((w*z)*conjugate(w*z)) |
Are you suggesting adding something like |
I think |
From where can start working on this issue? I tried to search but could not find a starting point. Kindly give me a direction to start with. |
@theanshm I'm not exactly sure but it looks like there are two issues to fix:
|
While working on this issue I realized that changing the default behaviour is breaking a lot of stuff. Should I just make the output of Abs(x*y) consistent with the other outputs or just go on with changing the default behaviour and modifying the expand function? |
I'm not sure exactly what you are asking. To be clear I don't expect that it would be easy to make these changes. |
Actually while working on the above mentioned changes, I noticed that it broke a lot of other tests. So I was just confirming if changing the way that Abs works is the right way to go or should I just make it so that,
which makes it consistent with the other Abs outputs such as:
|
Changing how Abs works so we have
is the right way to go to fix the first issue. That will break a lot of tests which is probably why @oscarbenjamin doesn't expect it to be easy to make these changes. |
Ok, got it. Thanks for the clarification. |
It seems like there's a bug in how the absolute value is evaluated.
I would expect
Abs(x*y)
to evaluate toAbs(x)*Abs(y)
.The text was updated successfully, but these errors were encountered: