Skip to content

Noncommuting variables to the zeroth power #118

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

Open
kbarros opened this issue Oct 18, 2022 · 2 comments
Open

Noncommuting variables to the zeroth power #118

kbarros opened this issue Oct 18, 2022 · 2 comments
Labels

Comments

@kbarros
Copy link

kbarros commented Oct 18, 2022

Taking noncommuting variables to the zeroth power can lead to surprising results:

using DynamicPolynomials
@ncpolyvar a x
p = x^0 * a  # displays as `a`
p == a       # returns true (expected behavior)
a == p       # returns false (bug)
@blegat blegat added the bug label Oct 19, 2022
@exAClior
Copy link

exAClior commented Mar 18, 2025

A related bug with the following Minimal Working Example

using DynamicPolynomials
@ncpolyvar x y z
bases = monomials([x,y,z],2)
@assert z^0*y*x^0*z in bases

A dirty fix is possible with calling the following function on monomials

using DynamicPolynomials: Monomial
function remove_zero_degree(m::Monomial{C}) where {C}
    isconstant(m) && return m
    return prod([x[1]^x[2] for x in filter(!(iszero  last), collect(zip(m.vars, m.z)))])
end
@assert remove_zero_degree(z^0*y*x^0*z) in bases

If desirable, I would be happy to make a PR on related parts of the library.

@blegat
Copy link
Member

blegat commented Mar 18, 2025

Thanks for the proposal, it would be best to fix the root of the issue which is that the equality should ignore the trailing zeros

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

No branches or pull requests

3 participants