Ask Your Question

Revision history [back]

Is this what you need ?

sage: R.<I> = QQ[I]
sage: R
Number Field in I with defining polynomial x^2 + 1
sage: K.<x,y> = PolynomialRing(R)
sage: K
Multivariate Polynomial Ring in x, y over Number Field in I with defining polynomial x^2 + 1
sage: P = x+I*y
sage: P^2
x^2 + (2*I)*x*y - y^2

Is this what you need ?

sage: R.<I> = QQ[I]
sage: R
Number Field in I with defining polynomial x^2 + 1
sage: K.<x,y> = PolynomialRing(R)
sage: K
Multivariate Polynomial Ring in x, y over Number Field in I with defining polynomial x^2 + 1
sage: P = x+I*y
sage: P^2
x^2 + (2*I)*x*y - y^2

EDIT: For GF(5), you can do similarly, but you have to define the quotient by yourself:

sage: S.<i> = GF(5)[]
sage: S
Univariate Polynomial Ring in i over Finite Field of size 5
sage: R.<I> = S.quotient(i^2+1)
sage: R
Univariate Quotient Polynomial Ring in I over Finite Field of size 5 with modulus i^2 + 1
sage: I
I
sage: I^2
4
sage: K.<x,y> = PolynomialRing(R)
sage: K
Multivariate Polynomial Ring in x, y over Univariate Quotient Polynomial Ring in I over Finite Field of size 5 with modulus i^2 + 1
sage: P = x+I*3*y
sage: P
x + 3*I*y
sage: P^2
x^2 + I*x*y + y^2