Skip to content

Build a whole power by a loop over the exponent's bits - #2363

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
fix/whole-power-without-recursion
Nov 4, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
fix/whole-power-without-recursion

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

(-1)^(2^20000) overflowed the stack of a thread-pool thread, which is 1.5 MB on Linux. A stack overflow ends the process rather than throwing. limitcheck died that way at DEPTH=3, SEED=28, while evaluating a sample point.

The whole power was built by a recursion on half the exponent, one frame per bit. IsTooLargeToBuild rightly never stops a power of -1, i or -i, since those do not grow, so nothing bounded the depth.

It is now a loop from the exponent's top bit down. The loop makes the same multiplications in the same order. The recursion's half truncates toward zero, so a negative exponent is the bits of its magnitude, each one multiplying by 1 / num. Exact and decimal powers, real and complex, come out digit for digit as before. The test pins four of them, beside the unit powers on a 256 KB thread, where master ends the test host with "Stack overflow".

limitcheck at SEED=28 now finishes its 600 expressions. Suite, AOT and the harnesses are green locally. No issue was filed.

🤖 Generated with Claude Code

The whole power was a recursion on the half of the exponent, one frame for
each of its bits, and a power of -1, i or -i is never too large to build. So
(-1)^(2^20000) took 20000 frames and overflowed the stack of a thread-pool
thread, 1.5 MB on Linux -- which ends the process rather than throwing.
limitcheck died that way at SEED=28, evaluating a sample point.

A loop from the exponent's top bit down makes the same multiplications in
the same order: the recursion's half truncates toward zero, so a negative
exponent is the bits of its magnitude, each multiplying by 1 / num. Exact
and decimal powers, real and complex, come out digit for digit as before.

limitcheck at DEPTH=3, SEED=28 now finishes its 600 expressions. No issue
was filed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rafael-SOWNet Rafael-SOWNet added this to the 2.7.0 milestone Nov 4, 2026
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Nov 4, 2026
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.78%. Comparing base (43d9b81) to head (f7d1527).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2363   +/-   ##
=======================================
  Coverage   86.78%   86.78%           
=======================================
  Files         312      312           
  Lines       68825    68825           
  Branches    20053    20053           
=======================================
+ Hits        59732    59733    +1     
  Misses       4909     4909           
+ Partials     4184     4183    -1     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.33% <100.00%> (+<0.01%) ⬆️
fsharp 32.97% <ø> (ø)
interactive 40.72% <ø> (ø)

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

Files with missing lines Coverage Δ
...uriMath/Core/Entity/Continuous/Number/Operators.cs 90.87% <100.00%> (ø)

... and 7 files with indirect coverage changes

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

@Rafael-SOWNet
Rafael-SOWNet merged commit 53ce725 into master Nov 4, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Nov 4, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the fix/whole-power-without-recursion branch November 4, 2026 07:19
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.

1 participant