Skip to content

Commit a34dbc3

Browse files
A quadratic is split over a root it shares with a linear beside it (#1693)
* A quadratic is split over a root it shares with a linear beside it Writing each linear once read a quadratic's roots only where they were a monomial and its negative. Rubi's 1.2.1.2 and 1.2.1.4 have a d e + (c d^2 + a e^2) x + c d e x^2, which is (d + e x)(a e + c d x), beside a power of d + e x: under a power that is not whole, nothing splits it, and (d + e x)^(7/2)/(a d e + ...)^(3/2) was declined. A quadratic beside a linear under a root now takes the linear's root where it vanishes there, and its other root by the sum of the two. The two roots of the shared linear are then one whole power of it, and where that leaves two linears or fewer the rule answers: (d + e x)^(7/2)/(a d e + ...)^(3/2) is K (d + e x)^2/(a e + c d x)^(3/2). Beside a whole power of the linear, (d + e x)^3 sqrt(a d e + ...), the split would leave two roots where there was one, and the rules for a quadratic under a root answer it as written; beside a third linear, x sqrt(a d e + ...)/(d + e x), it would leave a product of three. In both the quadratic is read whole. Part of #718. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura * The breaking-changes entry for a quadratic written over a root it shares Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 61de03d commit a34dbc3

3 files changed

Lines changed: 81 additions & 2 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,25 @@ real is an arm of a piecewise, saying where it holds. Rubi's 7.3.6 and 7.4.2
10551055
| `"x*sqrt(c - a*c*x)/e^(3*atanh(a*x))".Integrate("x")` | left unevaluated | the antiderivative on both sides of `a x = 1`, where `master` gave one `provided c - a c x >= 0` |
10561056
| `"sqrt(x)/(sqrt(1/x + 1)*sqrt(1 - x^2))".Integrate("x")` | left unevaluated | the antiderivative on both sides of `x = 0`, where `master` gave one `provided x >= 0` |
10571057

1058+
### A quadratic that shares a root with a linear beside it is written over it
1059+
1060+
**Answers where there were none.** In Rubi's 1.2.1.2 and 1.2.1.4 a quadratic under a root stands
1061+
beside a power of a linear that divides it: `a d h + (c d^2 + a h^2) x + c d h x^2` is
1062+
`(d + h x)(a h + c d x)`. Nothing split a quadratic with symbols in it over a root it shares, so it
1063+
was read as irreducible and the integral was declined or ran out of time. A quadratic beside a
1064+
linear under a root now takes the linear's root where it vanishes there, and its other root by
1065+
the sum of the two. Each linear is then written once, as in the entry above
1066+
([#718](https://github.com/asc-community/AngouriMath/issues/718)), and the two roots of the shared
1067+
linear are one whole power of it. That is done only where it leaves two linears or fewer. Beside a
1068+
whole power of the linear, as in `(d + h x)^3 sqrt(a d h + ...)`, or beside a third linear, as in
1069+
`x sqrt(a d h + ...)/(d + h x)`, the quadratic is read whole, as before.
1070+
1071+
| Input | Was (2.5.0) | Now |
1072+
|---|---|---|
1073+
| `"(d + h*x)^(7/2)/(a*d*h + (c*d^2 + a*h^2)*x + c*d*h*x^2)^(3/2)".Integrate("x")` | left unevaluated | `K` times a sum of powers of `sqrt(a h + c d x)`, `provided a h + c d x >= 0` |
1074+
| `"(d + h*x)^(3/2)*(a*d*h + (c*d^2 + a*h^2)*x + c*d*h*x^2)^(1/2)".Integrate("x")` | left unevaluated | `K` times a polynomial in `sqrt(a h + c d x)`, `provided a h + c d x >= 0` |
1075+
| `"sqrt(d + h*x)/sqrt(a*d*h + (c*d^2 + a*h^2)*x + c*d*h*x^2)".Integrate("x")` | left unevaluated | `K` times `2 sqrt(a h + c d x)/(c d)`, `provided a h + c d x >= 0` |
1076+
10581077
### The inverse hyperbolic tangent's answer is given on its domain, and says so
10591078

10601079
`1/((1 - a^2 x^2)^(5/2) artanh(a x))` was left unevaluated, although the substitution `a x = tanh(u)`

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

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19018,15 +19018,41 @@ private static bool TryWriteAPairOfLinearsOverARadicand(Entity expr, Entity.Vari
1901819018
// is under such a power, and whether it is a quotient with x below the bar.
1901919019
var roots = new List<(Entity Root, Number.Rational Exponent, HashSet<int> Bases, bool UnderARoot)>();
1902019020
var bases = new List<(HashSet<int> Roots, bool UnderARoot, bool AQuotient)>();
19021+
// The roots of the linears written under a power that is not whole, which a quadratic
19022+
// beside them may share: `a d e + (c d^2 + a e^2) x + c d e x^2` is
19023+
// `(d + e x)(a e + c d x)`. Beside a whole power of the linear, `(d + e x)^3 sqrt(a d e
19024+
// + ...)`, the quadratic is under a root beside a polynomial, which the rules for one
19025+
// answer as it is written.
19026+
var writtenRoots = new List<Entity>();
19027+
foreach (var node in expr.Nodes)
19028+
if (node is Powf((Sumf or Minusf) and var linear, Number.Rational power) && power is not Number.Integer
19029+
&& linear.ContainsNode(x) && TreeAnalyzer.TryGetPolyLinear(linear, x, out var writtenSlope, out var writtenIntercept)
19030+
&& !writtenSlope.ContainsNode(x) && !writtenIntercept.ContainsNode(x) && writtenSlope.Evaled is not Number.Complex { IsZero: true })
19031+
{
19032+
var writtenRoot = Reduced(-writtenIntercept / writtenSlope);
19033+
if (!writtenRoots.Contains(writtenRoot))
19034+
writtenRoots.Add(writtenRoot);
19035+
}
19036+
// Set where a quadratic under a power that is not whole came apart only through a root
19037+
// it shares, which no other rule reads it as.
19038+
var splitThroughAShare = false;
1902119039
if (!Read(expr, Number.Integer.One))
1902219040
return null;
1902319041
// With every power whole the integrand is a rational function, and a root of a quotient
1902419042
// shared with another base is the same help: `e^(2 acoth(a x))/(c - c/(a^2 x^2))^2` is
1902519043
// `K x^4/((a x + 1)(a x - 1)^3)`, which the partial fractions answer at once, where
1902619044
// as written it ran out of time; and `K` is a constant there, with no arms to it.
19045+
// And a quadratic that came apart through a root it shares is help on its own where it
19046+
// leaves two linears or fewer, a product the rules for two linears answer: the linear
19047+
// it shares stands under a root too, and the two roots of it are one power that is
19048+
// whole. `(d + e x)^(7/2)/(a d e + (c d^2 + a e^2) x + c d e x^2)^(3/2)` is
19049+
// `K (d + e x)^2/(a e + c d x)^(3/2)`, where as written it was declined. Beside a
19050+
// third, as in `(a d e + ...)^(3/2)/(x^5 (d + e x))`, it is a product of three, which
19051+
// those rules do not answer, and the quadratic is left to the rules that read it whole.
1902719052
var wholePowersOnly = !bases.Any(written => written.UnderARoot);
19028-
if (!roots.Any(root => root.Bases.Count(which => bases[which].UnderARoot) >= 2
19029-
|| root.Bases.Any(which => (bases[which].UnderARoot || wholePowersOnly) && bases[which].AQuotient) && root.Bases.Count >= 2)
19053+
if (!(splitThroughAShare && roots.Count(root => root.Exponent != Number.Integer.Zero) <= 2
19054+
|| roots.Any(root => root.Bases.Count(which => bases[which].UnderARoot) >= 2
19055+
|| root.Bases.Any(which => (bases[which].UnderARoot || wholePowersOnly) && bases[which].AQuotient) && root.Bases.Count >= 2))
1903019056
|| roots.Count(root => root.Exponent is not Number.Integer) > 2)
1903119057
return null;
1903219058
// Each linear with the root's denominator for its leading coefficient: `a x + 1` for
@@ -19220,6 +19246,19 @@ bool WithItsRoots(Entity polynomial, Number.Rational exponent, int @base, bool u
1922019246
Add(Reduced(-root), exponent);
1922119247
return true;
1922219248
}
19249+
if (degree.Equals(EInteger.FromInt32(2)))
19250+
{
19251+
var (c2, c1, c0) = (CoefficientOf(highest), CoefficientOf(lowest.Add(EInteger.One)), CoefficientOf(lowest));
19252+
// A root of a linear written beside it, and the other root by their sum.
19253+
foreach (var shared in writtenRoots)
19254+
if (Reduced(c2 * shared * shared + c1 * shared + c0) == Number.Integer.Zero)
19255+
{
19256+
Add(shared, exponent);
19257+
Add(Reduced(-c1 / c2 - shared), exponent);
19258+
splitThroughAShare |= underARoot;
19259+
return true;
19260+
}
19261+
}
1922319262
return false;
1922419263

1922519264
void Add(Entity root, Number.Rational times)

‎Sources/Tests/UnitTests/Calculus/EachLinearWrittenOnceIntegralTest.cs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,28 @@ public sealed class EachLinearWrittenOnceIntegralTest
4848
[InlineData("x*sqrt(c-c/(a*x))/e^(3*atanh(a*x))", "a=1.37,c=-2.11")]
4949
[InlineData("e^(2*acoth(a*x))/(c-c/(a^2*x^2))^2", "a=1.37,c=2.11")]
5050
[InlineData("1/(e^(2*atanh(a*x))*(c-c/(a^2*x^2))^4)", "a=1.37,c=-2.11")]
51+
// A quadratic that shares a root with a linear beside it, Rubi's 1.2.1.2 and 1.2.1.4:
52+
// `a d e + (c d^2 + a e^2) x + c d e x^2` is `(d + e x)(a e + c d x)`, and comes apart
53+
// only through the root it shares, where the linear stands under a root as well.
54+
[InlineData("(d+h*x)^(7/2)/(a*d*h+(c*d^2+a*h^2)*x+c*d*h*x^2)^(3/2)", "a=1.37,c=2.11,d=0.83,h=1.9")]
55+
[InlineData("(d+h*x)^(3/2)*(a*d*h+(c*d^2+a*h^2)*x+c*d*h*x^2)^(1/2)", "a=1.37,c=2.11,d=0.83,h=1.9")]
56+
[InlineData("sqrt(d+h*x)/sqrt(a*d*h+(c*d^2+a*h^2)*x+c*d*h*x^2)", "a=1.37,c=2.11,d=0.83,h=1.9")]
5157
public void IsAnsweredWithEachLinearOnce(string integrand, string pins)
58+
=> DifferentiatesBack(integrand, pins);
59+
60+
/// <summary>
61+
/// Beside a third linear, a quadratic is not taken apart through the root it shares. That
62+
/// would leave a product of three linears, which the rules for two do not answer, and
63+
/// written so <c>x sqrt(a d h + ...)/(d + h x)</c> grows past what fits in memory. Read
64+
/// whole, it is answered.
65+
/// </summary>
66+
[Theory]
67+
[InlineData("x*sqrt(a*d*h+(c*d^2+a*h^2)*x+c*d*h*x^2)/(d+h*x)", "a=1.37,c=2.11,d=0.83,h=1.9")]
68+
[InlineData("sqrt(a*d*h+(c*d^2+a*h^2)*x+c*d*h*x^2)/(x*(d+h*x))", "a=1.37,c=2.11,d=0.83,h=1.9")]
69+
public void BesideAThirdLinearTheQuadraticIsReadWhole(string integrand, string pins)
70+
=> DifferentiatesBack(integrand, pins);
71+
72+
private static void DifferentiatesBack(string integrand, string pins)
5273
{
5374
var integral = integrand.ToEntity().Integrate("x").Substitute("C", 0);
5475
Assert.DoesNotContain("integral(", integral.Stringize());

0 commit comments

Comments
 (0)