Skip to content

Commit e802567

Browse files
A logarithm named as a linear is asked about where its name is zero (#1667)
`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. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent bc6c190 commit e802567

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13523,8 +13523,23 @@ node is Powf(Powf(var @base, var inner), var outer)
1352313523
var named = expr.Substitute(linear, slope * x + constant);
1352413524
if (named == expr)
1352513525
return null;
13526-
var answer = Integration.ComputeAsAQuestionOfItsOwn(named, x, integrateByParts);
13527-
return answer?.Substitute(constant, linear - slope * x);
13526+
if (Integration.ComputeAsAQuestionOfItsOwn(named, x, integrateByParts) is not { } answer)
13527+
return null;
13528+
var intercept = linear - slope * x;
13529+
var generic = answer.Substitute(constant, intercept);
13530+
// The answer is the generic case's, and where `c` is zero it can have no value:
13531+
// `1/(x ln(e^x))` is `1/(x (x + c))`, whose answer divides by `c`. That is the case
13532+
// wherever `ln(e^v)` is `v` -- on the strip `|Im v| < pi`, so on the whole real line
13533+
// for a real `v` -- and for `ln(e^x) - x` it is everywhere the integrand is real,
13534+
// where `ln(e^(2(a + b x))) - 2 b x` is `2a`. So where the answer has no value at
13535+
// `c = 0` and `c` is zero at real points, `c = 0` is asked as well, and its answer is
13536+
// the arm for it. https://github.com/asc-community/AngouriMath/issues/1666
13537+
if (!answer.Substitute(constant, Number.Integer.Zero).InnerSimplified.Nodes.Any(node => node is Number.Complex { IsNaN: true })
13538+
|| Functions.PartialFractions.InLowestTermsOverTheSymbols(intercept) != Number.Integer.Zero)
13539+
return generic;
13540+
if (Integration.ComputeAsAQuestionOfItsOwn(named.Substitute(constant, Number.Integer.Zero), x, integrateByParts) is not { } whereZero)
13541+
return null;
13542+
return MathS.Piecewise(new[] { new Providedf(whereZero, intercept.EqualTo(Number.Integer.Zero)) }, generic);
1352813543
}
1352913544

1353013545
/// <summary>

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,27 @@ public void AnInverseHyperbolicOfAHyperbolicIsLinearInTheVariable(string integra
7373
[InlineData("1/(x*ln(e^(2*(a+b*x))))")]
7474
[InlineData("x/ln(e^(a+b*x))")]
7575
public void ALogarithmOfACancellingQuotientAndALogarithmLinearInTheVariable(string integrand) => DifferentiatesBack(integrand);
76+
77+
/// <summary>
78+
/// A name that is zero on the real line: <c>ln(e^x) - x</c> is zero for every real
79+
/// <c>x</c>, and the answer for <c>1/(x (x + c))</c> divides by <c>c</c>, so it had no
80+
/// value at any real point. The arm for <c>c = 0</c> is asked as well. Rubi's 3.5,
81+
/// #192 and #226. https://github.com/asc-community/AngouriMath/issues/1666
82+
/// </summary>
83+
[Theory]
84+
[InlineData("1/(x*ln(e^x))")]
85+
[InlineData("cot(x)/ln(e^sin(x))")]
86+
[InlineData("1/(x*ln(e^(2*x)))")]
87+
public void ANameThatIsZeroOnTheRealLineIsAskedAboutAsZero(string integrand) => DifferentiatesBack(integrand);
88+
89+
/// <summary>
90+
/// ...and only there: <c>ln(e^(2(a + b x))) - 2 b x</c> is <c>2a</c> on the real line, and
91+
/// the answer for <c>atanh(tanh(x))^2</c> has a value at <c>c = 0</c>.
92+
/// </summary>
93+
[Theory]
94+
[InlineData("1/(x*atanh(tanh(a+b*x)))")]
95+
[InlineData("atanh(tanh(x))^2")]
96+
public void ANameThatIsNotZeroOrIsHarmlessGetsNoArm(string integrand)
97+
=> Assert.DoesNotContain("piecewise", integrand.ToEntity().Integrate("x").Stringize());
7698
}
7799
}

0 commit comments

Comments
 (0)