Skip to content

Evaluate an exact power too large to build as the decimal - #2347

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
an-exact-power-past-its-size-bound
Nov 3, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
an-exact-power-past-its-size-bound

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

An exact number to a whole power was built exactly however large. 46655^(10^20) has 4.7e20 digits, so its evaluation neither returned nor stopped when cancelled, and nor did Simplify of anything holding it. compilesweep found it on (x^x - 1)^(e^(e^x)) at 6. 2.6.0 does not finish it either. No issue was filed.

Past 2^24 bits (about five million digits) the power is now evaluated in the decimal context, the way 2^(10^7 + 0.5) already was:

before after
46655^(10^20) evaluated does not return +oo, 38 ms
(-3)^(10^20 + 1) does not return -oo
(1/3)^(10^20) does not return 0
"2^(10^10)".Simplify() does not return 2 ^ 10000000000
3^(10^7), i^(10^20), (-1)^(10^20+1) exact unchanged

An exact simplification leaves such a power as written. The library counts an infinity as exact, so without a guard 2^(10^10) would have simplified to +oo. The guard refuses an infinity whose only source is an oversized exact power.

Tests: AnExactPowerTooLargeToBuildTest, 12 cases under a 30 s cap each. The eight large cases fail on master by the cap; the four controls pass on both. The full suite, AOT and the nine harnesses pass. There is a BREAKING-CHANGES entry, measured on 2.6.0.

🤖 Generated with Claude Code

An exact number to a whole power was built exactly however large, so
46655^(10^20), which has 4.7e20 digits, neither returned nor stopped when
cancelled, and nor did a simplification of anything holding it. Found by
compilesweep on (x^x - 1)^(e^(e^x)) at 6; 2.6.0 does not finish it either.

Past 2^24 bits the power is evaluated in the decimal context, as the same
power with a half added already was: +oo past the range, -oo for an odd
power of a negative base, 0 below it. The exact powers of -1, i and -i are
unchanged, and so is every exact power that finishes today (3^(10^7) in
3.3 s). An exact simplification leaves such a power as written: an
infinity counts as exact, so without a guard 2^(10^10) simplified to +oo.

46655^(10^20) now evaluates in 38 ms. The eight large cases each hit the
30 s cap on master and pass here.

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

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.28571% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.77%. Comparing base (d41933e) to head (d0c3f23).

Files with missing lines Patch % Lines
...uriMath/Core/Entity/Continuous/Number/Operators.cs 84.21% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2347      +/-   ##
==========================================
- Coverage   86.78%   86.77%   -0.01%     
==========================================
  Files         312      312              
  Lines       68620    68645      +25     
  Branches    19971    19980       +9     
==========================================
+ Hits        59549    59570      +21     
- Misses       4903     4907       +4     
  Partials     4168     4168              
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.32% <89.28%> (-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/Functions/Evaluation/Evaluation.Classes.cs 85.37% <100.00%> (+0.49%) ⬆️
...uriMath/Core/Entity/Continuous/Number/Operators.cs 90.51% <84.21%> (-0.28%) ⬇️

... and 6 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 fb99ffe into master Nov 3, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Nov 3, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the an-exact-power-past-its-size-bound branch November 3, 2026 09:34
Rafael-SOWNet added a commit that referenced this pull request Nov 3, 2026
IsFinite is a cache made on an entity's first read of it, and each number
an evaluation or a power produces is a new entity. Asked of every exact
value in the exact-evaluation shortcut (the guard #2347 added) and of
every power built (the check this branch added), it cost about 250 KB and
237 KB on each solve of the kernel benchmark's SolveHard, +5.1% against
the gate's baseline. The parts answer the same question without the
cache, a rational part being finite as it is.

The size bound #2347 added is computed in longs as well; it measured free
as EIntegers, but it is asked of every exact power. SolveHard allocates
9,549,209 B, against 9,546,434 B before #2347 and 10,027,870 B before
this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rafael-SOWNet added a commit that referenced this pull request Nov 3, 2026
)

A complex number's parts are decimals in the precision context, whose
exponents end at 1e1000. A product or a whole power of finite numbers, a
part of which passed that end on the way, had oo - oo in it and was NaN:
(3+4i)^2000, (1+i)^(10^6) and (1e600+1e600i)^2, and Simplify returned the
NaN as well. 2.6.0 does the same.

A complex product whose parts leave the range is formed with unbounded
exponents and each part rounded into the context, and a complex power that
does is raised the same way. Each part past the range is the infinity of
its sign, as a real past it is +oo; within the range nothing changes, since
the bounded result is used whenever it is finite. (1+i)^(10^6) is +oo and
(1e600+1e600i)^2 is +oo i.

The guard against an infinity only rounding made now covers any sum,
product or power of exact finite operands (a power's base not zero), which
is exact and finite, so an exact simplification leaves (3+4i)^2000 as
written. An operand that is already a decimal is not covered: the
integrator reads a decimal sample past the range as +oo, and taking that
away made one Rubi antiderivative 23,030 characters long.

Read finiteness from a number's parts where every evaluation passes

IsFinite is a cache made on an entity's first read of it, and each number
an evaluation or a power produces is a new entity. Asked of every exact
value in the exact-evaluation shortcut (the guard #2347 added) and of
every power built (the check this branch added), it cost about 250 KB and
237 KB on each solve of the kernel benchmark's SolveHard, +5.1% against
the gate's baseline. The parts answer the same question without the
cache, a rational part being finite as it is.

The size bound #2347 added is computed in longs as well; it measured free
as EIntegers, but it is asked of every exact power. SolveHard allocates
9,549,209 B, against 9,546,434 B before #2347 and 10,027,870 B before
this commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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