Skip to content

Commit 06df32e

Browse files
A logarithm of a nested quotient is written over one bar under the exponential substitution (#1410)
* A logarithm of a nested quotient is written over one bar under the exponential substitution 1/sqrt(atanh(tanh(a + b x))) was answered in 300 ms before the exponential substitution took a symbolic slope (#1377) and not after. atanh(tanh(a + b x)) arrives at the chain as 1/2 ln((1 + (w - 1)/(w + 1))/(1 - (w - 1)/(w + 1))) in w = e^(2(a + b x)), and under u = w that logarithm is 1/2 ln(u); but the combining on the way in reaches the quotient the integrand is and not one inside a function, the simplifier combines nothing (#1239), and the substitution search compared its candidates against the nested spelling and never saw the u. Every logarithm whose argument is a rational function of u with a quotient nested in it is now written over one bar in lowest terms where that is smaller, before the integrand in u is asked. Part of #718. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura * BREAKING-CHANGES: the logarithm of a nested quotient under the exponential substitution Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 84b0a9c commit 06df32e

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,22 @@ shorter than the symbolic split's.
412412
| `"1/(u*(u^2 + 1)^6*(a*(u^2 + 1) + 2*a*u))".Integrate("u")` | unevaluated | `(17/24 - 829/1536 u + … - 273/512 u^10)/(a (u^2 + 1)^5 (u + 1)) + ln(u)/a - 7/64 ln(u + 1)/a - 57/128 ln(u^2 + 1)/a - 329/512 arctan(u)/a` |
413413
| `"u^5/((u^2 - 1)^5*(2*a*u + b*(u^2 + 1)))".Integrate("u")` | unevaluated | the same piecewise in `u`, its coefficients `1/256 (3a^3 - 7ab^2)/(a^4 - 2a^2 b^2 + b^4)` and the like rather than two thousand nodes each |
414414

415+
### A logarithm of a nested quotient is written over one bar under the exponential substitution
416+
417+
**Improvement, not silent.** `atanh(tanh(a + b x))` reaches the integrator as
418+
`1/2 ln((1 + (w - 1)/(w + 1))/(1 - (w - 1)/(w + 1)))` in `w = e^(2(a + b x))`, and under `u = w`
419+
that logarithm is `1/2 ln(u)`; but the combining on the way into the substitution reaches the
420+
quotient the integrand is and not one inside a function, the simplifier combines nothing (#1239),
421+
and the substitution search compared its candidates against the nested spelling and never saw
422+
the `u`. A logarithm whose argument is a rational function of `u` with a quotient nested in it is
423+
now written over one bar in lowest terms, where that is smaller, before the question in `u` is
424+
asked. Only under that substitution; `Simplify` still combines nothing.
425+
426+
| | Was | Is |
427+
|---|---|---|
428+
| `"1/sqrt(atanh(tanh(a + b*x)))".Integrate("x")` | unevaluated after 49 s | `2 (1/2 ln(e^(2 b x + 2 a)))^(1/2)/(1/2)/(2 b)`, 0.3 s |
429+
| `"atanh(tanh(a + b*x))^(1/2)".Integrate("x")` | unevaluated | `2 (1/2 ln(e^(2 b x + 2 a)))^(3/2)/(3/2)/(2 b)` |
430+
415431
### A condition the answer states on its own is no longer repeated beside it
416432

417433
**Improvement, not silent.** `Simplify` returned `(1 - ln(x))/x^2 provided not x = 0` for the

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9828,6 +9828,7 @@ node is Powf(Powf(var @base, var inner), var outer)
98289828
rewritten / (Number.Rational.Create(k) * u)).Simplify();
98299829
if (integrand is Providedf(var inner, _))
98309830
integrand = inner;
9831+
integrand = WithLogarithmArgumentsOverOneBar(integrand, u);
98319832
// A whole power of a product is written as the product of the powers: the
98329833
// simplifier writes `4a^2 u^2` as `(a u)^2 4`, and no rational reader sees the `u^2`
98339834
// inside -- Timofeev's `1/(a^2 + b^2 cosh(x)^2)` was declined in that spelling and
@@ -9879,6 +9880,40 @@ node is Powf(Powf(var @base, var inner), var outer)
98799880
}
98809881
}
98819882

9883+
/// <summary>
9884+
/// <paramref name="expr"/> with every logarithm whose argument is a rational function
9885+
/// of <paramref name="x"/> with a quotient nested inside it written over one bar in
9886+
/// lowest terms, where that is smaller: <c>ln((1 + (u - 1)/(u + 1))/(1 - (u - 1)/(u + 1)))</c>
9887+
/// is <c>ln(u)</c>.
9888+
/// </summary>
9889+
/// <remarks>
9890+
/// The combining above reaches the quotient the integrand is and not one inside a
9891+
/// function, and the simplifier combines nothing
9892+
/// (https://github.com/asc-community/AngouriMath/issues/1239). <c>atanh(tanh(a + b x))</c>
9893+
/// arrives as half that logarithm of <c>tanh</c> written in <c>e^(2(a + b x))</c>, and
9894+
/// under <c>u</c> the substitution search compared its candidates against the nested
9895+
/// spelling and never saw the <c>u</c> it is: <c>1/sqrt(atanh(tanh(a + b x)))</c> was
9896+
/// answered before the substitution took a symbolic slope and not after.
9897+
/// https://github.com/asc-community/AngouriMath/issues/718
9898+
/// </remarks>
9899+
private static Entity WithLogarithmArgumentsOverOneBar(Entity expr, Entity.Variable x)
9900+
=> expr.Replace(node =>
9901+
{
9902+
if (node is not Logf(var logBase, var argument) || logBase != MathS.e || !argument.ContainsNode(x) || !IsARationalFunction(argument, x)
9903+
|| !argument.Nodes.Any(inner => inner is Divf && inner != argument))
9904+
return node;
9905+
var (above, below) = Functions.SingleQuotient.Of(argument);
9906+
var over = below == Number.Integer.One ? above.InnerSimplified
9907+
: Functions.PolynomialGcd.TryCancel(above.InnerSimplified, below.InnerSimplified, out var cancelled)
9908+
? Functions.PartialFractions.Bare(cancelled).InnerSimplified
9909+
: (above / below).InnerSimplified;
9910+
if (over.Complexity >= argument.Complexity)
9911+
return node;
9912+
// Small by now, and `2u/2` is what the cancellation leaves of `(2u/(u + 1))/(2/(u + 1))`.
9913+
over = Functions.PartialFractions.Bare(over.Simplify());
9914+
return MathS.Ln(over);
9915+
});
9916+
98829917
/// <summary>
98839918
/// A product with a whole negative power of a polynomial in <paramref name="x"/> of
98849919
/// two or more terms among its factors, with every such power written below the bar

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,22 @@ public void BasesThatArePowersOfOne(string integrand)
407407
public void ASymbolicSlope(string integrand)
408408
=> DifferentiatesBackWithParametersPinned(integrand, new[] { -0.5, 0.23, 0.61, 1.05, 1.7 });
409409

410+
/// <summary>
411+
/// A logarithm's argument that is a rational function of <c>u</c> with a quotient
412+
/// nested in it is written over one bar in lowest terms: <c>atanh(tanh(a + b x))</c>
413+
/// arrives as <c>1/2 ln((1 + (u - 1)/(u + 1))/(1 - (u - 1)/(u + 1)))</c> under
414+
/// <c>u = e^(2(a + b x))</c>, which is <c>1/2 ln(u)</c>, and the substitution search
415+
/// compared its candidates against the nested spelling and never saw it. The
416+
/// combining on the way in reaches the quotient the integrand is and not one inside a
417+
/// function, and the simplifier combines nothing.
418+
/// </summary>
419+
[Theory]
420+
[InlineData("1/sqrt(atanh(tanh(a + b*x)))")]
421+
[InlineData("atanh(tanh(a + b*x))^(1/2)")]
422+
[InlineData("1/atanh(tanh(a + b*x))^2")]
423+
public void ALogarithmOfANestedQuotientIsWrittenOverOneBar(string integrand)
424+
=> DifferentiatesBackWithParametersPinned(integrand, new[] { -0.5, 0.23, 0.61, 1.05, 1.7 });
425+
410426
/// <summary>
411427
/// A quotient the gathering on the chain's entry writes as a product with a negative
412428
/// power -- <c>u^3/((a u^2 + b)^3 u)</c> as <c>u^2 (a u^2 + b)^(-3)</c> -- is written

0 commit comments

Comments
 (0)