Ora2

176 days ago by bupe

#Polinomok: megalkotjuk a polinomgyűrűt: R.<x> = PolynomialRing(QQ) 
       
#utána dolgozunk benne (a fent megadott x jelöli a határozatlant) f = x^2 + 1 
       
g = x^2 - 1 
       
f*g 
       
x^4 - 1
x^4 - 1
factor(_) 
       
(x - 1) * (x + 1) * (x^2 + 1)
(x - 1) * (x + 1) * (x^2 + 1)
#Akár ideálokat is létrehozhatunk I = f * R 
       
       
Principal ideal (x^2 + 1) of Univariate Polynomial Ring in x over
Rational Field
Principal ideal (x^2 + 1) of Univariate Polynomial Ring in x over Rational Field
x^3+x in I 
       
True
True
K.<y> = R.quotient_by_principal_ideal(f) 
       
       
Univariate Quotient Polynomial Ring in y over Rational Field with
modulus x^2 + 1
Univariate Quotient Polynomial Ring in y over Rational Field with modulus x^2 + 1
y^2 
       
-1
-1
# Egy másik példa polinomgyűrűre R.<x> = PolynomialRing(GF(3)) R 
       
Univariate Polynomial Ring in x over Finite Field of size 3
Univariate Polynomial Ring in x over Finite Field of size 3
K.<t> = R.quotient_ring(x^2-2) K 
       
Univariate Quotient Polynomial Ring in t over Finite Field of size 3
with modulus x^2 + 1
Univariate Quotient Polynomial Ring in t over Finite Field of size 3 with modulus x^2 + 1
K.is_field() 
       
True
True
K.is_finite() 
       
True
True
K2.<t> = GF(9) K2.multiplication_table() 
       
*  a b c d e f g h i
 +------------------
a| a a a a a a a a a
b| a c d e f g h i b
c| a d e f g h i b c
d| a e f g h i b c d
e| a f g h i b c d e
f| a g h i b c d e f
g| a h i b c d e f g
h| a i b c d e f g h
i| a b c d e f g h i
*  a b c d e f g h i
 +------------------
a| a a a a a a a a a
b| a c d e f g h i b
c| a d e f g h i b c
d| a e f g h i b c d
e| a f g h i b c d e
f| a g h i b c d e f
g| a h i b c d e f g
h| a i b c d e f g h
i| a b c d e f g h i
K.<y> = NumberField(x^2+5) K 
       
Number Field in y with defining polynomial x^2 + 5
Number Field in y with defining polynomial x^2 + 5
R = ZZ[y] 
       
I = (6)* R I 
       
Fractional ideal (6)
Fractional ideal (6)
I.is_principal() 
       
True
True
I.factor() 
       
(Fractional ideal (2, y0 + 1))^2 * (Fractional ideal (3, y0 + 1)) *
(Fractional ideal (3, y0 + 2))
(Fractional ideal (2, y0 + 1))^2 * (Fractional ideal (3, y0 + 1)) * (Fractional ideal (3, y0 + 2))
#Vektorok, mátrixok M = Matrix([[1,2],[3,4],[5,6],[7,8]]) v = vector([-1, 7]) (M, v, M*v) 
       
(
[1 2]                           
[3 4]                           
[5 6]                           
[7 8], (-1, 7), (13, 25, 37, 49)
)
(
[1 2]                           
[3 4]                           
[5 6]                           
[7 8], (-1, 7), (13, 25, 37, 49)
)
Matrix(2,2,[1, 2, 5, 6]).inverse() 
       
[-3/2  1/2]
[ 5/4 -1/4]
[-3/2  1/2]
[ 5/4 -1/4]
Matrix(2, range(10, 14)) 
       
[10 11]
[12 13]
[10 11]
[12 13]
M = Matrix(2, 2, [a, b, c, d]) 
       
Traceback (click to the left of this block for traceback)
...
NameError: name 'a' is not defined
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_68.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("TSA9IE1hdHJpeCgyLCAyLCBbYSwgYiwgYywgZF0p"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpeE84oS/___code___.py", line 3, in <module>
    exec compile(u'M = Matrix(_sage_const_2 , _sage_const_2 , [a, b, c, d])
  File "", line 1, in <module>
    
NameError: name 'a' is not defined
M = Matrix(SR, 2, var('a, b, c, d')) 
       
M.inverse() 
       
[-b*c/((b*c/a - d)*a^2) + 1/a            b/((b*c/a - d)*a)]
[           c/((b*c/a - d)*a)               -1/(b*c/a - d)]
[-b*c/((b*c/a - d)*a^2) + 1/a            b/((b*c/a - d)*a)]
[           c/((b*c/a - d)*a)               -1/(b*c/a - d)]
M.det() 
       
a*d - b*c
a*d - b*c
M.charpoly() 
       
x^2 + (-a - d)*x + a*d - b*c
x^2 + (-a - d)*x + a*d - b*c
M = Matrix(ZZ, 2, [0, 1, 2, 0]) M 
       
[0 1]
[2 0]
[0 1]
[2 0]
M.charpoly() 
       
x^2 - 2
x^2 - 2
_.factor() 
       
x^2 - 2
x^2 - 2
hilbert = Matrix(5, 5, [[1/(i+j-1) for i in [1..5]] for j in [1..5]]) hilbert 
       
[  1 1/2 1/3 1/4 1/5]
[1/2 1/3 1/4 1/5 1/6]
[1/3 1/4 1/5 1/6 1/7]
[1/4 1/5 1/6 1/7 1/8]
[1/5 1/6 1/7 1/8 1/9]
[  1 1/2 1/3 1/4 1/5]
[1/2 1/3 1/4 1/5 1/6]
[1/3 1/4 1/5 1/6 1/7]
[1/4 1/5 1/6 1/7 1/8]
[1/5 1/6 1/7 1/8 1/9]
#csoportok G = SymmetricGroup(4) G 
       
Symmetric group of order 4! as a permutation group
Symmetric group of order 4! as a permutation group
show(G.cayley_graph()) 
       
G.order() 
       
24
24
G.is_abelian() 
       
False
False
G.center() 
       
Subgroup of (Symmetric group of order 4! as a permutation group)
generated by [()]
Subgroup of (Symmetric group of order 4! as a permutation group) generated by [()]
G.subgroups() 
       
[Permutation Group with generators [()], Permutation Group with
generators [(1,2)(3,4)], Permutation Group with generators [(1,3)(2,4)],
Permutation Group with generators [(1,4)(2,3)], Permutation Group with
generators [(3,4)], Permutation Group with generators [(2,3)],
Permutation Group with generators [(2,4)], Permutation Group with
generators [(1,2)], Permutation Group with generators [(1,3)],
Permutation Group with generators [(1,4)], Permutation Group with
generators [(2,4,3)], Permutation Group with generators [(1,2,3)],
Permutation Group with generators [(1,4,2)], Permutation Group with
generators [(1,3,4)], Permutation Group with generators [(1,3)(2,4),
(1,4)(2,3)], Permutation Group with generators [(3,4), (1,2)(3,4)],
Permutation Group with generators [(2,3), (1,4)(2,3)], Permutation Group
with generators [(2,4), (1,3)(2,4)], Permutation Group with generators
[(1,2)(3,4), (1,3,2,4)], Permutation Group with generators [(1,3)(2,4),
(1,4,3,2)], Permutation Group with generators [(1,2,4,3), (1,4)(2,3)],
Permutation Group with generators [(3,4), (2,4,3)], Permutation Group
with generators [(3,4), (1,3,4)], Permutation Group with generators
[(1,2), (1,2,3)], Permutation Group with generators [(1,2), (1,4,2)],
Permutation Group with generators [(1,2), (1,3)(2,4), (1,4)(2,3)],
Permutation Group with generators [(1,2)(3,4), (1,3)(2,4), (1,4)],
Permutation Group with generators [(1,2)(3,4), (1,3), (1,4)(2,3)],
Permutation Group with generators [(2,4,3), (1,3)(2,4), (1,4)(2,3)],
Permutation Group with generators [(2,4,3), (1,2), (1,3)(2,4),
(1,4)(2,3)]]
[Permutation Group with generators [()], Permutation Group with generators [(1,2)(3,4)], Permutation Group with generators [(1,3)(2,4)], Permutation Group with generators [(1,4)(2,3)], Permutation Group with generators [(3,4)], Permutation Group with generators [(2,3)], Permutation Group with generators [(2,4)], Permutation Group with generators [(1,2)], Permutation Group with generators [(1,3)], Permutation Group with generators [(1,4)], Permutation Group with generators [(2,4,3)], Permutation Group with generators [(1,2,3)], Permutation Group with generators [(1,4,2)], Permutation Group with generators [(1,3,4)], Permutation Group with generators [(1,3)(2,4), (1,4)(2,3)], Permutation Group with generators [(3,4), (1,2)(3,4)], Permutation Group with generators [(2,3), (1,4)(2,3)], Permutation Group with generators [(2,4), (1,3)(2,4)], Permutation Group with generators [(1,2)(3,4), (1,3,2,4)], Permutation Group with generators [(1,3)(2,4), (1,4,3,2)], Permutation Group with generators [(1,2,4,3), (1,4)(2,3)], Permutation Group with generators [(3,4), (2,4,3)], Permutation Group with generators [(3,4), (1,3,4)], Permutation Group with generators [(1,2), (1,2,3)], Permutation Group with generators [(1,2), (1,4,2)], Permutation Group with generators [(1,2), (1,3)(2,4), (1,4)(2,3)], Permutation Group with generators [(1,2)(3,4), (1,3)(2,4), (1,4)], Permutation Group with generators [(1,2)(3,4), (1,3), (1,4)(2,3)], Permutation Group with generators [(2,4,3), (1,3)(2,4), (1,4)(2,3)], Permutation Group with generators [(2,4,3), (1,2), (1,3)(2,4), (1,4)(2,3)]]
(1, 2, 3) in G 
       
True
True
H = G.subgroup([G((1,2,3)), G((1,2))]) H 
       
Subgroup of (Symmetric group of order 4! as a permutation group)
generated by [(1,2), (1,2,3)]
Subgroup of (Symmetric group of order 4! as a permutation group) generated by [(1,2), (1,2,3)]
H.order() 
       
6
6
H.is_normal() 
       
False
False
g = G((1,2)) g 
       
(1,2)
(1,2)
G = DihedralGroup(4); G 
       
Dihedral group of order 8 as a permutation group
Dihedral group of order 8 as a permutation group
for g in G: print([g, order(g)]) 
       
[(), 1]
[(2,4), 2]
[(1,2)(3,4), 2]
[(1,2,3,4), 4]
[(1,3), 2]
[(1,3)(2,4), 2]
[(1,4,3,2), 4]
[(1,4)(2,3), 2]
[(), 1]
[(2,4), 2]
[(1,2)(3,4), 2]
[(1,2,3,4), 4]
[(1,3), 2]
[(1,3)(2,4), 2]
[(1,4,3,2), 4]
[(1,4)(2,3), 2]
#Feladat: keressük meg S4 normálosztóit, illetve D4 konjugáltosztályait. 
       
#Gráfok #éllistával d = {0: [1,4,5], 1: [2,6], 2: [3,7], 3: [4,8], 4: [9], \ 5: [7, 8], 6: [8,9], 7: [9]} G = Graph(d); G 
       
Graph on 10 vertices
Graph on 10 vertices
G.show() 
       
#Rajzoljuk ki a következő gráfot: csúcsai az {1, 2, 3, 4, 5} kételemű részei, #élek pedig a diszjunkt csúcsok közt mennek. 
       
#Plotok plot(sin(x), (x, -5, 5)) 
       
a = animate([circle((i,i), 1-1/(i+1), hue=i/10) for i in srange(0,2,0.2)], xmin=0,ymin=0,xmax=2,ymax=2,figsize=[2,2]) 
       
a.show() 
       
var('x') x0 = 0 f = sin(x)*e^(-x) p = plot(f,-1,5, thickness=2) dot = point((x0,f(x=x0)),pointsize=80,rgbcolor=(1,0,0)) @interact def _(order=(1..12)): ft = f.taylor(x,x0,order) pt = plot(ft,-1, 5, color='green', thickness=2) html('$f(x)\;=\;%s$'%latex(f)) html('$\hat{f}(x;%s)\;=\;%s+\mathcal{O}(x^{%s})$'%(x0,latex(ft),order+1)) show(dot + p + pt, ymin = -.5, ymax = 1) 
       
order 

Click to the left again to hide and once more to show the dynamic interactive window