# 7.7 행렬식. Cramer의 법칙

### 행렬 $A$

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

### 소행렬 $A_{11}$과 그 행렬식 $M_{11} = \det A_{11}$.

A11=A[1:3,1:3] print "A11 =" show(A11) print "M11 = det(A11) =", A11.det()
 A11 = \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} 6 & 4 \\ 0 & 2 \end{array}\right) M11 = det(A11) = 12 A11 = M11 = det(A11) = 12

### 소행렬 $A_{12}$과 그 행렬식 $M_{12} = \det A_{12}$.

A12=A[1:3,0:3:2] print "A12 =" show(A12) print "M12 = det(A12) =", A12.det()
 A12 = \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} 2 & 4 \\ -1 & 2 \end{array}\right) M12 = det(A12) = 8 A12 = M12 = det(A12) = 8

### 소행렬 $A_{13}$과 그 행렬식 $M_{13} = \det A_{13}$.

A13=A[1:3,0:2] print "A13 =" show(A13) print "M13 = det(A13)=", A13.det()
 A13 = \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rr} 2 & 6 \\ -1 & 0 \end{array}\right) M13 = det(A13)= 6 A13 = M13 = det(A13)= 6

### 행렬식 $D = a_{11}M_{11} - a_{12}M_{12} + a_{13}M_{13}$.

D=A[0,0]*A11.det()-A[0,1]*A12.det()+A[0,2]*A13.det() print "det(A)=",D
 det(A)= -12 det(A)= -12

### 내장함수를 이용하여 행렬식 $\det A$ 계산.

print "det(A) =", A.det()
 det(A) = -12 det(A) = -12

### 행렬 $A$

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

### 주대각선 성분들의 곱 $\det A = -3 \times 4 \times 5 = -60$.  $\Rightarrow$  내장함수를 이용하여 행렬식 $\det A$ 계산한 것과 일치한다.

print "det(A) =", A.det()
 det(A) = -60 det(A) = -60

### 행렬 $A$

A=matrix(RDF,4,4,[[2,0,-4,6],[4,5,1,0],[0,2,6,-1],[-3,8,9,1]]) print "A =" show(A)
 A = \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr} 2.0 & 0.0 & -4.0 & 6.0 \\ 4.0 & 5.0 & 1.0 & 0.0 \\ 0.0 & 2.0 & 6.0 & -1.0 \\ -3.0 & 8.0 & 9.0 & 1.0 \end{array}\right) A =

### 내장함수를 이용하여 행렬식 $\det A$를 계산.

print "det(A) =", A.det()
 det(A) = 1134.0 det(A) = 1134.0

## Gauss 소거법과 행렬식의 관계

### $$R_4 + 1.5 R_1$$

 E1 = \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr} 2.0 & 0.0 & -4.0 & 6.0 \\ 0.0 & 5.0 & 9.0 & -12.0 \\ 0.0 & 2.0 & 6.0 & -1.0 \\ 0.0 & 8.0 & 3.0 & 10.0 \end{array}\right) E1 =

### 행렬식 $\det E_1$을 계산.

print "det(E1) =", A.det()
 det(E1) = 1134.0 det(E1) = 1134.0

### $$R_4 - 1.6 R_2$$

 E2= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr} 2.0 & 0.0 & -4.0 & 6.0 \\ 0.0 & 5.0 & 9.0 & -12.0 \\ 0.0 & 0.0 & 2.4 & 3.8 \\ 0.0 & 0.0 & -11.4 & 29.2 \end{array}\right) E2=

### 행렬식 $\det E_2$를 계산.

print "det(E2) =", A.det()
 det(E2) = 1134.0 det(E2) = 1134.0

### $$R_4 + 4.75R_3$$

A.add_multiple_of_row(3,2,4.75) print "E3=" show(A)
 E3= \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrrr} 2.0 & 0.0 & -4.0 & 6.0 \\ 0.0 & 5.0 & 9.0 & -12.0 \\ 0.0 & 0.0 & 2.4 & 3.8 \\ 0.0 & 0.0 & 0.0 & 47.25 \end{array}\right) E3=

### $\Rightarrow$  내장함수를 이용하여 행렬식 $\det A$를 계산한 것과 일치한다.

print "det(E3) =", A.det()
 det(E3) = 1134.0 det(E3) = 1134.0

### 에제 3번의 행렬 $A$  $\Rightarrow$  $\det A = -60$

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

### $$R_1 \leftrightarrow R_3$$

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

### 행렬식 $\det E$를 계산.

print "det(E) =", A.det()
 det(E) = 60 det(E) = 60

### 에제 3번의 행렬 $A$  $\Rightarrow$  $\det A = -60$

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

### $$(-3)R_1$$

A.rescale_row(0,-3) print "E =" show(A)
 E = \newcommand{\Bold}[1]{\mathbf{#1}}\left(\begin{array}{rrr} 9 & 0 & 0 \\ 6 & 4 & 0 \\ -1 & 2 & 5 \end{array}\right) E =

### 행렬식 $\det E$를 계산.

print "det(E) =", A.det()
 det(E) = 180 det(E) = 180