Skip to content

Commit 49bf5d1

Browse files
Integrate a power of a power of a logarithm over x below the question asked (#2037)
SolvePowersOfOneLinearAsOnePower answered only at the question asked. Under u = ln(a x^n), Rubi's 3.5 (ln(a x^n)^2)^p/x is (u^2)^p/n, a symbolic power of a power of the variable, and that is a question below the top. Below it the rule now reads powers of the variable itself, with no sum in x in them, and (u^2)^p is u (u^2)^p/(2 p + 1) on both sides of u = 0. Chain against master 2a98be4: pocket 5661 -> 5662 solved of 5675, 0 wrong; every family's samples unchanged; the one row that moved, 3.5:188, master declines and this answers. 11,193 rows compared for allocation, none grew past 1.3x and 300 MB. Part of #233. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 5b85e6b commit 49bf5d1

3 files changed

Lines changed: 68 additions & 1 deletion

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,20 @@ the working digits, or `MathS.Settings.PrecisionErrorZeroRange` where a caller h
486486
still that integer, so `e^(-123.456)` is 0 as it was.
487487
[#1338](https://github.com/asc-community/AngouriMath/issues/1338).
488488

489+
### A power of a power of a logarithm over x is integrated below the question asked too
490+
491+
**Answers where there were none.** Rubi's 3.5 `(ln(a x^n)^2)^p/x` was declined. Under `u = ln(a x^n)` it is
492+
`(u^2)^p/n`, a symbolic power of a power of the variable, and the rule for powers of one linear answered that only
493+
where it was the question asked; below it, the rule now reads powers of the variable itself, with no sum in it. Its integral is
494+
`u (u^2)^p/(2 p + 1)` on both sides of `u = 0`, written as `(u^2)^p/u^(2 p)`, constant on each side, times
495+
`u^(2 p + 1)/(2 p + 1)` ([#233](https://github.com/asc-community/AngouriMath/issues/233)).
496+
497+
| Input | Was (2.5.0) | Now |
498+
|---|---|---|
499+
| `"(ln(x)^2)^p/x".ToEntity().Integrate("x")` | `integral(...)` | 79 characters |
500+
| `"(ln(a*x^n)^2)^p/x".ToEntity().Integrate("x")` | `integral(...)` | 107 characters |
501+
| `"(ln(a*x)^3)^p/x".ToEntity().Integrate("x")` | `integral(...)` | 91 characters |
502+
489503
### A polynomial over a power of the linear of an artanh is written in powers of the linear
490504

491505
**Answers where there were none.** `x (a + b atanh(c x))^2/(d + c d x)^3`, Rubi's 7.3.4, ran out of time. In powers of

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27382,7 +27382,10 @@ Entity At(Dictionary<EInteger, Entity> read, EInteger power)
2738227382
/// </remarks>
2738327383
internal static Entity? SolvePowersOfOneLinearAsOnePower(Entity expr, Entity.Variable x, bool integrateByParts)
2738427384
{
27385-
if (!Integration.AnsweringTheQuestionAsked)
27385+
// Below the top only powers of x itself, with no sum in x to read: `(u^2)^p`, which
27386+
// `u = ln(x)` makes of Rubi's 3.5 `(ln(x)^2)^p/x`, is `u (u^2)^p/(2 p + 1)` and was
27387+
// declined there.
27388+
if (!Integration.AnsweringTheQuestionAsked && expr.Nodes.Any(node => node is Sumf or Minusf && node.ContainsNode(x)))
2738627389
return null;
2738727390
// Without a leading `1 *`, which is another spelling to the rules that read the result.
2738827391
static Entity Times(Entity a, Entity b) => a == Number.Integer.One ? b : a * b;
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 symbolic power of a power of the variable, asked below the question: <c>u = ln(x)</c> makes
16+
/// Rubi's 3.5 <c>(ln(x)^2)^p/x</c> the question <c>(u^2)^p</c>, which is <c>u (u^2)^p/(2 p + 1)</c>
17+
/// on every branch and was answered only where it was the question asked.
18+
/// <a href="https://github.com/asc-community/AngouriMath/issues/233">#233</a>
19+
/// </summary>
20+
[Trait("Area", "Calculus")]
21+
public sealed class APowerOfASquaredLogarithmOverXIntegralTest
22+
{
23+
[Theory]
24+
[InlineData("(ln(x)^2)^p/x")]
25+
[InlineData("(ln(a*x^n)^2)^p/x")]
26+
[InlineData("(ln(a*x)^3)^p/x")]
27+
public void DifferentiatesBack(string integrand)
28+
{
29+
var integral = integrand.ToEntity().Integrate("x");
30+
Assert.DoesNotContain("integral(", integral.Stringize());
31+
Entity Pinned(Entity e) => e.Substitute("a", 1.3).Substitute("n", 2.0).Substitute("p", 0.35);
32+
var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
33+
var original = Pinned(integrand.ToEntity());
34+
var compared = 0;
35+
// Both sides of ln = 0, where (ln^2)^p is real and ln^(2p) is not.
36+
foreach (var at in new[] { 0.2, 0.5, 0.8, 1.4, 2.6, 4.1 })
37+
{
38+
var want = original.Substitute("x", at).EvalNumerical();
39+
var got = derivative.Substitute("x", at).EvalNumerical();
40+
if (want.IsNaN || got.IsNaN)
41+
continue;
42+
compared++;
43+
Assert.True(Math.Abs((double)(got - want).RealPart) + Math.Abs((double)(got - want).ImaginaryPart)
44+
< 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart) + Math.Abs((double)want.ImaginaryPart)),
45+
$"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}");
46+
}
47+
Assert.True(compared >= 5, $"only {compared} points could be compared for {integrand}");
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)