Skip to content

BUG: arcsin evaluation on branch cuts deviates from Python array API standard  #26310

Closed
@pearu

Description

@pearu

Describe the issue:

According to Python array API standard, arcsin(z) is defined as

-1j * ln(z*1j + sqrt(1 - z**2))

As demonstrated below, the evaluation of numpy.arcsin and using the definition above lead to different results on the real line when abs(z.real) > 1.

Reproduce the code example:

import numpy
z = complex(2, 0)
print(numpy.arcsin(z))                            # -> (1.5707963267948966+1.3169578969248166j)
print(-1j*numpy.log(z*1j + numpy.sqrt(1 - z*z)))  # -> (1.5707963267948966-1.3169578969248166j)

Error message:

No response

Python and NumPy Versions:

2.0.0rc1
3.11.8 | packaged by conda-forge | (main, Feb 16 2024, 20:53:32) [GCC 12.3.0]

Runtime Environment:

No response

Context for the issue:

See also mpmath/mpmath#786 that contains some data points on how other software evaluate arcsin on its branch cuts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions