Skip to content

Commit 8af280b

Browse files
committed
Various fixes to ramified_primes and discriminant
- Fixed a bug in .discriminant() and .ramified_primes() for rational invariants - Removed unnecessary product and factoring for .ramified_primes() - Reduced description of .ramified_primes() to rational quaternion algebras in preparation of planned .ramified_places() methods over number fields (Amended: Fixed trailing whitespaces)
1 parent 3dd953c commit 8af280b

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed

src/sage/algebras/quatalg/quaternion_algebra.py

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
# ****************************************************************************
3737

3838
from sage.arith.misc import (hilbert_conductor_inverse,
39-
hilbert_conductor,
39+
hilbert_symbol,
4040
factor,
4141
gcd,
4242
kronecker as kronecker_symbol,
@@ -1031,9 +1031,7 @@ def inner_product_matrix(self):
10311031
@cached_method
10321032
def discriminant(self):
10331033
"""
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.
10371035
10381036
EXAMPLES::
10391037
@@ -1058,24 +1056,47 @@ def discriminant(self):
10581056
except NotImplementedError:
10591057
raise ValueError("base field must be rational numbers or number field")
10601058
else:
1061-
return hilbert_conductor(self._a, self._b)
1059+
return prod(self.ramified_primes())
10621060

1063-
def ramified_primes(self):
1061+
def ramified_primes(self, sorted=False):
10641062
"""
1065-
Return the primes that ramify in this quaternion algebra.
1063+
Return the (finite) primes that ramify in this rational quaternion algebra.
10661064
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``.
10681073
10691074
EXAMPLES::
10701075
10711076
sage: QuaternionAlgebra(QQ, -1, -1).ramified_primes()
10721077
[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]
10731084
"""
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])
10761097

10771098
def is_isomorphic(self, A) -> bool:
1078-
r"""
1099+
"""
10791100
Return ``True`` if ``self`` and ``A`` are isomorphic quaternion algebras over Q.
10801101
10811102
INPUT:
@@ -1097,7 +1118,7 @@ def is_isomorphic(self, A) -> bool:
10971118
if self.base_ring() != QQ or A.base_ring() != QQ:
10981119
raise NotImplementedError("isomorphism check only implemented for rational quaternion algebras")
10991120

1100-
return self.discriminant() == A.discriminant()
1121+
return set(self.ramified_primes()) == set(A.ramified_primes())
11011122

11021123
def _magma_init_(self, magma):
11031124
"""

0 commit comments

Comments
 (0)