Skip to content

Commit 52e18fb

Browse files
JohnCremonadimpase
authored andcommitted
#34537: make qqbar tests more robust
1 parent 37dcd37 commit 52e18fb

File tree

1 file changed

+37
-13
lines changed

1 file changed

+37
-13
lines changed

src/sage/rings/qqbar.py

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,9 +2656,11 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
26562656
26572657
sage: elems = [sqrt(5), 2^(1/3)+sqrt(3)*I, 3/4]
26582658
sage: nf, nums, hom = number_field_elements_from_algebraics(elems, embedded=True)
2659-
sage: nf
2659+
sage: nf # random (polynomial and root not unique)
26602660
Number Field in a with defining polynomial y^24 - 6*y^23 ...- 9*y^2 + 1
26612661
with a = 0.2598679? + 0.0572892?*I
2662+
sage: nf.is_isomorphic(NumberField(x^24 - 9*x^22 + 135*x^20 - 720*x^18 + 1821*x^16 - 3015*x^14 + 3974*x^12 - 3015*x^10 + 1821*x^8 - 720*x^6 + 135*x^4 - 9*x^2 + 1, 'a'))
2663+
True
26622664
sage: list(map(QQbar, nums)) == elems == list(map(hom, nums))
26632665
True
26642666
@@ -7857,16 +7859,21 @@ def neg(self, n):
78577859
sage: b = a._descr
78587860
sage: type(b)
78597861
<class 'sage.rings.qqbar.ANExtensionElement'>
7860-
sage: b.neg(a)
7861-
-1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
7862-
sage: b.neg("ham spam and eggs")
7862+
sage: c = b.neg(None); c # random (not uniquely represented)
78637863
-1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
7864+
sage: c.generator() == b.generator() and c.field_element_value() + b.field_element_value() == 0
7865+
True
7866+
7867+
The parameter is ignored::
7868+
7869+
sage: b.neg("random").generator() == c.generator() and b.neg("random").field_element_value() == c.field_element_value()
7870+
True
78647871
"""
78657872
return ANExtensionElement(self._generator, -self._value)
78667873

78677874
def invert(self, n):
78687875
r"""
7869-
1/self.
7876+
Reciprocal of self.
78707877
78717878
EXAMPLES::
78727879
@@ -7875,16 +7882,20 @@ def invert(self, n):
78757882
sage: b = a._descr
78767883
sage: type(b)
78777884
<class 'sage.rings.qqbar.ANExtensionElement'>
7878-
sage: b.invert(a)
7879-
-7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
7880-
sage: b.invert("ham spam and eggs")
7885+
sage: c = b.invert(None); c # random (not uniquely represented)
78817886
-7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
7887+
sage: c.generator() == b.generator() and c.field_element_value() * b.field_element_value() == 1
7888+
True
7889+
7890+
The parameter is ignored::
7891+
7892+
sage: b.invert("random").generator() == c.generator() and b.invert("random").field_element_value() == c.field_element_value()
7893+
True
78827894
"""
78837895
return ANExtensionElement(self._generator, ~self._value)
78847896

78857897
def conjugate(self, n):
7886-
r"""
7887-
Negation of self.
7898+
r"""Complex conjugate of self.
78887899
78897900
EXAMPLES::
78907901
@@ -7893,10 +7904,23 @@ def conjugate(self, n):
78937904
sage: b = a._descr
78947905
sage: type(b)
78957906
<class 'sage.rings.qqbar.ANExtensionElement'>
7896-
sage: b.conjugate(a)
7897-
1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
7898-
sage: b.conjugate("ham spam and eggs")
7907+
sage: c = b.conjugate(None); c # random (not uniquely represented)
78997908
1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
7909+
7910+
Internally, complex conjugation is implemented by taking the
7911+
same abstract field element but conjugating the complex embedding of
7912+
the field::
7913+
7914+
sage: c.generator() == b.generator().conjugate()
7915+
True
7916+
sage: c.field_element_value() == b.field_element_value()
7917+
True
7918+
7919+
The parameter is ignored::
7920+
7921+
sage: b.conjugate("random").generator() == c.generator() and b.conjugate("random").field_element_value() == c.field_element_value()
7922+
True
7923+
79007924
"""
79017925
if self._exactly_real:
79027926
return self

0 commit comments

Comments
 (0)