-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Sign of real part of -1.0im is negative #10000
Comments
Well, |
That's precisely the problem. |
We've been around that block before: #5468 |
Agreed, but I feel that it's worth reconsidering that decision, or least looking more carefully at how we do mixed real-imaginary and real-complex arithmetic. There have been a few issues with complex arithmetic recently like #9531 and #9790, and pure imaginary literals like |
The reason why this particular case is so important and problematic is that julia> f(z)=log(-im*z); f(-1.0im)
0.0 + 3.141592653589793im
julia> f(0.0-1.0im)
0.0 - 3.141592653589793im
julia> f(-0.0-1.0im)
0.0 + 3.141592653589793im
julia> asinh(-2.0im)
-1.3169578969248166 - 1.5707963267948966im
julia> asinh(0.0-2.0im)
1.3169578969248166 - 1.5707963267948966im
julia> atan(0.0-2.0im)
1.5707963267948966 - 0.5493061443340549im
julia> atan(-2.0im)
-1.5707963267948966 - 0.5493061443340549im In these situations, the sign of zero matters greatly. |
Maybe we should have |
The issue seems to be that the two operations "convert imaginary to complex" and "negate" commute for integer types, but do not commute for IEEE numbers. To make
I think people find the value of
(Of course, the implementations above are a sketch only.) I like the very elegant notation of an optimized |
That is a landmark issue number! |
@eschnett The problem is in complex multiplication, not in the order of negation vs multiplication: julia> (-1.0)im
-0.0 - 1.0im
julia> -(1.0im)
-0.0 - 1.0im Because @JeffBezanson's proposal to change @eschnett's proposal to have a separate imaginary type echoes Kahan's 1991 proposal. I think we have tried to follow the spirit of the proposal as much as possible without introducing |
@jiahao I spoke of the two operations "convert to complex" ( |
Ah, I didn't get the first time that you meant negation of non-floats. Yes that would also be true. |
Thinking about this again, after a long time: The expression We should come to a decision, then close this issue. |
Another example:
|
@simonbyrne's example from 6(!!!) years ago is still valid. Is that still something we're interested in addressing? |
This doesn't look right.
The text was updated successfully, but these errors were encountered: