Skip to content

Commit fb527ae

Browse files
Multiples of one linear argument are written in it with x beside them in a linear (#1863)
* Multiples of one linear argument are written in it with x beside them in a linear Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura * Breaking-changes entry for multiples of one linear argument with x beside them Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent c267991 commit fb527ae

3 files changed

Lines changed: 45 additions & 7 deletions

File tree

‎BREAKING-CHANGES.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,6 +2319,21 @@ one reads a numeric slope, and writes an offset out by the addition formula, whi
23192319
| `"csc(1+x)*csc(2+2*x)^2".ToEntity().Integrate("x")` | `integral(...)` | an antiderivative in `cos(1 + x)` |
23202320
| `"sin(a+b*x)^3/sin(2*a+2*b*x)^(3/2)".ToEntity().Integrate("x")` | `integral(...)` | an antiderivative in `tan(a + b x)` |
23212321

2322+
### Multiples of one linear argument are written in it with `x` beside them in a linear
2323+
2324+
`csc(a + b x) sin(3a + 3b x)/(c + d x)` was left unevaluated, and so was each power of `c + d x`
2325+
below the bar. Writing the arguments in `u = a + b x` declined wherever `x` stood outside them as
2326+
well. Where it stands there only in sums, products and powers, it is written in `u` too, as
2327+
`(u - a)/b`, and the linears in the answer are put back in lowest terms. Rubi's 4.7.3
2328+
([#718](https://github.com/asc-community/AngouriMath/issues/718), PR
2329+
[#1863](https://github.com/asc-community/AngouriMath/pull/1863)).
2330+
2331+
| Input | Was (2.5.0) | Now |
2332+
|---|---|---|
2333+
| `"csc(a+b*x)*sin(3*a+3*b*x)/(c+d*x)".ToEntity().Integrate("x")` | `integral(...)` | 190 characters, in `ln`, `Si` and `Ci` of a multiple of `c + d x` |
2334+
| `"csc(a+b*x)*sin(3*a+3*b*x)/(c+d*x)^4".ToEntity().Integrate("x")` | `integral(...)` | 736 characters |
2335+
| `"csc(2+3*x)*sin(6+9*x)/(c+d*x)".ToEntity().Integrate("x")` | `integral(...)` | 194 characters |
2336+
23222337
### A function of one linear under a power inside a sum is written in that linear
23232338

23242339
`x^3/(a + b (c + d x)^3)` was left unevaluated, and `(c + d x)^4/(a + b (c + d x)^3)` ran for more

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13297,8 +13297,10 @@ Entity Named(Entity value)
1329713297
/// <c>csc(1 + x) csc(2 + 2x)^2</c> became a rational function of the sine and cosine with
1329813298
/// <c>sin(2)</c> and <c>cos(2)</c> in its coefficients, and ran twenty seconds; with the slope
1329913299
/// a symbol it declined at once. Only where some argument has an offset or a symbolic
13300-
/// slope, the rest being that rule's already, and where x stands nowhere else. At the
13301-
/// question asked or one below it, since it lands on the chain in u. Rubi's 4.7.1.
13300+
/// slope, the rest being that rule's already, and where x stands elsewhere only
13301+
/// algebraically: <c>csc(a + b x) sin(3a + 3b x)/(c + d x)</c> is
13302+
/// <c>csc(u) sin(3u)/(b c + d (u - a))</c> over <c>b</c>, Rubi's 4.7.3. At the question
13303+
/// asked or one below it, since it lands on the chain in u. Rubi's 4.7.1.
1330213304
/// https://github.com/asc-community/AngouriMath/issues/718
1330313305
/// </remarks>
1330413306
internal static Entity? SolveByWritingMultiplesOfOneLinearArgument(Entity expr, Entity.Variable x, bool integrateByParts)
@@ -13348,12 +13350,26 @@ Entity Named(Entity value)
1334813350
Cosecantf(var a) when Of(a) is { } v => new Cosecantf(v),
1334913351
_ => node,
1335013352
});
13351-
if (inU.ContainsNode(x))
13352-
return null;
13353+
// x beside the functions as well, algebraically -- `csc(a + b x) sin(3a + 3b x)/(c + d x)`
13354+
// -- is written in u too, x = (u - p)/q.
13355+
var beside = inU.ContainsNode(x);
13356+
if (beside)
13357+
{
13358+
if (inU.Nodes.Any(node => node.ContainsNode(x) && node is not (Variable or Sumf or Minusf or Mulf or Divf)
13359+
&& !(node is Powf(_, var exponent) && !exponent.ContainsNode(x))))
13360+
return null;
13361+
inU = inU.Substitute(x, (u - firstOffset) / firstSlope).InnerSimplified;
13362+
}
1335313363
// dx = du/q.
1335413364
if (Integration.ComputeAsAQuestionOfItsOwn((inU / firstSlope).InnerSimplified, u, integrateByParts) is not { } answer)
1335513365
return null;
1335613366
var back = answer.Substitute(u, first);
13367+
// And each linear the substitution wrote, `b c + d (a + b x - a)`, back in lowest terms.
13368+
if (beside)
13369+
back = back.Replace(node => node is Sumf or Minusf && node.ContainsNode(x)
13370+
&& TreeAnalyzer.TryGetPolyLinear(node, x, out var slope, out var offset) && !slope.ContainsNode(x) && !offset.ContainsNode(x)
13371+
? LowestOverTheSymbols(slope) * x + LowestOverTheSymbols(offset)
13372+
: node).InnerSimplified;
1335713373
return back.Nodes.Any(node => node == MathS.NaN) ? null : back;
1335813374
}
1335913375

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,29 @@ private static void DifferentiatesBack(string integrand, string variable = "x")
7777
/// Multiples of one linear with an offset or a symbolic slope, written in that linear:
7878
/// <c>csc(1 + x) csc(2 + 2x)^2</c> ran twenty seconds with the offsets written out by the
7979
/// addition formula, and <c>csc(a + b x) csc(2a + 2b x)^2</c> was declined for its slope.
80-
/// Rubi's 4.7.1.
80+
/// Rubi's 4.7.1; and with x beside them in a linear, <c>csc(a + b x) sin(3a + 3b x)/(c + d x)</c>,
81+
/// which was declined whatever the slope, Rubi's 4.7.3.
8182
/// </summary>
8283
[Theory]
8384
[InlineData("csc(1 + x)*csc(2 + 2*x)^2")]
8485
[InlineData("sin(3 + 3*x)/sin(1 + x)")]
86+
[InlineData("csc(2 + 3*x)*sin(6 + 9*x)/(1 + x)")]
87+
[InlineData("csc(2 + 3*x)*sin(6 + 9*x)/(1 + x)^2")]
8588
public void MultiplesOfOneLinearArgument(string integrand) => DifferentiatesBack(integrand);
8689

8790
[Theory]
8891
[InlineData("csc(a + b*x)*csc(2*a + 2*b*x)^2")]
8992
[InlineData("cos(a + b*x)^2/sin(2*a + 2*b*x)^5")]
93+
[InlineData("csc(a + b*x)*sin(3*a + 3*b*x)/(c + d*x)")]
94+
[InlineData("csc(a + b*x)*sin(3*a + 3*b*x)/(c + d*x)^2")]
95+
[InlineData("csc(a + b*x)*sin(3*a + 3*b*x)/(c + d*x)^4")]
9096
public void MultiplesOfOneLinearArgumentWithASymbolicSlope(string integrand)
9197
{
9298
var integral = integrand.ToEntity().Integrate("x");
9399
Assert.DoesNotContain("integral(", integral.Stringize());
94-
var derivative = integral.Substitute("C", 0).Differentiate("x").Substitute("a", 0.3).Substitute("b", 1.2);
95-
var original = integrand.ToEntity().Substitute("a", 0.3).Substitute("b", 1.2);
100+
var derivative = integral.Substitute("C", 0).Differentiate("x")
101+
.Substitute("a", 0.3).Substitute("b", 1.2).Substitute("c", 0.7).Substitute("d", 1.3);
102+
var original = integrand.ToEntity().Substitute("a", 0.3).Substitute("b", 1.2).Substitute("c", 0.7).Substitute("d", 1.3);
96103
var compared = 0;
97104
foreach (var at in new[] { 0.3, 0.5, 0.9, 1.1 })
98105
{

0 commit comments

Comments
 (0)