기초수학-실습

1980 days 전, sky 작성

plot(Piecewise([[(0,1),x^2],[(1,2),1],[(2,3),x^2-3]])) 
       
not (True or False) == (False and True) 
       
True
True
1 >= 1 
       
True
True
1 + i >= 2 - i 
       
(I + 1) >= (-I + 2)
(I + 1) >= (-I + 2)
((3/2) > 1) or (2/3 < 1) 
       
True
True
((3/2) > 1) ^^ (2/3 < 1) 
       
False
False
x > 1/2 
       
x > (1/2)
x > (1/2)
S=12 
       
       
12
12
sage: s=34 sage: s 
       
34
34
sage: t=7 sage: t=t+1 sage: t 
       
8
8
sage: t=7 sage: t=t/4.5 sage: t 
       
1.55555555555556
1.55555555555556
f(x)= x^2 + x + 1 f(123456789) 
       
15241578873647311
15241578873647311
       
x |--> x^2 + x + 1
x |--> x^2 + x + 1
f(x=120) 
       
14521
14521
sage: [6,28,496,8128] 
       
[6, 28, 496, 8128]
[6, 28, 496, 8128]
sage: [1,11..121] 
       
[1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121]
[1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121]
sage: [1,4,16,25..81] 
       
[1, 4, 16, 25, 34, 43, 52, 61, 70, 79]
[1, 4, 16, 25, 34, 43, 52, 61, 70, 79]
sage: [pi,4*pi..32] 
       
[pi, 4*pi, 7*pi, 10*pi]
[pi, 4*pi, 7*pi, 10*pi]
A = Set([2,3,3,3,2,1,8,6,21,7,3]) A 
       
{1, 2, 3, 21, 6, 7, 8}
{1, 2, 3, 21, 6, 7, 8}
sage: A.cardinality() 
       
7
7
sage: 8 in A 
       
True
True
sage: 21 in A 
       
True
True
sage: 124 in A 
       
False
False
sage: 8 in A, 211 in A 
       
(True, False)
(True, False)
sage: B = Set([8,6,17,-4,20, -2 ]) sage: B 
       
{17, 20, 6, 8, -4, -2}
{17, 20, 6, 8, -4, -2}
sage: A.intersection(B) 
       
{8, 6}
{8, 6}
sage: A.union(B) 
       
{1, 2, 3, 6, 7, 8, 17, 20, 21, -4, -2}
{1, 2, 3, 6, 7, 8, 17, 20, 21, -4, -2}
sage: A.difference(B) 
       
{1, 2, 3, 21, 7}
{1, 2, 3, 21, 7}
sage: B.difference(A) 
       
{17, 20, -4, -2}
{17, 20, -4, -2}
sage: A.symmetric_difference(B) 
       
{1, 2, 3, 7, 17, 20, 21, -4, -2}
{1, 2, 3, 7, 17, 20, 21, -4, -2}
sage: A = Set([1,2,3]); A 
       
{1, 2, 3}
{1, 2, 3}
sage: powA = A.subsets(); powA 
       
Subsets of {1, 2, 3}
Subsets of {1, 2, 3}
sage: pairsA = A.subsets(2); pairsA 
       
Subsets of {1, 2, 3} of size 2
Subsets of {1, 2, 3} of size 2
sage: [tan(0),tan(pi/4),tan(3*pi/4),tan(pi)] 
       
[0, 1, -1, 0]
[0, 1, -1, 0]
A = Set([3,6,9..18]); A 
       
{18, 3, 6, 9, 12, 15}
{18, 3, 6, 9, 12, 15}
sage: powA = A.subsets(); powA 
       
Subsets of {18, 3, 6, 9, 12, 15}
Subsets of {18, 3, 6, 9, 12, 15}
sage: powA.cardinality() 
       
64
64
[tan(x)for x in [0,pi/4..pi]] 
       
[0, 1, Infinity, -1, 0]
[0, 1, Infinity, -1, 0]
divmod(141,2) 
       
(70, 1)
(70, 1)
14 // 4 
       
3
3
14 & 3 
       
2
2
14 % 3 
       
2
2
10305.divides(123) 
       
False
False
5.divides(125) 
       
True
True
12.divisors() 
       
[1, 2, 3, 4, 6, 12]
[1, 2, 3, 4, 6, 12]
9000.divisors() 
       
[1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 18, 20, 24, 25, 30, 36, 40, 45, 50,
60, 72, 75, 90, 100, 120, 125, 150, 180, 200, 225, 250, 300, 360, 375,
450, 500, 600, 750, 900, 1000, 1125, 1500, 1800, 2250, 3000, 4500, 9000]
[1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 18, 20, 24, 25, 30, 36, 40, 45, 50, 60, 72, 75, 90, 100, 120, 125, 150, 180, 200, 225, 250, 300, 360, 375, 450, 500, 600, 750, 900, 1000, 1125, 1500, 1800, 2250, 3000, 4500, 9000]
(2^19-1).is_prime() 
       
True
True
(2^19-1).divisors() 
       
[1, 524287]
[1, 524287]
62.factor() 
       
2 * 31
2 * 31
factor(122) 
       
2 * 61
2 * 61
24.prime_divisors() 
       
[2, 3]
[2, 3]
gcd(14,63) 
       
7
7
gcd(184,693)#서로소# 
       
1
1
lcm(14,21) 
       
42
42
divmod(956,98) 
       
(9, 74)
(9, 74)
3.divides(234878) 
       
False
False
134.divisors() 
       
[1, 2, 67, 134]
[1, 2, 67, 134]
491.divisors() 
       
[1, 491]
[1, 491]
422.divisors() 
       
[1, 2, 211, 422]
[1, 2, 211, 422]
1002.divisors() 
       
[1, 2, 3, 6, 167, 334, 501, 1002]
[1, 2, 3, 6, 167, 334, 501, 1002]
491.is_prime() 
       
True
True
134.is_prime() 
       
False
False
491.is_prime() 
       
True
True
422.is_prime() 
       
False
False
[ a.is_prime() for a in [1, 2, 3, 6, 167, 334, 501, 1002]] 
       
[False, True, True, False, True, False, False, False]
[False, True, True, False, True, False, False, False]
gcd(2,5) 
       
1
1
gcd(4,10) 
       
2
2
gcd(18,51) 
       
3
3
lcm(2,5),lcm(4,10),lcm(18,51) 
       
(10, 20, 306)
(10, 20, 306)
(2*5),(4*10),(18*51) 
       
(10, 40, 918)
(10, 40, 918)
max(1,5,8) 
       
8
8
max(1,5,8, 9999999999999999999999999) 
       
9999999999999999999999999
9999999999999999999999999
min(1/2,sin(pi),cos(pi/2)) 
       
0
0
abs(-10) 
       
10
10
abs(4) 
       
4
4
plot (abs(x),(x, -3, 3))