1+1
13/5
13/5.n()
sin(1), sqrt(2)
sin(1.0), sqrt(2).n()
sin(pi/3)
_.n(1000)
111^111
13//5, 13%5
(3+3*i)^4, (sqrt(3)+i)^6
expand(_[1])
l = [1, 3, 2, 4]
l[1:2]
l = range(5); l
l[1], l[-1], l[:2], l[2:], l[3:1], l[0:-1], l[0:-1:2]
L = [factor(n) for n in range(10000, 10025)]
print L
P = [n for n in range(10000,10100) if is_prime(n)]
P
3==4
3<>4, 3!=4
3<4
f(x)=x^3
f(5)
var('c')
f(c)
a=f(c^2-3)
expand(a)
a=3
a=a+1
a=a^2
a
a="ez egy szöveg"
a
print a
diff(x^2*exp(x),x)
diff(x^2*exp(x),x,10)
integral(9*x^2*exp(3*x^3), x)
diff(y^2*exp(y),y)
var('y')
diff(y^2*exp(y),y)
solve([x+y==3, x-y-4], x, y)
var('x y p q')
eq1 = p+q==5
eq2 = p*x+q*y==-5
eq3 = p*x^2+q*y^2==10
solve([eq1,eq2,eq3],q,x,y)
solve(cos(x)==sin(x), x)
find_root(cos(x)==sin(x), 0, 1)
limit(arctan(-x)+exp(-x)*x^1000, x=oo)
a = 11
if a%2 == 0:
print "páros"
else:
print "páratlan"
f(x,y) = x^3*exp(x^2)*y^3
f.diff(y)
f.integral(x)
def lnko(a,b):
if b==0:
return abs(a)
else:
return lnko(b,a%b)
lnko(1111,1111111111)
Szinek = ["Treff", "Karo", "Kor", "Pikk"]
Ertekek = [2, 3, 4, 5, 6, 7, 8, 9, 10, "Bubi", "Dama", "Kiraly", "Asz"]
Kartyak = cartesian_product([Szinek, Ertekek])
Kartyak.random_element()
Kartyak.cardinality()
Set([Kartyak.random_element(), Kartyak.random_element()])
Kezek = Subsets(Kartyak, 5)
Kezek.random_element()
Kezek.cardinality()
binomial(52,5)
def par_e(kez):
return len(set(ertek for (szin, ertek) in kez)) == 4
kez = Kezek.random_element(); kez
par_e(kez)
n=2
n.is_unit()
type(n)
polinomQ.<q> = PolynomialRing(QQ)
polinomR.<x> = PolynomialRing(RR)
polinomC.<z> = PolynomialRing(CC)
factor(q^4+2*q^2+2)
factor(x^4+2*x^2+2)
factor(z^4+2*z^2+2)
factor(x^2-2)
gcd(q^4-3*q^3+2*q^2-q+1,q^2-1)
(q^4-3*q^3+2*q^2-q+1)//(q^2-1)
(q^4-3*q^3+2*q^2-q+1)%(q^2-1)
(q^2-1)*(q^2 - 3*q + 3)-4*q + 4
p = q^4-3*q^3+2*q^2-q+1
p.is_irreducible()
p.xgcd(q^2-1)
-1/4*p+(1/4*q^2 - 3/4*q + 3/4)*(q^2-1)
A = Matrix([[1,2,3],[3,2,1],[1,1,1]]); A
A.LU()
A.rank()
A.nullity()
A.left_kernel() # bal nulltér: xA=0
A.right_kernel() # jobb nulltér: Ax=0
A.row_space()
A.echelon_form()
A.column_space()
B = A.transpose()
B.echelon_form()
B.rref()
v = vector([1,1,-4])
A, v*A, A*v
w=vector([3,5,2])
A.solve_right(w)
A.solve_left(w)
B=A.change_ring(GF(2))
B.echelon_form()
B.base_ring()
plot(cos, (-5,5))
plot([cos,sin], (-5,5), aspect_ratio=1)
parametric_plot((cos(x),sin(x)^3),(x,0,2*pi),color='red')
var('x')
p = plot(2*x^4-2*x^3+3*x^2-3*x+4, (x,-1,1), color = 'cyan', thickness=3)
p += plot(2*x^4, (x,-1,1), color = 'magenta', thickness=3)
p.show()