Skip to content

Commit 22ebb2a

Browse files
asech(a + b x) and acsch(a + b x) beside a power of x are integrated (#1457)
By parts they leave 1/(x (a + b x)^2 sqrt(1/(a + b x)^2 - 1)), and five things stood between that and an answer, each found by tracing and fixed in its place: - ComputeAsTheSameQuestion: taking a constant factor off an integrand, and cancelling its quotient, no longer consume a descent level -- b f(x) and f(x) are one question -- so the rules scoped to the question asked or one below it see the remainder by parts leaves. TakeConstantFactorOutOfNumerator no longer hands on `1 * f`. - Yun's square-free factorisation keeps an x-free content: a root beside the polynomial stood in the last cofactor and threw the factorisation away, and the remainder went on with `x (a + b x)^2` expanded. - SolveByWritingAPowerOfAQuotientApart writes an even power of a polynomial below the bar apart as sgn(P) P provided P^2 > 0, the sign in front of the answer -- only where the root is a factor of the integrand, since inside a logarithm the sign is no factor. - TakeConstantFactorOutOfDenominator keeps (a + b x)^k as written where the polynomial stands under a root elsewhere, and a radicand written in two orders is one spelling where it stands to both signs; the cancellation runs before the reduction over a linear factor and the sum split, which expanded what it cancels whole. - PartialFractions bounds the values a linear solve hands on: for the remainder from acoth(c x) ln(1 - c^2 x^2) the nine values came out at ten million nodes each, and pinning a symbol in them ran out of memory. Rubi's family 7: 194 to 206 of 270, 0 wrong, timeouts 44 to 34, wall 1445 to 1185 s; the 1774-problem suite unchanged at 1706, 0 wrong, 0 timeout, wall 89 s. Suite 12531 passed; the kernel gate passed on all 19 gated benchmarks. Part of #718. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent f62db4c commit 22ebb2a

6 files changed

Lines changed: 259 additions & 26 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,24 @@ the crash harness found. Both now agree with the solver
902902
| `"{ x : 1/0 = x }".ToEntity().Evaled` | `NaN` | `{ }` |
903903
| `"x subset 2".ToEntity().Solve("x")` | `x * subset ^ 2` had no solution: `{ }` — `subset` is new since | `{ }`, where the unreleased keyword threw |
904904

905+
### `asech(a + b x)` and `acsch(a + b x)` beside a power of `x` are integrated
906+
907+
By parts they leave `1/(x (a + b x)^2 sqrt(1/(a + b x)^2 - 1))`, and the chain never read it:
908+
taking the remainder's constants out had carried it past the rules scoped to the question asked
909+
or one below it, the root beside the polynomial made Yun's factorisation expand
910+
`x (a + b x)^2`, the power was rewritten monic beside a root that kept `(a + b x)`, the
911+
radicand stood in two orders, and an even power of a linear below the bar was not written
912+
apart. Each fixed in its place; an even power of a polynomial `P` below the bar is now written
913+
apart as `sgn(P) P` with `provided P^2 > 0` — only where the root is a factor of the integrand
914+
([#718](https://github.com/asc-community/AngouriMath/issues/718)).
915+
916+
| Input | Was (2.5.0) | Now |
917+
|---|---|---|
918+
| `"asech(a+b*x)/x^2".Integrate("x")` | left unevaluated | the antiderivative, in `sgn(a + b x)`, `provided (a + b x)^2 > 0` |
919+
| `"x*asech(a+b*x)".Integrate("x")` | left unevaluated | the antiderivative |
920+
| `"acsch(a+b*x)/x^2".Integrate("x")` | left unevaluated | the antiderivative |
921+
| `"1/(x*(a+b*x)^2*sqrt(1/(a+b*x)^2-1))".Integrate("x")` | left unevaluated | the antiderivative |
922+
905923
### `binomial(n, k)` is a function
906924

907925
**Addition, not silent.** The binomial coefficient is a node, `Entity.Binomialf`, spelled

‎Sources/.editorconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed
291291
[AngouriMath/Functions/NumberTheory/ResidueClasses.cs]
292292
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n
293293

294+
[Tests/UnitTests/Calculus/InverseHyperbolicOfALinearIntegralTest.cs]
295+
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n
296+
294297
[Tests/UnitTests/Calculus/InverseHyperbolicOfAHyperbolicIntegralTest.cs]
295298
file_header_template=\nCopyright (c) 2019-2026 Angouri.\nAngouriMath is licensed under MIT.\nDetails: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.\nWebsite: https://am.angouri.org.\n
296299

‎Sources/AngouriMath/Functions/Algebra/Polynomials/PartialFractions.cs‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,18 @@ private static Entity AsFraction(RationalPolynomial numerator, RationalPolynomia
375375
/// </summary>
376376
private const int LargestValuePutInLowestTerms = 4096;
377377

378+
/// <summary>
379+
/// The largest decomposition, by the <see cref="Entity.Complexity"/> of its values
380+
/// together, that is checked and handed on. The elimination is fraction-free over the
381+
/// symbols, and its values grow as determinants do: for
382+
/// `(-8 c^11 x + ...)/((c x - 1)^2 (c x + 1))`, which by parts leaves from
383+
/// `acoth(c x) ln(1 - c^2 x^2)`, the nine values came out at ten million nodes each
384+
/// and the sum at thirty-three million, and pinning `c` in it to check it ran out of
385+
/// memory. Nothing downstream reads a decomposition of that size; the largest that
386+
/// was ever answered was eighty thousand, four values of twenty thousand.
387+
/// </summary>
388+
private const int LargestDecompositionHandedOn = 250_000;
389+
378390
/// <summary>
379391
/// <c>N/D</c> written as one fraction per factor of <paramref name="denominator"/>,
380392
/// where the denominator is <b>written</b> as a product of distinct linear and quadratic
@@ -584,6 +596,11 @@ internal static bool TrySplitOverWrittenFactors(
584596
for (var column = 0; column < width; column++)
585597
if (values[column].Complexity <= LargestValuePutInLowestTerms)
586598
values[column] = InLowestTermsOverTheSymbols(values[column]);
599+
// ...and not handed on at all past the bound: a decomposition of millions of
600+
// nodes is not one any rule reads, and pinning a symbol in it to check it is
601+
// what ran out of memory.
602+
if (values.Sum(value => (long)value.Complexity) > LargestDecompositionHandedOn)
603+
return false;
587604
Entity sum = 0;
588605
for (var i = 0; i < factors.Count; i++)
589606
{
@@ -1214,7 +1231,25 @@ private static bool IsZero(Entity entry, bool simplify)
12141231
=> entry == Integer.Zero || entry.Evaled is Complex { IsZero: true }
12151232
|| (simplify && entry.Evaled is not Complex && entry.Simplify().Evaled is Complex { IsZero: true });
12161233

1234+
/// <summary>
1235+
/// <see cref="TrySolveLinearUnbounded"/> with its values bounded by
1236+
/// <see cref="LargestDecompositionHandedOn"/> together: the eliminations over the
1237+
/// symbols hand back quotients of determinants, which grow as determinants do, and
1238+
/// past the bound the values are declined here rather than substituted, checked and
1239+
/// simplified downstream -- writing an atom back into nine values of ten million
1240+
/// nodes each is where `acoth(c x) ln(1 - c^2 x^2)` ran out of memory.
1241+
/// </summary>
12171242
private static bool TrySolveLinear(Entity[][] matrix, Entity[] rhs, bool symbolsMayCancel, [NotNullWhen(true)] out Entity[]? values)
1243+
{
1244+
if (!TrySolveLinearUnbounded(matrix, rhs, symbolsMayCancel, out values))
1245+
return false;
1246+
if (values.Sum(value => (long)value.Complexity) <= LargestDecompositionHandedOn)
1247+
return true;
1248+
values = null;
1249+
return false;
1250+
}
1251+
1252+
private static bool TrySolveLinearUnbounded(Entity[][] matrix, Entity[] rhs, bool symbolsMayCancel, [NotNullWhen(true)] out Entity[]? values)
12181253
{
12191254
values = null;
12201255
var rows = rhs.Length;

0 commit comments

Comments
 (0)