Skip to content
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

abs2(x) == conjugate(x)*x #332

Closed
benneti opened this issue Feb 20, 2020 · 7 comments
Closed

abs2(x) == conjugate(x)*x #332

benneti opened this issue Feb 20, 2020 · 7 comments

Comments

@benneti
Copy link

benneti commented Feb 20, 2020

Hi,
I think the title already describes the problem.
Is this outside the scope of the project?
A simple fix/workaround for own code is:

import Base.abs2
abs2(x::Sym) = x*conjugate(x)

Best,
Benedikt

PS: the same is true when using conj(x)

@jverzani
Copy link
Collaborator

Sure, we could add this. Do you want to make a pull request with a simple test?

@benneti
Copy link
Author

benneti commented Feb 20, 2020

yeah, no problem

@benneti
Copy link
Author

benneti commented Feb 24, 2020

I just checked it in Python and there
simplify(abs(x)**2 - conjugate(x)*x) == 0 is false, too.
Therefore I think this is actually not an issue with the Package and should probably be addressed in the python package.

@jverzani
Copy link
Collaborator

No, there is an issue with SymPy. I checked and have abs2 misdefined. I will make it x*conj(x) instead of abs(x)^2. Thanks.

@mzaffalon
Copy link
Contributor

Is there any reason to prefer x*conj(x) to conj(x)*x? Does x commute with its conjugate?

@jverzani
Copy link
Collaborator

jverzani commented Feb 24, 2020 via email

@benneti
Copy link
Author

benneti commented Feb 24, 2020

As far as I understand, sympy simply still has some inconsistencies.
See for example sympy/sympy#10822 , which basically tells you that to get the equality you have to expand with complex=true else it will not realize that stuff like the equality in the title are true.

jverzani added a commit to jverzani/SymPy.jl that referenced this issue Feb 25, 2020
jverzani added a commit that referenced this issue Feb 25, 2020
* bump SpecialFunctions, version number

* define abs2 differently; address issue #332
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants