Skip to content

ArcTanh, ArcCoth: Indeterminate where the error covers the pole, as in WMA - #2063

Merged
tombouctou merged 2 commits into
masterfrom
arctanh-pole-indeterminate
Oct 20, 2026
Merged

tombouctou merged 2 commits into
masterfrom
arctanh-pole-indeterminate

Conversation

@tombouctou

Copy link
Copy Markdown
Collaborator

A follow-up to #2056 (part of #2047).

ArcTanh and ArcCoth have poles at 1 and -1. For an inexact argument there, SymPy gave Infinity. Near a pole, the old path gave 0. or a complex number even when the argument's error covered the pole. In WMA, if the error of an inexact argument covers a pole, the result is Indeterminate: within that error, the function goes to Infinity on one side and takes an imaginary part on the other. A machine number has no error, so only 1. and -1. themselves are covered. Exact ArcTanh[1] is still Infinity.

This is a new MPMathFunction attribute, indeterminate_at, checked by covers_point in mathics/eval/numeric.py.

Input master this PR WMA 15
ArcTanh[1.`20] Infinity Indeterminate Indeterminate
ArcTanh[-1.] -Infinity Indeterminate Indeterminate
ArcCoth[1.] Infinity Indeterminate Indeterminate
ArcTanh[1.0000001`5] Infinity Indeterminate Indeterminate
ArcTanh[0.9999999`5] 0. Indeterminate Indeterminate
ArcTanh[1.000001`6] 7.27805 - 1.5708 I Indeterminate Indeterminate
Precision[ArcTanh[0.999999`6.1]] 1.26163 1.26163 1.26163
ArcTanh[1] Infinity Infinity Infinity

Right at the boundary, WMA gives ArcTanh[0.999999`6] = 0-6.``, which looks like an artifact. Here it is a number with precision about 1.16.

Tests

In test_hyperbolic_real_valued_precision (test/builtin/atomic/test_numbers.py), with WMA 15 values, plus a doctest in ArcTanh. Full run on kimmy next to master: all 4620 doctests pass. The pytest failures are the ones that depend on test order: each failing file passes when run on its own.

🤖 Generated with Claude Code

…n WMA

An inexact argument whose error covers 1 or -1, as ArcTanh[1.`20],
ArcTanh[1.] or ArcTanh[1.0000001`5], gives Indeterminate, as in WMA,
instead of Infinity from SymPy. Exact ArcTanh[1] stays Infinity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
("ArcTanh[1.0000001`5]", "Indeterminate", "the error covers the pole"),
("ArcTanh[0.9999999`5]", "Indeterminate", None),
("ArcTanh[1.000001`6]", "Indeterminate", None),
("Precision[ArcTanh[0.999999`6.1]]", "1.26163", "the error misses it"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
("Precision[ArcTanh[0.999999`6.1]]", "1.26163", "the error misses it"),
("Precision[ArcTanh[0.999999`6.1]]", "1.26163", "the error misses the pole"),

If we get a failure message, the person seeing the failure probably will not immediately know what "it" refers to.

@rocky

rocky commented Oct 20, 2026

Copy link
Copy Markdown
Member

LGTM

@tombouctou
tombouctou merged commit 8712bc7 into master Oct 20, 2026
15 checks passed
@tombouctou
tombouctou deleted the arctanh-pole-indeterminate branch October 20, 2026 21:41
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.

2 participants