# Polynomial in n variables with AbstractAlgebra

**URL:** <https://discourse.julialang.org/t/polynomial-in-n-variables-with-abstractalgebra/84338>\
**Category:** General Usage\
**Tags:** question, polynomials\
**Created:** [July 16, 2022, 10:32pm UTC](https://discourse.julialang.org/t/polynomial-in-n-variables-with-abstractalgebra/84338 "2022-07-16T22:32:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_stla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/_stla/32/35613_2.png) [@\_stla](https://discourse.julialang.org/u/_stla)\
**Post date:** [July 16, 2022, 10:32pm UTC](https://discourse.julialang.org/t/polynomial-in-n-variables-with-abstractalgebra/84338/1 "2022-07-16T22:32:45Z")

</div>

Hello,

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

```julia
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.

---

<div class="post-metadata">

**Author:** ![\_stla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/_stla/32/35613_2.png) [@\_stla](https://discourse.julialang.org/u/_stla)\
**Post date:** [July 16, 2022, 11:22pm UTC](https://discourse.julialang.org/t/polynomial-in-n-variables-with-abstractalgebra/84338/2 "2022-07-16T23:22:42Z")

</div>

Yes:

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

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]
x_1

julia> vars[1] * vars[2]
x_1*x_2

```
