From 7be27a50a6601aa1e5692e7597fe718b83a19a4d Mon Sep 17 00:00:00 2001 From: Rafael Vuijk Date: Fri, 2 Oct 2026 02:01:46 +0000 Subject: [PATCH] A logarithm named as a linear is asked about where its name is zero `SolveByNamingALogarithmLinearInTheVariable` writes `ln(e^x)` as `x + c`, with `c` standing for `ln(e^x) - x`, and answers the generic case: `1/(x ln(e^x))` is `1/(x (x + c))`, whose answer divides by `c`. But `ln(e^v)` is `v` on the strip `|Im v| < pi`, so `c` is zero at every real `x` and the answer had no value anywhere on the real line. Where the answer has no value at `c = 0` and `c` is zero at real points, `c = 0` is asked as well, and its answer is the arm for `ln(e^x) - x = 0`: `1/(x ln(e^x))` is `-1/x` there. `ln(e^(2(a + b x))) - 2 b x`, which is `2a` on the real line, keeps the generic answer alone. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --- .../Integration/IndefiniteIntegralSolver.cs | 19 ++++++++++++++-- ...erseHyperbolicOfAHyperbolicIntegralTest.cs | 22 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs index b1ceaa86b..c72b88bdc 100644 --- a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs +++ b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs @@ -13523,8 +13523,23 @@ node is Powf(Powf(var @base, var inner), var outer) var named = expr.Substitute(linear, slope * x + constant); if (named == expr) return null; - var answer = Integration.ComputeAsAQuestionOfItsOwn(named, x, integrateByParts); - return answer?.Substitute(constant, linear - slope * x); + if (Integration.ComputeAsAQuestionOfItsOwn(named, x, integrateByParts) is not { } answer) + return null; + var intercept = linear - slope * x; + var generic = answer.Substitute(constant, intercept); + // The answer is the generic case's, and where `c` is zero it can have no value: + // `1/(x ln(e^x))` is `1/(x (x + c))`, whose answer divides by `c`. That is the case + // wherever `ln(e^v)` is `v` -- on the strip `|Im v| < pi`, so on the whole real line + // for a real `v` -- and for `ln(e^x) - x` it is everywhere the integrand is real, + // where `ln(e^(2(a + b x))) - 2 b x` is `2a`. So where the answer has no value at + // `c = 0` and `c` is zero at real points, `c = 0` is asked as well, and its answer is + // the arm for it. https://github.com/asc-community/AngouriMath/issues/1666 + if (!answer.Substitute(constant, Number.Integer.Zero).InnerSimplified.Nodes.Any(node => node is Number.Complex { IsNaN: true }) + || Functions.PartialFractions.InLowestTermsOverTheSymbols(intercept) != Number.Integer.Zero) + return generic; + if (Integration.ComputeAsAQuestionOfItsOwn(named.Substitute(constant, Number.Integer.Zero), x, integrateByParts) is not { } whereZero) + return null; + return MathS.Piecewise(new[] { new Providedf(whereZero, intercept.EqualTo(Number.Integer.Zero)) }, generic); } /// diff --git a/Sources/Tests/UnitTests/Calculus/InverseHyperbolicOfAHyperbolicIntegralTest.cs b/Sources/Tests/UnitTests/Calculus/InverseHyperbolicOfAHyperbolicIntegralTest.cs index e501737bb..c0d69f620 100644 --- a/Sources/Tests/UnitTests/Calculus/InverseHyperbolicOfAHyperbolicIntegralTest.cs +++ b/Sources/Tests/UnitTests/Calculus/InverseHyperbolicOfAHyperbolicIntegralTest.cs @@ -73,5 +73,27 @@ public void AnInverseHyperbolicOfAHyperbolicIsLinearInTheVariable(string integra [InlineData("1/(x*ln(e^(2*(a+b*x))))")] [InlineData("x/ln(e^(a+b*x))")] public void ALogarithmOfACancellingQuotientAndALogarithmLinearInTheVariable(string integrand) => DifferentiatesBack(integrand); + + /// + /// A name that is zero on the real line: ln(e^x) - x is zero for every real + /// x, and the answer for 1/(x (x + c)) divides by c, so it had no + /// value at any real point. The arm for c = 0 is asked as well. Rubi's 3.5, + /// #192 and #226. https://github.com/asc-community/AngouriMath/issues/1666 + /// + [Theory] + [InlineData("1/(x*ln(e^x))")] + [InlineData("cot(x)/ln(e^sin(x))")] + [InlineData("1/(x*ln(e^(2*x)))")] + public void ANameThatIsZeroOnTheRealLineIsAskedAboutAsZero(string integrand) => DifferentiatesBack(integrand); + + /// + /// ...and only there: ln(e^(2(a + b x))) - 2 b x is 2a on the real line, and + /// the answer for atanh(tanh(x))^2 has a value at c = 0. + /// + [Theory] + [InlineData("1/(x*atanh(tanh(a+b*x)))")] + [InlineData("atanh(tanh(x))^2")] + public void ANameThatIsNotZeroOrIsHarmlessGetsNoArm(string integrand) + => Assert.DoesNotContain("piecewise", integrand.ToEntity().Integrate("x").Stringize()); } }