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

How to convert an univariate polynomial to a multivariate polynomial? #1503

Open
nsajko opened this issue Nov 22, 2023 · 2 comments
Open

How to convert an univariate polynomial to a multivariate polynomial? #1503

nsajko opened this issue Nov 22, 2023 · 2 comments

Comments

@nsajko
Copy link
Contributor

nsajko commented Nov 22, 2023

Basically the opposite of #220. I've got a univariate polynomial over a multivariate polynomial ring, and I'd like to convert it into a multivariate polynomial ring with one more variable. How to do this? The use case is that minpoly and charpoly return univariate polynomials, but I want a multivariate polynomial.

Example, in case it's not clear what I'm talking about:

julia> using AbstractAlgebra

julia> xy_ring, (x, y) = QQ["x", "y"]
(Multivariate polynomial ring in 2 variables over rationals, AbstractAlgebra.Generic.MPoly{Rational{BigInt}}[x, y])

julia> _, z = polynomial_ring(xy_ring, :z)
(Univariate polynomial ring in z over multivariate polynomial ring, z)

julia> x*z
x*z

julia> typeof(ans)
AbstractAlgebra.Generic.Poly{AbstractAlgebra.Generic.MPoly{Rational{BigInt}}}

So x*z is actually a univariate polynomial, according to AA's type system, and my question is how to convert it into a multivariate polynomial?

@nsajko
Copy link
Contributor Author

nsajko commented Nov 22, 2023

Figured it out:

julia> using AbstractAlgebra

julia> xyz_ring, (x, y, z) = QQ["x", "y", "z"]
(Multivariate polynomial ring in 3 variables over rationals, AbstractAlgebra.Generic.MPoly{Rational{BigInt}}[x, y, z])

julia> _, z_ = polynomial_ring(xyz_ring, :z)
(Univariate polynomial ring in z over multivariate polynomial ring, z)

julia> (x*z_)(z)
x*z

julia> typeof(ans)
AbstractAlgebra.Generic.MPoly{Rational{BigInt}}

Maybe there should be an example like this in the docs?

@thofma
Copy link
Member

thofma commented Dec 1, 2023

Where would you put in the docs?

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