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 @@ -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);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/// <summary>
/// A name that is zero on the real line: <c>ln(e^x) - x</c> is zero for every real
/// <c>x</c>, and the answer for <c>1/(x (x + c))</c> divides by <c>c</c>, so it had no
/// value at any real point. The arm for <c>c = 0</c> is asked as well. Rubi's 3.5,
/// #192 and #226. https://github.com/asc-community/AngouriMath/issues/1666
/// </summary>
[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);

/// <summary>
/// ...and only there: <c>ln(e^(2(a + b x))) - 2 b x</c> is <c>2a</c> on the real line, and
/// the answer for <c>atanh(tanh(x))^2</c> has a value at <c>c = 0</c>.
/// </summary>
[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());
}
}
Loading