Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,44 @@ public void TheEvenRootStepSaysWhereItHolds()
Assert.True(derivative.Substitute("x", 0.59).Evaled.IsNaN, "the answer claims a derivative outside its condition");
}

/// <summary>
/// <c>e^artanh(a x) sqrt(c - a c x)</c> is real past <c>a x = 1</c> 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 <c>a x = 1</c> 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
/// </summary>
[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}");
}
}

/// <summary>
/// The substitution search's even root reads the sign of a real <c>u</c> as well, and
/// says where it does: <c>(1 + sec(x))^(5/2) sqrt(cos(x))</c> under <c>t = cos(x)</c> and
Expand Down
Loading