Skip to content

Commit e2dfc5c

Browse files
A symbolic power of one of two conjugate tangent sums is integrated in that sum (#1791)
(a + i a tan(c + d x))^m (q - i q tan(c + d x))^4 and the rest of Rubi's 4.3.2.1 and 4.3.3.1 that put a symbolic power on one of the two sums and a whole power on the other were declined or ran past the budget: the sum under a power that is not whole is the variable, and a symbol was not read as one. In that sum the other is a whole power of a linear. A short sum of symbols in the answer is simplified, so that S^(m + -1 + 1)/(m + -1 + 1) is S^m/m. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 113ae13 commit e2dfc5c

3 files changed

Lines changed: 35 additions & 8 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,21 @@ the variable: `(a + i a tan(z))/(q - i q tan(z))^(3/2)`, from 4.3.2.1, ran past
930930
| `"cot(c + d*x)^2*(k + q*tan(c + d*x))/(a + i*a*tan(c + d*x))^4".ToEntity().Integrate("x")` | `integral(...)` | powers and logarithms of `a + i a tan(c + d x)`, of `a - i a tan(c + d x)` and of `tan(c + d x)` |
931931
| `"(a + i*a*tan(c + d*x))/(q - i*q*tan(c + d*x))^(3/2)".ToEntity().Integrate("x")` | `integral(...)` | `-2 i a (q - i q tan(c + d x))^(-3/2)/(3d)`, written longer |
932932

933+
### A symbolic power of one of two conjugate tangent sums is integrated in that sum
934+
935+
**Answers where there were none.** `(a + i a tan(c + d x))^m (q - i q tan(c + d x))^4` and the rest
936+
of Rubi's 4.3.2.1 and 4.3.3.1 that put a symbolic power on one of `a + i a tan(z)` and
937+
`q - i q tan(z)` and a whole power on the other were declined or ran past the budget. The sum under
938+
a power that is not whole is the variable they are integrated in, and a symbol was not read as one;
939+
in that sum the other is a whole power of a linear, and the integral a polynomial in it beside a
940+
power of it ([#718](https://github.com/asc-community/AngouriMath/issues/718)).
941+
942+
| Input | Was (2.5.0) | Now |
943+
|---|---|---|
944+
| `"(a + i*a*tan(c + d*x))^m*(q - i*q*tan(c + d*x))^4".ToEntity().Integrate("x")` | `integral(...)` | powers of `a + i a tan(c + d x)` from `m` to `m + 3`, each over its exponent |
945+
| `"(a + i*a*tan(c + d*x))^m*(q - i*q*tan(c + d*x))".ToEntity().Integrate("x")` | `integral(...)` | `-i q (a + i a tan(c + d x))^m/(m d)` where `a` is not 0 |
946+
| `"(a + i*a*tan(c + d*x))^2*(k + p*tan(c + d*x))*(q - i*q*tan(c + d*x))^n".ToEntity().Integrate("x")` | `integral(...)` | powers of `q - i q tan(c + d x)` from `n` to `n + 2`, each over its exponent |
947+
933948
### A rational function with complex coefficients is integrated through its real and imaginary parts
934949

935950
**Answers where there were none.** `1/((1 + i x)^2 (1 + x^2))` was declined: the rational

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26151,7 +26151,10 @@ static bool IsAWholeNumberOfSteps(ERational difference)
2615126151
/// Beside a second such sum of the same argument, <c>q - i q tan(z)</c>, which is linear in
2615226152
/// the first, the one under a power that is not whole is the variable and the other a whole
2615326153
/// power of a linear in it: <c>(a + i a tan(z))/(q - i q tan(z))^(3/2)</c>, Rubi's 4.3.2.1,
26154-
/// ran past the budget too.
26154+
/// ran past the budget too. A symbol for the power is not whole either:
26155+
/// <c>(a + i a tan(z))^m (q - i q tan(z))^4</c> is <c>S^(m - 1)</c> times a polynomial in
26156+
/// <c>S</c>, and was declined or past the budget with the rest of 4.3.2.1 and 4.3.3.1 that
26157+
/// write a symbolic power of one sum beside a whole one of the other.
2615526158
/// https://github.com/asc-community/AngouriMath/issues/718
2615626159
/// </para>
2615726160
/// </remarks>
@@ -26207,9 +26210,10 @@ static bool IsAWholeNumberOfSteps(ERational difference)
2620726210
sums.Add((node, sum, factor, inner));
2620826211
}
2620926212
// Two such sums, `a + i a tan(z)` and `c - i c tan(z)`, are each linear in the other: in
26210-
// the one under a power that is not whole the other is a whole power of a linear, where
26211-
// in the other it would be the root of one. Where both or neither are, declined.
26212-
bool NotWhole(Entity sum) => expr.Nodes.Any(node => node is Powf(var b, Number.Rational p) && b == sum && p is not Number.Integer);
26213+
// the one under a power that is not whole -- a fraction or a symbol -- the other is a
26214+
// whole power of a linear, where in the other it would be the root of one. Where both or
26215+
// neither are, declined.
26216+
bool NotWhole(Entity sum) => expr.Nodes.Any(node => node is Powf(var b, var p) && b == sum && p is not Number.Integer && (p is Number.Rational || !p.ContainsNode(x)));
2621326217
var chosen = sums.Count switch
2621426218
{
2621526219
1 => sums[0],
@@ -26224,8 +26228,7 @@ 2 when NotWhole(sums[0].Base) != NotWhole(sums[1].Base) => NotWhole(sums[0].Base
2622426228
// Below the bar, or to a power that is not whole: a positive whole power alone is a
2622526229
// polynomial in the tangent.
2622626230
var below = Functions.SingleQuotient.Of(Functions.SingleQuotient.Combine(expr)).Denominator;
26227-
if (!below.Nodes.Contains(@base)
26228-
&& !expr.Nodes.Any(node => node is Powf(var b, Number.Rational p) && b == @base && p is not Number.Integer))
26231+
if (!below.Nodes.Contains(@base) && !NotWhole(@base))
2622926232
return null;
2623026233
var s = Variable.CreateUnique(expr, "s_imaginary_tangent");
2623126234
var tangent = (s - constant) / coefficient;
@@ -26260,6 +26263,10 @@ 2 when NotWhole(sums[0].Base) != NotWhole(sums[1].Base) => NotWhole(sums[0].Base
2626026263
var inS = (rewritten * coefficient / (s * (s - 2 * constant)) / rate).InnerSimplified;
2626126264
if (Integration.ComputeAsAQuestionOfItsOwn(inS, s, integrateByParts) is not { } inTermsOfS)
2626226265
return null;
26266+
// A short sum of symbols simplified, which the power rule leaves as it wrote it:
26267+
// `S^(m + -1 + 1)/(m + -1 + 1)` is `S^m/m`.
26268+
inTermsOfS = inTermsOfS.Replace(node => node is Sumf or Minusf && !node.ContainsNode(s) && node.Vars.Any() && node.Complexity <= 20
26269+
? node.Simplify() : node);
2626326270
return inTermsOfS.Substitute(s, @base);
2626426271
}
2626526272

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ namespace AngouriMath.Tests.Calculus
1515
/// A rational function of <c>tan(z)</c> beside a power of <c>S = a ± i a tan(z)</c>, integrated
1616
/// in <c>S</c>, where <c>dz = c dS/(S (S - 2a))</c>: the factors are <c>S</c>, <c>S - 2a</c> and
1717
/// <c>S - a</c>, with no imaginary root among them. Beside <c>q - i q tan(z)</c>, a linear in
18-
/// <c>S</c>, the sum under a power that is not whole is the variable. Rubi's 4.3.3.1 and 4.3.2.1.
18+
/// <c>S</c>, the sum under a power that is not whole, a fraction or a symbol, is the variable.
19+
/// Rubi's 4.3.3.1 and 4.3.2.1.
1920
/// <a href="https://github.com/asc-community/AngouriMath/issues/718">#718</a>
2021
/// </summary>
2122
/// <remarks>Compared as complex numbers, the integrand being complex.</remarks>
@@ -31,12 +32,16 @@ public sealed class RationalInTheTangentBesideAnImaginarySumIntegralTest
3132
[InlineData("(a + i*a*tan(c + d*x))/(q - i*q*tan(c + d*x))^(3/2)")]
3233
[InlineData("sqrt(q - i*q*tan(c + d*x))/(a + i*a*tan(c + d*x))")]
3334
[InlineData("(a + i*a*tan(c + d*x))^2/sqrt(q - i*q*tan(c + d*x))")]
35+
// A symbol for the power of one sum, a whole power of the other.
36+
[InlineData("(a + i*a*tan(c + d*x))^m*(q - i*q*tan(c + d*x))^4")]
37+
[InlineData("(a + i*a*tan(c + d*x))^m*(q - i*q*tan(c + d*x))")]
38+
[InlineData("(a + i*a*tan(c + d*x))^2*(k + q*tan(c + d*x))*(q - i*q*tan(c + d*x))^n")]
3439
public void IsIntegratedInTheSum(string integrand)
3540
{
3641
var integral = integrand.ToEntity().Integrate("x");
3742
Assert.DoesNotContain("integral(", integral.Stringize());
3843
Entity Pinned(Entity e) => e.Substitute("a", 1.3).Substitute("c", 0.4).Substitute("d", 1.1)
39-
.Substitute("k", 1.1).Substitute("q", 0.6);
44+
.Substitute("k", 1.1).Substitute("q", 0.6).Substitute("m", 1.7).Substitute("n", 0.6);
4045
var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
4146
var original = Pinned(integrand.ToEntity());
4247
foreach (var at in new[] { -1.1, -0.6, 0.3, 0.9 })

0 commit comments

Comments
 (0)