Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,24 @@ Each of these was checked by differentiating it back with the parameters pinned
four points. The Rubi sample is unchanged at 231 of 463 with no wrong answers, so nothing that
already had an antiderivative moves.

### `NaN` a fourth time, from an exponent that is `-1` only as a value

**A wrong answer.** `x^(-1 - 3n) (a + b x^n)^3` came back as a sum whose last term was `x^0/0`, so
that it had no value anywhere, and `x^(-n/n)` as `NaN + C`. Expanded, the integrand's last term is
`x^(-1 - 3n + 3n)`, which is `x^(-1)` for every `n`; `InnerSimplified` keeps `-3n + 3n` as two
terms, and the power rule, which reads `-1` once the exponent is a number (the entry above), read
this one as written and divided by its zero. It asks whether the exponent plus one vanishes as a
value now, and gives the logarithm where it does. A symbolic exponent that is `-1` for one value
only is the power rule's as before. Rubi's 1.1.3.2 has four of these
([#718](https://github.com/asc-community/AngouriMath/issues/718)).

| Input | Was (2.5.0) | Now |
|---|---|---|
| `"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)` |
| `"x^(-1 - 3*n + 3*n)".ToEntity().Integrate("x")` | `x^(-1 - 3n + 3n + 1)/(-1 - 3n + 3n + 1)`, no value anywhere | `ln(x)` |
| `"x^(-n/n)".ToEntity().Integrate("x")` | `NaN` | `ln(x)` |
| `"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` |

### `NaN` a third time, from a quadratic with a coefficient off the real line

The integrals of `1/sqrt(Q)`, `1/Q` and `1/Q^n` over a quadratic `Q` choose their form by the sign
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2486,13 +2486,23 @@ over is Entity.Powf(var @base, var power) ?
/// whether an undecidable <c>n</c> is that one; what it fixes is an exponent that
/// <em>is</em> decidable and was read as though it were not.
/// </para>
/// <para>
/// Decidable includes a symbol that cancels: <c>x^(-1 - 3n + 3n)</c> is <c>x^(-1)</c> for
/// every <c>n</c>, and is what expanding <c>x^(-1 - 3n) (a + b x^n)^3</c> leaves for its
/// last term, but <see cref="Entity.InnerSimplified"/> keeps <c>-3n + 3n</c> as two terms,
/// so the exponent plus one is asked whether it vanishes as a value. Read as written it
/// was <c>x^0/0</c> again, and the whole answer had no value anywhere; Rubi's 1.1.3.2
/// has four such and <c>1/(a (b x^m)^n)^(1/(m n))</c>, which is <c>x^(-m n/(m n))</c>.
/// </para>
/// </remarks>
private static Entity IntegrateAPowerOfTheVariable(Entity @base, Entity power, Entity.Variable x)
{
var exponent = power.InnerSimplified;
if (exponent == -1)
return IntegralPatterns.AntiderivativeLog(@base);
var raised = (exponent + 1).InnerSimplified;
if (raised.Vars.Any() && VanishesIdentically(raised))
return IntegralPatterns.AntiderivativeLog(@base);
return MathS.Pow(x, raised) / raised;
}

Expand Down
19 changes: 18 additions & 1 deletion Sources/Tests/UnitTests/Calculus/ExpandedSquareNaNTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public sealed class ExpandedSquareNaNTest
/// </summary>
private static Entity Pin(Entity expr) => expr
.Substitute("a", 2).Substitute("b", 3)
.Substitute("c", 2).Substitute("d", 3).Substitute("e", 5);
.Substitute("c", 2).Substitute("d", 3).Substitute("e", 5)
.Substitute("m", 1.7).Substitute("n", 2.9);

private static void DifferentiatesBack(string integrand)
{
Expand Down Expand Up @@ -123,6 +124,22 @@ private static void DifferentiatesBack(string integrand)
[InlineData("x^(-2)")]
[InlineData("x^(-7)")]
[InlineData("x^(1/2)")]
[InlineData("x^n")]
[InlineData("x^(n - 1)")]
public void ThePowerRuleIsUnchanged(string integrand) => DifferentiatesBack(integrand);

/// <summary>
/// A symbolic exponent that is <c>-1</c> as a value, which the power rule read as written:
/// <c>x^(-1 - 3n + 3n)</c> is what expanding <c>x^(-1 - 3n) (a + b x^n)^3</c> leaves for its
/// last term, and came out as <c>x^0/0</c>, so the whole answer had no value anywhere.
/// Rubi's 1.1.3.2.
/// </summary>
[Theory]
[InlineData("x^(-1 - 3*n)*(a + b*x^n)^3")]
[InlineData("x^(-1 - 7*n)*(a + b*x^n)^8")]
[InlineData("1/(a*(b*x^m)^n)^(1/(m*n))")]
[InlineData("x^(-1 - 3*n + 3*n)")]
[InlineData("x^(-n/n)")]
public void AnExponentThatIsMinusOneAsAValue(string integrand) => DifferentiatesBack(integrand);
}
}
Loading