# 8.1 행렬의 고유값 문제. 고유값과 고유벡터 구하기

### 행렬 $A$

A=matrix(QQ, 2, 2, [-5,2,2,-2]) print "A=" show(A)
 A= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} -5 & 2 \\ 2 & -2 \end{array}\right) A=

### 특성다항식 $D(t) = \det(A - t I)$

char=A.charpoly('t') show(char)
 \newcommand{\Bold}[1]{\mathbf{#1}}t^{2} + 7 t + 6

### 특성방정식 $\det(A - t I) = 0$ $\Rightarrow$ 고유값.

eigval=A.eigenvalues() show(eigval)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left[-1, -6\right]

### 고유값 $t_1 = -1$에 대응하는 행렬 $A$의 고유벡터. $\Rightarrow$ $(A + I)\mathbf{x} = \mathbf{0}$의 해공간.

T1 = A+identity_matrix(2) print "A + I =" show(T1) print "det(A + I)=", T1.det() show(T1.rref())
 A + I = \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} -4 & 2 \\ 2 & -1 \end{array}\right) det(A + I)= 0 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} 1 & -\frac{1}{2} \\ 0 & 0 \end{array}\right) A + I = det(A + I)= 0

### $(A + I)\mathbf{x} = \mathbf{0}$의 영공간(해공간) 찾기.

x,y = var('x,y') eq1 = -4*x + 2*y == 0 eq2 = 2*x - y == 0 r=solve([eq1,eq2],x,y ) show(eq1) show(eq2) show(r)
 \newcommand{\Bold}[1]{\mathbf{#1}}-4 \, x + 2 \, y = 0 \newcommand{\Bold}[1]{\mathbf{#1}}2 \, x - y = 0 \newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[x = \frac{1}{2} \, r_{1}, y = r_{1}\right]\right]

### 고유값 $t_2 = -6$에 대응하는 행렬 $A$의 고유벡터. $\Rightarrow$ $(A + 6I)\mathbf{x} = \mathbf{0}$의 해공간.

T2 = A+6*identity_matrix(2) print "A + 6I=" show(T2) print "det(A + 6I)=", T2.det() show(T2.rref())
 A + 6I= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} 1 & 2 \\ 2 & 4 \end{array}\right) det(A + 6I)= 0 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} 1 & 2 \\ 0 & 0 \end{array}\right) A + 6I= det(A + 6I)= 0

### $(A + 6I)\mathbf{x} = \mathbf{0}$의 영공간(해공간) 찾기.

x,y = var('x,y') eq1 = x + 2*y == 0 eq2 = 2*x + 4*y == 0 r=solve([eq1,eq2],x,y ) show(eq1) show(eq2) show(r)
 \newcommand{\Bold}[1]{\mathbf{#1}}x + 2 \, y = 0 \newcommand{\Bold}[1]{\mathbf{#1}}2 \, x + 4 \, y = 0 \newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[x = -2 \, r_{2}, y = r_{2}\right]\right]

### 고유값 $t_1 = -1$에 대응하는 행렬 $A$의 고유벡터.

x1,x2=A.eigenvectors_right() show(x1)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(-1, \left[\left(1,\,2\right)\right], 1\right)

### 고유값 $t_2 = -6$에 대응하는 행렬 $A$의 고유벡터.

show(x2)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(-6, \left[\left(1,\,-\frac{1}{2}\right)\right], 1\right)

### 행렬 $A$

A=matrix(QQ, 3, 3, [-2,2,-3,2,1,-6,-1,-2,0]) print "A=" show(A)
 A= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} -2 & 2 & -3 \\ 2 & 1 & -6 \\ -1 & -2 & 0 \end{array}\right) A=

### 특성다항식 $D(t) = \det(A - t I)$

char=A.charpoly('t') show(char)
 \newcommand{\Bold}[1]{\mathbf{#1}}t^{3} + t^{2} - 21 t - 45

### 특성방정식 $\det(A - t I) = 0$ $\Rightarrow$ 고유값.

eigval=A.eigenvalues() show(eigval)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left[5, -3, -3\right]

### 고유값 $t_1 = 5$에 대응하는 행렬 $A$의 고유벡터. $\Rightarrow$ $(A - 5I)\mathbf{x} = \mathbf{0}$의 해공간.

T1 = A-5*identity_matrix(3) print "A - 5I =" show(T1) print "det(A - 5I)=", T1.det()
 A - 5I = \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} -7 & 2 & -3 \\ 2 & -4 & -6 \\ -1 & -2 & -5 \end{array}\right) det(A - 5I)= 0 A - 5I = det(A - 5I)= 0

### $A - 5I$의 행 사다리꼴

E1=T1.echelon_form() show(E1)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} 1 & 0 & 1 \\ 0 & 1 & 2 \\ 0 & 0 & 0 \end{array}\right)

### $(A - 5I)\mathbf{x} = \mathbf{0}$의 영공간(해공간) 찾기.

x,y,z = var('x,y,z') eq1 = x + z == 0 eq2 = y + 2*z == 0 show(eq1) show(eq2) r=solve([eq1,eq2],x,y,z) show(r)
 \newcommand{\Bold}[1]{\mathbf{#1}}x + z = 0 \newcommand{\Bold}[1]{\mathbf{#1}}y + 2 \, z = 0 \newcommand{\Bold}[1]{\mathbf{#1}}\left[\left[x = -r_{3}, y = -2 \, r_{3}, z = r_{3}\right]\right]

### 고유값 $t_2 = t_3 = -3$에 대응하는 행렬 $A$의 고유벡터. $\Rightarrow$ $(A + 3I)\mathbf{x} = \mathbf{0}$의 해공간.

T2 = A+3*identity_matrix(3) print "A + 3I=" show(T2) print "det(A + 3I)=", T2.det()
 A + 3I= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} 1 & 2 & -3 \\ 2 & 4 & -6 \\ -1 & -2 & 3 \end{array}\right) det(A + 3I)= 0 A + 3I= det(A + 3I)= 0

### $A + 3I$의 행 사다리꼴

E2=T2.echelon_form() show(E2)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} 1 & 2 & -3 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{array}\right)

### $(A + 3I)\mathbf{x} = \mathbf{0}$의 영공간(해공간) 찾기.

var('x,y,z') eq = x +2*y - 3*z == 0 show(eq) p=solve([eq],z) show(p)
 \newcommand{\Bold}[1]{\mathbf{#1}}x + 2 \, y - 3 \, z = 0 \newcommand{\Bold}[1]{\mathbf{#1}}\left[z = \frac{1}{3} \, x + \frac{2}{3} \, y\right]

### 고유값 $t_1 = 5$에 대응하는 행렬 $A$의 고유벡터.

v1,v2=A.eigenvectors_right() show(v1)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(5, \left[\left(1,\,2,\,-1\right)\right], 1\right)

### 고유값 $t_2 = t_3 = -3$에 대응하는 행렬 $A$의 고유벡터.

show(v2)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(-3, \left[\left(1,\,0,\,\frac{1}{3}\right), \left(0,\,1,\,\frac{2}{3}\right)\right], 2\right)

### 행렬 $A$

A=matrix(QQ, 2, 2, [3,2,0,3]) print "A=" show(A)
 A= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} 3 & 2 \\ 0 & 3 \end{array}\right) A=

### 행렬 $A$의 고유값과 고유벡터, 대수적 다중도와 기하적 다중도.

v=A.eigenvectors_right() show(v)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left[\left(3, \left[\left(1,\,0\right)\right], 2\right)\right]