diff --git a/src/anti_diff.jl b/src/anti_diff.jl index 8a4c0d3..46ce047 100644 --- a/src/anti_diff.jl +++ b/src/anti_diff.jl @@ -13,7 +13,7 @@ function MP.antidifferentiate(m::Monomial{V,M}, x::Variable{V,M}) where {V,M} Monomial(MP.variables(m), z) * x else z[i] += 1 - Monomial(MP.variables(m), z) / (m.z[i] + 1) + (1 // (m.z[i] + 1)) * Monomial(MP.variables(m), z) end end diff --git a/test/mono.jl b/test/mono.jl index 5bca173..17dd672 100644 --- a/test/mono.jl +++ b/test/mono.jl @@ -148,13 +148,19 @@ import MultivariatePolynomials as MP mi = DynamicPolynomials.MP.antidifferentiate(m, y) @test mi == x * y + # Antidifferentiation is product => Integral coefficients + @test MP.coefficient_type(mi) == Int + + # General antidifferentiation => Rational coefficients m = x^3 mi = DynamicPolynomials.MP.antidifferentiate(m, x) @test mi == (x^4 / 4) + @test MP.coefficient_type(mi) == Rational{Int} m = Monomial([x, y, z], [1, 2, 3]) mi = DynamicPolynomials.MP.antidifferentiate(m, z) @test mi == (x*y^2*z^4) / 4 + @test MP.coefficient_type(mi) == Rational{Int} end @testset "Evaluation" begin