Skip to content

Commit 90c9d3e

Browse files
Integrate a negative power of an inverse function of c + d x^2 in sine and cosine integrals (#1906)
* Integrate a power of an inverse function of c + d x^2 by its recurrence For u the inverse sine or cosine of w = c + d x^2 with c^2 = 1, its hyperbolic cosine with c^2 = 1, or its hyperbolic sine with c^2 = -1, integral (a + b u)^n is x (a + b u)^n + 2 e n b H (a + b u)^(n - 1) - 4 e b^2 n (n - 1) integral (a + b u)^(n - 2), with H = 1/(d x u'(w)), and it closes at the first two powers. Rubi's 5.1.5, 5.2.5 and 7.2.5 (a + b acos(1 + d x^2))^4 and the like were declined. Part of #718 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura * Integrate a negative power of an inverse function of c + d x^2 in sine and cosine integrals w - c is a constant times g(u/2 + beta)^2 for a sine or a cosine g, so x/g is constant on each side of 0 and dx = (x/g)(g'/2) du. The powers -1 and -2 are then sine and cosine integrals of (a + b u)/(2 b), hyperbolic ones for the inverse hyperbolic cosine, and the recurrence run backwards gives the rest. Rubi's 5.1.5, 5.2.5 and 7.2.5 1/(a + b acos(1 + d x^2)) and the like, to the first three negative powers, were declined. Part of #718 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura * Record the negative powers in the breaking changes Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 2d17cd1 commit 90c9d3e

3 files changed

Lines changed: 91 additions & 2 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,24 @@ in Rubi's 1.1.3.4 come out shorter as well, and those that took two seconds take
396396
| `"1/(x^8*(a + b*x^3)*(c + d*x^3))".ToEntity().Integrate("x")` | `integral(...)` | 1,217 characters |
397397
| `"1/(x^6*(a + b*x^4)*(c + d*x^4))".ToEntity().Integrate("x")` | `integral(...)` | 795 characters |
398398

399+
### A negative power of an inverse function of `c + d x^2` is integrated in sine and cosine integrals
400+
401+
**Answers where there were none.** `1/(a + b acos(1 + d x^2))` was declined, and so were seventeen more of Rubi's
402+
5.1.5, 5.2.5 and 7.2.5, to the first three negative powers. `w - c` is a constant times `g(u/2 + beta)^2` for a sine or
403+
a cosine `g`, so `x/g` is constant on each side of 0; the powers `-1` and `-2` are then sine and cosine integrals of
404+
`(a + b u)/(2 b)`, hyperbolic ones for the inverse hyperbolic cosine, and the recurrence run backwards gives the
405+
rest. The answers hold on the real domain of the integrand
406+
([#718](https://github.com/asc-community/AngouriMath/issues/718)).
407+
408+
| Input | Was (2.5.0) | Now |
409+
|---|---|---|
410+
| `"1/(a+b*acos(1+d*x^2))".ToEntity().Integrate("x")` | `integral(...)` | 184 characters |
411+
| `"1/(a+b*acos(-1+d*x^2))^2".ToEntity().Integrate("x")` | `integral(...)` | 273 characters |
412+
| `"1/(a+b*asin(1+d*x^2))^3".ToEntity().Integrate("x")` | `integral(...)` | 380 characters |
413+
| `"1/(a+b*asin(-1+d*x^2))".ToEntity().Integrate("x")` | `integral(...)` | 224 characters |
414+
| `"1/(a+b*acosh(1+d*x^2))^2".ToEntity().Integrate("x")` | `integral(...)` | 608 characters |
415+
| `"1/(a+b*acosh(-1+d*x^2))^3".ToEntity().Integrate("x")` | `integral(...)` | 633 characters |
416+
399417
### The reciprocal of a binomial in a high power of a sine, cosine or hyperbolic one is split over its roots
400418

401419
**Answers where there were none.** `1/(a + b sin(x)^5)` was declined, and so were twenty more of Rubi's 4.1.7, 4.2.7,

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

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28942,7 +28942,12 @@ static bool Through(Entity node, Entity.Variable x)
2894228942
/// inverse hyperbolic sine of one with <c>c^2 = -1</c>, by the recurrence
2894328943
/// <c>integral (a + b u)^n = x (a + b u)^n + 2 e n b H (a + b u)^(n - 1) - 4 e b^2 n (n - 1) integral (a + b u)^(n - 2)</c>,
2894428944
/// with <c>H = 1/(d x u'(w))</c>, <c>e = 1</c> for the circular functions and <c>-1</c> for the
28945-
/// hyperbolic ones. It closes at <c>n = 0</c> and <c>n = 1</c>, so nothing is asked below.
28945+
/// hyperbolic ones. It closes at <c>n = 0</c> and <c>n = 1</c>, so nothing is asked below. A
28946+
/// negative power goes through <c>u</c>: <c>w - c</c> is a constant times <c>g(u/2 + beta)^2</c>
28947+
/// for a sine or a cosine <c>g</c>, so <c>x/g</c> is constant on each side of 0, and the
28948+
/// powers <c>-1</c> and <c>-2</c> are sine and cosine integrals of <c>(a + b u)/(2 b)</c>
28949+
/// (hyperbolic ones for the hyperbolic cosine), the rest the recurrence run backwards. Exact on
28950+
/// the real domain; off it <c>x/g</c> can change sign across a cut.
2894628951
/// </summary>
2894728952
/// <remarks>
2894828953
/// Each <c>u</c> has <c>u'' = e w u'^3</c>, and with <c>c^2 = 1</c> (or <c>-1</c>) the radicand of
@@ -28955,7 +28960,7 @@ static bool Through(Entity node, Entity.Variable x)
2895528960
internal static Entity? SolveAPowerOfAnInverseFunctionOfAQuadraticByTheRecurrence(Entity expr, Entity.Variable x)
2895628961
{
2895728962
var (@base, power) = expr is Powf(var b0, Number.Integer p0) ? (b0, p0) : (expr, Number.Integer.One);
28958-
if (power.EInteger.Sign <= 0 || power.EInteger.CompareTo(EInteger.FromInt32(12)) > 0)
28963+
if (power.EInteger.IsZero || power.EInteger.Abs().CompareTo(EInteger.FromInt32(12)) > 0)
2895928964
return null;
2896028965
var n = power.EInteger.ToInt32Unchecked();
2896128966
// The inverse function, its argument w, the sign e, the radical H is written with, and
@@ -28997,6 +29002,8 @@ static bool Through(Entity node, Entity.Variable x)
2899729002
var h = root / (d * x);
2899829003
var e = (Entity)Number.Integer.Create(sign);
2899929004
var a_bu = a + b * inverse;
29005+
if (n < 0)
29006+
return NegativePower();
2900029007
// I(k) by the recurrence, from I(0) = x and I(1) = x (a + b u) + 2 e b H.
2900129008
var integrals = new Entity[n + 1];
2900229009
for (var k = 0; k <= n; k++)
@@ -29013,6 +29020,55 @@ static bool Through(Entity node, Entity.Variable x)
2901329020
if (!Functions.PartialFractions.IsZeroAsAValue((h * inverse.Differentiate(x) - 2).InnerSimplified))
2901429021
return null;
2901529022
return integrals[n].InnerSimplified;
29023+
29024+
// A negative power, through u: w - c is a constant times g(theta)^2 with theta = u/2 + beta,
29025+
// so x = kappa g(theta) with kappa = x/g(theta) constant on each side of 0, and
29026+
// dx = (kappa/2) g'(theta) du. Then I(-1) and I(-2) are sine and cosine integrals of
29027+
// v = (a + b u)/(2 b), and the recurrence run backwards gives the rest.
29028+
Entity? NegativePower()
29029+
{
29030+
var plus = Functions.PartialFractions.IsZeroAsAValue((c - 1).InnerSimplified);
29031+
// Whether g is a sine, beta, and h = g' as (hyperbolic, cosine, sign).
29032+
(bool GIsSine, Entity Beta, bool Hyperbolic, bool Cosine, int Sign)? table = (inverse, sign, squareAtZero, plus) switch
29033+
{
29034+
(Arccosf, _, _, true) => (true, Number.Integer.Zero, false, true, 1),
29035+
(Arccosf, _, _, false) => (false, Number.Integer.Zero, false, false, -1),
29036+
(Arcsinf, _, _, true) => (true, -MathS.pi / 4, false, true, 1),
29037+
(Arcsinf, _, _, false) => (false, -MathS.pi / 4, false, false, -1),
29038+
(Logf, -1, 1, true) => (true, Number.Integer.Zero, true, true, 1),
29039+
(Logf, -1, 1, false) => (false, Number.Integer.Zero, true, false, 1),
29040+
_ => null,
29041+
};
29042+
if (table is not var (gIsSine, beta, hyperbolic, cosine, hSign))
29043+
return null;
29044+
var theta = inverse / 2 + beta;
29045+
var kappa = x / (gIsSine ? Sin(theta) : Cos(theta));
29046+
var v = a_bu / (2 * b);
29047+
var gamma = a / (2 * b) - beta;
29048+
Entity Sin(Entity z) => hyperbolic ? MathS.Hyperbolic.Sinh(z) : MathS.Sin(z);
29049+
Entity Cos(Entity z) => hyperbolic ? MathS.Hyperbolic.Cosh(z) : MathS.Cos(z);
29050+
// The integral over v of h(v - gamma)/v for h a cosine or a sine, circular or hyperbolic.
29051+
Entity OverV(bool ofCosine) => (hyperbolic, ofCosine) switch
29052+
{
29053+
(false, true) => Cos(gamma) * MathS.Ci(v) + Sin(gamma) * MathS.Si(v),
29054+
(false, false) => Cos(gamma) * MathS.Si(v) - Sin(gamma) * MathS.Ci(v),
29055+
(true, true) => Cos(gamma) * MathS.Chi(v) - Sin(gamma) * MathS.Shi(v),
29056+
_ => Cos(gamma) * MathS.Shi(v) - Sin(gamma) * MathS.Chi(v),
29057+
};
29058+
// h' is the other function: -sin for cos, cos for sin; sinh for cosh, cosh for sinh.
29059+
var hPrimeSign = hyperbolic || !cosine ? hSign : -hSign;
29060+
var hOfTheta = hSign * (cosine ? Cos(theta) : Sin(theta));
29061+
var integrals = new Dictionary<int, Entity>
29062+
{
29063+
[-1] = kappa / (2 * b) * hSign * OverV(cosine),
29064+
[-2] = kappa / 2 * (-hOfTheta / (b * a_bu) + hPrimeSign * OverV(!cosine) / (2 * MathS.Sqr(b))),
29065+
};
29066+
for (var k = -1; k - 2 >= n; k--)
29067+
integrals[k - 2] = (x * MathS.Pow(a_bu, k) + 2 * e * k * b * h * MathS.Pow(a_bu, k - 1) - integrals[k])
29068+
/ (4 * e * MathS.Sqr(b) * k * (k - 1));
29069+
var answer = integrals[n].InnerSimplified;
29070+
return Functions.PartialFractions.DerivativeDiffersWhereReal(answer, expr, x) ? null : answer;
29071+
}
2901629072
}
2901729073

2901829074
/// <summary>

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ public void IsAnsweredAndDifferentiatesBack(string integrand, int sign)
6161
DifferentiatesBack(integrand, ("a", -0.75), ("b", -0.7), ("d", 0.15 * sign));
6262
}
6363

64+
// A negative power, in sine and cosine integrals (hyperbolic ones for acosh) of (a + b u)/(2 b):
65+
// exact on the real domain, where d keeps the argument inside [-1, 1].
66+
[Theory]
67+
[InlineData("1/(a+b*acos(1+d*x^2))", -1)]
68+
[InlineData("1/(a+b*acos(-1+d*x^2))^2", 1)]
69+
[InlineData("1/(a+b*asin(1+d*x^2))^3", -1)]
70+
[InlineData("1/(a+b*asin(-1+d*x^2))", 1)]
71+
[InlineData("1/(a+b*acosh(1+d*x^2))^2", 1)]
72+
[InlineData("1/(a+b*acosh(-1+d*x^2))^3", -1)]
73+
public void ANegativePowerIsAnsweredAndDifferentiatesBack(string integrand, int sign)
74+
{
75+
DifferentiatesBack(integrand, ("a", 0.6), ("b", 1.25), ("d", 0.3 * sign));
76+
DifferentiatesBack(integrand, ("a", -0.75), ("b", -0.7), ("d", 0.15 * sign));
77+
}
78+
6479
[Fact]
6580
public void WithNumbersIsAnswered()
6681
=> DifferentiatesBack("asin(1-2*x^2)^2");

0 commit comments

Comments
 (0)