You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b71a26e
Browse filesBrowse the repository at this point in the historyBrowse files
A rational function of the hyperbolic functions odd in the sine or the cosine is integrated by the other (#1464)
`sinh(x)^3/(a + b cosh(x)^2)` was a search past the budget: under u = e^x
it is a rational function of a symbolic palindromic quartic, and under
u = tanh(x/2) of a symbolic polynomial of degree eight. It is
(u^2 - 1)/(a + b u^2) under u = cosh(x) -- Bioche's first two rules, which
the trigonometric functions already had: odd in the hyperbolic sine,
u = cosh with sinh^2 = u^2 - 1; odd in the hyperbolic cosine, u = sinh
with cosh^2 = u^2 + 1. The six hyperbolic functions are read back from
their exponential spellings through the gathered exponentials, for any
linear argument and either sign of it; a written power is handed on as
the power it is, factor by factor, and not expanded into a symbolic
quartic for the rational integrator to factor again; a root of a
polynomial in the two even in the function is admitted, a Laurent one
(`a + b sech(x)`) declined, since the search after `sqrt(a + b/u)` is
longer than the exponential substitution's. ParityIn and InU are lifted
out of SolveByBiochesOddSubstitution and shared. In front of the
substitution search, which with a symbolic coefficient spends the budget
on u = e^x.
Family 6 of the Rubi suite: 344 -> 357 of 417, 0 wrong, timeouts 34 -> 24;
family 7 215/270 and the 1774-problem suite 1707 unchanged. Suite 12610
passed; allocation gate passed on all 19 gated benchmarks.
Part of #718.
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|`"sinh(x)^3/(a+b*cosh(x)^2)".Integrate("x")`| left unevaluated |`cosh(x)/b - (a + b) arctan(sqrt(b) cosh(x)/sqrt(a))/(b sqrt(a b))` up to the form, by cases on `a` and `b`|
1048
+
|`"cosh(c+d*x)/(a+b*tanh(c+d*x)^2)".Integrate("x")`| left unevaluated | the antiderivative, in `sinh(c + d x)`|
1049
+
|`"sech(c+d*x)/(a+b*sinh(c+d*x)^2)^(3/2)".Integrate("x")`| left unevaluated | the antiderivative |
1050
+
|`"csch(x)^5/(a+b*cosh(x)^2)".Integrate("x")`| left unevaluated | the antiderivative |
1051
+
|`"sinh(x)^3/(1+cosh(x)^2)".Integrate("x")`| left unevaluated |`cosh(x) - 2 arctan(cosh(x))`, in exponentials -- where `master` between the releases gave it through `u = e^x`, in `arctan(2 e^x/sqrt(12 - 8 sqrt(2)))` and its like |
1052
+
1033
1053
### `binomial(n, k)` is a function
1034
1054
1035
1055
**Addition, not silent.** The binomial coefficient is a node, `Entity.Binomialf`, spelled
// coth(y) the reciprocal, sech(y) 1/cosh(y) and csch(y) 1/sinh(y). The argument is y,
14020
+
// or its half where `tanh(c + d x)` alone is written with e^(2(c + d x)) and the
14021
+
// gathering names that y: then the tangent's spelling carries e^y.
14022
+
Entity? argument = null;
14023
+
Entity overTheTwo = expr;
14024
+
foreach (var halved in new[] { false, true })
13963
14025
{
13964
-
if (!TreeAnalyzer.TryGetPolynomial(polynomial, f, out var read))
14026
+
var one = halved ? null : (EInteger?)EInteger.One;
14027
+
var two = halved ? EInteger.One : EInteger.FromInt32(2);
14028
+
// With y named from an exponential of the other sign, e^-y is the k = 1 one:
14029
+
// sinh and tanh are odd, cosh even.
14030
+
Entity? ReadTheTwo(Entity node)
14031
+
{
14032
+
switch (node)
14033
+
{
14034
+
case Divf(Minusf(var a, var b), Number.Integer { EInteger: var d }) when d.Equals(EInteger.FromInt32(2)) && Is(a, one) && Is(b, one?.Negate()):
14035
+
return s;
14036
+
case Divf(Minusf(var a, var b), Number.Integer { EInteger: var d }) when d.Equals(EInteger.FromInt32(2)) && Is(a, one?.Negate()) && Is(b, one):
14037
+
return -s;
14038
+
case Divf(Sumf(var a, var b), Number.Integer { EInteger: var d }) when d.Equals(EInteger.FromInt32(2)) && (Is(a, one) && Is(b, one?.Negate()) || Is(a, one?.Negate()) && Is(b, one)):
14039
+
return c;
14040
+
case Divf(Minusf(var a, Number.Integer { EInteger: var m }), Sumf(var b, Number.Integer { EInteger: var n })) when m.Equals(EInteger.One) && n.Equals(EInteger.One) && Is(a, two) && Is(b, two):
14041
+
return s / c;
14042
+
case Divf(Minusf(var a, Number.Integer { EInteger: var m }), Sumf(var b, Number.Integer { EInteger: var n })) when m.Equals(EInteger.One) && n.Equals(EInteger.One) && Is(a, two.Negate()) && Is(b, two.Negate()):
14043
+
return -s / c;
14044
+
case Divf(Sumf(var a, Number.Integer { EInteger: var m }), Minusf(var b, Number.Integer { EInteger: var n })) when m.Equals(EInteger.One) && n.Equals(EInteger.One) && Is(a, two) && Is(b, two):
14045
+
return c / s;
14046
+
case Divf(Sumf(var a, Number.Integer { EInteger: var m }), Minusf(var b, Number.Integer { EInteger: var n })) when m.Equals(EInteger.One) && n.Equals(EInteger.One) && Is(a, two.Negate()) && Is(b, two.Negate()):
14047
+
return -c / s;
14048
+
case Divf(Number.Integer { EInteger: var m }, var inner) when m.Equals(EInteger.One) && ReadTheTwo(inner) is { } read:
14049
+
return 1 / read;
14050
+
}
13965
14051
return null;
13966
-
Entity sum = Number.Integer.Zero;
13967
-
foreach (var pair in read)
14052
+
}
14053
+
bool Is(Entity node, EInteger? k) => k is { } wanted && exponentials.TryGetValue(node, out var found) && found.Equals(wanted);
14054
+
var read = expr.Replace(node => node.ContainsNode(x) && ReadTheTwo(node) is { } inTheTwo ? inTheTwo : node);
14055
+
if (read.ContainsNode(s) || read.ContainsNode(c))
13968
14056
{
13969
-
if (pair.Key.Sign < 0 || !pair.Key.CanFitInInt32())
13970
-
return null;
13971
-
var power = pair.Key.ToInt32Unchecked() - (dividedByOdd ? 1 : 0);
13972
-
if (power < 0 || power % 2 != 0)
14057
+
argument = halved ? (y / 2).InnerSimplified : y;
14058
+
overTheTwo = read;
14059
+
break;
14060
+
}
14061
+
}
14062
+
if (argument is null)
14063
+
return null;
14064
+
if (!overTheTwo.ContainsNode(s) && !overTheTwo.ContainsNode(c))
14065
+
return null;
14066
+
var radicals = new List<(Variable Symbol, Entity Base, Number.Rational Exponent)>();
14067
+
overTheTwo = overTheTwo.Replace(node =>
14068
+
{
14069
+
if (node is not Powf(var radicand, Number.Rational exponent) || exponent is Number.Integer || !radicand.ContainsNode(s) && !radicand.ContainsNode(c))
14070
+
return node;
14071
+
var symbol = Variable.CreateUnique(expr, "r_hyp" + radicals.Count);
14072
+
var combined = Functions.SingleQuotient.Combine(radicand);
14073
+
radicals.Add((symbol, combined, exponent));
14074
+
return symbol;
14075
+
});
14076
+
if (overTheTwo.ContainsNode(x))
14077
+
return null;
14078
+
// A radicand that is a polynomial in the two, and not a Laurent one: `a + b sech(x)`
14079
+
// is `a + b/c`, whose root under u = cosh(x) is a root of `a + b/u`, and the search
14080
+
// that follows it is longer than the exponential substitution's.
14081
+
if (radicals.Any(radical => radical.Base.ContainsNode(x) || !IsAPolynomialInBoth(radical.Base)))
14082
+
return null;
14083
+
// The quotient factor by factor, each factor a polynomial in the two, so that a
14084
+
// written power -- `(a + b sech(x)^2)^2` -- is handed on as the power it is and not
14085
+
// expanded into a symbolic quartic for the rational integrator to factor again.
14086
+
var (above, below) = Functions.SingleQuotient.Of(Functions.SingleQuotient.Combine(overTheTwo));
14087
+
var factors = new List<(Entity Base, int Power)>();
0 commit comments