36
36
# ****************************************************************************
37
37
38
38
from sage .arith .misc import (hilbert_conductor_inverse ,
39
- hilbert_conductor ,
39
+ hilbert_symbol ,
40
40
factor ,
41
41
gcd ,
42
42
kronecker as kronecker_symbol ,
@@ -1031,9 +1031,7 @@ def inner_product_matrix(self):
1031
1031
@cached_method
1032
1032
def discriminant (self ):
1033
1033
"""
1034
- Given a quaternion algebra `A` defined over a number field,
1035
- return the discriminant of `A`, i.e. the
1036
- product of the ramified primes of `A`.
1034
+ Return the discriminant of this quaternion algebra, i.e. the product of the ramified primes in it.
1037
1035
1038
1036
EXAMPLES::
1039
1037
@@ -1058,24 +1056,47 @@ def discriminant(self):
1058
1056
except NotImplementedError :
1059
1057
raise ValueError ("base field must be rational numbers or number field" )
1060
1058
else :
1061
- return hilbert_conductor (self ._a , self . _b )
1059
+ return prod (self .ramified_primes () )
1062
1060
1063
- def ramified_primes (self ):
1061
+ def ramified_primes (self , sorted = False ):
1064
1062
"""
1065
- Return the primes that ramify in this quaternion algebra.
1063
+ Return the (finite) primes that ramify in this rational quaternion algebra.
1066
1064
1067
- Currently only implemented over the rational numbers.
1065
+ INPUT:
1066
+
1067
+ - ``sorted`` -- (default: ``False``)
1068
+
1069
+ OUTPUT:
1070
+
1071
+ The list of prime numbers at which ``self`` ramifies (given as integers), sorted by their
1072
+ magnitude (small to large) if ``sorted`` is set to ``True``.
1068
1073
1069
1074
EXAMPLES::
1070
1075
1071
1076
sage: QuaternionAlgebra(QQ, -1, -1).ramified_primes()
1072
1077
[2]
1078
+
1079
+ sage: QuaternionAlgebra(QQ, -58, -69).ramified_primes()
1080
+ [3, 29, 23]
1081
+
1082
+ sage: QuaternionAlgebra(QQ, -58, -69).ramified_primes(sorted=True)
1083
+ [3, 23, 29]
1073
1084
"""
1074
- # TODO: more examples
1075
- return [f [0 ] for f in factor (self .discriminant ())]
1085
+ if not is_RationalField (self .base_ring ()):
1086
+ raise ValueError ("base field must be the rational numbers" )
1087
+
1088
+ if not sorted :
1089
+ return [p for p in set ([2 ]).union (prime_divisors (self ._a .numerator ()),
1090
+ prime_divisors (self ._a .denominator ()), prime_divisors (self ._b .numerator ()),
1091
+ prime_divisors (self ._b .denominator ())) if hilbert_symbol (self ._a , self ._b , p ) == - 1 ]
1092
+
1093
+ else :
1094
+ return sorted ([p for p in set ([2 ]).union (prime_divisors (self ._a .numerator ()),
1095
+ prime_divisors (self ._a .denominator ()), prime_divisors (self ._b .numerator ()),
1096
+ prime_divisors (self ._b .denominator ())) if hilbert_symbol (self ._a , self ._b , p ) == - 1 ])
1076
1097
1077
1098
def is_isomorphic (self , A ) -> bool :
1078
- r """
1099
+ """
1079
1100
Return ``True`` if ``self`` and ``A`` are isomorphic quaternion algebras over Q.
1080
1101
1081
1102
INPUT:
@@ -1097,7 +1118,7 @@ def is_isomorphic(self, A) -> bool:
1097
1118
if self .base_ring () != QQ or A .base_ring () != QQ :
1098
1119
raise NotImplementedError ("isomorphism check only implemented for rational quaternion algebras" )
1099
1120
1100
- return self .discriminant () == A . discriminant ( )
1121
+ return set ( self .ramified_primes ()) == set ( A . ramified_primes () )
1101
1122
1102
1123
def _magma_init_ (self , magma ):
1103
1124
"""
0 commit comments