Polynomial in n variables with AbstractAlgebra


Here is an example of the declaration of a multivariate polynomial with AbstractAlgebra:

using AbstractAlgebra
using Printf # used to write the result

# define the symbolic constants
SS, (a,b,c,d,sqrt3,w0) = PolynomialRing(QQ, ["a","b","c","d","sqrt3","w0"])
# define the symbolic variables
TT, (x,y,z,w) = PolynomialRing(SS, ["x","y","z","w"])

# polynomial expression
P = ((x^2+y^2+z^2+w^2+145//3)^2-4*(9*z^2+16*w^2))^2*((x^2+y^2+z^2+w^2+145//3)^2+......

Is it possible to define a polynomial in n variables? With DynamicPolynomials one can have a vector of variables by doing:

@polyvar x[1:n]

But I want to use AbstractAlgebra because I don’t know whether it’s possible to deal with symbolic constants with DynamicPolynomials, and this is what I need.


julia> x = map(i -> "x_" * string(i), 1:4)
4-element Vector{String}:

julia> SS, vars = PolynomialRing(QQ, x)
(Multivariate Polynomial Ring in x_1, x_2, x_3, x_4 over Rationals, AbstractAlgebra.Generic.MPoly{Rational{BigInt}}[x_1, x_2, x_3, x_4])

julia> vars[1]

julia> vars[1] * vars[2]