Skip to content

Commit d2ebbbb

Browse files
authored
Additional definite integral testing (#659)
1 parent b0e7168 commit d2ebbbb

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

Sources/Tests/UnitTests/Calculus/IntegrationTest.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,27 @@ public sealed class IntegrationTest
1515
{
1616
// TODO: add more tests
1717
[Theory]
18-
[InlineData("2x", "x2 + C")]
19-
[InlineData("x2", "(1/3) * x3 + C")]
20-
[InlineData("x2 + x", "(1/3) * x3 + (1/2) * x2 + C")]
21-
[InlineData("x2 - x", "1/3 * x ^ 3 - 1/2 * x ^ 2 + C")]
22-
[InlineData("a / x", "ln(abs(x)) * a + C")]
18+
[InlineData("2x", "C + x ^ 2")]
19+
[InlineData("x2", "x ^ 3 / 3 + C")]
20+
[InlineData("x2 + x", "x ^ 3 / 3 + x ^ 2 / 2 + C")]
21+
[InlineData("x2 - x", "x ^ 3 / 3 - x ^ 2 / 2 + C")]
22+
[InlineData("a / x", "a * ln(abs(x)) + C")]
2323
[InlineData("x cos(x)", "cos(x) + sin(x) * x + C")]
2424
[InlineData("sin(x)cos(x)", "sin(x) ^ 2 / 2 + C")]
2525
[InlineData("ln(x)", "x * (ln(x) - 1) + C")]
26-
[InlineData("log(a, x)", "x * (ln(x) - 1) / ln(a) + C")]
27-
[InlineData("e ^ x", "e ^ x + C")]
26+
[InlineData("log(a, x)", "C + x * (ln(x) - 1) / ln(a)")]
27+
[InlineData("e ^ x", "C + e ^ x")]
2828
[InlineData("a ^ x", "a ^ x / ln(a) + C")]
29-
[InlineData("sec(a x + b)", "1/2 * ln((1 + sin(a x + b)) / (1 - sin(a x + b))) / a + C")]
30-
[InlineData("csc(a x + b)", "ln(abs(tan(1/2(a x + b)))) / a + C")]
31-
[InlineData("C", "C x + C_1")]
32-
[InlineData("C C_1", "C C_1 x + C_2")]
29+
[InlineData("sec(a x + b)", "1/2 * ln((1 + sin(a * x + b)) / (1 - sin(a * x + b))) / a + C")]
30+
[InlineData("csc(a x + b)", "ln(abs(tan((a * x + b) / 2))) / a + C")]
31+
[InlineData("C", "C_1 + C * x")]
32+
[InlineData("C C_1", "C_2 + C * C_1 * x")]
3333
[InlineData("integral(x, x)", "C_1 + C * x + x ^ 3 / 6")]
3434
[InlineData("e^e^x", "integral(e ^ e ^ x, x)")] // don't recurse infinitely
3535
public void TestIndefinite(string initial, string expected)
3636
{
3737
Assert.Equal(MathS.Boolean.True, initial.Integrate("x").EqualTo(expected).Simplify());
38+
Assert.Equal(expected, MathS.Integral(initial, "x").Simplify().Stringize());
3839
}
3940
[Theory]
4041
[InlineData("2x * e ^ (x2)", "e ^ (x2) + C")]
@@ -200,9 +201,11 @@ public void TestHighPowerSubstitution(string initial, string expected)
200201
[InlineData("sin(x)", "-1", "1", "0")]
201202
[InlineData("cos(x)", "0", "pi", "0")]
202203
[InlineData("1/(x^2+1)", "-oo", "+oo", "pi")]
204+
[InlineData("e^e^x", "0", "1", "integral(e ^ e ^ x, x, 0, 1)")] // don't recurse infinitely
203205
public void TestDefinite(string initial, string from, string to, string expected)
204206
{
205207
Assert.Equal(expected, initial.Integrate("x", from, to).Simplify().Stringize());
208+
Assert.Equal(expected, MathS.Integral(initial, "x", from, to).Simplify().Stringize());
206209
}
207210

208211
[Theory] // TODO: Some of these results can be further simplified, e.g. (4 + 2 * x) / 2

0 commit comments

Comments
 (0)