Skip to content

Commit e29b612

Browse files
A power of x shared by the numerator and every term of a sum below the bar is cancelled (#1800)
x/(a x + b x^3 + c x^5) and x/(x (a + b x^2 + c x^4)) arrive at the integrator as x^0/(a + b x^2 + c x^4), and no rule reads x^0 as a polynomial, so both were declined where 1/(a + b x^2 + c x^4) is answered. The integrand's normalization, on every call, now writes a zeroth power of anything with the variable in it as one: it differs from one only where its base is zero, a point the antiderivative passes through as it passes every removable one. And 1/(x (a x + b x^3 + c x^5)^2) ran past a minute: the power of x that SolveByPartialFractions takes out of a sum was written beside the one already there, x x^2 (a + b x^2 + c x^4)^2, which the splits read as two factors. The powers of one base are gathered before the quotient is asked again. Rubi's 1.2.4.2 goes from 125 to 128 of 130. Part of #718. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent fa6fed4 commit e29b612

4 files changed

Lines changed: 58 additions & 2 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,24 @@ also how the substitution `u = x^2` writes `x/(a + c x^4)^2` since 2.5.0, having
403403
| `"(x/(a + c*x^2))^2".ToEntity().Integrate("x")` | `integral(...)` | the same |
404404
| `"x/(a + c*x^4)^2".ToEntity().Integrate("x")` | the answer, in 0.1 s; 22 s on the unreleased master | the answer, in 0.06 s |
405405

406+
### A power of `x` shared by the numerator and every term of a sum below the bar is cancelled
407+
408+
**Answers where there were none.** `x/(a x + b x^3 + c x^5)` was declined, and so was
409+
`x/(x (a + b x^2 + c x^4))`, where `1/(a + b x^2 + c x^4)` is answered: the integrand arrives as
410+
`x^0/(a + b x^2 + c x^4)`, and no rule reads `x^0` as a polynomial. A zeroth power of anything with the
411+
variable in it is one to the integrator now, but where its base is zero, a point the antiderivative
412+
passes through as it passes every removable one. And `1/(x (a x + b x^3 + c x^5)^2)` ran past a
413+
minute: the power of `x` taken out of the sum was written beside the other one,
414+
`x x^2 (a + b x^2 + c x^4)^2`, which the splits read as two factors; the two are one power now. Rubi's
415+
1.2.4.2
416+
([#718](https://github.com/asc-community/AngouriMath/issues/718)).
417+
418+
| Input | Was (2.5.0) | Now |
419+
|---|---|---|
420+
| `"x/(a*x + b*x^3 + c*x^5)".ToEntity().Integrate("x")` | `integral(...)` | the antiderivative of `1/(a + b x^2 + c x^4)` |
421+
| `"x/(x*(a + b*x^2 + c*x^4))".ToEntity().Integrate("x")` | `integral(...)` | the same |
422+
| `"1/(x*(a*x + b*x^3 + c*x^5)^2)".ToEntity().Integrate("x")` | `integral(...)`; past a minute on the unreleased master | the antiderivative of `1/(x^3 (a + b x^2 + c x^4)^2)`, in a second |
423+
406424
### Arms no real coefficients reach are left out of a symbolic quadratic's antiderivative
407425

408426
**Shorter answers.** An integrand over a quadratic with symbols in it is answered by arms on its

‎Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -758,9 +758,13 @@ is var (multiple, leftover)
758758
// repeated linear over the rationals, and read as a quadratic with `a` in it the
759759
// split computed its digits modulo `(1 + u^2)^6` with `a` in every coefficient, for
760760
// an answer twice the length. Once: a primitive factor has no content to take out.
761+
// And the powers of x it takes out joined to the ones beside them: `x (a x + b x^3 + c x^5)^2`
762+
// is `x^3 (a + b x^2 + c x^4)^2`, and written `x x^2 (a + b x^2 + c x^4)^2` the splits
763+
// below read `x` and `x^2` as two factors and the search ran past a minute.
761764
if (WithTheContentOutOfEachSumFactor(denominator, x) is { } primitive
762-
&& (SolveByPartialFractions(numerator / primitive, x, integrateByParts)
763-
?? Integration.ComputeIndefiniteIntegral(numerator / primitive, x, integrateByParts)) is { } overPrimitives)
765+
&& Patterns.GatherPowersOfOneBase(numerator / primitive) is var overThePrimitives
766+
&& (SolveByPartialFractions(overThePrimitives, x, integrateByParts)
767+
?? Integration.ComputeIndefiniteIntegral(overThePrimitives, x, integrateByParts)) is { } overPrimitives)
764768
return overPrimitives;
765769

766770
// Written factors with a symbol in them that share a factor, or repeat one inside,

‎Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,14 @@ private static Entity Normalized(Entity expr, Entity.Variable x) =>
201201
// `x^3 arctan(x)^2/(1 + x^2)^3` from 0.1 s to 8.
202202
.Replace(node => node is Entity.Powf(Entity.Powf(var @base, var inner), Entity.Number.Integer whole) && inner is Entity.Number.Rational && inner is not Entity.Number.Integer && @base.ContainsNode(x)
203203
? MathS.Pow(@base, (inner * whole).InnerSimplified)
204+
: node)
205+
// A zeroth power of anything with the variable in it is one but where its base is
206+
// zero, a point the antiderivative passes through as the generic case does every
207+
// removable one: `x/(x (a + b x^2 + c x^4))` arrives as `x^0/(a + b x^2 + c x^4)`,
208+
// and no rule reads `x^0` as a polynomial, so it was declined where
209+
// `1/(a + b x^2 + c x^4)` is answered.
210+
.Replace(node => node is Entity.Powf(var zeroth, Entity.Number.Integer { IsZero: true }) && zeroth.ContainsNode(x)
211+
? Entity.Number.Integer.One
204212
: node);
205213

206214
/// <summary>

‎Sources/Tests/UnitTests/Calculus/PowerOfATrinomialIntegralTest.cs‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,31 @@ private static void DifferentiatesBack(string integrand, params (string, double)
6363
[InlineData("(d + k*x^2)/(a + b*x^2 + c*x^4)^3", 3.1)]
6464
public void PastTheSquare(string integrand, double b)
6565
=> DifferentiatesBack(integrand, ("a", 1.3), ("b", b), ("c", 0.9), ("d", 0.4), ("k", 1.1));
66+
67+
/// <summary>
68+
/// A power of x above the bar and the same power below it: the integrand arrives as
69+
/// <c>x^0/(a + b x^2 + c x^4)</c>, and no rule read <c>x^0</c> as a polynomial, so it was
70+
/// declined where <c>1/(a + b x^2 + c x^4)</c> is answered. Rubi's 1.2.4.2
71+
/// <c>x/(a x + b x^3 + c x^5)</c>.
72+
/// </summary>
73+
[Theory]
74+
[InlineData("x/(a*x + b*x^3 + c*x^5)", 0.7)]
75+
[InlineData("x/(a*x + b*x^3 + c*x^5)", 3.1)]
76+
[InlineData("x/(x*(a + b*x^2 + c*x^4))", 0.7)]
77+
[InlineData("x^3/(x^3*(a + b*x^2 + c*x^4))", 3.1)]
78+
public void AZerothPowerOfXIsOne(string integrand, double b)
79+
=> DifferentiatesBack(integrand, ("a", 1.3), ("b", b), ("c", 0.9));
80+
81+
/// <summary>
82+
/// A square of a sum with a power of x in every term, beside a power of x: the power comes
83+
/// out of the sum and was written beside the other, <c>x x^2 (a + b x^2 + c x^4)^2</c>, which
84+
/// the splits read as two factors, and the search ran past a minute. Rubi's 1.2.4.2.
85+
/// </summary>
86+
[Theory]
87+
[InlineData("1/(x*(a*x + b*x^3 + c*x^5)^2)", 0.7)]
88+
[InlineData("1/(x*(a*x + b*x^3 + c*x^5)^2)", 3.1)]
89+
[InlineData("1/(x^3*(a*x + b*x^3 + c*x^5)^2)", 0.7)]
90+
public void ASquareWithAPowerOfXInEachTerm(string integrand, double b)
91+
=> DifferentiatesBack(integrand, ("a", 1.3), ("b", b), ("c", 0.9));
6692
}
6793
}

0 commit comments

Comments
 (0)