diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md
index ce00080e0..ffb6e7432 100644
--- a/BREAKING-CHANGES.md
+++ b/BREAKING-CHANGES.md
@@ -658,6 +658,21 @@ leading coefficient once expanded, and declined: it is read expanded and bare no
| `"sin(x)/(a+b*sin(x))^3".Integrate("x")`, Rubi's 4.1.2.1 row 242 | `integral(...)` | the antiderivative |
| `"4*x*(1+x^2)/(a*x^2+2*b*x+a)^3".Integrate("x")` | `integral(...)` | the antiderivative |
+### A linear over a linear beside the root of a cubic binomial is integrated where that is elementary
+
+**Answers where there were none.** `(1 + x + sqrt(3))/((1 + x - sqrt(3)) sqrt(1 + x^3))` and the rest
+of Rubi's 1.3.2 quotients of linears, and of quadratics, beside the reciprocal of the root of
+`a + b x^3` were declined. The curve is elliptic, and the integral elementary only at coefficients
+where it is a constant times an arctangent or an inverse hyperbolic tangent of `(1 + p x)/sqrt(a + b x^3)`,
+or of its square over the root. Rubi's 1.3.3 names those coefficients, and its rules are taken
+([#718](https://github.com/asc-community/AngouriMath/issues/718)).
+
+| Input | Was (2.5.0) | Now |
+|---|---|---|
+| `"(2^(2/3) - 2*x)/((2^(2/3) + x)*sqrt(1 + x^3))".ToEntity().Integrate("x")` | `integral(...)` | `2 2^(2/3) arctan(sqrt(3) (1 + 2^(1/3) x)/sqrt(1 + x^3))/sqrt(3)` |
+| `"(c - 2*d*x)/((c + d*x)*sqrt(c^3 + 4*d^3*x^3))".ToEntity().Integrate("x")` | `integral(...)` | `2 c/d` times an arctangent of `sqrt(3 c^3) (1 + 2 d x/c)/sqrt(c^3 + 4 d^3 x^3)` over `sqrt(3 c^3)`, or an inverse hyperbolic tangent, by the sign of `c^3` |
+| `"(1+x)/((x-2)*sqrt(1+x^3))".ToEntity().Integrate("x")` | `integral(...)` | `-(2/3) artanh((1 + x)^2/(3 sqrt(1 + x^3)))`, written as a logarithm |
+
### `x^2` over a three-quarter power of a quadratic binomial beside another is integrated where that is elementary
**Answers where there were none.** `x^2/((A + B x^2)^(3/4) (C + D x^2))` at `B C - 2 A D = 0`, Rubi's
diff --git a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs
index 6bc944eda..db6d8329e 100644
--- a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs
@@ -4818,6 +4818,108 @@ private static bool TryReadAsABinomialIn(Entity expr, Entity.Variable x, out Ent
return !c.ContainsNode(x) && n >= 1;
}
+ ///
+ /// A linear over a linear, or a quadratic over a quadratic, beside the reciprocal of the
+ /// square root of a cubic binomial a + b x^3, at the coefficients where its
+ /// integral is elementary: Rubi's (1 + x + sqrt(3))/((1 + x - sqrt(3)) sqrt(1 + x^3)),
+ /// (c - 2 d x)/((c + d x) sqrt(c^3 + 4 d^3 x^3)).
+ ///
+ ///
+ ///
+ /// The curve y^2 = a + b x^3 is elliptic, and the integral of (e + f x)/((c + d x) y)
+ /// is elementary only where the coefficients make it so. Rubi's 1.3.3 names those places,
+ /// and at each the integral is a constant times int du/(1 + K u^2) at
+ /// u = (1 + p x)/y, or (1 + p x)^2/y:
+ ///
+ /// b c^3 = 4 a d^3, 2 d e + c f = 0: (2 e/d) int 1/(1 + 3 a u^2), u = (1 + 2 d x/c)/y
+ /// b c^3 = -8 a d^3, 2 d e + c f = 0: (-2 e/(9 d)) int 1/(1 - (a/9) u^2), u = (1 + f x/e)^2/y
+ /// b^2 c^6 - 20 a b c^3 d^3 - 8 a^2 d^6 = 0, 6 a d^4 e = c f (b c^3 - 22 a d^3), k = (d e + 2 c f)/(c f):
+ /// ((1 + k) e/d) int 1/(1 + (3 + 2k) a u^2), u = (1 + (1 + k) d x/c)/y
+ ///
+ /// and over a quadratic, (f + g x + h x^2)/((c + d x + e x^2) y) where
+ /// b g^3 = 8 a h^3, g^2 + 2 f h = 0 and b d f + b c g = 4 a e h:
+ /// -(g/e) int 1/(1 - M u^2), M = (b d f - 2 a e h)/(2 e h), at u = (1 + 2 h x/g)/y.
+ /// Each condition is decided at sampled values of the symbols, the inner integral is an
+ /// arctangent or an inverse hyperbolic tangent by the sign of its constant, and the answer
+ /// is differentiated back at sampled points before it is returned.
+ /// https://github.com/asc-community/AngouriMath/issues/718
+ ///
+ ///
+ internal static Entity? SolveAPseudoEllipticQuotientOverTheRootOfACubicBinomial(Entity expr, Entity.Variable x)
+ {
+ var (numerator, denominator) = Functions.SingleQuotient.Of(expr);
+ Entity? radicand = null;
+ Entity below = Number.Integer.One;
+ foreach (var factor in Mulf.LinearChildren(denominator))
+ if (factor is Powf(var @base, Number.Rational half) && half.ERational.Equals(ERational.Create(1, 2)) && @base.ContainsNode(x))
+ {
+ if (radicand is not null)
+ return null;
+ radicand = @base;
+ }
+ else
+ below *= factor;
+ if (radicand is null || numerator.Nodes.Any(node => node is Powf(_, Number.Rational r) && r is not Number.Integer && node.ContainsNode(x))
+ || !TreeAnalyzer.TryGetPolynomial(radicand, x, out var cubic) || cubic.Count != 2
+ || !cubic.TryGetValue(EInteger.Zero, out var a) || !cubic.TryGetValue(EInteger.FromInt32(3), out var b)
+ || !TreeAnalyzer.TryGetPolynomial(numerator, x, out var above) || !TreeAnalyzer.TryGetPolynomial(below, x, out var under))
+ return null;
+ Entity Coefficient(Dictionary read, int power)
+ => read.TryGetValue(EInteger.FromInt32(power), out var value) ? value : Number.Integer.Zero;
+ int Degree(Dictionary read) => read.Count == 0 ? -1 : read.Keys.Max()!.ToInt32Unchecked();
+ if (Degree(above) > 2 || Degree(under) is not (1 or 2) || Degree(above) > Degree(under))
+ return null;
+ // A condition is decided as a value, at pinned symbols where nothing simplifies it
+ // to zero -- `6 a d^4 e - c f (b c^3 - 22 a d^3)` at `c = 1 - sqrt(3)` and
+ // `d = (b/a)^(1/3)` is one -- since the answer is checked by its derivative anyway.
+ static bool Zero(Entity condition) => Functions.PartialFractions.IsZeroAsAValue(condition);
+ var y = MathS.Sqrt(radicand);
+ var u = Variable.CreateUnique(expr, "u_pseudo");
+ // int du/(1 + K u^2), by the sign of K.
+ Entity OverOnePlus(Entity k)
+ {
+ var kLowest = LowestOverTheSymbols(k);
+ return BySign(kLowest,
+ MathS.Arctan(MathS.Sqrt(kLowest) * u) / MathS.Sqrt(kLowest),
+ MathS.Hyperbolic.Artanh(MathS.Sqrt(LowestOverTheSymbols(-kLowest)) * u) / MathS.Sqrt(LowestOverTheSymbols(-kLowest)));
+ }
+ Entity? answer = null;
+ if (Degree(under) == 1)
+ {
+ var (e, f) = (Coefficient(above, 0), Coefficient(above, 1));
+ var (c, d) = (Coefficient(under, 0), Coefficient(under, 1));
+ if (Zero(d * e - c * f) || Zero(c))
+ return null;
+ if (Zero(b * MathS.Pow(c, 3) - 4 * a * MathS.Pow(d, 3)) && Zero(2 * d * e + c * f))
+ answer = (2 * e / d * OverOnePlus(3 * a)).Substitute(u, (1 + 2 * d * x / c) / y);
+ else if (!Zero(e) && Zero(b * MathS.Pow(c, 3) + 8 * a * MathS.Pow(d, 3)) && Zero(2 * d * e + c * f))
+ answer = (-2 * e / (9 * d) * OverOnePlus(-a / 9)).Substitute(u, MathS.Pow(1 + f * x / e, 2) / y);
+ else if (!Zero(f)
+ && Zero(MathS.Pow(b, 2) * MathS.Pow(c, 6) - 20 * a * b * MathS.Pow(c, 3) * MathS.Pow(d, 3) - 8 * MathS.Pow(a, 2) * MathS.Pow(d, 6))
+ && Zero(6 * a * MathS.Pow(d, 4) * e - c * f * (b * MathS.Pow(c, 3) - 22 * a * MathS.Pow(d, 3))))
+ {
+ var k = LowestOverTheSymbols((d * e + 2 * c * f) / (c * f));
+ answer = ((1 + k) * e / d * OverOnePlus((3 + 2 * k) * a)).Substitute(u, (1 + (1 + k) * d * x / c) / y);
+ }
+ }
+ else
+ {
+ var (f, g, h) = (Coefficient(above, 0), Coefficient(above, 1), Coefficient(above, 2));
+ var (c, d, e) = (Coefficient(under, 0), Coefficient(under, 1), Coefficient(under, 2));
+ if (!Zero(g) && !Zero(h)
+ && Zero(b * MathS.Pow(g, 3) - 8 * a * MathS.Pow(h, 3)) && Zero(MathS.Pow(g, 2) + 2 * f * h)
+ && Zero(b * d * f + b * c * g - 4 * a * e * h) && !Zero(b * d * f - 2 * a * e * h))
+ answer = (-g / e * OverOnePlus(-(b * d * f - 2 * a * e * h) / (2 * e * h))).Substitute(u, (1 + 2 * h * x / g) / y);
+ }
+ if (answer is null)
+ return null;
+ answer = answer.InnerSimplified;
+ bool holds;
+ using (MathS.Settings.DowncastingEnabled.Set(false))
+ holds = Functions.PartialFractions.HoldsAtSampledPoints(answer.Differentiate(x), expr, x);
+ return holds ? answer : null;
+ }
+
///
/// A root of a quadratic binomial beside another, 1/((A + B x^2)^(1/3) (C + D x^2))
/// with B C + 3 A D = 0 or B C - 9 A D = 0, and
diff --git a/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs b/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs
index b7cf7cf7c..3e9474a31 100644
--- a/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs
@@ -795,6 +795,11 @@ private static Entity Normalized(Entity expr, Entity.Variable x) =>
// the polynomial written in powers of the linear at its root: the part the power
// divides goes over the rest alone. Before the split, so that the whole polynomial
// is reduced once rather than each of its terms.
+ // A linear over a linear beside the root of a cubic binomial, or a quadratic over a
+ // quadratic, at the coefficients where the integral is elementary: Rubi's
+ // `(1 + x + sqrt(3))/((1 + x - sqrt(3)) sqrt(1 + x^3))`. Before the reduction over the
+ // linear, which writes it as `1` and `2 sqrt(3)` over the linear, neither elementary.
+ if ((answer = IndefiniteIntegralSolver.SolveAPseudoEllipticQuotientOverTheRootOfACubicBinomial(expr, x)) is { }) return answer;
if ((answer = IndefiniteIntegralSolver.SolveByReducingThePolynomialOverALinearFactor(expr, x, integrateByParts)) is { }) return answer;
if (expr is Entity.Sumf or Entity.Minusf
&& (answer = IndefiniteIntegralSolver.SolveBySplittingSum(expr, x, integrateByParts)) is { })
diff --git a/Sources/Tests/UnitTests/Calculus/PseudoEllipticQuotientIntegralTest.cs b/Sources/Tests/UnitTests/Calculus/PseudoEllipticQuotientIntegralTest.cs
new file mode 100644
index 000000000..fe691adb8
--- /dev/null
+++ b/Sources/Tests/UnitTests/Calculus/PseudoEllipticQuotientIntegralTest.cs
@@ -0,0 +1,55 @@
+//
+// 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 linear over a linear, or a quadratic over a quadratic, beside the reciprocal of the
+ /// square root of a cubic binomial, at the coefficients where the integral is elementary:
+ /// Rubi's 1.3.2, by its 1.3.3's rules.
+ /// #718
+ ///
+ ///
+ /// Checked by differentiating back with a = 1.3, b = 0.7, c = 1.1 and
+ /// d = 0.6, at points where the radicand is positive and away from the pole.
+ ///
+ [Trait("Area", "Calculus")]
+ public sealed class PseudoEllipticQuotientIntegralTest
+ {
+ [Theory]
+ // b c^3 = 4 a d^3 and 2 d e + c f = 0.
+ [InlineData("(c - 2*d*x)/((c + d*x)*sqrt(c^3 + 4*d^3*x^3))")]
+ [InlineData("(2^(2/3) - 2*x)/((2^(2/3) + x)*sqrt(1 + x^3))")]
+ // b c^3 = -8 a d^3 and 2 d e + c f = 0.
+ [InlineData("(a^(1/3) + b^(1/3)*x)/((2*a^(1/3) - b^(1/3)*x)*sqrt(a + b*x^3))")]
+ // b^2 c^6 - 20 a b c^3 d^3 - 8 a^2 d^6 = 0, at its second condition.
+ [InlineData("(1 + x + sqrt(3))/((1 + x - sqrt(3))*sqrt(1 + x^3))")]
+ [InlineData("(1 + (b/a)^(1/3)*x - sqrt(3))/((1 + (b/a)^(1/3)*x + sqrt(3))*sqrt(a + b*x^3))")]
+ // A quadratic over a quadratic.
+ [InlineData("(2 - 2*x - x^2)/((2 + d + d*x + x^2)*sqrt(1 + x^3))")]
+ 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", 1.1).Substitute("d", 0.6);
+ var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
+ var original = Pinned(integrand.ToEntity());
+ foreach (var at in new[] { -0.8, -0.4, 0.3, 1.1, 1.6 })
+ {
+ 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}");
+ }
+ }
+ }
+}
diff --git a/Sources/Tests/UnitTests/Calculus/SquareRootLogarithmAnsatzTest.cs b/Sources/Tests/UnitTests/Calculus/SquareRootLogarithmAnsatzTest.cs
index d71e4cef3..3046425bb 100644
--- a/Sources/Tests/UnitTests/Calculus/SquareRootLogarithmAnsatzTest.cs
+++ b/Sources/Tests/UnitTests/Calculus/SquareRootLogarithmAnsatzTest.cs
@@ -65,15 +65,12 @@ private static void DifferentiatesBack(string integrand, double[] points)
private static readonly double[] AboveMinusOne = { -0.7, -0.3, 0.2, 0.5, 0.8, 1.6, 2.4, 3.5 };
///
- /// Welz's, a logarithm at the pole 2 where 1 + x^3 is 9:
- /// (2/3) ln((1 + x)^2/3 - sqrt(1 + x^3)) - ln(x - 2) - ln(1 + x)/3; the same with
- /// a rational part, (2/3) sqrt(1 + x^3), brought over the denominator, and as a
- /// sum.
+ /// Welz's with a rational part, (2/3) sqrt(1 + x^3), brought over the denominator:
+ /// a logarithm at the pole 2 where 1 + x^3 is 9,
+ /// (2/3) ln((1 + x)^2/3 - sqrt(1 + x^3)) - ln(x - 2) - ln(1 + x)/3.
///
[Theory]
- [InlineData("(1+x)/((x-2)*sqrt(1+x^3))")]
[InlineData("(x^3-2*x^2+x+1)/((x-2)*sqrt(1+x^3))")]
- [InlineData("(1+x)/((x-2)*sqrt(1+x^3)) + x^2/sqrt(1+x^3)")]
public void ALogarithmAtAPole(string integrand)
{
DifferentiatesBack(integrand, AboveMinusOne);
@@ -82,6 +79,22 @@ public void ALogarithmAtAPole(string integrand)
Assert.Contains("ln(x - 2)", integral);
}
+ ///
+ /// Welz's own, a linear over a linear, and as a sum: one of the pseudo-elliptic quotients
+ /// a closed rule answers before the ansatz is asked, as
+ /// -(2/3) artanh((1 + x)^2/(3 sqrt(1 + x^3))), one logarithm where the ansatz
+ /// writes three.
+ ///
+ [Theory]
+ [InlineData("(1+x)/((x-2)*sqrt(1+x^3))")]
+ [InlineData("(1+x)/((x-2)*sqrt(1+x^3)) + x^2/sqrt(1+x^3)")]
+ public void WelzsIsOneLogarithm(string integrand)
+ {
+ DifferentiatesBack(integrand, AboveMinusOne);
+ var integral = integrand.ToEntity().Integrate("x").Stringize();
+ Assert.Equal(1, integral.Split("ln(").Length - 1);
+ }
+
///
/// Bronstein's, matched at infinity: the answer is
/// -ln(A - B sqrt(P))/8 with A = x^8 + 20x^6 - 128x^5 + 54x^4 - 1408x^3 + 3124x^2 + 10001