# Resolution of the Poisson's equation with the WRM using global Shape Functions

The residual formulation is based on the Weighted Residual Method (WRM). The differential equation is converted in an integral equation with certain weighting functions applied to each equation.
The residual form of the Poisson's equation, that is, by using an approach solution $\frac{}{} \hat \varphi = \sum_{i=0}^n N_i (x) a_i$, is written:

$\frac{}{} r_{\Omega} = A(\hat \varphi) = \frac{d}{dx} \left( k \frac{d \hat \varphi}{dx} \right) + Q \ne 0 \quad in \quad \Omega$
$\frac{}{} r_{\Gamma} = B(\hat \varphi) = \begin{cases} \hat \varphi - \overline{\varphi} \ne 0 & in \quad \Gamma_{\varphi} \\ k \frac{d \hat \varphi}{dx} + \overline{q} \ne 0 & in \quad \Gamma_{q} \end{cases}$

Therefore, the integral equation to be solved, including the weightings ($W(x) \frac{}{}$ and $\overline{W}(x)$), become:

${ \int_{\Omega} W(x) r_{\Omega} d\Omega + \oint_{\Gamma} \overline{W}(x) r_{\Gamma} d_{\Gamma}= \int_{\Omega} W_i A(\sum_j^n N_j a_j) d\Omega + \oint_{\Gamma} \overline{W_i} B(\sum_j^n N_j a_j) d_{\Gamma}=0 \qquad i=1..n }$

that can be written as:

$\mathbf{K} \cdot \mathbf{a} = \mathbf{f}$

with K is a coefficients matrix that depends on the geometrical and physical properties of the problem, a is the vector with the n unknowns ($\frac{}{} a_j$) to be obtained and f is a vector that depends on the source values and boundary conditions.

Using the same basis functions $\frac{}{} N_i (x)$ for the whole domain, and if they are selected to naturally accomplish the boundary conditions, the integral form can be written:

${ \int_{\Omega} W_i \left[ \frac{d}{dx} k \frac{d}{dx} \left( \sum_{j=0}^n N_j (x) a_j \right) + Q \right] d\Omega =0 \qquad i=1..n }$

and therefore:

$\begin{cases} K_{ij} & = \int_{\Omega} W_i(x) \left[ \frac{d}{dx} k \frac{d}{dx} \left( N_j (x) \right) \right] d\Omega \\ f_i & = - \int_{\Omega} W_i(x) Q(x) d\Omega \, \end{cases}$

For simplicity reasons, we select as basis functions the Fourier Series $(N_i(x)=\sin \frac {\pi x i}{l} \,)$, that automatically accomplish the boundary conditions $(N_i(0)=0 \,$ and $N_i(x_L)=0 \,)$. If the material is constant, we can write:

$\frac{d}{dx} k \frac{d}{dx} \left ( \sin \frac {\pi x i}{l} \right) = \left ( - k \left (\frac{\pi i}{l} \right )^2 \sin \frac {\pi x i}{l} \right) = - k \left (\frac{\pi i}{l} \right )^2 \sin \frac {\pi x i}{l}$

$\begin{cases} K_{ij} & = - \int_{\Omega} W_i(x) k \left (\frac{\pi j}{l} \right )^2 \sin \frac {\pi x j}{l} d\Omega \\ f_i & = - \frac{}{} \int_{\Omega} W_i(x) Q(x) d\Omega \end{cases} \Rightarrow \begin{cases} K_{ij} & = \left (\frac{\pi j}{l} \right )^2 \int_{\Omega} W_i(x) k \sin \frac {\pi x j}{l} d\Omega \\ f_i & = \frac{}{} \int_{\Omega} W_i(x) Q(x) d\Omega \end{cases}$

Depending on the kind of weighting functions used, different weighted residual methods (WRM) can be considered, as follows in the next sections.

## Collocation Method     $(\frac{}{} W_i(x)=\delta(x - x_i),$ $\frac{}{} i=1, 2,... , n)$

Remember:
$\begin{cases} \delta_i(x) = 0 & \forall x \ne x_i \, \\ \int_{- \infin}^{\infin} \delta(x-x_i) dx = 1 \, \\ \int_0^l f(x) \delta(x-x_i) dx = f(x_i) \, \end{cases}$

The matrix components are:
$\begin{cases} K_{ij} & = \int_{\Omega} \delta(x - x_i) \left[ \frac{d}{dx} k \frac{d}{dx} \left( N_j (x) \right) \right] d\Omega = \frac{d}{dx} k \frac{d}{dx} \left( N_j (x) \right) \bigg|_{x=x_i} \\ f_i & = - \int_{\Omega} \delta(x - x_i) Q(x) d\Omega = Q(x_i) \, \end{cases}$

If the material k is constant and the source Q is also constant over a part of the domain, and we still use Fourier series as basis functions, the matrix form becomes:

$\begin{cases} K_{ij} & = k \left (\frac{\pi j}{l} \right )^2 \sin \frac {\pi x_i j}{l} \\ f_i & = Q(x_i) \, \end{cases}$

## Subdomain Method     $(W_i(x)=1 \quad \forall x \in \Omega_i \quad and \quad W_i(x)=0 \quad \forall x \notin \Omega_i )$

$\begin{cases} K_{ij} & = \int_{\Omega_i} \left[ \frac{d}{dx} k \frac{d}{dx} \left( N_j (x) \right) \right] d\Omega \\ f_i & = \frac{}{} \int_{\Omega_i} Q(x) d\Omega \end{cases}$
that is, the Subdomain Method is equivalent to be the residual integral equal to zero for each subdomain (note that now the integral is applied just to the $\Omega_i \,$ subdomain.

If the material k is constant and the source Q is also constant over a part of the domain, and Fourier series are used too as basis functions, the matrix form becomes:

$\begin{cases} K_{ij} & = k \left (\frac{\pi j}{l} \right )^2 \int_{\Omega_i} \sin \frac {\pi x j}{l} d\Omega = - k \left (\frac{\pi j}{l} \right ) \cos \frac {\pi x j}{l} \Big|_{\Omega_i} \\ f_i & = Q(x) \Big|_{\Omega_i} \int_{\Omega_i} d\Omega \, \end{cases}$

## Galerkin Method     $(\frac{}{} W_i(x) \equiv N_i(x))$

$\begin{cases} K_{ij} & = \int_{\Omega} N_i(x) \left[ \frac{d}{dx} k \frac{d}{dx} \left( N_j (x) \right) \right] d\Omega \\ f_i & = \frac{}{} \int_{\Omega} N_i(x) Q(x) d\Omega \end{cases}$
If the material k is constant and the source Q is also constant over a part of the domain, and Fourier series are used as basis functions again, the matrix form becomes:

$\begin{cases} K_{ij} & = \int_{\Omega} \sin \frac {\pi x i}{l} k \left (\frac{\pi j}{l} \right )^2 \sin \frac {\pi x j}{l} d\Omega = k \left (\frac{\pi j}{l} \right )^2 \int_{\Omega} \sin \frac {\pi x i}{l} \sin \frac {\pi x j}{l} d\Omega \\ f_i & = \frac{}{} \int_{\Omega} \sin \frac {\pi x i}{l} Q(x) d\Omega \end{cases}$

## Least Squares Method     $(W_i(x)=A(\varphi) \quad and \quad \overline{W_i}(x)=B(\varphi))$

The expression to minimize is:
$I=\int_{\Omega} \left[ A(\hat \varphi) \right]^2 d\Omega + \int_{\Gamma} \left[ B(\hat \varphi) \right]^2 d\Gamma$

$\delta I = \frac{\part I}{\part a_1} \delta a_1 + \frac{\part I}{\part a_2} \delta a_2 + ... + \frac{\part I}{\part a_n} \delta a_n ~ \Rightarrow ~ \begin{cases} \frac{\part I}{\part a_1} & = 0 \\ \frac{\part I}{\part a_2} & = 0 \\ \vdots \\ \frac{\part I}{\part a_n} & = 0 \end{cases}$
$\frac{\part}{\part a_i} \int_{\Omega} \left[ A(\hat \varphi) \right]^2 d\Omega = 0; ~ ~ ~ ~ i= 1, 2, ..., n$

$\frac{\part}{\part a_i} \int_{\Omega} \left[ \frac{d^2 \hat \varphi}{dx^2} + Q \right]^2 d{\Omega} = \int_{\Omega} 2 \left[ \frac{d^2 \hat \varphi}{dx^2} + Q \right] \frac{\part}{\part a_i} \left[ \frac{d^2 \hat \varphi}{dx^2} \right] d{\Omega}$

$\frac{\part I}{\part a_i}=\int_{\Omega} \underbrace{ \frac{\part}{\part a_i} \left[ \frac{d^2 \hat \varphi}{dx^2} \right] }_{W_i(x)} \underbrace{ 2 \left[ \frac{d^2 \hat \varphi}{dx^2} + Q \right] }_{A(\hat \varphi)} d{\Omega} = \int_{\Omega} W_i(x) A(\hat \varphi) d{\Omega} = 0 ~ ~ ~ ~ i= 1, 2, ..., n$

Therefore, the minimization process can be understood as a form of the weighting residues with:

$W_i(x) = 2 \frac{\part}{\part a_i} \left[ \frac{d^2 \hat \varphi}{dx^2} \right]= 2 \frac{\part}{\part a_i} \left[ \frac{d^2 \sum_1^n a_j N_j(x)}{dx^2} \right] = 2 \left[ \frac{d^2 N_i(x)}{dx^2} \right]$

$\begin{cases} K_{ij} & = \int_{\Omega} W_i(x) \left[ \frac{d}{dx} k \frac{d}{dx} \left( N_j (x) \right) \right] d\Omega \\ f_i & = \frac{}{} \int_{\Omega} W_i(x) Q(x) d\Omega \end{cases}$

$\begin{cases} K_{ij} & = \int_{\Omega} 2 \left[ \frac{d^2 N_i(x)}{dx^2} \right] \left[ \frac{d}{dx} k \frac{d}{dx} \left( N_j (x) \right) \right] d\Omega \\ f_i & = \frac{}{} \int_{\Omega} 2 \left[ \frac{d^2 N_i(x)}{dx^2} \right] Q(x) d\Omega \end{cases}$

If the material k is constant and the source Q is also constant over a part of the domain, and Fourier series are used as basis functions $(N_i(x)=\sin \frac {\pi x i}{l} \,)$, the matrix form becomes:

$W_i(x) = 2 \left[ \frac{d^2 \sin \frac {\pi x i}{l}}{dx^2} \right] = - 2 \left( \frac{\pi i}{l} \right)^2 sin \frac {\pi x i}{l} = -2 \left( \frac{\pi i}{l} \right)^2 N_i(x)$

$\begin{cases} K_{ij} & = - \int_{\Omega} 2 \left( \frac{\pi i}{l} \right)^2 N_i(x) \left[ \frac{d}{dx} k \frac{d}{dx} \left( N_j (x) \right) \right] d\Omega = - 2 \left( \frac{\pi i}{l} \right)^2 \int_{\Omega} N_i(x) \left[ \frac{d}{dx} k \frac{d}{dx} \left( N_j (x) \right) \right] d\Omega \\ f_i & = - \int_{\Omega} 2 \left( \frac{\pi i}{l} \right)^2 \frac{}{} N_i(x) Q(x) d\Omega = - 2 \left( \frac{\pi i}{l} \right)^2 \frac{}{} \int_{\Omega} N_i(x) Q(x) d\Omega \end{cases}$

Note that, in this case and without generality, due to the selected basis functions, the obtained solution is the same that the obtained one using the Galerkin method.

In order to compare the different methods, check some specific examples.

Back to the Weighted Residual Method applied to the Poisson's equation