# Introduction to finite elements/Finite element basis functions

## Finite Element Basis Functions

The Finite Element Method provides a general and systematic technique for constructing basis functions for Galerkin's approximation of boundary value problems.

The idea of finite elements is to choose $N_i$ piecewise over subregions of the domain called finite elements. Such functions can be very simple, for example, polynomials of low degree. We measure the size of each subregion with a parameter $h$. As $h$ decreases more elements are introduced and more basis functions are needed. The square integrability condition implies that jumps in the value of the function are not allowed at the nodes.

The simplest basis functions are piecewise linear functions and the corresponding elements are line segments in 1D, triangles and quadrilaterals in 2D, and tetrahedra, prisms and hexahedra in 3D.

These basis functions have to be chosen from the space $\mathcal{H}^n_0$. Let $\Omega_n$ be the space of piecewise linear functions. It can be shown that $\Omega_n \subset \mathcal{H}^n_0$.

Let

$0 = x_0 < x_1 < x_2 < \dots < x_n < x_{N+1} = 1$

be a partition of $[0,1]$ into subintervals $I_j = x_j, x_{j+1}$ of length

$\Delta x_j = x_{j+1} - x_{j}, \qquad j=1, 2, \dots, N+1$

Let $h = \max(h_j)$ be a measure of overall fineness of the grid. Let us choose as basis functions the set of triangular functions shown in Figure 1.

 Figure 1. Finite element basis functions.

In algebraic form, these basis functions are defined as

$\text{(25)} \qquad { N_j(x) = \begin{cases} \cfrac{x - x_{j-1}}{x_j - x_{j-1}}, & x_{j-1} \le x \le x_j \\ \cfrac{x_{j+1} - x}{x_{j+1} - x_j}, & x_j \le x \le x_{j+1} \\ 0 & \text{otherwise} \end{cases} }$

Note that the shape functions also satisfy the following,

${ N_i(x_j) = \delta_{ij} = \begin{cases} 1, & \text{at nodes } i = j. \\ 0, & \text{at nodes } i \ne j. \end{cases} }$

The first derivatives of the basis functions are

$\text{(26)} \qquad { \frac{dN_j(x)}{dx} = \begin{cases} \cfrac{1}{x_j - x_{j-1}}, & x_{j-1} \le x \le x_j \\ -\cfrac{1}{x_{j+1}-x_j}, & x_j \le x \le x_{j+1} \\ 0 & \text{otherwise} \end{cases} }$

So there are discontinuities in the first derivatives at $x = x_j$ as you can see in Figure 2.

 Figure 2. Derivatives of finite element basis functions.

The Galerkin trial solution is

$u_h = N_0 + \sum^{n}_{i=1} a_i N_i$

where $n$ is the number of nodes in an element. If we have two nodes per element as shown in Figure 2, then within each element we have

${ u^e_h = a_1 N_1^e + a_2 N_2^e~. }$

The basis functions $N_i^e$ are the element (or local) basis functions and are to be distinguished from the global basis functions centered around nodes.

If you look at the element that joins node $x_j$ to node $x_{j+1}$ you will see that there are two functions $N_j$ and $N_{j+1}$ that describe this element. The local basis functions for the element are therefore

$N_1^e = \frac{x_{j+1} - x}{x_{j+1} - x_j} \qquad \text{and} \qquad N_2^e = \frac{x - x_j}{x_{j+1} - x_j} ~.$

Hence we can write

$u^e_h = a_1 \left(\frac{x_{j+1} - x}{x_{j+1} - x_j}\right) + a_2 \left(\frac{x - x_j}{x_{j+1} - x_j}\right)$

If we force the solution $u^e_h$ to be equal to $u_j$ at $x = x_j$ and $u_{j+1}$ at $x = x_{j+1}$, we get $a_1 = u_j$ and $a_2 = u_{j+1}$.

Therefore, the solution is approximated by the piecewise linear function,

${ u^e_h = u_j \left(\frac{x_{j+1} - x}{x_{j+1} - x_j}\right) + u_{j+1} \left(\frac{x - x_j}{x_{j+1} - x_j}\right) }$

We could also write

$u^e_h = (1-t)~u_j + t~u_{j+1} \qquad \text{where}~ t =\left(\frac{x - x_j}{x_{j+1} - x_j}\right)~.$

This a parametric representation of a line and shows very clearly that $u^e_h$ is a linear approximation. Figure 3 shows a schematic of a FE solution using linear shape functions.

 Figure 3. Schematic of a finite element solution computed using linear shape functions.