Skip to content

Compare numerically to half the evaluation's digits, where the comparison was exact - #2062

Merged
Rafael-SOWNet merged 3 commits into
masterfrom
compare-numerically-to-the-precision
Oct 22, 2026
Merged

Rafael-SOWNet merged 3 commits into
masterfrom
compare-numerically-to-the-precision

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Fixes #1674.

  • The defect. MathS.UnsafeAndInternal.AreEqualNumerically evaluated both sides at its check points and compared the values with !=. Two equal expressions computed by different routes differ in their last digits. So the derivative of x ln(x)'s antiderivative, 2 x (-1/4 + ln(x)/2) + 1/x * 2/4 * x^2, read as unequal to x ln(x) at -100 and 100.
  • The change. Two finite values now agree when they differ by no more than half the evaluation's digits, relative to the larger of them or to one. A value that is not finite agrees only with itself, and a NaN is still passed over. A difference of 1e-40 still counts at the default hundred digits.
  • Where else it reaches. The limit solver's check that a limit agrees from both sides goes through the same comparison.
  • The MCP server keeps its own comparison, at positive reals and with an answer for "could not evaluate". Its comment no longer says the library's comparison is exact.

AreEqualNumericallyToThePrecisionTest: the two cases from the issue fail on master. The pairs that are equal by every route, and the two differences above the tolerance, pass on both. The full unit suite passes (16,709), and so do the MCP tests (325). The library builds for netstandard2.0. The BREAKING-CHANGES entry opens the section for changes since 2.6.0. #2061 opens it too, so whichever merges second has one heading to resolve.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

…ison was exact

AreEqualNumerically evaluated both sides at its check points and compared
the values with !=. Two equal expressions computed by different routes
differ in their last digits, so the derivative of x ln(x)'s
antiderivative, 2 x (-1/4 + ln(x)/2) + 1/x * 2/4 * x^2, read as unequal
to x ln(x) at -100 and 100. Two finite values now agree when they differ
by no more than half the evaluation's digits, relative to the larger of
them or to one; a value that is not finite agrees only with itself, and a
NaN is still passed over. A difference of 1e-40 is still a difference.
The limit solver's two-sided check goes through the same comparison.

The MCP server keeps its own comparison, at positive reals and with an
answer for "could not evaluate", and its comment no longer says the
library's is exact; its README lists the workarounds that remain.

Fixes #1674.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Rafael-SOWNet and others added 2 commits October 22, 2026 14:27
…-to-the-precision

# Conflicts:
#	BREAKING-CHANGES.md
#	Sources/MCP/README.md
The README listed the workarounds waiting for the library by issue, and every PR that fixed one
edited the list, so the PRs fixing #1673-#1676 conflicted with each other one merge at a time.
Each workaround links its issue in a comment beside it, which is where it is removed.

Part of #1674.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet
Rafael-SOWNet merged commit e230dd7 into master Oct 22, 2026
34 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in AngouriMath Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

AreEqualNumerically compares without a tolerance, so equal expressions read as unequal

1 participant