Closed chrhansk closed 3 months ago
Looks very good thanks. Maybe we should go for Rational{Int}
if the current coefficient type is Int
? So create some custom _div
that uses /
if AbstractFloat
and //
otherwise. Note that 1 // 2
is used here
https://github.com/JuliaAlgebra/MultivariatePolynomials.jl/blob/master/src/antidifferentiation.jl#L30
so it's consistent with that
Done.
Is there anything else needed or is this ready to merge?
I was indeed unaware of the existence of that particular function. The problem should be fixed by now.
I also noticed another aspect regarding the monomials: The antidifferentiation of a monomial yields a term with a Float64
type. We could make this a Rational{Int}
instead (similarly to the polynomial case). What is your opinion on this?
Yes, this should also be Rational{Int}
OK, I adjusted the implementation accordingly.
Thanks, let's wait to see the CI results but looks good to me
This patch adds an implementation of the
antidifferentiate
function for both monomials and polynomials (fixing #157).The function
antidifferentiate(p, x)
works by either returning the productp*x
ifp
has no term with variablex
, or by incrementing the powers and adjusting the coefficients to match (thereby always ensuring that the antiderivative evaluates to zero wheneverx
is zero).I included some basic unit tests as well. I did not run
JuliaFormatter.jl
over the codebase, since numerous other files are not formatted according to those formatting rules...Let me know if anything is missing. If this lands, I would appreciated a new version to be used in my own project.