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

The matrix form of the residual formulation can be written as: $\mathbf{K} \cdot \mathbf{a} = \mathbf{f}$ with: $\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}$

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}$

sources medium boundary

conditions

shape functions
constant source
homogeneous
Dirichlet
Fourier Series $Q(x) = \begin{cases} Q_0 & x_0 \leqslant x \leqslant x_f \\ 0 & x_f \leqslant x \leqslant x_L \end{cases}$ $k(x) = cte \frac{ }{ }$ $\varphi (x_0)= \varphi_0$ $\varphi (x_L)= \varphi_L$ $N_i(x)=\sin \frac {\pi x i}{l} \,$

By using different weighting functions, a new range of methods can be classified:

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

General expression k and Q constant, using Fourier series $\begin{cases} K_{ij} & = \frac{d}{dx} k \frac{d}{dx} N_j (x) \bigg|_{x=x_i} \\ f_i & = Q(x_i) \, \end{cases}$ $\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}$

Number of points = 1 $\begin{cases} x_1 & = \frac{l}{2} \\ Q(x_1) & = \frac{Q}{2} \\ K_{11} & = k \left (\frac{\pi}{l} \right )^2 \sin \frac {\pi x_1}{l} \\ f_1 & = Q(x_1) \, \end{cases}$

Number of points = 2 $\begin{cases} x_1 & = \frac{l}{4} \\ x_2 & = \frac{3 l}{4} \\ Q(x_1) & = Q \\ Q(x_2) & = 0 \\ K_{ij} & = k \left (\frac{\pi j}{l} \right )^2 \sin \frac {\pi x_i j}{l} \\ f_i & = Q(x_i) \, \end{cases}$

Number of points = n $\begin{cases} x_i & = \frac{i l}{n+1} \\ Q(x_i) & = \begin{cases} Q & if ~ x < \frac{l}{2} \\ 0 & if ~ x > \frac{l}{2} \end{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}$ To modify the parameters, edit this Matlab code

## 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 )$

General expression k and Q constant, using Fourier series $\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}$ $\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}$

Number of points = 1 $\begin{cases} x_1 & = \frac{l}{2} \\ Q(x_1) & = \frac{Q}{2} \\ K_{11} & = 2 k \left (\frac{\pi}{l} \right ) \\ f_1 & = Q(x_1) \, \end{cases}$

Number of points = 2 $\begin{cases} x_1 & = x_0 \\ x_2 & = \frac{l}{2} \\ x_3 & = x_L \\ Q(x_1) & = Q \\ Q(x_2) & = 0 \\ K_{ij} & = - k \left (\frac{\pi j}{l} \right ) \left ( \cos \frac {\pi x_{i+1} j}{l} - \cos \frac {\pi x_{i} j}{l}\right )\\ f_i & = Q(x_i) (x_{i+1} - x_i)\, \end{cases}$

Number of points = n $\begin{cases} x_1 & = x_0 \\ x_{i+1} & = \frac{i l}{n} \\ Q(x_i) & = \begin{cases} Q & if ~ x < \frac{l}{2} \\ 0 & if ~ x > \frac{l}{2} \end{cases} \\ K_{ij} & = - k \left (\frac{\pi j}{l} \right ) \left ( \cos \frac {\pi x_{i+1} j}{l} - \cos \frac {\pi x_{i} j}{l}\right )\\ f_i & = Q(x_i) (x_{i+1} - x_i) \, \end{cases}$ To modify the parameters, edit this Matlab code

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

General expression k and Q constant, using Fourier series $\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}$ $\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}$

Number of points = 1 $\begin{cases} x_1 & = \frac{l}{2} \\ Q(x_1) & = Q \, \\ K_{11} & = k \left ( \frac{\pi^2}{2 l} \right) \\ f_1 & = \left ( \frac{Q(x_1) l}{\pi} \right)\, \end{cases}$

Number of points = 2 $\begin{cases} x_1 & = x_0 \, \\ x_2 & = \frac{l}{2} \\ x_3 & = x_L \, \\ Q(x_1) & = Q \\ Q(x_2) & = 0 \\ K_{ij} & = \begin{cases} k \left (\frac{\pi j}{l} \right )^2 \frac {l}{2} & if ~ i = j \\ k \left (\frac{\pi j}{l} \right )^2 \frac {l}{2 \pi} \left( \frac {sin(\pi (i-j))}{i-j} - \frac {sin(\pi (i+j))}{i+j} \right) & if ~ i <> j \end{cases} \\ f_i & = Q l \frac{1 - cos(\frac{i \pi}{2})}{i \pi} \, \end{cases}$

Number of points = n $\begin{cases} x_1 & = x_0 \, \\ x_{i+1} & = \frac{i l}{n} \\ Q(x_i) & = \begin{cases} Q & if x < \frac{l}{2} \\ 0 & if x > \frac{l}{2} \end{cases} \\ K_{ij} & = \begin{cases} k \left (\frac{\pi j}{l} \right )^2 \frac {l}{2} & if ~ i = j \\ k \left (\frac{\pi j}{l} \right )^2 \frac {l}{2 \pi} \left( \frac {sin(\pi (i-j))}{i-j} - \frac {sin(\pi (i+j))}{i+j} \right) & if ~ i <> j \end{cases} \\ f_i & = Q l \frac{1 - cos(\frac{i \pi}{2})}{i \pi} \, \end{cases}$ To modify the parameters, edit this Matlab code

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

General expression k and Q constant, using Fourier series $\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}$ $\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 scaled with a factor $2 \left( \frac{\pi i}{l} \right)^2$. To modify the parameters, edit this Matlab code

Back to the Resolution of the Poisson's equation with the Weighted Residual Method using global Shape Functions
Back to the Weighted Residual Method applied to the Poisson's equation