@@ -8076,8 +8076,14 @@ private static bool IsTheSameQuadratic(Entity candidate, Entity wanted, Entity.V
80768076 /// <para>
80778077 /// <b>Where the answer holds.</b> <c>u = ln(x)</c> is a bijection from the positive reals
80788078 /// to the whole line, so the answer is an antiderivative for <c>x > 0</c> — which is
8079- /// where an integrand built from <c>ln(x)</c> is real in the first place. Nothing is
8080- /// assumed that the integrand did not already assume.
8079+ /// where an integrand built from <c>ln(x)</c> is real, with one kind of exception. A
8080+ /// radical function of whole powers of <c>x = e^u</c>, <c>sqrt(sinh(2 ln(x)))</c> or
8081+ /// <c>1/csch(2 ln(x))^(1/2)</c>, is real for a negative <c>x</c> too, where <c>ln(x)</c>
8082+ /// is <c>ln(-x) + i pi</c>; and the rules that integrate it in <c>u</c> take <c>e^u</c> to
8083+ /// be positive, which it is for every real <c>u</c>. That answer is given
8084+ /// <c>provided x > 0</c>. Written in powers of <c>x</c>, which
8085+ /// <see cref="SolveByFoldingAnExponentialOfALogarithm"/> does before this, the same
8086+ /// integrand is answered on both sides of zero where the rules read it.
80818087 /// </para>
80828088 /// https://github.com/asc-community/AngouriMath/issues/718
80838089 /// </remarks>
@@ -8103,19 +8109,46 @@ node is Logf(var @base, var argument) && !@base.ContainsNode(x) && @base != Math
81038109 if (integrand is Providedf(var inner, _))
81048110 integrand = inner;
81058111
8106- return Integration.ComputeIndefiniteIntegral(integrand, u, integrateByParts) is { } result
8107- ? result.Substitute(u, MathS.Ln(x))
8108- : null;
8112+ if (Integration.ComputeIndefiniteIntegral(integrand, u, integrateByParts) is not { } result)
8113+ return null;
8114+ var back = result.Substitute(u, MathS.Ln(x));
8115+ return IsARadicalFunctionOfWholePowersOfTheExponential(inU, u) ? back.Provided(x > Number.Integer.Zero) : back;
8116+ }
8117+
8118+ /// <summary>
8119+ /// Whether <paramref name="expr"/> holds <paramref name="t"/> only in exponentials
8120+ /// <c>e^(k t + a)</c> with a whole <c>k</c>, some of them under a power that is not
8121+ /// whole: a radical function of whole powers of <c>e^t</c>. At <c>t = s + i pi</c>,
8122+ /// where a substitution <c>t = ln(c x^n)</c> lands for a negative <c>c x^n</c>, it is the
8123+ /// same function of <c>-e^s</c>, real again wherever its radicands are positive; and an
8124+ /// integral of it in <c>t</c> is found for a real <c>t</c>, under which <c>e^t</c> is
8125+ /// positive and gives up its powers from under a root.
8126+ /// </summary>
8127+ private static bool IsARadicalFunctionOfWholePowersOfTheExponential(Entity expr, Entity.Variable t)
8128+ {
8129+ var exponential = Variable.CreateUnique(expr, "w_exp");
8130+ var inExponentials = expr.Replace(node =>
8131+ node is Powf(var @base, var exponent) && @base == MathS.e && exponent.ContainsNode(t)
8132+ && TreeAnalyzer.TryGetPolyLinear(exponent, t, out var slope, out var offset)
8133+ && slope.Evaled is Number.Integer && !offset.ContainsNode(t)
8134+ ? exponential
8135+ : node);
8136+ return !inExponentials.ContainsNode(t)
8137+ && inExponentials.Nodes.Any(node => node is Powf(var @base, var power) && @base.ContainsNode(exponential) && power.Evaled is not Number.Integer);
81098138 }
81108139
81118140 /// <summary>
81128141 /// A power of <c>x</c> times a function of one logarithm of a monomial, <c>x^m G(ln(c x^n))</c>,
81138142 /// under <c>t = ln(c x^n)</c>: <c>dx = x dt/n</c>, and <c>x^(m + 1)</c> is
81148143 /// <c>K e^((m + 1) t/n)</c> with <c>K = x^(m + 1) (c x^n)^(-(m + 1)/n)</c>, whose derivative
81158144 /// is 0 wherever it is defined. So the answer is <c>K/n</c> times the integral of
8116- /// <c>e^((m + 1) t/n) G(t)</c> at <c>t = ln(c x^n)</c>, an antiderivative on the whole of
8117- /// the real line where the integrand is real -- for an even <c>n</c> that includes negative
8118- /// <c>x</c>, where <c>ln(c x^n)</c> is not <c>ln(c) + n ln(x)</c>. A power of a monomial,
8145+ /// <c>e^((m + 1) t/n) G(t)</c> at <c>t = ln(c x^n)</c>, an antiderivative wherever
8146+ /// <c>c x^n</c> is positive -- for an even <c>n</c> and a positive <c>c</c> the whole line,
8147+ /// negative <c>x</c> included, where <c>ln(c x^n)</c> is not <c>ln(c) + n ln(x)</c>. Where
8148+ /// <c>c x^n</c> is negative, <c>t</c> is <c>ln(-c x^n) + i pi</c>, and a function of whole
8149+ /// powers of <c>e^t</c>, <c>sqrt(sinh(2 t))</c> say, is real there as well; a radical one
8150+ /// has its integral in <c>t</c> found for a real <c>t</c>, under which <c>e^t</c> is
8151+ /// positive, so that answer is given <c>provided c x^n > 0</c>. A power of a monomial,
81198152 /// <c>(e x)^p</c>, is <c>x^p</c> times a factor of the same kind. What by parts leaves of
81208153 /// <c>(e x)^m Si(d (a + b ln(c x^n)))</c> is this, with <c>G(t)</c> a sine over a linear in
81218154 /// <c>t</c>. Rubi's answers to 8.3 to 8.5 are written in exactly this <c>K</c>.
@@ -8172,7 +8205,14 @@ node is Logf(var @base, var argument) && !@base.ContainsNode(x) && @base != Math
81728205 var k = logarithms[0].Antilogarithm == x ? Number.Integer.One
81738206 : MathS.Pow(x, mPlusOne) * MathS.Pow(logarithms[0].Antilogarithm, (-mPlusOne / n).InnerSimplified);
81748207 var back = constant * locallyConstant * k / n * inTIntegral.Substitute(t, logarithms[0]);
8175- return back.Nodes.Any(node => node == MathS.NaN) ? null : back;
8208+ if (back.Nodes.Any(node => node == MathS.NaN))
8209+ return null;
8210+ // Positive for every x other than 0 when n is even and c a positive number, and
8211+ // nothing to say then.
8212+ var positiveEverywhere = n.Evaled is Number.Integer whole && whole.EInteger.IsEven && c.Evaled is Number.Real { IsPositive: true };
8213+ return !positiveEverywhere && IsARadicalFunctionOfWholePowersOfTheExponential(inT, t)
8214+ ? back.Provided(logarithms[0].Antilogarithm > Number.Integer.Zero)
8215+ : back;
81768216 }
81778217
81788218 /// <summary>
0 commit comments