JuliaAlgebra / DynamicPolynomials.jl

Multivariate polynomials implementation of commutative and non-commutative variables
Other
59 stars 21 forks source link

Don't turn coefficients into float on div #144

Closed shashi closed 4 months ago

shashi commented 1 year ago
julia> pa = PolyForm(x+2y).p
2y + x

julia> pa/1
2.0y + x

It should at best be Rational... If one of the coeffs is already Float then it makes if the output has floats.

blegat commented 1 year ago

What is PolyForm ? I think it is consistent with Julia, 1 / 2 is also Float

hersle commented 7 months ago

Hi! PolyForm is a wrapper in SymbolicUtils.jl, which underlies Symbolics.jl. Reliably working with integer/rational coefficients would greatly help symbolic calculations.

Anyway, here div is not consistent with base Julia:

julia> using DynamicPolynomials

julia> @polyvar x
(x,)

julia> div(x, x)
1.0

julia> div(7, 7)
1

Should/could this be fixed?

shashi commented 6 months ago

Thanks @hersle ! @blegat, we use div, / is just surface notation. PolyForm wraps your polynomials and implements the Symbolics expression interface.