6661 | | sage: O = K.maximal_order() |
6662 | | sage: K.hilbert_symbol(a, a+5, 5*O) |
6663 | | 1 |
6664 | | sage: K.hilbert_symbol(a+1, 13, (-a-6)*O) |
| 6667 | sage: K.hilbert_symbol(0, a+5) |
| 6668 | 0 |
| 6669 | sage: K.hilbert_symbol(a, 0) |
| 6670 | 0 |
| 6671 | sage: K.hilbert_symbol(-a, a+1) |
| 6672 | 1 |
| 6673 | sage: K.hilbert_symbol(-a, a+2) |
| 6674 | -1 |
| 6675 | sage: K.hilbert_symbol(a, a+5) |
| 6676 | -1 |
| 6677 | |
| 6678 | That the latter two are unsolvable should be visible in local |
| 6679 | obstructions. For the first, this is a prime ideal above 19. |
| 6680 | For the second, the ramified prime above 23:: |
| 6681 | |
| 6682 | sage: K.hilbert_symbol(-a, a+2, a+2) |
| 6683 | -1 |
| 6684 | sage: K.hilbert_symbol(a, a+5, K.ideal(23).factor()[0][0]) |
| 6685 | -1 |
| 6686 | |
| 6687 | More local examples:: |
| 6688 | |
| 6689 | sage: K.hilbert_symbol(a, 0, K.ideal(5)) |
| 6690 | 0 |
| 6691 | sage: K.hilbert_symbol(a, a+5, K.ideal(5)) |
| 6692 | 1 |
| 6693 | sage: K.hilbert_symbol(a+1, 13, (a+6)*K.maximal_order()) |
6729 | | sage: K.<i> = QuadraticField(-1) |
6730 | | sage: O = K.maximal_order() |
6731 | | sage: K.hilbert_symbol(1/2, 1/6, 3*O) |
6732 | | 1 |
6733 | | sage: p = 1+i |
6734 | | sage: K.hilbert_symbol(p,p,p*O) |
6735 | | -1 |
| 6769 | sage: K.<i> = QuadraticField(-1) |
| 6770 | sage: O = K.maximal_order() |
| 6771 | sage: K.hilbert_symbol(1/2, 1/6, 3*O) |
| 6772 | 1 |
| 6773 | sage: p = 1+i |
| 6774 | sage: K.hilbert_symbol(p, p, p) |
| 6775 | 1 |
| 6776 | sage: K.hilbert_symbol(p, 3*p, p) |
| 6777 | -1 |
| 6778 | sage: K.hilbert_symbol(3, p, p) |
| 6779 | -1 |
6753 | | sage: K.<a> = NumberField(x^3+x+1) |
6754 | | sage: K.hilbert_symbol(-6912, 24, -a^2-a-2) |
6755 | | 1 |
6756 | | sage: K.<a> = NumberField(x^5-23) |
6757 | | sage: P = K.ideal(-1105*a^4 + 1541*a^3 - 795*a^2 - 2993*a + 11853) |
6758 | | sage: Q = K.ideal(-7*a^4 + 13*a^3 - 13*a^2 - 2*a + 50) |
6759 | | sage: b = -a+5 |
6760 | | sage: K.hilbert_symbol(a,b,P) |
6761 | | -1 |
6762 | | sage: K.hilbert_symbol(a,b,Q) |
6763 | | 1 |
6764 | | sage: K.<a> = NumberField(x^5-23) |
6765 | | sage: P = K.ideal(-1105*a^4 + 1541*a^3 - 795*a^2 - 2993*a + 11853) |
6766 | | sage: b = a+5 |
6767 | | sage: K.hilbert_symbol(a, b, P) |
6768 | | -1 |
6769 | | sage: K.hilbert_symbol(a, 2, P) |
6770 | | -1 |
6771 | | sage: K.hilbert_symbol(a+5, 2, P) |
6772 | | -1 |
| 6788 | sage: K.<a> = NumberField(x^3+x+1) |
| 6789 | sage: K.hilbert_symbol(-6912, 24, -a^2-a-2) |
| 6790 | 1 |
| 6791 | sage: K.<a> = NumberField(x^5-23) |
| 6792 | sage: P = K.ideal(-1105*a^4 + 1541*a^3 - 795*a^2 - 2993*a + 11853) |
| 6793 | sage: Q = K.ideal(-7*a^4 + 13*a^3 - 13*a^2 - 2*a + 50) |
| 6794 | sage: b = -a+5 |
| 6795 | sage: K.hilbert_symbol(a,b,P) |
| 6796 | 1 |
| 6797 | sage: K.hilbert_symbol(a,b,Q) |
| 6798 | 1 |
| 6799 | sage: K.<a> = NumberField(x^5-23) |
| 6800 | sage: P = K.ideal(-1105*a^4 + 1541*a^3 - 795*a^2 - 2993*a + 11853) |
| 6801 | sage: K.hilbert_symbol(a, a+5, P) |
| 6802 | 1 |
| 6803 | sage: K.hilbert_symbol(a, 2, P) |
| 6804 | 1 |
| 6805 | sage: K.hilbert_symbol(a+5, 2, P) |
| 6806 | -1 |
6780 | | if a == 0 or b == 0: |
6781 | | return ZZ(0) |
6782 | | if P != None: |
6783 | | if sage.rings.all.is_RingHomomorphism(P): |
6784 | | if not P.domain() == self: |
6785 | | raise ValueError, "Domain of P (=%s) should be self (=%s) in self.hilbert_symbol" % (P, self) |
6786 | | codom = P.codomain() |
6787 | | one = ZZ(1) |
6788 | | from sage.rings.all import (is_ComplexField, AA, CDF, QQbar, |
6789 | | is_ComplexIntervalField, is_RealField, |
6790 | | is_RealIntervalField, RDF) |
6791 | | if is_ComplexField(codom) or is_ComplexIntervalField(codom) or \ |
6792 | | codom is CDF or codom is QQbar: |
6793 | | if P(self.gen()).imag() == 0: |
6794 | | raise ValueError, "Possibly real place (=%s) given as complex embedding in hilbert_symbol. Is it real or complex?" % P |
6795 | | return one |
6796 | | if is_RealField(codom) or codom is RDF or codom is AA: |
6797 | | if P(a) > 0 or P(b) > 0: |
6798 | | return one |
6799 | | return -one |
6800 | | if P in self: |
6801 | | P = P*self.maximal_order() |
6802 | | if not is_NumberFieldIdeal(P): |
6803 | | raise ValueError, "P (=%s) should be an ideal or real or complex embedding in hilbert_symbol" % str(P) |
6804 | | if not P.number_field() == self: |
6805 | | raise ValueError, "P (=%s) should be an ideal of self (=%s) in hilbert_symbol, not of %s" % (P, self, P.number_field()) |
6806 | | if not P.is_prime(): |
6807 | | raise ValueError, "Non-prime ideal P (=%s) in hilbert_symbol" % P |
6808 | | k = pari(self) |
6809 | | if P != None: |
6810 | | P = k.idealfactor(pari(P))[0,0] |
6811 | | a = pari(self(a)) |
6812 | | b = pari(self(b)) |
6813 | | return ZZ(pari(self).nfhilbert(a, b, P)) |
6814 | | |
6815 | | |
| 6814 | if a.is_zero() or b.is_zero(): |
| 6815 | return 0 |
| 6816 | a = self(a) |
| 6817 | b = self(b) |
| 6818 | if P is None: |
| 6819 | # We MUST convert a and b to pari before calling the function |
| 6820 | # to work around Trac #11868 -- Jeroen Demeyer |
| 6821 | return pari(self).nfhilbert(pari(a), pari(b)) |
| 6822 | |
| 6823 | if sage.rings.all.is_RingHomomorphism(P): |
| 6824 | if not P.domain() == self: |
| 6825 | raise ValueError, "Domain of P (=%s) should be self (=%s) in self.hilbert_symbol" % (P, self) |
| 6826 | codom = P.codomain() |
| 6827 | from sage.rings.all import (is_ComplexField, AA, CDF, QQbar, |
| 6828 | is_ComplexIntervalField, is_RealField, |
| 6829 | is_RealIntervalField, RDF) |
| 6830 | if is_ComplexField(codom) or is_ComplexIntervalField(codom) or \ |
| 6831 | codom is CDF or codom is QQbar: |
| 6832 | if P(self.gen()).imag() == 0: |
| 6833 | raise ValueError, "Possibly real place (=%s) given as complex embedding in hilbert_symbol. Is it real or complex?" % P |
| 6834 | return 1 |
| 6835 | if is_RealField(codom) or codom is RDF or codom is AA: |
| 6836 | if P(a) > 0 or P(b) > 0: |
| 6837 | return 1 |
| 6838 | return -1 |
| 6839 | if not is_NumberFieldIdeal(P): |
| 6840 | P = self.ideal(P) |
| 6841 | if not P.number_field() == self: |
| 6842 | raise ValueError, "P (=%s) should be an ideal of self (=%s) in hilbert_symbol, not of %s" % (P, self, P.number_field()) |
| 6843 | if not P.is_prime(): |
| 6844 | raise ValueError, "Non-prime ideal P (=%s) in hilbert_symbol" % P |
| 6845 | # We MUST convert a and b to pari before calling the function |
| 6846 | # to work around Trac #11868 -- Jeroen Demeyer |
| 6847 | return pari(self).nfhilbert(pari(a), pari(b), P.pari_prime()) |