Skip to content
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

Symbolics.coeff for multivariate polynomials incorrect #1041

Closed
NAThompson opened this issue Jan 19, 2024 · 4 comments
Closed

Symbolics.coeff for multivariate polynomials incorrect #1041

NAThompson opened this issue Jan 19, 2024 · 4 comments

Comments

@NAThompson
Copy link
Contributor

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.

@yuvalwas
Copy link

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

@NAThompson
Copy link
Contributor Author

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

@zengmao
Copy link
Contributor

zengmao commented Aug 26, 2024

I've fixed the original issue in pull request #1240, though I haven't covered the case where the power is also a variable.

ChrisRackauckas added a commit that referenced this issue Aug 26, 2024
Fix `coeff(p, sym)` when `sym` is a product (issue #1041)
@ChrisRackauckas
Copy link
Member

Fixed in #1240

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants