Skip to content

Preserve real-axis branches in complex asin and acos - #1437

Draft
agourakis82 wants to merge 1 commit into
xtensor-stack:masterfrom
agourakis82:fix/complex-asin-real-axis-1432
Draft

agourakis82 wants to merge 1 commit into
xtensor-stack:masterfrom
agourakis82:fix/complex-asin-real-axis-1432

Conversation

@agourakis82

@agourakis82 agourakis82 commented Oct 30, 2026 •

Copy link
Copy Markdown

Complex asin discards the imaginary component on the real-axis branch outside [-1, 1] and returns a positive real component for negative arguments. This also gives incorrect results in acos, which is defined through asin.

For example, asin(2 + 0i) returns approximately (1.5708, 0) instead of (1.5708, 1.31696), while asin(-4 + 0i) returns a positive half-pi instead of a negative one. Restore the signed real component and the imaginary magnitude using real acosh, with the branch side selected by the imaginary zero. Preserve the input imaginary zero inside [-1, 1]. Clamp the real acosh argument to its domain in lanes where that branch is discarded.

Add mixed-lane float/double regressions for asin and acos: both imaginary-zero signs, signed real zero, interior points, endpoints, adjacent values outside the endpoints, and off-axis controls. Comparisons use scalar C++ complex functions, with exact zero/sign assertions where applicable.

Validation (C++23):

Addresses part of #1432. Large off-axis cancellation/overflow, nonfinite inputs, and complete architecture coverage remain outside this patch. The new signed-zero assertions are disabled under fast-math; no fast-math signed-zero guarantee or full-suite pass is claimed. Floating-point exception freedom is not claimed: the clamp preserves the baseline FE_INVALID state for a focused interior-axis witness, including a pre-existing float FE_INVALID flag.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant