diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md
index 176583a6a..5c280eaea 100644
--- a/BREAKING-CHANGES.md
+++ b/BREAKING-CHANGES.md
@@ -323,6 +323,22 @@ Rubi's `x^m (a + b x^n)^p` and `(a + b x^n)^p (c + d x^n)^q`
| `"1/(2+3/x^2)^3".Integrate("x")`, `1/(a + b/x^3)` | left unevaluated | an antiderivative |
| `"(a+b*x^n)*(c+d*x^n)^3".Integrate("x")` | left unevaluated | written out, eight powers of `x` integrated: `a c^3 x + ... + b d^3 x^(4 n + 1)/(4 n + 1)` |
+### The derivative of a power of `x` over a binomial is integrated as an arctangent over one plus a multiple of its square
+
+**Answers where there were none.** `(k - 4 f x^3)/(k^2 + 4 d f x^2 + 4 k f x^3 + 4 f^2 x^6)` is
+`w'/(2 f (1 + (d/f) w^2))` for `w = x/(x^3 + k/(2 f))`, and was declined: the partial fractions
+over a sextic in `x`, or over a sum of symbolic powers of it, are out of reach, and nothing read the
+quotient. A denominator `a + b x^p + c x^(2p) + d x^(2j)` with `b^2 = 4 a c` is read as
+`c L^2 + d x^(2j)` for `L = x^p + b/(2c)`, and a numerator that is a constant multiple of
+`(x^j/L)' L^2` is integrated as an arctangent of `x^j/L`, or a logarithm, by the sign of `d/c`.
+Rubi's 1.3.2 ([#718](https://github.com/asc-community/AngouriMath/issues/718)).
+
+| Input | Was (2.5.0) | Now |
+|---|---|---|
+| `"(k - 4*f*x^3)/(k^2 + 4*d*f*x^2 + 4*k*f*x^3 + 4*f^2*x^6)".ToEntity().Integrate("x")` | `integral(...)` | `arctan(sqrt(d/f) x/(x^3 + k/(2 f)))/(2 sqrt(d f))` for `d/f > 0`, a logarithm for `d/f < 0` |
+| `"(k - 2*f*(n - 1)*x^n)/(k^2 + 4*d*f*x^2 + 4*k*f*x^n + 4*f^2*x^(2*n))".ToEntity().Integrate("x")` | `integral(...)` | the same in `x/(x^n + k/(2 f))` |
+| `"x^m*(k*(1 + m) + 2*f*(1 + m - n)*x^n)/(k^2 + 4*d*f*x^(2 + 2*m) + 4*k*f*x^n + 4*f^2*x^(2*n))".ToEntity().Integrate("x")` | `integral(...)` | the same in `x^(m + 1)/(x^n + k/(2 f))` |
+
### A half-odd power of a constant over a polynomial of either sign is integrated with its sign
**Answers where there were none.** `sqrt(1/(1 - x^2))`, the arcsine's derivative where it is real,
diff --git a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs
index 7daa2a0e6..de6cf93c9 100644
--- a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs
@@ -18913,6 +18913,114 @@ static Entity Shifted(Entity exponent, Entity by, bool subtract)
}
}
+ ///
+ /// The derivative of w = x^k/L, for a binomial L = x^p + l, over a multiple of
+ /// L^2 plus a power of x, c L^2 + d x^(2k): the integrand is
+ /// (m/c) w'/(1 + (d/c) w^2), an arctangent of w or a hyperbolic one. Rubi's
+ /// 1.3.2 (e - 4 f x^3)/(e^2 + 4 d f x^2 + 4 e f x^3 + 4 f^2 x^6) is
+ /// arctan(2 sqrt(d f) x/(e + 2 f x^3))/(2 sqrt(d f)), and its rows in symbolic
+ /// powers of x are the same in w = x^(m + 1)/(e + 2 f x^n).
+ ///
+ ///
+ /// The denominator is read as four terms, each a constant times a power of x: one is
+ /// d x^(2k), and the other three are a + b x^p + c x^(2p) with
+ /// b^2 = 4 a c, which is c L^2 for L = x^p + b/(2c). The numerator is
+ /// a constant multiple of k x^(k - 1) L - p x^(k + p - 1), which is w' L^2;
+ /// the constant is read at x = 1, and the answer is differentiated back. Past a
+ /// quartic these were declined: partial fractions over a sextic in x, or over a sum of
+ /// symbolic powers of it, are out of reach, and nothing read the quotient.
+ /// https://github.com/asc-community/AngouriMath/issues/718
+ ///
+ internal static Entity? SolveAsTheArctangentOfAPowerOfXOverABinomial(Entity expr, Entity.Variable x, bool integrateByParts)
+ {
+ var (above, below) = Functions.SingleQuotient.Of(expr);
+ if (!below.ContainsNode(x))
+ return null;
+ var terms = Sumf.LinearChildren(below);
+ if (terms.Count != 4)
+ return null;
+ var read = new (Entity Coefficient, Entity Exponent)[4];
+ for (var i = 0; i < 4; i++)
+ if (ConstantTimesAPowerOfX(terms[i], x) is { } term)
+ read[i] = term;
+ else
+ return null;
+ for (var i = 0; i < 4; i++)
+ {
+ // The i-th as d x^(2k), and the other three as a + b x^p + c x^(2p).
+ Entity? a = null;
+ var powers = new List<(Entity Coefficient, Entity Exponent)>();
+ for (var j = 0; j < 4; j++)
+ if (j != i)
+ {
+ if (Functions.PartialFractions.IsZeroAsAValue(read[j].Exponent))
+ a = a is null ? read[j].Coefficient : null;
+ else
+ powers.Add(read[j]);
+ }
+ if (a is null || powers.Count != 2)
+ continue;
+ if (!Functions.PartialFractions.IsZeroAsAValue(powers[1].Exponent - 2 * powers[0].Exponent))
+ powers.Reverse();
+ var ((b, p), (c, twiceP)) = (powers[0], powers[1]);
+ if (!Functions.PartialFractions.IsZeroAsAValue(twiceP - 2 * p)
+ || !Functions.PartialFractions.IsZeroAsAValue(b * b - 4 * a * c))
+ continue;
+ var (d, twiceK) = read[i];
+ var k = Exponent(twiceK / 2);
+ var binomial = MathS.Pow(x, p) + Exponent(b / (2 * c));
+ // w' L^2, and the constant the numerator is of it.
+ var derivative = k * MathS.Pow(x, Exponent(k - 1)) * binomial - p * MathS.Pow(x, Exponent(k + p - 1));
+ var atOne = derivative.Substitute(x, 1).InnerSimplified;
+ if (Functions.PartialFractions.IsZeroAsAValue(atOne))
+ continue;
+ // The constants in lowest terms: `(e - 4 f)/(1 + e/(2 f) - 3)` is `2 f`.
+ var multiple = Functions.PartialFractions.InLowestTermsOverTheSymbols(above.Substitute(x, 1) / (atOne * c));
+ var ratio = Functions.PartialFractions.InLowestTermsOverTheSymbols(d / c);
+ // The ratio named while it is integrated: as a quotient of symbols it is read as
+ // the coefficient of a general quadratic, with an arm for a double root that 1 + q u^2
+ // never has.
+ var u = Variable.CreateUnique(expr, "u_quotient");
+ var q = Variable.CreateUnique(expr, "q_ratio");
+ if (Integration.ComputeIndefiniteIntegral(1 / (1 + q * MathS.Pow(u, 2)), u, integrateByParts) is not { } inU)
+ return null;
+ var answer = multiple * inU.Substitute(u, MathS.Pow(x, k) / binomial).Substitute(q, ratio);
+ return Functions.PartialFractions.DerivativeHoldsAtSampledPoints(answer, expr, x) ? answer : null;
+ }
+ return null;
+
+ // An exponent as it simplifies: `(2 + 2 m)/2` is `1 + m`. Exponents are small.
+ static Entity Exponent(Entity exponent)
+ => exponent.InnerSimplified is var inner && (inner is Number || inner.Complexity > 40) ? inner : inner.Simplify();
+
+ // A constant times a power of x, `c x^e` with `e` free of x and not 0 unless the term
+ // is free of x; null otherwise.
+ static (Entity Coefficient, Entity Exponent)? ConstantTimesAPowerOfX(Entity term, Entity.Variable x)
+ {
+ Entity coefficient = Number.Integer.One;
+ Entity? exponent = null;
+ foreach (var part in Mulf.LinearChildren(term))
+ {
+ if (!part.ContainsNode(x))
+ {
+ coefficient = coefficient == Number.Integer.One ? part : coefficient * part;
+ continue;
+ }
+ if (exponent is not null)
+ return null;
+ exponent = part switch
+ {
+ Variable v when v == x => Number.Integer.One,
+ Powf(var @base, var e) when @base == x && !e.ContainsNode(x) => e,
+ _ => null
+ };
+ if (exponent is null)
+ return null;
+ }
+ return (coefficient, exponent ?? Number.Integer.Zero);
+ }
+ }
+
///
/// A power of a square written out, (A + B w + C w^2)^p with B^2 = 4 A C and
/// w = x^k, as the power of its root, L = w + B/(2 C): the integral is
diff --git a/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs b/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs
index 3e9474a31..d94cf50b2 100644
--- a/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs
@@ -723,6 +723,10 @@ private static Entity Normalized(Entity expr, Entity.Variable x) =>
// And of quotients, which a substitution leaves where it has simplified a sum over
// the bar: `(c/(a + c u^2))^2` is read by nothing that reads `c^2/(a + c u^2)^2`.
if ((answer = IndefiniteIntegralSolver.SolveByDistributingWholePowersOfQuotients(expr, x, integrateByParts)) is { }) return answer;
+ // The derivative of a power of x over a binomial, over a multiple of the binomial's
+ // square plus a power of x: an arctangent of the quotient, which nothing else reads
+ // past a quartic -- `(e - 4 f x^3)/(e^2 + 4 d f x^2 + 4 e f x^3 + 4 f^2 x^6)`.
+ if ((answer = IndefiniteIntegralSolver.SolveAsTheArctangentOfAPowerOfXOverABinomial(expr, x, integrateByParts)) is { }) return answer;
// And a fractional or symbolic power of a monomial: `(c x^n)^b` is `c^b x^(n b)`
// for a positive `c`, on the `x > 0` where a symbolic `n` leaves the integrand real.
if ((answer = IndefiniteIntegralSolver.SolveByDistributingAPowerOfAMonomial(expr, x, integrateByParts)) is { }) return answer;
diff --git a/Sources/Tests/UnitTests/Calculus/ArctangentOfAPowerOfXOverABinomialIntegralTest.cs b/Sources/Tests/UnitTests/Calculus/ArctangentOfAPowerOfXOverABinomialIntegralTest.cs
new file mode 100644
index 000000000..150b74d8d
--- /dev/null
+++ b/Sources/Tests/UnitTests/Calculus/ArctangentOfAPowerOfXOverABinomialIntegralTest.cs
@@ -0,0 +1,60 @@
+//
+// 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
+{
+ ///
+ /// The derivative of w = x^j/(x^p + l) over a multiple of (x^p + l)^2 plus a
+ /// power of x: an arctangent of w, or a hyperbolic one. Rubi's 1.3.2.
+ /// #718
+ ///
+ ///
+ /// Checked by differentiating back with d = 0.7, f = 0.4, k = 1.3,
+ /// m = 0.6 and n = 1.7: on both sides of 0 where the powers of x are whole, and
+ /// at positive x where they are symbols.
+ ///
+ [Trait("Area", "Calculus")]
+ public sealed class ArctangentOfAPowerOfXOverABinomialIntegralTest
+ {
+ [Theory]
+ [InlineData("(k - 4*f*x^3)/(k^2 + 4*d*f*x^2 + 4*k*f*x^3 + 4*f^2*x^6)")]
+ [InlineData("(k - 4*f*x^3)/(k^2 - 4*d*f*x^2 + 4*k*f*x^3 + 4*f^2*x^6)")]
+ [InlineData("x^2*(3*k + 2*f*x^2)/(k^2 + 4*k*f*x^2 + 4*f^2*x^4 + 4*d*f*x^6)")]
+ [InlineData("x*(2*k - 2*f*x^3)/(k^2 + 4*k*f*x^3 - 4*d*f*x^4 + 4*f^2*x^6)")]
+ public void IsIntegratedOnBothSidesOfZero(string integrand)
+ => DifferentiatesBack(integrand, new[] { -1.6, -0.7, 0.3, 0.9, 1.7 });
+
+ [Theory]
+ [InlineData("(k - 2*f*(n - 1)*x^n)/(k^2 + 4*d*f*x^2 + 4*k*f*x^n + 4*f^2*x^(2*n))")]
+ [InlineData("x^m*(k*(1 + m) + 2*f*(1 + m - n)*x^n)/(k^2 + 4*d*f*x^(2 + 2*m) + 4*k*f*x^n + 4*f^2*x^(2*n))")]
+ [InlineData("x^m*(k*(1 + m) + 2*f*(1 + m - n)*x^n)/(k^2 - 4*d*f*x^(2 + 2*m) + 4*k*f*x^n + 4*f^2*x^(2*n))")]
+ public void IsIntegratedInSymbolicPowersOfX(string integrand)
+ => DifferentiatesBack(integrand, new[] { 0.3, 0.9, 1.7, 2.6 });
+
+ private static void DifferentiatesBack(string integrand, double[] points)
+ {
+ var integral = integrand.ToEntity().Integrate("x");
+ Assert.DoesNotContain("integral(", integral.Stringize());
+ Assert.Contains("arctan(", integral.Stringize());
+ Entity Pinned(Entity e) => e.Substitute("d", 0.7).Substitute("f", 0.4).Substitute("k", 1.3).Substitute("m", 0.6).Substitute("n", 1.7);
+ var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
+ var original = Pinned(integrand.ToEntity());
+ foreach (var at in points)
+ {
+ 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}");
+ }
+ }
+ }
+}