From 5956ceee24b836ff29935e7c9554d14fb1d6a2f6 Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Mon, 5 Oct 2026 05:43:11 +0000 Subject: [PATCH] A power of a monomial in a symbolic power of x is integrated as the power of x it is (c x^n)^b is written c^b x^(n b), and the exponent n b was left as the inner simplification leaves it: (c x^n)^(2/n) came out as c^(2/n) x^(n (2/n)), which no rule reads as x^2, and 1/(a + b (c x^n)^(2/n)) was declined where 1/(a + b c^(2/n) x^2) is answered. The exponent is simplified now. Part of #718. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --- BREAKING-CHANGES.md | 13 +++++ .../Integration/IndefiniteIntegralSolver.cs | 9 +++- ...DistributedPowerOfAMonomialIntegralTest.cs | 48 +++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 Sources/Tests/UnitTests/Calculus/DistributedPowerOfAMonomialIntegralTest.cs diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md index dc39a1fe6..052aa2ddf 100644 --- a/BREAKING-CHANGES.md +++ b/BREAKING-CHANGES.md @@ -328,6 +328,19 @@ polynomial exponent in `u` now, and the question asked in `u`. Rubi's 2.3 | `"F^(a + b/(c + d*x))/(c + d*x)".ToEntity().Integrate("x")` | `integral(...)` | an exponential integral | | `"F^(a + b/(c + d*x)^3)*(c + d*x)^2".ToEntity().Integrate("x")` | `integral(...)` | an exponential integral of the cube, and the exponential | +### A power of a monomial in a symbolic power of `x` is integrated as the power of `x` it is + +**Answers where there were none.** `(c x^n)^b` is written `c^b x^(n b)`, and the exponent `n b` was +left as the inner simplification leaves it: `(c x^n)^(2/n)` came out as `c^(2/n) x^(n (2/n))`, which +no rule reads as `x^2`, and `1/(a + b (c x^n)^(2/n))` was declined where `1/(a + b c^(2/n) x^2)` is +answered. The exponent is simplified now. Rubi's 1.1.3.2 +([#718](https://github.com/asc-community/AngouriMath/issues/718)). + +| Input | Was (2.5.0) | Now | +|---|---|---| +| `"1/(a + b*(c*x^n)^(2/n))".ToEntity().Integrate("x")` | `integral(...)` | an arctangent or a logarithm in `b c^(2/n) x`, by the sign of `a b c^(2/n)` | +| `"1/(1 + 4*(x^(2*n))^(1/n))".ToEntity().Integrate("x")` | `integral(...)` | `arctan(2 x)/2` | + ### A polynomial over a power of a binomial past the cube is integrated **Answers where there were none.** `P(x)/(a + b x^n)^k` with symbols in the binomial, `n >= 3`, was diff --git a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs index 875a31f1c..0d129bfcf 100644 --- a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs +++ b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs @@ -23482,7 +23482,11 @@ private static bool HasTheSameRatioAtTwoPoints(Entity expr, Entity reference, En assumed = assumed == Entity.Boolean.True ? positive : assumed & positive; } changed = true; - var distributed = split ? MathS.Pow(x, (degree! * exponent).InnerSimplified) : MathS.Pow(rest, exponent); + // The exponent of x as it simplifies: `(c x^n)^(2/n)` is `c^(2/n) x^(n (2/n))`, and that + // power of x is `x^2` only once `n (2/n)` is folded, which the inner simplification + // leaves standing -- `1/(a + b (c x^n)^(2/n))` was declined where `1/(a + b c^(2/n) x^2)` + // is answered. Exponents are small. + var distributed = split ? MathS.Pow(x, SimplifiedExponent((degree! * exponent).InnerSimplified)) : MathS.Pow(rest, exponent); return constant == Number.Integer.One ? distributed : MathS.Pow(constant, exponent) * distributed; }); if (!changed) @@ -23498,6 +23502,9 @@ private static bool HasTheSameRatioAtTwoPoints(Entity expr, Entity reference, En if (Integration.ComputeAsTheSameQuestion(rewritten, x, integrateByParts) is not { } answer) return null; return assumed == Entity.Boolean.True ? answer : answer.Provided(assumed); + + static Entity SimplifiedExponent(Entity exponent) + => exponent is Number || exponent.Complexity > 40 ? exponent : Functions.PartialFractions.Bare(exponent.Simplify()); } /// diff --git a/Sources/Tests/UnitTests/Calculus/DistributedPowerOfAMonomialIntegralTest.cs b/Sources/Tests/UnitTests/Calculus/DistributedPowerOfAMonomialIntegralTest.cs new file mode 100644 index 000000000..c3f9f3a97 --- /dev/null +++ b/Sources/Tests/UnitTests/Calculus/DistributedPowerOfAMonomialIntegralTest.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) 2019-2026 Angouri. +// AngouriMath is licensed under MIT. +// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md. +// Website: https://am.angouri.org. +// + +using System; +using AngouriMath.Extensions; +using Xunit; + +namespace AngouriMath.Tests.Calculus +{ + /// + /// A power of a monomial in a symbolic power of x, distributed with its exponent of x + /// simplified: (c x^n)^(2/n) is c^(2/n) x^2. Rubi's 1.1.3.2. + /// #718 + /// + /// + /// Checked by differentiating back with a = 1.3, b = 0.7, c = 0.4 and + /// n = 1.7, at positive x, where a symbolic power of it is real. + /// + [Trait("Area", "Calculus")] + public sealed class DistributedPowerOfAMonomialIntegralTest + { + [Theory] + [InlineData("1/(a + b*(c*x^n)^(2/n))")] + [InlineData("1/(x^2*(a + b*(c*x^n)^(1/n)))")] + [InlineData("1/(a + b*(c*x^n)^(3/n))")] + [InlineData("1/(1 + 4*(x^(2*n))^(1/n))")] + public void IsIntegrated(string integrand) + { + var integral = integrand.ToEntity().Integrate("x"); + Assert.DoesNotContain("integral(", integral.Stringize()); + Entity Pinned(Entity e) => e.Substitute("a", 1.3).Substitute("b", 0.7).Substitute("c", 0.4).Substitute("n", 1.7); + var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x"); + var original = Pinned(integrand.ToEntity()); + foreach (var at in new[] { 0.3, 0.8, 1.4, 2.1 }) + { + var want = original.Substitute("x", at).EvalNumerical(); + var got = derivative.Substitute("x", at).EvalNumerical(); + Assert.True(Math.Abs((double)(got - want).RealPart) + Math.Abs((double)(got - want).ImaginaryPart) + < 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart) + Math.Abs((double)want.ImaginaryPart)), + $"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}"); + } + } + } +}