Open
Description
openedon Jun 5, 2024
Julia's base complex^complex
power function may produce NaN
for some arguments when the result should be representable because of underflow/overflow at intermediate stages of the computation.
Example:
julia> a=exp(1+im)
1.4686939399158851 + 2.2873552871788423im
julia> b=1e5*(1+im)
100000.0 + 100000.0im
julia> abs(a^b)
NaN
In this case, the naive implementation of complex powers produces a correct result
julia> abs(exp(b*log(a)))
1.0
I suspect that this issue was introduced by #24570.
The example is constructed to cause overflow/underflow in
Line 860 in a5d6b50
r^pᵣ
very large and exp(-pᵢ*θ)
very small.
Version info
julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 12 × Apple M2 Pro
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment