Skip to content

Commit bc6c190

Browse files
An answer through the quotient of the logarithm's linears holds where it is given (#1663)
SolveByTheQuotientOfTheLogarithmsLinears splits the linears' powers as the generic case does, and checks the answer at sampled points before giving it. That check skips a point where the derivative has no value. Past the generic case's domain, the derivative is a fractional power of a negative number, which the interval and decimal evaluations decline, so the check compared only where the generic case holds. e^atanh(a x) sqrt(c - a c x), as e^(ln((1 + a x)/(1 - a x))/2), passed it, and was wrong by its sign past a x = 1, where the integrand is real. The route now also asks DiffersWhereReal, which counts a point where the integrand is real and the derivative has no value as a difference. With that it declines, and the linear radical substitution answers (2/(3 a c)) (c (1 + a x))^(3/2) provided c - a c x >= 0, which is right where it is given. Measured on the Rubi corpus against master 7219aea, every problem of each family, both arms side by side: family 7 is 3679 -> 3689 of 4289 solved and 23 -> 13 wrong, with families 3 and 0 unchanged. Of the 12 problems whose verdict moved, re-run alone, master answers 10 wrongly and this answers those 10 rightly. The suite passes, 14,304 tests, and so does the allocation gate. Closes #1655. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 422c711 commit bc6c190

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14297,7 +14297,20 @@ private static Entity WithLogarithmArgumentsOverOneBar(Entity expr, Entity.Varia
1429714297
if (Integration.ComputeAsAQuestionOfItsOwn(rewritten, t, integrateByParts) is not { } integrated)
1429814298
return null;
1429914299
var answer = integrated.Substitute(t, l1.Linear / l2.Linear);
14300-
if (answer.Nodes.Any(node => node == MathS.NaN) || !Functions.PartialFractions.HoldsAtSampledPoints(answer.Differentiate(x), expr, x))
14300+
if (answer.Nodes.Any(node => node == MathS.NaN))
14301+
return null;
14302+
// The generic case holds where the linears' powers split as written. Past that it can
14303+
// fail where the integrand is still real, a product of two imaginary factors. The
14304+
// sampled check skips a point where the derivative has no value, and there the
14305+
// derivative is a fractional power of a negative number, which the interval and decimal
14306+
// evaluations decline. So it compared only where the generic case holds:
14307+
// `e^artanh(a x) sqrt(c - a c x)`, as `e^(ln((1 + a x)/(1 - a x))/2)`, passed it and was
14308+
// wrong by its sign past `a x = 1`. A point where the integrand is real and the
14309+
// derivative is not is a difference too.
14310+
// https://github.com/asc-community/AngouriMath/issues/1655
14311+
var derivative = answer.Differentiate(x);
14312+
if (!Functions.PartialFractions.HoldsAtSampledPoints(derivative, expr, x)
14313+
|| Functions.PartialFractions.DiffersWhereReal(derivative, expr, x))
1430114314
return null;
1430214315
return answer;
1430314316

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,44 @@ public void TheEvenRootStepSaysWhereItHolds()
117117
Assert.True(derivative.Substitute("x", 0.59).Evaled.IsNaN, "the answer claims a derivative outside its condition");
118118
}
119119

120+
/// <summary>
121+
/// <c>e^artanh(a x) sqrt(c - a c x)</c> is real past <c>a x = 1</c> as well, where both
122+
/// factors are imaginary, and there it is the negative of what it is inside. Through the
123+
/// quotient of the logarithm's linears the answer was the one for inside, given
124+
/// everywhere, so past <c>a x = 1</c> it was wrong by its sign: the check at sampled
125+
/// points skipped the points where the derivative has no value, and those were the
126+
/// points where it was wrong. Now the answer holds where it is given and says where that is.
127+
/// https://github.com/asc-community/AngouriMath/issues/1655
128+
/// </summary>
129+
[Fact]
130+
public void AnExponentialOfAnInverseTangentBesideTheRootSaysWhereItHolds()
131+
{
132+
var integrand = "e^atanh(a*x)*sqrt(c - a*c*x)".ToEntity();
133+
var integral = integrand.Integrate("x");
134+
Assert.DoesNotContain("integral(", integral.Stringize());
135+
var pinned = integral.Substitute("C", 0).Substitute("a", 1.37).Substitute("c", 3.71);
136+
var derivative = pinned.Differentiate("x");
137+
var original = integrand.Substitute("a", 1.37).Substitute("c", 3.71);
138+
// Inside, a x < 1: the derivative is the integrand.
139+
foreach (var at in new[] { 0.29, -0.61 })
140+
{
141+
var got = derivative.Substitute("x", at).EvalNumerical();
142+
var want = original.Substitute("x", at).EvalNumerical();
143+
Assert.True(Math.Abs((double)(got - want).RealPart) < 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart)),
144+
$"d/dx of the antiderivative is {got} at x = {at}, where the integrand is {want}");
145+
}
146+
// Past it the integrand is real, and the answer is either right or claims nothing.
147+
foreach (var at in new[] { 1.43, 3.17 })
148+
{
149+
var want = original.Substitute("x", at).EvalNumerical();
150+
Assert.True(Math.Abs((double)want.ImaginaryPart) < 1e-12, $"the integrand at x = {at} is {want}, not real");
151+
var got = derivative.Substitute("x", at).Evaled;
152+
Assert.True(got.IsNaN || got is Entity.Number.Complex number
153+
&& Math.Abs((double)(number - want).RealPart) < 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart)),
154+
$"d/dx of the antiderivative is {got} at x = {at}, where the integrand is {want}");
155+
}
156+
}
157+
120158
/// <summary>
121159
/// The substitution search's even root reads the sign of a real <c>u</c> as well, and
122160
/// says where it does: <c>(1 + sec(x))^(5/2) sqrt(cos(x))</c> under <c>t = cos(x)</c> and

0 commit comments

Comments
 (0)