# Replace coefficient to specific value on multivariate polynomial

Hello, I consider a multivariate polynomial ring F_p[t][x,y] with a univariate polynomial ring F_p[t] over a finite field F_p as a coefficient ring (p is prime number).

I want to generate polynomials as follows.

1. the degree of each coefficient of t is d
2. the terms of x and y are random except for the constant term
3. the constant term should have a specific value (e.g., the value obtained by substituting x=t, y=t^2 for the terms other than the constant term). I want to replace constant coefficient to them.

I have done so far. As follows,

p = 31
P.<t> = PolynomialRing(GF(p))
Q.<x,y> = PolynomialRing(P)
X = Q.random_element(degree = 2,terms = 6,choose_degree = True)
while len(list(X)) <= 5:
X = Q.random_element(degree = 2,terms = 6,choose_degree = True)
print(X)


But I can't make step 3. What should I do??

edit retag close merge delete

I noticed that Step 1 was not done either. How do I specify the order of the coefficient t to be d (d=10, etc.)?

( 2022-05-12 02:41:57 +0200 )edit

Try X = Q.random_element(2,6,False,10). The thing is that you need to pass d=10 to Q.base().random_element() (i.e. P.random_element()) but you cannot do so as keyword argument since there will be two degree=. So, we have to use positional arguments instead.

( 2022-05-12 05:50:58 +0200 )edit

Thank you from the bottom of my heart!!

( 2022-05-13 06:48:44 +0200 )edit

Sort by » oldest newest most voted

The following should do the job:

X -= X.constant_coefficient()   # removing the current free term
X += X.subs( {x:t, y:t^2} )     # adding the required free term

more

I appreciate it ! Thank you so much!

( 2022-05-12 02:36:09 +0200 )edit