Skip to content

sqrt returns incorrect results at complex infinities #776

Description

@pearu

As in the title.

Reproducer (mpmath version 1.4.0a1.dev43+g0d287bf):

>>> mpmath.mp.sqrt(mpmath.mp.mpc(mpmath.mp.inf, mpmath.mp.inf))  # expected (+∞,+∞)
mpc(real='+inf', imag='nan')
>>> mpmath.mp.sqrt(mpmath.mp.mpc(-mpmath.mp.inf, mpmath.mp.inf))  # expected (+∞,+∞)
mpc(real='nan', imag='+inf')
>>> mpmath.mp.sqrt(mpmath.mp.mpc(mpmath.mp.inf, -mpmath.mp.inf))  # expected (+∞,-∞)
mpc(real='+inf', imag='nan')
>>> mpmath.mp.sqrt(mpmath.mp.mpc(-mpmath.mp.inf, -mpmath.mp.inf))  # expected (+∞,-∞)
mpc(real='nan', imag='-inf')

mpmath.fp gives expected results as defined by https://en.cppreference.com/w/cpp/numeric/complex/sqrt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions