diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md index 157dfd5af..891e0ae34 100644 --- a/BREAKING-CHANGES.md +++ b/BREAKING-CHANGES.md @@ -2848,6 +2848,36 @@ measured on a build, `v2.5.0` against this change. | `"x^3*e^(2*x)/((x+1)*(x-2))".Integrate("x")` | `integral(x ^ 3 * e ^ (2 * x) / ((x + 1) * (x - 2)), x)` | `e ^ (2 * x) * (-1/4 + 1/2 * x) + e ^ (2 * x) / 2 + 1/3 * e ^ (-2) * Ei(2 * (x + 1)) + 8/3 * e ^ 4 * Ei(2 * (x - 2)) + C` | | `"x*sin(x)/((c+d*x)*(x-2))".Integrate("x")` | `integral(x * sin(x) / ((c + d * x) * (x - 2)), x)` | in `Si` and `Ci` of `(c + d x)/d` and `x - 2` | +### An exponential, hyperbolic or trigonometric function over a quadratic or a binomial is split at its roots + +**Answers where there were none.** `sin(c + d x)/(a + b x^2)` was answered, the rule for a sine or a +cosine writing the quadratic as its leading coefficient times the linears of its two roots, and +`cosh(c + d x)/(a + b x^2)` was declined, as was `e^x/(x^2 + x + 1)`: the rule for an exponential or +`sinh` and `cosh` over several linears read linears only. It writes a quadratic the same way now, +and both rules write a binomial `a + b x^3` or `a + b x^4` as the linears of its roots, +`(a/b)^(1/n)` times the n-th roots of -1. The roots are complex where the discriminant is negative, +and the integrals at conjugate arguments add up to a real answer. An exponential that is not of a linear is not split: +`sinh(sqrt((1 - a x)/(1 + a x)))/(1 - a^2 x^2)` is still answered whole, by its substitution. And +both rules divided a numerator past the degree by the linears of the roots, which with a symbol in +the quadratic left a remainder in the squares of its roots that nothing read: `x^2 sin(c + d x)/(a + b x^2)` +was declined. They divide by the denominator as it is written now. Rubi's 6.2.2, +`(e x)^m (a + b x^n)^p cosh(c + d x)`, its 4.1.11, and exponentials in its 2.3 +([#718](https://github.com/asc-community/AngouriMath/issues/718)). + +| Input | Was (2.5.0) | Now | +|---|---|---| +| `"cosh(c + d*x)/(a + b*x^2)".ToEntity().Integrate("x")` | `integral(...)` | `Chi` and `Shi` of `d (x -/+ sqrt(-4 a b)/(2 b))` | +| `"x*sinh(c + d*x)/(a + b*x^2)".ToEntity().Integrate("x")` | `integral(...)` | the same | +| `"cosh(c + d*x)/(x*(a + b*x^2))".ToEntity().Integrate("x")` | `integral(...)` | the same, and `Chi(d x)` and `Shi(d x)` | +| `"x^3*cosh(c + d*x)/(a + b*x^2)".ToEntity().Integrate("x")` | `integral(...)` | `e^(c + d x)` and `e^(-c - d x)` times linears, and the same | +| `"cosh(x)/(x^2 - 2)".ToEntity().Integrate("x")` | `integral(...)` | `Chi` and `Shi` of `x -/+ sqrt(2)` | +| `"e^(c + d*x)/(a + b*x^2)".ToEntity().Integrate("x")` | `integral(...)` | `Ei` of `d (x -/+ sqrt(-4 a b)/(2 b))` | +| `"e^x/(x^2 + x + 1)".ToEntity().Integrate("x")` | `integral(...)` | `Ei` of `x + (1 -/+ sqrt(-3))/2` | +| `"x^2*sin(c + d*x)/(a + b*x^2)".ToEntity().Integrate("x")` | `integral(...)` | `cos(d x)` and `sin(d x)`, and `Si` and `Ci` of `d (x -/+ sqrt(-4 a b)/(2 b))` | +| `"sin(c + d*x)/(a + b*x^3)".ToEntity().Integrate("x")` | `integral(...)` | `Si` and `Ci` of `d` times `x` less each root of `a + b x^3` | +| `"cosh(c + d*x)/(a + b*x^3)".ToEntity().Integrate("x")` | `integral(...)` | `Chi` and `Shi` the same | +| `"e^x/(a + b*x^4)".ToEntity().Integrate("x")` | `integral(...)` | `Ei` of `x` less each root of `a + b x^4` | + ### An inverse trigonometric function below the bar is integrated to the sine and cosine integrals `1/arcsin(x)` was left unintegrated. Under the substitution that undoes the inverse function, diff --git a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs index f338c8c80..402d52850 100644 --- a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs +++ b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs @@ -4740,7 +4740,8 @@ bool Read(Entity factor, int times) /// . e^x/(x (x + 1)) is /// e^x/x - e^x/(x + 1), which is Ei(x) - Ei(x + 1)/e; the trigonometric rule /// splits the same way (). It is also what by parts leaves - /// of Ei(a + b x)/x^2, e^(a + b x)/((a + b x) x). + /// of Ei(a + b x)/x^2, e^(a + b x)/((a + b x) x). A quadratic below the bar is + /// the linears of its two roots: Rubi's 6.2.2, cosh(c + d x)/(a + b x^2). /// https://github.com/asc-community/AngouriMath/issues/1501 /// internal static Entity? SolveAnExponentialOverSeveralLinears(Entity expr, Entity.Variable x) @@ -4751,6 +4752,16 @@ bool Read(Entity factor, int times) var linears = new List<(Entity Linear, int Power)>(); Entity? polynomial = null; Entity? exponentials = null; + // The denominator as it is written, each quadratic monic, for the division. + Entity written = Number.Integer.One; + void AddALinear(Entity linear, int power) + { + var at = linears.FindIndex(pair => pair.Linear == linear); + if (at < 0) + linears.Add((linear, power)); + else + linears[at] = (linear, linears[at].Power + power); + } foreach (var (factor, underneath) in FactorsOfTheIntegrand(expr)) { if (!factor.ContainsNode(x)) @@ -4764,11 +4775,30 @@ bool Read(Entity factor, int times) exponent = -exponent; if (exponent < 0 && TreeAnalyzer.TryGetPolyLinear(@base, x, out var slopeOfIt, out _) && !TreeAnalyzer.IsZero(slopeOfIt)) { - var at = linears.FindIndex(pair => pair.Linear == @base); - if (at < 0) - linears.Add((@base, -exponent)); - else - linears[at] = (@base, linears[at].Power - exponent); + AddALinear(@base, -exponent); + written *= MathS.Pow(@base, -exponent); + continue; + } + // A quadratic is its leading coefficient times the linears of its two roots, complex + // where its discriminant is negative, as the trigonometric rule writes it: + // `cosh(c + d x)/(a + b x^2)` is a sum over `x -/+ sqrt(-a/b)`, each the one-linear + // question, and the integrals of the two conjugate arguments add up to a real answer. + if (exponent < 0 && TreeAnalyzer.TryGetPolyQuadratic(@base, x, out var leading, out var middle, out var last) && !TreeAnalyzer.IsZero(leading)) + { + var discriminant = MathS.Sqrt(middle * middle - 4 * leading * last); + constant /= MathS.Pow(leading, -exponent); + AddALinear(LessTheRoot(((-middle + discriminant) / (2 * leading)).InnerSimplified, x), -exponent); + AddALinear(LessTheRoot(((-middle - discriminant) / (2 * leading)).InnerSimplified, x), -exponent); + written *= MathS.Pow(Monic(leading, middle, last, x), -exponent); + continue; + } + // And a binomial past the quadratic the linears of its roots: `cosh(c + d x)/(a + b x^3)`. + if (exponent < 0 && TheRootsOfABinomial(@base, x) is { } binomial) + { + constant /= MathS.Pow(binomial.Leading, -exponent); + foreach (var root in binomial.Roots) + AddALinear(LessTheRoot(root, x), -exponent); + written *= MathS.Pow(binomial.Monic, -exponent); continue; } if (underneath) @@ -4787,31 +4817,15 @@ bool Read(Entity factor, int times) } if (exponentials is null || linears.Count < 2 || linears.Count > 4 || linears.Sum(pair => pair.Power) > 12) return null; - // Over each linear by partial fractions, the polynomial part first, since the split is - // of a proper fraction -- as the trigonometric rule does it. Only where the fraction is - // not proper already: divided, `x` over `(c + d x)(x - 2)` came back as a quotient and a - // remainder `2 provided not c + d x = 0`, which nothing splits. + // Exponentials of linears only, which is what the one-linear rules read: split, a term of + // `sinh(sqrt((1 - a x)/(1 + a x)))/(1 - a^2 x^2)` goes to the whole integrator, and the + // substitution that answers the question whole in a tenth of a second is not reached. + if (!Sumf.LinearChildren(exponentials.Expand()).All(term => ReadAnExponentialTerm(term, x) is not null)) + return null; + // Over each linear by partial fractions, as the trigonometric rule does it. var denominator = linears.Aggregate((Entity)Number.Integer.One, (product, pair) => product * MathS.Pow(pair.Linear, pair.Power)); - Entity numerator = polynomial ?? Number.Integer.One; - var terms = new List(); - if (numerator.ContainsNode(x) - && TreeAnalyzer.TryGetPolynomial(numerator, x, out var monomialsAbove) - && monomialsAbove.Keys.Any(degree => degree.CompareTo(EInteger.FromInt32(linears.Sum(pair => pair.Power))) >= 0) - && TreeAnalyzer.PolynomialLongDivision(numerator, denominator, genericCase: true, inTermsOf: x) is var (quotient, remainder)) - { - if (!TreeAnalyzer.IsZero(quotient)) - terms.Add(quotient); - numerator = remainder is Divf(var left, _) ? left : (numerator - quotient * denominator).Expand().InnerSimplified; - } - if (!TreeAnalyzer.IsZero(numerator)) - { - if (!Functions.PartialFractions.TrySplitOverWrittenFactors(numerator, denominator, x, out var decomposition)) - return null; - var fractions = decomposition.InnerSimplified; - if (fractions is Divf(var over, var by) && !by.ContainsNode(x)) - fractions = Sumf.LinearChildren(over).Aggregate((Entity)Number.Integer.Zero, (all, one) => all + one / by); - terms.AddRange(Sumf.LinearChildren(fractions)); - } + if (OverEachLinear(polynomial ?? Number.Integer.One, written, denominator, linears.Sum(pair => pair.Power), x) is not { } terms) + return null; Entity sum = Number.Integer.Zero; foreach (var term in terms) { @@ -5513,6 +5527,72 @@ void Add(int k, bool isSine, Entity coefficient) return UnderAPowerOfTheVariable(expr, x, argument); } + // x - r, written x + |r| where the root is a negative number: x + 1 for the root -1. + private static Entity LessTheRoot(Entity root, Entity.Variable x) => + root is Number.Complex { RealPart.IsNegative: true } or Number.Complex { RealPart.EDecimal.IsZero: true, ImaginaryPart.IsNegative: true } + ? x + (-root).InnerSimplified : (x - root).InnerSimplified; + + // A quadratic divided by its leading coefficient, `x^2 + (b/a) x + c/a`, in the generic + // case: the division declines a divisor with a condition on it. + private static Entity Monic(Entity leading, Entity middle, Entity last, Entity.Variable x) => + Functions.PartialFractions.Bare((MathS.Sqr(x) + middle / leading * x + last / leading).InnerSimplified); + + // `a + b x^n` for an n of 3 or 4, as its leading coefficient, its n roots, and itself monic in + // the generic case. The roots are `(a/b)^(1/n)` times the n-th roots of -1, `e^(i pi (2k + 1)/n)`: + // only their n-th power is used, so they are the roots whichever branch the n-th root takes. + private static (Entity Leading, Entity[] Roots, Entity Monic)? TheRootsOfABinomial(Entity binomial, Entity.Variable x) + { + if (!TreeAnalyzer.TryGetPolynomial(binomial, x, out var terms) || terms.Count != 2 + || !terms.TryGetValue(EInteger.Zero, out var free) || free.ContainsNode(x) || TreeAnalyzer.IsZero(free)) + return null; + var top = terms.First(term => !term.Key.IsZero); + if (top.Value.ContainsNode(x) || TreeAnalyzer.IsZero(top.Value) || !top.Key.CanFitInInt32() || top.Key.ToInt32Checked() is not (3 or 4)) + return null; + var n = top.Key.ToInt32Checked(); + var scale = MathS.Pow(Functions.PartialFractions.InLowestTermsOverTheSymbols(free / top.Value), Number.Rational.Create(1, n)); + Entity[] rootsOfMinusOne = n == 3 + ? new Entity[] { -1, (1 + MathS.i * MathS.Sqrt(3)) / 2, (1 - MathS.i * MathS.Sqrt(3)) / 2 } + : new Entity[] { (1 + MathS.i) / MathS.Sqrt(2), (1 - MathS.i) / MathS.Sqrt(2), (-1 + MathS.i) / MathS.Sqrt(2), (-1 - MathS.i) / MathS.Sqrt(2) }; + return (top.Value, rootsOfMinusOne.Select(root => (root * scale).InnerSimplified).ToArray(), + Functions.PartialFractions.Bare((MathS.Pow(x, n) + free / top.Value).InnerSimplified)); + } + + /// + /// over a denominator as terms each over one linear: the + /// polynomial part first, divided by the denominator as it is , + /// and the proper rest split into partial fractions over , + /// the same denominator with each quadratic in it written as the linears of its roots. + /// Divided by those linears, `x^2` over `(x - r)(x + r)`, `r = sqrt(-a/b)`, left a remainder + /// in `r^2` that nothing read as `-a/b`. Only where the fraction is not proper already: + /// divided, `x` over `(c + d x)(x - 2)` came back as a quotient and a remainder + /// `2 provided not c + d x = 0`, which nothing splits. Null where the split declines. + /// + private static List? OverEachLinear(Entity numerator, Entity written, Entity overTheLinears, int degreeBelow, Entity.Variable x) + { + var terms = new List(); + if (numerator.ContainsNode(x) + && TreeAnalyzer.TryGetPolynomial(numerator, x, out var monomialsAbove) + && monomialsAbove.Keys.Any(degree => degree.CompareTo(EInteger.FromInt32(degreeBelow)) >= 0) + && TreeAnalyzer.PolynomialLongDivision(numerator, written, genericCase: true, inTermsOf: x) is var (quotient, remainder)) + { + if (!TreeAnalyzer.IsZero(quotient)) + terms.Add(quotient); + // The remainder comes over the divisor already. + numerator = remainder is Divf(var left, _) ? left : (numerator - quotient * written).Expand().InnerSimplified; + } + if (!TreeAnalyzer.IsZero(numerator)) + { + if (!Functions.PartialFractions.TrySplitOverWrittenFactors(numerator, overTheLinears, x, out var decomposition)) + return null; + // The sum of the fractions, over a constant it may come divided by. + var fractions = decomposition.InnerSimplified; + if (fractions is Divf(var over, var by) && !by.ContainsNode(x)) + fractions = Sumf.LinearChildren(over).Aggregate((Entity)Number.Integer.Zero, (all, one) => all + one / by); + terms.AddRange(Sumf.LinearChildren(fractions)); + } + return terms; + } + /// /// where the argument is /// , linear in . Two or more linears below @@ -5529,6 +5609,8 @@ void Add(int k, bool isSine, Entity coefficient) var linears = new List<(Entity Linear, int Power)>(); Entity? polynomial = null; Entity? trigonometric = null; + // The denominator as it is written, each quadratic monic, for the division. + Entity written = Number.Integer.One; void AddALinear(Entity linear, int power) { var at = linears.FindIndex(pair => pair.Linear == linear); @@ -5537,10 +5619,6 @@ void AddALinear(Entity linear, int power) else linears[at] = (linear, linears[at].Power + power); } - // x - r, written x + |r| where the root is a negative number: x + 1 for the root -1. - Entity LessTheRoot(Entity root) => - root is Number.Complex { RealPart.IsNegative: true } or Number.Complex { RealPart.EDecimal.IsZero: true, ImaginaryPart.IsNegative: true } - ? x + (-root).InnerSimplified : (x - root).InnerSimplified; foreach (var (factor, underneath) in FactorsOfTheIntegrand(expr)) { if (!factor.ContainsNode(x)) @@ -5571,7 +5649,10 @@ Entity LessTheRoot(Entity root) => if (exponent < 0) { if (TreeAnalyzer.TryGetPolyLinear(@base, x, out var slopeOfIt, out _) && !TreeAnalyzer.IsZero(slopeOfIt)) + { AddALinear(@base, -exponent); + written *= MathS.Pow(@base, -exponent); + } // A quadratic is its leading coefficient times the linears of its two roots, // complex where its discriminant is negative: `sin(c + d x)/(a + b x^2)` is a // sum over `x -/+ sqrt(-a/b)`, each the one-linear question, and the sine and @@ -5582,8 +5663,17 @@ Entity LessTheRoot(Entity root) => var first = ((-middle + discriminant) / (2 * leading)).InnerSimplified; var second = ((-middle - discriminant) / (2 * leading)).InnerSimplified; constant /= MathS.Pow(leading, -exponent); - AddALinear(LessTheRoot(first), -exponent); - AddALinear(LessTheRoot(second), -exponent); + AddALinear(LessTheRoot(first, x), -exponent); + AddALinear(LessTheRoot(second, x), -exponent); + written *= MathS.Pow(Monic(leading, middle, last, x), -exponent); + } + // And a binomial past the quadratic the linears of its roots: `sin(c + d x)/(a + b x^3)`. + else if (TheRootsOfABinomial(@base, x) is { } binomial) + { + constant /= MathS.Pow(binomial.Leading, -exponent); + foreach (var root in binomial.Roots) + AddALinear(LessTheRoot(root, x), -exponent); + written *= MathS.Pow(binomial.Monic, -exponent); } else return null; @@ -5603,32 +5693,10 @@ Entity LessTheRoot(Entity root) => return AgainstAPowerOfALinear(polynomial, linears[0].Linear, linears[0].Power, angles, argument, x, needsAnIntegral: true) is var (one, _) && one is not null ? Functions.PartialFractions.Bare((constant * one).InnerSimplified) : null; - // Over each linear by partial fractions, and each term the one-linear question; the - // polynomial part first, since the split is of a proper fraction -- and only where it is - // not proper already, as in SolveAnExponentialOverSeveralLinears. + // Over each linear by partial fractions, and each term the one-linear question. var denominator = linears.Aggregate((Entity)Number.Integer.One, (product, pair) => product * MathS.Pow(pair.Linear, pair.Power)); - Entity numerator = polynomial ?? Number.Integer.One; - var terms = new List(); - if (numerator.ContainsNode(x) - && TreeAnalyzer.TryGetPolynomial(numerator, x, out var monomialsAbove) - && monomialsAbove.Keys.Any(degree => degree.CompareTo(EInteger.FromInt32(linears.Sum(pair => pair.Power))) >= 0) - && TreeAnalyzer.PolynomialLongDivision(numerator, denominator, genericCase: true, inTermsOf: x) is var (quotient, remainder)) - { - if (!TreeAnalyzer.IsZero(quotient)) - terms.Add(quotient); - // The remainder comes over the divisor already. - numerator = remainder is Divf(var left, _) ? left : (numerator - quotient * denominator).Expand().InnerSimplified; - } - if (!TreeAnalyzer.IsZero(numerator)) - { - if (!Functions.PartialFractions.TrySplitOverWrittenFactors(numerator, denominator, x, out var decomposition)) - return null; - // The sum of the fractions, over a constant it may come divided by. - var fractions = decomposition.InnerSimplified; - if (fractions is Divf(var over, var by) && !by.ContainsNode(x)) - fractions = Sumf.LinearChildren(over).Aggregate((Entity)Number.Integer.Zero, (all, one) => all + one / by); - terms.AddRange(Sumf.LinearChildren(fractions)); - } + if (OverEachLinear(polynomial ?? Number.Integer.One, written, denominator, linears.Sum(pair => pair.Power), x) is not { } terms) + return null; Entity sum = Number.Integer.Zero; var special = false; foreach (var term in terms) diff --git a/Sources/Tests/UnitTests/Calculus/HyperbolicIntegralIntegrationTest.cs b/Sources/Tests/UnitTests/Calculus/HyperbolicIntegralIntegrationTest.cs index 7b7282918..aa55682f1 100644 --- a/Sources/Tests/UnitTests/Calculus/HyperbolicIntegralIntegrationTest.cs +++ b/Sources/Tests/UnitTests/Calculus/HyperbolicIntegralIntegrationTest.cs @@ -78,6 +78,50 @@ public void ASumOfExponentialsOverAPowerOfALinear(string integrand) public void ASumOfExponentialsOverSeveralLinears(string integrand) => DifferentiatesBack(integrand, AroundZero, Pins); + /// + /// And over a quadratic, which is the linears of its two roots, complex where its + /// discriminant is negative, the integrals of the two conjugate arguments adding up to a + /// real answer. Rubi's 6.2.2, cosh(c + d x)/(a + b x^2); a numerator past the degree + /// is divided by the quadratic as it is written. + /// + [Theory] + [InlineData("cosh(c + d*x)/(a + b*x^2)")] + [InlineData("x^2*cosh(c + d*x)/(a + b*x^2)")] + [InlineData("x^3*cosh(c + d*x)/(a + b*x^2)")] + [InlineData("x^2*e^(c + d*x)/(a + b*x^2)")] + [InlineData("sinh(c + d*x)/(a - b*x^2)")] + [InlineData("x*sinh(c + d*x)/(a + b*x^2)")] + [InlineData("cosh(c + d*x)/(x*(a + b*x^2))")] + [InlineData("x^2*cosh(c + d*x)/(a + b*x^2)^2")] + [InlineData("cosh(x)/(x^2 - 2)")] + [InlineData("e^x/(x^2 + x + 1)")] + public void ASumOfExponentialsOverAQuadratic(string integrand) + => DifferentiatesBack(integrand, AroundZero, Pins); + + /// + /// And over a binomial past the quadratic, a + b x^3 or a + b x^4, which is the + /// linears of its roots, (a/b)^(1/n) times the n-th roots of -1. + /// + [Theory] + [InlineData("cosh(c + d*x)/(a + b*x^3)")] + [InlineData("x*cosh(c + d*x)/(a + b*x^3)")] + [InlineData("cosh(c + d*x)/(x*(a + b*x^3))")] + [InlineData("cosh(x)/(1 + x^3)")] + [InlineData("e^x/(a + b*x^4)")] + public void ASumOfExponentialsOverABinomial(string integrand) + => DifferentiatesBack(integrand, AroundZero, Pins); + + /// + /// An exponential of something other than a linear is not split over the linears below + /// it: sinh(sqrt((1 - a x)/(1 + a x)))/(1 - a^2 x^2) is a substitution's, answered + /// whole, where each term of the split would go to the whole integrator. + /// + [Theory] + [InlineData("sinh(sqrt(1 - a*x)/sqrt(1 + a*x))/(1 - a^2*x^2)")] + [InlineData("cosh(sqrt(1 - a*x)/sqrt(1 + a*x))^3/(1 - a^2*x^2)")] + public void AnExponentialOfSomethingElseIsNotSplit(string integrand) + => DifferentiatesBack(integrand, AroundZero, Pins); + /// /// An inverse hyperbolic tangent below the bar, beside a whole power of 1 - a^2 x^2: /// under x = tanh(u)/a it is a polynomial in sinh(u) and cosh(u) over diff --git a/Sources/Tests/UnitTests/Calculus/TrigonometricIntegralIntegrationTest.cs b/Sources/Tests/UnitTests/Calculus/TrigonometricIntegralIntegrationTest.cs index 478d248c0..a820c8f9f 100644 --- a/Sources/Tests/UnitTests/Calculus/TrigonometricIntegralIntegrationTest.cs +++ b/Sources/Tests/UnitTests/Calculus/TrigonometricIntegralIntegrationTest.cs @@ -97,7 +97,10 @@ public void OverSeveralLinears(string integrand) /// A quadratic below the bar is its leading coefficient times the linears of its two /// roots, complex where its discriminant is negative, and the sine and cosine integrals of /// the two conjugate arguments add up to a real answer. Rubi's 4.1.11 and 4.7.7, - /// sin(c + d x)/(a + b x^2) and sin(a + b x)/(c + d x + e x^2). + /// sin(c + d x)/(a + b x^2) and sin(a + b x)/(c + d x + e x^2), and a binomial past + /// it, a + b x^3 or a + b x^4, the linears of its roots. A numerator past the degree + /// is divided by the denominator as it is written, since the remainder of a division by the + /// linears of symbolic roots was left in their powers. /// [Theory] [InlineData("sin(x)/(1 + x^2)")] @@ -106,6 +109,13 @@ public void OverSeveralLinears(string integrand) [InlineData("sin(c + d*x)/(a + b*x^2)")] [InlineData("cos(x)/(x*(1 + x^2))")] [InlineData("sin(x)/(1 + x^2)^2")] + [InlineData("x^2*sin(c + d*x)/(a + b*x^2)")] + [InlineData("x^3*cos(c + d*x)/(a + b*x^2)")] + [InlineData("sin(c + d*x)/(a + b*x^3)")] + [InlineData("x^3*sin(c + d*x)/(a + b*x^3)")] + [InlineData("sin(c + d*x)/(a + b*x^3)^2")] + [InlineData("sin(x)/(1 + x^4)")] + [InlineData("x*sin(x)/(1 + x^3)")] public void OverAQuadratic(string integrand) => DifferentiatesBack(integrand, AroundZero, Pins); diff --git a/Sources/Tests/UnitTests/Calculus/TrigonometricTowerAnsatzTest.cs b/Sources/Tests/UnitTests/Calculus/TrigonometricTowerAnsatzTest.cs index e9fb37e72..c4064679e 100644 --- a/Sources/Tests/UnitTests/Calculus/TrigonometricTowerAnsatzTest.cs +++ b/Sources/Tests/UnitTests/Calculus/TrigonometricTowerAnsatzTest.cs @@ -96,7 +96,7 @@ public void TheAnswerIsInTheSineAndCosine() [InlineData("tan(x)/x")] [InlineData("x/sin(x)")] [InlineData("x*tan(x)")] - [InlineData("x*sin(x)/(1 + x^3)")] + [InlineData("x*sin(x)/(1 + x + x^3)")] public void ANonElementaryOneIsDeclined(string integrand) => Assert.Contains("integral(", integrand.ToEntity().Integrate("x").Stringize()); }