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

overflow bug in inv(::Complex) #5188

Closed
stevengj opened this issue Dec 18, 2013 · 1 comment
Closed

overflow bug in inv(::Complex) #5188

stevengj opened this issue Dec 18, 2013 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@stevengj
Copy link
Member

As discussed in #5112, inv(1e300+0im) gives 0.0 - 0.0im rather than 1e-300 - 0.0im. The problem is that the definition inv(z::Complex) = conj(z)/abs2(z) is not robust to overflows.

The right thing is probably:

  • Use a specialized version of the robust division algorithm to compute 1.0/z for Complex{Float64}, or maybe specialize it for /(r::Float64, z::Complex{Float64}) if that is faster than r*inv(z) (I'm guessing not). (Just take the existing complex-division algorithm and simplify it for the case of a real numerator 1.0.)
  • Use the naive algorithm with Float64 arithmetic for Complex{Float32} and Complex{Integer} types where there is no possibility of Float64 overflow.
  • Continue to use the naive algorithm for BigFloat.

(Similarly for complex division in general.)

@stevengj
Copy link
Member Author

cc: @ggggggggg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant