Search code examples
sagepolynomialscoefficients

Given a list of coefficients, create a polynomial


I want to create a polynomial with given coefficients. This seems very simple but what I have found till now did not appear to be the thing I desired. For example in such an environment;

n = 11
K = GF(4,'a')
R = PolynomialRing(GF(4,'a'),"x")
x = R.gen()
a = K.gen()
v = [1,a,0,0,1,1,1,a,a,0,1]

Given a list/vector v of length n (I will set this n and v at the begining), I want to get the polynomial v(x) as v[i]*x^i. (Actually after that I am going to build the quotient ring GF(4,'a')[x] /< x^n-v(x) > after getting this v(x) from above) then I will say;

S = R.quotient(x^n-v(x), 'y')
y = S.gen()

But I couldn't write it.


Solution

  • This is a frequently asked question in many places so it is better to leave it here as an answer although the answer I have is so simple:

    I just wrote R(v) and it gave me the polynomial:

    sage
    n = 11
    K = GF(4,'a')
    R = PolynomialRing(GF(4,'a'),"x")
    x = R.gen()
    a = K.gen()
    
    v = [1,a,0,0,1,1,1,a,a,0,1]
    R(v)
    
    x^10 + a*x^8 + a*x^7 + x^6 + x^5 + x^4 + a*x + 1