Skip to content

Commit 084c471

Browse files
One linear twice is not two linear powers (#1794)
(a c + b c x)^(-3 - 2 p) (f + g x) (a^2 + 2 a b x + b^2 x^2)^p was answered with (1/b a b c - a c)^(-2) in it, zero to a negative power, so the answer had no value anywhere. The square is written as a power of its root, (x + a/b)^(2 p), beside a c + b c x, which is b c (x + a/b): one linear twice. The rule for two linear powers whose exponents sum to a whole number divides by the two linears' cross term and declines where it is zero, but tested it as a number, which with symbols in it it is not. It is tested as a value now (PartialFractions.IsZeroAsAValue), and the rules after it answer the integral. Fixes #1793. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 2aae852 commit 084c471

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ the division's; with it on, the rounding is the setting's own and stays
161161
| `"(-60.5)!"` at 30 digits, downcasting off | `5.86118478907722232671451280188E-81` | `2.93059239453861116335725639905E-81` |
162162
| `"abs(75 + 316.22776601683796i)"`, downcasting off | `325` | `325.000000000000026076735749…` |
163163

164+
### One linear twice is not two linear powers
165+
166+
**Answers that had no value.** `(a c + b c x)^(-3 - 2 p) (f + g x) (a^2 + 2 a b x + b^2 x^2)^p` was answered
167+
on the unreleased master with `(1/b a b c - a c)^(-2)` in it, which is zero to a negative power: the
168+
answer had no value anywhere. The square is written as a power of its root, `(x + a/b)^(2 p)`, beside
169+
`a c + b c x`, which is `b c (x + a/b)`, and the rule for two linear powers whose exponents sum to a whole
170+
number divides by the two linears' cross term, declining where it is zero -- tested as a number, which
171+
with symbols in it it is not. It is tested as a value now, and the integral is answered by the rules
172+
after it
173+
([#1793](https://github.com/asc-community/AngouriMath/issues/1793)).
174+
175+
| Input | Was (2.5.0) | Now |
176+
|---|---|---|
177+
| `"(a*c + b*c*x)^(-3-2*p)*(f + g*x)*(a^2 + 2*a*b*x + b^2*x^2)^p".ToEntity().Integrate("x")` | `integral(...)`; an answer with no value on the unreleased master | the antiderivative |
178+
164179
### A power of a constant below `1e-50` is no longer simplified to zero
165180

166181
**Answers that were wrong.** Evaluation rounds a value within `1e-50` of an integer onto it, and

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13171,8 +13171,11 @@ static Entity Simplified(Entity exponent)
1317113171
var k = -sum.ToInt32Checked();
1317213172
if (!TreeAnalyzer.TryGetPolyLinear(first, x, out var b1, out var a1) || !TreeAnalyzer.TryGetPolyLinear(second, x, out var b2, out var a2))
1317313173
return null;
13174+
// Zero as a value, not only as a number: `x + a/b` beside `a c + b c x` is one linear
13175+
// twice, their cross term `a/b (b c) - a c` has symbols in it and is zero, and the
13176+
// formula below divided by it -- an answer with no value anywhere.
1317413177
var d = (a1 * b2 - a2 * b1).InnerSimplified;
13175-
if (d.Evaled is Number.Complex { IsZero: true })
13178+
if (Functions.PartialFractions.IsZeroAsAValue(d))
1317613179
return null;
1317713180
Entity product = Number.Integer.One;
1317813181
foreach (var (factor, _) in polynomial)

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,32 @@ Entity Pinned(Entity e) => e.Substitute("a", 1.3).Substitute("b", 0.9).Substitut
4646
$"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}");
4747
}
4848
}
49+
50+
/// <summary>
51+
/// One linear twice is not two: `x + a/b` beside `a c + b c x` has a cross term
52+
/// `a/b (b c) - a c` that is zero with symbols in it, and the formula divided by it, for an
53+
/// answer with no value anywhere. Rubi's 1.2.1.3:2459.
54+
/// https://github.com/asc-community/AngouriMath/issues/1793
55+
/// </summary>
56+
[Theory]
57+
[InlineData("(a*c + b*c*x)^(-3 - 2*p)*(f + g*x)*(a^2 + 2*a*b*x + b^2*x^2)^p")]
58+
[InlineData("(x + a/b)^(2*p)*(a*c + b*c*x)^(-3 - 2*p)*(f + g*x)")]
59+
public void OneLinearTwiceHasAValue(string integrand)
60+
{
61+
var integral = integrand.ToEntity().Integrate("x");
62+
Assert.DoesNotContain("integral(", integral.Stringize());
63+
Entity Pinned(Entity e) => e.Substitute("a", 1.3).Substitute("b", 0.7).Substitute("c", 1.1)
64+
.Substitute("f", 0.3).Substitute("g", 1.7).Substitute("p", 0.29);
65+
var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
66+
var original = Pinned(integrand.ToEntity());
67+
foreach (var at in new[] { 0.3, 0.8, 1.5, 2.4 })
68+
{
69+
var got = derivative.Substitute("x", at).EvalNumerical();
70+
var want = original.Substitute("x", at).EvalNumerical();
71+
Assert.False(got.IsNaN, $"the antiderivative of {integrand} has no derivative at x = {at}: {integral}");
72+
Assert.True(Math.Abs((double)(got - want).RealPart) + Math.Abs((double)(got - want).ImaginaryPart) < 1e-9 * Math.Max(1.0, Math.Abs((double)want.RealPart)),
73+
$"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}");
74+
}
75+
}
4976
}
5077
}

0 commit comments

Comments
 (0)