In [1]:
RRing = Rings()
In [2]:
[method for method in dir(RRing) if method[0] is not r'_']
Out[2]:
In [3]:
RRing.axioms()
Out[3]:
In [4]:
RCommutRing = CommutativeRing( RR ) # a "base" ring for input is needed
In [5]:
RCommutRing.is_commutative()
Out[5]:
Abstract Algebra: Theory and Applications, Section on Rings has some useful examples:
In [6]:
ZZRing = ZZ()
RRRing = RR()
CCRing = CC()
QQRing = QQ() # Rational numbers
$\mathbb{Z}_n$, integers mod $n$:
In [7]:
Z_2Ring = Integers(2)
Z_16Ring = Integers(16)
Quadratic Field is the the field formed by combining the rationals with a solution to polynomial equation $x^2-n=0$, $\equiv \mathbb{Q}[\sqrt{n}]$
In [8]:
QuadField2Ring = QuadraticField(2)
In [9]:
[method for method in dir(ZZRing) if method[0] is not '_']
Out[9]:
In [10]:
ZZRing.rank()
Out[10]:
In [1]:
ZZ[I]
Out[1]:
In [3]:
ZZ[I].is_integral_domain()
Out[3]:
In [4]:
ZZ[I].zero()
Out[4]:
In [5]:
ZZ[I].one()
Out[5]:
In [11]:
ZZ[I].is_ring()
Out[11]:
For reading - cf. Sec. 3.4 Greatest Common Divisors, of Joseph Rotman's Advanced Modern Algebra
For the Sage Math exercises - cf. in Abstract Algebra - Theory and Applications by Thomas W. Judson, 17 Polynomials, 17.6 Sage
In [12]:
R.<x> = Integers(8)[]; R
Out[12]:
In [19]:
R1.<x> = PolynomialRing(ZZ.quo(8*ZZ)); R1
Out[19]:
In [20]:
R1 == R
Out[20]:
In [21]:
S.<y> = ZZ[]; S
Out[21]:
In [22]:
T.<z> = QQ[]; T
Out[22]:
In [23]:
R.is_finite()
Out[23]:
In [25]:
R.is_integral_domain()
Out[25]:
In [26]:
S.is_integral_domain()
Out[26]:
In [27]:
T.is_field()
Out[27]:
In [28]:
R.characteristic()
Out[28]:
In [29]:
T.characteristic()
Out[29]:
In [31]:
print(y in S)
x in S
Out[31]:
In [32]:
q = (3/2) + (5/4)*z^2
q in T
Out[32]:
In [34]:
print(3 in S)
r = 3
print( r.parent() )
s = 3*y^0
s.parent()
Out[34]:
Polynomials can be evaluated like they are functions
In [35]:
p = 3 + 5*x + 2*x^2
print( p.parent() )
p(1)
Out[35]:
In [36]:
[p(t) for t in Integers(8)]
Out[36]:
In [38]:
g = 4*x^2 + 4*x
[g(t) for t in Integers(8)]
Out[38]:
In [39]:
M.<s,t> = QQ[]; M
Out[39]:
In [40]:
R.<x> = QQ[]
p = 1/4*x^4 - x^3 + x^2 - x - 1/2
p.is_irreducible()
Out[40]:
In [41]:
p.factor()
Out[41]:
In [42]:
q = 2*x^5 + 5/2*x^4 + 3/4*x^3 - 25/24*x^2 - x - 1/2
q.is_irreducible()
Out[42]:
In [43]:
q.factor()
Out[43]:
In [51]:
F.<a> = FiniteField(5^2)
S.<y> = F[]
p = 2*y^5 + 2*y^4 + 4*y^3 + 2*y^2 + 3*y + 1
p.is_irreducible()
Out[51]:
In [52]:
p.factor()
Out[52]:
In [54]:
q = 3*y^4+2*y^3-y+4; print( q.is_irreducible() )
q.factor()
Out[54]:
In [55]:
r = y^4 + 2*y^3 + 3*y^2+4; r.factor()
Out[55]:
In [57]:
s = 3*y^4+2*y^3-y+3; s.factor()
Out[57]:
In [58]:
F.modulus()
Out[58]:
In [60]:
F.modulus().is_irreducible()
Out[60]:
If $F$ is a field, then every ideal of $F[x]$ is principal. cf. (http://abstract.ups.edu/aata/poly-sage.html)
In [61]:
W.<w> = QQ[]
r = -w^5 + 5*w^4 - 4*w^3 + 14*w^2 - 67*w + 17
s = 3*w^5 - 14*w^4 + 12*w^3 - 6*w^2 + w
S = W.ideal(r, s)
S
Out[61]:
In [62]:
(w^2)*r + (3*w-6)*s in S
Out[62]:
In [63]:
F = Integers(7)
R.<x> = F[]
p = x^5 + x + 4
p.is_irreducible()
Out[63]:
In [64]:
_.<x> = PolynomialRing(ZZ)
f = x^4 + 2*x^2 + 1
print( f.coefficients() )
f.coefficients(sparse=False)
Out[64]:
In [65]:
f.degree()
Out[65]:
In [66]:
print( f.derivative(x) )
print( f.derivative(x,x) )
f.derivative(x,2)
Out[66]:
cf. J. Rotman, Advanced Modern Algebra, Exercise 3.28
In [89]:
ZZ5_x_polys.<x> = PolynomialRing( Integers(5) )
In [92]:
( Integers(5)(1)*x**3-Integers(5)(7)*x+Integers(5)(6) ).gcd( Integers(5)(1)*x**2-Integers(5)(1)*x-Integers(5)(2) )
(x^3-7*x+6).gcd(x^2-x-2)
Out[92]:
In [95]:
print( (x^2-x-2).factor() )
(x^3-7*x+6).factor()
factor( x^3-7*x+6)
Out[95]:
In [93]:
print( (x+1)*(x+3) )
In [96]:
p0328 = x^2 - x - 2
q0328 = x^3 - 7*x+6
print( p0328.parent() )
q0328.parent()
Out[96]:
At this point, this helped to check what's going on: cf. Ring Z/nZ of integers modulo n
In [94]:
print( Integers(5).0 )
print( Integers(5)(0) + Integers(5)(3) )
print( Integers(5)(0) + Integers(5)(6) )
print( Integers(5)(0)*Integers(5)(2) )
print( Integers(5)(1)*Integers(5)(3) )
print( 0 )
print( 0 + 3 )
print( 0 + 6 )
print( 0 * 2 )
print( 1 * 3 )
cf. J. Rotman, Advanced Modern Algebra, Exercise 3.30
In [97]:
ZZ3_x_polys.<x> = PolynomialRing( Integers(3) )
In [98]:
f0330 = x^2 + 1
g0330 = x^3 + x + 1
In [99]:
f0330.gcd( g0330 )
Out[99]:
In [101]:
print( factor( f0330 ) )
factor( g0330 )
Out[101]:
In [ ]:
In [ ]:
In [11]:
%display latex
In [12]:
RingModule = Modules(Rings())
In [13]:
[method for method in dir(RingModule) if method[0] is not '_']
Out[13]:
In [14]:
RingModule.category_graph()
Out[14]:
In [15]:
RingModule.axioms()
Out[15]:
In [16]:
ZZmodule = Modules(ZZ)
In [17]:
ZZmodule.AdditiveInverse(), ZZmodule.AdditiveUnital(), ZZmodule.an_instance()
Out[17]:
In [18]:
ZZmodule.category_graph()
Out[18]:
cf. Chapter 7 Modules and Categories, 7.1 Modules of Rotman, Advanced Modern Algebra, pp. 423, Example 7.1
In [19]:
n = var('n',domain="integer")
RRmoduleVecSpace = VectorSpace(RR,3)
In [20]:
[method for method in dir(RRmoduleVecSpace) if method[0] is not '_']
Out[20]:
In [21]:
RRmoduleVecSpace.basis(), RRmoduleVecSpace.basis_matrix(), RRmoduleVecSpace.gens()
Out[21]:
In [22]:
RRmoduleVecSpace.gens_dict()
Out[22]:
In [ ]: