Skip to content

Commit a8a6cc8

Browse files
Rafael-SOWNetclaude
andcommitted
Read a power of a multiple of the exponent as that multiple times a power of u
The rule that reads an exponential's exponent P as the variable, beside its derivative, wrote P as u only where it stood as written. Taking the leading coefficient's power out of a power below the bar hands on e^P P'/(P/c)^k, where P/c is another polynomial, so e^(a + b x + c x^2) (b + 2 c x)/(a + b x + c x^2)^3 went on to the ansatz and ran out of time, where it is e^u/u^3. A polynomial equal to k P coefficient by coefficient is now read as k u, and a whole power of one as the power of k times the power of u. Rubi's 2.3: the cube, past 60 s on master f7f2a7a, is answered in 27 ms (197 characters); the square, 14.4 s and 9.9 GB there, takes 0.3 s and 7 MB (114 characters, carrying a factor that is 1). 2.5.0 declined both. Of the other 21 rows the branch's chain moved against 4877ed2, 17 answer identically on master f7f2a7a and here, and 4 are declined or past 20 s on both: #2005 and #2012 have since written the other mechanisms this branch had, and those are not part of it any more. Part of #233. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
1 parent f7f2a7a commit a8a6cc8

3 files changed

Lines changed: 96 additions & 1 deletion

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,21 @@ compared everywhere with its value at one positive point
218218
| `"asin(sqrt(1+b*x^2))^n/sqrt(1+b*x^2)".ToEntity().Integrate("x")` | `integral(...)` | 136 characters |
219219
| `"acos(sqrt(1+b*x^2))^n/sqrt(1+b*x^2)".ToEntity().Integrate("x")` | `integral(...)` | 137 characters |
220220

221+
### An exponential of a polynomial beside its derivative over a power of a multiple of it is integrated in the polynomial
222+
223+
**Answers where there were none.** `e^(a + b x + c x^2) (b + 2 c x)/(a + b x + c x^2)^3` ran out of time, where with
224+
`u = a + b x + c x^2` it is `e^u/u^3`. Taking the leading coefficient's power out of a power below the bar hands it on
225+
as `e^P P'/(P/c)^3`, and the exponent read as the variable was read only as written, so `P/c` was another polynomial
226+
and the question went on to the ansatz. A whole power of a constant multiple of the exponent is now read as that power
227+
of the multiple times the power of `u` (Rubi's 2.3, [#233](https://github.com/asc-community/AngouriMath/issues/233)).
228+
The square was answered by the unreleased master in fourteen seconds, as 90 characters; it is answered in a third of
229+
a second now, as 114, which carry a factor `(1/c)^(-2)/c^2` that is 1.
230+
231+
| Input | Was (2.5.0) | Now |
232+
|---|---|---|
233+
| `"e^(a+b*x+c*x^2)*(b+2*c*x)/(a+b*x+c*x^2)^3".ToEntity().Integrate("x")` | `integral(...)` | 197 characters |
234+
| `"e^(a+b*x+c*x^2)*(b+2*c*x)/(a+b*x+c*x^2)^2".ToEntity().Integrate("x")` | `integral(...)` | 114 characters |
235+
221236
### A power of a sum beside its derivative is read with the logarithms in it as factors
222237

223238
**Answers where there were none.** `(a m x^m + b n q ln(c x^n)^(q - 1))/(x (a x^m + b ln(c x^n)^q))` was declined, and so

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41189,10 +41189,37 @@ static bool SameMonomial((Entity Coefficient, Entity Exponent, List<(Entity Base
4118941189
if (scale is null)
4119041190
return null;
4119141191
var u = Variable.CreateUnique(expr, "u");
41192-
var inU = (scale * rest.Replace(node => node == polynomial ? u : node)).InnerSimplified;
41192+
// And a constant multiple of P, as that multiple of u: taking the leading coefficient's
41193+
// power out of a power below the bar hands on `e^P P'/(P/c)^2`, and with P read only as
41194+
// written, `e^(a + b x + c x^2) (b + 2 c x)/(a + b x + c x^2)^2` went on to the ansatz,
41195+
// which ran out of time, where `e^u/u^2` is answered at once.
41196+
// A whole power of one as that power of the multiple times the power of u, so that the
41197+
// multiple stands apart from u and the rules in u read a power of u alone.
41198+
TreeAnalyzer.TryGetPolynomial(polynomial, x, out var ofP);
41199+
var inU = (scale * rest
41200+
.Replace(node => node is Powf(var @base, Number.Integer whole) && @base != polynomial && AMultipleOfThePolynomial(@base) is { } multiple
41201+
? MathS.Pow(multiple, whole) * MathS.Pow(polynomial, whole) : node)
41202+
.Replace(node => node == polynomial ? u : AMultipleOfThePolynomial(node) is { } multiple ? multiple * u : node)).InnerSimplified;
4119341203
if (inU.ContainsNode(x))
4119441204
return null;
4119541205
return Integration.ComputeAsAQuestionOfItsOwn(inU, u, integrateByParts)?.Substitute(u, polynomial);
41206+
41207+
// The constant k where the node is a polynomial in x equal to k P coefficient by coefficient.
41208+
Entity? AMultipleOfThePolynomial(Entity node)
41209+
{
41210+
if (node is not (Sumf or Minusf) || !node.ContainsNode(x) || ofP is null
41211+
|| !TreeAnalyzer.TryGetPolynomial(node, x, out var read) || read.Count != ofP.Count
41212+
|| read.Keys.Any(key => !ofP.ContainsKey(key)) || read.Values.Any(value => value.ContainsNode(x)))
41213+
return null;
41214+
var top = ofP.Keys.Max()!;
41215+
var multiple = Functions.PartialFractions.InLowestTermsOverTheSymbols(read[top] / ofP[top]);
41216+
if (multiple.Evaled is Number.Complex { IsZero: true } || multiple.Nodes.Any(inner => inner == MathS.NaN))
41217+
return null;
41218+
foreach (var pair in read)
41219+
if (!VanishesIdentically(pair.Value - multiple * ofP[pair.Key]))
41220+
return null;
41221+
return multiple;
41222+
}
4119641223
}
4119741224

4119841225
/// <summary>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
/// <c>e^P P'</c> over a power of the quadratic <c>P</c>, under <c>u = P</c>, with a constant multiple
16+
/// of <c>P</c> read as that multiple of <c>u</c>: taking the leading coefficient's power out from
17+
/// below the bar hands on <c>e^P P'/(P/c)^2</c>, and <c>e^(a + b x + c x^2) (b + 2 c x)/(a + b x + c x^2)^2</c>
18+
/// went on to the ansatz and ran out of time. Rubi's 2.3.
19+
/// <a href="https://github.com/asc-community/AngouriMath/issues/718">#718</a>
20+
/// </summary>
21+
[Trait("Area", "Calculus")]
22+
public sealed class TheExponentAsTheVariableBesideAMultipleOfItIntegralTest
23+
{
24+
[Theory]
25+
[InlineData("e^(a + b*x + c*x^2)*(b + 2*c*x)/(a + b*x + c*x^2)^2")]
26+
[InlineData("e^(a + b*x + c*x^2)*(b + 2*c*x)/(a + b*x + c*x^2)^3")]
27+
[InlineData("e^(a + b*x + c*x^2)*(b + 2*c*x)/(a + b*x + c*x^2)^4")]
28+
[InlineData("e^(1 + x + 3*x^2)*(1 + 6*x)/(1 + x + 3*x^2)^2")]
29+
public void APowerOfTheExponentBelowTheBar(string integrand)
30+
{
31+
var integral = integrand.ToEntity().Integrate("x");
32+
var text = integral.Stringize();
33+
Assert.DoesNotContain("integral(", text);
34+
Assert.True(text.Length < 20000, $"{text.Length} characters of answer for {integrand}");
35+
Entity Pinned(Entity e) => e.Substitute("a", -1.3).Substitute("b", 0.7).Substitute("c", 0.4);
36+
var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
37+
var original = Pinned(integrand.ToEntity());
38+
var compared = 0;
39+
foreach (var at in new[] { -2.7, -1.2, -0.5, 0.3, 0.8, 1.7, 2.9 })
40+
{
41+
var want = original.Substitute("x", at).EvalNumerical();
42+
var got = derivative.Substitute("x", at).EvalNumerical();
43+
if (want.IsNaN)
44+
continue;
45+
compared++;
46+
Assert.True(Math.Abs((double)(got - want).RealPart) + Math.Abs((double)(got - want).ImaginaryPart)
47+
< 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart) + Math.Abs((double)want.ImaginaryPart)),
48+
$"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}");
49+
}
50+
Assert.True(compared >= 5, $"only {compared} points could be compared for {integrand}");
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)