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

exponent_vectors of universal polynomials #1256

Open
SoongNoonien opened this issue Feb 7, 2023 · 3 comments
Open

exponent_vectors of universal polynomials #1256

SoongNoonien opened this issue Feb 7, 2023 · 3 comments

Comments

@SoongNoonien
Copy link
Contributor

Hi, I found some inconsistencies of exponent_vectors:

julia> S=UniversalPolynomialRing(QQ)
Universal Polynomial Ring over Rational Field

julia> i,j=gens(S, ["i","j"])
(i, j)

julia> collect(exponent_vectors(i))
1-element Vector{Vector{Int64}}:
 [1]

julia> collect(exponent_vectors(j))
1-element Vector{Vector{Int64}}:
 [0, 1]

julia> ii=S(i)
i

julia> collect(exponent_vectors(ii))
1-element Vector{Vector{Int64}}:
 [1, 0]

I wondered why they have sometimes different length. First I thought that they may be zero stripped from the right but this is clearly not the case as one can see with ii. As far as I can tell this is caused by the underlying MPolys. By the time i was created S had only one variable, so i.p is contained in a ring with just one variable. But ii is now created from a ring that already has two variables, so the parent of ii.p has two variables (similarly j.p). This can be seen here:

julia> nvars(parent(i.p))
1

julia> nvars(parent(ii.p))
2

julia> nvars(parent(j.p))
2

So, is the current behavior of exponent_vectors intended?

@thofma
Copy link
Member

thofma commented Feb 15, 2023

Yes, I think this is intended. One "problem" is that, i,j=gens(S, ["i","j"]) is done recursively, so first _, i = QQ["i"] is constructed and then _,(_,j)) = QQ["i", "j"] and then (i, j) is returned.

Not sure if exponent_vectors is useful at all. Because gens(S) is dynamic, there is no guarantee that one can recover an element p from exponent_vectors(p) and gens(S).

What is your application for exponent_vectors? I am leaning towards deleting it.

@SoongNoonien
Copy link
Contributor Author

Not sure if exponent_vectors is useful at all. Because gens(S) is dynamic, there is no guarantee that one can recover an element p from exponent_vectors(p) and gens(S).

If I understand the universal polynomials correctly then gens(S) should only grow. And the documentation states the exponent vectors will remain valid:

Later, when the ring has more variable, these exponent vectors will still be accepted. The exponent vectors are simply padded out to the full number of variables behind the scenes.

So, it should be no problem to recover elements from their coefficients and exponent vectors.

What is your application for exponent_vectors? I am leaning towards deleting it.

I'm using it to replace variables. For example S has variables x, y, x1, y1 and p is 3*x^2+x*y and I want to replace x with x1 and y with y1. This can clearly be done with evaluate as well, but I used exponent_vectors because of #1245. Since it is fixed now I should port to evaluate.

@thofma
Copy link
Member

thofma commented Feb 15, 2023

I think the documentation wants to say, that you can do the following:

julia> coeff(i, [1])
1//1

julia> coeff(i, [1, 0])
1//1

Also this works:

julia> S(collect(coefficients(i)), collect(exponent_vectors(i)))
i

So it seems everything is working as expected, including the behaviour exponent_vectors.

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

2 participants