# Computation of homomorphisms of number fields

Given two number fields, I want to construct a morphism between them. For this I tried to use the hom member-function of the NumberField object as follows:

R.<zeta3> = CyclotomicField(3)
P.<X> = PolynomialRing(R)
K.<gen1> = R.extension(X^3-zeta3)
L.<gen2> = R.extension(X^3-zeta3^2)
print K.gens(), L.gens()
H = K.hom( [gen2,zeta3^2], L )
print H


The help page of hom specifies:

Return the unique homomorphism from self to codomain that sends self.gens() to the entries of im_gens. Raises a TypeError if there is no such homomorphism.

However, instead of TypeError, I get an incomprehensible error:

File "/home/sage/bin/sage2/local/lib/python2.7/site-packages/sage/rings/number_field/number_field.py", line 1670, in _element_constructor_ raise ValueError("Length must be equal to the degree of this number field") ValueError: Length must be equal to the degree of this number field

What am I doing wrong? Is there a better way to define this morphism?

edit retag close merge delete

Sort by » oldest newest most voted

You might have misread the description that you copy paste. The arguments of K.hom must be the list of the images of the generators. In your case, there is one generator for K (which is gen1). Even L is an optional argument.

sage: K.hom([gen2])
Relative number field morphism:
From: Number Field in gen1 with defining polynomial X^3 - zeta3 over its base field
To:   Number Field in gen2 with defining polynomial X^3 + zeta3 + 1 over its base field
Defn: gen1 |--> gen2
zeta3 |--> -zeta3 - 1

more

Maybe I should have included this, but at print K.gens(), L.gens()' sage answers with

(gen1, zeta3) (gen2, zeta3)

so clearly K has two generators, I think? Secondly, how does it decide where to send zeta3? In this case there is little room, but if we take

P.<X> = PolynomialRing(QQ)
R.<s2> = QQ.extension(X^2-2)
K.<s3> = R.extension(X^2-3)
print K.gens()
H = K.hom( [-s3,-s2], K )
print H
`

this should also give a valid morphism instead of the one returned by K.hom([-s3]) that maps s2 to itself.

( 2018-01-27 05:42:28 -0500 )edit