From 765f983ed1f41a576548957363a9c149ffd57053 Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Fri, 2 Oct 2026 01:14:06 +0000 Subject: [PATCH] An answer through the quotient of the logarithm's linears holds where it is given 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 7219aeae, 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. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --- .../Integration/IndefiniteIntegralSolver.cs | 15 +++++++- .../LinearRadicalSubstitutionIntegralTest.cs | 38 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs index f9f7317fc..b1ceaa86b 100644 --- a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs +++ b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs @@ -14297,7 +14297,20 @@ private static Entity WithLogarithmArgumentsOverOneBar(Entity expr, Entity.Varia if (Integration.ComputeAsAQuestionOfItsOwn(rewritten, t, integrateByParts) is not { } integrated) return null; var answer = integrated.Substitute(t, l1.Linear / l2.Linear); - if (answer.Nodes.Any(node => node == MathS.NaN) || !Functions.PartialFractions.HoldsAtSampledPoints(answer.Differentiate(x), expr, x)) + if (answer.Nodes.Any(node => node == MathS.NaN)) + return null; + // The generic case holds where the linears' powers split as written. Past that it can + // fail where the integrand is still real, a product of two imaginary factors. The + // sampled check skips a point where the derivative has no value, and there the + // derivative is a fractional power of a negative number, which the interval and decimal + // evaluations decline. So it compared only where the generic case holds: + // `e^artanh(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`. A point where the integrand is real and the + // derivative is not is a difference too. + // https://github.com/asc-community/AngouriMath/issues/1655 + var derivative = answer.Differentiate(x); + if (!Functions.PartialFractions.HoldsAtSampledPoints(derivative, expr, x) + || Functions.PartialFractions.DiffersWhereReal(derivative, expr, x)) return null; return answer; diff --git a/Sources/Tests/UnitTests/Calculus/LinearRadicalSubstitutionIntegralTest.cs b/Sources/Tests/UnitTests/Calculus/LinearRadicalSubstitutionIntegralTest.cs index 6a14ceae5..a88f6d822 100644 --- a/Sources/Tests/UnitTests/Calculus/LinearRadicalSubstitutionIntegralTest.cs +++ b/Sources/Tests/UnitTests/Calculus/LinearRadicalSubstitutionIntegralTest.cs @@ -117,6 +117,44 @@ public void TheEvenRootStepSaysWhereItHolds() Assert.True(derivative.Substitute("x", 0.59).Evaled.IsNaN, "the answer claims a derivative outside its condition"); } + /// + /// e^artanh(a x) sqrt(c - a c x) is real past a x = 1 as well, where both + /// factors are imaginary, and there it is the negative of what it is inside. Through the + /// quotient of the logarithm's linears the answer was the one for inside, given + /// everywhere, so past a x = 1 it was wrong by its sign: the check at sampled + /// points skipped the points where the derivative has no value, and those were the + /// points where it was wrong. Now the answer holds where it is given and says where that is. + /// https://github.com/asc-community/AngouriMath/issues/1655 + /// + [Fact] + public void AnExponentialOfAnInverseTangentBesideTheRootSaysWhereItHolds() + { + var integrand = "e^atanh(a*x)*sqrt(c - a*c*x)".ToEntity(); + var integral = integrand.Integrate("x"); + Assert.DoesNotContain("integral(", integral.Stringize()); + var pinned = integral.Substitute("C", 0).Substitute("a", 1.37).Substitute("c", 3.71); + var derivative = pinned.Differentiate("x"); + var original = integrand.Substitute("a", 1.37).Substitute("c", 3.71); + // Inside, a x < 1: the derivative is the integrand. + foreach (var at in new[] { 0.29, -0.61 }) + { + var got = derivative.Substitute("x", at).EvalNumerical(); + var want = original.Substitute("x", at).EvalNumerical(); + Assert.True(Math.Abs((double)(got - want).RealPart) < 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart)), + $"d/dx of the antiderivative is {got} at x = {at}, where the integrand is {want}"); + } + // Past it the integrand is real, and the answer is either right or claims nothing. + foreach (var at in new[] { 1.43, 3.17 }) + { + var want = original.Substitute("x", at).EvalNumerical(); + Assert.True(Math.Abs((double)want.ImaginaryPart) < 1e-12, $"the integrand at x = {at} is {want}, not real"); + var got = derivative.Substitute("x", at).Evaled; + Assert.True(got.IsNaN || got is Entity.Number.Complex number + && Math.Abs((double)(number - want).RealPart) < 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart)), + $"d/dx of the antiderivative is {got} at x = {at}, where the integrand is {want}"); + } + } + /// /// The substitution search's even root reads the sign of a real u as well, and /// says where it does: (1 + sec(x))^(5/2) sqrt(cos(x)) under t = cos(x) and