# Sets of homomorphisms between number fields#

class sage.rings.number_field.homset.CyclotomicFieldHomset(R, S, category=None)[source]#

Set of homomorphisms with domain a given cyclotomic field.

EXAMPLES:

```sage: End(CyclotomicField(16))
Automorphism group of Cyclotomic Field of order 16 and degree 8
```
```>>> from sage.all import *
>>> End(CyclotomicField(Integer(16)))
Automorphism group of Cyclotomic Field of order 16 and degree 8
```
Element[source]#
list()[source]#

Return a list of all the elements of `self` (for which the domain is a cyclotomic field).

EXAMPLES:

```sage: K.<z> = CyclotomicField(12)
sage: G = End(K); G
Automorphism group of Cyclotomic Field of order 12 and degree 4
sage: [g(z) for g in G]
[z, z^3 - z, -z, -z^3 + z]
sage: x = polygen(ZZ, 'x')
sage: L.<a, b> = NumberField([x^2 + x + 1, x^4 + 1])
sage: L
Number Field in a with defining polynomial x^2 + x + 1 over its base field
sage: Hom(CyclotomicField(12), L)[3]
Ring morphism:
From: Cyclotomic Field of order 12 and degree 4
To:   Number Field in a with defining polynomial x^2 + x + 1 over its base field
Defn: zeta12 |--> -b^2*a
sage: list(Hom(CyclotomicField(5), K))
[]
sage: Hom(CyclotomicField(11), L).list()
[]
```
```>>> from sage.all import *
>>> K = CyclotomicField(Integer(12), names=('z',)); (z,) = K._first_ngens(1)
>>> G = End(K); G
Automorphism group of Cyclotomic Field of order 12 and degree 4
>>> [g(z) for g in G]
[z, z^3 - z, -z, -z^3 + z]
>>> x = polygen(ZZ, 'x')
>>> L = NumberField([x**Integer(2) + x + Integer(1), x**Integer(4) + Integer(1)], names=('a', 'b',)); (a, b,) = L._first_ngens(2)
>>> L
Number Field in a with defining polynomial x^2 + x + 1 over its base field
>>> Hom(CyclotomicField(Integer(12)), L)[Integer(3)]
Ring morphism:
From: Cyclotomic Field of order 12 and degree 4
To:   Number Field in a with defining polynomial x^2 + x + 1 over its base field
Defn: zeta12 |--> -b^2*a
>>> list(Hom(CyclotomicField(Integer(5)), K))
[]
>>> Hom(CyclotomicField(Integer(11)), L).list()
[]
```
class sage.rings.number_field.homset.NumberFieldHomset(R, S, category=None)[source]#

Set of homomorphisms with domain a given number field.

Element[source]#
cardinality()[source]#

Return the order of this set of field homomorphism.

EXAMPLES:

```sage: x = polygen(ZZ, 'x')
sage: k.<a> = NumberField(x^2 + 1)
sage: End(k)
Automorphism group of Number Field in a with defining polynomial x^2 + 1
sage: End(k).order()
2
sage: k.<a> = NumberField(x^3 + 2)
sage: End(k).order()
1

sage: K.<a> = NumberField([x^3 + 2, x^2 + x + 1])
sage: End(K).order()
6
```
```>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> k = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = k._first_ngens(1)
>>> End(k)
Automorphism group of Number Field in a with defining polynomial x^2 + 1
>>> End(k).order()
2
>>> k = NumberField(x**Integer(3) + Integer(2), names=('a',)); (a,) = k._first_ngens(1)
>>> End(k).order()
1

>>> K = NumberField([x**Integer(3) + Integer(2), x**Integer(2) + x + Integer(1)], names=('a',)); (a,) = K._first_ngens(1)
>>> End(K).order()
6
```
list()[source]#

Return a list of all the elements of `self`.

EXAMPLES:

```sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^3 - 3*x + 1)
sage: End(K).list()
[
Ring endomorphism of Number Field in a with defining polynomial x^3 - 3*x + 1
Defn: a |--> a,
Ring endomorphism of Number Field in a with defining polynomial x^3 - 3*x + 1
Defn: a |--> a^2 - 2,
Ring endomorphism of Number Field in a with defining polynomial x^3 - 3*x + 1
Defn: a |--> -a^2 - a + 2
]
sage: Hom(K, CyclotomicField(9))[0] # indirect doctest
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 3*x + 1
To:   Cyclotomic Field of order 9 and degree 6
Defn: a |--> -zeta9^4 + zeta9^2 - zeta9
```
```>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(3) - Integer(3)*x + Integer(1), names=('a',)); (a,) = K._first_ngens(1)
>>> End(K).list()
[
Ring endomorphism of Number Field in a with defining polynomial x^3 - 3*x + 1
Defn: a |--> a,
Ring endomorphism of Number Field in a with defining polynomial x^3 - 3*x + 1
Defn: a |--> a^2 - 2,
Ring endomorphism of Number Field in a with defining polynomial x^3 - 3*x + 1
Defn: a |--> -a^2 - a + 2
]
>>> Hom(K, CyclotomicField(Integer(9)))[Integer(0)] # indirect doctest
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 3*x + 1
To:   Cyclotomic Field of order 9 and degree 6
Defn: a |--> -zeta9^4 + zeta9^2 - zeta9
```

An example where the codomain is a relative extension:

```sage: K.<a> = NumberField(x^3 - 2)
sage: L.<b> = K.extension(x^2 + 3)
sage: Hom(K, L).list()
[
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 2
To:   Number Field in b with defining polynomial x^2 + 3 over its base field
Defn: a |--> a,
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 2
To:   Number Field in b with defining polynomial x^2 + 3 over its base field
Defn: a |--> -1/2*a*b - 1/2*a,
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 2
To:   Number Field in b with defining polynomial x^2 + 3 over its base field
Defn: a |--> 1/2*a*b - 1/2*a
]
```
```>>> from sage.all import *
>>> K = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = K._first_ngens(1)
>>> L = K.extension(x**Integer(2) + Integer(3), names=('b',)); (b,) = L._first_ngens(1)
>>> Hom(K, L).list()
[
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 2
To:   Number Field in b with defining polynomial x^2 + 3 over its base field
Defn: a |--> a,
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 2
To:   Number Field in b with defining polynomial x^2 + 3 over its base field
Defn: a |--> -1/2*a*b - 1/2*a,
Ring morphism:
From: Number Field in a with defining polynomial x^3 - 2
To:   Number Field in b with defining polynomial x^2 + 3 over its base field
Defn: a |--> 1/2*a*b - 1/2*a
]
```
order()[source]#

Return the order of this set of field homomorphism.

EXAMPLES:

```sage: x = polygen(ZZ, 'x')
sage: k.<a> = NumberField(x^2 + 1)
sage: End(k)
Automorphism group of Number Field in a with defining polynomial x^2 + 1
sage: End(k).order()
2
sage: k.<a> = NumberField(x^3 + 2)
sage: End(k).order()
1

sage: K.<a> = NumberField([x^3 + 2, x^2 + x + 1])
sage: End(K).order()
6
```
```>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> k = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = k._first_ngens(1)
>>> End(k)
Automorphism group of Number Field in a with defining polynomial x^2 + 1
>>> End(k).order()
2
>>> k = NumberField(x**Integer(3) + Integer(2), names=('a',)); (a,) = k._first_ngens(1)
>>> End(k).order()
1

>>> K = NumberField([x**Integer(3) + Integer(2), x**Integer(2) + x + Integer(1)], names=('a',)); (a,) = K._first_ngens(1)
>>> End(K).order()
6
```
class sage.rings.number_field.homset.RelativeNumberFieldHomset(R, S, category=None)[source]#

Set of homomorphisms with domain a given relative number field.

EXAMPLES:

We construct a homomorphism from a relative field by giving the image of a generator:

```sage: x = polygen(ZZ, 'x')
sage: L.<cuberoot2, zeta3> = CyclotomicField(3).extension(x^3 - 2)
sage: phi = L.hom([cuberoot2 * zeta3]); phi
Relative number field endomorphism of
Number Field in cuberoot2 with defining polynomial x^3 - 2 over its base field
Defn: cuberoot2 |--> zeta3*cuberoot2
zeta3 |--> zeta3
sage: phi(cuberoot2 + zeta3)
zeta3*cuberoot2 + zeta3
```
```>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> L = CyclotomicField(Integer(3)).extension(x**Integer(3) - Integer(2), names=('cuberoot2', 'zeta3',)); (cuberoot2, zeta3,) = L._first_ngens(2)
>>> phi = L.hom([cuberoot2 * zeta3]); phi
Relative number field endomorphism of
Number Field in cuberoot2 with defining polynomial x^3 - 2 over its base field
Defn: cuberoot2 |--> zeta3*cuberoot2
zeta3 |--> zeta3
>>> phi(cuberoot2 + zeta3)
zeta3*cuberoot2 + zeta3
```

In fact, this `phi` is a generator for the Kummer Galois group of this cyclic extension:

```sage: phi(phi(cuberoot2 + zeta3))
(-zeta3 - 1)*cuberoot2 + zeta3
sage: phi(phi(phi(cuberoot2 + zeta3)))
cuberoot2 + zeta3
```
```>>> from sage.all import *
>>> phi(phi(cuberoot2 + zeta3))
(-zeta3 - 1)*cuberoot2 + zeta3
>>> phi(phi(phi(cuberoot2 + zeta3)))
cuberoot2 + zeta3
```
Element[source]#
default_base_hom()[source]#

Pick an embedding of the base field of `self` into the codomain of this homset. This is done in an essentially arbitrary way.

EXAMPLES:

```sage: x = polygen(ZZ, 'x')
sage: L.<a, b> = NumberField([x^3 - x + 1, x^2 + 23])
sage: M.<c> = NumberField(x^4 + 80*x^2 + 36)
sage: Hom(L, M).default_base_hom()
Ring morphism:
From: Number Field in b with defining polynomial x^2 + 23
To:   Number Field in c with defining polynomial x^4 + 80*x^2 + 36
Defn: b |--> 1/12*c^3 + 43/6*c
```
```>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> L = NumberField([x**Integer(3) - x + Integer(1), x**Integer(2) + Integer(23)], names=('a', 'b',)); (a, b,) = L._first_ngens(2)
>>> M = NumberField(x**Integer(4) + Integer(80)*x**Integer(2) + Integer(36), names=('c',)); (c,) = M._first_ngens(1)
>>> Hom(L, M).default_base_hom()
Ring morphism:
From: Number Field in b with defining polynomial x^2 + 23
To:   Number Field in c with defining polynomial x^4 + 80*x^2 + 36
Defn: b |--> 1/12*c^3 + 43/6*c
```
list()[source]#

Return a list of all the elements of `self` (for which the domain is a relative number field).

EXAMPLES:

```sage: x = polygen(ZZ, 'x')
sage: K.<a, b> = NumberField([x^2 + x + 1, x^3 + 2])
sage: End(K).list()
[
Relative number field endomorphism of
Number Field in a with defining polynomial x^2 + x + 1 over its base field
Defn: a |--> a
b |--> b,
...
Relative number field endomorphism of
Number Field in a with defining polynomial x^2 + x + 1 over its base field
Defn: a |--> a
b |--> -b*a - b
]
```
```>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField([x**Integer(2) + x + Integer(1), x**Integer(3) + Integer(2)], names=('a', 'b',)); (a, b,) = K._first_ngens(2)
>>> End(K).list()
[
Relative number field endomorphism of
Number Field in a with defining polynomial x^2 + x + 1 over its base field
Defn: a |--> a
b |--> b,
...
Relative number field endomorphism of
Number Field in a with defining polynomial x^2 + x + 1 over its base field
Defn: a |--> a
b |--> -b*a - b
]
```

An example with an absolute codomain:

```sage: x = polygen(ZZ, 'x')
sage: K.<a, b> = NumberField([x^2 - 3, x^2 + 2])
sage: Hom(K, CyclotomicField(24, 'z')).list()
[
Relative number field morphism:
From: Number Field in a with defining polynomial x^2 - 3 over its base field
To:   Cyclotomic Field of order 24 and degree 8
Defn: a |--> z^6 - 2*z^2
b |--> -z^5 - z^3 + z,
...
Relative number field morphism:
From: Number Field in a with defining polynomial x^2 - 3 over its base field
To:   Cyclotomic Field of order 24 and degree 8
Defn: a |--> -z^6 + 2*z^2
b |--> z^5 + z^3 - z
]
```
```>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField([x**Integer(2) - Integer(3), x**Integer(2) + Integer(2)], names=('a', 'b',)); (a, b,) = K._first_ngens(2)
>>> Hom(K, CyclotomicField(Integer(24), 'z')).list()
[
Relative number field morphism:
From: Number Field in a with defining polynomial x^2 - 3 over its base field
To:   Cyclotomic Field of order 24 and degree 8
Defn: a |--> z^6 - 2*z^2
b |--> -z^5 - z^3 + z,
...
Relative number field morphism:
From: Number Field in a with defining polynomial x^2 - 3 over its base field
To:   Cyclotomic Field of order 24 and degree 8
Defn: a |--> -z^6 + 2*z^2
b |--> z^5 + z^3 - z
]
```