Skip to content

Commit

Permalink
Fix log1p with complex Irrational argument (#21784)
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano authored and tkelman committed May 14, 2017
1 parent bd28e02 commit 320892a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ function log1p(z::Complex{T}) where T
# This is based on a well-known trick for log1p of real z,
# allegedly due to Kahan, only modified to handle real(u) <= 0
# differently to avoid inaccuracy near z==-2 and for correct branch cut
u = float(one(T)) + z
u = one(float(T)) + z
u == 1 ? convert(typeof(u), z) : real(u) <= 0 ? log(u) : log(u)*z/(u-1)
elseif isnan(zr)
Complex(zr, zr)
Expand Down
1 change: 1 addition & 0 deletions test/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -948,5 +948,6 @@ end
for x in (pi, e, catalan) # No need to test all of them
@test typeof(Complex(x, x)) == Complex{typeof(x)}
@test exp(complex(x, x)) exp(x) * cis(x)
@test log1p(complex(x, x)) log(1 + complex(x, x))
end
end

0 comments on commit 320892a

Please sign in to comment.