Skip to content

Commit 492afc2

Browse files
A logarithm of x is matched to a logarithm of a multiple of x below the bar (#1644)
By parts on li(b x)/x takes the antiderivative of 1/x, and with ln(x) the remainder was b ln(x)/ln(b x), which nothing read. ln(b x) is as much an antiderivative of 1/x, and taken so, the logarithm the derivative of li(b x) divides by cancels: li(b x)/x is li(b x) ln(b x) - b x, which is Rubi's answer. The constant of integration is matched to a logarithm of a multiple of x below the bar now, as it is matched to a polynomial divisor. Measured on the Rubi corpus, master at 16203aa and this change on it, run side by side: family 8 380 -> 381 of 420 (li(b x)/x); family 3 at twenty a file 172 and 173 of 180, family 0 1756 of 1814, and families 1, 2 and 4 to 7 at five a file 771 and 770 of 867. 0 wrong everywhere. Run alone, the three that moved are li(b x)/x, answered here and not on master, and 3.2.3 #30 and 6.7.1 #180, answered on both in 19 to 24 s: their side-by-side difference was load. The unit tests pass, 14,262, and the performance gate passes on c6f7a34c, which is this change on 16203aa: allocation is what the baseline says on all 19 gated benchmarks. SpecialFunctionsByPartsTest checks li(b x)/x at positive points, where li(b x) is real. Part of #1501. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9efc486 commit 492afc2

3 files changed

Lines changed: 59 additions & 1 deletion

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,6 +2353,19 @@ a sample of its families 1 to 7 are answered alone as they were.
23532353
| `"x^2*Ei(a+b*x)^2".Integrate("x")` | `a ^ 2 * Ei * x ^ 3 / 3 + a * b * 2 * Ei * x ^ 4 / 4 + b ^ 2 * Ei * x ^ 5 / 5 + C`, with `Ei` a variable | an antiderivative in `Ei(a + b x)` and `Ei(2 (a + b x))` |
23542354
| `"erf(a+b*x)^2".Integrate("x")` | `UnrecognizedFunctionParseException`: there is no function `erf` | an antiderivative in `erf` |
23552355

2356+
### A logarithm of `x` is matched to a logarithm of a multiple of `x` below the bar
2357+
2358+
By parts on `li(b x)/x` takes the antiderivative of `1/x`, and with `ln(x)` the remainder was
2359+
`b ln(x)/ln(b x)`, which nothing read. `ln(b x)` is as much an antiderivative of `1/x`, and taken so,
2360+
the logarithm the derivative of `li(b x)` divides by cancels: `li(b x)/x` is `li(b x) ln(b x) - b x`
2361+
([#1501](https://github.com/asc-community/AngouriMath/issues/1501)). `li` had no reading in 2.5.0,
2362+
which its own entry records, and no integrand without it changes: Rubi's independent suites, its
2363+
family 3 at twenty a file and a sample of the others are answered alone as they were.
2364+
2365+
| Input | Was (2.5.0) | Now |
2366+
|---|---|---|
2367+
| `"li(b*x)/x".Integrate("x")` | `li * b * x + C`, with `li` a variable | `li(b * x) * ln(b * x) - b * x + C` |
2368+
23562369
### An exponential or a hyperbolic function over several linears is split into partial fractions over them
23572370

23582371
`e^x/(x (x + 1))` was left unevaluated, where `e^x/x` and `e^x/(x + 1)` were each answered with

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,18 @@ private static bool IsASpecialFunctionOfALinear(Entity factor, Variable x)
16791679
// divisor, where the division leaves a constant.
16801680
static Entity WithTheConstantMatchedTo(Entity antiderivative, Entity derivativeOfV, Variable x)
16811681
{
1682+
// A logarithm of x, against a logarithm of a multiple of x below the bar: ln(c x) is
1683+
// as much an antiderivative of 1/x as ln(x) is, and taken so, the logarithm the
1684+
// derivative divides by cancels. li(b x)/x is li(b x) ln(b x) - b x, where with ln(x)
1685+
// the remainder was ln(x)/ln(b x), which nothing read.
1686+
// https://github.com/asc-community/AngouriMath/issues/1501
1687+
if (TheLogarithmOfTheVariable(antiderivative, x) is (var logarithmCoefficient, true)
1688+
&& Sumf.LinearChildren(Functions.PartialFractions.Bare(derivativeOfV))
1689+
.SelectMany(term => Mulf.LinearChildren(Functions.SingleQuotient.Of(term).Denominator))
1690+
.FirstOrDefault(factor => factor is Logf(var logBase, var argument) && logBase == MathS.e
1691+
&& TreeAnalyzer.TryGetPolyLinear(argument, x, out var multiple, out var offset)
1692+
&& TreeAnalyzer.IsZero(offset) && !TreeAnalyzer.IsZero(multiple)) is { } logarithmBelow)
1693+
return logarithmCoefficient * logarithmBelow;
16821694
if (!TreeAnalyzer.TryGetPolynomial(antiderivative, x, out _))
16831695
return antiderivative;
16841696
var divisors = Sumf.LinearChildren(Functions.PartialFractions.Bare(derivativeOfV))
@@ -20367,6 +20379,25 @@ private static bool TheRemainderIsAskedTermByTerm(Entity v, Entity u, Variable x
2036720379
|| u == special;
2036820380
}
2036920381

20382+
/// <summary>
20383+
/// <paramref name="expr"/> as a constant times <c>ln(x)</c>, the coefficient and
20384+
/// <see langword="true"/>, or <see langword="false"/> where it is not one.
20385+
/// </summary>
20386+
private static (Entity Coefficient, bool IsOne) TheLogarithmOfTheVariable(Entity expr, Variable x)
20387+
{
20388+
static bool IsTheLogarithm(Entity factor, Variable x) => factor is Logf(var logBase, var argument) && logBase == MathS.e && argument == x;
20389+
if (IsTheLogarithm(expr, x))
20390+
return (Number.Integer.One, true);
20391+
if (expr is Mulf(var left, var right))
20392+
{
20393+
if (IsTheLogarithm(right, x) && !left.ContainsNode(x))
20394+
return (left, true);
20395+
if (IsTheLogarithm(left, x) && !right.ContainsNode(x))
20396+
return (right, true);
20397+
}
20398+
return (Number.Integer.Zero, false);
20399+
}
20400+
2037020401
/// <summary>
2037120402
/// The factors of <paramref name="expr"/> that are polynomials in <paramref name="x"/> of
2037220403
/// positive degree, against the rest: <c>x sin(b x)</c> is <c>x</c> and <c>sin(b x)</c>.

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ public sealed class SpecialFunctionsByPartsTest
3030
/// rule is asked the symbolic question.
3131
/// </summary>
3232
private static void DifferentiatesBack(string integrand, params (string Name, string Value)[] pins)
33+
=> DifferentiatesBackAt(Points, integrand, pins);
34+
35+
/// <summary><see cref="DifferentiatesBack"/> at <paramref name="points"/>.</summary>
36+
private static void DifferentiatesBackAt(double[] points, string integrand, params (string Name, string Value)[] pins)
3337
{
3438
var integral = integrand.ToEntity().Integrate("x");
3539
Assert.DoesNotContain("integral(", integral.Stringize());
3640
Entity Pinned(Entity e) => pins.Aggregate(e, (current, pin) => current.Substitute(pin.Name, pin.Value.ToEntity()));
3741
var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
3842
var original = Pinned(integrand.ToEntity());
39-
foreach (var at in Points)
43+
foreach (var at in points)
4044
{
4145
var got = derivative.Substitute("x", at).EvalNumerical();
4246
var want = original.Substitute("x", at).EvalNumerical();
@@ -73,6 +77,16 @@ public void ASpecialFunctionAloneIsByPartsAgainstOne(string integrand)
7377
public void TheLogarithmicIntegralIsByParts(string integrand)
7478
=> DifferentiatesBack(integrand, ("a", "3"), ("b", "13/10"));
7579

80+
/// <summary>
81+
/// Over <c>x</c>, the antiderivative of <c>1/x</c> is taken as <c>ln(b x)</c>, the logarithm the
82+
/// derivative of <c>li(b x)</c> divides by, and the remainder is <c>b</c>:
83+
/// <c>li(b x) ln(b x) - b x</c>. At positive <c>x</c>, where <c>li(b x)</c> is real, and off
84+
/// <c>x = 1/b</c>, where <c>ln(b x)</c> is 0.
85+
/// </summary>
86+
[Fact]
87+
public void TheLogarithmicIntegralOverXIsOneRoundOfParts()
88+
=> DifferentiatesBackAt(new[] { 0.35, 1.45, 2.3 }, "li(b*x)/x", ("b", "13/10"));
89+
7690
/// <summary>
7791
/// Against a power of <c>x</c>, the special function is the factor differentiated: what is
7892
/// left is the power times <c>e^(-u^2)</c>, <c>e^u/u</c>, <c>sin(u)/u</c> and the like.

0 commit comments

Comments
 (0)