Homomorphisms for relative number fields

How can I define a homomorphism from a relative number field K (containing F) to some other field L if I know where to send K.gens()?

Example:

F_pol  = x^2-x-1
F      = NumberField(F_pol, 'lam')
K_pol  = x^2 + 4
K      = F.extension(K_pol, 'e')
L      = QQbar
lam_im = L(F_pol.roots()[1][0])
e_im   = L(K_pol.roots()[1][0])


Wrong result:

K.hom([e_im], QQbar, check=False)


What we want (not working):

K.hom([e_im, lam_im], QQbar, check=False)


A working solution (edit):

K.Hom(L)(e_im, F.hom([lam_im], check=False))


New question/example: What if L is not exact?

x       = PolynomialRing(QQ,'x').gen()
F_pol   = x^3 - x^2 - 2*x + 1
F.<lam> = NumberField(F_pol, 'lam')
D       = 4*lam^2 + 4*lam - 4
K_pol   = x^2 - D
K       = F.extension(K_pol, 'e')
L       = CC
lam_im  = F_pol.roots(L)[2][0]
e_im    = F.hom([lam_im], check=False)(D).sqrt()

K.Hom(L)(e_im, F.hom([lam_im], check=False), check=False)


This gives the error:

TypeError: images do not define a valid homomorphism

edit retag close merge delete

Sort by » oldest newest most voted

First you need to write

sage: lam_im = F_pol.roots(L)[1][0]
sage: e_im = K_pol.roots(L)[1][0]


Then the following works

sage: HomKL = K.Hom(L)
sage: HomKL(e_im, F.hom([lam_im]))
Relative number field morphism:
From: Number Field in e with defining polynomial x^2 + 4 over its base field
To:   Algebraic Field
Defn: e |--> 0.?e-53 + 2.000000000000000?*I
lam |--> 1.618033988749895? + 0.?e-53*I


Typing

sage: HomKL.__call__?


explains the syntax. There should be an easier way to do this.

On the second question

This is a bug, the check parameter does not get passed on as it should be. I will raise a ticket to deal with this, but in the meantime you can get the result you want as follows.

sage: K_abs = K.absolute_field('a')
sage: from_abs = K_abs.structure()[0]
sage: a = from_abs(K_abs.gen())
sage: R = L['x']
sage: f = R(map(F.hom([lam_im], check=False), a))
sage: abs_hom = K_abs.hom([f(e_im)], check=False)
sage: from sage.rings.number_field.morphism import RelativeNumberFieldHomomorphism_from_abs
sage: RelativeNumberFieldHomomorphism_from_abs(K.Hom(L), abs_hom)
Relative number field morphism:
From: Number Field in e with defining polynomial x^2 - 4*lam^2 - 4*lam + 4 over its base field
To:   Complex Field with 53 bits of precision
Defn: e |--> 4.02438434522465
lam |--> 1.80193773580484


This is taken, with some slight modifications, from the code for _from_im in sage/rings/number_field/morphism.py, the key difference being the addition of check=False where abs_hom is defined.

more

I get the following error after "lam_im = F_pol.roots(L)[1][0]": TypeError: Algebraic Field is not a valid variable. But with my "lam_im"-way it works. Thanks a lot!

( 2014-09-18 16:32:37 +0200 )edit

Now I see. Your F_pol was a symbolic expression, but mine was a polynomial. Unfortunately the root methods for each are not compatible.

( 2014-09-18 17:49:41 +0200 )edit

Ok, that makes sense. Usually I use polynomial variables as well...

( 2014-09-19 10:08:46 +0200 )edit

Hmm, how can I make it work for non-exact fields like CC? I tried to put a check=False flag everwhere but it still seems to fail. :(

( 2014-09-19 16:47:07 +0200 )edit

Thanks for the updated answer!

( 2014-10-20 19:26:28 +0200 )edit