Skip to content

A limit of a logarithm that is not decided is left unevaluated - #2278

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
a-limit-of-a-logarithm-that-is-not-decided-is-left-unevaluated
Oct 31, 2026
Merged

Rafael-SOWNet merged 1 commit into
masterfrom
a-limit-of-a-logarithm-that-is-not-decided-is-left-unevaluated

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

limit(ln(2 + sin(x)), x, +oo) overflowed the stack and took the process down, in 2.6.0 and on master.

The cycle:

  1. When a limit node simplifies, it evaluates its expression first, so ln(f) becomes log(2.718..., f).
  2. ExpandLogarithm wrote every base except the symbol e as a quotient, ln(f) / ln(2.718...).
  3. The first remarkable limit asks whether that numerator vanishes, through a limit node of ln(f). That node is evaluated, so the same question is asked again.

When the limit of ln(f) is decided, the loop ends. When it is not, it never did.

ExpandLogarithm now reads a base that is e, evaluated, as e.

Input 2.6.0 Now
limit(ln(2 + sin(x)), x, +oo) stack overflow unevaluated
limitright(ln(sin(1/x) + 2), x, 0) stack overflow unevaluated

UndecidedLogarithmLimitTest: on master the test host crashes with a stack overflow. The suite (18,251), the trio, F#, AOT and the eight harnesses pass locally.

Found while working on the branch-cut half of #2266. Declining a limit there made the same cycle reachable from ln(x^x), so that fix waits for this one.

Fixes #2273.

🤖 Generated with Claude Code

limit(ln(2 + sin(x)), x, +oo) overflowed the stack. A limit node
simplifies its expression evaluated, in which ln(f) is
log(2.718..., f). ExpandLogarithm wrote every base but the symbol e as
a quotient, ln(f) / ln(2.718...), and the first remarkable limit asks
whether its numerator vanishes through a limit node of ln(f), which is
evaluated, and so asks the same question again. Where the limit of
ln(f) is decided that ends; where it is not, it did not.

ExpandLogarithm now reads a base that is e evaluated as e, and writes
the logarithm as ln(f) rather than as a quotient.

UndecidedLogarithmLimitTest takes five limits of logarithms of
oscillating arguments, which must come back unevaluated or NaN, and
three decided ones. On master the test host crashes with a stack
overflow on the first five. The suite, the trio, F#, AOT and the eight
harnesses pass.

Fixes #2273.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Rafael-SOWNet Rafael-SOWNet added this to the 2.7.0 milestone Oct 30, 2026
@Rafael-SOWNet Rafael-SOWNet moved this from Todo to In review in AngouriMath Oct 30, 2026
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.71%. Comparing base (aab5e7f) to head (414f1fa).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2278      +/-   ##
==========================================
- Coverage   86.72%   86.71%   -0.02%     
==========================================
  Files         310      310              
  Lines       67841    67846       +5     
  Branches    19689    19690       +1     
==========================================
- Hits        58834    58830       -4     
- Misses       4891     4895       +4     
- Partials     4116     4121       +5     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.26% <100.00%> (-0.02%) ⬇️
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 Δ
...ns/Continuous/Limits/Solvers/Solvers.Definition.cs 89.61% <100.00%> (+0.06%) ⬆️

... 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 6cabd96 into master Oct 31, 2026
35 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in AngouriMath Oct 31, 2026
@Rafael-SOWNet
Rafael-SOWNet deleted the a-limit-of-a-logarithm-that-is-not-decided-is-left-unevaluated branch October 31, 2026 01:34
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.

A limit of a logarithm that is not decided overflows the stack

1 participant