Skip to content

MethodError caused by implementation of complex rationals in a small region (function fails for -0.6 + 0.0*im < z < -0.4 + 0.0*im) #35

@RobbieMackenzie

Description

@RobbieMackenzie

Hi,

Thanks for the package, I use it a lot.

I've noticed an issue with the implementation. There is a small region of complex floating-point arguments which trigger this line (line 151) in the case structure:-

w = abs(z+ 1//2) < 1//10 ? imag(z) > 0 ? complex(pointseven, pointseven) : complex(pointseven, -pointseven) : z

If w is assigned either complex(pointseven, pointseven) or complex(pointseven, -pointseven), then the root finding raises a MethodError, because of the function signature (line 168)

function lambertw_root_finding(z::T, x0::T, maxits) where T <: Number

which expects z and x0 to have the same type, but it will get z::ComplexF64 and x0::Complex{Rational{Int64}}.

On the real line this corresponds to approximately -0.6 < z -0.4, and it doesn't take much of an imaginary part before the problematic line isn't triggered, which may explain why no-one's spotted it until now!

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions