Skip to content

Commit 0185ff2

Browse files
Rafael-SOWNetclaude
andcommitted
Integrate a power of a logarithm beside a linear in another as two powers of the first
(a + b L)^p (d + e M), with L = ln(c x^n) and M = ln(f x^r), was declined, and so was it with M = L. M is (r/n) L + delta, where delta = M - (r/n) L is constant between the cuts: its derivative is r/x - (r/n)(n/x) = 0. So d + e M is alpha (a + b L) + beta with alpha = e r/(n b), and the integrand is alpha (a + b L)^(p + 1) + beta (a + b L)^p beside what else is there, each answered by the rules for a power of one logarithm. delta is written back in the answer. Asked after the product of powers read as a derivative, which writes p x^m ln(x)^n ((m + 1) ln(x) + n + 1) as p x^(m + 1) ln(x)^(n + 1), where this would write a sum of gamma functions. Part of #2075. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
1 parent 92227d9 commit 0185ff2

3 files changed

Lines changed: 84 additions & 0 deletions

File tree

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

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18199,6 +18199,75 @@ bool Read(Entity node, bool insideASum)
1819918199
return back.Nodes.Any(node => node == MathS.NaN) ? null : back;
1820018200
}
1820118201

18202+
/// <summary>
18203+
/// A power that is not whole of a linear in one logarithm <c>L = ln(c x^n)</c>, beside a linear in it or in another
18204+
/// logarithm of a power of x, <c>(a + b L)^p (d + e M)</c> with <c>M = ln(f x^r)</c>. M is <c>(r/n) L + delta</c>,
18205+
/// where <c>delta = M - (r/n) L</c> is constant between the cuts, its derivative being <c>r/x - (r/n)(n/x) = 0</c>.
18206+
/// So <c>d + e M</c> is <c>alpha (a + b L) + beta</c>, with <c>alpha = e r/(n b)</c> and
18207+
/// <c>beta = d + e delta - alpha a</c>, and the integrand is <c>alpha (a + b L)^(p + 1) + beta (a + b L)^p</c> beside
18208+
/// what else is there: powers of the one logarithm, which the rules for those answer. delta is written back in the
18209+
/// answer. Rubi's 3.1.5. https://github.com/asc-community/AngouriMath/issues/2075
18210+
/// </summary>
18211+
internal static Entity? SolveAPowerOfALogarithmBesideALinearInALogarithm(Entity expr, Entity.Variable x, bool integrateByParts)
18212+
{
18213+
if (!Integration.AnsweringTheQuestionAskedOrOneBelow || expr is not (Mulf or Divf))
18214+
return null;
18215+
var (numerator, denominator) = expr is Divf(var above, var below) ? (above, below) : (expr, (Entity)Number.Integer.One);
18216+
Powf? power = null;
18217+
Entity? linear = null;
18218+
Entity beside = Number.Integer.One;
18219+
foreach (var factor in Mulf.LinearChildren(numerator))
18220+
{
18221+
if (power is null && factor is Powf(var @base, var exponent) candidate && exponent is not Number.Integer
18222+
&& !exponent.ContainsNode(x) && TheLinearInOneLogarithm(@base, x) is not null)
18223+
power = candidate;
18224+
else if (linear is null && factor.ContainsNode(x) && factor is Logf or Sumf or Minusf && TheLinearInOneLogarithm(factor, x) is not null)
18225+
linear = factor;
18226+
else
18227+
beside *= factor;
18228+
}
18229+
if (power is null || linear is null
18230+
|| TheLinearInOneLogarithm(power.Base, x) is not var (logarithm, degree, a, b)
18231+
|| TheLinearInOneLogarithm(linear, x) is not var (other, otherDegree, d, e))
18232+
return null;
18233+
var ratio = (otherDegree / degree).InnerSimplified;
18234+
Entity delta = other == logarithm ? Number.Integer.Zero : Variable.CreateUnique(expr, "delta_log");
18235+
var alpha = e * ratio / b;
18236+
var beta = d + e * delta - alpha * a;
18237+
beside /= denominator;
18238+
if (Integration.ComputeAsAQuestionOfItsOwn((beside * MathS.Pow(power.Base, power.Exponent + 1)).InnerSimplified, x, integrateByParts) is not { } raised
18239+
|| Integration.ComputeAsAQuestionOfItsOwn((beside * power).InnerSimplified, x, integrateByParts) is not { } asWritten)
18240+
return null;
18241+
var answer = alpha * raised + beta * asWritten;
18242+
if (delta is Variable constant)
18243+
answer = answer.Substitute(constant, other - ratio * logarithm);
18244+
return answer.Nodes.Any(node => node == MathS.NaN) ? null : answer;
18245+
}
18246+
18247+
/// <summary>
18248+
/// <paramref name="expr"/> as <c>a + b L</c>, linear in one logarithm <c>L = ln(c x^n)</c> and free of x otherwise,
18249+
/// with the logarithm, <c>n</c>, <c>a</c> and <c>b</c>; or <see langword="null"/>.
18250+
/// </summary>
18251+
private static (Entity Logarithm, Entity Degree, Entity Offset, Entity Slope)? TheLinearInOneLogarithm(Entity expr, Entity.Variable x)
18252+
{
18253+
Entity? logarithm = null;
18254+
foreach (var node in expr.Nodes)
18255+
if (node is Logf(var @base, var antilogarithm) && @base == MathS.e && antilogarithm.ContainsNode(x))
18256+
{
18257+
if (logarithm is not null && node != logarithm)
18258+
return null;
18259+
logarithm = node;
18260+
}
18261+
if (logarithm is not Logf(_, var argument) || TheMonomial(argument, x) is not var (_, degree) || TreeAnalyzer.IsZero(degree))
18262+
return null;
18263+
var l = Variable.CreateUnique(expr, "l_log");
18264+
var inL = expr.Replace(node => node == logarithm ? l : node);
18265+
if (inL.ContainsNode(x) || !TreeAnalyzer.TryGetPolyLinear(inL, l, out var slope, out var offset)
18266+
|| slope.ContainsNode(l) || offset.ContainsNode(l) || TreeAnalyzer.IsZero(slope))
18267+
return null;
18268+
return (logarithm, degree, offset, slope);
18269+
}
18270+
1820218271
/// <summary>
1820318272
/// Whether <paramref name="factor"/> is a power that is not whole of something holding a logarithm of something in
1820418273
/// <paramref name="x"/>, or an exponential of something in <paramref name="x"/> that is not linear in it.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,10 @@ internal static bool ASumOverRootsWouldAnswer
18371837
// And a product of powers that is the derivative of one with symbolic exponents, its
18381838
// constant read at a point where the quotient of the brackets does not simplify free of x.
18391839
if ((answer = IndefiniteIntegralSolver.SolveAsTheDerivativeOfAProductOfPowersReadAtAPoint(expr, x, integrateByParts)) is { }) return answer;
1840+
// A power of a logarithm beside a linear in another as two powers of the first, after the product of powers read
1841+
// as a derivative: p x^m ln(x)^n ((m + 1) ln(x) + n + 1) is p x^(m + 1) ln(x)^(n + 1) there, and a sum of gamma
1842+
// functions here. https://github.com/asc-community/AngouriMath/issues/2075
1843+
if ((answer = IndefiniteIntegralSolver.SolveAPowerOfALogarithmBesideALinearInALogarithm(expr, x, integrateByParts)) is { }) return answer;
18401844
// An arcoth of a linear as its artanh plus a constant, last of all, so that every arcoth
18411845
// answered as written keeps that answer: `acoth(x)^2/(1 - x^2)^2` is
18421846
// `(atanh(x) + K)^2/(1 - x^2)^2` with `K = acoth(x) - atanh(x)`, constant where it is

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,17 @@ public void APositiveRateIsTakenOutOfThePower()
147147
[InlineData("x*(d + f*acosh(f*x))^n/(sqrt(f*x - 1)*sqrt(f*x + 1))")]
148148
public void ASymbolicPowerOfAnInverseHyperbolicFunction(string integrand) => DifferentiatesBack(integrand);
149149

150+
/// <summary>
151+
/// A power of a linear in one logarithm of a power of x beside a linear in it or in another, which is the first
152+
/// times a ratio of degrees plus a constant between the cuts: two powers of the one logarithm. Rubi's 3.1.5.
153+
/// </summary>
154+
[Theory]
155+
[InlineData("(f - b*ln(c*x^2))^n*(d + a*ln(f*x^3))")]
156+
[InlineData("x^2*(f - b*ln(c*x))^n*(d + a*ln(f*x^3))")]
157+
[InlineData("(f - b*ln(c*x))^n*(d + a*ln(c*x))/x^2")]
158+
[InlineData("(d*x)^m*(f - b*ln(c*x^2))^n*ln(a*x)")]
159+
public void APowerOfALogarithmBesideALinearInALogarithm(string integrand) => DifferentiatesBack(integrand);
160+
150161
/// <summary>
151162
/// Not where the integral is elementary, an exponential integral or an error function: those keep the form
152163
/// they had.

0 commit comments

Comments
 (0)