@@ -107,19 +107,19 @@ def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None,
107107 compute a 200-bit approximation to `sqrt(2)` which is wrong in the
108108 33'rd bit::
109109
110- sage: # needs sage.rings.real_mpfr
110+ sage: # needs sage.libs.pari sage. rings.real_mpfr
111111 sage: z = sqrt(RealField(200)(2)) + (1/2)^33
112- sage: p = algdep(z, 4); p # needs sage.libs.pari
112+ sage: p = algdep(z, 4); p
113113 227004321085*x^4 - 216947902586*x^3 - 99411220986*x^2 + 82234881648*x - 211871195088
114- sage: factor(p) # needs sage.libs.pari
114+ sage: factor(p)
115115 227004321085*x^4 - 216947902586*x^3 - 99411220986*x^2 + 82234881648*x - 211871195088
116- sage: algdep(z, 4, known_bits=32) # needs sage.libs.pari
116+ sage: algdep(z, 4, known_bits=32)
117117 x^2 - 2
118- sage: algdep(z, 4, known_digits=10) # needs sage.libs.pari
118+ sage: algdep(z, 4, known_digits=10)
119119 x^2 - 2
120- sage: algdep(z, 4, use_bits=25) # needs sage.libs.pari
120+ sage: algdep(z, 4, use_bits=25)
121121 x^2 - 2
122- sage: algdep(z, 4, use_digits=8) # needs sage.libs.pari
122+ sage: algdep(z, 4, use_digits=8)
123123 x^2 - 2
124124
125125 Using the ``height_bound`` and ``proof`` parameters, we can see that
@@ -131,18 +131,18 @@ def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None,
131131
132132 For stronger results, we need more precision::
133133
134- sage: algdep(pi.n(), 5, height_bound=100, proof=True) is None # needs sage.libs.pari sage.symbolic
134+ sage: # needs sage.libs.pari sage.symbolic
135+ sage: algdep(pi.n(), 5, height_bound=100, proof=True) is None
135136 Traceback (most recent call last):
136137 ...
137138 ValueError: insufficient precision for non-existence proof
138- sage: algdep(pi.n(200), 5, height_bound=100, proof=True) is None # needs sage.libs.pari sage.symbolic
139+ sage: algdep(pi.n(200), 5, height_bound=100, proof=True) is None
139140 True
140-
141- sage: algdep(pi.n(), 10, height_bound=10, proof=True) is None # needs sage.libs.pari sage.symbolic
141+ sage: algdep(pi.n(), 10, height_bound=10, proof=True) is None
142142 Traceback (most recent call last):
143143 ...
144144 ValueError: insufficient precision for non-existence proof
145- sage: algdep(pi.n(200), 10, height_bound=10, proof=True) is None # needs sage.libs.pari sage.symbolic
145+ sage: algdep(pi.n(200), 10, height_bound=10, proof=True) is None
146146 True
147147
148148 We can also use ``proof=True`` to get positive results::
@@ -594,19 +594,20 @@ def is_pseudoprime(n):
594594
595595 EXAMPLES::
596596
597- sage: is_pseudoprime(389) # needs sage.libs.pari
597+ sage: # needs sage.libs.pari
598+ sage: is_pseudoprime(389)
598599 True
599- sage: is_pseudoprime(2000) # needs sage.libs.pari
600+ sage: is_pseudoprime(2000)
600601 False
601- sage: is_pseudoprime(2) # needs sage.libs.pari
602+ sage: is_pseudoprime(2)
602603 True
603- sage: is_pseudoprime(-1) # needs sage.libs.pari
604+ sage: is_pseudoprime(-1)
604605 False
605606 sage: factor(-6)
606607 -1 * 2 * 3
607- sage: is_pseudoprime(1) # needs sage.libs.pari
608+ sage: is_pseudoprime(1)
608609 False
609- sage: is_pseudoprime(-2) # needs sage.libs.pari
610+ sage: is_pseudoprime(-2)
610611 False
611612 """
612613 return ZZ (n ).is_pseudoprime ()
@@ -1635,19 +1636,22 @@ class Sigma:
16351636
16361637 sage: sigma(100,4)
16371638 106811523
1638- sage: sigma(factorial(100), 3).mod(144169) # needs sage.libs.pari
1639+
1640+ sage: # needs sage.libs.pari
1641+ sage: sigma(factorial(100), 3).mod(144169)
16391642 3672
1640- sage: sigma(factorial(150), 12).mod(691) # needs sage.libs.pari
1643+ sage: sigma(factorial(150), 12).mod(691)
16411644 176
1642- sage: RR(sigma(factorial(133),20)) # needs sage.libs.pari sage. rings.real_mpfr
1645+ sage: RR(sigma(factorial(133),20)) # needs sage.rings.real_mpfr
16431646 2.80414775675747e4523
1644- sage: sigma(factorial(100),0) # needs sage.libs.pari
1647+ sage: sigma(factorial(100),0)
16451648 39001250856960000
1646- sage: sigma(factorial(41),1) # needs sage.libs.pari
1649+ sage: sigma(factorial(41),1)
16471650 229199532273029988767733858700732906511758707916800
16481651 sage: from numpy import int8 # needs numpy
1649- sage: sigma(int8(100), int8(4)) # needs numpy sage.libs.pari
1652+ sage: sigma(int8(100), int8(4)) # needs numpy
16501653 106811523
1654+
16511655 sage: from gmpy2 import mpz
16521656 sage: sigma(mpz(100), mpz(4))
16531657 106811523
@@ -1797,13 +1801,13 @@ def gcd(a, b=None, **kwargs):
17971801 The following shows that indeed coercion takes place before computing
17981802 the gcd. This behaviour was introduced in :trac:`10771`::
17991803
1800- sage: R.<x>= QQ[]
1801- sage: S.<x>= ZZ[]
1804+ sage: R.<x> = QQ[]
1805+ sage: S.<x> = ZZ[]
18021806 sage: p = S.random_element(degree=(0,10))
18031807 sage: q = R.random_element(degree=(0,10))
1804- sage: parent(gcd(1/p,q))
1808+ sage: parent(gcd(1/p, q))
18051809 Fraction Field of Univariate Polynomial Ring in x over Rational Field
1806- sage: parent(gcd([1/p,q]))
1810+ sage: parent(gcd([1/p, q]))
18071811 Fraction Field of Univariate Polynomial Ring in x over Rational Field
18081812
18091813 Make sure we try QQ and not merely ZZ (:trac:`13014`)::
@@ -5068,26 +5072,28 @@ def falling_factorial(x, a):
50685072
50695073 sage: falling_factorial(10, 3)
50705074 720
5071- sage: falling_factorial(10, RR('3.0')) # needs sage.symbolic
5072- 720.000000000000
5073- sage: falling_factorial(10, RR('3.3')) # needs sage.symbolic
5074- 1310.11633396601
50755075 sage: falling_factorial(10, 10)
50765076 3628800
50775077 sage: factorial(10)
50785078 3628800
5079- sage: a = falling_factorial(1 + I, I); a # needs sage.symbolic
5079+
5080+ sage: # needs sage.symbolic
5081+ sage: falling_factorial(10, RR('3.0'))
5082+ 720.000000000000
5083+ sage: falling_factorial(10, RR('3.3'))
5084+ 1310.11633396601
5085+ sage: a = falling_factorial(1 + I, I); a
50805086 gamma(I + 2)
5081- sage: CC(a) # needs sage.symbolic
5087+ sage: CC(a)
50825088 0.652965496420167 + 0.343065839816545*I
5083- sage: falling_factorial(1 + I, 4) # needs sage.symbolic
5089+ sage: falling_factorial(1 + I, 4)
50845090 4*I + 2
5085- sage: falling_factorial(I, 4) # needs sage.symbolic
5091+ sage: falling_factorial(I, 4)
50865092 -10
50875093
50885094 sage: M = MatrixSpace(ZZ, 4, 4) # needs sage.modules
50895095 sage: A = M([1,0,1,0, 1,0,1,0, 1,0,10,10, 1,0,1,1]) # needs sage.modules
5090- sage: falling_factorial(A, 2) # A(A - I) # needs sage.modules
5096+ sage: falling_factorial(A, 2) # A(A - I) # needs sage.modules
50915097 [ 1 0 10 10]
50925098 [ 1 0 10 10]
50935099 [ 20 0 101 100]
@@ -5171,18 +5177,16 @@ def rising_factorial(x, a):
51715177 sage: rising_factorial(10,3)
51725178 1320
51735179
5174- sage: rising_factorial(10, RR('3.0')) # needs sage.symbolic
5180+ sage: # needs sage.symbolic
5181+ sage: rising_factorial(10, RR('3.0'))
51755182 1320.00000000000
5176-
5177- sage: rising_factorial(10, RR('3.3')) # needs sage.symbolic
5183+ sage: rising_factorial(10, RR('3.3'))
51785184 2826.38895824964
5179-
5180- sage: a = rising_factorial(1+I, I); a # needs sage.symbolic
5185+ sage: a = rising_factorial(1+I, I); a
51815186 gamma(2*I + 1)/gamma(I + 1)
5182- sage: CC(a) # needs sage.symbolic
5187+ sage: CC(a)
51835188 0.266816390637832 + 0.122783354006372*I
5184-
5185- sage: a = rising_factorial(I, 4); a # needs sage.symbolic
5189+ sage: a = rising_factorial(I, 4); a
51865190 -10
51875191
51885192 sage: x = polygen(ZZ)
@@ -5474,7 +5478,8 @@ def three_squares(n):
54745478 sage: three_squares(7^100)
54755479 (0, 0, 1798465042647412146620280340569649349251249)
54765480 sage: three_squares(11^111 - 1) # needs sage.libs.pari
5477- (616274160655975340150706442680, 901582938385735143295060746161, 6270382387635744140394001363065311967964099981788593947233)
5481+ (616274160655975340150706442680, 901582938385735143295060746161,
5482+ 6270382387635744140394001363065311967964099981788593947233)
54785483 sage: three_squares(7 * 2^41) # needs sage.libs.pari
54795484 (1048576, 2097152, 3145728)
54805485 sage: three_squares(7 * 2^42)
@@ -5618,8 +5623,9 @@ def four_squares(n):
56185623 sage: four_squares(1101011011004)
56195624 (90, 102, 1220, 1049290)
56205625 sage: four_squares(10^100 - 1) # needs sage.libs.pari
5621- (155024616290, 2612183768627, 14142135623730950488016887, 99999999999999999999999999999999999999999999999999)
5622- sage: for i in range(2^129, 2^129+10000): # long time # needs sage.libs.pari
5626+ (155024616290, 2612183768627, 14142135623730950488016887,
5627+ 99999999999999999999999999999999999999999999999999)
5628+ sage: for i in range(2^129, 2^129 + 10000): # long time # needs sage.libs.pari
56235629 ....: S = four_squares(i)
56245630 ....: assert sum(x^2 for x in S) == i
56255631
@@ -5695,7 +5701,11 @@ def sum_of_k_squares(k, n):
56955701 sage: sum_of_k_squares(5, 9634)
56965702 (0, 1, 2, 5, 98)
56975703 sage: sum_of_k_squares(6, 11^1111 - 1) # needs sage.libs.pari
5698- (19215400822645944253860920437586326284, 37204645194585992174252915693267578306, 3473654819477394665857484221256136567800161086815834297092488779216863122, 5860191799617673633547572610351797996721850737768032876360978911074629287841061578270832330322236796556721252602860754789786937515870682024273948, 20457423294558182494001919812379023992538802203730791019728543439765347851316366537094696896669915675685581905102118246887673397020172285247862426612188418787649371716686651256443143210952163970564228423098202682066311189439731080552623884051737264415984619097656479060977602722566383385989, 311628095411678159849237738619458396497534696043580912225334269371611836910345930320700816649653412141574887113710604828156159177769285115652741014638785285820578943010943846225597311231847997461959204894255074229895666356909071243390280307709880906261008237873840245959883405303580405277298513108957483306488193844321589356441983980532251051786704380984788999660195252373574924026139168936921591652831237741973242604363696352878914129671292072201700073286987126265965322808664802662993006926302359371379531571194266134916767573373504566621665949840469229781956838744551367172353)
5704+ (19215400822645944253860920437586326284, 37204645194585992174252915693267578306,
5705+ 3473654819477394665857484221256136567800161086815834297092488779216863122,
5706+ 5860191799617673633547572610351797996721850737768032876360978911074629287841061578270832330322236796556721252602860754789786937515870682024273948,
5707+ 20457423294558182494001919812379023992538802203730791019728543439765347851316366537094696896669915675685581905102118246887673397020172285247862426612188418787649371716686651256443143210952163970564228423098202682066311189439731080552623884051737264415984619097656479060977602722566383385989,
5708+ 311628095411678159849237738619458396497534696043580912225334269371611836910345930320700816649653412141574887113710604828156159177769285115652741014638785285820578943010943846225597311231847997461959204894255074229895666356909071243390280307709880906261008237873840245959883405303580405277298513108957483306488193844321589356441983980532251051786704380984788999660195252373574924026139168936921591652831237741973242604363696352878914129671292072201700073286987126265965322808664802662993006926302359371379531571194266134916767573373504566621665949840469229781956838744551367172353)
56995709 sage: sum_of_k_squares(7, 0)
57005710 (0, 0, 0, 0, 0, 0, 0)
57015711 sage: sum_of_k_squares(30,999999)
@@ -5954,32 +5964,32 @@ def sort_complex_numbers_for_display(nums):
59545964
59555965 EXAMPLES::
59565966
5967+ sage: # needs sage.rings.complex_double
59575968 sage: import sage.arith.misc
59585969 sage: sort_c = sort_complex_numbers_for_display
5959- sage: nums = [CDF(i) for i in range(3)] # needs sage.rings.complex_double
5960- sage: for i in range(3): # needs sage.rings.complex_double
5970+ sage: nums = [CDF(i) for i in range(3)]
5971+ sage: for i in range(3):
59615972 ....: nums.append(CDF(i + RDF.random_element(-3e-11, 3e-11),
59625973 ....: RDF.random_element()))
59635974 ....: nums.append(CDF(i + RDF.random_element(-3e-11, 3e-11),
59645975 ....: RDF.random_element()))
5965- sage: shuffle(nums) # needs sage.rings.complex_double
5966- sage: nums = sort_c(nums) # needs sage.rings.complex_double
5967- sage: for i in range(len(nums)): # needs sage.rings.complex_double
5976+ sage: shuffle(nums)
5977+ sage: nums = sort_c(nums)
5978+ sage: for i in range(len(nums)):
59685979 ....: if nums[i].imag():
59695980 ....: first_non_real = i
59705981 ....: break
59715982 ....: else:
59725983 ....: first_non_real = len(nums)
5973- sage: assert first_non_real >= 3 # needs sage.rings.complex_double
5974- sage: for i in range(first_non_real - 1): # needs sage.rings.complex_double
5984+ sage: assert first_non_real >= 3
5985+ sage: for i in range(first_non_real - 1):
59755986 ....: assert nums[i].real() <= nums[i + 1].real()
5976-
59775987 sage: def truncate(n):
59785988 ....: if n.real() < 1e-10:
59795989 ....: return 0
59805990 ....: else:
59815991 ....: return n.real().n(digits=9)
5982- sage: for i in range(first_non_real, len(nums)-1): # needs sage.rings.complex_double
5992+ sage: for i in range(first_non_real, len(nums)-1):
59835993 ....: assert truncate(nums[i]) <= truncate(nums[i + 1])
59845994 ....: if truncate(nums[i]) == truncate(nums[i + 1]):
59855995 ....: assert nums[i].imag() <= nums[i+1].imag()
0 commit comments