Skip to content

Commit 098cb2b

Browse files
A symbolic exponent that is -1 as a value is integrated to the logarithm (#1723)
x^(-1 - 3n) (a + b x^n)^3 expanded leaves x^(-1 - 3n + 3n) for its last term, which is x^(-1) for every n, and InnerSimplified keeps -3n + 3n as two terms. The power rule read the exponent as written and divided by its zero, so the whole answer had no value anywhere; x^(-n/n) came back NaN. It asks whether the exponent plus one vanishes as a value now, and gives the logarithm where it does. 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 4d1f3b7 commit 098cb2b

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,24 @@ Each of these was checked by differentiating it back with the parameters pinned
583583
four points. The Rubi sample is unchanged at 231 of 463 with no wrong answers, so nothing that
584584
already had an antiderivative moves.
585585

586+
### `NaN` a fourth time, from an exponent that is `-1` only as a value
587+
588+
**A wrong answer.** `x^(-1 - 3n) (a + b x^n)^3` came back as a sum whose last term was `x^0/0`, so
589+
that it had no value anywhere, and `x^(-n/n)` as `NaN + C`. Expanded, the integrand's last term is
590+
`x^(-1 - 3n + 3n)`, which is `x^(-1)` for every `n`; `InnerSimplified` keeps `-3n + 3n` as two
591+
terms, and the power rule, which reads `-1` once the exponent is a number (the entry above), read
592+
this one as written and divided by its zero. It asks whether the exponent plus one vanishes as a
593+
value now, and gives the logarithm where it does. A symbolic exponent that is `-1` for one value
594+
only is the power rule's as before. Rubi's 1.1.3.2 has four of these
595+
([#718](https://github.com/asc-community/AngouriMath/issues/718)).
596+
597+
| Input | Was (2.5.0) | Now |
598+
|---|---|---|
599+
| `"x^(-1 - 3*n)*(a + b*x^n)^3".ToEntity().Integrate("x")` | three powers and `x^0/0`, no value anywhere | the three powers and `b^3 ln(x)` |
600+
| `"x^(-1 - 3*n + 3*n)".ToEntity().Integrate("x")` | `x^(-1 - 3n + 3n + 1)/(-1 - 3n + 3n + 1)`, no value anywhere | `ln(x)` |
601+
| `"x^(-n/n)".ToEntity().Integrate("x")` | `NaN` | `ln(x)` |
602+
| `"1/(a*(b*x^m)^n)^(1/(m*n))".ToEntity().Integrate("x")` | `integral(...)` | `(a b^n)^(-1/(m n)) ln(x)`, provided `b > 0` and `a b^n > 0` |
603+
586604
### `NaN` a third time, from a quadratic with a coefficient off the real line
587605

588606
The integrals of `1/sqrt(Q)`, `1/Q` and `1/Q^n` over a quadratic `Q` choose their form by the sign

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,13 +2486,23 @@ over is Entity.Powf(var @base, var power) ?
24862486
/// whether an undecidable <c>n</c> is that one; what it fixes is an exponent that
24872487
/// <em>is</em> decidable and was read as though it were not.
24882488
/// </para>
2489+
/// <para>
2490+
/// Decidable includes a symbol that cancels: <c>x^(-1 - 3n + 3n)</c> is <c>x^(-1)</c> for
2491+
/// every <c>n</c>, and is what expanding <c>x^(-1 - 3n) (a + b x^n)^3</c> leaves for its
2492+
/// last term, but <see cref="Entity.InnerSimplified"/> keeps <c>-3n + 3n</c> as two terms,
2493+
/// so the exponent plus one is asked whether it vanishes as a value. Read as written it
2494+
/// was <c>x^0/0</c> again, and the whole answer had no value anywhere; Rubi's 1.1.3.2
2495+
/// has four such and <c>1/(a (b x^m)^n)^(1/(m n))</c>, which is <c>x^(-m n/(m n))</c>.
2496+
/// </para>
24892497
/// </remarks>
24902498
private static Entity IntegrateAPowerOfTheVariable(Entity @base, Entity power, Entity.Variable x)
24912499
{
24922500
var exponent = power.InnerSimplified;
24932501
if (exponent == -1)
24942502
return IntegralPatterns.AntiderivativeLog(@base);
24952503
var raised = (exponent + 1).InnerSimplified;
2504+
if (raised.Vars.Any() && VanishesIdentically(raised))
2505+
return IntegralPatterns.AntiderivativeLog(@base);
24962506
return MathS.Pow(x, raised) / raised;
24972507
}
24982508

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public sealed class ExpandedSquareNaNTest
4848
/// </summary>
4949
private static Entity Pin(Entity expr) => expr
5050
.Substitute("a", 2).Substitute("b", 3)
51-
.Substitute("c", 2).Substitute("d", 3).Substitute("e", 5);
51+
.Substitute("c", 2).Substitute("d", 3).Substitute("e", 5)
52+
.Substitute("m", 1.7).Substitute("n", 2.9);
5253

5354
private static void DifferentiatesBack(string integrand)
5455
{
@@ -123,6 +124,22 @@ private static void DifferentiatesBack(string integrand)
123124
[InlineData("x^(-2)")]
124125
[InlineData("x^(-7)")]
125126
[InlineData("x^(1/2)")]
127+
[InlineData("x^n")]
128+
[InlineData("x^(n - 1)")]
126129
public void ThePowerRuleIsUnchanged(string integrand) => DifferentiatesBack(integrand);
130+
131+
/// <summary>
132+
/// A symbolic exponent that is <c>-1</c> as a value, which the power rule read as written:
133+
/// <c>x^(-1 - 3n + 3n)</c> is what expanding <c>x^(-1 - 3n) (a + b x^n)^3</c> leaves for its
134+
/// last term, and came out as <c>x^0/0</c>, so the whole answer had no value anywhere.
135+
/// Rubi's 1.1.3.2.
136+
/// </summary>
137+
[Theory]
138+
[InlineData("x^(-1 - 3*n)*(a + b*x^n)^3")]
139+
[InlineData("x^(-1 - 7*n)*(a + b*x^n)^8")]
140+
[InlineData("1/(a*(b*x^m)^n)^(1/(m*n))")]
141+
[InlineData("x^(-1 - 3*n + 3*n)")]
142+
[InlineData("x^(-n/n)")]
143+
public void AnExponentThatIsMinusOneAsAValue(string integrand) => DifferentiatesBack(integrand);
127144
}
128145
}

0 commit comments

Comments
 (0)