Skip to content

Commit c21de3e

Browse files
An odd power of the secant is read in the tangent, with the cosine's sign (#1816)
The substitution u = tan(x) read an odd power of the sine or the cosine as its sign times a function of the tangent, and not the secant, the same the other way up. 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 c417571 commit c21de3e

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,20 @@ answer on the far side of a root gets a real expression where it used to get a c
270270
| `1/(x*(-4+x^2)^4)` | 8,472 ms | 1,878 ms |
271271
| `1/((1+x)^3*(2+x)^3)` | 1,343 ms | 492 ms |
272272

273+
### An odd power of the secant is read in the tangent, with the cosine's sign
274+
275+
**Answers where there were none.** `sec(x)^5/(a + b tan(x))^2` was declined: the substitution
276+
`u = tan(x)` read an odd power of the sine or the cosine as its sign times a function of the tangent,
277+
`cos(x) = sgn(cos(x))/sqrt(1 + u^2)`, and not the secant, which is the same the other way up. It reads the
278+
secant too now, and the integrand is `sgn(cos(x)) (1 + u^2)^(3/2)/(a + b u)^2` in `u`
279+
([#718](https://github.com/asc-community/AngouriMath/issues/718)).
280+
281+
| Input | Was (2.5.0) | Now |
282+
|---|---|---|
283+
| `"sec(x)^5/(a + b*tan(x))^2".ToEntity().Integrate("x")` | `integral(...)` | in `sgn(cos(x))` and `tan(x)`, 901 characters |
284+
| `"sec(x)^7/(a + b*tan(x))^3".ToEntity().Integrate("x")` | `integral(...)` | 1,253 characters |
285+
| `"sec(x)/(a + b*cot(x))".ToEntity().Integrate("x")` | `integral(...)` | 571 characters |
286+
273287
### A whole power of the radicand under Euler's substitution is read as one
274288

275289
**Answers where there were none, and none where they were wrong.** Euler's substitution writes the

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10283,6 +10283,11 @@ static bool IsTwice(Entity argument, Entity.Variable x)
1028310283
=> MathS.Pow(sign / rootOfSecantSquared, k),
1028410284
Powf(Sinf(var a), Number.Integer k) when a == x && k.EInteger.CanFitInInt32() && !k.EInteger.IsEven
1028510285
=> MathS.Pow(sign * tangent / rootOfSecantSquared, k),
10286+
// And the secant is the cosine the other way up, the sign its own inverse:
10287+
// `sec(x)^5/(a + b tan(x))^2` is `sgn(cos(x)) (1 + u^2)^(5/2)/(a + b u)^2`.
10288+
Secantf(var a) when a == x => sign * rootOfSecantSquared,
10289+
Powf(Secantf(var a), Number.Integer k) when a == x && k.EInteger.CanFitInInt32() && !k.EInteger.IsEven
10290+
=> MathS.Pow(sign * rootOfSecantSquared, k),
1028610291
_ => node,
1028710292
}).Substitute(tangent, uSub);
1028810293
if (odd.ContainsNode(x) || !IsAlgebraicIn(odd, uSub))

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,20 @@ private static void DifferentiatesBack(string integrand)
113113
[InlineData("sqrt(a + b*csc(c + d*x)^2)")]
114114
[InlineData("sqrt(1 + csc(x)^2)")]
115115
[InlineData("1/sqrt(-1 + csc(x)^2)")]
116-
public void AnEvenPowerOfTheSecantOrTheCosecantUnderARoot(string integrand)
116+
public void AnEvenPowerOfTheSecantOrTheCosecantUnderARoot(string integrand) => DifferentiatesBackWithTheSymbolsPinned(integrand);
117+
118+
/// <summary>
119+
/// An odd power of the secant is the cosine's the other way up: <c>sec(x)^5/(a + b tan(x))^2</c>
120+
/// is <c>sgn(cos(x)) (1 + u^2)^(3/2)/(a + b u)^2</c> under <c>u = tan(x)</c>. Rubi's 4.3.1.2,
121+
/// checked on both signs of the cosine.
122+
/// </summary>
123+
[Theory]
124+
[InlineData("sec(x)^5/(a + b*tan(x))^2")]
125+
[InlineData("sec(x)^7/(a + b*tan(x))^3")]
126+
[InlineData("sec(c + d*x)^5/(a + b*tan(c + d*x))^3")]
127+
public void AnOddPowerOfTheSecantIsItsSignTimesAFunctionOfTheTangent(string integrand) => DifferentiatesBackWithTheSymbolsPinned(integrand);
128+
129+
private static void DifferentiatesBackWithTheSymbolsPinned(string integrand)
117130
{
118131
var integral = integrand.ToEntity().Integrate("x");
119132
Assert.DoesNotContain("integral(", integral.Stringize());

0 commit comments

Comments
 (0)