diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md
index 5abee0b6d..1a19ed48d 100644
--- a/BREAKING-CHANGES.md
+++ b/BREAKING-CHANGES.md
@@ -448,6 +448,23 @@ searched as before, and where a search at another size cannot be run, the answer
| `10^(-12) arcsin(x / 10^(-12)) = x pi / 3` | `{ 0 }` | `{ 0, -5E-13, 5E-13 }` |
| `arcsin(x) = x pi / 3` | `{ -0.4999…, 0, 0.4999… }` | unchanged |
+### The limits at a break of an antiderivative are remembered
+
+**Not silent in time: answers or declines that did not arrive now do.** A definite integral across a break of its
+antiderivative takes the antiderivative's one-sided limits there. These were taken outside the cache
+that the limits at a bound have, so every candidate `Simplify` tried took them again. With a parameter, as in
+`1/(a + sin(x))` over `[0, 2 pi]`, they are undecided after seconds each, and the simplification did not finish. With
+numbers, several integrals of `1/(A + B sin(x))` across `pi` took over thirty seconds. Without an assumption on `a`
+the parametric integral is left unevaluated: it is `2 pi / sqrt(a^2 - 1)` for `a > 1` and diverges for `|a| <= 1`
+([#2658](https://github.com/asc-community/AngouriMath/issues/2658)).
+
+| simplified | Was (2.10.0), within 20 s | Now |
+|---|---|---|
+| `integral(1/(a + sin(x)), x, 0, 2 pi)` | did not finish | unevaluated, 8.5 s |
+| `integral(1/(a + cos(x)), x, 0, pi)` | unevaluated | unevaluated, 1.5 s |
+| `integral(1/(3 + sin(x)), x, 0, 5)` | did not finish | closed form = `1.68876…` |
+| `integral(1/(4 - sin(x)), x, -7, -2)` | did not finish | closed form = `1.36096…` |
+
### A definite integral of a function of abs is split where its argument changes sign
**An answer where there was none.** A definite integral whose integrand holds `abs(u)` was left unevaluated unless the
diff --git a/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs b/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs
index 26a6c80a2..c17fa3a90 100644
--- a/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs
@@ -181,8 +181,14 @@ public Entity Integrate(Variable x, Entity from, Entity to) =>
{
// Approached from the side the range comes from, then left on the other.
var (arriving, leaving) = lower < upper ? (ApproachFrom.Left, ApproachFrom.Right) : (ApproachFrom.Right, ApproachFrom.Left);
- var before = antiderivative.Limit(x, at, arriving);
- var after = antiderivative.Limit(x, at, leaving);
+ // Through the cache of the limits at a bound: an undecided limit at a break was taken again by every
+ // candidate Simplify tried, at seconds each, and with a parameter in the antiderivative they are undecided
+ // often -- the integral of 1/(a + sin(x)) over [0, 2 pi], whose antiderivative has a case for each sign of
+ // a^2 - 1 and a pole of tan(x/2) at pi in each, did not finish. Not under its budget: a limit at a break
+ // can take more limits than one at a bound and still be decided, as the antiderivative of
+ // 1/((1 + x^2)^(1/3) (9 + x^2)) at 0 does. https://github.com/asc-community/AngouriMath/issues/2658
+ var before = LimitAtTheBound(antiderivative, x, at, arriving, budgeted: false);
+ var after = LimitAtTheBound(antiderivative, x, at, leaving, budgeted: false);
if (before.Nodes.Any(node => node is Limitf) || after.Nodes.Any(node => node is Limitf))
return null;
total += before - after;
@@ -558,7 +564,7 @@ private static bool HoldsAnInfinity(Entity expr)
/// not settle, two seconds of search each time, and the simplification ran past two minutes.
/// https://github.com/asc-community/AngouriMath/issues/2081
///
- private static Entity LimitAtTheBound(Entity antiderivative, Variable x, Entity bound, ApproachFrom side)
+ private static Entity LimitAtTheBound(Entity antiderivative, Variable x, Entity bound, ApproachFrom side, bool budgeted = true)
{
if (limitsAtBounds is null || limitsAtBoundsUnder is null || !SettingsState.StillHolds(limitsAtBoundsUnder))
{
@@ -573,9 +579,9 @@ private static Entity LimitAtTheBound(Entity antiderivative, Variable x, Entity
// Within a budget of the limits it asks along the way. Past it the limit is undecided and the integral left
// as written, which is no wrong answer. The most a decided limit at a bound took in the tests is 957; one
// spelling of the antiderivative of ln(x) Si(x) took over 38,000 in forty seconds without deciding.
- var limit = Functions.Algebra.LimitFunctional.WithinABudget(LimitsAtABound,
- () => (bound.Evaled is Number.Real { EDecimal: var at } && at.IsInfinity() ? WithItsLogarithmsGathered(antiderivative, x, bound, side) : antiderivative)
- .Limit(x, bound, side));
+ Entity Taken() => (bound.Evaled is Number.Real { EDecimal: var at } && at.IsInfinity() ? WithItsLogarithmsGathered(antiderivative, x, bound, side) : antiderivative)
+ .Limit(x, bound, side);
+ var limit = budgeted ? Functions.Algebra.LimitFunctional.WithinABudget(LimitsAtABound, Taken) : Taken();
if (SettingsState.StillHolds(stamp))
{
if (into.Count >= 256)
diff --git a/Sources/Tests/UnitTests/Calculus/ALimitAtABreakIsRememberedTest.cs b/Sources/Tests/UnitTests/Calculus/ALimitAtABreakIsRememberedTest.cs
new file mode 100644
index 000000000..7c6e80017
--- /dev/null
+++ b/Sources/Tests/UnitTests/Calculus/ALimitAtABreakIsRememberedTest.cs
@@ -0,0 +1,44 @@
+//
+// Copyright (c) 2019-2026 Angouri.
+// AngouriMath is licensed under MIT.
+// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
+// Website: https://am.angouri.org.
+//
+
+using System;
+using System.Linq;
+using System.Threading.Tasks;
+using AngouriMath.Extensions;
+using Xunit;
+using static AngouriMath.Entity;
+
+namespace AngouriMath.Tests.Calculus
+{
+ ///
+ /// The antiderivative of 1/(a + sin(x)) has a case for each sign of a^2 - 1, and a pole of
+ /// tan(x/2) at pi in each, where its limits with a unknown are undecided after seconds. Those
+ /// limits were taken outside the cache of the limits at a bound, so every candidate
+ /// Simplify tried took them again, and the simplification of the integral over [0, 2 pi] did not
+ /// finish. Without an assumption on a it is left unevaluated: it is 2 pi / sqrt(a^2 - 1) for
+ /// a > 1 and diverges for |a| <= 1. https://github.com/asc-community/AngouriMath/issues/2658
+ ///
+ [Trait("Area", "Calculus")]
+ public sealed class ALimitAtABreakIsRememberedTest
+ {
+ [Theory]
+ [InlineData("1/(a + sin(x))", "0", "2 pi")]
+ [InlineData("1/(a + cos(x))", "0", "pi")]
+ public void AParametricIntegralAcrossAPoleIsLeftUnevaluatedInTime(string integrand, string from, string to)
+ {
+ var task = Task.Run(() => integrand.ToEntity().Integrate("x", from.ToEntity(), to.ToEntity()).Simplify());
+ Assert.True(task.Wait(TimeSpan.FromSeconds(60)), $"{integrand} over [{from}, {to}] did not finish");
+ Assert.Contains(task.Result.Nodes, node => node is Integralf);
+ }
+
+ /// At a numeric parameter the same integral has its value.
+ [Fact]
+ public void AtANumericParameterItIsAnswered()
+ => Assert.Equal(Number.Integer.Zero,
+ ("integral(1/(3 + cos(x)), x, 0, 2 pi) - 2 pi / sqrt(8)").ToEntity().Simplify());
+ }
+}