Sharedsupport / 2016-04-27-144252.sagewsOpen in CoCalc
Author: William A. Stein
License: GNU General Public License v3.0
Description: Examples for support purposes.
R.<x> = QQ[] f = x^6 + 9398*x^5 + 939*x^4 + 10*x^3 + 17*x + 3
f.factor()
x^6 + 9398*x^5 + 939*x^4 + 10*x^3 + 17*x + 3
for p in primes(50): print p, f.factor_mod(p)
2 (x + 1) * (x^2 + x + 1) * (x^3 + x + 1) 3 x * (x + 2)^2 * (x^3 + x^2 + x + 2) 5 x^6 + 3*x^5 + 4*x^4 + 2*x + 3 7 x^6 + 4*x^5 + x^4 + 3*x^3 + 3*x + 3 11 (x + 4)^2 * (x^4 + 7*x^3 + 9*x^2 + 2*x + 5) 13 (x + 3) * (x + 10)^2 * (x^3 + 2*x^2 + 5*x + 3) 17 (x^2 + x + 2) * (x^2 + 3*x + 12) * (x^2 + 10*x + 15) 19 (x + 16) * (x^2 + 16*x + 11) * (x^3 + 18*x^2 + x + 12) 23 (x + 13) * (x + 18) * (x^4 + 6*x^3 + 13*x^2 + 20*x + 18) 29 (x^3 + 10*x^2 + 10*x + 22) * (x^3 + 21*x^2 + 23*x + 12) 31 (x + 7) * (x^2 + 9*x + 22) * (x^3 + 20*x^2 + 7*x + 28) 37 (x + 20) * (x + 24) * (x^2 + 6*x + 4) * (x^2 + 24*x + 27) 41 x^6 + 9*x^5 + 37*x^4 + 10*x^3 + 17*x + 3 43 (x + 35) * (x^5 + 32*x^4 + 34*x^3 + 24*x^2 + 20*x + 5) 47 (x + 8) * (x + 13) * (x^4 + 24*x^3 + 2*x^2 + 10*x + 5)
f.factor_mod(17) f.factor_mod(29)
(x^2 + x + 2) * (x^2 + 3*x + 12) * (x^2 + 10*x + 15) (x^3 + 10*x^2 + 10*x + 22) * (x^3 + 21*x^2 + 23*x + 12)
devel/sage/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx 0a0dfac1-36b5-4245-a768-551666c6332cs v = list(Partitions(6))
v
[[6], [5, 1], [4, 2], [4, 1, 1], [3, 3], [3, 2, 1], [3, 1, 1, 1], [2, 2, 2], [2, 2, 1, 1], [2, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]
v[1] [x for x in v if v[1].contains(x)]
[5, 1] [[5, 1]]
R.<x> = QQ[] f = R.random_element(800) f
2/21*x^800 + x^799 + 1/2*x^798 + 4*x^796 + 88/61*x^795 + 1/89*x^792 - x^790 - x^789 + x^788 - x^786 + x^785 - 49*x^783 + 2*x^782 - x^781 + 2*x^780 + 2*x^779 + x^778 - 1/2*x^777 + 1/11*x^776 - 1/12*x^773 - 13*x^770 - 1/6*x^769 - 1/6*x^768 - 11*x^767 - x^766 - x^765 - 19/2*x^763 - 1/24*x^762 - 15*x^761 - 4/3*x^760 - 1/40*x^758 + x^756 - 2*x^754 + 4*x^752 + x^751 + x^750 + 10*x^749 + x^747 - 2*x^745 + 1/3*x^744 + 73/347*x^743 + x^742 + x^741 + 1/8*x^740 + x^738 + x^737 + 9/20*x^736 - x^735 - 3*x^733 - 1/6*x^731 - 3/4*x^730 + 5/2*x^729 - 3*x^726 - x^725 - x^724 + 2*x^722 - 7/8*x^721 + 16/3*x^720 + 3*x^719 + 2*x^718 - 4*x^717 + 67*x^713 + x^711 - 13/5*x^710 + 3*x^707 - 1/2*x^706 - 2/7*x^704 - 2*x^703 - x^702 - 1/54*x^701 - x^699 - x^698 + 2*x^697 + 3/2*x^696 + 1/2*x^695 + x^693 + x^692 + 6*x^691 + 13*x^690 - 1/3*x^689 + 1/2*x^688 + 5*x^687 + 3*x^686 + 5*x^684 + 5*x^682 - 1/2*x^681 - 2*x^680 + x^679 - 1/14*x^678 + 3*x^677 - x^676 + x^675 + 2*x^674 + 23*x^673 - 1/119*x^672 + 3*x^671 - x^670 - x^669 + 3/7*x^668 - x^667 - 2/3*x^666 + 1/2*x^663 + 2*x^662 - 5*x^661 - 1/7*x^660 - 14*x^659 + 1/3*x^658 + 3*x^657 + 19/3*x^656 + 3*x^655 - x^653 + 1/4*x^652 + x^650 + x^649 + 1/15*x^648 - 2*x^647 + 1/2*x^646 + 2*x^644 - 2*x^643 + x^642 + x^641 - 8/7*x^640 + x^638 - 1/2*x^635 + x^633 - 3*x^631 - 2*x^630 - 2*x^629 - 35*x^628 + 2*x^627 - 2/3*x^626 + x^625 + 2*x^623 - x^622 - 19*x^621 + 28/5*x^620 + 17*x^619 - 1/4*x^616 + 2*x^615 - 1/2*x^613 + 3*x^610 - 5*x^609 + 15/2*x^607 + x^606 + 2/3*x^605 - x^604 - 28*x^603 - 4*x^601 - 11*x^600 + 3*x^599 - 3*x^598 + x^597 - 1/3*x^596 + 5/6*x^595 + x^593 + 1/3*x^592 - 5*x^591 - 13/5*x^590 + 6*x^589 - 135/2*x^588 + 11*x^587 - 3*x^586 - 7*x^585 - 3/2*x^584 - 1/2*x^583 + 2*x^582 + x^581 - x^580 - 4*x^579 + x^578 + x^577 + 3/10*x^576 - 1/3*x^575 - 7*x^574 + 2*x^573 - 1/6*x^572 - 17*x^571 - 1/5*x^570 + x^568 + 1/20*x^566 - 11*x^565 + 1/40*x^563 + x^562 + x^561 - 1/4*x^560 + x^559 + x^558 - x^557 + x^556 + 1/3*x^555 + 1/5*x^554 - x^553 + 1/124*x^552 + 25*x^551 + 2*x^549 - 4*x^548 + 2*x^547 + 1/4*x^545 + 1/2*x^544 - 1/2*x^543 - x^542 - 2*x^541 - x^539 + 2*x^538 + 13/3*x^537 - x^536 - x^535 - 1/4*x^534 - x^532 + 2*x^531 + 1/6*x^529 - x^528 - 1/3*x^526 + 1/2*x^524 - 2*x^523 + 1/4*x^522 - x^521 + 2*x^520 - 15/2*x^519 + 1/2*x^518 - 1/6*x^516 + 1/9*x^512 - x^511 + x^510 - x^509 - 1/9*x^508 + 16/5*x^507 - 5/3*x^506 + x^505 + 9*x^504 + x^503 - 1/2*x^502 + x^501 + 79/85*x^499 - 25/29*x^498 - 6*x^496 + x^495 + 1/4*x^494 - 2*x^492 - 3*x^491 + 1/5*x^490 + 1/21*x^488 + x^487 - x^486 + x^484 + x^483 + x^482 - 3*x^478 + 6*x^477 + x^476 - 4*x^475 - 6*x^474 - 1/5*x^473 - 1/2*x^469 - 1/2*x^468 + 4*x^467 + 2/15*x^466 + x^464 + x^463 + x^462 - x^461 - 2/3*x^459 - 3*x^456 - 1/3*x^455 + x^454 - x^453 + x^450 + 1/2*x^449 - x^448 + 2*x^446 - 14*x^444 - 1/9*x^443 + 1/5*x^442 + x^441 - x^440 - 3/2*x^438 - x^437 - 17*x^436 + x^435 - x^434 - 2/3*x^433 + x^432 + 1/2*x^431 + 2/9*x^430 + x^426 + 4/3*x^423 - 1/2*x^422 + 4*x^420 + 1/18*x^419 - 1/2*x^418 - x^416 - 2/9*x^414 + 75*x^413 + x^412 - 1/2*x^410 - 1/4*x^409 + 3*x^408 + 1/2*x^407 + 1/2*x^406 - x^405 - 1/19*x^403 - x^401 - 5/2*x^400 + 1/6*x^399 - 1/4*x^397 - 1/3*x^394 + 4*x^393 - 1/2*x^392 - 1/2*x^390 + x^389 + 2/5*x^388 + x^387 + x^386 - x^384 - 4/7*x^383 - 2/11*x^381 - 1/3*x^380 - 21*x^379 + 2*x^378 + x^377 - 1/28*x^376 - 1/40*x^375 + 1/8*x^374 + 2*x^373 - 2/21*x^372 + x^371 - x^370 - x^369 + x^368 + 1/5*x^367 - x^366 - x^365 - 1/82*x^362 + 3*x^361 - 6/5*x^360 - 1/23*x^359 - 1/2*x^358 + 5*x^357 - x^356 + x^355 + 3*x^354 + 2*x^353 + x^351 - 1/6*x^350 + 1/2*x^349 + x^348 + 2/5*x^347 - 334*x^346 + 2/7*x^345 + x^344 - 32*x^343 + 2/9*x^342 - 2*x^341 + 1/4*x^339 - 6*x^338 - 1/3*x^337 - x^336 - x^335 + x^334 - 3*x^332 - x^331 - 2*x^330 - 2*x^327 - 1/7*x^326 - 12/17*x^323 + 1/8*x^322 + x^321 - 1/3*x^320 + x^319 - x^318 + 1/10*x^316 + 6/5*x^315 + 7/3*x^314 + x^313 + 1/3*x^312 + 1/2*x^309 - x^308 + x^307 + 1/5*x^305 - x^303 + x^302 - 1/2*x^301 - x^300 - 8*x^299 - 5/3*x^298 - 1/4*x^297 + 2*x^296 - 1/2*x^295 + 3/2*x^293 - 3*x^292 - 75*x^290 + 10*x^289 - 1/2*x^288 + x^287 + x^285 - 7/2*x^284 + 8/3*x^283 + 4*x^282 + 2*x^281 - 1/6*x^280 - x^278 + 1/3*x^276 - x^275 - 1/5*x^274 - 7/2*x^272 - 5/6*x^271 - x^269 - x^266 + 24*x^265 - 4/5*x^264 - 7/5*x^262 + 6*x^261 + 27*x^259 - x^258 - 1/2*x^256 + 6*x^255 + x^254 - 2*x^252 + x^251 - 1/2*x^250 + 2*x^249 - 5/3*x^248 + 2/5*x^247 - 1/6*x^246 + 1/13*x^245 + 1/2*x^243 - 1/19*x^241 - 4*x^240 - 1/3*x^239 - x^238 - 2/3*x^237 - x^236 - 1/5*x^235 + 1/30*x^234 + 10*x^233 + 1/2*x^232 - x^231 - x^230 - 6*x^229 + 6*x^227 + 6*x^226 + x^225 - x^222 + x^220 + 10*x^219 + 5/2*x^218 + 1/2*x^217 - x^216 - 11/4*x^215 + 10/101*x^214 - x^213 + 2*x^212 - 1/2*x^211 + x^210 + x^209 - x^208 - 1/78*x^207 + x^206 - 9*x^205 + 3*x^204 + 3*x^203 - x^202 - x^200 + 3*x^199 + 2*x^198 - 4*x^197 + x^196 + 2/3*x^195 - 2*x^194 + x^193 + 13/3*x^192 - 2*x^191 - 1/4*x^190 + x^189 - 1/3*x^188 + x^187 - 2/3*x^186 + 5*x^185 + 1/2*x^184 - 1/19*x^183 + x^182 + 3*x^181 + 11*x^178 + 2/3*x^175 - 1/4*x^174 + x^173 + x^172 + 1/2*x^170 - 50*x^169 - x^167 + 6*x^165 + 3*x^163 - 1/4*x^162 + x^161 + 1/18*x^160 + x^158 - 8*x^157 + 18*x^156 + 1/2*x^155 - 5*x^154 + 1/11*x^153 - x^152 + 1/2*x^151 + x^150 + x^149 + 2*x^146 + 7/2*x^145 + 31/15*x^143 - 2*x^142 + x^140 - 1/2*x^139 + x^137 + 1/5*x^136 + 13/112*x^134 - 4*x^133 - 1/7*x^132 - 7/2*x^131 - 13*x^130 - x^129 + x^128 - x^127 - 5*x^126 - 3/13*x^125 - 3/2*x^124 + 1/2*x^123 - 2/3*x^121 - 1/9*x^120 + x^119 + 1/2*x^118 + 1/3*x^115 - 1/4*x^114 + 1/6*x^113 - 1/2*x^112 + x^110 - x^109 + 161*x^108 - 3/2*x^107 - 1/2*x^105 + x^104 + 5*x^102 - 7*x^101 + 1/3*x^100 + 1/3*x^99 - 1/3*x^98 - 2*x^97 + x^96 - 2*x^95 - 2*x^94 - x^92 + 2*x^89 - x^88 + 2*x^86 - x^84 + x^81 + 25*x^80 + 3/5*x^79 - 10/13*x^78 + 5/6*x^77 + 2*x^76 - x^75 + x^73 - 8*x^72 + 2*x^71 + 1/19*x^70 - 9*x^69 + 1/23*x^68 - 1/2*x^67 - x^66 - 1/3*x^63 + 1/2*x^62 - 13*x^61 + x^60 + 7*x^58 - 1/9*x^56 - x^55 - 2/79*x^54 - 1/11*x^53 + x^52 + 1/3*x^51 + 14*x^50 + 2/3*x^48 + 1/2*x^47 - x^46 - 3/4*x^45 - 2/21*x^43 - 2/3*x^42 - 2/5*x^38 - 1/3*x^36 + 2*x^35 - x^33 - 2*x^32 + x^31 + 1/6*x^29 + 2/3*x^28 + 1/2*x^27 + 1/2*x^26 + 1/2*x^25 + 2*x^24 - 1/7*x^23 - 3*x^22 - 1/6*x^21 - 1/2*x^20 + 3*x^19 - x^16 + 1/16*x^15 + 2*x^14 - 4/3*x^13 + x^12 + 5*x^11 + x^10 - x^9 - 8*x^7 - 2*x^6 - 45/2*x^3 + 2*x^2 - 1/2
f.factor()
Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "sage/rings/polynomial/polynomial_element.pyx", line 3674, in sage.rings.polynomial.polynomial_element.Polynomial.factor (/projects/sage/sage-6.10/src/build/cythonized/sage/rings/polynomial/polynomial_element.c:32746) return R._factor_univariate_polynomial(self, **kwargs) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/rings/rational_field.py", line 1306, in _factor_univariate_polynomial G = list(f._pari_with_name().factor()) File "sage/libs/pari/gen.pyx", line 8987, in sage.libs.pari.gen.gen.factor (/projects/sage/sage-6.10/src/build/cythonized/sage/libs/pari/gen.c:140712) pari_catch_sig_on() File "sage/ext/interrupt/interrupt.pyx", line 88, in sage.ext.interrupt.interrupt.sig_raise_exception (/projects/sage/sage-6.10/src/build/cythonized/sage/ext/interrupt/interrupt.c:924) raise KeyboardInterrupt KeyboardInterrupt
for p in primes(100): try: v = [g[0].degree() for g in f.factor_mod(p)] print p, v except: pass
37 [1, 3, 5, 13, 34, 94, 211, 439] 43 [1, 1, 1, 8, 13, 23, 28, 725] 47 [1, 1, 1, 10, 11, 20, 264, 492] 53 [1, 1, 3, 8, 34, 142, 171, 440] 59 [1, 3, 29, 45, 71, 106, 135, 410] 67 [1, 2, 2, 54, 60, 137, 544] 71 [2, 21, 24, 240, 513] 73 [1, 1, 1, 19, 23, 45, 710] 83 [22, 30, 211, 537] 97 [1, 5, 26, 101, 142, 231, 294]
%time f.is_irreducible()
True CPU time: 1.06 s, Wall time: 1.10 s
f.factor()
(-1/32) * x * (x^29 + 64*x^28 + 32*x^26 + 4/3*x^25 - 416*x^24 - 1568*x^23 + 192/7*x^22 - 256*x^21 + 64*x^20 - 32*x^19 + 64/3*x^18 - 16*x^17 - 32*x^16 + 32*x^15 - 32*x^14 + 32*x^13 + 32/5*x^11 - 80*x^10 - 32*x^9 - 32*x^8 + 64*x^6 - 32*x^5 + 16*x^4 + 32/9*x^3 - 8/9*x^2 + 192)
factorial(7)
5040