# Nonlinear finite elements/Weighted residual methods

## Weak Formulation : Weighted Average Methods

Weighted average methods are also often called "Rayleigh-Ritz Methods". The idea is to satisfy the differential equation in an average sense by converting it into an integral equation. The differential equation is multiplied by a weighting function and then averaged over the domain.

If ${\displaystyle v(t)}$ is a weighting function then the weak form of Equation (1) is

${\displaystyle {\text{(5)}}\qquad {\int _{0}^{1}\left({\frac {du}{dt}}+u\right)~v(t)~dt=0~;\qquad u(0)=1~.}}$

The weighting function ${\displaystyle v(t)}$ can be any function of the independent variables that is sufficiently well-behaved that the integrals make sense.

Recall that we are looking for an approximate solution. Let us call this approximate solution ${\displaystyle u_{h}}$. If we plug the approximate solution into equation (5) we get

${\displaystyle {\text{(6)}}\qquad {\int _{0}^{1}\left({\frac {d}{dt}}(u_{h})+u_{h}\right)~v(t)~dt=\int _{0}^{1}R(t)~v(t)~dt=0~;\qquad u_{h}(0)=1~.}}$

Since the solution is approximate, the original differential equation will not be satisfied exactly and we will be left with a residual ${\displaystyle R(t)}$. Weighted average methods try to minimize the residual in a weighted average sense.

Finite element methods are a special type of weighted average method.

### Examples of Weighted Average Methods

Let us assume the trial solution for problem (6) to be

${\displaystyle u_{h}(t)=a_{0}+a_{1}t+a_{2}t^{2}+\dots +a_{n}t^{n}~.}$

After applying the initial condition we get ${\displaystyle a_{0}=1}$, and the trial solution becomes

${\displaystyle u_{h}(t)=1+a_{1}t+a_{2}t^{2}+\dots +a_{n}t^{n}~.}$

Let us simplify the trial solution further and consider only the first three terms, i.e.,

${\displaystyle {\text{(7)}}\qquad {u_{h}(t)=1+a_{1}t+a_{2}t^{2}~.}}$

Plug in the trial solution (7) into (6). Then, the residual is

${\displaystyle {\text{(8)}}\qquad {R(t)=1+a_{1}(1+t)+a_{2}(2t+t^{2})~.}}$

If ${\displaystyle R(t)=0}$, then the trial solution is equal to the exact solution. If ${\displaystyle R(t)\neq 0}$, we can try to make the residual as close to zero as possible. This can be done by choosing ${\displaystyle a_{1}}$ and ${\displaystyle a_{2}}$ such that ${\displaystyle R(t)}$ is a minimum.

#### Minimizing ${\displaystyle R(t)}$: Collocation Method

In the collocation method, we minimize the residual by making it vanish at ${\displaystyle n}$ points ${\displaystyle t_{1},t_{2},\dots ,t_{n}}$ within the domain.

For our problem, the domain of interest is ${\displaystyle 0\leq t\leq 1}$. Let us pick two points in this domain ${\displaystyle t_{1}}$ and ${\displaystyle t_{2}}$ such that ${\displaystyle 0\leq t_{1} (see Figure 1). In this example we choose ${\displaystyle t_{1}=1/3}$ and ${\displaystyle t_{2}=2/3}$.

 Figure 1. Discretized domain for Problem 1.

The values of the residual (8) at ${\displaystyle t_{1}}$ and ${\displaystyle t_{2}}$ are

${\displaystyle R(t_{1})=1+{\frac {4}{3}}a_{1}+{\frac {7}{9}}a_{2}~;\qquad R(t_{2})=1+{\frac {5}{3}}a_{1}+{\frac {16}{9}}a_{2}~.}$

If we now impose the condition that the residual vanishes at these two points and solve the resulting equations, we get ${\displaystyle a_{1}=-27/29}$ and ${\displaystyle a_{2}=9/29}$. Therefore the approximate solution is

${\displaystyle {u_{h}(t)=1-{\frac {27}{29}}t+{\frac {9}{29}}t^{2}~.}}$

Figure 2 shows a comparison of this solution with the exact solution.

You can see that the collocation method gives a solution that is close to the exact up to ${\displaystyle t=1}$. However, the same results cannot be used up to ${\displaystyle t=2}$ without re-evaluating the integrals.

If you think in terms of equation (6) you can see that a weighting function ${\displaystyle v(t)}$ was used to get to the solution. In fact, it is the choice of weighting function that determines whether a method is a collocation method! The weighting function in this case is

${\displaystyle {v(t)=\delta (t-t_{j})}}$

where ${\displaystyle t_{j}}$ is a node and ${\displaystyle \delta }$ is the Dirac delta function.

#### Minimizing ${\displaystyle R(t)}$: Subdomain Method

The subdomain method is another way of minimizing the residuals. In this case, instead of letting the residual vanish at unique points, we let the "average" of the residual vanish over each domain. That is, we let,

${\displaystyle {\frac {1}{\Delta t_{i}}}\int _{\Delta t_{i}}R(t)dt=0}$

where ${\displaystyle \Delta t_{i}}$ is the subdomain over which averaging is done. From this definition it is clear that the weighting function for the subdomain method is

${\displaystyle v(t)={\begin{cases}1&{\rm {{if}\;t\in \Delta t_{i},}}\\0&{\rm {{otherwise}.}}\end{cases}}}$

Let us apply the subdomain method to Problem 1. We discretize the domain by choosing one point between ${\displaystyle 0}$ and ${\displaystyle 1}$ at ${\displaystyle t=1/2}$. For the two subdomains (elements) we have,

${\displaystyle {\frac {1}{\Delta t_{1}}}\int _{0}^{\frac {1}{2}}R(t)dt=1+{\frac {5}{4}}a_{1}+{\frac {7}{12}}a_{2}~;\qquad {\text{and}}~\qquad {\frac {1}{\Delta t_{2}}}\int _{\frac {1}{2}}^{1}R(t)dt=1+{\frac {7}{4}}a_{1}+{\frac {25}{12}}a_{2}~.}$

Setting these residuals to zero and solving for ${\displaystyle a_{1}}$ and ${\displaystyle a_{2}}$ we get ${\displaystyle a_{1}=-18/19}$ and ${\displaystyle a_{2}=6/19}$. Therefore the approximate solution is

${\displaystyle {u_{h}(t)=1-{\frac {18}{19}}t+{\frac {6}{19}}t^{2}~.}}$

Figure 2 shows a comparison of the exact solution and the subdomain and the collocation solutions.

 Figure 2. Subdomain solution versus exact solution for Problem 1.

#### Minimizing ${\displaystyle R(t)}$: Galerkin Method

In this case, instead of writing our trial function as,

${\displaystyle u_{h}(t)=1+a_{1}t+a_{2}t^{2}+\dots +a_{n}t^{n}}$

we write it as

${\displaystyle u_{h}(t)=N_{0}(t)+\sum _{i=1}^{n}a_{i}N_{i}(t)}$

where ${\displaystyle N_{0},N_{1},\dots ,N_{n}}$ are ${\displaystyle (n+1)}$ linearly independent functions of ${\displaystyle t}$. These are called basis functions, interpolation functions, or shape functions. The first term ${\displaystyle N_{0}}$ is left outside the sum because it is associated with part or all of the initial or boundary conditions (i.e., we put everything that can be fixed by initial or boundary conditions into ${\displaystyle N_{0}}$).

Then the trial function in equation (7) can be rewritten using basis functions as

${\displaystyle {u_{h}(t)=N_{0}(t)+a_{1}N_{1}(t)+a_{2}N_{2}(t)}}$

where

${\displaystyle {\text{(12)}}\qquad {N_{0}(t)=1~,~~N_{1}(t)=t~,~~{\text{and}}~~N_{2}(t)=t^{2}~.}}$
##### Important:

In the Galerkin method we choose the basis functions ${\displaystyle N_{i}~(i=1\dots n)}$ as the weighting functions.

If we use ${\displaystyle N_{i}(t)}$ as the weighting functions ${\displaystyle v(t)}$, equation (6) becomes

${\displaystyle {\text{(13)}}\qquad {\int _{0}^{1}\left({\frac {du_{h}}{dt}}+u_{h}\right)N_{i}(t)=0\implies \int _{0}^{1}R(t)N_{i}(t)=0,\qquad i=1,2~.}}$

Plugging in the value of ${\displaystyle R(t)}$ from equation (8) into equation (13) and using the basis functions from (12) we get

${\displaystyle \int _{0}^{1}\left[1+a_{1}(1+t)+a_{2}(2t+t^{2})\right]~t~dt=0\quad {\text{and}}\quad \int _{0}^{1}\left[1+a_{1}(1+t)+a_{2}(2t+t^{2})\right]~t^{2}~dt=0~.}$

After integrating and solving for ${\displaystyle a_{1}}$ and ${\displaystyle a_{2}}$ we get ${\displaystyle a_{1}=-32/35}$ and ${\displaystyle a_{2}=2/7}$. Therefore, the Galerkin approximation we seek is

${\displaystyle {u_{h}(t)=1-{\frac {32}{35}}t+{\frac {2}{7}}t^{2}}~.}$

Figure 3 shows a comparison of the exact solution with the Galerkin, subdomain, and collocation solutions.

 Figure 3. Galerkin solution versus exact solution for Problem 1.

All the approximate solutions diverge from the exact solution beyond ${\displaystyle t=1}$. The solution to this problem is to break up the domain into elements so that the trial solution is a good approximation to the exact solution in each element.

#### Minimizing ${\displaystyle R(t)}$: Least Squares Method

In the least-squares method, we try to minimize the residual in a least-squares sense, that is

${\displaystyle {\text{(15)}}\qquad \int _{0}^{1}{\frac {\partial R(t)^{2}}{\partial a_{i}}}~dt=\int _{0}^{1}2~R(t)~{\frac {\partial R(t)}{\partial a_{i}}}~dt=0\equiv {\int _{0}^{1}R(t)~{\frac {\partial R(t)}{\partial a_{i}}}~dt=0}}$

where ${\displaystyle a_{i}=(a_{1},a_{2})}$. The weighting function for the least squares method is therefore

${\displaystyle {v(t)={\frac {\partial R(t)}{\partial a_{i}}}~.}}$

Plugging in the value of ${\displaystyle R(t)}$ from equation (8) into equation (15) and using the basis functions from (12) we get

${\displaystyle \int _{0}^{1}\left[1+a_{1}(1+t)+a_{2}(2t+t^{2})\right]~(1+t)~dt=0\quad {\text{and}}\quad \int _{0}^{1}\left[1+a_{1}(1+t)+a_{2}(2t+t^{2})\right]~(2t+t^{2})~dt=0~.}$

After integrating and solving for ${\displaystyle a_{1}}$ and ${\displaystyle a_{2}}$ we get ${\displaystyle a_{1}=-576/611}$ and ${\displaystyle a_{2}=190/611}$. Therefore, the least squares approximation we seek is

${\displaystyle {u_{h}(t)=1-{\frac {576}{611}}t+{\frac {190}{611}}t^{2}}~.}$

Figure 4 shows a comparison of the exact solution with the Galerkin, subdomain, and collocation solutions.

 Figure 4. Least squares solution versus other solutions for Problem 1.