Skip to content

Commit d276b34

Browse files
Half-odd powers of a + i a sinh are integrated by the half angle at which they are squares (#1753)
x^3 sqrt(a + i a sinh(c + f x)) was declined, with the rest of Rubi's 6.1.1 and 6.1.5 with a half-odd power of a +- i a sinh. 1 + i sinh(y) is (cosh(y/2) + i sinh(y/2))^2, so such a power is a^p times an odd power of cosh(y/2) +- i sinh(y/2), a sum of exponentials of the half angle, up to a constant on every interval where both are continuous. The rest of the integrand is written in the half angle and the question asked again; the answer is the antiderivative times the power as written over that form, a quotient whose logarithmic derivative is zero. Rubi's 47 such problems go from none to 29 of the 32 the harness can check. Part of #718. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
1 parent f18a7d2 commit d276b34

4 files changed

Lines changed: 172 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,22 @@ of the third to the sixth degree, with a symbol in it, that written in `y = x +
297297
| `"1/(3*a*b + 3*b^2*x + 3*b*c*x^2 + c^2*x^3)".ToEntity().Integrate("x")`, and its square | `integral(...)` | two logarithms and an arctangent in `x + b/c` |
298298
| `"x/(a + 8*x - 8*x^2 + 4*x^3 - x^4)".ToEntity().Integrate("x")`, and `1` over it | `integral(...)` | the antiderivative in `x - 1` |
299299

300+
### Half-odd powers of `a + i a sinh` are integrated by the half angle at which they are squares
301+
302+
**Answers where there were none.** `x^3 sqrt(a + i a sinh(g + f x))` was declined, with the rest of
303+
Rubi's 6.1.1 and 6.1.5 with a half-odd power of `a ± i a sinh`, six of them after searches past the
304+
budget. `1 + i sinh(y)` is `(cosh(y/2) + i sinh(y/2))^2`, so such a power is `a^p` times an odd
305+
power of `cosh(y/2) ± i sinh(y/2)`, a sum of exponentials of the half angle, up to a constant on
306+
every interval where both are continuous; it is integrated so now, and the answer is the
307+
antiderivative times the power as written over that form, which holds on every such interval
308+
whatever `a` is ([#718](https://github.com/asc-community/AngouriMath/issues/718)).
309+
310+
| Input | Was (2.5.0) | Now |
311+
|---|---|---|
312+
| `"x^3*sqrt(a + i*a*sinh(g + f*x))".ToEntity().Integrate("x")` | `integral(...)` | powers of `x` times exponentials of the half angle |
313+
| `"sqrt(a + i*a*sinh(g + f*x))/x".ToEntity().Integrate("x")` | `integral(...)` | `Shi` and `Chi` of half of `f x` |
314+
| `"1/sqrt(a + i*a*sinh(g + f*x))".ToEntity().Integrate("x")` | `integral(...)` | arctangents and logarithms of `e^((g + f x)/2)` |
315+
300316
### The hyperbolic functions have antiderivatives, and so does anything rational in `e^(k x)`
301317

302318
An integrand rational in `e^(k x)` becomes a rational function of one variable under

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

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21971,6 +21971,113 @@ private static (Entity OverTheTwo, Entity Argument)? ReadTheHyperbolicFunctions(
2197121971
return answer.Nodes.Any(node => node == MathS.NaN) ? null : answer;
2197221972
}
2197321973

21974+
/// <summary>
21975+
/// Half-odd powers of <c>a ± i a sinh(y)</c> beside anything in the hyperbolic functions of
21976+
/// <c>y</c>, by the half angle at which they are squares: <c>1 + i sinh(y)</c> is
21977+
/// <c>(cosh(y/2) + i sinh(y/2))^2</c>, so <c>sqrt(a + i a sinh(y))</c> is
21978+
/// <c>sqrt(a) (cosh(y/2) + i sinh(y/2))</c> times a constant on every interval where both
21979+
/// are continuous. The rest of the integrand is written in the half angle, and the question
21980+
/// asked again in <c>x</c>.
21981+
/// </summary>
21982+
/// <remarks>
21983+
/// <para>
21984+
/// Rubi's <c>x^3 sqrt(a + i a sinh(e + f x))</c> and the rest of the 47 of 6.1.1 and 6.1.5
21985+
/// were declined or searches past the budget: the half angle of
21986+
/// <see cref="SolveByTheHalfAngleWhereOnePlusAHyperbolicCosineIsASquare"/> reads
21987+
/// <c>a ± a cosh(y)</c>, and <c>1 + i sinh(y)</c> is the square of a complex function rather
21988+
/// than of a real one.
21989+
/// </para>
21990+
/// <para>
21991+
/// The constant is not written: the answer is the antiderivative of the rewritten integrand
21992+
/// times each power as written over the form it was rewritten to, a quotient whose
21993+
/// logarithmic derivative is zero, so it is constant wherever it is continuous and the
21994+
/// answer holds on every such interval, whatever <c>a</c> is.
21995+
/// https://github.com/asc-community/AngouriMath/issues/718
21996+
/// </para>
21997+
/// </remarks>
21998+
internal static Entity? SolveAHalfOddPowerOfOnePlusAnImaginaryHyperbolicSine(Entity expr, Entity.Variable x, bool integrateByParts)
21999+
{
22000+
var s = Variable.CreateUnique(expr, "s_hyp");
22001+
var c = Variable.CreateUnique(expr, "c_hyp");
22002+
if (ReadTheHyperbolicFunctions(expr, x, s, c) is not var (read, argument))
22003+
return null;
22004+
var half = (argument / 2).InnerSimplified;
22005+
var sinhHalf = MathS.Hyperbolic.Sinh(half);
22006+
var coshHalf = MathS.Hyperbolic.Cosh(half);
22007+
Entity constant = Number.Integer.One;
22008+
var found = false;
22009+
var rewritten = read.Replace(node =>
22010+
{
22011+
if (node is not Powf(var radicand, Number.Rational exponent) || exponent is Number.Integer
22012+
|| !exponent.ERational.Denominator.Equals(EInteger.FromInt32(2))
22013+
|| !radicand.ContainsNode(s) || radicand.ContainsNode(c)
22014+
|| ReadAsOnePlusMinusAnImaginarySine(radicand, s) is not var (a, plus))
22015+
return node;
22016+
found = true;
22017+
var root = plus ? coshHalf + MathS.i * sinhHalf : coshHalf - MathS.i * sinhHalf;
22018+
var written = MathS.Pow(a, exponent) * MathS.Pow(root, Number.Integer.Create(exponent.ERational.Numerator));
22019+
var asItIs = MathS.Pow(radicand.Substitute(s, MathS.Hyperbolic.Sinh(argument)), exponent);
22020+
constant = constant * asItIs / written;
22021+
return written;
22022+
});
22023+
if (!found)
22024+
return null;
22025+
var inX = rewritten.Substitute(c, 2 * MathS.Sqr(coshHalf) - 1).Substitute(s, 2 * sinhHalf * coshHalf);
22026+
if (inX.ContainsNode(s) || inX.ContainsNode(c))
22027+
return null;
22028+
if (Integration.ComputeAsTheSameQuestion(inX, x, integrateByParts) is not { } result
22029+
|| result.Nodes.Any(node => node == MathS.NaN))
22030+
return null;
22031+
return constant * result;
22032+
}
22033+
22034+
/// <summary>
22035+
/// <paramref name="radicand"/> read as <c>a (1 ± i s)</c> for the hyperbolic sine
22036+
/// <paramref name="sine"/>: the constant <c>a</c>, and whether the imaginary unit comes
22037+
/// with a plus. Null for anything else.
22038+
/// </summary>
22039+
private static (Entity Constant, bool Plus)? ReadAsOnePlusMinusAnImaginarySine(Entity radicand, Entity sine)
22040+
{
22041+
Entity a = Number.Integer.Zero;
22042+
Entity? b = null;
22043+
foreach (var term in Sumf.LinearChildren(radicand))
22044+
{
22045+
if (!term.ContainsNode(sine))
22046+
{
22047+
a += term;
22048+
continue;
22049+
}
22050+
if (b is not null)
22051+
return null;
22052+
Entity coefficient = Number.Integer.One;
22053+
var seen = false;
22054+
foreach (var factor in Mulf.LinearChildren(term))
22055+
{
22056+
if (factor == sine && !seen)
22057+
seen = true;
22058+
else if (!factor.ContainsNode(sine))
22059+
coefficient *= factor;
22060+
else
22061+
return null;
22062+
}
22063+
if (!seen)
22064+
return null;
22065+
b = coefficient;
22066+
}
22067+
if (b is null)
22068+
return null;
22069+
a = a.InnerSimplified;
22070+
if (a.Evaled is Number.Complex { IsZero: true })
22071+
return null;
22072+
static bool IsZero(Entity value) => value.InnerSimplified.Evaled is Number.Complex { IsZero: true }
22073+
|| value.Simplify().Evaled is Number.Complex { IsZero: true };
22074+
if (IsZero(b - MathS.i * a))
22075+
return (a, true);
22076+
if (IsZero(b + MathS.i * a))
22077+
return (a, false);
22078+
return null;
22079+
}
22080+
2197422081
/// <summary>
2197522082
/// A sum every term of which carries the same power of one linear form in
2197622083
/// <paramref name="x"/>, written as that power times the sum of the rest:

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,8 @@ private static Entity Normalized(Entity expr, Entity.Variable x) =>
853853
if ((answer = IndefiniteIntegralSolver.SolveByTheHalfAngleTangentBesideAHalfOddPowerOfOnePlusASecant(expr, x, integrateByParts)) is { }) return answer;
854854
// And `a ± a cosh(y)` under a fractional power: `2a cosh(y/2)^2`, `-2a sinh(y/2)^2`.
855855
if ((answer = IndefiniteIntegralSolver.SolveByTheHalfAngleWhereOnePlusAHyperbolicCosineIsASquare(expr, x, integrateByParts)) is { }) return answer;
856+
// The hyperbolic sine's, off the real line: 1 + i sinh(y) is (cosh(y/2) + i sinh(y/2))^2.
857+
if ((answer = IndefiniteIntegralSolver.SolveAHalfOddPowerOfOnePlusAnImaginaryHyperbolicSine(expr, x, integrateByParts)) is { }) return answer;
856858
// Several trigonometric arguments that are multiples of one linear with an offset or a
857859
// symbolic slope, written in that linear: before the substitution search, which reads
858860
// each function on its own.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// Copyright (c) 2019-2026 Angouri.
3+
// AngouriMath is licensed under MIT.
4+
// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
5+
// Website: https://am.angouri.org.
6+
//
7+
8+
using System;
9+
using AngouriMath.Extensions;
10+
using Xunit;
11+
12+
namespace AngouriMath.Tests.Calculus
13+
{
14+
/// <summary>
15+
/// Half-odd powers of <c>a + i a sinh(y)</c>, which is <c>a (cosh(y/2) + i sinh(y/2))^2</c>:
16+
/// beside a power of <c>x</c> each is a sum of exponentials of the half angle times that power,
17+
/// up to a constant on every interval where both are continuous. Rubi's 6.1.1 and 6.1.5. The
18+
/// integrands are complex, and compared as complex numbers on both sides of zero.
19+
/// <a href="https://github.com/asc-community/AngouriMath/issues/718">#718</a>
20+
/// </summary>
21+
[Trait("Area", "Calculus")]
22+
public sealed class OnePlusAnImaginaryHyperbolicSineIntegralTest
23+
{
24+
[Theory]
25+
[InlineData("x^3*sqrt(a + i*a*sinh(g + f*x))")]
26+
[InlineData("x*sqrt(a + i*a*sinh(g + f*x))")]
27+
[InlineData("sqrt(a + i*a*sinh(g + f*x))/x")]
28+
[InlineData("x^3*(a + i*a*sinh(g + f*x))^(3/2)")]
29+
[InlineData("1/sqrt(a + i*a*sinh(g + f*x))")]
30+
public void ByTheHalfAngle(string integrand)
31+
{
32+
var integral = integrand.ToEntity().Integrate("x");
33+
Assert.DoesNotContain("integral(", integral.Stringize());
34+
Entity Pinned(Entity e) => e.Substitute("a", 1.3).Substitute("g", 0.4).Substitute("f", 1.1);
35+
var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
36+
var original = Pinned(integrand.ToEntity());
37+
foreach (var at in new[] { -1.2, -0.4, 0.3, 0.8, 1.5 })
38+
{
39+
var want = original.Substitute("x", at).EvalNumerical();
40+
var got = derivative.Substitute("x", at).EvalNumerical();
41+
Assert.True(Math.Abs((double)(got - want).RealPart) + Math.Abs((double)(got - want).ImaginaryPart)
42+
< 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart) + Math.Abs((double)want.ImaginaryPart)),
43+
$"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}");
44+
}
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)