| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 |
Tags
- DP
- Stack
- isalnum()
- 그래프 탐색
- 프로그래머스
- Recommendation
- 코테
- Knowledge graph
- 동적 프로그래밍
- Algorithm
- kg
- 우선순위 큐
- bfs
- Python
- isalpha()
- 그래프
- Dynamic Programming
- 정렬
- isnumeric()
- 백준
- Deque
- 추천시스템
- 알고리즘
- find()
- LSTM
- isdigit()
- 파이썬
- knowledge
- explainable recommendation
- 자료구조
Archives
- Today
- Total
데린이 고인물되기
1. 행렬과 행렬식 본문
반응형
1강 행렬과 행렬식
연립 일차 방정식
(1) 행렬의 표현
- 예를 들어, $ \begin{cases} x + 2y = 5 \\[1em] 2x + 3y = 8 \end{cases} $ 를
- $ \begin{pmatrix} 1&2&5 \\[1em] 2&3&8\end{pmatrix} $로 표현 $ \Rightarrow $ 가우스 조던 소거법으로 품
- $ \begin{pmatrix} 1&2&5 \\[1em] 2&3&8\end{pmatrix} $ : 첨가행렬
- $ \begin{pmatrix} 1&2 \\[1em] 2&3\end{pmatrix} \begin{pmatrix} x \\[1em] y \end{pmatrix} = \begin{pmatrix} 5 \\[1em] 8 \end{pmatrix} $로 표현 $ \Rightarrow $ 역행렬 이용해서 품
- $ \begin{pmatrix} 1&2 \\[1em] 2&3 \end{pmatrix} $ : 계수행렬 , $ \begin{pmatrix} 5 \\[1em] 8 \end{pmatrix} $ : 상수행렬
- $ \begin{pmatrix} 1&2&5 \\[1em] 2&3&8\end{pmatrix} $로 표현 $ \Rightarrow $ 가우스 조던 소거법으로 품
(2) 가우스 조던 소거법
- 다음 세 가지의 기본 행 연산을 통해 연립일차방정식의 첨가행렬을 기약 행 사다리꼴로 변환하여 해를 구함
- 한 행을 상수배한다.
- 한 행을 상수배하여 다른 행에 더한다
- 두 행을 맞바꾼다.
- ex.
- $ \begin{cases} x + 2y = 5 \\[1em] 2x + 3y = 8 \end{cases} \xrightarrow{\text{첨가행렬로}} \begin{pmatrix} 1&2&5 \\[1em] 2&3&8\end{pmatrix} \xrightarrow[R_2 - 2R_1]{2R_1 = \begin{pmatrix} 2&4&10 \end{pmatrix}} \begin{pmatrix} 1&2&5 \\[1em] 0&-1&-2 \end{pmatrix} \xrightarrow{-R_2} \begin{pmatrix} 1&2&5 \\[1em] 0&1&2 \end{pmatrix} : \text{행 사다리꼴} \\[1em] \xrightarrow{R_1 - 2R_2} \begin{pmatrix} 1&0&1 \\[1em] 0&1&2 \end{pmatrix} : \text{기약 행 사다리꼴} \xrightarrow{\text{연립일차방정식으로}} \begin{cases} x = 1 \\[1em] y = 2 \end{cases} $
- ex. 부정형인 경우 : 임의의 상수를 잡아서 해를 구함 $ \Rightarrow $ 일반해
- $ \begin{cases} y+z = 1 \\[1em] 2x + y + 3z = 3 \end{cases} \rightarrow \begin{pmatrix} 0&1&1&1 \\[1em] 2&1&3&3 \end{pmatrix}\rightarrow \begin{pmatrix} 0&1&1&1 \\[1em] 1&1/2&3/2&3/2 \end{pmatrix} \rightarrow \begin{pmatrix} 0&1&1&1 \\[1em] 1&0&1&1 \end{pmatrix} \\[1em] \rightarrow \begin{pmatrix} 1&0&1&1 \\[1em] 0&1&1&1 \end{pmatrix} \Rightarrow \begin{cases} x+z = 1 \\[1em] y+z = 1 \end{cases} \xrightarrow{\text{t = 임의의 상수}} \begin{cases} z = t \\[1em] x = 1-t \\[1em] y = 1-t \end{cases} : \text{일반해} $
- 가우스 조던 소거법은 손으로 풀면 시간이 오래 걸리지만, 컴퓨터를 이용해서 알고리즘을 짜줄 때는 유용하게 활용됨.
(3) 역행렬 이용
- 연립일차방정식 $ Ax = B $ 에서 $ A $의 역행렬 $ A^{-1} $이 존재할 때, $ x = A^{-1}B $로 해를 구할 수 있음
- ex. $ \begin{pmatrix} 1&2 \\[1em] 2&3 \end{pmatrix}\begin{pmatrix} x \\[1em] y \end{pmatrix} = \begin{pmatrix} 5 \\[1em] 8 \end{pmatrix} \Leftrightarrow \begin{pmatrix} x \\[1em] y \end{pmatrix} = \begin{pmatrix} 1&2 \\[1em] 2&3 \end{pmatrix}^{-1}\begin{pmatrix} 5 \\[1em] 8 \end{pmatrix} $
행렬식
(1) 행렬식이란?
- 정사각행렬 $ A $를 하나의 수로써 대응시키는 특별한 함수. $ det(A) = |A| $
이때 $ A $가 $ m\times n 일때,$- $ 0 \times 0 \rightarrow det() = 0 $
- $ 1 \times 1 \rightarrow det(A) = a $
- $ 2 \times 2 \rightarrow det(A) = det\begin{pmatrix} a_{11}&a_{12} \\[1em] a_{21}&a_{22} \end{pmatrix} = a_{11}a_{22} - a_{12}a_{21} $
- ex. $ A = \begin{pmatrix} 1&2 \\[1em] 3&4 \end{pmatrix} \Rightarrow det(A) = |A| = 1\times 4 - 2\times 3 = -2 $ : 행렬 $ A $를 하나의 수로 대응시킴
- $ 3 \times 3 \rightarrow det\begin{pmatrix} a_{11}&a_{12}&a_{13} \\[1em] a_{21}&a_{22}&a_{23} \\[1em] a_{31}&a_{32}&a_{33} \end{pmatrix} \\[1em] = a_{11}M_{11} - a_{12}M_{12} + a_{13}M_{13} \\[1em] = a_{11} \begin{vmatrix} a_{22} & a_{23} \\[1em] a_{32} & a_{33} \end{vmatrix} - a_{12} \begin{vmatrix} a_{21} & a_{23} \\[1em] a_{31} & a_{33} \end{vmatrix} + a_{13} \begin{vmatrix} a_{21} & a_{22} \\[1em] a_{31} & a_{32} \end{vmatrix} \\[1em] = a_{11}a_{22}a_{33} + a_{12}a_{23}a_{31} + a_{13}a_{21}a_{32} - a_{13}a_{22}a_{31} - a_{12}a_{21}a_{33} - a_{11}a_{23}a_{32}$
- ex. $ A = \begin{pmatrix} 1&2&3 \\[1em] 4&5&6 \\[1em] 7&8&9 \end{pmatrix} \Rightarrow det(A) = 1\begin{vmatrix} 5&6 \\[1em] 8&9 \end{vmatrix} - 2\begin{vmatrix} 4&6 \\[1em] 7&9 \end{vmatrix} + 3\begin{vmatrix} 4&5 \\[1em] 7&8 \end{vmatrix} \\[1em]
= 1(5\times9-6\times8) - 2(4\times9-6\times7) + 3(4\times8-5\times7) = -3 $
- ex. $ A = \begin{pmatrix} 1&2&3 \\[1em] 4&5&6 \\[1em] 7&8&9 \end{pmatrix} \Rightarrow det(A) = 1\begin{vmatrix} 5&6 \\[1em] 8&9 \end{vmatrix} - 2\begin{vmatrix} 4&6 \\[1em] 7&9 \end{vmatrix} + 3\begin{vmatrix} 4&5 \\[1em] 7&8 \end{vmatrix} \\[1em]
- $ 4 \times 4 \rightarrow det(A) = a_{11}M_{11} - a_{12}M_{12} + a_{13}M_{13} - a_{14}M_{14} $
* 사루스 법칙(전개) : 머리 안쓰고 아무생각없이 행렬식 구하는 법
- $ \begin{pmatrix} a_{11}&a_{12}&a_{13} \\[1em] a_{21}&a_{22}&a_{23} \\[1em]
a_{31}&a_{32}&a_{33} \end{pmatrix} \xrightarrow[복붙하기]{\text{제일 왼쪽 두 컬럼을 가장 오른쪽에}} \begin{pmatrix} a_{11}&a_{12}&a_{13}&a_{11}&a_{12} \\[1em] a_{21}&a_{22}&a_{23}&a_{21}&a_{22} \\[1em]
a_{31}&a_{32}&a_{33}&a_{31}&a_{32} \end{pmatrix} \\[1em] \Rightarrow$
(2) 역행렬
- 행렬식이 0이면 역행렬이 존재하지 않음. 즉, 행렬식이 0이 아닌 정사각행렬 $ A $의 역행렬 $ A^{-1} $은 $$ A^{-1} = \frac{1}{det(A)} \begin{pmatrix} C_{11} & C_{21} & \cdots \\[1em] C_{12} & C_{22} & \cdots \\[1em] \vdots & \vdots & \ddots \end{pmatrix} \\[1em] \text{(단,} C_{ij} = (-1)^{i+j}M_{ij} \text{)}$$
- ex. $ \begin{pmatrix} a&b \\[1em] c&d \end{pmatrix} = \frac{1}{ad-bc}\begin{pmatrix} d&-b \\[1em] -c&a \end{pmatrix} $
- $ AA^{-1} = I , A^{-1}A = I $
- $ \because AB = I $ 이고 $ B $가 역행렬이 존재할 때($ det(B) \neq 0 $),
- $ \Rightarrow BABB^{-1} = BIB^{-1} \Rightarrow BAI = BIB^{-1} \Rightarrow BA = BB^{-1} = I \Rightarrow BA = I $
(3) 크래머 공식
- $ Ax = b $에서 $ x $를 구할때 $ x = A^{-1}b $처럼 구하는 걸 알아봤는데, $ x $에 있는 모든 값을 구하고 싶은게 아닌 특정 값만 알고 싶은 경우 사용할 수 있음
- 연립일차방정식 $ Ax = b $에서, $ A $가 행렬식이 0이 아닌 정사각행렬일 때, $$ x_j = \frac{detA_j}{detA} = \frac{\begin{vmatrix} a_{11} & a_{12} & \cdots & b_1 & \cdots & a_{1n} \\[1em] a_{21} & a_{22} & \cdots & b_2 & \cdots & a_{2n} \\[1em] \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\[1em] a_{n1} & a_{n2} & \cdots & b_n & \cdots & a_{nn} \end{vmatrix}}{\begin{vmatrix} a_{11} & a_{12} & \cdots & a_{1j} & \cdots & a_{1n} \\[1em] a_{21} & a_{22} & \cdots & a_{2j} & \cdots & a_{2n} \\[1em] \vdots & \vdots & \ddots & \vdots & \ddots & \vdots \\[1em] a_{n1} & a_{n2} & \cdots & a_{nj} & \cdots & a_{nn} \end{vmatrix}} $$
- 단, $ j = 1,\cdots ,n $ 이고, $ A_j $는 $ A $의 $ j $번째 열을 $ b $로 바꾼 행렬
- ex.

연습문제






반응형