Skip to content

Commit fc90704

Browse files
Rafael-SOWNetclaude
andcommitted
Merge master, with #1523: the breaking-changes entry moved beside the one it follows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
2 parents 17c0236 + 2005023 commit fc90704

3 files changed

Lines changed: 65 additions & 16 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,6 +1710,18 @@ since they are these exponentials
17101710
| `"(p + q*x)^2*f^(a + b*x + c*x^2)".Integrate("x")` | `integral((p + q * x) ^ 2 * f ^ (a + b * x + c * x ^ 2), x)` | the antiderivative |
17111711
| `"x^2*sinh(a + b*x + c*x^2)".Integrate("x")` | `integral(x ^ 2 * (e ^ (a + b * x + c * x ^ 2) - e ^ (-(a + b * x + c * x ^ 2))) / 2, x)` | the antiderivative |
17121712

1713+
### An exponential of a polynomial beside the polynomial's derivative is integrated
1714+
1715+
`e^(a + b x + c x^2) (b + 2 c x) sqrt(a + b x + c x^2)` was left unintegrated. `G^P k P' f(P)`, with
1716+
`P` a polynomial of degree two or more and `P'` a factor of its own up to a constant, is now
1717+
integrated under `u = P`, as `k G^u f(u)`
1718+
([#1501](https://github.com/asc-community/AngouriMath/issues/1501)).
1719+
1720+
| Input | Was (2.5.0) | Now |
1721+
|---|---|---|
1722+
| `"e^(a + b*x + c*x^2)*(b + 2*c*x)*(a + b*x + c*x^2)^(1/2)".Integrate("x")` | `integral(e ^ (a + b * x + c * x ^ 2) * (b + 2 * c * x) * sqrt(a + b * x + c * x ^ 2), x)` | the antiderivative, with `erfi` |
1723+
| `"e^(a + b*x + c*x^2)*(b + 2*c*x)/(a + b*x + c*x^2)^(3/2)".Integrate("x")` | `integral(e ^ (a + b * x + c * x ^ 2) * (b + 2 * c * x) / (a + b * x + c * x ^ 2) ^ (3/2), x)` | the antiderivative, with `erfi` |
1724+
17131725
### An exponential of a quadratic in `1/x` or `1/(c + d x)` is integrated
17141726

17151727
`e^(-1/x^2)` was left unintegrated. `L^m F^(A/L^2 + B/L + C)`, with `L = c + d x` and a whole `m`,
@@ -1760,17 +1772,19 @@ same question under `u = d + e x`
17601772
| `"(d*g + k*g*x)^m*F^(f*(a + b*ln(c*(d + k*x)^n))^2)".Integrate("x")` | `integral((d * g + k * g * x) ^ m * F ^ (f * (a + b * ln(c * (d + k * x) ^ n)) ^ 2), x)` | the antiderivative |
17611773
| `"(g + h*x)^3*F^(f*(a + b*ln(c*(d + k*x)^n)^2))".Integrate("x")` | `integral((g + h * x) ^ 3 * F ^ (f * (a + b * ln(c * (d + k * x) ^ n) ^ 2)), x)` | the antiderivative |
17621774

1763-
### An exponential of a polynomial beside the polynomial's derivative is integrated
1775+
### A power of `x` one less than a half-odd multiple of the power inside is integrated
17641776

1765-
`e^(a + b x + c x^2) (b + 2 c x) sqrt(a + b x + c x^2)` was left unintegrated. `G^P k P' f(P)`, with
1766-
`P` a polynomial of degree two or more and `P'` a factor of its own up to a constant, is now
1767-
integrated under `u = P`, as `k G^u f(u)`
1777+
`f^(a + b x^n) x^(-1 + 5n/2)` was left unintegrated. `x^(k n - 1) g(x^n)`, with a symbolic `n`, was
1778+
integrated under `u = x^n` for a whole `k` of 1 or more. For `k` half an odd number, of either sign,
1779+
it is now integrated under `u = x^(n/2)`, where `g(x^n)` is `g(u^2)`: beside an exponential of `x^n`
1780+
that is a moment of the Gaussian
17681781
([#1501](https://github.com/asc-community/AngouriMath/issues/1501)).
17691782

17701783
| Input | Was (2.5.0) | Now |
17711784
|---|---|---|
1772-
| `"e^(a + b*x + c*x^2)*(b + 2*c*x)*(a + b*x + c*x^2)^(1/2)".Integrate("x")` | `integral(e ^ (a + b * x + c * x ^ 2) * (b + 2 * c * x) * sqrt(a + b * x + c * x ^ 2), x)` | the antiderivative, with `erfi` |
1773-
| `"e^(a + b*x + c*x^2)*(b + 2*c*x)/(a + b*x + c*x^2)^(3/2)".Integrate("x")` | `integral(e ^ (a + b * x + c * x ^ 2) * (b + 2 * c * x) / (a + b * x + c * x ^ 2) ^ (3/2), x)` | the antiderivative, with `erfi` |
1785+
| `"f^(a + b*x^n)*x^(-1 + 5/2*n)".Integrate("x")` | `integral(f ^ (a + b * x ^ n) * x ^ (-1 + 5/2 * n), x)` | the antiderivative |
1786+
| `"f^(a + b*x^n)*x^(-1 - 1/2*n)".Integrate("x")` | `integral(f ^ (a + b * x ^ n) * x ^ (-1 - 1/2 * n), x)` | the antiderivative |
1787+
| `"x^(-1 + 1/2*n)*sinh(a + b*x^n)".Integrate("x")` | `integral(x ^ (-1 + 1/2 * n) * (e ^ (a + b * x ^ n) - e ^ (-(a + b * x ^ n))) / 2, x)` | the antiderivative |
17741788

17751789
### `binomial(n, k)` is a function
17761790

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

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11229,6 +11229,14 @@ Entity Without(Entity side)
1122911229
/// one was nobody's, and <c>x^(n - 1) e^(x^n)</c> was declined.
1123011230
/// https://github.com/asc-community/AngouriMath/issues/718
1123111231
/// </summary>
11232+
/// <remarks>
11233+
/// <c>x^(k n - 1)</c> with <c>k</c> half an odd number is the same substitution by half
11234+
/// the power: under <c>u = x^(n/2)</c>, <c>x^(k n - 1) dx</c> is <c>(2/n) u^(2k - 1) du</c>
11235+
/// and <c>g(x^n)</c> is <c>g(u^2)</c>. Beside an exponential of <c>x^n</c> that is a moment
11236+
/// of the Gaussian: Rubi's 2.3, <c>f^(a + b x^n) x^(-1 + 5n/2)</c>, and 6.1.3's
11237+
/// <c>x^(-1 + n/2) sinh(a + b x^n)</c>.
11238+
/// https://github.com/asc-community/AngouriMath/issues/1501
11239+
/// </remarks>
1123211240
internal static Entity? SolveByAPowerOfTheVariableTimesAFunctionOfItsPower(Entity expr, Entity.Variable x, bool integrateByParts)
1123311241
{
1123411242
Entity? inFront = null;
@@ -11272,22 +11280,25 @@ Entity Without(Entity side)
1127211280
// Bare: the simplification attaches `provided not n = 0` to the quotient it
1127311281
// cancelled, and the generic case is what every rule answers in.
1127411282
var timesN = Functions.PartialFractions.Bare(((inFront + Number.Integer.One) / n).InnerSimplified);
11275-
if (timesN is not Number.Integer k || k.EInteger.Sign <= 0)
11276-
{
11283+
if (!IsAWholeOrHalfOddMultiple(timesN))
1127711284
timesN = Functions.PartialFractions.Bare(((inFront + Number.Integer.One) / n).Simplify());
11278-
if (timesN is not Number.Integer k2 || k2.EInteger.Sign <= 0)
11279-
return null;
11280-
k = k2;
11281-
}
11285+
if (!IsAWholeOrHalfOddMultiple(timesN))
11286+
return null;
11287+
// A half-odd k: the same by half the power, u = x^(n/2), where g(x^n) is g(u^2) and
11288+
// x^(k n - 1) dx is (2/n) u^(2k - 1) du.
11289+
var halved = timesN is not Number.Integer;
1128211290
var u = Variable.CreateUnique(expr, "u_pow");
11283-
var inU = rest.Replace(node => node is Powf(var b, var e) && b == x && e == n ? u : node);
11291+
var inU = rest.Replace(node => node is Powf(var b, var e) && b == x && e == n ? (halved ? MathS.Sqr(u) : u) : node);
1128411292
if (inU.ContainsNode(x))
1128511293
return null;
11286-
if (k != Number.Integer.One)
11287-
inU = MathS.Pow(u, (k - Number.Integer.One).InnerSimplified) * inU;
11294+
var powerOfU = halved ? (2 * timesN - 1).InnerSimplified : (timesN - Number.Integer.One).InnerSimplified;
11295+
if (powerOfU != Number.Integer.Zero)
11296+
inU = MathS.Pow(u, powerOfU) * inU;
1128811297
if (Integration.ComputeAsAQuestionOfItsOwn(inU, u, integrateByParts) is not { } inner)
1128911298
return null;
11290-
Entity answer = constant * inner.Substitute(u, MathS.Pow(x, n)) / n;
11299+
Entity answer = halved
11300+
? constant * 2 * inner.Substitute(u, MathS.Pow(x, n / 2)) / n
11301+
: constant * inner.Substitute(u, MathS.Pow(x, n)) / n;
1129111302
// (e x)^(n - 1) is e^(n - 1) x^(n - 1) for a positive e, which the answer states.
1129211303
if (scale is { })
1129311304
{
@@ -11298,6 +11309,16 @@ Entity Without(Entity side)
1129811309
return answer;
1129911310
}
1130011311

11312+
/// <summary>
11313+
/// A whole <c>k >= 1</c>, or half an odd number of either sign: the multiples of the
11314+
/// power inside that <see cref="SolveByAPowerOfTheVariableTimesAFunctionOfItsPower"/> takes.
11315+
/// A whole one below 1 leaves <c>u^(k - 1) g(u)</c> with a negative power in front of an
11316+
/// exponential of <c>u</c>, the exponential integral where it is <c>1/u</c>.
11317+
/// </summary>
11318+
private static bool IsAWholeOrHalfOddMultiple(Entity timesN)
11319+
=> timesN is Number.Integer { EInteger.Sign: > 0 }
11320+
|| timesN is Number.Rational half and not Number.Integer && half.ERational.Denominator.Equals(EInteger.FromInt32(2));
11321+
1130111322
/// <summary>
1130211323
/// Whether <c>b^2 - 4ac</c> is zero, which makes <c>a x^2 + b x + c</c> a perfect square.
1130311324
/// Symbolically as well as numerically: for <c>a^2 + 2 a b x + b^2 x^2</c> it is

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ Entity Pinned(Entity e) => e.Substitute("C", 0).Substitute("n", "5/2".ToEntity()
5656
[InlineData("(pe*x)^(-1+n)/(a+b*sech(c+d*x^n))^2")]
5757
public void APowerTimesAFunctionOfItsPower(string integrand) => DifferentiatesBack(integrand);
5858

59+
/// <summary>
60+
/// A power in front one less than a half-odd multiple of the power inside, by half the
61+
/// power, <c>u = x^(n/2)</c>: beside an exponential of <c>x^n</c> it is a moment of the
62+
/// Gaussian. Rubi's 2.3, <c>f^(a + b x^n) x^(-1 + 5n/2)</c>, and 6.1.3.
63+
/// https://github.com/asc-community/AngouriMath/issues/1501
64+
/// </summary>
65+
[Theory]
66+
[InlineData("2^(a+b*x^n)*x^(-1+5/2*n)")]
67+
[InlineData("2^(a+b*x^n)*x^(-1+1/2*n)")]
68+
[InlineData("2^(a+b*x^n)*x^(-1-3/2*n)")]
69+
[InlineData("x^(-1+3/2*n)*e^(-x^n)")]
70+
[InlineData("x^(-1+1/2*n)*sinh(a+b*x^n)")]
71+
public void APowerTimesAFunctionOfItsPowerByHalfThePower(string integrand) => DifferentiatesBack(integrand);
72+
5973
[Fact]
6074
public void TheScaleIsSaidToBePositive()
6175
{

0 commit comments

Comments
 (0)