Skip to content

Commit da2eb2e

Browse files
Rafael-SOWNetclaude
andcommitted
Check the skipped integration case at points, not symbolically
The difference between the derivative and the integrand is zero, but Simplify does not reduce it to zero, so a symbolic assertion would keep failing after the answer became right. Checked at three points instead, and the skip reason now says what actually makes it pass: this fix together with the integration-recursion one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent dc4a66b commit da2eb2e

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,26 @@ public void TestPowerSubstitution(string initial, string expected)
8484
// 3 * x2 * (x3 + 2) ^ 2 -> C + -5/4 * x^6 + (x^3 + 2) * (x^6 / 2 + 2 * x^3)
8585
// which is not an antiderivative of the integrand: at x = 2 the integrand is 1200
8686
// and the derivative of that answer is 1536. The true antiderivative is
87-
// (x^3 + 2)^3 / 3, which differentiates back exactly. The old expectation was
88-
// pinning the wrong answer, so it is asserted here the way it should be and left
89-
// skipped until integration produces it.
90-
[Fact(Skip = "Integration returns a wrong antiderivative here; see the comment above")]
87+
// (x^3 + 2)^3 / 3. The old expectation was pinning the wrong answer, so the case
88+
// is asserted here the way it should be.
89+
//
90+
// Checked at points rather than symbolically: the difference is zero, but Simplify
91+
// does not reduce it to zero, so a symbolic assertion would fail even once the
92+
// answer is right.
93+
[Fact(Skip = "Integration returns a wrong antiderivative here on its own; " +
94+
"it is right once the integration-recursion fix is also applied")]
9195
public void PowerSubstitutionIsAnAntiderivative()
9296
{
9397
var integrand = "3 * x2 * (x3 + 2) ^ 2".ToEntity();
94-
var residual = (integrand.Integrate("x").Differentiate("x") - integrand).Simplify();
95-
Assert.Equal(Entity.Number.Integer.Create(0), residual);
98+
var derivative = integrand.Integrate("x").Differentiate("x");
99+
foreach (var point in new[] { 2, 3, 5 })
100+
{
101+
var expected = integrand.Substitute(x, point).EvalNumerical();
102+
var actual = derivative.Substitute(x, point).Substitute("C", 0).EvalNumerical();
103+
Assert.True((expected - actual).Abs().EDecimal.ToDouble() < 1e-9,
104+
$"at x = {point} the integrand is {expected.Stringize()} "
105+
+ $"but the derivative of the answer is {actual.Stringize()}");
106+
}
96107
}
97108

98109
[Theory]

0 commit comments

Comments
 (0)