Skip to content

Judge a decimal root against the terms of the equation as written (#2645) - #2649

Open
Rafael-SOWNet wants to merge 1 commit into
masterfrom
false-root-2645
Open

Rafael-SOWNet wants to merge 1 commit into
masterfrom
false-root-2645

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Closes #2645

tanh, sinh and cosh are written with exponentials, and near 0 the parts of e^u - 1 or e^u - e^(-u) cancel. A root the numeric search found near 0 was judged against those parts (via LargestTerm, which multiplies out a factor that depends on x once the root is put in), and kept beside 0.

A root found in decimals is now also judged against the terms of the sum the equation is, each read whole and reached only through factors and divisors that do not depend on x (IsLargeBesideTheTermsAsWritten in SolveStatement.Verdict). It is dropped where its residual is more than 1% of the largest term. This only adds a reason to drop a decimal root.

.Solve("x") master / 2.10.0 this PR
10^3 tanh(x / 10^3) = x / 2 { 0, 1.1013E-13 } { 0 }
10^20 tanh(x / 10^20) = x / 3 { -3.1958E-13, 0 } { 0 }
10^6 sinh(x / 10^6) = 2 x { -4.9027E-13, 0, 4.9027E-13 } { 0 }
tanh(x) = x / 2, sinh(x) = 2 x, sin(x) = x / 2 their roots unchanged

The missing roots ±1915.008… of the first row are #2643's, answered by #2644.

Family check: 99 equations K F(x/K) in nine arcsin, arctan, tanh, sinh and cosh shapes, K = 10^-30 to 10^30, each root checked against mpmath at 120 digits: answered 90 → 90, roots 196 → 190, false roots 6 → 0, no true root lost.

Tests: ARootNearZeroIsJudgedByTheTermsAsWrittenTest, 9 cases, 5 of which fail on master. Full UnitTests suite (net10.0, on dccddc5 + this): 21854 passed, 0 failed, 13 skipped. Entry in BREAKING-CHANGES.md.

🤖 Generated with Claude Code

)

tanh, sinh and cosh are written with exponentials, so 10^3 tanh(x / 10^3)
= x / 2 is 10^3 (e^(2x / 10^3) - 1) / (e^(2x / 10^3) + 1) - x / 2. A root
the numeric search found near 0 was judged by IsEvidenceAgainst against
LargestTerm. LargestTerm reads the equation after the root is put in,
where every part is a number, so it multiplied out the factor
e^(2x / 10^3) - 1, which depends on x and cancels near 0, and read it as
terms of size 500. Beside those, the residual 5.5e-14 at x = 1.1e-13 was
nothing, so 1.1e-13 was answered beside 0. The terms of the equation are
1.1e-13 and 5.5e-14, and the residual is half the larger.

Verdict now also judges a root found in decimals against the terms of the
sum the equation is, each read whole, reached only through factors and
divisors that do not depend on x. It drops the root where the residual is
more than RelativeResidualTolerance of the largest. This only adds a
reason to drop a decimal root, and only where the terms cancel. Over 99
equations K F(x/K) = K g(x/K) in nine tanh, sinh, cosh, arcsin and
arctan shapes, K = 10^-30 to 10^30, the false roots go from 6 to 0
against mpmath at 120 digits, and no true root is lost.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codecov

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 34.61538% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.70%. Comparing base (dccddc5) to head (76dc198).

Files with missing lines Patch % Lines
...ontinuous/Solvers/EquationSolver/SolveStatement.cs 34.61% 12 Missing and 5 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2649      +/-   ##
==========================================
- Coverage   86.71%   86.70%   -0.01%     
==========================================
  Files         346      346              
  Lines       75647    75673      +26     
  Branches    22114    22127      +13     
==========================================
+ Hits        65596    65612      +16     
- Misses       5420     5426       +6     
- Partials     4631     4635       +4     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.20% <34.61%> (-0.01%) ⬇️
fsharp 32.79% <ø> (ø)
interactive 40.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ontinuous/Solvers/EquationSolver/SolveStatement.cs 83.52% <34.61%> (-3.14%) ⬇️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Status: Todo

Development

Successfully merging this pull request may close these issues.

A false root near 0 of 10^3 tanh(x / 10^3) = x / 2

1 participant