Ask Your Question

Interpreting an element of CyclotomicField as an element of polynomial ring

asked 2015-03-03 15:12:21 +0200

BGS gravatar image

updated 2023-01-09 23:59:36 +0200

tmonteil gravatar image

I am trying to write a function that sums up numbers in different cyclotomic field formally, i.e., as expressions in $z$ where $z$ is the corresponding primitive root of unity. I run into a type error, however, as sage wouldn't let me sum elements of two different cyclotomic fields. Is there a way to typecast an expression in one cyclotomic field into the other, or, better yet, to a polynomial ring?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-03-03 19:13:08 +0200

tmonteil gravatar image

updated 2015-03-04 11:45:05 +0200

EDIT: The comment of @BGS indicates that the question migh be understood as follows : given an element of a cyclotomic field, how to recover it as a polynomial of the generator, so that we can "recast" the generator into a generator of another cyclotomic field. Here is a simple solution, involving the .polynomial() method of cyclotomic field elements.

Finding the polynomial:

sage: C7 = CyclotomicField(7)
sage: z7 = C7.gen()
sage: a7 = z7 + 3*z7^2 + 1
sage: a7.polynomial()
x^3 + 3*x^2 + 1
sage: a7.polynomial().parent()
Univariate Polynomial Ring in x over Rational Field

Recasting into another cyclotomic field:

sage: C5 = CyclotomicField(5)
sage: z5 = C5.gen()
sage: a5 = a7.polynomial()(z5)
sage: a5
zeta5^3 + 3*zeta5^2 + 1

That said, the polynomial is not uniquely determined (unless you need the minimal one) and the recasting will depend on the polynomial, since for example:

sage: z5^5 + z5 == z5 + 1
sage: z7^5 + z7 == z7 + 1

PREVIOUS ANSWER (answering a question about embedding cyclotomic field generators into the algebraic field)

The problem is that the cyclotomic field is not well embedded into the complex plane (more precisely into the field of complex algebraic numbers), see my answer of ask question 25822 for more details about this.

sage: CC(z3)
-0.500000000000000 + 0.866025403784439*I
sage: C3 = CyclotomicField(3)
sage: z3 = C3.gen()
sage: z3
sage: CC(z3)
-0.500000000000000 + 0.866025403784439*I


sage: QQbar(z3)
TypeError: Illegal initializer for algebraic number

Which is a pity. Let me propose the following fix:

sage: def repair(z):
....:     F = z.parent()
....:     for f in F.embeddings(QQbar):
....:         if CLF(f.im_gens()[0]) - CLF(z) < 1e-14:
....:             return f(z)

The function repair put an generator of some cyclotomic field into the algebraic field QQbar (if n is not too big, so that two generators are at distance larger than 2e-14, but you can adapt the bound if needed).

So you can do:

sage: C3 = CyclotomicField(3)
sage: z3 = C3.gen()
sage: Z3 = repair(z3)
sage: Z3
-0.50000000000000000? - 0.866025403784439?*I
sage: Z3.parent()
Algebraic Field

sage: C4 = CyclotomicField(4)
sage: z4 = C4.gen()
sage: Z4 = repair(z4)
sage: Z4
sage: Z4.parent()
Algebraic Field

Then you can do:

sage: Z3 + Z4
-0.50000000000000000? - 1.866025403784439?*I
sage: (Z3^2 + 2*Z3 + 1) + (Z4^3 + 7)
6.5000000000000000? + 0.1339745962155614?*I
sage: ((Z3^2 + 2*Z3 + 1) + (Z4^3 + 7)).minpoly()
x^4 - 26*x^3 + 257*x^2 - 1144*x + 1933
edit flag offensive delete link more


Thank you for your prompt reply. This is useful to know, but I had in mind something else. Specifically, what I was trying to do was to recast Z3 as the generator of Z4. I am trying to compute a certain semiclassical approximation, i.e., I try to successively recast a given expression in z as expressions in various cyclotomic fields.

BGS gravatar imageBGS ( 2015-03-03 22:04:35 +0200 )edit

I do not understand, Z3 is different from Z4, it is not even an element of C4. Could you please give a concrete example of the behavior you would like to see, so that i can understand ? I edited my answer according to how i understand the question now.

tmonteil gravatar imagetmonteil ( 2015-03-04 11:08:37 +0200 )edit

answered 2015-03-04 10:27:14 +0200

vdelecroix gravatar image


In Sage there is the universal cyclotomic field implemented. It would be much faster than QQbar as proposed by @tmonteil

sage: UCF = UniversalCyclotomicField()
sage: UCF.gen(3)
sage: e3 = UCF.gen(3)
sage: e4 = UCF.gen(4)
sage: e3 + e4
E(12)^4 - E(12)^7 - E(12)^11


edit flag offensive delete link more


Weird, in particular the special case of cyclotomic fields, there is a map from them to QQbar, just do:

sage: C3 = CyclotomicField(3)
sage: z3 = C3.gen()
sage: Z3 = QQbar(UniversalCyclotomicField()(z3))
sage: Z3
-0.500000000000000? + 0.866025403784439?*I

There is definitely an issue with embedded number fields.

tmonteil gravatar imagetmonteil ( 2015-03-04 11:25:07 +0200 )edit

Indeed! There is a problem

sage: C3 = CyclotomicField(3)
sage: UCF = UniversalCyclotomicField()
sage: UCF.has_coerce_map_from(C3)
sage: QQbar.has_coerce_map_from(UCF)
sage: QQbar.has_coerce_map_from(C3)
vdelecroix gravatar imagevdelecroix ( 2015-03-04 11:35:30 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-03-03 15:12:21 +0200

Seen: 430 times

Last updated: Mar 04 '15