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 de11aaf
Browse filesBrowse the repository at this point in the historyBrowse files
Read x times a rational function of an exponential of a logarithm off the integrand (#2047)
Rubi's 6.5.3 (1 - b^2 n^2) sech(u) + 2 b^2 n^2 sech(u)^3 for u = a + b ln(c x^n)
is (x (-sech(u) - b n tanh(u) sech(u)))', and its 6.6.3 twin in the cosecant
the same way; both were declined. With w = e^u the Euler derivative x w' is
b n w, so (x G(w))' = G + b n w G'(w): the integrand P/Q in w is that for
G = N/Q exactly where N Q + c w (N' Q - N Q') = P Q, linear in N's
coefficients, read at sampled values of w and solved with the symbols in;
the homogeneous solution w^(-1/c) is no rational function for a symbolic c,
so the solution is unique. Only where x stands in the exponentials alone and
the exponent's Euler derivative is a constant, at the question asked; the
quotient is simplified in w to lowest terms and the answer checked.
A symbolic power K B^p of one function of w goes through x K B^(p - 2) H(w),
since (x B^(p - 2) H)' = B^(p - 2) (H + c w H' + (p - 2) c (w B'/B) H): Rubi's
6.5.3 sech(a - ln(c x^n)/(n (p - 2)))^p, whose c is -1/(p - 2), is
x (p - 2)/(p - 1) sech(u)^(p - 2) (1 - tanh(u)), and its cosecant twin in
6.6.3 the same way. There the system is square, (p - 2) c is simplified once,
every row is scaled by c's denominator and the entries taken bare: with
1/(p - 2) and a provided not p - 2 = 0 in them, the elimination over p did not
settle.
Part of #233.
Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: BREAKING-CHANGES.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -618,6 +618,23 @@ integrand over `D^2` as `(N/D)'`, with `N` a constant times each exponential in
618
618
| `"(b+a*cosh(x))/(a+b*cosh(x))^2".ToEntity().Integrate("x")` | `integral(...)` | 70 characters, where before this change master gave 7,631 |
619
619
| `"sech(x)^2*tanh(x)^2/(2+tanh(x)^3)^2".ToEntity().Integrate("x")` | no answer in thirty seconds | 60 characters, `-1/3/(2 + tanh(x)^3)`, in 55 ms; master gave 117 in 16 s and 9.7 GB |
620
620
621
+
### x times a rational function of an exponential of a logarithm is read off the integrand
622
+
623
+
**Answers where there were none.** Rubi's 6.5.3 `(1 - b^2 n^2) sech(u) + 2 b^2 n^2 sech(u)^3` for `u = a + b ln(c x^n)` is
624
+
`(x (-sech(u) - b n tanh(u) sech(u)))'`, and its 6.6.3 twin in the cosecant the same way. Both were declined. With
625
+
`w = e^u`, the Euler derivative `x w' = b n w` makes `(x G(w))'` equal `G + b n w G'(w)`. Where x stands in the
626
+
exponentials alone, a rational G is now solved for by sampling w: a linear system, with the symbolic `b n` making
627
+
its solution unique. A symbolic power `B^p` of one function of w goes through `x B^(p - 2) H(w)` the same way, which
628
+
answers 6.5.3's `sech(a - ln(c x^n)/(n (p - 2)))^p` and its cosecant twin
static bool IsAnExponential(Entity node, Entity.Variable x) => node is Powf(var @base, var exponent) && @base == MathS.e && exponent.ContainsNode(x);
43313
+
if (expr.Replace(node => IsAnExponential(node, x) ? Number.Integer.One : node).ContainsNode(x))
43314
+
return null;
43315
+
var exponentials = expr.Nodes.Where(node => IsAnExponential(node, x)).Distinct().ToList();
43316
+
if (exponentials.Count is 0 or > 4)
43317
+
return null;
43318
+
var first = ((Powf)exponentials[0]).Exponent;
43319
+
// Only an exponent of a logarithm: a linear one is the exponential substitution's.
43320
+
if (TreeAnalyzer.TryGetPolyLinear(first, x, out _, out _) || !first.Nodes.Any(node => node is Logf))
43321
+
return null;
43322
+
var rate = Functions.PartialFractions.Bare((x * first.Differentiate(x)).Simplify());
43323
+
if (rate.ContainsNode(x) || Functions.PartialFractions.IsZeroAsAValue(rate))
43324
+
return null;
43325
+
var powers = new Dictionary<Entity, int>();
43326
+
foreach (var exponential in exponentials)
43327
+
if (Functions.PartialFractions.Bare((((Powf)exponential).Exponent / first).Simplify()) is Number.Integer { EInteger: var whole } && whole.CanFitInInt32())
43328
+
powers[exponential] = whole.ToInt32Unchecked();
43329
+
else
43330
+
return null;
43331
+
var w = Variable.CreateUnique(expr, "w_euler");
43332
+
var inW = expr.Replace(node => powers.TryGetValue(node, out var k) ? MathS.Pow(w, Number.Integer.Create(k)) : node);
43333
+
var exponentialOfTheFirst = exponentials.First(e => powers[e] == 1);
43334
+
// A symbolic power of one function of w, `K B^p`: x K B^(p - 2) H(w) for a rational H, since
43335
+
// (x B^(p - 2) H)' is B^(p - 2) (H + c w H' + (p - 2) c (w B'/B) H), and H solves the system
43336
+
// below with that term beside. Rubi's 6.5.3 `sech(a - ln(c x^n)/(n (p - 2)))^p` has
43337
+
// c = -1/(p - 2), and is `x (p - 2)/(p - 1) sech(u)^(p - 2) (1 - tanh(u))`.
43338
+
Entity? symbolicPower = null, ofIt = null;
43339
+
Entity constantFactor = Number.Integer.One;
43340
+
foreach (var (factor, underneath) in FactorsOfTheIntegrand(inW))
var (above, below) = Functions.SingleQuotient.Of(Functions.SingleQuotient.Combine(inW));
43406
+
if (!TreeAnalyzer.TryGetPolynomial(Functions.PartialFractions.Bare(above.Expand()), w, out var p) || !TreeAnalyzer.TryGetPolynomial(Functions.PartialFractions.Bare(below.Expand()), w, out var q))
43407
+
return null;
43408
+
// Negative powers of w cleared from both.
43409
+
var lowest = p.Keys.Concat(q.Keys).Min()!;
43410
+
Entity Written(Dictionary<EInteger, Entity> read)
43411
+
{
43412
+
Entity sum = Number.Integer.Zero;
43413
+
foreach (var pair in read)
43414
+
sum += pair.Value * MathS.Pow(w, Number.Integer.Create(pair.Key - lowest));
43415
+
return sum.InnerSimplified;
43416
+
}
43417
+
var bigP = Written(p);
43418
+
var bigQ = Written(q);
43419
+
var degreeOfQ = q.Keys.Max()! - lowest;
43420
+
if (!degreeOfQ.CanFitInInt32() || degreeOfQ.ToInt32Unchecked() is < 1 or > 12)
43421
+
return null;
43422
+
var size = degreeOfQ.ToInt32Unchecked() + 1;
43423
+
var derivativeOfQ = bigQ.Differentiate(w);
43424
+
var samples = Enumerable.Range(0, size + 3).Select(k => (Entity)Number.Rational.Create(EInteger.FromInt32(2 + 3 * k), EInteger.FromInt32(1 + k % 3))).ToList();
43425
+
var matrix = new Entity[samples.Count][];
43426
+
var rhs = new Entity[samples.Count];
43427
+
for (var r = 0; r < samples.Count; r++)
43428
+
{
43429
+
var at = samples[r];
43430
+
var qAt = bigQ.Substitute(w, at).InnerSimplified;
43431
+
var qPrimeAt = derivativeOfQ.Substitute(w, at).InnerSimplified;
0 commit comments