# 高斯-赛德尔迭代

## 算法

{\displaystyle {\begin{aligned}a_{11}\cdot x_{1}+a_{12}\cdot x_{2}+\ldots +a_{1n}\cdot x_{n}&=b_{1},\\a_{21}\cdot x_{1}+a_{22}\cdot x_{2}+\ldots +a_{2n}\cdot x_{n}&=b_{2},\\\vdots \qquad \qquad \qquad &=\vdots \\a_{n1}\cdot x_{1}+a_{n2}\cdot x_{2}+\ldots +a_{nn}\cdot x_{n}&=b_{n}.\end{aligned}}}

${\displaystyle x_{m}^{k+1}={\frac {1}{a_{mm}}}\left(b_{m}-\sum _{j=1}^{m-1}a_{mj}\cdot x_{j}^{k+1}-\sum _{j=m+1}^{n}a_{mj}\cdot x_{j}^{k}\right),\quad 1\leq m\leq n.}$

## 矩阵分解

${\displaystyle A{\vec {x}}={\vec {b}}}$

${\displaystyle A=D+L+U}$,

${\displaystyle A={\begin{pmatrix}1&2&2\\3&1&4\\5&3&1\end{pmatrix}}}$${\displaystyle D={\begin{pmatrix}1&0&0\\0&1&0\\0&0&1\end{pmatrix}}}$${\displaystyle L={\begin{pmatrix}0&0&0\\3&0&0\\5&3&0\end{pmatrix}}}$${\displaystyle U={\begin{pmatrix}0&2&2\\0&0&4\\0&0&0\end{pmatrix}}}$.

${\displaystyle D{\vec {x}}^{\,k+1}={\vec {b}}-L{\vec {x}}^{\,k+1}-U{\vec {x}}^{\,k}}$.

## 算法

输入: A, b



repeat until convergence（收敛）
for i from 1 until n do
${\displaystyle \sigma \leftarrow 0}$
for j from 1 until n do
if j ≠ i then
${\displaystyle \sigma \leftarrow \sigma +a_{ij}\phi _{j}}$
end if
end (j - loop)
${\displaystyle \phi _{i}\leftarrow {\frac {1}{a_{ii}}}(b_{i}-\sigma )}$
end (i-loop)
check if convergence is reached（检查是否已收敛）
end (repeat)