# Multivariate polynomial with symbolic values

**URL:** <https://discourse.julialang.org/t/multivariate-polynomial-with-symbolic-values/109345>\
**Category:** General Usage\
**Tags:** polynomials\
**Created:** [January 27, 2024, 5:33pm UTC](https://discourse.julialang.org/t/multivariate-polynomial-with-symbolic-values/109345 "2024-01-27T17:33:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hugopottinger](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@hugopottinger](https://discourse.julialang.org/u/hugopottinger)\
**Post date:** [January 27, 2024, 5:33pm UTC](https://discourse.julialang.org/t/multivariate-polynomial-with-symbolic-values/109345/1 "2024-01-27T17:33:56Z")

</div>

For a multivariate polynomial with symbolic coefficients such as

p = a_x + b_x^2_y + c_x\*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 = a_x + b_x^2_y + c_x\*y

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

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [January 27, 2024, 6:12pm UTC](https://discourse.julialang.org/t/multivariate-polynomial-with-symbolic-values/109345/2 "2024-01-27T18:12:31Z")

</div>

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [January 27, 2024, 6:32pm UTC](https://discourse.julialang.org/t/multivariate-polynomial-with-symbolic-values/109345/3 "2024-01-27T18:32:31Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![hugopottinger](https://avatars.discourse-cdn.com/v4/letter/h/ecd19e/32.png) [@hugopottinger](https://discourse.julialang.org/u/hugopottinger)\
**Post date:** [January 30, 2024, 10:21am UTC](https://discourse.julialang.org/t/multivariate-polynomial-with-symbolic-values/109345/4 "2024-01-30T10:21:42Z")

</div>

Thanks so much!
