# 8.4 고유기저. 대각화

### 행렬 $A$

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

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

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

### 고유값 $t_1 = 8$에 대응하는 행렬 $A$의 고유벡터 $\mathbf{x_1}$.

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

### 고유값 $t_2 = 2$에 대응하는 행렬 $A$의 고유벡터 $\mathbf{x_2}$.

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

### $\Rightarrow$ 고유값 $t_1 = 8$에 대응하는 정규직교 고유벡터 $\mathbf{u_1} = \frac{1}{|| \mathbf{x_1} ||}\mathbf{x_1}$.

D,X=A.eigenmatrix_right() u=X.column(0) u1=(1/u.norm())*u print "u1=" show(u1)
 u1= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\frac{1}{2} \, \sqrt{2},\,\frac{1}{2} \, \sqrt{2}\right) u1=

### 고유값 $t_2 = 2$에 대응하는 정규직교 고유벡터 $\mathbf{u_2} = \frac{1}{|| \mathbf{x_2} ||}\mathbf{x_2}$

u=X.column(1) u2=(1/u.norm())*u print "u2=" show(u2)
 u2= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\frac{1}{2} \, \sqrt{2},\,-\frac{1}{2} \, \sqrt{2}\right) u2=

### 행렬 $A$

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

### 행렬 $P$

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

### 역행렬 $P^{-1}$

invP=P.inverse() print "P^(-1)=" show(invP)
 P^(-1)= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} 4 & -3 \\ -1 & 1 \end{array}\right) P^(-1)=

### 유사행렬 $\hat{A} = P^{-1} A P$.

Ahat=invP*A*P show(Ahat)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} 3 & 0 \\ 0 & 2 \end{array}\right)

### 행렬 $A$의 고유값과 고유벡터.

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

### 유사행렬 $\hat{A}$의 고유값과 고유벡터. $\Rightarrow$ 행렬 $A$의 고유값과 일치.

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

### 행렬 $A$의 고유값 $t_1 = 3$에 대응하는 고유벡터 $\mathbf{x_1}$, 고유값 $t_2 = 2$에 대응하는 고유벡터 $\mathbf{x_2}$.

x1=vector([1,1]) print "x1=" show(x1) x2=vector([3,4]) print "x2=" show(x2)
 x1= \newcommand{\Bold}[1]{\mathbf{#1}}\left(1,\,1\right) x2= \newcommand{\Bold}[1]{\mathbf{#1}}\left(3,\,4\right) x1= x2=

### 유사 행렬 $\hat{A}$의 고유값 $t_1 = 3$에 대응하는 고유벡터. $\Rightarrow$ $\mathbf{y_1} = P^{-1} \mathbf{x_1}$

y1=invP*x1 print "y1=P^(-1)*x1=" show(y1)
 y1=P^(-1)*x1= \newcommand{\Bold}[1]{\mathbf{#1}}\left(1,\,0\right) y1=P^(-1)*x1=

### 유사 행렬 $\hat{A}$의 고유값 $t_2 = 2$에 대응하는 고유벡터. $\Rightarrow$ $\mathbf{y_2} = P^{-1} \mathbf{x_2}$

y2=invP*x2 print "y2=P^(-1)*x2=" show(y2)
 y2=P^(-1)*x2= \newcommand{\Bold}[1]{\mathbf{#1}}\left(0,\,1\right) y2=P^(-1)*x2=

### 행렬 $A$

A=matrix(QQ, 3, 3, [7.3, 0.2, -3.7, -11.5, 1.0, 5.5, 17.7, 1.8, -9.3]) AA=matrix(RDF, 3, 3, [7.3, 0.2, -3.7, -11.5, 1.0, 5.5, 17.7, 1.8, -9.3]) print "A=" show(AA)
 A= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} 7.3 & 0.2 & -3.7 \\ -11.5 & 1.0 & 5.5 \\ 17.7 & 1.8 & -9.3 \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} - 12 t

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

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

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

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

### 행렬 $A$의 고유값들이 주대각선의 원소인 대각행렬 $D$.

D,X=A.eigenmatrix_right() print "D=" show(D)
 D= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} 3 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & -4 \end{array}\right) D=

### (주의)반드시 대각행렬 $D$의 주대각선 순서에 맞춰서 대응하는 열벡터를 $X$에 배열한다.

print "X=" show(X)
 X= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} 1 & 1 & 1 \\ -3 & \frac{1}{2} & -1 \\ 1 & 2 & 3 \end{array}\right) X=

### 역행렬 $X^{-1}$.

invX=X.inverse() print "X^(-1)=" show(invX)
 X^(-1)= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} \frac{7}{10} & -\frac{1}{5} & -\frac{3}{10} \\ \frac{8}{5} & \frac{2}{5} & -\frac{2}{5} \\ -\frac{13}{10} & -\frac{1}{5} & \frac{7}{10} \end{array}\right) X^(-1)=

### 행렬 $A$의 유사행렬 $D$. $\Rightarrow$ $X^{-1} A X = D$ 확인.

Ahat=invX*A*X show(Ahat)
 \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} 3 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & -4 \end{array}\right)