JuliaSymbolics/Symbolics.jl

Symbolics.coeff for multivariate polynomials incorrect

NAThompson opened this issue · 2 comments

To reproduce:

julia> @variables x y;
julia> Symbolics.coeff(3x + 2*x*y, x*y)
0

Of course the answer should be 2. . .

Julia version 1.10.0, latest released Symbolics.

I'm also having this problem. For your case, semipolynomial_form seems to work:

julia> @variables x y;
julia> d = semipolynomial_form(3x + 2*x*y, [x, y], Inf)
(Dict{Any, Any}(x*y => 2, x => 3), 0)
julia> d[1][x*y]
2

However, it doesn't work when the power is also a variable, as in

@variables x y a b
poly = 3x^a + 2*x^b * y^a

@yuvalwas : My report was actually a simplification of a case where the power was also a variable, so thanks for looking into this. . .