Skip to content

incorrect (Inf + Inf*im)^2.0 and other complex^float #24515

@stevengj

Description

@stevengj

In Julia 0.4–0.7, I get:

julia> (Inf + Inf*im)^2.0
0.0 + Inf*im

which seems wrong (it assumes that the two Inf components are the "same"). The correct answer is given for ^2:

julia> (Inf + Inf*im)^2
NaN + Inf*im

The error seems to be due to this line, which dates back to #2891 by @jiahao.

My first inclination is to remove the entire p==2 special case from this ^ method. As I commented in #24497, that seems to be a performance optimization that is probably largely superseded, since most cases that need a fast z^2 probably use (a) an integer exponent (that calls a different method) and/or (b) a literal integer exponent (for which z^2 is inlined as z*z for Complex64 and Complex128).

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexComplex numbersmathsMathematical functions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions