Multivariate polynomial with symbolic values

For a multivariate polynomial with symbolic coefficients such as

p = ax + bx^2y + cx*y

I require in my code to be able to use functions similar to those in MultivariatePolynomials such as length(p), degree(p,x), coefficient(p), terms(p) etc however I am struggling to do this. So far i have tried:

using AbstractAlgebra

S, (a,b,c) = PolynomialRing(QQ, [“a”,“b”,“c”])

T, (x,y) = PolynomialRing(S, [“x”,“y”])

p = ax + bx^2y + cx*y

However I cant get any of the equivalent functions in AbstractAlgebra to work. Any help would be greatly appreciated!

julia> using AbstractAlgebra

julia> S, (a,b,c) = polynomial_ring(QQ, ["a", "b", "c"]);

julia> T, (x,y) = polynomial_ring(S, ["x", "y"]);

julia> p = a*x + b*x^2*y + c*x*y;

julia> coeff(p, x)
a

julia> length(p)
3

julia> degree(p, x)
2

julia> collect(terms(p))
3-element Vector{AbstractAlgebra.Generic.MPoly{AbstractAlgebra.Generic.MPoly{Rational{BigInt}}}}:
 b*x^2*y
 c*x*y
 a*x
4 Likes

Thanks so much!