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
13 changes: 13 additions & 0 deletions BREAKING-CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,19 @@ polynomial exponent in `u` now, and the question asked in `u`. Rubi's 2.3
| `"F^(a + b/(c + d*x))/(c + d*x)".ToEntity().Integrate("x")` | `integral(...)` | an exponential integral |
| `"F^(a + b/(c + d*x)^3)*(c + d*x)^2".ToEntity().Integrate("x")` | `integral(...)` | an exponential integral of the cube, and the exponential |

### A power of a monomial in a symbolic power of `x` is integrated as the power of `x` it is

**Answers where there were none.** `(c x^n)^b` is written `c^b x^(n b)`, and the exponent `n b` was
left as the inner simplification leaves it: `(c x^n)^(2/n)` came out as `c^(2/n) x^(n (2/n))`, which
no rule reads as `x^2`, and `1/(a + b (c x^n)^(2/n))` was declined where `1/(a + b c^(2/n) x^2)` is
answered. The exponent is simplified now. Rubi's 1.1.3.2
([#718](https://github.com/asc-community/AngouriMath/issues/718)).

| Input | Was (2.5.0) | Now |
|---|---|---|
| `"1/(a + b*(c*x^n)^(2/n))".ToEntity().Integrate("x")` | `integral(...)` | an arctangent or a logarithm in `b c^(2/n) x`, by the sign of `a b c^(2/n)` |
| `"1/(1 + 4*(x^(2*n))^(1/n))".ToEntity().Integrate("x")` | `integral(...)` | `arctan(2 x)/2` |

### A function of a quotient of two linears is integrated over the quotient's denominator

**Answers where there were none.** `sin((a + b x)/(c + d x))` and its powers were declined, and so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25416,7 +25416,11 @@ Entity Rewritten(Entity side, Number.Integer sign)
assumed = assumed == Entity.Boolean.True ? positive : assumed & positive;
}
changed = true;
var distributed = split ? MathS.Pow(x, (degree! * exponent).InnerSimplified) : MathS.Pow(rest, exponent);
// The exponent of x as it simplifies: `(c x^n)^(2/n)` is `c^(2/n) x^(n (2/n))`, and that
// power of x is `x^2` only once `n (2/n)` is folded, which the inner simplification
// leaves standing -- `1/(a + b (c x^n)^(2/n))` was declined where `1/(a + b c^(2/n) x^2)`
// is answered. Exponents are small.
var distributed = split ? MathS.Pow(x, SimplifiedExponent((degree! * exponent).InnerSimplified)) : MathS.Pow(rest, exponent);
return constant == Number.Integer.One ? distributed : MathS.Pow(constant, exponent) * distributed;
});
if (!changed)
Expand All @@ -25432,6 +25436,9 @@ Entity Rewritten(Entity side, Number.Integer sign)
if (Integration.ComputeAsTheSameQuestion(rewritten, x, integrateByParts) is not { } answer)
return null;
return assumed == Entity.Boolean.True ? answer : answer.Provided(assumed);

static Entity SimplifiedExponent(Entity exponent)
=> exponent is Number || exponent.Complexity > 40 ? exponent : Functions.PartialFractions.Bare(exponent.Simplify());
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// 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 power of a monomial in a symbolic power of x, distributed with its exponent of x
/// simplified: <c>(c x^n)^(2/n)</c> is <c>c^(2/n) x^2</c>. Rubi's 1.1.3.2.
/// <a href="https://github.com/asc-community/AngouriMath/issues/718">#718</a>
/// </summary>
/// <remarks>
/// Checked by differentiating back with <c>a = 1.3</c>, <c>b = 0.7</c>, <c>c = 0.4</c> and
/// <c>n = 1.7</c>, at positive x, where a symbolic power of it is real.
/// </remarks>
[Trait("Area", "Calculus")]
public sealed class DistributedPowerOfAMonomialIntegralTest
{
[Theory]
[InlineData("1/(a + b*(c*x^n)^(2/n))")]
[InlineData("1/(x^2*(a + b*(c*x^n)^(1/n)))")]
[InlineData("1/(a + b*(c*x^n)^(3/n))")]
[InlineData("1/(1 + 4*(x^(2*n))^(1/n))")]
public void IsIntegrated(string integrand)
{
var integral = integrand.ToEntity().Integrate("x");
Assert.DoesNotContain("integral(", integral.Stringize());
Entity Pinned(Entity e) => e.Substitute("a", 1.3).Substitute("b", 0.7).Substitute("c", 0.4).Substitute("n", 1.7);
var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
var original = Pinned(integrand.ToEntity());
foreach (var at in new[] { 0.3, 0.8, 1.4, 2.1 })
{
var want = original.Substitute("x", at).EvalNumerical();
var got = derivative.Substitute("x", at).EvalNumerical();
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}");
}
}
}
}
Loading