# 기초수학실습 1월 14일의 흔적

## 2399 days 전, whwnqjq119 작성

def f(s, braces=True): t = ', '.join(sorted(list(s))) if braces: return '{' + t + '}' return t def g(s): return set(str(s).replace(',',' ').split()) @interact def _(X='1,2,3,a', Y='2,a,3,4,apple', Z='a,b,10,apple'): S = [g(X), g(Y), g(Z)] X,Y,Z = S XY = X & Y XZ = X & Z YZ = Y & Z XYZ = XY & Z html('<center>') html("$X \cap Y$ = %s"%f(XY)) html("$X \cap Z$ = %s"%f(XZ)) html("$Y \cap Z$ = %s"%f(YZ)) html("$X \cap Y \cap Z$ = %s"%f(XYZ)) html('</center>') centers = [(cos(n*2*pi/3), sin(n*2*pi/3)) for n in [0,1,2]] scale = 1.7 clr = ['yellow', 'blue', 'green'] G = Graphics() for i in range(len(S)): G += circle(centers[i], scale, rgbcolor=clr[i], fill=True, alpha=0.3) for i in range(len(S)): G += circle(centers[i], scale, rgbcolor='black') # Plot what is in one but neither other for i in range(len(S)): Z = set(S[i]) for j in range(1,len(S)): Z = Z.difference(S[(i+j)%3]) G += text(f(Z,braces=False), (1.5*centers[i][0],1.7*centers[i][1]), rgbcolor='black') # Plot pairs of intersections for i in range(len(S)): Z = (set(S[i]) & S[(i+1)%3]) - set(XYZ) C = (1.3*cos(i*2*pi/3 + pi/3), 1.3*sin(i*2*pi/3 + pi/3)) G += text(f(Z,braces=False), C, rgbcolor='black') # Plot intersection of all three G += text(f(XYZ,braces=False), (0,0), rgbcolor='black') # Show it G.show(aspect_ratio=1, axes=False)

 X Y Z

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

x,y = var("x y") f(x,y) = x^2 - y^2 p = plot3d(f(x,y), (x,-10,10), (y,-10,10)) p.show()
 Sleeping...
[-9, -7..30]
 [-9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29] [-9, -7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]
[-18, -15..100]
 [-18, -15, -12, -9, -6, -3, 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99] [-18, -15, -12, -9, -6, -3, 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99]
[a.is_prime() for a in [1..100]]
 [False, True, True, False, True, False, True, False, False, False, True, False, True, False, False, False, True, False, True, False, False, False, True, False, False, False, False, False, True, False, True, False, False, False, False, False, True, False, False, False, True, False, True, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, True, False, False, False, False, False, True, False, False, False, True, False, True, False, False, False, False, False, True, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, False, False, True, False, False, False] [False, True, True, False, True, False, True, False, False, False, True, False, True, False, False, False, True, False, True, False, False, False, True, False, False, False, False, False, True, False, True, False, False, False, False, False, True, False, False, False, True, False, True, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, True, False, True, False, False, False, False, False, True, False, False, False, True, False, True, False, False, False, False, False, True, False, False, False, True, False, False, False, False, False, True, False, False, False, False, False, False, False, True, False, False, False]
b=[] for a in [1..100]: if a.is_prime(): b.append(a) print b
 [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97] [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
P(x)=(x-2)^3*(x^2-4*x+3)*2 P(x)
 2*(x^2 - 4*x + 3)*(x - 2)^3 2*(x^2 - 4*x + 3)*(x - 2)^3
expand(P(x))
 2*x^5 - 20*x^4 + 78*x^3 - 148*x^2 + 136*x - 48 2*x^5 - 20*x^4 + 78*x^3 - 148*x^2 + 136*x - 48
show(expand(P(x)))
 \newcommand{\Bold}[1]{\mathbf{#1}}2 \, x^{5} - 20 \, x^{4} + 78 \, x^{3} - 148 \, x^{2} + 136 \, x - 48
factor(P(x))
 2*(x - 1)*(x - 2)^3*(x - 3) 2*(x - 1)*(x - 2)^3*(x - 3)
show(factor(P(x)))
 \newcommand{\Bold}[1]{\mathbf{#1}}2 \, {\left(x - 1\right)} {\left(x - 2\right)}^{3} {\left(x - 3\right)}
(P(x)/(x-1))
 2*(x^2 - 4*x + 3)*(x - 2)^3/(x - 1) 2*(x^2 - 4*x + 3)*(x - 2)^3/(x - 1)
show((P(x)/(x-1)))
 \newcommand{\Bold}[1]{\mathbf{#1}}\frac{2 \, {\left(x^{2} - 4 \, x + 3\right)} {\left(x - 2\right)}^{3}}{x - 1}
(P(x)/(x-1)).simplify_full()
 2*x^4 - 18*x^3 + 60*x^2 - 88*x + 48 2*x^4 - 18*x^3 + 60*x^2 - 88*x + 48
W.<x>=QQ[] show(W(P(x)).quo_rem(x-5))
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(2 x^{4} - 10 x^{3} + 28 x^{2} - 8 x + 96, 432\right)
sage: f(x) = sin(x) sage: p = plot(f(x), (x, -pi/2, pi/2)) sage: p.show()
sage: p = plot(f(x), (x,-pi/2, pi/2), axes_labels=['x','sin(x)'], color='cyan') sage: p.show()
var('x,y') solve( [3*x - y == 2, -2*x -y == 1 ], x,y)
 [[x == (1/5), y == (-7/5)]] [[x == (1/5), y == (-7/5)]]
solve( [ 2*x + y == -1 , -4*x - 2*y == 2],x,y)
 [[x == -1/2*r1 - 1/2, y == r1]] [[x == -1/2*r1 - 1/2, y == r1]]
solve( [ 2*x - y == -1 , 2*x - y == 2],x,y)
 [] []
var('z') solve([ 2*x + 3*y + 5*z == 1, 4*x + 6*y + 10*z == 2, 6*x + 9*y + 15*z == 3], x,y,z)
 [[x == -5/2*r2 - 3/2*r3 + 1/2, y == r3, z == r2]] [[x == -5/2*r2 - 3/2*r3 + 1/2, y == r3, z == r2]]
var('x') solve((x^3-x == 7*x^2-7), x)
 [x == 7, x == -1, x == 1] [x == 7, x == -1, x == 1]
var('t') solve(abs(t-7)>=3,t)
 #0: solve_rat_ineq(ineq=abs(t-7) >= 3) [[t == 10], [t == 4], [t < 4], [10 < t]] #0: solve_rat_ineq(ineq=abs(t-7) >= 3) [[t == 10], [t == 4], [t < 4], [10 < t]]
var('x,y') solve([2*x+y==17,x-3*y==-16],x,y)
 [[x == 5, y == 7]] [[x == 5, y == 7]]
sage: f(x) = sin(x) sage: p = plot(f(x), (x, -pi/2, pi/2)) sage: p.show()
p = plot(f(x), (x,-pi/2, pi/2), axes_labels=['x','sin(x)'], color='purple') p.show()
p=plot(sin(pi*x-pi), (x,-1,1), thickness=3, color='red') q=plot(cos(pi*x-pi), (x,-1,1), thickness=3, color='blue') p+q
plot(cos(pi*x-pi), (x,-1,1), thickness=3, color='blue')
plot(1/x,(x,-1,1), ymin=-10,ymax=10,xmax=1,xmin=-1)
P(x)=2*x^3+3*x^2-5*x-6 solve(P(x)==0, x)
 [x == -2, x == -1, x == (3/2)] [x == -2, x == -1, x == (3/2)]
plot(P(x), (x, -4, 4), ymax=20, ymin=-20)
P(x)=4*x^4++4*x^3-9*x^2-x+2 solve(P(x)==0, x)
 [x == (1/2), x == -2, x == 1, x == (-1/2)] [x == (1/2), x == -2, x == 1, x == (-1/2)]
plot(P(x), (x, -3, 3), ymax=20, ymin=-20)
f(x)=2/(x-5) plot(f(x), (x, 2, 7), ymax=10, ymin=-10)
f(x)=-4/((x-4)^2) plot(f(x), (x, 2, 7), ymax=10, ymin=-20)
f(x)=(2*x^2+1)/(x^2-4*x+3) plot(f(x), (x, -2, 6), ymax=20, ymin=-20)
f(x)=(2*x^2-1)/(x^2+1) plot(f(x), (x, -6, 6), ymax=3)+plot(2, (x, -6, 6), color='red')
sage: x,y = var("x y") sage: f(x,y) = x^2 - y^2 sage: p = plot3d(f(x,y), (x,-10,10), (y,-10,10)) sage: p.show()
 Sleeping...