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