Skip to content

Commit 1437bd1

Browse files
An exponential of the reciprocal of a linear beside a power of it is integrated (#1748)
F^(a + b/(c + d x)) (c + d x)^2 was declined, with the same alone, over c + d x, and with the cube of the reciprocal in the exponent: under u = 1/(c + d x) each is an exponential beside a power of u, and the substitution was made only where the exponent is a Gaussian in u. For any other polynomial exponent in u the integrand is asked as a question in u and written back, after the exponential ansatz, which answers some of these in the base. Rubi's 2.3 goes from 32 to 41 of the 58 problems with an exponential of a reciprocal of a linear. Part of #718. Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent fc7aafe commit 1437bd1

4 files changed

Lines changed: 125 additions & 9 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,21 @@ too. A correct antiderivative in an unhelpful form, where there was none at all.
313313
`e^(x^2)` is still declined, and correctly: its exponent is not linear and it has no elementary
314314
antiderivative.
315315

316+
### An exponential of the reciprocal of a linear beside a power of it is integrated
317+
318+
**Answers where there were none.** `F^(a + b/(c + d x)) (c + d x)^2` was declined, and so were
319+
`F^(a + b/(c + d x))` alone, over `c + d x`, and with the cube of the reciprocal in the exponent:
320+
under `u = 1/(c + d x)` each is an exponential beside a power of `u`, and the substitution was made
321+
only where the exponent is a Gaussian in `u`, whose moments the table answers. It is made for any
322+
polynomial exponent in `u` now, and the question asked in `u`. Rubi's 2.3
323+
([#718](https://github.com/asc-community/AngouriMath/issues/718)).
324+
325+
| Input | Was (2.5.0) | Now |
326+
|---|---|---|
327+
| `"F^(a + b/(c + d*x))*(c + d*x)^2".ToEntity().Integrate("x")` | `integral(...)` | an exponential integral and powers of `c + d x` times the exponential |
328+
| `"F^(a + b/(c + d*x))/(c + d*x)".ToEntity().Integrate("x")` | `integral(...)` | an exponential integral |
329+
| `"F^(a + b/(c + d*x)^3)*(c + d*x)^2".ToEntity().Integrate("x")` | `integral(...)` | an exponential integral of the cube, and the exponential |
330+
316331
### A polynomial over a power of a binomial past the cube is integrated
317332

318333
**Answers where there were none.** `P(x)/(a + b x^n)^k` with symbols in the binomial, `n >= 3`, was

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

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15993,6 +15993,63 @@ private static bool TryReadAPowerTimesARadicalQuadratic(Entity expr, Entity.Vari
1599315993
/// that <c>1/(1/u)^2</c> is <c>u^2</c>.
1599415994
/// </remarks>
1599515995
internal static Entity? SolveAGaussianInAReciprocal(Entity expr, Entity.Variable x)
15996+
{
15997+
if (ReadAnExponentialInTheReciprocalOfALinear(expr, x) is not var (constant, @base, exponentInU, u, linear, slope, power)
15998+
|| !TreeAnalyzer.TryGetPolyQuadratic(exponentInU, u, out var square, out _, out _) || TreeAnalyzer.IsZero(square))
15999+
return null;
16000+
var powerInU = -power - EInteger.FromInt32(2);
16001+
if (!powerInU.CanFitInInt32() || powerInU.Abs().CompareTo(EInteger.FromInt32(32)) > 0)
16002+
return null;
16003+
var gaussian = MathS.Pow(@base, exponentInU);
16004+
var inU = powerInU.IsZero ? gaussian : MathS.Pow(u, Number.Integer.Create(powerInU)) * gaussian;
16005+
if (IntegralPatterns.TryStandardIntegrals(inU, u) is not { } answerInU)
16006+
return null;
16007+
return (-constant / slope * answerInU.Substitute(u, 1 / linear)).InnerSimplified;
16008+
}
16009+
16010+
/// <summary>
16011+
/// The same substitution where the exponent is not a Gaussian in <c>u = 1/L</c>:
16012+
/// <c>L^m F^(a + b/L)</c> or <c>L^m F^(a + b/L^3)</c> is
16013+
/// <c>-(1/d) u^(-m - 2) F^(a + b u)</c> or <c>F^(a + b u^3)</c>, an exponential beside a
16014+
/// power, asked as a question in <c>u</c> and written back with <c>u = 1/L</c>.
16015+
/// </summary>
16016+
/// <remarks>
16017+
/// Rubi's 2.3, <c>F^(a + b/(c + d x)) (c + d x)^2</c>, <c>F^(a + b/(c + d x))/(c + d x)</c>
16018+
/// and <c>F^(a + b/(c + d x)^3)/(c + d x)</c>, were declined: the substitution was made only
16019+
/// for a Gaussian, whose moments the table answers, and an exponential of a linear or a
16020+
/// cube in <c>u</c> beside a power of it is the exponential integral's, or a power of the
16021+
/// cube's argument under <c>w = u^3</c>, which the integrator answers when asked in
16022+
/// <c>u</c>.
16023+
/// https://github.com/asc-community/AngouriMath/issues/718
16024+
/// </remarks>
16025+
internal static Entity? SolveAnExponentialInTheReciprocalOfALinear(Entity expr, Entity.Variable x, bool integrateByParts)
16026+
{
16027+
if (ReadAnExponentialInTheReciprocalOfALinear(expr, x) is not var (constant, @base, exponentInU, u, linear, slope, power)
16028+
|| !TreeAnalyzer.TryGetPolynomial(exponentInU, u, out var monomials)
16029+
|| monomials.Keys.Any(k => k.Sign < 0 || k.CompareTo(EInteger.FromInt32(8)) > 0)
16030+
|| !monomials.Keys.Any(k => k.Sign > 0))
16031+
return null;
16032+
var powerInU = -power - EInteger.FromInt32(2);
16033+
if (!powerInU.CanFitInInt32() || powerInU.Abs().CompareTo(EInteger.FromInt32(32)) > 0)
16034+
return null;
16035+
var exponential = MathS.Pow(@base, exponentInU);
16036+
var inU = powerInU.IsZero ? exponential : MathS.Pow(u, Number.Integer.Create(powerInU)) * exponential;
16037+
if (Integration.ComputeAsAQuestionOfItsOwn(inU, u, integrateByParts) is not { } answerInU
16038+
|| answerInU.Nodes.Any(node => node == MathS.NaN))
16039+
return null;
16040+
return (-constant / slope * answerInU.Substitute(u, 1 / linear)).InnerSimplified;
16041+
}
16042+
16043+
/// <summary>
16044+
/// <paramref name="expr"/> read as a constant times <c>F^E</c> times a whole power of a
16045+
/// linear <c>L</c>, with every <c>x</c> in <c>E</c> inside a reciprocal power of <c>L</c>:
16046+
/// the constant, <c>F</c>, <c>E</c> written in <c>u = 1/L</c>, <c>u</c>, <c>L</c>, its slope
16047+
/// and the power of <c>L</c>. The exponent is rewritten into <c>u</c> a node at a time --
16048+
/// <c>b/L^k</c> is <c>b u^k</c> -- rather than by substituting <c>x = (1/u - c)/d</c> and
16049+
/// asking the simplifier to see that <c>1/(1/u)^2</c> is <c>u^2</c>.
16050+
/// </summary>
16051+
private static (Entity Constant, Entity Base, Entity ExponentInU, Variable U, Entity Linear, Entity Slope, EInteger Power)?
16052+
ReadAnExponentialInTheReciprocalOfALinear(Entity expr, Entity.Variable x)
1599616053
{
1599716054
Powf? exponential = null;
1599816055
Entity? linear = null;
@@ -16031,16 +16088,9 @@ private static bool TryReadAPowerTimesARadicalQuadratic(Entity expr, Entity.Vari
1603116088
Powf(var below, Number.Integer { EInteger.Sign: < 0 } k) when below == linear => MathS.Pow(u, -k),
1603216089
_ => node
1603316090
});
16034-
if (exponentInU.ContainsNode(x) || !TreeAnalyzer.TryGetPolyQuadratic(exponentInU, u, out var square, out _, out _) || TreeAnalyzer.IsZero(square))
16035-
return null;
16036-
var powerInU = -power - EInteger.FromInt32(2);
16037-
if (!powerInU.CanFitInInt32() || powerInU.Abs().CompareTo(EInteger.FromInt32(32)) > 0)
16091+
if (exponentInU.ContainsNode(x))
1603816092
return null;
16039-
var gaussian = MathS.Pow(exponential.Base, exponentInU);
16040-
var inU = powerInU.IsZero ? gaussian : MathS.Pow(u, Number.Integer.Create(powerInU)) * gaussian;
16041-
if (IntegralPatterns.TryStandardIntegrals(inU, u) is not { } answerInU)
16042-
return null;
16043-
return (-constant / slope * answerInU.Substitute(u, 1 / linear)).InnerSimplified;
16093+
return (constant, exponential.Base, exponentInU, u, linear, slope, power);
1604416094
}
1604516095

1604616096
/// <summary>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,10 @@ private static Entity Normalized(Entity expr, Entity.Variable x) =>
11111111
// an ansatz finds it or nothing does. After the substitutions, which answer the
11121112
// linear-exponent cases in their own terms.
11131113
if ((answer = IndefiniteIntegralSolver.SolveByExponentialAnsatz(expr, x)) is { }) return answer;
1114+
// An exponential of a polynomial in the reciprocal of a linear that is not a Gaussian,
1115+
// under the Gaussian's substitution `u = 1/L`. After the ansatz, which answers some of
1116+
// these in the base: `f^(a + b/x)/x^4` is `f^(a + b/x)` times a polynomial in `1/x`.
1117+
if ((answer = IndefiniteIntegralSolver.SolveAnExponentialInTheReciprocalOfALinear(expr, x, integrateByParts)) is { }) return answer;
11141118
// A polynomial times a fractional power of a base that holds a function of x,
11151119
// answered as a polynomial times the next power of the base: a linear system in
11161120
// the polynomial's coefficients, exact, and volunteered at any depth.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// Copyright (c) 2019-2026 Angouri.
3+
// AngouriMath is licensed under MIT.
4+
// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
5+
// Website: https://am.angouri.org.
6+
//
7+
8+
using System;
9+
using AngouriMath.Extensions;
10+
using Xunit;
11+
12+
namespace AngouriMath.Tests.Calculus
13+
{
14+
/// <summary>
15+
/// An exponential of a power of the reciprocal of a linear, beside a power of the linear, that
16+
/// is not a Gaussian in <c>u = 1/L</c>: <c>F^(a + b/L) L^m</c> is
17+
/// <c>-(1/d) u^(-m - 2) F^(a + b u)</c>, an exponential beside a power. Rubi's 2.3.
18+
/// <a href="https://github.com/asc-community/AngouriMath/issues/718">#718</a>
19+
/// </summary>
20+
[Trait("Area", "Calculus")]
21+
public sealed class ExponentialOfTheReciprocalIntegralTest
22+
{
23+
[Theory]
24+
[InlineData("F^(a + b/(c + d*x))*(c + d*x)^2")]
25+
[InlineData("F^(a + b/(c + d*x))")]
26+
[InlineData("F^(a + b/(c + d*x))/(c + d*x)")]
27+
[InlineData("F^(a + b/(c + d*x)^3)/(c + d*x)")]
28+
[InlineData("F^(a + b/(c + d*x)^3)*(c + d*x)^2")]
29+
public void UnderTheReciprocal(string integrand)
30+
{
31+
var integral = integrand.ToEntity().Integrate("x");
32+
Assert.DoesNotContain("integral(", integral.Stringize());
33+
Entity Pinned(Entity e) => e.Substitute("F", 2.3).Substitute("a", 0.4).Substitute("b", 1.1)
34+
.Substitute("c", 0.6).Substitute("d", 1.3);
35+
var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
36+
var original = Pinned(integrand.ToEntity());
37+
foreach (var at in new[] { -2.4, -1.5, 0.3, 0.8, 1.5, 2.4 })
38+
{
39+
var want = original.Substitute("x", at).EvalNumerical();
40+
var got = derivative.Substitute("x", at).EvalNumerical();
41+
Assert.True(Math.Abs((double)(got - want).RealPart) + Math.Abs((double)(got - want).ImaginaryPart)
42+
< 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart) + Math.Abs((double)want.ImaginaryPart)),
43+
$"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}");
44+
}
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)