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
14 changes: 14 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,20 @@ the working digits, or `MathS.Settings.PrecisionErrorZeroRange` where a caller h
still that integer, so `e^(-123.456)` is 0 as it was.
[#1338](https://github.com/asc-community/AngouriMath/issues/1338).

### A power of a power of a logarithm over x is integrated below the question asked too

**Answers where there were none.** Rubi's 3.5 `(ln(a x^n)^2)^p/x` was declined. Under `u = ln(a x^n)` it is
`(u^2)^p/n`, a symbolic power of a power of the variable, and the rule for powers of one linear answered that only
where it was the question asked; below it, the rule now reads powers of the variable itself, with no sum in it. Its integral is
`u (u^2)^p/(2 p + 1)` on both sides of `u = 0`, written as `(u^2)^p/u^(2 p)`, constant on each side, times
`u^(2 p + 1)/(2 p + 1)` ([#233](https://github.com/asc-community/AngouriMath/issues/233)).

| Input | Was (2.5.0) | Now |
|---|---|---|
| `"(ln(x)^2)^p/x".ToEntity().Integrate("x")` | `integral(...)` | 79 characters |
| `"(ln(a*x^n)^2)^p/x".ToEntity().Integrate("x")` | `integral(...)` | 107 characters |
| `"(ln(a*x)^3)^p/x".ToEntity().Integrate("x")` | `integral(...)` | 91 characters |

### A polynomial over a power of the linear of an artanh is written in powers of the linear

**Answers where there were none.** `x (a + b atanh(c x))^2/(d + c d x)^3`, Rubi's 7.3.4, ran out of time. In powers of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26501,7 +26501,10 @@ Entity ToThe(EInteger k)
/// </remarks>
internal static Entity? SolvePowersOfOneLinearAsOnePower(Entity expr, Entity.Variable x, bool integrateByParts)
{
if (!Integration.AnsweringTheQuestionAsked)
// Below the top only powers of x itself, with no sum in x to read: `(u^2)^p`, which
// `u = ln(x)` makes of Rubi's 3.5 `(ln(x)^2)^p/x`, is `u (u^2)^p/(2 p + 1)` and was
// declined there.
if (!Integration.AnsweringTheQuestionAsked && expr.Nodes.Any(node => node is Sumf or Minusf && node.ContainsNode(x)))
return null;
// Without a leading `1 *`, which is another spelling to the rules that read the result.
static Entity Times(Entity a, Entity b) => a == Number.Integer.One ? b : a * b;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// Copyright (c) 2019-2026 Angouri.
// AngouriMath is licensed under MIT.
// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
// Website: https://am.angouri.org.
//

using System;
using AngouriMath.Extensions;
using Xunit;

namespace AngouriMath.Tests.Calculus
{
/// <summary>
/// A symbolic power of a power of the variable, asked below the question: <c>u = ln(x)</c> makes
/// Rubi's 3.5 <c>(ln(x)^2)^p/x</c> the question <c>(u^2)^p</c>, which is <c>u (u^2)^p/(2 p + 1)</c>
/// on every branch and was answered only where it was the question asked.
/// <a href="https://github.com/asc-community/AngouriMath/issues/233">#233</a>
/// </summary>
[Trait("Area", "Calculus")]
public sealed class APowerOfASquaredLogarithmOverXIntegralTest
{
[Theory]
[InlineData("(ln(x)^2)^p/x")]
[InlineData("(ln(a*x^n)^2)^p/x")]
[InlineData("(ln(a*x)^3)^p/x")]
public void DifferentiatesBack(string integrand)
{
var integral = integrand.ToEntity().Integrate("x");
Assert.DoesNotContain("integral(", integral.Stringize());
Entity Pinned(Entity e) => e.Substitute("a", 1.3).Substitute("n", 2.0).Substitute("p", 0.35);
var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
var original = Pinned(integrand.ToEntity());
var compared = 0;
// Both sides of ln = 0, where (ln^2)^p is real and ln^(2p) is not.
foreach (var at in new[] { 0.2, 0.5, 0.8, 1.4, 2.6, 4.1 })
{
var want = original.Substitute("x", at).EvalNumerical();
var got = derivative.Substitute("x", at).EvalNumerical();
if (want.IsNaN || got.IsNaN)
continue;
compared++;
Assert.True(Math.Abs((double)(got - want).RealPart) + Math.Abs((double)(got - want).ImaginaryPart)
< 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart) + Math.Abs((double)want.ImaginaryPart)),
$"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}");
}
Assert.True(compared >= 5, $"only {compared} points could be compared for {integrand}");
}
}
}
Loading