Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Math 223a Class Demos

Project: Math 223a
Views: 1226
R5 = Zp(5); R5 #define 5-adic ring, default precision is O(5^20)
5-adic Ring with capped relative precision 20
F5 = GF(5); F5 #define residue field F_5
Finite Field of size 5
a = R5(-1/2); a # -1/2 as a 5-adic power series
2 + 2*5 + 2*5^2 + 2*5^3 + 2*5^4 + 2*5^5 + 2*5^6 + 2*5^7 + 2*5^8 + 2*5^9 + 2*5^10 + 2*5^11 + 2*5^12 + 2*5^13 + 2*5^14 + 2*5^15 + 2*5^16 + 2*5^17 + 2*5^18 + 2*5^19 + O(5^20)
R5polys = R5['x'] #define a polynomial ring over Z_5 in the variable x
poly = x^5 - x #this polynomial has 5 distinct roots in F5, so by Hensel's lemma they should lift to Z5
roots = gp.polrootspadic(poly, 5, 20); roots #find the roots of x^5-x in Z5 to precision O(5^20)
[O(5^20), 1 + O(5^20), 2 + 5 + 2*5^2 + 5^3 + 3*5^4 + 4*5^5 + 2*5^6 + 3*5^7 + 3*5^9 + 2*5^10 + 2*5^11 + 4*5^13 + 5^14 + 3*5^15 + 2*5^16 + 4*5^17 + 4*5^19 + O(5^20), 3 + 3*5 + 2*5^2 + 3*5^3 + 5^4 + 2*5^6 + 5^7 + 4*5^8 + 5^9 + 2*5^10 + 2*5^11 + 4*5^12 + 3*5^14 + 5^15 + 2*5^16 + 4*5^18 + O(5^20), 4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + 4*5^6 + 4*5^7 + 4*5^8 + 4*5^9 + 4*5^10 + 4*5^11 + 4*5^12 + 4*5^13 + 4*5^14 + 4*5^15 + 4*5^16 + 4*5^17 + 4*5^18 + 4*5^19 + O(5^20)]~
gp.factorpadic(poly, 5, 20) #factor x^5-x in Z5 to precision O(5^20)
[(1 + O(5^20))*x + O(5^20), 1; (1 + O(5^20))*x + (1 + O(5^20)), 1; (1 + O(5^20))*x + (3 + 3*5 + 2*5^2 + 3*5^3 + 5^4 + 2*5^6 + 5^7 + 4*5^8 + 5^9 + 2*5^10 + 2*5^11 + 4*5^12 + 3*5^14 + 5^15 + 2*5^16 + 4*5^18 + O(5^20)), 1; (1 + O(5^20))*x + (2 + 5 + 2*5^2 + 5^3 + 3*5^4 + 4*5^5 + 2*5^6 + 3*5^7 + 3*5^9 + 2*5^10 + 2*5^11 + 4*5^13 + 5^14 + 3*5^15 + 2*5^16 + 4*5^17 + 4*5^19 + O(5^20)), 1; (1 + O(5^20))*x + (4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + 4*5^6 + 4*5^7 + 4*5^8 + 4*5^9 + 4*5^10 + 4*5^11 + 4*5^12 + 4*5^13 + 4*5^14 + 4*5^15 + 4*5^16 + 4*5^17 + 4*5^18 + 4*5^19 + O(5^20)), 1]
poly2 = x^6 - 1; #another polynomial
gp.polrootspadic(poly2, 5, 20) #this one only has roots 1 and -1 in Z5
[1 + O(5^20), 4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + 4*5^6 + 4*5^7 + 4*5^8 + 4*5^9 + 4*5^10 + 4*5^11 + 4*5^12 + 4*5^13 + 4*5^14 + 4*5^15 + 4*5^16 + 4*5^17 + 4*5^18 + 4*5^19 + O(5^20)]~
gp.factorpadic(poly2, 5, 20) #but it factors as a product of two linear and two quadratic polynomials (as expected by Hensel's lemma)
[(1 + O(5^20))*x + (1 + O(5^20)), 1; (1 + O(5^20))*x + (4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + 4*5^6 + 4*5^7 + 4*5^8 + 4*5^9 + 4*5^10 + 4*5^11 + 4*5^12 + 4*5^13 + 4*5^14 + 4*5^15 + 4*5^16 + 4*5^17 + 4*5^18 + 4*5^19 + O(5^20)), 1; (1 + O(5^20))*x^2 + (1 + O(5^20))*x + (1 + O(5^20)), 1; (1 + O(5^20))*x^2 + (4 + 4*5 + 4*5^2 + 4*5^3 + 4*5^4 + 4*5^5 + 4*5^6 + 4*5^7 + 4*5^8 + 4*5^9 + 4*5^10 + 4*5^11 + 4*5^12 + 4*5^13 + 4*5^14 + 4*5^15 + 4*5^16 + 4*5^17 + 4*5^18 + 4*5^19 + O(5^20))*x + (1 + O(5^20)), 1]