Skip to content

Commit 2aae852

Browse files
A binomial differential with a symbol in its exponents is integrated in Chebyshev's third case (#1792)
1/(a + b x^n)^((1 + 2 n)/n) and the rest of x^m (a + b x^n)^p with a symbol in the exponents where (m + 1)/n + p + 1 is a whole number at most 0 were declined, but for x^m beside the binomial at 0. Rubi's reduction raises p by one, and as many steps of it as the number says reach x^(m + 1) (a + b x^n)^(p + 1)/(a (m + 1)); each coefficient is put in lowest terms over the symbols, and the answer is differentiated back. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent e2dfc5c commit 2aae852

4 files changed

Lines changed: 180 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,20 @@ out shorter and five longer -- `1/((c x)^(5/3) (a + b x^2)^(2/3))` was
15831583
`-3/(2 a) x (c x)^(-5/3) (a + b x^2)^(1/3)` there, and is the same function written in `x^(1/3)`.
15841584
2.5.0 declined all nine.
15851585

1586+
### A binomial differential with a symbol in its exponents is integrated in Chebyshev's third case
1587+
1588+
**Answers where there were none.** `1/(a + b x^n)^((1 + 2 n)/n)` and the rest of `x^m (a + b x^n)^p`
1589+
with a symbol in the exponents where `(m + 1)/n + p + 1` is a whole number at most 0 were declined,
1590+
but for `x^m` beside the binomial at 0. Rubi's reduction raises `p` by one,
1591+
`J(p) = -x^(m+1) (a + b x^n)^(p+1)/(a n (p + 1)) + (m + 1 + n (p + 1))/(a n (p + 1)) J(p + 1)`, and as many
1592+
steps of it as the number says reach `x^(m + 1) (a + b x^n)^(p + 1)/(a (m + 1))`. Rubi's 1.1.3.2
1593+
([#718](https://github.com/asc-community/AngouriMath/issues/718)).
1594+
1595+
| Input | Was (2.5.0) | Now |
1596+
|---|---|---|
1597+
| `"1/(a + b*x^n)^((1 + n)/n)".ToEntity().Integrate("x")` | `integral(...)` | `x (a + b x^n)^(-1/n)/a` |
1598+
| `"1/(a + b*x^n)^((1 + 2*n)/n)".ToEntity().Integrate("x")` | `integral(...)` | `x (a + b x^n)^(-1 - 1/n)/(a (n + 1)) + n x (a + b x^n)^(-1/n)/(a^2 (n + 1))` |
1599+
15861600
### A power of a multiple of a quadratic's derivative beside a power of the quadratic is a binomial
15871601

15881602
**Improvement, not silent.** `(b d + 2 c d x)^m (a + b x + c x^2)^p`, with a power that is not whole,

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

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12980,6 +12980,118 @@ static bool IsRationalInBoth(Entity e, Entity.Variable x, Entity.Variable L)
1298012980
return null;
1298112981
}
1298212982

12983+
12984+
/// <summary>
12985+
/// A binomial differential <c>x^m (a + b x^n)^p</c> with a symbol in its exponents, in
12986+
/// Chebyshev's third case at a whole <c>(m + 1)/n + p + 1 = -k</c> of at most 0: Rubi's
12987+
/// <c>1/(a + b x^n)^((1 + 2 n)/n)</c>.
12988+
/// </summary>
12989+
/// <remarks>
12990+
/// At <c>k = 0</c> the integral is <c>x^(m + 1) (a + b x^n)^(p + 1)/(a (m + 1))</c>, whose
12991+
/// derivative is the integrand there. Below it Rubi's reduction raises <c>p</c> by one,
12992+
/// <code>
12993+
/// J(p) = -x^(m + 1) (a + b x^n)^(p + 1)/(a n (p + 1)) + (m + 1 + n (p + 1))/(a n (p + 1)) J(p + 1)
12994+
/// </code>
12995+
/// and <c>k</c> steps of it reach the first. <see cref="SolveABinomialDifferential(Entity, Entity.Variable)"/> reads
12996+
/// the three cases with numbers for the exponents; with a symbol, a power of x beside the
12997+
/// binomial at <c>k = 0</c> is <see cref="SolveAsTheDerivativeOfAProductOfPowers"/>'s, which
12998+
/// leaves a power on its own and every <c>k</c> past 0, and those were declined: Rubi's
12999+
/// 1.1.3.2:3301-3304. The answer is differentiated back at sampled points before it is
13000+
/// returned.
13001+
/// https://github.com/asc-community/AngouriMath/issues/718
13002+
/// </remarks>
13003+
internal static Entity? SolveABinomialInTheThirdCaseWithASymbolicExponent(Entity expr, Entity.Variable x)
13004+
{
13005+
Entity constant = Number.Integer.One;
13006+
Entity m = Number.Integer.Zero;
13007+
Entity? sum = null, p = null;
13008+
foreach (var (factor, underneath) in FactorsOfTheIntegrand(expr))
13009+
{
13010+
if (!factor.ContainsNode(x))
13011+
{
13012+
constant = underneath ? constant / factor : constant * factor;
13013+
continue;
13014+
}
13015+
var (@base, exponent) = factor is Powf(var factorBase, var factorExponent) && !factorExponent.ContainsNode(x) ? (factorBase, factorExponent) : (factor, (Entity)Number.Integer.One);
13016+
if (underneath)
13017+
exponent = -exponent;
13018+
if (@base == x)
13019+
{
13020+
m = m + exponent;
13021+
continue;
13022+
}
13023+
if (sum is not null || @base is not (Sumf or Minusf))
13024+
return null;
13025+
(sum, p) = (@base, exponent);
13026+
}
13027+
if (sum is null || p is null || ABinomial(sum) is not var (a, b, n))
13028+
return null;
13029+
m = m.InnerSimplified;
13030+
p = p.InnerSimplified;
13031+
// A symbol among the exponents: with numbers only it is the binomial differential's.
13032+
if (!m.Vars.Any() && !n.Vars.Any() && !p.Vars.Any())
13033+
return null;
13034+
var s = Simplified((m + 1) / n + p + 1);
13035+
if (s is not Number.Integer { EInteger: var whole } || whole.Sign > 0 || whole.CompareTo(-6) < 0)
13036+
return null;
13037+
var k = -whole.ToInt32Checked();
13038+
static bool Zero(Entity value) => Functions.PartialFractions.IsZeroAsAValue(value);
13039+
if (Zero(m + 1) || Zero(a))
13040+
return null;
13041+
// Each coefficient in lowest terms over the symbols: the first step's
13042+
// `(-3) n/(a n (-3 - 1/n))` is `3 n/(a (3 n + 1))`.
13043+
var raisedX = MathS.Pow(x, Simplified(m + 1));
13044+
Entity? answer = null;
13045+
Entity coefficient = Number.Integer.One;
13046+
for (var j = 0; j < k; j++)
13047+
{
13048+
var raised = Simplified(p + j + 1);
13049+
if (Zero(raised))
13050+
return null;
13051+
var term = LowestOverTheSymbols(-coefficient / (a * n * raised)) * raisedX * MathS.Pow(sum, raised);
13052+
answer = answer is null ? term : answer + term;
13053+
coefficient = LowestOverTheSymbols(coefficient * (m + 1 + n * raised) / (a * n * raised));
13054+
}
13055+
var last = LowestOverTheSymbols(coefficient / (a * (m + 1))) * raisedX * MathS.Pow(sum, Simplified(p + k + 1));
13056+
answer = constant * (answer is null ? last : answer + last);
13057+
return Functions.PartialFractions.DerivativeHoldsAtSampledPoints(answer, expr, x) ? answer : null;
13058+
13059+
// `a + b x^n`, `b x^n + a`: the constant, the coefficient and the power, each free of x.
13060+
(Entity, Entity, Entity)? ABinomial(Entity binomial)
13061+
{
13062+
Entity? free = null, coefficient = null, power = null;
13063+
foreach (var term in Sumf.LinearChildren(binomial))
13064+
{
13065+
if (!term.ContainsNode(x))
13066+
{
13067+
if (free is not null)
13068+
return null;
13069+
free = term;
13070+
continue;
13071+
}
13072+
if (coefficient is not null)
13073+
return null;
13074+
Entity c = Number.Integer.One;
13075+
foreach (var part in Mulf.LinearChildren(term))
13076+
if (!part.ContainsNode(x))
13077+
c = c == Number.Integer.One ? part : c * part;
13078+
else if (part == x && power is null)
13079+
power = Number.Integer.One;
13080+
else if (part is Powf(var powerBase, var powerExponent) && powerBase == x && !powerExponent.ContainsNode(x) && power is null)
13081+
power = powerExponent;
13082+
else
13083+
return null;
13084+
coefficient = c;
13085+
}
13086+
return free is null || coefficient is null || power is null ? null : (free, coefficient, power);
13087+
}
13088+
13089+
// A short exponent simplified: `p + 1 + 1` is `p + 2`, which the inner simplification
13090+
// leaves as written, and `1/n - (1 + n)/n + 1` is 0, which the simplification gives with
13091+
// `n` not 0 beside it.
13092+
static Entity Simplified(Entity exponent)
13093+
=> exponent.InnerSimplified is var inner && (inner is Number || inner.Complexity > 40) ? inner : Functions.PartialFractions.Bare(inner.Simplify());
13094+
}
1298313095
/// <summary>
1298413096
/// Powers of two linears whose exponents sum to a whole number <c>-k</c>, <c>k &gt;= 2</c>,
1298513097
/// beside a polynomial of degree at most <c>k - 2</c>: <c>(a + b x)^m (c + d x)^(-3 - m)</c>,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,10 @@ private static Entity Normalized(Entity expr, Entity.Variable x) =>
777777
// of the powers raised by one -- `e^x x^2 ln(x)^2 (3 + (3 + x) ln(x))` -- read off
778778
// the sum, for symbolic exponents too. Before the split, which loses it.
779779
if ((answer = IndefiniteIntegralSolver.SolveAsTheDerivativeOfAProductOfPowers(expr, x)) is { }) return answer;
780+
// And a power of a binomial in x^n beside a power of x, with a symbol in the exponents,
781+
// where Chebyshev's third case is a whole number at most 0: by Rubi's reduction, which
782+
// the rule above does not read for a power on its own or past the first step.
783+
if ((answer = IndefiniteIntegralSolver.SolveABinomialInTheThirdCaseWithASymbolicExponent(expr, x)) is { }) return answer;
780784
// Powers of two linears whose exponents sum to a whole number below -2, beside a polynomial of
781785
// low degree, by t = L1/L2: a power of t beside a polynomial. The rule above reads the sum -2.
782786
if ((answer = IndefiniteIntegralSolver.SolveTwoLinearPowersWhoseExponentsSumToAWholeNumber(expr, x)) is { }) return answer;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
/// A binomial differential <c>x^m (a + b x^n)^p</c> with a symbol in its exponents, where
16+
/// <c>(m + 1)/n + p + 1</c> is a whole number at most 0: Rubi's 1.1.3.2:3301-3304 and the same
17+
/// with a power of x beside the binomial.
18+
/// <a href="https://github.com/asc-community/AngouriMath/issues/718">#718</a>
19+
/// </summary>
20+
/// <remarks>
21+
/// Checked by differentiating back with <c>a = 1.3</c>, <c>b = 0.7</c>, <c>n = 1.7</c> and
22+
/// <c>m = 0.6</c>, at positive <c>x</c>, where a symbolic power of it is real.
23+
/// </remarks>
24+
[Trait("Area", "Calculus")]
25+
public sealed class BinomialInTheThirdCaseWithASymbolicExponentIntegralTest
26+
{
27+
[Theory]
28+
[InlineData("1/(a + b*x^n)^((1 + n)/n)")]
29+
[InlineData("1/(a + b*x^n)^((1 + 2*n)/n)")]
30+
[InlineData("1/(a + b*x^n)^((1 + 4*n)/n)")]
31+
[InlineData("x^2/(a + b*x^n)^((3 + 2*n)/n)")]
32+
[InlineData("x^m*(a + b*x^n)^(-(m + 1)/n - 3)")]
33+
public void IsIntegrated(string integrand)
34+
{
35+
var integral = integrand.ToEntity().Integrate("x");
36+
Assert.DoesNotContain("integral(", integral.Stringize());
37+
Entity Pinned(Entity e) => e.Substitute("a", 1.3).Substitute("b", 0.7).Substitute("n", 1.7).Substitute("m", 0.6);
38+
var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
39+
var original = Pinned(integrand.ToEntity());
40+
foreach (var at in new[] { 0.3, 0.8, 1.4, 2.1 })
41+
{
42+
var want = original.Substitute("x", at).EvalNumerical();
43+
var got = derivative.Substitute("x", at).EvalNumerical();
44+
Assert.True(Math.Abs((double)(got - want).RealPart) + Math.Abs((double)(got - want).ImaginaryPart)
45+
< 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart) + Math.Abs((double)want.ImaginaryPart)),
46+
$"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}");
47+
}
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)