Skip to content

A power of a constant below 1e-50 is no longer simplified to zero - #1772

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
a-product-of-nonzero-numbers-is-not-rounded-to-zero
Oct 5, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
a-product-of-nonzero-numbers-is-not-rounded-to-zero

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

Closes #1769.

1/pi^136, about 2.4e-68, inner-simplified to 0, and so did any product, quotient or power of constants below 1e-50. Simplify raises constants to such powers on its way, and returned 0 for expressions that are not zero:

expression 2.5.0 master 85d6601c this
1/pi^136, inner-simplified 0 0 1/pi^136
e^(-160), inner-simplified 0 0 e^(-160)
pi^(-136) + pi^(-137), inner-simplified 0 0 as written
x^n ((1 - d^2)/x - x)^3 (1 + x^2 - d x)/(x - d)/pi^2, simplified 0 provided ... 0 provided ... itself, rearranged

What changes. Evaluation rounds a value within 1e-50 of an integer onto the integer, half the default hundred digits, which is what makes the residual of a cancellation -- sin(pi)'s, sqrt(2)^2 - 2's -- the zero it is; and inner simplification takes a node's value wherever that value is an exact number. A product cancels nothing, so a zero there is rounding alone: 1/pi^136 evaluated to 0, and that 0 was taken as its value. The shortcut passes over such a zero now where the node is a product, a quotient or a power of numbers and constants none of which is zero, or a sum of such of one sign, and the node is kept as written. Evaluation is unchanged: "1/pi^136".EvalNumerical() is 0 as before, the rounding being the setting's.

Where it showed. The integrator simplifies an integrand under a substitution, and answered e x^n (((a e f^2 - d^2 e)/(e x) - x)/2 + x)^3 (4 x (x - d) - 2 ((x - d)^2 - a f^2))/(f^3 (2 e x)^2), with Euler's e, as 0. The derivation of the last row's Simplify reaches (pi^136)^(-1), and its value is lost at that node's inner simplification.

Tests: PowerOfAConstantBelowTheToleranceTest: six expressions not rounded to zero, compared exactly with a rational for each constant; two cancellations still zero; and Simplify keeping the last row's value at a point. On master eight of its ten fail.

The full suite on the head, f1f8bfee, passes, 14,934 tests, and the allocation gate passed on the change; the library builds for netstandard2.0. The head is one commit on master 85d6601c.

🤖 Generated with Claude Code

https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura

InnerSimplified takes a node's value where that value is an exact number, and
evaluation rounds a value within 1e-50 of an integer onto it, so 1/pi^136,
about 2.4e-68, became 0, and Simplify, which raises constants to such powers on
its way, returned 0 for expressions that are not zero. A product, a quotient or a
power of numbers none of which is zero, or a sum of such numbers of one sign, is
kept as written now; evaluation still rounds.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
@Rafael-SOWNet Rafael-SOWNet added this to the 2.6.0 milestone Oct 5, 2026
@Rafael-SOWNet
Rafael-SOWNet merged commit 3a60557 into master Oct 5, 2026
34 checks passed
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.

A power of a constant below 1e-50 inner-simplifies to 0

1 participant