Numeric: Why multiply matrix lines by constants before solve linear system?

50 Views Asked by At

I'm learning about Finite Difference Method(FDM) $(2)$ on Poisson equation $(1)$ and basically we do

$$ \nabla^2 u = f \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (1) $$ $$ \nabla^2 u \approx \begin{bmatrix} \dfrac{1}{h_x^2} & \dfrac{-2}{h_x^2} & \dfrac{1}{h_x^2} \end{bmatrix} \begin{bmatrix}u_{i-1} \\ u_{i} \\ u_{i+1}\end{bmatrix} \ \ \ \ \ \ \ \ \ \ (2) $$

Mixing $(1)$ and $(2)$ we get $(3)\ \forall \ i=1, \ \cdots, n-2$ and get the system $(4)$ by adding the boundary conditions

$$ \begin{bmatrix} \dfrac{1}{h_x^2} & \dfrac{-2}{h_x^2} & \dfrac{1}{h_x^2} \end{bmatrix} \begin{bmatrix}u_{i-1} \\ u_{i} \\ u_{i+1}\end{bmatrix} = f_i \ \ \ \ \ \ \ \ \ \ \ \ \ \ (3) $$ $$ \underbrace{\begin{bmatrix} 1 & & & & \\ \frac{1}{h_x^2} & \frac{-2}{h_x^2} & \frac{1}{h_x^2} & & \\ & \ddots & \ddots & \ddots & \\ & & \frac{1}{h_x^2} & \frac{-2}{h_x^2} & \frac{1}{h_x^2} \\ & & & & 1 \end{bmatrix}}_{A} \begin{bmatrix}u_{0} \\ u_{1} \\ \vdots \\ u_{n-2} \\ u_{n-1} \end{bmatrix} = \begin{bmatrix} u_a \\ f_1 \\ \vdots \\ f_{n-2} \\ u_{b}\end{bmatrix} \ \ \ \ \ \ \ \ \ \ \ \ \ \ (4) $$

But I also can write $(4)$ as $(5)$ by multiplying the internal lines by $h_x^2$

$$ \underbrace{\begin{bmatrix} 1 & & & & \\ 1 & -2 & 1 & & \\ & \ddots & \ddots & \ddots & \\ & & 1 & -2 & 1 \\ & & & & 1 \end{bmatrix}}_{B} \begin{bmatrix}u_{0} \\ u_{1} \\ \vdots \\ u_{n-2} \\ u_{n-1} \end{bmatrix} = \begin{bmatrix} u_a \\ h_x^2f(x_1) \\ \vdots \\ h_x^2f(x_{n-2}) \\ u_{b}\end{bmatrix} \ \ \ \ \ \ \ \ \ \ \ \ \ \ (5) $$

Question: Why $(5)$ is better than $(4)$ to solve numerically? It seems to be the same system, but could $\text{cond}(A) \ne \text{cond}(B)$? My question also applies to the $2D$ case in which someone told me the formulation $(7)$ is better than the formulation $(6)$.

$$ \begin{bmatrix} \dfrac{1}{h_x^2} & \dfrac{1}{h_y^2} & -2\left(\dfrac{1}{h_x^2}+\dfrac{1}{h_y^2}\right) & \dfrac{1}{h_y^2} &\dfrac{1}{h_x^2} \end{bmatrix} \begin{bmatrix}u_{j,i-1} \\ u_{j-1,i} \\ u_{j,i} \\ u_{j+1,i} \\ u_{j,i+1}\end{bmatrix} = f_{j,i} \ \ \ \ \ \ \ \ \ \ \ \ \ \ (6) $$

$$ \begin{bmatrix} \dfrac{h_y}{h_x} & \dfrac{h_x}{h_y} & -2\left(\dfrac{h_y}{h_x}+\dfrac{h_x}{h_y}\right) & \dfrac{h_x}{h_y} &\dfrac{1}{h_x^2} \end{bmatrix} \begin{bmatrix}u_{j,i-1} \\ u_{j-1,i} \\ u_{j,i} \\ u_{j+1,i} \\ u_{j,i+1}\end{bmatrix} = h_x h_y \cdot f_{j,i} \ \ \ \ \ \ \ \ \ \ \ \ \ \ (7) $$