Skip to content

Commit 9b1591d

Browse files
Enhance trigonometric function tests to verify mathematical correctness
Updated tests to verify that integrals produce mathematically correct results: - ∫sin(x)dx derivative should equal sin(x) - ∫cos(x)dx derivative should equal cos(x) - ∫tan(x)dx derivative should equal tan(x) This ensures the Risch method not only runs without errors but produces the correct mathematical results that calculus expects.
1 parent 8df9d1d commit 9b1591d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

test/methods/risch/test_trigonometric_functions.jl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ using Symbolics
1212
@test_nowarn integrate(sin(x), x, RischMethod())
1313
@test_nowarn integrate(cos(x), x, RischMethod())
1414

15-
# Test that the result is computed (not just that it doesn't error)
15+
# Test that the results are mathematically correct
1616
sin_result = integrate(sin(x), x, RischMethod())
1717
cos_result = integrate(cos(x), x, RischMethod())
1818

@@ -21,5 +21,23 @@ using Symbolics
2121
@test cos_result !== nothing
2222
@test sin_result isa Union{Number, SymbolicUtils.BasicSymbolic}
2323
@test cos_result isa Union{Number, SymbolicUtils.BasicSymbolic}
24+
25+
# Test mathematical correctness by verifying derivatives
26+
# ∫sin(x)dx should give -cos(x) (up to constants), so d/dx of result should be sin(x)
27+
@test isequal(Symbolics.derivative(sin_result, x), sin(x))
28+
29+
# ∫cos(x)dx should give sin(x) (up to constants), so d/dx of result should be cos(x)
30+
@test isequal(Symbolics.derivative(cos_result, x), cos(x))
31+
end
32+
33+
@testset "Additional trigonometric functions" begin
34+
# Test more trigonometric functions if the basic ones work
35+
@test_nowarn integrate(tan(x), x, RischMethod())
36+
37+
tan_result = integrate(tan(x), x, RischMethod())
38+
@test tan_result !== nothing
39+
40+
# Verify derivative: d/dx[∫tan(x)dx] = tan(x)
41+
@test isequal(Symbolics.derivative(tan_result, x), tan(x))
2442
end
2543
end

0 commit comments

Comments
 (0)