열렬히.뛰기

2. 행렬

수학 & 통계 > 최적화이론 > 수업 : 통수 & 선계 > 행렬

행렬이란?

  • 사각형 안에 수를 모은 것.
  • 세 가지 역할/기능이 있다.
    1. 연립방정식을 푸는 도구
    2. 벡터들을 모은 일종의 공간 = 벡터공간
    3. 벡터를 넣을 때 벡터가 나오는 함수 = 선형변환!

행렬 표기법

숫자로 표기하기

\left( \begin{matrix} 1 & 2 \\ 3 & 4\\ \end{matrix} \right) \kern{10pt} \left[ \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{matrix} \right] \\[20pt] \begin{pmatrix} 1 \\ 2 \end{pmatrix} = \underline{a}_{01} \rightarrow \text{열벡터 (행이 1개인 벡터)} \\[20pt] \begin{pmatrix} 2 & 4 & 6 \end{pmatrix} = \underline{a}_{10} \rightarrow \text{행벡터 (열이 1개인 벡터)} \\[20pt] \text{if.}~A = \begin{pmatrix} 1 & 3 & 5 \\ 2 & 4 & 6 \end{pmatrix} = \begin{bmatrix} \underline{a}_{01} & \underline{a}_{02} & \underline{a}_{03} \end{bmatrix} = \begin{bmatrix} \underline{a}_{10} \\ \underline{a}_{20} \end{bmatrix}

기호로 표기하기

  • A_{ij},\; A_{i \times j},\; \{a_{ij}\}_{ij}
    • 행렬 A의 차원은 n \times m
    • i행 j열의 원소값은 a_{ij}

행렬의 성질

1. 스칼라배

kA = B 일때, ka_{ij} = \{b_{ij}\}_{ij} (여기서 k는 스칼라)

\because k\{a_{ij}\} = \{ka_{ij}\} = b_{ij}

2. 행렬의 덧셈

A + B = C (여기서 A, B, C 모두 동일한 차원을 가진다.)

\left[ \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{matrix} \right] + \left[ \begin{matrix} 1 & -7 & 12 \\ 5 & 0 & -3 \\ 9 & 1 & 7 \\ \end{matrix} \right] = \left[ \begin{matrix} 2 & -5 & 15 \\ 9 & 5 & 3 \\ 7 & 8 & 9 \\ \end{matrix} \right]
\begin{pmatrix} 2 & 3 & 1 \\ 3 & 10 & 6 \\ \end{pmatrix} + \begin{pmatrix} 1 & 3 & 1 \\ 3 & 7 & 8 \\ \end{pmatrix} = \begin{pmatrix} 3 & 6 & 2 \\ 6 & 17 & 14 \\ \end{pmatrix}

따라서, A = \{a_{ij}\}_{ij}이고 B = \{b_{ij}\}_{ij}이며 C = \{c_{ij}\}_{ij}일 때,

a_{ij} + b_{ij} = c_{ij}이다.

3. 행렬의 곱셈

AB = C \\[10pt] \left[ \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{matrix} \right] \left[ \begin{matrix} 1 & -7 & 12 \\ 5 & 0 & -3 \\ 9 & 1 & 7 \\ \end{matrix} \right] = \left[ \begin{matrix} 2 & -5 & 15 \\ 9 & 5 & 3 \\ 7 & 8 & 9 \\ \end{matrix} \right]
  1. 앞 행렬의 행 크기 = 뒤 행렬의 열 크기 이어야만 연산 성립
dim(A) = n \times m. \quad dim(B) = m \times l. \quad dim(C) = n \times l
  1. 벡터의 내적과 같다.
A = \begin{pmatrix} \underline{a}_{1\cdot} \\ \vdots \\ \underline{a}_{n\cdot} \\ \end{pmatrix} = \begin{pmatrix} \underline{a}_{\cdot 1} & \cdots & \underline{a}_{\cdot m} \\ \end{pmatrix}
B = \begin{pmatrix} \underline{b}_{\cdot 1} & \cdots & \underline{b}_{\cdot l} \\ \end{pmatrix} = \begin{pmatrix} \underline{b}_{1\cdot} \\ \vdots \\ \underline{b}_{m\cdot} \\ \end{pmatrix}
c_{11} = \displaystyle\sum_{k=1}^{3} = a_{1k}b_{k1} \kern{10pt} c_{12} = \displaystyle\sum_{k=1}^{3} = a_{1k}b_{k2} \\[10pt] c_{21} = \displaystyle\sum_{k=1}^{3} = a_{2k}b_{k1} \kern{10pt} c_{22} = \displaystyle\sum_{k=1}^{3} = a_{2k}b_{k2}
c_{ij} = \displaystyle\sum_{k=1}^{m} = a_{ik}b_{kj} = \begin{pmatrix} a_{1i} & \cdots & a_{1m} \\ \end{pmatrix} \begin{pmatrix} b_{1j} \\ \vdots \\ b_{mj} \\ \end{pmatrix} = \underline{a}_{i\cdot}\; \underline{b}_{\cdot j}

3. 교환법칙은 성립하지 않는다.

\begin{align*} AB &= \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ \end{pmatrix} \begin{pmatrix} 1 & 0 \\ 2 & 1 \\ 1 & 4 \end{pmatrix} = \begin{pmatrix} 8 & 14 \\ 20 & 29 \\ \end{pmatrix} \\[15pt] BA &= \begin{pmatrix} 1 & 0 \\ 2 & 1 \\ 1 & 4 \end{pmatrix} \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ \end{pmatrix} = \begin{pmatrix} 1 & 2 & 3\\ 6 & 9 & 12\\ 17& 22& 27\\ \end{pmatrix} \end{align*}

4. 전치행렬

(AB)^{T} = B^TA^T \\[10pt] dim(A) = n \times m. \kern{10pt} dim(B) = m \times l. \\[10pt] AB = \{a_{ij}\}_{ij}\{b_{ij}\}_{ij} = \{\underline{a}_{i\cdot}^{'} \underline{b}_{\cdot j}\}_{ij} \\ \text{Then,}~~ (AB)^{\prime} = C^{\prime} = \{ \underline{a}_{i\cdot}^{\prime} \underline{b}_{\cdot j} \}_{ij} \\[10pt] \underline{a}_{i\cdot}^{\prime} \; \underline{b}_{\cdot j} = c_{ij} \kern{10pt} c_{ji}= \underline{a}_{j\cdot}^{\prime} \; \underline{b}_{\cdot i}

5. 행렬의 결합법칙

(AB)C = A(BC)
A = \{a_{ij}\}_{ij},~~ B = \{b_{ij}\}_{ij},~~ C = \{c_{ij}\}_{ij}. \\[10pt] D = AB = \{a_{ij}\}_{ij}\{b_{ij}\}_{ij} = \{\underline{a}_{i\cdot}^{'} \underline{b}_{\cdot j}\}_{ij} = \{d_{ij}\}_{ij} \\[10pt] (AB)C = DC = \{\underline{d}_{i\cdot}^{\prime}\; \underline{c}_{\cdot j}\}_{ij}
\begin{align*} \underline{d}_{i\cdot}^{\prime}\; \underline{c}_{\cdot j} &= \displaystyle\sum_{p=1}^{1} d_{ip}c_{pj} = \displaystyle\sum_{p=1}^{l} (\underline{a}_{i\cdot}^{\prime}\; \underline{b}_{\cdot j})\; {c}_{pj} \\[20pt] &= \displaystyle\sum_{p=1}^{l} \Bigg( \displaystyle\sum_{q=1}^{m} {a}_{iq}\;{b}_{qj}\Bigg) = \displaystyle\sum_{p=1}^{l} {a}_{iq} \Bigg(\displaystyle\sum_{q=1}^{m} {b}_{qj}\;{c}_{pj} \Bigg) \\[20pt] &= \displaystyle\sum_{p=1}^{l} {a}_{iq} ( \underline{b}_{i\cdot}^{\prime}\; \underline{c}_{\cdot j} ) = \displaystyle\sum_{p=1}^{l} {a}_{iq}\;{f}_{qj} = \underline{a}_{i\cdot}^{\prime}\; \underline{f}_{\cdot j} \\[15pt] &= AF = A(BC) \end{align*}

6. 행렬의 분배법칙

A(B+C) = AB + AC
B + C = \{b_{ij} + c_{ij}\}_{ij} = \{d_{ij}\}_{ij} = D \\[8pt] A(B+C) = AD = \{\underline{a}_{i\cdot}^{\prime}\; b_{ij}\}_{ij} + \{\underline{a}_{i\cdot}^{\prime}\; c_{ij}\}_{ij}

같은 이유에서 (B+C)A = BA + BC 도 성립한다.

행렬의 종류

1. 정방행렬

  • 행의 수와 열의 수가 같은 행렬
A = \begin{pmatrix} 2 & 3 & 1 \\ 3 & 10 & 6 \\ 5 & 4 & 7 \\ \end{pmatrix}

2. 대각행렬 / 단위행렬

  • 주대각선을 제외한 나머지가 전부 0인 행렬
\begin{pmatrix} 1 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \\ \end{pmatrix}
  • 이 중 주대각선이 전부 1인 행렬을 단위행렬이라고 한다.
\begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \\ \end{pmatrix}

3. 전치행렬 / 대칭행렬

  • 주대각선을 기준으로 해서 원소들을 바꿔준 행렬을 전치행렬이라 한다.
\begin{pmatrix} 2 & 3 & 1 \\ 3 & 10 & 6 \\ 5 & 4 & 7 \\ \end{pmatrix}^T = \begin{pmatrix} 2 & 3 & 5 \\ 3 & 10 & 4 \\ 1 & 6 & 7 \\ \end{pmatrix}
  • 주대각선을 기준으로 대칭인 경우 대칭행렬이라고 한다.

    • 대칭행렬은 전치시켜도 그 모양이 같다.
    \begin{pmatrix} 2 & 3 & 1 \\ 3 & 1 & 4 \\ 1 & 4 & 7 \\ \end{pmatrix} ^T = \begin{pmatrix} 2 & 3 & 1 \\ 3 & 1 & 4 \\ 1 & 4 & 7 \\ \end{pmatrix}

4. 멱등행렬

  • 제곱했을 때 자기 자신이 되는 행렬
  • 영어로는 idempotent matrix
\begin{pmatrix} 2 & -2 & -4 \\ -1 & 3 & 4 \\ 1 & -2 & -3 \\ \end{pmatrix} ^n = \begin{pmatrix} 2 & -2 & -4 \\ -1 & 3 & 4 \\ 1 & -2 & -3 \\ \end{pmatrix}

5. 직교행렬

  • 행렬 속 모든 열벡터가 서로 직교하는 행렬
  • ex. 회전행렬, 아다마르 행렬, 푸리에 행렬 등등…
\begin{bmatrix} cos\theta & -sin\theta \\ sin\theta & cos\theta \end{bmatrix} = \begin{bmatrix} q_1 & q_2 \end{bmatrix} \\ [10pt] q_1 \cdot q_2 = q_1^Tq_2 = cos\theta \cdot -sin\theta + cos\theta \cdot sin\theta = 0