@@ -565,11 +565,11 @@ cdef class Polynomial(CommutativePolynomial):
565
565
tuple containing the values to be substituted, though it is
566
566
perhaps more natural to just unpack the list::
567
567
568
- sage: f([2]) # calling with a list
568
+ sage: f([2]) # calling with a list
569
569
3*x + 4
570
- sage: f((2,)) # calling with a tuple
570
+ sage: f((2,)) # calling with a tuple
571
571
3*x + 4
572
- sage: f(*[2]) # unpacking the list to call normally
572
+ sage: f(*[2]) # unpacking the list to call normally
573
573
3*x + 4
574
574
575
575
The following results in an element of the symbolic ring. ::
@@ -710,11 +710,12 @@ cdef class Polynomial(CommutativePolynomial):
710
710
711
711
These were drastically slower prior to :trac:`33165`::
712
712
713
- sage: R.<x> = GF(31337)[] # needs sage.rings.finite_rings
713
+ sage: # needs sage.rings.finite_rings
714
+ sage: R.<x> = GF(31337)[]
714
715
sage: f = R(list(range(100, 201)))
715
716
sage: g = R(list(range(1, 1001)))
716
- sage: S.<y> = R.quotient(f) # needs sage.rings.finite_rings
717
- sage: g(y) # needs sage.rings.finite_rings
717
+ sage: S.<y> = R.quotient(f)
718
+ sage: g(y)
718
719
22537*y^99 + 4686*y^98 + 13285*y^97 + 4216*y^96 + ... + 6389*y^3 + 30062*y^2 + 13755*y + 11875
719
720
720
721
::
@@ -1300,7 +1301,7 @@ cdef class Polynomial(CommutativePolynomial):
1300
1301
Defn: x |--> 5
1301
1302
sage: f(x)
1302
1303
5
1303
- sage: f(x^2 + 3) # indirect doctest
1304
+ sage: f(x^2 + 3) # indirect doctest
1304
1305
28
1305
1306
1306
1307
sage: # needs sage.rings.number_field
@@ -1383,7 +1384,7 @@ cdef class Polynomial(CommutativePolynomial):
1383
1384
0. 6324555320336758* I
1384
1385
sage: CC( c)
1385
1386
0. 632455532033676* I
1386
- sage: CBF( c) # abs tol 1e-16 # needs sage. libs. flint
1387
+ sage: CBF( c) # abs tol 1e-16 # needs sage. libs. flint
1387
1388
[0.6324555320336759 +/- 3.38e-17 ]* I
1388
1389
sage: CIF( c)
1389
1390
0. 6324555320336758?* I
@@ -2455,12 +2456,13 @@ cdef class Polynomial(CommutativePolynomial):
2455
2456
2456
2457
Check that the algorithm used is indeed correct::
2457
2458
2459
+ sage: # needs sage.rings.finite_rings
2458
2460
sage: from sage.arith.power import generic_power
2459
- sage: R1 = PolynomialRing(GF(8,'a'), 'x') # needs sage.rings.finite_rings
2460
- sage: R2 = PolynomialRing(GF(9,'b'), 'x', sparse=True) # needs sage.rings.finite_rings
2461
+ sage: R1 = PolynomialRing(GF(8,'a'), 'x')
2462
+ sage: R2 = PolynomialRing(GF(9,'b'), 'x', sparse=True)
2461
2463
sage: R3 = PolynomialRing(R2, 'y')
2462
2464
sage: R4 = PolynomialRing(R1, 'y', sparse=True)
2463
- sage: for d in range(20,40): # long time # needs sage.rings.finite_rings
2465
+ sage: for d in range(20,40): # long time
2464
2466
....: for R in [R1, R2, R3, R3]:
2465
2467
....: a = R.random_element()
2466
2468
....: assert a^d == generic_power(a, d)
@@ -2595,16 +2597,16 @@ cdef class Polynomial(CommutativePolynomial):
2595
2597
TESTS::
2596
2598
2597
2599
sage: x = polygen( QQ)
2598
- sage: ( 3* x- 5) . power_trunc( 2^ 200, 0)
2600
+ sage: ( 3* x - 5) . power_trunc( 2^ 200, 0)
2599
2601
0
2600
2602
sage: x. power_trunc( -1, 10)
2601
2603
Traceback ( most recent call last) :
2602
2604
...
2603
2605
ValueError: n must be a non-negative integer
2604
2606
sage: R. <y> = QQ['x' ]
2605
- sage: y. power_trunc( 2** 32- 1, 2)
2607
+ sage: y. power_trunc( 2** 32 - 1, 2)
2606
2608
0
2607
- sage: y. power_trunc( 2** 64- 1, 2)
2609
+ sage: y. power_trunc( 2** 64 - 1, 2)
2608
2610
0
2609
2611
"""
2610
2612
cdef Integer ZZn = ZZ(n)
@@ -4256,7 +4258,7 @@ cdef class Polynomial(CommutativePolynomial):
4256
4258
* ( x + 0. 9999908759550227 - 1. 0000069659624138* I)
4257
4259
* ( x + 0. 9999985293216753 - 0. 9999886153831807* I)
4258
4260
* ( x + 1. 0000105947233 - 1. 0000044186544053* I)
4259
- sage: [f(t[0 ][0 ]). abs( ) for t in F] # abs tol 1e-13
4261
+ sage: [f(t[0 ][0 ]). abs( ) for t in F] # abs tol 1e-13
4260
4262
[1.979365054e-14, 1.97936298566e-14, 1.97936990747e-14,
4261
4263
3.6812407475e-14, 3.65211563729e-14, 3.65220890052e-14 ]
4262
4264
@@ -4398,20 +4400,22 @@ cdef class Polynomial(CommutativePolynomial):
4398
4400
4399
4401
Test that :trac:`10279` is fixed::
4400
4402
4403
+ sage: # needs sage. rings. number_field
4401
4404
sage: R. <t> = PolynomialRing( QQ)
4402
- sage: K. <a> = NumberField( t^ 4 - t^ 2 + 1) # needs sage . rings . number_field
4403
- sage: pol = t^ 3 + ( -4* a^ 3 + 2* a) * t^ 2 - 11/3* a^ 2* t + 2/3* a^ 3 - 4/3* a # needs sage . rings . number_field
4404
- sage: pol. factor( ) # needs sage . rings . number_field
4405
+ sage: K. <a> = NumberField( t^ 4 - t^ 2 + 1)
4406
+ sage: pol = t^ 3 + ( -4* a^ 3 + 2* a) * t^ 2 - 11/3* a^ 2* t + 2/3* a^ 3 - 4/3* a
4407
+ sage: pol. factor( )
4405
4408
( t - 2* a^ 3 + a) * ( t - 4/3* a^ 3 + 2/3* a) * ( t - 2/3* a^ 3 + 1/3* a)
4406
4409
4407
4410
Test that this factorization really uses ``nffactor( ) `` internally::
4408
4411
4409
- sage: pari. default( "debug", 3) # needs sage. libs. pari
4410
- sage: F = pol. factor( ) # needs sage. rings. number_field
4412
+ sage: # needs sage. libs. pari sage. rings. number_field
4413
+ sage: pari. default( "debug", 3)
4414
+ sage: F = pol. factor( )
4411
4415
<BLANKLINE>
4412
4416
Entering nffactor:
4413
4417
...
4414
- sage: pari. default( "debug", 0) # needs sage . libs . pari
4418
+ sage: pari. default( "debug", 0)
4415
4419
4416
4420
Test that :trac:`10369` is fixed::
4417
4421
@@ -9827,6 +9831,7 @@ cdef class Polynomial(CommutativePolynomial):
9827
9831
A generic implementation is available, which relies on gcd
9828
9832
computations::
9829
9833
9834
+ sage: # needs sage.libs.pari
9830
9835
sage: R.<x> = ZZ[]
9831
9836
sage: (2*x).is_squarefree() # needs sage.libs.pari
9832
9837
True
@@ -9937,9 +9942,9 @@ cdef class Polynomial(CommutativePolynomial):
9937
9942
EXAMPLES::
9938
9943
9939
9944
sage: R. <x> = QQbar[] # needs sage. rings. number_field
9940
- sage: ( x^ 2* ( x + 1)) . is_squarefree( ) # indirect doctest # needs sage. rings. number_field
9945
+ sage: ( x^ 2* ( x + 1)) . is_squarefree( ) # indirect doctest # needs sage. rings. number_field
9941
9946
False
9942
- sage: ( x* ( x+ 1)) . is_squarefree( ) # indirect doctest # needs sage. rings. number_field
9947
+ sage: ( x* ( x+ 1)) . is_squarefree( ) # indirect doctest # needs sage. rings. number_field
9943
9948
True
9944
9949
9945
9950
"""
@@ -10162,23 +10167,25 @@ cdef class Polynomial(CommutativePolynomial):
10162
10167
10163
10168
EXAMPLES::
10164
10169
10165
- sage: R.<x> = SR[] # needs sage.symbolic
10166
- sage: f = (1+I)*x^2 + 3*x - I # needs sage.symbolic
10167
- sage: f.map_coefficients(lambda z: z.conjugate()) # needs sage.symbolic
10168
- (-I + 1)*x^2 + 3*x + I
10169
10170
sage: R.<x> = ZZ[]
10170
10171
sage: f = x^2 + 2
10171
10172
sage: f.map_coefficients(lambda a: a + 42)
10172
10173
43*x^2 + 44
10173
- sage: R.<x> = PolynomialRing(SR, sparse=True) # needs sage.symbolic
10174
- sage: f = (1+I)*x^(2^32) - I # needs sage.symbolic
10175
- sage: f.map_coefficients(lambda z: z.conjugate()) # needs sage.symbolic
10176
- (-I + 1)*x^4294967296 + I
10177
10174
sage: R.<x> = PolynomialRing(ZZ, sparse=True)
10178
10175
sage: f = x^(2^32) + 2
10179
10176
sage: f.map_coefficients(lambda a: a + 42)
10180
10177
43*x^4294967296 + 44
10181
10178
10179
+ sage: # needs sage.symbolic
10180
+ sage: R.<x> = SR[]
10181
+ sage: f = (1+I)*x^2 + 3*x - I
10182
+ sage: f.map_coefficients(lambda z: z.conjugate())
10183
+ (-I + 1)*x^2 + 3*x + I
10184
+ sage: R.<x> = PolynomialRing(SR, sparse=True)
10185
+ sage: f = (1+I)*x^(2^32) - I
10186
+ sage: f.map_coefficients(lambda z: z.conjugate())
10187
+ (-I + 1)*x^4294967296 + I
10188
+
10182
10189
Examples with different base ring::
10183
10190
10184
10191
sage: R.<x> = ZZ[]
@@ -12453,7 +12460,7 @@ cdef class ConstantPolynomialSection(Map):
12453
12460
Generic map:
12454
12461
From: Univariate Polynomial Ring in x over Rational Field
12455
12462
To: Rational Field
12456
- sage: m(x-x+1/2) # implicit
12463
+ sage: m(x-x+1/2) # implicit
12457
12464
1/2
12458
12465
sage: m(x-x)
12459
12466
0
@@ -12598,7 +12605,7 @@ cdef class PolynomialBaseringInjection(Morphism):
12598
12605
Polynomial base injection morphism:
12599
12606
From: Integer Ring
12600
12607
To: Univariate Polynomial Ring in x over Integer Ring
12601
- sage: m(2) # indirect doctest
12608
+ sage: m(2) # indirect doctest
12602
12609
2
12603
12610
sage: parent(m(2))
12604
12611
Univariate Polynomial Ring in x over Integer Ring
@@ -12649,7 +12656,7 @@ cdef class PolynomialBaseringInjection(Morphism):
12649
12656
12650
12657
Check that :trac:`23203` has been resolved::
12651
12658
12652
- sage: R. is_subring( S) # indirect doctest
12659
+ sage: R. is_subring( S) # indirect doctest
12653
12660
True
12654
12661
12655
12662
"""
0 commit comments