Skip to content

Commit 113ae13

Browse files
x over a cubic binomial beside the root of another is integrated where that is elementary (#1790)
x/((a + b x^3) sqrt(c + d x^3)) is elementary at 4 b c = a d and at 8 b c + a d = 0, Rubi's 1.1.3.4, and Welz's x/((4 - x^3) sqrt(1 - x^3)) and the rest at those ratios were declined. Both are written in closed form, by the sign of c, each condition decided as a value and the answer differentiated back. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 221d3c5 commit 113ae13

4 files changed

Lines changed: 179 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,21 @@ or of its square over the root. Rubi's 1.3.3 names those coefficients, and its r
747747
| `"(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` |
748748
| `"(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 |
749749

750+
### `x` over a cubic binomial beside the root of another is integrated where that is elementary
751+
752+
**Answers where there were none.** `x/((a + b x^3) sqrt(c + d x^3))` is elementary at `4 b c = a d`
753+
and at `8 b c + a d = 0`, Rubi's 1.1.3.4, as arctangents and inverse hyperbolic tangents of
754+
`sqrt(c + d x^3)` and of `(1 + q x)/sqrt(c + d x^3)` for `q = (d/c)^(1/3)`, and Welz's
755+
`x/((4 - x^3) sqrt(1 - x^3))` and the rest at those ratios were declined. They are answered in
756+
closed form now, by the sign of `c`
757+
([#718](https://github.com/asc-community/AngouriMath/issues/718)).
758+
759+
| Input | Was (2.5.0) | Now |
760+
|---|---|---|
761+
| `"x/((4 - x^3)*sqrt(1 - x^3))".ToEntity().Integrate("x")` | `integral(...)` | two arctangents and two inverse hyperbolic tangents, of `sqrt(1 - x^3)` and of `(1 - 2^(1/3) x)/sqrt(1 - x^3)` and its kind |
762+
| `"x/((4*c + d*x^3)*sqrt(c + d*x^3))".ToEntity().Integrate("x")` | `integral(...)` | the same in `sqrt(c + d x^3)` and `q = (d/c)^(1/3)`, by the sign of `c` |
763+
| `"x/((8 - d*x^3)*sqrt(1 + d*x^3))".ToEntity().Integrate("x")` | `integral(...)` | `(artanh((1 + d^(1/3) x)^2/(3 sqrt(1 + d x^3))) - artanh(sqrt(1 + d x^3)/3))/(18 d^(2/3)) - atan(sqrt(3) (1 + d^(1/3) x)/sqrt(1 + d x^3))/(6 sqrt(3) d^(2/3))`, written with logarithms |
764+
750765
### `x^2` over a three-quarter power of a quadratic binomial beside another is integrated where that is elementary
751766

752767
**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

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

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4920,6 +4920,105 @@ Entity OverOnePlus(Entity k)
49204920
return holds ? answer : null;
49214921
}
49224922

4923+
/// <summary>
4924+
/// <c>x/((a + b x^3) sqrt(c + d x^3))</c> at the two ratios where its integral is elementary,
4925+
/// Rubi's 1.1.3.4: <c>4 b c = a d</c> and <c>8 b c + a d = 0</c>, in closed form.
4926+
/// </summary>
4927+
/// <remarks>
4928+
/// <para>
4929+
/// With <c>q = (d/c)^(1/3)</c>, the real root, and <c>y = sqrt(c + d x^3)</c>, at
4930+
/// <c>4 b c = a d</c>, for <c>r = sqrt(c)</c> where <c>c</c> is positive and
4931+
/// <c>r = sqrt(-c)</c> where it is negative:
4932+
/// <code>
4933+
/// c &gt; 0: q/(3 2^(2/3) b r) (artanh(y/r)/3 + atan(y/(sqrt(3) r))/sqrt(3)
4934+
/// - atan(sqrt(3) r (1 + 2^(1/3) q x)/y)/sqrt(3) - artanh(r (1 - 2^(1/3) q x)/y))
4935+
/// c &lt; 0: -q/(3 2^(2/3) b r) (atan(y/r)/3 + artanh(y/(sqrt(3) r))/sqrt(3)
4936+
/// + artanh(sqrt(3) r (1 + 2^(1/3) q x)/y)/sqrt(3) + atan(r (1 - 2^(1/3) q x)/y))
4937+
/// </code>
4938+
/// and at <c>8 b c + a d = 0</c>, where the integrand is <c>-(d/b) x/((8 c - d x^3) y)</c>, that
4939+
/// times
4940+
/// <code>
4941+
/// c &gt; 0: (artanh(r (1 + q x)^2/(3 y))/18 - artanh(y/(3 r))/18 - atan(sqrt(3) r (1 + q x)/y)/(6 sqrt(3)))/(r^3 q^2)
4942+
/// c &lt; 0: -(atan(r (1 + q x)^2/(3 y))/18 + atan(y/(3 r))/18 - artanh(sqrt(3) r (1 + q x)/y)/(6 sqrt(3)))/(r^3 q^2)
4943+
/// </code>
4944+
/// Rubi splits the second into three integrals, a substitution's in <c>x^3</c>, a linear
4945+
/// over a linear and a quadratic over a quadratic, each elementary, and their sum is the
4946+
/// form above; asked as three, two come back piecewise in the symbols and their sum holds
4947+
/// every combination of the arms. Every condition is decided as a value, and the answer is
4948+
/// differentiated back at sampled points before it is returned.
4949+
/// Welz's <c>x/((4 - x^3) sqrt(1 - x^3))</c> and <c>x/((8 - d x^3) sqrt(1 + d x^3))</c> were
4950+
/// declined, with the rest of 1.1.3.4 at those ratios.
4951+
/// https://github.com/asc-community/AngouriMath/issues/718
4952+
/// </para>
4953+
/// </remarks>
4954+
internal static Entity? SolveXOverACubicBinomialBesideTheRootOfAnother(Entity expr, Entity.Variable x, bool integrateByParts)
4955+
{
4956+
var (numerator, denominator) = Functions.SingleQuotient.Of(expr);
4957+
if (!TreeAnalyzer.TryGetPolynomial(numerator, x, out var above) || above.Count != 1
4958+
|| !above.TryGetValue(EInteger.One, out var multiple) || multiple.ContainsNode(x))
4959+
return null;
4960+
Entity? radicand = null;
4961+
Entity below = Number.Integer.One;
4962+
foreach (var factor in Mulf.LinearChildren(denominator))
4963+
if (factor is Powf(var @base, Number.Rational half) && half.ERational.Equals(ERational.Create(1, 2)) && @base.ContainsNode(x))
4964+
{
4965+
if (radicand is not null)
4966+
return null;
4967+
radicand = @base;
4968+
}
4969+
else
4970+
below = below == Number.Integer.One ? factor : below * factor;
4971+
if (radicand is null || ACubicBinomial(radicand) is not var (c, d) || ACubicBinomial(below) is not var (a, b))
4972+
return null;
4973+
static bool Zero(Entity condition) => Functions.PartialFractions.IsZeroAsAValue(condition);
4974+
if (Zero(a) || Zero(b) || Zero(c) || Zero(d) || Zero(b * c - a * d))
4975+
return null;
4976+
var y = MathS.Sqrt(radicand);
4977+
var q = MathS.Pow(LowestOverTheSymbols(d / c), Number.Rational.Create(1, 3));
4978+
var cubeRootOfTwo = MathS.Pow(2, Number.Rational.Create(1, 3));
4979+
var sqrtOfThree = MathS.Sqrt(3);
4980+
Entity? answer = null;
4981+
if (Zero(4 * b * c - a * d))
4982+
{
4983+
var r = MathS.Sqrt(c);
4984+
var wherePositive = q / (3 * MathS.Sqr(cubeRootOfTwo) * b * r)
4985+
* (MathS.Hyperbolic.Artanh(y / r) / 3 + MathS.Arctan(y / (sqrtOfThree * r)) / sqrtOfThree
4986+
- MathS.Arctan(sqrtOfThree * r * (1 + cubeRootOfTwo * q * x) / y) / sqrtOfThree
4987+
- MathS.Hyperbolic.Artanh(r * (1 - cubeRootOfTwo * q * x) / y));
4988+
var s = MathS.Sqrt(LowestOverTheSymbols(-c));
4989+
var whereNegative = -q / (3 * MathS.Sqr(cubeRootOfTwo) * b * s)
4990+
* (MathS.Arctan(y / s) / 3 + MathS.Hyperbolic.Artanh(y / (sqrtOfThree * s)) / sqrtOfThree
4991+
+ MathS.Hyperbolic.Artanh(sqrtOfThree * s * (1 + cubeRootOfTwo * q * x) / y) / sqrtOfThree
4992+
+ MathS.Arctan(s * (1 - cubeRootOfTwo * q * x) / y));
4993+
answer = BySign(c, wherePositive, whereNegative);
4994+
}
4995+
else if (Zero(8 * b * c + a * d))
4996+
{
4997+
// The integrand is -(d/b) x/((8 c - d x^3) y).
4998+
var r = MathS.Sqrt(c);
4999+
var wherePositive = (MathS.Hyperbolic.Artanh(r * MathS.Sqr(1 + q * x) / (3 * y)) / 18 - MathS.Hyperbolic.Artanh(y / (3 * r)) / 18
5000+
- MathS.Arctan(sqrtOfThree * r * (1 + q * x) / y) / (6 * sqrtOfThree)) / (MathS.Pow(r, 3) * MathS.Sqr(q));
5001+
var s = MathS.Sqrt(LowestOverTheSymbols(-c));
5002+
var whereNegative = -(MathS.Arctan(s * MathS.Sqr(1 + q * x) / (3 * y)) / 18 + MathS.Arctan(y / (3 * s)) / 18
5003+
- MathS.Hyperbolic.Artanh(sqrtOfThree * s * (1 + q * x) / y) / (6 * sqrtOfThree)) / (MathS.Pow(s, 3) * MathS.Sqr(q));
5004+
answer = LowestOverTheSymbols(-d / b) * BySign(c, wherePositive, whereNegative);
5005+
}
5006+
if (answer is null)
5007+
return null;
5008+
answer = (multiple * answer).InnerSimplified;
5009+
bool holds;
5010+
using (MathS.Settings.DowncastingEnabled.Set(false))
5011+
holds = Functions.PartialFractions.HoldsAtSampledPoints(answer.Differentiate(x), expr, x);
5012+
return holds ? answer : null;
5013+
5014+
// `p + r x^3`, as `(p, r)`, each free of x.
5015+
(Entity, Entity)? ACubicBinomial(Entity binomial)
5016+
=> TreeAnalyzer.TryGetPolynomial(binomial, x, out var read) && read.Count == 2
5017+
&& read.TryGetValue(EInteger.Zero, out var constant) && read.TryGetValue(EInteger.FromInt32(3), out var cubic)
5018+
&& !constant.ContainsNode(x) && !cubic.ContainsNode(x)
5019+
? (constant, cubic) : null;
5020+
}
5021+
49235022
/// <summary>
49245023
/// A root of a quadratic binomial beside another, <c>1/((A + B x^2)^(1/3) (C + D x^2))</c>
49255024
/// with <c>B C + 3 A D = 0</c> or <c>B C - 9 A D = 0</c>, and

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,9 @@ private static Entity Normalized(Entity expr, Entity.Variable x) =>
807807
// `(1 + x + sqrt(3))/((1 + x - sqrt(3)) sqrt(1 + x^3))`. Before the reduction over the
808808
// linear, which writes it as `1` and `2 sqrt(3)` over the linear, neither elementary.
809809
if ((answer = IndefiniteIntegralSolver.SolveAPseudoEllipticQuotientOverTheRootOfACubicBinomial(expr, x)) is { }) return answer;
810+
// x over a cubic binomial beside the root of another, at the two ratios where that is
811+
// elementary: Welz's `x/((4 - x^3) sqrt(1 - x^3))`.
812+
if ((answer = IndefiniteIntegralSolver.SolveXOverACubicBinomialBesideTheRootOfAnother(expr, x, integrateByParts)) is { }) return answer;
810813
if ((answer = IndefiniteIntegralSolver.SolveByReducingThePolynomialOverALinearFactor(expr, x, integrateByParts)) is { }) return answer;
811814
if (expr is Entity.Sumf or Entity.Minusf
812815
&& (answer = IndefiniteIntegralSolver.SolveBySplittingSum(expr, x, integrateByParts)) is { })
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
/// <c>x/((a + b x^3) sqrt(c + d x^3))</c> at the two ratios where its integral is elementary,
16+
/// Rubi's 1.1.3.4: <c>4 b c = a d</c>, in closed form by the sign of <c>c</c>, and
17+
/// <c>8 b c + a d = 0</c>, as three integrals.
18+
/// <a href="https://github.com/asc-community/AngouriMath/issues/718">#718</a>
19+
/// </summary>
20+
/// <remarks>
21+
/// Checked by differentiating back with <c>c</c> pinned to either sign and <c>d = 0.7</c>, on
22+
/// both sides of 0 wherever the integrand is real.
23+
/// </remarks>
24+
[Trait("Area", "Calculus")]
25+
public sealed class XOverACubicBinomialBesideTheRootOfAnotherIntegralTest
26+
{
27+
private static readonly double[] Points = { -2.3, -1.4, -0.8, -0.3, 0.4, 0.9, 1.6, 2.4 };
28+
29+
[Theory]
30+
// 4 b c = a d.
31+
[InlineData("x/((4 - x^3)*sqrt(1 - x^3))", 1.3)]
32+
[InlineData("x/((4 - d*x^3)*sqrt(-1 + d*x^3))", 1.3)]
33+
[InlineData("x/((4*c + d*x^3)*sqrt(c + d*x^3))", 1.3)]
34+
[InlineData("x/((4*c + d*x^3)*sqrt(c + d*x^3))", -1.3)]
35+
// 8 b c + a d = 0.
36+
[InlineData("x/((8 - d*x^3)*sqrt(1 + d*x^3))", 1.3)]
37+
[InlineData("x/((8*c - d*x^3)*sqrt(c + d*x^3))", 1.3)]
38+
[InlineData("x/((8*c - d*x^3)*sqrt(c + d*x^3))", -1.3)]
39+
[InlineData("3*x/((8 + x^3)*sqrt(-1 + x^3))", 1.3)]
40+
public void IsIntegrated(string integrand, double c)
41+
{
42+
var integral = integrand.ToEntity().Integrate("x");
43+
Assert.DoesNotContain("integral(", integral.Stringize());
44+
Entity Pinned(Entity e) => e.Substitute("c", c).Substitute("d", 0.7);
45+
var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
46+
var original = Pinned(integrand.ToEntity());
47+
var compared = 0;
48+
foreach (var at in Points)
49+
{
50+
var want = original.Substitute("x", at).EvalNumerical();
51+
if (want.IsNaN || Math.Abs((double)want.ImaginaryPart) > 1e-12 * Math.Max(1, Math.Abs((double)want.RealPart)))
52+
continue;
53+
var got = derivative.Substitute("x", at).EvalNumerical();
54+
compared++;
55+
Assert.True(Math.Abs((double)(got - want).RealPart) + Math.Abs((double)(got - want).ImaginaryPart)
56+
< 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart)),
57+
$"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}");
58+
}
59+
Assert.True(compared >= 2, $"only {compared} points were real for {integrand}");
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)