# HG changeset patch
# User John Cremona <john.cremona@gmail.com>
# Date 1244151511 -3600
# Node ID e9c8a156d9d3c9c316186deed452cd80b18ccbf7
# Parent 0b6b4751a6eafc40481b322ad6110092b79d56e5
[mq]: docrev
diff -r 0b6b4751a6ea -r e9c8a156d9d3 sage/rings/number_field/number_field.py
a
|
b
|
|
1435 | 1435 | |
1436 | 1436 | def specified_complex_embedding(self): |
1437 | 1437 | r""" |
1438 | | Returns the embedding of this field into the complex numbers has |
| 1438 | Returns the embedding of this field into the complex numbers which has |
1439 | 1439 | been specified. |
1440 | 1440 | |
1441 | 1441 | Fields created with the ``QuadraticField`` or |
… |
… |
|
3919 | 3919 | """ |
3920 | 3920 | Return generators for the unit group modulo torsion. |
3921 | 3921 | |
| 3922 | INPUT: |
| 3923 | |
| 3924 | - ``proof`` (bool, default True) flag passed to ``pari``. |
| 3925 | |
| 3926 | .. note:: |
| 3927 | |
| 3928 | For more functionality see the unit_group() function. |
| 3929 | |
3922 | 3930 | ALGORITHM: Uses PARI's bnfunit command. |
3923 | 3931 | |
3924 | | INPUTS: proof - default: True |
3925 | | |
3926 | | NOTE: For more functionality see the unit_group() function. |
3927 | | |
3928 | 3932 | EXAMPLES:: |
3929 | 3933 | |
3930 | 3934 | sage: x = QQ['x'].0 |
… |
… |
|
3995 | 3999 | |
3996 | 4000 | ALGORITHM: Uses PARI's bnfunit command. |
3997 | 4001 | |
3998 | | INPUTS: proof -- default: True |
3999 | | |
4000 | | NOTE: the group is cached. |
| 4002 | INPUT: |
| 4003 | |
| 4004 | - ``proof`` (bool, default True) flag passed to ``pari``. |
| 4005 | |
| 4006 | .. note:: |
| 4007 | |
| 4008 | The group is cached. |
4001 | 4009 | |
4002 | 4010 | EXAMPLES:: |
4003 | 4011 | |
… |
… |
|
6321 | 6329 | |
6322 | 6330 | If prec is 53 (the default), then the complex double field is used; |
6323 | 6331 | otherwise the arbitrary precision (but slow) complex field is used. |
| 6332 | |
6324 | 6333 | EXAMPLES:: |
6325 | 6334 | |
6326 | 6335 | sage: C = CyclotomicField(4) |
… |
… |
|
6788 | 6797 | return self.gen() |
6789 | 6798 | |
6790 | 6799 | class NumberField_quadratic(NumberField_absolute): |
6791 | | """ |
| 6800 | r""" |
6792 | 6801 | Create a quadratic extension of the rational field. |
6793 | 6802 | |
6794 | | The command QuadraticField(a) creates the field Q(sqrt(a)). |
| 6803 | The command ``QuadraticField(a)`` creates the field `\QQ(\sqrt{a})`. |
6795 | 6804 | |
6796 | 6805 | EXAMPLES:: |
6797 | 6806 | |
… |
… |
|
6945 | 6954 | field is negative, then the following warning from the PARI manual |
6946 | 6955 | applies: |
6947 | 6956 | |
6948 | | IMPORTANT WARNING: For `D<0`, this function may give |
6949 | | incorrect results when the class group has a low exponent |
6950 | | (has many cyclic factors), because implementing Shank's |
6951 | | method in full generality slows it down immensely. |
| 6957 | .. warning:: |
| 6958 | |
| 6959 | For `D<0`, this function may give incorrect results when |
| 6960 | the class group has a low exponent (has many cyclic |
| 6961 | factors), because implementing Shank's method in full |
| 6962 | generality slows it down immensely. |
6952 | 6963 | |
6953 | 6964 | EXAMPLES:: |
6954 | 6965 | |
… |
… |
|
6963 | 6974 | |
6964 | 6975 | It is an open problem to *prove* that there are infinity many |
6965 | 6976 | positive square-free `d` such that |
6966 | | `\QQ(\sqrt{d})` has class number `1`:n |
| 6977 | `\QQ(\sqrt{d})` has class number `1`: |
6967 | 6978 | |
6968 | 6979 | :: |
6969 | 6980 | |
… |
… |
|
7221 | 7232 | |
7222 | 7233 | |
7223 | 7234 | def refine_embedding(e, prec=None): |
7224 | | """ |
7225 | | Given an embedding e: K->RR or CC, returns an equivalent embedding |
7226 | | with higher precision. |
| 7235 | r""" |
| 7236 | Given an embedding from a number field to either `\RR` or |
| 7237 | `\CC`, returns an equivalent embedding with higher precision. |
7227 | 7238 | |
7228 | 7239 | INPUT: |
7229 | | |
| 7240 | |
7230 | 7241 | |
7231 | 7242 | - ``e`` - an embedding of a number field into either |
7232 | 7243 | RR or CC (with some precision) |
diff -r 0b6b4751a6ea -r e9c8a156d9d3 sage/rings/number_field/number_field_ideal.py
a
|
b
|
|
166 | 166 | is in the ideal. |
167 | 167 | |
168 | 168 | AUTHOR: John Cremona 2008-10-31 |
169 | | Uses linear algebra. The change-of-basis matrix is |
170 | | cached. Provides simpler implementations for |
171 | | _contains_(), is_integral() and smallest_integer(). |
| 169 | |
| 170 | ALGORITHM: |
| 171 | |
| 172 | Uses linear algebra. The change-of-basis matrix is cached. |
| 173 | Provides simpler implementations for ``_contains_()``, |
| 174 | ``is_integral()`` and ``smallest_integer()``. |
172 | 175 | |
173 | 176 | EXAMPLES:: |
174 | 177 | |
… |
… |
|
363 | 366 | return self.__pari_hnf |
364 | 367 | |
365 | 368 | def basis(self): |
366 | | """ |
| 369 | r""" |
367 | 370 | Return an immutable sequence of elements of this ideal (note: |
368 | 371 | their parent is the number field) that form a basis for this |
369 | | ideal viewed as a ZZ-module. |
| 372 | ideal viewed as a `\ZZ` -module. |
370 | 373 | |
371 | 374 | OUTPUT: |
372 | 375 | basis -- an immutable sequence. |
… |
… |
|
397 | 400 | return self.__basis |
398 | 401 | |
399 | 402 | def free_module(self): |
400 | | """ |
401 | | Return the free ZZ-module contained in the vector space |
| 403 | r""" |
| 404 | Return the free `\ZZ`-module contained in the vector space |
402 | 405 | associated to the ambient number field, that corresponds |
403 | 406 | to this ideal. |
404 | 407 | |
… |
… |
|
418 | 421 | [ 5 1 1 0 1 0] |
419 | 422 | [ 5 6 2 1 1 1] |
420 | 423 | |
421 | | However, the actual ZZ-module is not at all random:: |
| 424 | However, the actual `\ZZ`-module is not at all random:: |
422 | 425 | |
423 | 426 | sage: A.basis_matrix().change_ring(ZZ).echelon_form() |
424 | 427 | [ 1 0 0 5 1 1] |
… |
… |
|
599 | 602 | return self.__elements_from_hnf(hnf) |
600 | 603 | |
601 | 604 | def integral_split(self): |
602 | | """ |
603 | | Return a tuple (I, d), where I is an integral ideal, and d is the |
604 | | smallest positive integer such that this ideal is equal to I/d. |
| 605 | r""" |
| 606 | Return a tuple `(I, d)`, where `I` is an integral ideal, and `d` is the |
| 607 | smallest positive integer such that this ideal is equal to `I/d`. |
605 | 608 | |
606 | 609 | EXAMPLES:: |
607 | 610 | |
… |
… |
|
913 | 916 | |
914 | 917 | def valuation(self, p): |
915 | 918 | r""" |
916 | | Return the valuation of this fractional ideal at the prime |
| 919 | Return the valuation of self at ``p``. |
| 920 | |
| 921 | INPUT: |
| 922 | |
| 923 | - ``p`` -- a prime ideal `\mathfrak{p}` of this number field. |
| 924 | |
| 925 | OUTPUT: |
| 926 | |
| 927 | (integer) The valuation of this fractional ideal at the prime |
917 | 928 | `\mathfrak{p}`. If `\mathfrak{p}` is not prime, raise a |
918 | 929 | ValueError. |
919 | 930 | |
920 | | INPUT: |
921 | | p -- a prime ideal of this number field. |
922 | | |
923 | | OUTPUT: |
924 | | integer |
925 | | |
926 | 931 | EXAMPLES:: |
927 | 932 | |
928 | 933 | sage: K.<a> = NumberField(x^5 + 2); K |
… |
… |
|
952 | 957 | return ZZ(nf.idealval(self.pari_hnf(), p._pari_prime)) |
953 | 958 | |
954 | 959 | def decomposition_group(self): |
955 | | """ |
956 | | Return the decomposition group of self, as a subset of the automorphism |
957 | | group of the number field of self. Raises an error if the field isn't |
958 | | Galois. See the decomposition_group method of the GaloisGroup_v2 class |
959 | | for further examples and doctests. |
| 960 | r""" |
| 961 | Return the decomposition group of self, as a subset of the |
| 962 | automorphism group of the number field of self. Raises an |
| 963 | error if the field isn't Galois. See the decomposition_group |
| 964 | method of the ``GaloisGroup_v2`` class for further examples |
| 965 | and doctests. |
960 | 966 | |
961 | 967 | EXAMPLE:: |
962 | 968 | |
… |
… |
|
966 | 972 | return self.number_field().galois_group().decomposition_group(self) |
967 | 973 | |
968 | 974 | def ramification_group(self, v): |
969 | | """ |
970 | | Return the vth ramification group of self, i.e. the set of elements s |
971 | | of the Galois group of the number field of self (which we assume is Galois) |
972 | | such that s acts trivially modulo self^(v+1). See the |
973 | | ramification_group method of the GaloisGroup class for further examples |
974 | | and doctests. |
| 975 | r""" |
| 976 | Return the `v`'th ramification group of self, i.e. the set of |
| 977 | elements `s` of the Galois group of the number field of self |
| 978 | (which we assume is Galois) such that `s` acts trivially |
| 979 | modulo the `(v+1)`'st power of self. See the |
| 980 | ramification_group method of the ``GaloisGroup`` class for |
| 981 | further examples and doctests. |
975 | 982 | |
976 | 983 | EXAMPLE:: |
977 | 984 | |
… |
… |
|
984 | 991 | return self.number_field().galois_group().ramification_group(self, v) |
985 | 992 | |
986 | 993 | def inertia_group(self): |
987 | | """ |
| 994 | r""" |
988 | 995 | Return the inertia group of self, i.e. the set of elements s of the |
989 | 996 | Galois group of the number field of self (which we assume is Galois) |
990 | 997 | such that s acts trivially modulo self. This is the same as the 0th |
991 | 998 | ramification group of self. See the inertia_group method of the |
992 | | GaloisGroup_v2 class for further examples and doctests. |
| 999 | ``GaloisGroup_v2`` class for further examples and doctests. |
993 | 1000 | |
994 | 1001 | EXAMPLE:: |
995 | 1002 | |
… |
… |
|
999 | 1006 | return self.ramification_group(0) |
1000 | 1007 | |
1001 | 1008 | def artin_symbol(self): |
1002 | | """ |
1003 | | Return the Artin symbol ( K / Q, self), where K is the number field of self. |
1004 | | This is the unique element s of the decomposition group of self such that |
1005 | | s(x) = x^p mod self where p is the residue characteristic of self. |
1006 | | (Here self should be prime and unramified.) |
| 1009 | r""" |
| 1010 | Return the Artin symbol `( K / \QQ, P)`, where `K` is the |
| 1011 | number field of `P` =self. This is the unique element `s` of |
| 1012 | the decomposition group of `P` such that `s(x) = x^p \pmod{P}` |
| 1013 | where `p` is the residue characteristic of `P`. (Here `P` |
| 1014 | (self) should be prime and unramified.) |
1007 | 1015 | |
1008 | | See the artin_symbol method of the GaloisGroup_v2 class for further |
1009 | | documentation and examples. |
| 1016 | See the ``artin_symbol`` method of the ``GaloisGroup_v2`` |
| 1017 | class for further documentation and examples. |
1010 | 1018 | |
1011 | 1019 | EXAMPLE:: |
1012 | 1020 | |
… |
… |
|
1016 | 1024 | return self.number_field().galois_group().artin_symbol(self) |
1017 | 1025 | |
1018 | 1026 | def basis_to_module(B, K): |
1019 | | """ |
1020 | | Given a basis B of elements for a ZZ-submodule of a number field K, return |
1021 | | the corresponding ZZ-submodule. |
| 1027 | r""" |
| 1028 | Given a basis `B` of elements for a `\ZZ`-submodule of a number |
| 1029 | field `K`, return the corresponding `\ZZ`-submodule. |
1022 | 1030 | |
1023 | 1031 | EXAMPLES:: |
1024 | 1032 | |
… |
… |
|
1370 | 1378 | `I`, i.e. a list of elements in the ring of integers `R` representing |
1371 | 1379 | the elements of `(R/I)^*`. |
1372 | 1380 | |
1373 | | METHOD: Use pari's ``idealstar`` to find the group structure and |
| 1381 | ALGORITHM: Use pari's ``idealstar`` to find the group structure and |
1374 | 1382 | generators of the multiplicative group modulo the ideal. |
1375 | 1383 | |
1376 | 1384 | EXAMPLES:: |
… |
… |
|
1501 | 1509 | |
1502 | 1510 | def denominator(self): |
1503 | 1511 | r""" |
1504 | | Return the denominator ideal of this fractional ideal. Each fractional |
1505 | | ideal has a unique expression as `N/D` where N, D are coprime integral |
1506 | | ideals; the denominator is D. |
| 1512 | Return the denominator ideal of this fractional ideal. Each |
| 1513 | fractional ideal has a unique expression as `N/D` where `N`, |
| 1514 | `D` are coprime integral ideals; the denominator is `D`. |
1507 | 1515 | |
1508 | 1516 | EXAMPLES:: |
1509 | 1517 | |
… |
… |
|
1529 | 1537 | return self._denom_ideal |
1530 | 1538 | |
1531 | 1539 | def numerator(self): |
1532 | | """ |
| 1540 | r""" |
1533 | 1541 | Return the numerator ideal of this fractional ideal. |
1534 | 1542 | |
1535 | | Each fractional ideal has a unique expression as N/D where N, |
1536 | | D are coprime integral ideals. The numerator is N. |
| 1543 | Each fractional ideal has a unique expression as `N/D` where `N`, |
| 1544 | `D` are coprime integral ideals. The numerator is `N`. |
1537 | 1545 | |
1538 | 1546 | EXAMPLES:: |
1539 | 1547 | |
… |
… |
|
1563 | 1571 | Returns True if this ideal is coprime to the other, else False. |
1564 | 1572 | |
1565 | 1573 | INPUT: |
1566 | | other -- another ideal of the same field, or generators of an ideal. |
| 1574 | |
| 1575 | - ``other`` -- another ideal of the same field, or generators |
| 1576 | of an ideal. |
1567 | 1577 | |
1568 | 1578 | OUTPUT: |
1569 | | True if self and other are coprime, else False. |
| 1579 | |
| 1580 | True if self and other are coprime, else False. |
1570 | 1581 | |
1571 | | NOTE: |
| 1582 | .. note:: |
| 1583 | |
1572 | 1584 | This function works for fractional ideals as well as |
1573 | 1585 | integral ideals. |
1574 | 1586 | |
… |
… |
|
1658 | 1670 | return k(l) |
1659 | 1671 | |
1660 | 1672 | def small_residue(self, f): |
1661 | | """ |
1662 | | Given an element f of the ambient number field, returns an |
1663 | | element g such that f - g belongs to the ideal self (which |
1664 | | must be integral), and g is small. |
| 1673 | r""" |
| 1674 | Given an element `f` of the ambient number field, returns an |
| 1675 | element `g` such that `f - g` belongs to the ideal self (which |
| 1676 | must be integral), and `g` is small. |
1665 | 1677 | |
1666 | 1678 | .. note:: |
1667 | 1679 | |
… |
… |
|
1736 | 1748 | |
1737 | 1749 | INPUT: |
1738 | 1750 | |
1739 | | - flag -- when flag=2, it also computes the generators of the |
1740 | | group `(O_K/I)^*`, which takes more time. By default flag=1 |
1741 | | (no generators are computed). In both cases the special pari |
1742 | | structure ``bid`` is computed as well. If flag=0 |
1743 | | (deprecated) it computes only the group structure of |
1744 | | `(O_K/I)^*` (with generators) and not the special ``bid`` |
1745 | | structure. OUTPUT: The finite abelian group `(O_K/I)^*`. |
| 1751 | - ``flag`` (int default 1) -- when ``flag`` =2, it also |
| 1752 | computes the generators of the group `(O_K/I)^*`, which |
| 1753 | takes more time. By default ``flag`` =1 (no generators are |
| 1754 | computed). In both cases the special pari structure ``bid`` |
| 1755 | is computed as well. If ``flag`` =0 (deprecated) it computes |
| 1756 | only the group structure of `(O_K/I)^*` (with generators) |
| 1757 | and not the special ``bid`` structure. |
| 1758 | |
| 1759 | OUTPUT: |
| 1760 | |
| 1761 | The finite abelian group `(O_K/I)^*`. |
1746 | 1762 | |
1747 | 1763 | .. note:: |
1748 | 1764 | |
… |
… |
|
1789 | 1805 | INPUT: |
1790 | 1806 | |
1791 | 1807 | - ``x`` - a non-zero element of the number field of self, |
1792 | | which must have valuation equal to 0 at all prime |
1793 | | ideals in the support of the ideal self. |
| 1808 | which must have valuation equal to 0 at all prime ideals in |
| 1809 | the support of the ideal self. |
1794 | 1810 | |
1795 | 1811 | OUTPUT: |
1796 | 1812 | |
1797 | 1813 | - ``l`` - a list of integers `(x_i)` such that `0 \leq x_i < d_i` and |
1798 | | `x = \prod_i g_i^{x_i}` in `(R/I)^*`, where I = self, R = ring of |
| 1814 | `x = \prod_i g_i^{x_i}` in `(R/I)^*`, where `I` = self, `R` = ring of |
1799 | 1815 | integers of the field, and `g_i` are the generators of `(R/I)^*`, of |
1800 | 1816 | orders `d_i` respectively, as given in the ``bid`` structure of |
1801 | 1817 | the ideal self. |
… |
… |
|
1824 | 1840 | return [ZZ(l) for l in k.pari_nf().ideallog(x._pari_(), self._pari_bid_(2))] |
1825 | 1841 | |
1826 | 1842 | def element_1_mod(self, other): |
1827 | | """ |
1828 | | Returns an element r in this ideal such that 1-r is in other |
| 1843 | r""" |
| 1844 | Returns an element `r` in this ideal such that `1-r` is in other |
1829 | 1845 | |
1830 | 1846 | An error is raised if either ideal is not integral of if they |
1831 | 1847 | are not coprime. |
1832 | 1848 | |
1833 | 1849 | INPUT: |
1834 | | other -- another ideal of the same field, or generators of an ideal. |
| 1850 | |
| 1851 | - ``other`` -- another ideal of the same field, or generators |
| 1852 | of an ideal. |
| 1853 | |
1835 | 1854 | OUTPUT: |
1836 | | r -- an element of the ideal self such that 1-r is in the ideal other |
| 1855 | |
| 1856 | An element `r` of the ideal self such that `1-r` is in the ideal other |
1837 | 1857 | |
1838 | 1858 | AUTHOR: Maite Aranes |
1839 | 1859 | |
… |
… |
|
1948 | 1968 | for p,e in self.factor()]]) |
1949 | 1969 | |
1950 | 1970 | def prime_to_idealM_part(self, M): |
1951 | | """ |
1952 | | Version for integral ideals of the prime_to_m_part function over ZZ. |
1953 | | Returns the largest divisor of self that is coprime to the ideal M. |
| 1971 | r""" |
| 1972 | Version for integral ideals of the ``prime_to_m_part`` function over `\ZZ`. |
| 1973 | Returns the largest divisor of self that is coprime to the ideal ``M``. |
1954 | 1974 | |
1955 | 1975 | INPUT: |
1956 | | M -- an integral ideal of the same field, or generators of an ideal |
| 1976 | |
| 1977 | - ``M`` -- an integral ideal of the same field, or generators of an ideal |
1957 | 1978 | |
1958 | 1979 | OUTPUT: |
1959 | | An ideal which is the largest divisor of self that is coprime to M. |
| 1980 | |
| 1981 | An ideal which is the largest divisor of self that is coprime to `M`. |
1960 | 1982 | |
1961 | 1983 | AUTHOR: Maite Aranes |
1962 | 1984 | |
… |
… |
|
2214 | 2236 | return "Lifting map to %s from quotient of integers by %s"%(self.__OK, self.__I) |
2215 | 2237 | |
2216 | 2238 | def quotient_char_p(I, p): |
2217 | | """ |
2218 | | Given an integral ideal I that contains a prime number p, compute |
2219 | | a vector space V = (OK mod p) / (I mod p), along with a |
2220 | | homomorphism OK --> V and a section V --> OK. |
| 2239 | r""" |
| 2240 | Given an integral ideal `I` that contains a prime number `p`, compute |
| 2241 | a vector space `V = (O_K \mod p) / (I \mod p)`, along with a |
| 2242 | homomorphism `O_K \to V` and a section `V \to O_K`. |
2221 | 2243 | |
2222 | 2244 | EXAMPLES:: |
2223 | 2245 | |
diff -r 0b6b4751a6ea -r e9c8a156d9d3 sage/rings/number_field/number_field_ideal_rel.py
a
|
b
|
|
1 | | """ |
| 1 | r""" |
2 | 2 | Relative Number Field Ideals |
3 | 3 | |
4 | 4 | AUTHORS: |
… |
… |
|
55 | 55 | sage: i = K.ideal(38); i |
56 | 56 | Fractional ideal (38) |
57 | 57 | |
58 | | WARNING: Ideals in relative number fields are broken:: |
| 58 | .. warning:: |
| 59 | |
| 60 | Ideals in relative number fields are broken:: |
59 | 61 | |
60 | 62 | sage: K.<a0, a1> = NumberField([x^2 + 1, x^2 + 2]); K |
61 | 63 | Number Field in a0 with defining polynomial x^2 + 1 over its base field |
… |
… |
|
116 | 118 | return self.__pari_rhnf |
117 | 119 | |
118 | 120 | def absolute_ideal(self): |
119 | | """ |
120 | | If this is an ideal in the extension L/K, return the ideal with |
121 | | the same generators in the absolute field L/Q. |
| 121 | r""" |
| 122 | If this is an ideal in the extension `L/K`, return the ideal with |
| 123 | the same generators in the absolute field `L/\QQ`. |
122 | 124 | |
123 | 125 | EXAMPLES:: |
124 | 126 | |
… |
… |
|
127 | 129 | sage: L.<c> = K.extension(x^2 - b) |
128 | 130 | sage: F = L.absolute_field('a') |
129 | 131 | |
130 | | Let's check an inert ideal first:: |
| 132 | An example of an inert ideal:: |
131 | 133 | |
132 | 134 | sage: P = F.factor(13)[0][0]; P |
133 | 135 | Fractional ideal (13) |
… |
… |
|
135 | 137 | sage: J.absolute_ideal() |
136 | 138 | Fractional ideal (13) |
137 | 139 | |
138 | | Now how about a non-trivial ideal in L, but one that is actually |
139 | | principal in the subfield K:: |
| 140 | Now a non-trivial ideal in `L` that is principal in the |
| 141 | subfield `K`:: |
140 | 142 | |
141 | 143 | sage: J = L.ideal(b); J |
142 | 144 | Fractional ideal (b) |
… |
… |
|
149 | 151 | sage: J.absolute_ideal().norm() |
150 | 152 | 4 |
151 | 153 | |
152 | | Now an ideal not generated by an element of K:: |
| 154 | Now an ideal not generated by an element of `K`:: |
153 | 155 | |
154 | 156 | sage: J = L.ideal(c); J |
155 | 157 | Fractional ideal (c) |
… |
… |
|
310 | 312 | raise NotImplementedError, "For a fractional ideal in a relative number field you must use relative_norm or absolute_norm as appropriate" |
311 | 313 | |
312 | 314 | def ideal_below(self): |
313 | | """ |
314 | | Compute the ideal of K below this ideal of L. |
| 315 | r""" |
| 316 | Compute the ideal of `K` below this ideal of `L`. |
315 | 317 | |
316 | 318 | EXAMPLES:: |
317 | 319 | |
… |
… |
|
437 | 439 | raise NotImplementedError |
438 | 440 | |
439 | 441 | def integral_split(self): |
440 | | """ |
441 | | Return a tuple (I, d), where I is an integral ideal, and d is the |
442 | | smallest positive integer such that this ideal is equal to I/d. |
| 442 | r""" |
| 443 | Return a tuple `(I, d)`, where `I` is an integral ideal, and `d` is the |
| 444 | smallest positive integer such that this ideal is equal to `I/d`. |
443 | 445 | |
444 | 446 | EXAMPLES:: |
445 | 447 | |
… |
… |
|
549 | 551 | raise ValueError, "the fractional ideal (= %s) is not prime"%self |
550 | 552 | |
551 | 553 | def ramification_index(self): |
552 | | """ |
553 | | For ideals in relative number fields ramification_index is |
554 | | deliberately not implemented in order to avoid ambiguity. Either |
555 | | relative_ramification_index or absolute_ramification_index should |
556 | | be used instead. |
| 554 | r""" |
| 555 | For ideals in relative number fields, ``ramification_index`` |
| 556 | is deliberately not implemented in order to avoid ambiguity. |
| 557 | Either ``relative_ramification_index`` or |
| 558 | ``absolute_ramification_index`` should be used instead. |
557 | 559 | """ |
558 | 560 | raise NotImplementedError, "For an ideal in a relative number field you must use relative_ramification_index or absolute_ramification_index as appropriate" |
559 | 561 | |
560 | 562 | def residue_class_degree(self): |
561 | | """ |
| 563 | r""" |
| 564 | Return the resifue class degree of this prime. |
| 565 | |
562 | 566 | EXAMPLES:: |
563 | 567 | |
564 | 568 | sage: PQ.<X> = QQ[] |
… |
… |
|
596 | 600 | return xmrange_iter(abs_residues.iter_list, lambda c: from_abs(abs_residues.typ(c))) |
597 | 601 | |
598 | 602 | def element_1_mod(self, other): |
599 | | """ |
600 | | Returns an element r in this ideal such that 1-r is in other. |
| 603 | r""" |
| 604 | Returns an element `r` in this ideal such that `1-r` is in other. |
601 | 605 | |
602 | 606 | An error is raised if either ideal is not integral of if they |
603 | 607 | are not coprime. |
604 | 608 | |
605 | 609 | INPUT: |
606 | 610 | |
607 | | - other -- another ideal of the same field, or generators of an ideal. |
| 611 | - ``other`` -- another ideal of the same field, or generators of an ideal. |
608 | 612 | |
609 | | OUTPUT: an element of the ideal self such that 1-r is in the ideal |
610 | | other. |
| 613 | OUTPUT: |
| 614 | |
| 615 | an element `r` of the ideal self such that `1-r` is in the |
| 616 | ideal other. |
611 | 617 | |
612 | 618 | EXAMPLES:: |
613 | 619 | |
… |
… |
|
655 | 661 | |
656 | 662 | def valuation(self, p): |
657 | 663 | r""" |
658 | | Return the valuation of this fractional ideal at the prime |
659 | | `\mathfrak{p}`. If `\mathfrak{p}` is not prime, raise a ValueError. |
| 664 | Return the valuation of this fractional ideal at ``p``. |
660 | 665 | |
661 | 666 | INPUT: |
662 | 667 | |
663 | | - p -- a prime ideal of this relative number field. |
| 668 | - ``p`` -- a prime ideal `\mathfrak{p}` of this relative number field. |
664 | 669 | |
665 | | OUTPUT: integer |
| 670 | OUTPUT: |
| 671 | |
| 672 | (integer) The valuation of this fractional ideal at the prime |
| 673 | `\mathfrak{p}`. If `\mathfrak{p}` is not prime, raise a |
| 674 | ValueError. |
| 675 | |
666 | 676 | |
667 | 677 | EXAMPLES:: |
668 | 678 | |
diff -r 0b6b4751a6ea -r e9c8a156d9d3 sage/rings/number_field/number_field_rel.py
a
|
b
|
|
1 | 1 | r""" |
2 | 2 | Relative Number Fields |
3 | 3 | |
4 | | AUTHORS:: |
| 4 | AUTHORS: |
5 | 5 | |
6 | 6 | - William Stein (2004, 2005): initial version |
7 | 7 | - Steven Sivek (2006-05-12): added support for relative extensions |
… |
… |
|
151 | 151 | # from sage.rings.number_field.number_field import is_CyclotomicField |
152 | 152 | |
153 | 153 | def is_RelativeNumberField(x): |
154 | | """ |
155 | | Return True if x is a relative number field. |
| 154 | r""" |
| 155 | Return True if `x` is a relative number field. |
156 | 156 | |
157 | 157 | EXAMPLES:: |
158 | 158 | |
… |
… |
|
171 | 171 | |
172 | 172 | class NumberField_relative(NumberField_generic): |
173 | 173 | """ |
| 174 | INPUT: |
| 175 | |
| 176 | - ``base`` -- the base field |
| 177 | - ``polynomial`` -- must be defined in the ring `K[x]`, where `K` is |
| 178 | the base field. |
| 179 | - ``name`` -- variable name |
| 180 | - ``latex_name`` -- latex variable name |
| 181 | - ``names`` -- alternative to name |
| 182 | - ``check`` -- whether to check irreducibility of polynomial. |
| 183 | |
174 | 184 | EXAMPLES:: |
175 | 185 | |
176 | 186 | sage: K.<a> = NumberField(x^3 - 2) |
… |
… |
|
183 | 193 | r""" |
184 | 194 | INPUT: |
185 | 195 | |
186 | | - base -- the base field |
187 | | - polynomial -- must be defined in the ring ``K['x']``, where K is |
| 196 | - ``base`` -- the base field |
| 197 | - ``polynomial`` -- must be defined in the ring `K[x]`, where `K` is |
188 | 198 | the base field. |
189 | | - name -- variable name |
190 | | - latex_name -- latex variable name |
191 | | - names -- alternative to name |
192 | | - check -- whether to check irreducibility of polynomial. |
| 199 | - ``name`` -- variable name |
| 200 | - ``latex_name`` -- latex variable name |
| 201 | - ``names`` -- alternative to name |
| 202 | - ``check`` -- whether to check irreducibility of polynomial. |
193 | 203 | |
194 | 204 | EXAMPLES:: |
195 | 205 | |
… |
… |
|
219 | 229 | Number Field in a1 with defining polynomial x^2 + 1 |
220 | 230 | |
221 | 231 | TESTS: |
222 | | Let's ensure that irreducibility testing is working:: |
| 232 | |
| 233 | Test that irreducibility testing is working:: |
223 | 234 | |
224 | 235 | sage: x = ZZ['x'].0 |
225 | 236 | sage: K.<a, b> = NumberField([x^2 + 2, x^2 + 3]) |
… |
… |
|
314 | 325 | |
315 | 326 | INPUT: |
316 | 327 | |
317 | | - names -- number of names should be at most the number of generators |
318 | | of self, i.e., the number of steps in the tower of relative fields. |
| 328 | - ``names`` -- number of names should be at most the number of |
| 329 | generators of self, i.e., the number of steps in the tower |
| 330 | of relative fields. |
319 | 331 | |
320 | | Also, ``K.structure()`` returns from_K and to_K, where |
321 | | from_K is an isomorphism from K to self and to_K is an |
322 | | isomorphism from self to K. |
| 332 | Also, ``K.structure()`` returns ``from_K`` and ``to_K``, where |
| 333 | from_K is an isomorphism from `K` to self and ``to_K`` is an |
| 334 | isomorphism from self to `K`. |
323 | 335 | |
324 | 336 | EXAMPLES:: |
325 | 337 | |
… |
… |
|
372 | 384 | return L |
373 | 385 | |
374 | 386 | def is_absolute(self): |
375 | | """ |
| 387 | r""" |
| 388 | Returns False, since this is not an absolute field. |
| 389 | |
376 | 390 | EXAMPLES:: |
377 | 391 | |
378 | 392 | sage: K.<a,b> = NumberField([x^4 + 3, x^2 + 2]); K |
… |
… |
|
414 | 428 | |
415 | 429 | def gen(self, n=0): |
416 | 430 | """ |
417 | | Return the n'th generator of this relative number field. |
| 431 | Return the `n`'th generator of this relative number field. |
418 | 432 | |
419 | 433 | EXAMPLES:: |
420 | 434 | |
… |
… |
|
430 | 444 | return self.__gens[n] |
431 | 445 | |
432 | 446 | def galois_closure(self, names=None): |
433 | | """ |
| 447 | r""" |
434 | 448 | Return the absolute number field `K` that is the Galois closure of this |
435 | 449 | relative number field. |
436 | 450 | |
… |
… |
|
456 | 470 | return self.absolute_polynomial().degree() |
457 | 471 | |
458 | 472 | def relative_degree(self): |
459 | | """ |
| 473 | r""" |
| 474 | Returns the relative degree of this relative number field. |
460 | 475 | |
461 | 476 | EXAMPLES:: |
462 | 477 | |
… |
… |
|
564 | 579 | |
565 | 580 | def _latex_(self): |
566 | 581 | r""" |
567 | | Return a \LaTeX representation of the extension. |
| 582 | Return a `\LaTeX` representation of the extension. |
568 | 583 | |
569 | 584 | EXAMPLES:: |
570 | 585 | |
… |
… |
|
586 | 601 | |
587 | 602 | INPUT: |
588 | 603 | |
589 | | - x -- an element of some number field |
| 604 | - ``x`` -- an element of some number field |
590 | 605 | |
591 | 606 | EXAMPLES:: |
592 | 607 | |
… |
… |
|
605 | 620 | raise TypeError, "Cannot coerce element into this number field" |
606 | 621 | |
607 | 622 | def _coerce_non_number_field_element_in(self, x): |
608 | | """ |
609 | | Coerce a non-number field element x into this number field. |
| 623 | r""" |
| 624 | Coerce the non-number field element `x` into this number field. |
610 | 625 | |
611 | 626 | INPUT: |
612 | 627 | |
613 | | - x -- a non number field element x, e.g., a list, integer, rational, |
614 | | or polynomial. |
| 628 | - ``x`` -- a non number field element, e.g., a list, |
| 629 | integer, rational, or polynomial. |
615 | 630 | |
616 | 631 | EXAMPLES:: |
617 | 632 | |
… |
… |
|
645 | 660 | TypeError: <class 'sage.rings.polynomial.polynomial_element_generic.Polynomial_generic_dense_field'> |
646 | 661 | |
647 | 662 | One can also coerce an element of the polynomial quotient ring |
648 | | that's isomorphic to the number field:: |
| 663 | that is isomorphic to the number field:: |
649 | 664 | |
650 | 665 | sage: K.<a> = NumberField(x^3 + 17) |
651 | 666 | sage: b = K.polynomial_quotient_ring().random_element() |
… |
… |
|
811 | 826 | |
812 | 827 | There are situations for which one might imagine canonical |
813 | 828 | coercion could make sense (at least after fixing choices), but |
814 | | which aren't yet implemented:: |
| 829 | which are not yet implemented:: |
815 | 830 | |
816 | 831 | sage: K.<a> = QuadraticField(2) |
817 | 832 | sage: K.coerce(sqrt(2)) |
… |
… |
|
825 | 840 | sage: type(K.coerce_map_from(QQ)) |
826 | 841 | <type 'sage.structure.coerce_maps.DefaultConvertMap_unique'> |
827 | 842 | |
828 | | Make sure we still get our optimized morphisms for special fields: |
| 843 | Make sure we still get our optimized morphisms for special fields:: |
| 844 | |
829 | 845 | sage: K.<a> = NumberField(polygen(QQ)^2-2) |
830 | 846 | sage: type(K.coerce_map_from(QQ)) |
831 | 847 | <type 'sage.rings.number_field.number_field_element_quadratic.Q_to_quadratic_field_element'> |
… |
… |
|
848 | 864 | |
849 | 865 | def _coerce_map_from_(self, R): |
850 | 866 | """ |
851 | | Canonical implicit coercion of x into self. |
| 867 | Canonical implicit coercion of ``R`` into self. |
852 | 868 | |
853 | 869 | Elements of this field canonically coerce in, as does anything |
854 | 870 | that coerces into the base field of this field. |
… |
… |
|
875 | 891 | |
876 | 892 | def _rnfeltreltoabs(self, element, check=False): |
877 | 893 | r""" |
878 | | Return PARI's rnfeletreltoabs, but without requiring rnfinit(). |
| 894 | Return PARI's ``rnfeletreltoabs()``, but without requiring ``rnfinit()``. |
879 | 895 | |
880 | 896 | TESTS:: |
881 | 897 | |
… |
… |
|
956 | 972 | return sage.rings.number_field.number_field_ideal_rel.NumberFieldFractionalIdeal_rel |
957 | 973 | |
958 | 974 | def _pari_base_bnf(self, certify=False, units=True): |
959 | | """ |
| 975 | r""" |
960 | 976 | Return the PARI bnf (big number field) representation of the |
961 | | absolute base field in terms of the pari variable y, suitable |
962 | | for extension by the pari variable x. |
| 977 | absolute base field in terms of the pari variable ``y``, suitable |
| 978 | for extension by the pari variable ``x``. |
963 | 979 | |
964 | 980 | All caching is done by the absolute base field. |
965 | 981 | |
966 | 982 | INPUT: |
967 | 983 | |
968 | | - proof -- bool (default: True) if True, certify correctness of |
969 | | calculations (not assuming GRH). |
| 984 | - ``certify`` (bool, default True) -- if True, certify |
| 985 | correctness of calculations (not assuming GRH). |
970 | 986 | |
971 | 987 | EXAMPLES:: |
972 | 988 | |
… |
… |
|
983 | 999 | |
984 | 1000 | @cached_method |
985 | 1001 | def _pari_base_nf(self): |
986 | | """ |
| 1002 | r""" |
987 | 1003 | Return the PARI number field representation of the absolute |
988 | | base field, in terms of the pari variable y, suitable for |
989 | | extension by the pari variable x. |
| 1004 | base field, in terms of the pari variable ``y``, suitable for |
| 1005 | extension by the pari variable ``x``. |
990 | 1006 | |
991 | 1007 | In future, all caching will be done by the absolute base |
992 | 1008 | field, but for now we work around a PARI bug that makes |
… |
… |
|
1009 | 1025 | |
1010 | 1026 | def is_galois(self): |
1011 | 1027 | r""" |
1012 | | For a relative number field, is_galois() is deliberately not |
| 1028 | For a relative number field, ``is_galois()`` is deliberately not |
1013 | 1029 | implemented, since it is not clear whether this would mean "Galois over |
1014 | | QQ" or "Galois over the given base field". Use either |
1015 | | is_galois_absolute() or is_galois_relative() respectively. |
| 1030 | `\QQ`" or "Galois over the given base field". Use either ``is_galois_absolute()`` or ``is_galois_relative()`` respectively. |
1016 | 1031 | |
1017 | 1032 | EXAMPLES:: |
1018 | 1033 | |
… |
… |
|
1026 | 1041 | |
1027 | 1042 | def is_galois_relative(self): |
1028 | 1043 | r""" |
1029 | | Return True if for this relative extension L/K, L is a Galois extension of K. |
| 1044 | Return True if for this relative extension `L/K`, `L` is a |
| 1045 | Galois extension of `K`. |
1030 | 1046 | |
1031 | 1047 | EXAMPLE:: |
1032 | 1048 | |
… |
… |
|
1039 | 1055 | |
1040 | 1056 | def is_galois_absolute(self): |
1041 | 1057 | r""" |
1042 | | Return True if for this relative extension L/K, L is a Galois extension of `\QQ`. |
| 1058 | Return True if for this relative extension `L/K`, `L` is a Galois extension of `\QQ`. |
1043 | 1059 | |
1044 | 1060 | EXAMPLE:: |
1045 | 1061 | |
… |
… |
|
1091 | 1107 | |
1092 | 1108 | def absolute_vector_space(self): |
1093 | 1109 | """ |
| 1110 | Return vector space over `\QQ` of self and isomorphisms from |
| 1111 | the vector space to self and in the other direction. |
| 1112 | |
1094 | 1113 | EXAMPLES:: |
1095 | 1114 | |
1096 | 1115 | sage: K.<a,b> = NumberField([x^3 + 3, x^3 + 2]); K |
… |
… |
|
1128 | 1147 | return ans |
1129 | 1148 | |
1130 | 1149 | def vector_space(self): |
1131 | | """ |
1132 | | For a relative number field `L`, ``L.vector_space()`` is deliberately |
1133 | | not implemented, so that a user cannot confuse |
1134 | | ``L.relative_vector_space()`` with ``L.absolute_vector_space()``. |
| 1150 | r""" |
| 1151 | For a relative number field, ``vector_space()`` is |
| 1152 | deliberately not implemented, so that a user cannot confuse |
| 1153 | ``relative_vector_space()`` with ``absolute_vector_space()``. |
1135 | 1154 | """ |
1136 | 1155 | raise NotImplementedError, "For a relative number field L you must use either L.relative_vector_space() or L.absolute_vector_space() as appropriate" |
1137 | 1156 | |
1138 | 1157 | def absolute_base_field(self): |
1139 | | """ |
| 1158 | r""" |
1140 | 1159 | Return the base field of this relative extension, but viewed |
1141 | | as an absolute field over QQ. |
| 1160 | as an absolute field over `\QQ`. |
1142 | 1161 | |
1143 | 1162 | EXAMPLES:: |
1144 | 1163 | |
… |
… |
|
1246 | 1265 | |
1247 | 1266 | def pari_absolute_base_polynomial(self): |
1248 | 1267 | r""" |
1249 | | Return the PARI polynomial defining the absolute base field, in y. |
| 1268 | Return the PARI polynomial defining the absolute base field, in ``y``. |
1250 | 1269 | |
1251 | 1270 | EXAMPLES:: |
1252 | 1271 | |
… |
… |
|
1331 | 1350 | return [from_abs(x) for x in abs.roots_of_unity()] |
1332 | 1351 | |
1333 | 1352 | def absolute_generator(self): |
1334 | | """ |
1335 | | Return the chosen generator over QQ for this relative number field. |
| 1353 | r""" |
| 1354 | Return the chosen generator over `\QQ` for this relative number field. |
1336 | 1355 | |
1337 | 1356 | EXAMPLES:: |
1338 | 1357 | |
… |
… |
|
1353 | 1372 | |
1354 | 1373 | def absolute_field(self, names): |
1355 | 1374 | r""" |
1356 | | Return an absolute number field K that is isomorphic to this |
1357 | | field along with a field-theoretic bijection from self to K |
1358 | | and from K to self. |
| 1375 | Return an absolute number field `K` that is isomorphic to this |
| 1376 | field along with a field-theoretic bijection from self to `K` |
| 1377 | and from `K` to self. |
1359 | 1378 | |
1360 | 1379 | INPUT: |
1361 | 1380 | |
1362 | | - names -- string; name of generator of the absolute field |
| 1381 | - ``names`` -- string; name of generator of the absolute field |
1363 | 1382 | |
1364 | 1383 | OUTPUT: an absolute number field |
1365 | 1384 | |
1366 | | Also, ``K.structure()`` returns from_K and to_K, where from_K is an |
1367 | | isomorphism from K to self and to_K is an isomorphism from self to K. |
| 1385 | Also, ``K.structure()`` returns ``from_K`` and ``to_K``, where |
| 1386 | ``from_K`` is an isomorphism from `K` to self and ``to_K`` is |
| 1387 | an isomorphism from self to `K`. |
1368 | 1388 | |
1369 | 1389 | EXAMPLES:: |
1370 | 1390 | |
… |
… |
|
1466 | 1486 | """ |
1467 | 1487 | Return the defining polynomial of this relative number field. |
1468 | 1488 | |
1469 | | This is exactly the same as ``self.relative_polynomal()``. |
| 1489 | This is exactly the same as ``relative_polynomal()``. |
1470 | 1490 | |
1471 | 1491 | EXAMPLES:: |
1472 | 1492 | |
… |
… |
|
1481 | 1501 | |
1482 | 1502 | def polynomial(self): |
1483 | 1503 | """ |
1484 | | For a relative number field ``L``, ``L.polynomial()`` is deliberately |
1485 | | not implemented. Either ``L.relative_polynomial()`` or |
1486 | | ``L.absolute_polynomial()`` must be used. |
| 1504 | For a relative number field, ``polynomial()`` is deliberately |
| 1505 | not implemented. Either ``relative_polynomial()`` or |
| 1506 | ``absolute_polynomial()`` must be used. |
1487 | 1507 | """ |
1488 | 1508 | raise NotImplementedError, "For a relative number field L you must use either L.relative_polynomial() or L.absolute_polynomial() as appropriate" |
1489 | 1509 | |
… |
… |
|
1524 | 1544 | return self.base_field() |
1525 | 1545 | |
1526 | 1546 | def embeddings(self, K): |
1527 | | """ |
| 1547 | r""" |
1528 | 1548 | Compute all field embeddings of the relative number field self |
1529 | | into the field K (which need not even be a number field, e.g., |
1530 | | it could be the complex numbers). This will return an |
1531 | | identical result when given K as input again. |
| 1549 | into the field `K` (which need not even be a number field, |
| 1550 | e.g., it could be the complex numbers). This will return an |
| 1551 | identical result when given `K` as input again. |
1532 | 1552 | |
1533 | | If possible, the most natural embedding of K into self |
| 1553 | If possible, the most natural embedding of self into `K` |
1534 | 1554 | is put first in the list. |
1535 | 1555 | |
1536 | 1556 | INPUT: |
1537 | 1557 | |
1538 | | - K -- a number field |
| 1558 | - ``K`` -- a field |
1539 | 1559 | |
1540 | 1560 | EXAMPLES:: |
1541 | 1561 | |
… |
… |
|
1686 | 1706 | def absolute_discriminant(self, v=None): |
1687 | 1707 | r""" |
1688 | 1708 | Return the absolute discriminant of this relative number field |
1689 | | or if v is specified, the determinant of the trace pairing |
1690 | | on the elements of the list v. |
| 1709 | or if ``v`` is specified, the determinant of the trace pairing |
| 1710 | on the elements of the list ``v``. |
1691 | 1711 | |
1692 | 1712 | INPUT: |
1693 | 1713 | |
1694 | | - v (optional) -- list of element of this relative number field. |
| 1714 | - ``v`` (optional) -- list of element of this relative number field. |
1695 | 1715 | |
1696 | | OUTPUT: Integer if v is omitted, and Rational otherwise. |
| 1716 | OUTPUT: Integer if ``v`` is omitted, and Rational otherwise. |
1697 | 1717 | |
1698 | 1718 | EXAMPLES:: |
1699 | 1719 | |
… |
… |
|
1725 | 1745 | |
1726 | 1746 | INPUT: |
1727 | 1747 | |
1728 | | - proof -- (default: False) |
| 1748 | - ``proof`` -- (default: False) |
1729 | 1749 | |
1730 | 1750 | EXAMPLES:: |
1731 | 1751 | |
… |
… |
|
1766 | 1786 | |
1767 | 1787 | INPUT: |
1768 | 1788 | |
1769 | | - gens -- list of elements of self; if no generators are given, just |
| 1789 | - ``gens`` -- list of elements of self; if no generators are given, just |
1770 | 1790 | returns the cardinality of this number field (oo) for consistency. |
1771 | | - check_is_integral -- bool (default: True), whether to check that each |
| 1791 | - ``check_is_integral`` -- bool (default: True), whether to check that each |
1772 | 1792 | generator is integral. |
1773 | | - check_rank -- bool (default: True), whether to check that the ring |
| 1793 | - ``check_rank`` -- bool (default: True), whether to check that the ring |
1774 | 1794 | generated by gens is of full rank. |
1775 | | - allow_subfield -- bool (default: False), if True and the generators |
| 1795 | - ``allow_subfield`` -- bool (default: False), if True and the generators |
1776 | 1796 | do not generate an order, i.e., they generate a subring of smaller |
1777 | 1797 | rank, instead of raising an error, return an order in a smaller |
1778 | 1798 | number field. |
… |
… |
|
1786 | 1806 | sage: R = P.order([a,b,c]); R |
1787 | 1807 | Relative Order in Number Field in sqrt2 with defining polynomial x^2 - 2 over its base field |
1788 | 1808 | |
1789 | | The base ring of an order in a relative extension is still ZZ.:: |
| 1809 | The base ring of an order in a relative extension is still `\ZZ`.: |
1790 | 1810 | |
1791 | 1811 | sage: R.base_ring() |
1792 | 1812 | Integer Ring |
… |
… |
|
1848 | 1868 | |
1849 | 1869 | INPUT: |
1850 | 1870 | |
1851 | | - proof -- default: True |
| 1871 | - ``proof`` -- default: True |
1852 | 1872 | |
1853 | 1873 | EXAMPLES:: |
1854 | 1874 | |
… |
… |
|
1898 | 1918 | Given an element in self or an embedding of a subfield into self, |
1899 | 1919 | return a relative number field `K` isomorphic to self that is relative |
1900 | 1920 | over the absolute field `\QQ(\alpha)` or the domain of `\alpha`, along |
1901 | | with isomorphisms from `K` to self and from self to K. |
| 1921 | with isomorphisms from `K` to self and from self to `K`. |
1902 | 1922 | |
1903 | 1923 | INPUT: |
1904 | 1924 | |
1905 | | - alpha -- an element of self, or an embedding of a subfield into self |
1906 | | - names -- name of generator for output field K. |
| 1925 | - ``alpha`` -- an element of self, or an embedding of a subfield into self |
| 1926 | - ``names`` -- name of generator for output field `K`. |
1907 | 1927 | |
1908 | | OUTPUT: K -- a relative number field |
| 1928 | OUTPUT: `K` -- a relative number field |
1909 | 1929 | |
1910 | | Also, ``K.structure()`` returns from_K and to_K, where |
1911 | | from_K is an isomorphism from K to self and to_K is an isomorphism |
1912 | | from self to K. |
| 1930 | Also, ``K.structure()`` returns ``from_K`` and ``to_K``, where |
| 1931 | ``from_K`` is an isomorphism from `K` to self and ``to_K`` is |
| 1932 | an isomorphism from self to `K`. |
1913 | 1933 | |
1914 | 1934 | EXAMPLES:: |
1915 | 1935 | |
… |
… |
|
1925 | 1945 | sage: L.base_field() |
1926 | 1946 | Number Field in w with defining polynomial x^2 + 3 |
1927 | 1947 | |
1928 | | Now suppose we have K below L below M:: |
| 1948 | Now suppose we have `K` below `L` below `M`:: |
1929 | 1949 | |
1930 | 1950 | sage: M = NumberField(x^8 + 2, 'a'); M |
1931 | 1951 | Number Field in a with defining polynomial x^8 + 2 |
… |
… |
|
1943 | 1963 | sage: M_over_L_over_K.base_field() is L_over_K |
1944 | 1964 | True |
1945 | 1965 | |
1946 | | Let's test relativizing a degree 6 field over its degree 2 and degree 3 |
| 1966 | Test relativizing a degree 6 field over its degree 2 and degree 3 |
1947 | 1967 | subfields, using both an explicit element:: |
1948 | 1968 | |
1949 | 1969 | sage: K.<a> = NumberField(x^6 + 2); K |
diff -r 0b6b4751a6ea -r e9c8a156d9d3 sage/rings/number_field/order.py
a
|
b
|
|
6 | 6 | - William Stein and Robert Bradshaw (2007-09): initial version |
7 | 7 | |
8 | 8 | EXAMPLES: |
| 9 | |
9 | 10 | We define an absolute order:: |
10 | 11 | |
11 | 12 | sage: K.<a> = NumberField(x^2 + 1); O = K.order(2*a) |
… |
… |
|
48 | 49 | |
49 | 50 | |
50 | 51 | def is_NumberFieldOrder(R): |
51 | | """ |
52 | | Return True if R an order in a number field or R is the ring ZZ of integers. |
| 52 | r""" |
| 53 | Return True if R is either an order in a number field or is the ring `\ZZ` of integers. |
53 | 54 | |
54 | 55 | EXAMPLES:: |
55 | 56 | |
… |
… |
|
66 | 67 | return isinstance(R, Order) or R == ZZ |
67 | 68 | |
68 | 69 | def EquationOrder(f, names): |
69 | | """ |
| 70 | r""" |
70 | 71 | Return the equation order generated by a root of the irreducible |
71 | | polynomial f or list of polynomials f (to construct a relative |
| 72 | polynomial f or list of polynomials `f` (to construct a relative |
72 | 73 | equation order). |
73 | 74 | |
74 | 75 | IMPORTANT: Note that the generators of the returned order need |
75 | | *not* be a root of f, since the generators of an order are -- in |
76 | | SAGE -- module generators. |
| 76 | *not* be roots of `f`, since the generators of an order are -- in |
| 77 | Sage -- module generators. |
77 | 78 | |
78 | 79 | EXAMPLES:: |
79 | 80 | |
… |
… |
|
209 | 210 | |
210 | 211 | def __mul__(self, right): |
211 | 212 | """ |
212 | | Create an ideal in this order using the notation Ok*gens |
| 213 | Create an ideal in this order using the notation ``Ok*gens`` |
213 | 214 | |
214 | 215 | EXAMPLES:: |
215 | 216 | |
… |
… |
|
230 | 231 | |
231 | 232 | def __rmul__(self, left): |
232 | 233 | """ |
233 | | Create an ideal in this order using the notation gens*Ok. |
| 234 | Create an ideal in this order using the notation ``gens*Ok``. |
234 | 235 | |
235 | 236 | EXAMPLES:: |
236 | 237 | |
… |
… |
|
363 | 364 | return self.number_field().maximal_order() |
364 | 365 | |
365 | 366 | def gen(self, i): |
366 | | """ |
367 | | Return i-th module generator of this order. |
| 367 | r""" |
| 368 | Return `i`'th module generator of this order. |
368 | 369 | |
369 | 370 | EXAMPLES:: |
370 | 371 | |
… |
… |
|
395 | 396 | """ |
396 | 397 | Return a list of the module generators of this order. |
397 | 398 | |
398 | | NOTE: For a (much smaller) list of ring generators use |
399 | | ``self.ring_generators()``. |
| 399 | .. note:: |
| 400 | |
| 401 | For a (much smaller) list of ring generators use |
| 402 | ``ring_generators()``. |
400 | 403 | |
401 | 404 | EXAMPLES:: |
402 | 405 | |
… |
… |
|
421 | 424 | return self.absolute_degree() |
422 | 425 | |
423 | 426 | def basis(self): # this must be defined in derived class |
424 | | """ |
425 | | Return a basis over ZZ of this order. |
| 427 | r""" |
| 428 | Return a basis over `\ZZ` of this order. |
426 | 429 | |
427 | 430 | EXAMPLES:: |
428 | 431 | |
… |
… |
|
438 | 441 | r""" |
439 | 442 | Returns the coordinate vector of `x` with respect to this order. |
440 | 443 | |
441 | | INPUT:: |
| 444 | INPUT: |
442 | 445 | |
443 | | - `x` -- an element of the number field of this order. |
| 446 | - ``x`` -- an element of the number field of this order. |
444 | 447 | |
445 | 448 | OUTPUT: |
446 | 449 | |
… |
… |
|
452 | 455 | |
453 | 456 | AUTHOR: John Cremona 2008-11-15 |
454 | 457 | |
| 458 | ALGORITHM: |
| 459 | |
455 | 460 | Uses linear algebra. The change-of-basis matrix is |
456 | 461 | cached. Provides simpler implementations for |
457 | | _contains_(), is_integral() and smallest_integer(). |
| 462 | ``_contains_()``, ``is_integral()`` and ``smallest_integer()``. |
458 | 463 | |
459 | 464 | EXAMPLES:: |
460 | 465 | |
… |
… |
|
493 | 498 | return to_V(K(x))*M |
494 | 499 | |
495 | 500 | def free_module(self): |
496 | | """ |
497 | | Return the free ZZ-module contained in the vector space |
| 501 | r""" |
| 502 | Return the free `\ZZ`-module contained in the vector space |
498 | 503 | associated to the ambient number field, that corresponds |
499 | 504 | to this ideal. |
500 | 505 | |
… |
… |
|
511 | 516 | [ 0 0 1] |
512 | 517 | |
513 | 518 | An example in a relative extension. Notice that the module is |
514 | | a ZZ-module in the absolute_field associated to the relative |
| 519 | a `\ZZ`-module in the absolute_field associated to the relative |
515 | 520 | field:: |
516 | 521 | |
517 | 522 | sage: K.<a,b> = NumberField([x^2 + 1, x^2 + 2]) |
… |
… |
|
648 | 653 | |
649 | 654 | INPUT: |
650 | 655 | |
651 | | - prime -- a prime ideal of the maximal order in this number field. |
652 | | - name -- the name of the variable in the residue field |
653 | | - check -- whether or not to check the primality of prime. |
| 656 | - ``prime`` -- a prime ideal of the maximal order in this number field. |
| 657 | - ``name`` -- the name of the variable in the residue field |
| 658 | - ``check`` -- whether or not to check the primality of prime. |
654 | 659 | |
655 | 660 | OUTPUT: |
656 | 661 | |
… |
… |
|
707 | 712 | `\ZZ`-module, or the degree of the ambient number field that contains |
708 | 713 | this order. |
709 | 714 | |
710 | | This is a synonym for ``self.degree()``. |
| 715 | This is a synonym for ``degree()``. |
711 | 716 | |
712 | 717 | EXAMPLES:: |
713 | 718 | |
… |
… |
|
720 | 725 | return self.degree() |
721 | 726 | |
722 | 727 | def class_number(self, proof=None): |
723 | | """ |
| 728 | r""" |
| 729 | Return the class number of this order. |
| 730 | |
724 | 731 | EXAMPLES:: |
725 | 732 | |
726 | 733 | sage: ZZ[2^(1/3)].class_number() |
… |
… |
|
804 | 811 | r""" |
805 | 812 | Compare the order self to other. |
806 | 813 | |
807 | | NOTE: This is a well defined way to compare any two objects, but it is |
808 | | not the partial inclusion ordering!. Thus self < other being True does |
809 | | not necessarily mean that self is contained in other. Use |
810 | | ``self.is_suborder(other)`` to determine inclusion. |
| 814 | .. note:: |
| 815 | |
| 816 | This is a well defined way to compare any two objects, but |
| 817 | it is not the partial inclusion ordering!. Thus self < |
| 818 | other being True does not necessarily mean that self is |
| 819 | contained in other. Use ``self.is_suborder(other)`` to |
| 820 | determine inclusion. |
811 | 821 | |
812 | 822 | EXAMPLES:: |
813 | 823 | |
… |
… |
|
841 | 851 | return cmp(self._module_rep, other._module_rep) |
842 | 852 | |
843 | 853 | def absolute_degree(self): |
844 | | """ |
845 | | Returns the absolute degree of this order, ie the degree of this order over ZZ. |
| 854 | r""" |
| 855 | Returns the absolute degree of this order, ie the degree of this order over `\ZZ`. |
846 | 856 | |
847 | 857 | EXAMPLES:: |
848 | 858 | |
… |
… |
|
931 | 941 | raise ValueError, "the module must have full rank." |
932 | 942 | |
933 | 943 | def __call__(self, x): |
934 | | """ |
935 | | Coerce x into this order. |
| 944 | r""" |
| 945 | Coerce ``x`` into this order. |
936 | 946 | |
937 | 947 | EXAMPLES:: |
938 | 948 | |
… |
… |
|
1008 | 1018 | |
1009 | 1019 | INPUT: |
1010 | 1020 | |
1011 | | - magma -- a magma interpreter |
| 1021 | - ``magma`` -- a magma interpreter |
1012 | 1022 | |
1013 | 1023 | OUTPUT: |
1014 | 1024 | |
… |
… |
|
1087 | 1097 | |
1088 | 1098 | INPUT: |
1089 | 1099 | |
1090 | | - other -- another absolute order with the same ambient number field. |
| 1100 | - ``other`` -- another absolute order with the same ambient number field. |
1091 | 1101 | |
1092 | 1102 | OUTPUT: |
1093 | 1103 | |
… |
… |
|
1182 | 1192 | return "%sOrder in %r" % ("Maximal " if self._is_maximal else "", self._K) |
1183 | 1193 | |
1184 | 1194 | def basis(self): |
1185 | | """ |
1186 | | Return the basis over ZZ for this order. |
| 1195 | r""" |
| 1196 | Return the basis over `\ZZ` for this order. |
1187 | 1197 | |
1188 | 1198 | EXAMPLES:: |
1189 | 1199 | |
… |
… |
|
1319 | 1329 | |
1320 | 1330 | INPUT: |
1321 | 1331 | |
1322 | | - names -- string (default: 'z'); name of generator of absolute extension. |
| 1332 | - ``names`` -- string (default: 'z'); name of generator of absolute extension. |
1323 | 1333 | |
1324 | | NOTE: There *is* a default variable name, since this absolute |
1325 | | order is frequently used for internal algorithms. |
| 1334 | .. note:: |
| 1335 | |
| 1336 | There *is* a default variable name, since this absolute |
| 1337 | order is frequently used for internal algorithms. |
1326 | 1338 | |
1327 | 1339 | EXAMPLES:: |
1328 | 1340 | |
… |
… |
|
1336 | 1348 | sage: S.basis() |
1337 | 1349 | [1, 5/12*z^3 + 1/6*z, 1/2*z^2, 1/2*z^3] |
1338 | 1350 | |
1339 | | We compute a relative order in alpha0, alpha1, then make the number field |
1340 | | that contains the absolute order be called gamma.:: |
| 1351 | We compute a relative order in alpha0, alpha1, then make the |
| 1352 | number field that contains the absolute order be called |
| 1353 | gamma.:: |
1341 | 1354 | |
1342 | 1355 | sage: R = EquationOrder( [x^2 + 2, x^2 - 3], 'alpha'); R |
1343 | 1356 | Relative Order in Number Field in alpha0 with defining polynomial x^2 + 2 over its base field |
… |
… |
|
1356 | 1369 | Return module basis for this relative order. This is a list |
1357 | 1370 | of elements that generate this order over the base order. |
1358 | 1371 | |
1359 | | WARNING: For now this basis is actually just a basis over ZZ. |
| 1372 | .. warning:: |
| 1373 | |
| 1374 | For now this basis is actually just a basis over `\ZZ`. |
1360 | 1375 | |
1361 | 1376 | EXAMPLES:: |
1362 | 1377 | |
… |
… |
|
1482 | 1497 | |
1483 | 1498 | INPUT: |
1484 | 1499 | |
1485 | | - other -- another order with the same ambient absolute number field. |
| 1500 | - ``other`` -- another order with the same ambient absolute number field. |
1486 | 1501 | |
1487 | 1502 | OUTPUT: |
1488 | 1503 | |
… |
… |
|
1506 | 1521 | |
1507 | 1522 | def each_is_integral(v): |
1508 | 1523 | """ |
1509 | | Return True if each element of the list v of elements of a number |
| 1524 | Return True if each element of the list ``v`` of elements of a number |
1510 | 1525 | field is integral. |
1511 | 1526 | |
1512 | 1527 | EXAMPLES:: |
… |
… |
|
1529 | 1544 | """ |
1530 | 1545 | INPUT: |
1531 | 1546 | |
1532 | | - gens -- list of integral elements of an absolute order. |
1533 | | - check_is_integral -- bool (default: True), whether to check that each |
| 1547 | - ``gens`` -- list of integral elements of an absolute order. |
| 1548 | - ``check_is_integral`` -- bool (default: True), whether to check that each |
1534 | 1549 | generator is integral. |
1535 | | - check_rank -- bool (default: True), whether to check that the ring |
| 1550 | - ``check_rank`` -- bool (default: True), whether to check that the ring |
1536 | 1551 | generated by gens is of full rank. |
1537 | | - is_maximal -- bool (or None); set if maximality of the generated order is |
| 1552 | - ``is_maximal`` -- bool (or None); set if maximality of the generated order is |
1538 | 1553 | known |
1539 | | - allow_subfield -- bool (default: False), if True and the generators do |
| 1554 | - ``allow_subfield`` -- bool (default: False), if True and the generators do |
1540 | 1555 | not generate an order, i.e., they generate a subring of smaller rank, |
1541 | 1556 | instead of raising an error, return an order in a smaller number field. |
1542 | 1557 | |
… |
… |
|
1598 | 1613 | """ |
1599 | 1614 | INPUT: |
1600 | 1615 | |
1601 | | - gens -- list of elements of an absolute number field that generates an |
| 1616 | - ``gens`` -- list of elements of an absolute number field that generates an |
1602 | 1617 | order in that number field as a ZZ *module*. |
1603 | | - check_integral -- check that each gen is integral |
1604 | | - check_rank -- check that the gens span a module of the correct rank |
1605 | | - check_is_ring -- check that the module is closed under multiplication |
| 1618 | - ``check_integral`` -- check that each gen is integral |
| 1619 | - ``check_rank`` -- check that the gens span a module of the correct rank |
| 1620 | - ``check_is_ring`` -- check that the module is closed under multiplication |
1606 | 1621 | (this is very expensive) |
1607 | | - is_maximal -- bool (or None); set if maximality of the generated order is known |
| 1622 | - ``is_maximal`` -- bool (or None); set if maximality of the generated order is known |
1608 | 1623 | |
1609 | 1624 | OUTPUT: |
1610 | 1625 | |
… |
… |
|
1669 | 1684 | sage: R.basis() |
1670 | 1685 | [1/2, i] |
1671 | 1686 | |
1672 | | We turn off all check flags and make a really messed up order.:: |
| 1687 | We turn off all check flags and make a really messed up order:: |
1673 | 1688 | |
1674 | 1689 | sage: R = absolute_order_from_module_generators([1/2, i], check_is_ring=False, check_integral=False, check_rank=False); R |
1675 | 1690 | Order in Number Field in i with defining polynomial x^2 + 1 |
… |
… |
|
1738 | 1753 | """ |
1739 | 1754 | INPUT: |
1740 | 1755 | |
1741 | | - gens -- list of integral elements of an absolute order. |
1742 | | - check_is_integral -- bool (default: True), whether to check that each |
| 1756 | - ``gens`` -- list of integral elements of an absolute order. |
| 1757 | - ``check_is_integral`` -- bool (default: True), whether to check that each |
1743 | 1758 | generator is integral. |
1744 | | - check_rank -- bool (default: True), whether to check that the ring |
| 1759 | - ``check_rank`` -- bool (default: True), whether to check that the ring |
1745 | 1760 | generated by gens is of full rank. |
1746 | | - is_maximal -- bool (or None); set if maximality of the generated order is |
| 1761 | - ``is_maximal`` -- bool (or None); set if maximality of the generated order is |
1747 | 1762 | known |
1748 | 1763 | |
1749 | 1764 | EXAMPLES: |
… |
… |
|
1757 | 1772 | Relative Order in Number Field in i with defining polynomial x^2 + 1 over its base field |
1758 | 1773 | |
1759 | 1774 | Basis for the relative order, which is obtained by computing the algebra generated |
1760 | | by i and a.:: |
| 1775 | by i and a:: |
1761 | 1776 | |
1762 | 1777 | sage: S.basis() |
1763 | 1778 | [1, 7*i - 2*a, -a*i + 8, 25*i - 7*a] |
diff -r 0b6b4751a6ea -r e9c8a156d9d3 sage/rings/number_field/unit_group.py
a
|
b
|
|
1 | | """ |
| 1 | r""" |
2 | 2 | Unit Groups of Number Fields |
3 | 3 | |
4 | 4 | EXAMPLES:: |
… |
… |
|
143 | 143 | |
144 | 144 | INPUT: |
145 | 145 | |
146 | | - number_field - a number field |
147 | | - proof - boolean (default True): proof flag |
| 146 | - ``number_field`` - a number field |
| 147 | - ``proof`` - boolean (default True): proof flag |
148 | 148 | |
149 | | The proof flag is passed to pari via the pari_bnf() function |
| 149 | The proof flag is passed to pari via the ``pari_bnf()`` function |
150 | 150 | which computes the unit group. See the documentation for the |
151 | 151 | number_field module. |
152 | 152 | |
… |
… |
|
211 | 211 | |
212 | 212 | INPUT: |
213 | 213 | |
214 | | - u -- Any object from which an element of the unit group's number |
215 | | field K may be constructed; an error is raised if an element of K |
| 214 | - ``u`` -- Any object from which an element of the unit group's number |
| 215 | field `K` may be constructed; an error is raised if an element of `K` |
216 | 216 | cannot be constructed from u, or if the element constructed is not a |
217 | 217 | unit. |
218 | 218 | |
… |
… |
|
255 | 255 | |
256 | 256 | def _coerce_impl(self, x): |
257 | 257 | """ |
258 | | Canonical coercion of x into this unit group. |
| 258 | Canonical coercion of ``x`` into this unit group. |
259 | 259 | |
260 | 260 | EXAMPLES: |
261 | 261 | |
… |
… |
|
303 | 303 | |
304 | 304 | def gen(self, i=0): |
305 | 305 | """ |
306 | | Return the i-th generator for this unit group. |
| 306 | Return the `i`'th generator for this unit group. |
307 | 307 | |
308 | | NOTE: i=0 gives the torsion generator, i.e. a primitive root of unity. |
| 308 | .. note:: |
| 309 | |
| 310 | `i=0` gives the torsion generator, i.e. a primitive root of unity. |
309 | 311 | |
310 | 312 | EXAMPLES:: |
311 | 313 | |
… |
… |
|
489 | 491 | |
490 | 492 | |
491 | 493 | def log(self, u): |
492 | | """ |
493 | | Return the exponents of the unit u with respect to group generators. |
| 494 | r""" |
| 495 | Return the exponents of the unit ``u`` with respect to group generators. |
494 | 496 | |
495 | 497 | INPUT: |
496 | 498 | |
497 | | - u -- Any object from which an element of the unit group's number |
498 | | field K may be constructed; an error is raised if an element of K |
| 499 | - ``u`` -- Any object from which an element of the unit group's number |
| 500 | field `K` may be constructed; an error is raised if an element of `K` |
499 | 501 | cannot be constructed from u, or if the element constructed is not a |
500 | 502 | unit. |
501 | 503 | |
502 | | OUTPUT: a list of integers giving the exponents of u with |
| 504 | OUTPUT: a list of integers giving the exponents of ``u`` with |
503 | 505 | respect to the unit group's basis. |
504 | 506 | |
505 | 507 | EXAMPLES:: |
… |
… |
|
523 | 525 | return self(u).list() |
524 | 526 | |
525 | 527 | def exp(self, exponents): |
526 | | """ |
| 528 | r""" |
527 | 529 | Return unit with given exponents with respect to group generators. |
528 | 530 | |
529 | 531 | INPUT: |
530 | 532 | |
531 | | - u -- Any object from which an element of the unit group's number |
532 | | field K may be constructed; an error is raised if an element of K |
533 | | cannot be constructed from u, or if the element constructed is not a |
534 | | unit. |
| 533 | - ``u`` -- Any object from which an element of the unit |
| 534 | group's number field `K` may be constructed; an error is |
| 535 | raised if an element of `K` cannot be constructed from u, or |
| 536 | if the element constructed is not a unit. |
535 | 537 | |
536 | | OUTPUT: a list of integers giving the exponents of u with |
| 538 | OUTPUT: a list of integers giving the exponents of ``u`` with |
537 | 539 | respect to the unit group's basis. |
538 | 540 | |
539 | 541 | EXAMPLES:: |