# Direct Numerical Analysis

## LU Decomposition

A system of equations

$$a_1x_1+b_1x_2+c_1x_3=A$$
$$a_2x_1+b_2x_2+c_2x_3=B$$
$$a_3x_1+b_3x_2+c_3x_3=C$$

can be written in matrix form as

$$[A] \{ x \}=\{C\}$$

where
$$[A]= \begin{bmatrix} a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \\ \end{bmatrix}$$

$$\{ x \}= \left\{ \begin{matrix} x_1 \\ x_2 \\ x_3 \\ \end{matrix} \right\}$$

$$\{ C \}= \left\{ \begin{matrix} A \\ B \\ C \\ \end{matrix} \right\}$$

Matrix $$[A]$$ can be decomposed into a product of two matrices $$[L][U]$$ where

$$[L]= \begin{bmatrix} L_{11} & 0 & 0 \\ L_{21} & L_{22} & 0 \\ L_{31} & L_{32} & L_{33} \\ \end{bmatrix}$$

$$[U]= \begin{bmatrix} 1 & U_{12} & U_{13} \\ 0 & 1 & U_{23} \\ 0 & 0 & 1 \\ \end{bmatrix}$$

And $$[U]\{ x \} = \{ D \}$$
$$[L]\{ D \} = \{ C \}$$

$$\{ D \}$$ can then be found by forward substitution. Giving

$$[U] \{ x \} = \{ D \}$$

Where $$\{ x \}$$ can be found by backwards substitution.

## Cramer's Rule

For a system

$$[A]\{ x \} = \{ B \}$$

Where $$[A]$$ is reversible ($$det[A] \neq 0$$). $$\{ x \}$$ can be found by

$$x_i = \frac{det[A_i]}{det[A]}$$

Where $$[A_i]$$ is the matrix $$[A]$$ with the $$i$$th column replaced by the column matrix $$\{ B \}$$.

eg. For

$$\begin{bmatrix} A_{11} & A_{12} \\ A_{21} & A_{22} \end{bmatrix} \begin{Bmatrix} x_1 \\ x_2 \end{Bmatrix} = \begin{Bmatrix} B_1 \\ B_2 \end{Bmatrix}$$

$$x_1 = \frac{\begin{vmatrix} \ B_1 & A_{12} \\ \ B_2 & A_{22} \end{vmatrix}}{\begin{vmatrix}A_{11} & A_{12} \\ A_{21} & A_{22} \end{vmatrix}}$$

## Inverse Method

For

$$[A] \{ x \} = \{ C \}$$
$$[A]^{-1} [A] \{ x \} = \{ C \} [A]^{-1}$$
$$[I] \{ x \} = \{ C \} [A]^{-1}$$
$$\{ x \} = \{ C \} [A]^{-1}$$