-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Antidifferentiation (primitive) #230
Conversation
I see that the no-reg is failing because (as I understand it) it tries to apply |
We need to add the definition of antidifferentiate first, release MultivariatePolynomials, then add it to DynamicPolynomials, then release DynamicPolynomials and then add the tests in MultivariatePolynomials |
Alright. I will propose a commit without any tests. |
src/antidifferentiation.jl
Outdated
|
||
# Fallback for everything else | ||
antidifferentiate(α::T, v::AbstractVariable) where {T} = α * v | ||
antidifferentiate(v1::AbstractVariable, v2::AbstractVariable) = v1 == v2 ? 1 / 2 * v1 * v2 : v1 * v2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit concerned about defaulting to Float64
, this might also be used with polynomials on Rational{BigInt}
for instance, I would use Rational{Int}
as it is more neutral so it will preserve the type of the polynomial it is used with
julia> typeof(1.0 * (1 // 2))
Float64
julia> typeof((big(1)) * (1 // 2))
Rational{BigInt}
julia> typeof((big(1) // big(2)) * (1 // 2))
Rational{BigInt}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, I fixed it in my last commit (c34bb38)
I am also french-speaking so primitive is more natural for me as well but let's follow wikipedia: https://en.wikipedia.org/wiki/Antiderivative which uses antidifferentiate |
(done in c34bb38) |
Could you add some tests ? |
Hi Benoît, as I understand the tests will be added later. Or there is something I didn't understand? |
Indeed, sorry, I forgot that part, let's merge then |
With this PR, I propose to introduce a function to get the antiderivative of multivariate polynomial. Note that the word
primitive
, (more natural in my native language), is already used by the Julia language; hence theantiderivative
name. An associated PR inTypedPolynomials
is proposed.I tried to copy what is currently done for
differentiate
. Except forRationalPoly
, which are not always possible to antidifferentiate with polynoms. I provided some unit tests as well.With this new function, it would then be easy to integrate a multivariate polynomial on (simple) geometries such as lines, quads, cubes etc.
Note : for personal reasons, I may be absent in the next few weeks. Don't hesitate to continue the PR process "without me".