Skip to content

Commit 8e0bb15

Browse files
A Gaussian below the bar is read as its negated exponent above it (#1641)
e^(-x^2)/x^2 was integrated by the Gaussian's moments, and 1/(e^(x^2) x^2), the same function, was not: the moment rule took the exponential from above the bar only. By parts writes the factor beside erf(b x) in erf(b x)/(e^(b^2 x^2) x^2) the second way, and that integral was declined for want of it. A Gaussian below the bar is read as the exponential of its negated exponent now. Measured on the Rubi corpus, master at 2db4278 and this change on it, run side by side: family 8 367 -> 371 of 420, erf and erfc of b x over e^(b^2 x^2) x^2 and over e^(b^2 x^2) x^4; family 2 544 of 650, the independent suites 1756 of 1814 and families 1 and 3 to 7 at five a file 799 of 897, on both. 0 wrong everywhere. Run alone, the four are 0 of 4 on master and 4 of 4 here, each answered in 0.2 to 0.9 s where master declined it in 2.4 to 10.5 s. The unit tests pass, 14,249. The performance gate passes on c6024927, which is this change on 2db4278: allocation is what the baseline says on all 19 gated benchmarks. GaussianIntegralTest has two rows with the Gaussian below the bar, each differentiated back. Part of #1501. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 6c94652 commit 8e0bb15

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,6 +2917,20 @@ since they are these exponentials
29172917
| `"(p + q*x)^2*f^(a + b*x + c*x^2)".Integrate("x")` | `integral((p + q * x) ^ 2 * f ^ (a + b * x + c * x ^ 2), x)` | the antiderivative |
29182918
| `"x^2*sinh(a + b*x + c*x^2)".Integrate("x")` | `integral(x ^ 2 * (e ^ (a + b * x + c * x ^ 2) - e ^ (-(a + b * x + c * x ^ 2))) / 2, x)` | the antiderivative |
29192919

2920+
### A Gaussian below the bar is read as the exponential of its negated exponent
2921+
2922+
`e^(-x^2)/x^2` was integrated by the Gaussian's moments, and `1/(e^(x^2) x^2)`, the same function,
2923+
was not: the rule for the moments took the exponential from above the bar only. By parts writes
2924+
the factor beside `erf(b x)` in `erf(b x)/(e^(b^2 x^2) x^2)` the second way, and that integral was
2925+
declined for want of it ([#1501](https://github.com/asc-community/AngouriMath/issues/1501)). Both
2926+
columns measured on a build, `v2.5.0` against this change; `erf` had no reading in 2.5.0, which its
2927+
own entry records.
2928+
2929+
| Input | Was (2.5.0) | Now |
2930+
|---|---|---|
2931+
| `"1/(e^(x^2)*x^2)".Integrate("x")` | `integral(1 / (e ^ x ^ 2 * x ^ 2), x)` | `-1 / x * e ^ (-x ^ 2) + (-2) * pi ^ (1/2) / 2 * erf(x) + C` |
2932+
| `"erf(b*x)/(e^(b^2*x^2)*x^2)".Integrate("x")` | `UnrecognizedFunctionParseException`: there is no function `erf` | an antiderivative in `erf` and `Ei(-2 b^2 x^2)` |
2933+
29202934
### An exponential of a polynomial beside the polynomial's derivative is integrated
29212935

29222936
`e^(a + b x + c x^2) (b + 2 c x) sqrt(a + b x + c x^2)` was left unintegrated. `G^P k P' f(P)`, with

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,13 @@ private static bool TakeMomentFactor(Entity factor, bool inverted, Entity.Variab
232232
power = inverted ? -n.EInteger.ToInt32Checked() : n.EInteger.ToInt32Checked();
233233
return true;
234234
}
235-
if (!inverted && gaussian is null && factor is Entity.Powf(var @base, _) exponential && !@base.ContainsNode(x))
235+
// Below the bar too, as the exponential of the negated exponent: `1/(e^(b^2 x^2) x^2)` is
236+
// `e^(-b^2 x^2)/x^2`, and it is how by parts writes the factor beside `erf(b x)` in
237+
// `erf(b x)/(e^(b^2 x^2) x^2)`, which was declined for want of its integral.
238+
// https://github.com/asc-community/AngouriMath/issues/1501
239+
if (gaussian is null && factor is Entity.Powf(var @base, var exponent) exponential && !@base.ContainsNode(x))
236240
{
237-
gaussian = exponential;
241+
gaussian = inverted ? new Entity.Powf(@base, -exponent) : exponential;
238242
return true;
239243
}
240244
// A sum, or a whole power of one, taken as it is: read as a polynomial only once a

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ public void ASymbolicGaussianIsUnconditional()
103103
[InlineData("e^(-x^2)/x^2")]
104104
[InlineData("e^(x^2)/x^4")]
105105
[InlineData("3*x^6*e^(-2*x^2)/5")]
106+
[InlineData("1/(e^(x^2)*x^2)")]
107+
[InlineData("1/(e^(2*x^2)*x^4)")]
106108
public void TheGaussianBesideAnEvenPower(string integrand) => DifferentiatesBack(integrand);
107109

108110
/// <summary>

0 commit comments

Comments
 (0)