How to get the imaginary and real parts in quadratic extension?

I have the following code segment in Sage:

proof.arithmetic(False)

p = 10354717741769305252977768237866805321427389645549071170116189679054678940682478846502882896561066713624553211618840202385203911976522554393044160468771151816976706840078913334358399730952774926980235086850991501872665651576831
assert p.is_prime()
Fp = GF(p)
R.<x> = PolynomialRing(Fp)
# The quadratic extension via x^2 + 1 since p = 3 mod 4
Fp2.<j> = Fp.extension(x^2 + 1)
v = 9207905618485976447392495823891126491742950552335608949038426615382964807887894797411491716107572732408369786142697750332311947639207321056540404444033540648125838904594907601875471637980859284582852367748448663333866077035709*j + 4651155546510811048846770550870646667630430517849502373785869664283801023087435645046977319664381880355511529496538038596466138807253669785341264293301567029718659171475744580349901553036469330686320047828171225710153655171014

Now, if I try to get the real and imaginary parts with v.real() and v.imag(), I get errors that those methods do not exist. I guess because v has some different structure and type. How can I get the imaginary and real parts here?

edit retag close merge delete

Sort by ยป oldest newest most voted

The notion of real and imaginary part are very related to the particular polynomial x^2+1, so for me it makes sense that there is no suvh method for an arbitrary field extension.

Anuway, you can turn v into a polynomial on the undeterminate j:

sage: v.parent()
Finite Field in j of size 10354717741769305252977768237866805321427389645549071170116189679054678940682478846502882896561066713624553211618840202385203911976522554393044160468771151816976706840078913334358399730952774926980235086850991501872665651576831^2

sage: P = v.polynomial()
sage: P
9207905618485976447392495823891126491742950552335608949038426615382964807887894797411491716107572732408369786142697750332311947639207321056540404444033540648125838904594907601875471637980859284582852367748448663333866077035709*j + 4651155546510811048846770550870646667630430517849502373785869664283801023087435645046977319664381880355511529496538038596466138807253669785341264293301567029718659171475744580349901553036469330686320047828171225710153655171014
sage: P.parent()
Univariate Polynomial Ring in j over Finite Field of size 10354717741769305252977768237866805321427389645549071170116189679054678940682478846502882896561066713624553211618840202385203911976522554393044160468771151816976706840078913334358399730952774926980235086850991501872665651576831 (using NTL)

Then look at its coefficients:

sage: re, im = P.coefficients(sparse=False)
sage: re
4651155546510811048846770550870646667630430517849502373785869664283801023087435645046977319664381880355511529496538038596466138807253669785341264293301567029718659171475744580349901553036469330686320047828171225710153655171014
sage: im
9207905618485976447392495823891126491742950552335608949038426615382964807887894797411491716107572732408369786142697750332311947639207321056540404444033540648125838904594907601875471637980859284582852367748448663333866077035709
more

Thanks, this seems to work.

( 2018-01-26 13:11:40 -0600 )edit

Stats

Seen: 122 times

Last updated: Jan 26 '18