7 | | This ticket implements very generic classes for ring extensions. Other more specific classes (e.g. for field extensions or even finite field extensions) are coming soon... |
| 7 | This ticket implements a generic class for ring extensions, and more specific classes for finite free ring extensions (as finite degree field extensions). |
| 8 | |
| 9 | Below is a small tutorial extracted from the documentation: |
| 10 | |
| 11 | {{{ |
| 12 | Extension of rings. |
| 13 | |
| 14 | Sage offers the possibility to work with ring extensions `L/K` as |
| 15 | actual parents and perform meaningful operations on them and their |
| 16 | elements. |
| 17 | |
| 18 | The simplest way to build an extension is to use the method |
| 19 | :meth:`sage.rings.ring.CommutativeRing.over` on the top ring, |
| 20 | that is `L`. |
| 21 | For example, the following line constructs the extension of |
| 22 | finite fields `\mathbf{F}_{5^4}/\mathbf{F}_{5^2}`:: |
| 23 | |
| 24 | sage: GF(5^4).over(GF(5^2)) |
| 25 | Field in z4 with defining polynomial x^2 + (4*z2 + 3)*x + z2 over its base |
| 26 | |
| 27 | By default, Sage reuses the canonical generator of the top ring |
| 28 | (here `z_4 \in \mathbf{F}_{5^4}`), together with its name. However, |
| 29 | the user can customize them by passing in appropriate arguments:: |
| 30 | |
| 31 | sage: F = GF(5^2) |
| 32 | sage: k = GF(5^4) |
| 33 | sage: z4 = k.gen() |
| 34 | sage: K.<a> = k.over(F, gen = 1-z4) |
| 35 | sage: K |
| 36 | Field in a with defining polynomial x^2 + z2*x + 4 over its base |
| 37 | |
| 38 | The base of the extension is available via the method :meth:`base` (or |
| 39 | equivalently :meth:`base_ring`):: |
| 40 | |
| 41 | sage: K.base() |
| 42 | Finite Field in z2 of size 5^2 |
| 43 | |
| 44 | It also possible to building an extension on top of another extension, |
| 45 | obtaining this way a tower of extensions:: |
| 46 | |
| 47 | sage: L.<b> = GF(5^8).over(K) |
| 48 | sage: L |
| 49 | Field in b with defining polynomial x^2 + (4*z2 + 3*a)*x + 1 - a over its base |
| 50 | sage: L.base() |
| 51 | Field in a with defining polynomial x^2 + z2*x + 4 over its base |
| 52 | sage: L.base().base() |
| 53 | Finite Field in z2 of size 5^2 |
| 54 | |
| 55 | The method :meth:`bases` gives access to the complete list of rings in |
| 56 | a tower:: |
| 57 | |
| 58 | sage: L.bases() |
| 59 | [Field in b with defining polynomial x^2 + (4*z2 + 3*a)*x + 1 - a over its base, |
| 60 | Field in a with defining polynomial x^2 + z2*x + 4 over its base, |
| 61 | Finite Field in z2 of size 5^2] |
| 62 | |
| 63 | Once we have constructed an extension (or a tower of extensions), we |
| 64 | have interesting methods attached to it. As a basic example, one can |
| 65 | compute a basis of the top ring over any base in the tower:: |
| 66 | |
| 67 | sage: L.basis_over(K) |
| 68 | [1, b] |
| 69 | sage: L.basis_over(F) |
| 70 | [1, a, b, a*b] |
| 71 | |
| 72 | When the base is omitted, the default is the natural base of the extension:: |
| 73 | |
| 74 | sage: L.basis_over() |
| 75 | [1, b] |
| 76 | |
| 77 | The method :meth:`sage.rings.ring_extension_element.RingExtensionWithBasis.vector` |
| 78 | computes the coordinates of an element according to the above basis:: |
| 79 | |
| 80 | sage: u = a + 2*b + 3*a*b |
| 81 | sage: u.vector() # over K |
| 82 | (a, 2 + 3*a) |
| 83 | sage: u.vector(F) |
| 84 | (0, 1, 2, 3) |
| 85 | |
| 86 | One can also compute traces and norms with respect to any base of the tower:: |
| 87 | |
| 88 | sage: u.trace() # over K |
| 89 | (2*z2 + 1) + (2*z2 + 1)*a |
| 90 | sage: u.trace(F) |
| 91 | z2 + 1 |
| 92 | sage: u.trace().trace() # over K, then over F |
| 93 | z2 + 1 |
| 94 | |
| 95 | sage: u.norm() # over K |
| 96 | (z2 + 1) + (4*z2 + 2)*a |
| 97 | sage: u.norm(F) |
| 98 | 2*z2 + 2 |
| 99 | |
| 100 | And minimal polynomials:: |
| 101 | |
| 102 | sage: u.minpoly() |
| 103 | x^2 + ((3*z2 + 4) + (3*z2 + 4)*a)*x + (z2 + 1) + (4*z2 + 2)*a |
| 104 | sage: u.minpoly(F) |
| 105 | x^4 + (4*z2 + 4)*x^3 + x^2 + (z2 + 1)*x + 2*z2 + 2 |
| 106 | }}} |