# Galerkin methods#

In the previous section, we observed that we can approximate a known function \(g\) by a set of piecewise polynomial functions \(\phi_i\).

We did not go much detail about how these functions would look like. In this section, we look at this is some more detail.

We start by looking at an interval, subdivided into a set of elements.
For each of these segments, we will define a **local** basis function and a set of **global** basis functions.

## Composition of \(u_h\)#

Given a finite dimensional function space \(V_h\), with basis functions \(\phi_i, i=0,\dots,N-1\), we can write any function \(u_h\) in \(V_h\) as

where \(u_i\) are the coefficients of function. These coefficients are also known as the degrees of freedom DOFs of the function.

## Choice of basis functions#

We can do the same thing for a higher order set of polynomials

However, in the setting of a PDE, we do not know the solution \(u\).

In this section, we will explain how to find the solution \(u\) to a PDE using the Galerkin method.

We will consider the Poisson equation in 1D as a starting point

We rewrite the equation above as a residual

**Goal is to find a \(u\) such that \(R(u)=0\)**.

If we substitute \(u_h\) into the Poisson equation, we get

Does this equation make sense for piecewise linear polynomials?

As the double derivative of a linear function is \(0\), we cannot directly solve this equation!

We want to weaken the requirement of the equality

Inner product:

With this, we want to find a \(u_h\) such that

Reconsidering the equation above, we have

Integrate by parts

## The bilinear and linear form#

We define the **bilinear form** \(a(u,v)\)

and the **linear form** \(L(v)\)

We can now insert our expansion of \(u_h\) (where each \(u_i\) is to be determined)

By choosing \(v=\phi_0, \dots, \phi_{N-1}\), we can set up a linear system

where

## Galerkin orthogonality#

A key property of this method is that if \(a(u_h, v) = L(v)\), then the error between the exact solution \(u\) and \(u_h\), given as \(\epsilon=u-u_h\) has the following property:

Thus the error is orthogonal to the chosen sub-space

## Questions#

How does the matrix \(A\) look like? Is it dense or sparse?

The matrix will be sparse, as the support (function being non-zero) of \(\phi_i\) and \(\phi_j\) is localized to adjacent elements.

Does the Galerkin orthogonality property say something about the quality of the solution?

The Galerkin orthogonality states that you get the best approximation in the chosen function space. However, with a poor choice of function space, the error can be large.

How can we compute the integral \(\int_\Omega \frac{\partial \phi_i}{\partial x}\frac{\partial \phi_j}{\partial x}~\mathrm{d} x\)?

We split the domain \(\Omega\) into non-overlapping elements \(k\in \mathcal{K}\) such that \(\cup_{k\in\mathcal{K}} k = \Omega\) where \(\phi_i\) and \(\phi_j\) are continuous on each section, and use that \(\int_{\Omega} h~\mathrm{d}x = \sum_{k\in\mathcal{K}} \int_{k}h~\mathrm{d}x\).