When approximating \(f\) by \(u = \sum_j c_j{\varphi}_j\), the least squares method and the Galerkin/projection method give the same result. The interpolation/collocation method is simpler and yields different (mostly inferior) results.

Fourier series expansion can be viewed as a least squares or Galerkin approximation procedure with sine and cosine functions.

Basis functions should optimally be orthogonal or almost orthogonal, because this gives little round-off errors when solving the linear system, and the coefficient matrix becomes diagonal or sparse.

Finite element basis functions are

piecewisepolynomials, normally with discontinuous derivatives at the cell boundaries. The basis functions overlap very little, leading to stable numerics and sparse matrices.To use the finite element method for differential equations, we use the Galerkin method or the method of weighted residuals to arrive at a variational form. Technically, the differential equation is multiplied by a test function and integrated over the domain. Second-order derivatives are integrated by parts to allow for typical finite element basis functions that have discontinuous derivatives.

The least squares method is not much used for finite element solution of differential equations of second order, because it then involves second-order derivatives which cause trouble for basis functions with discontinuous derivatives.

We have worked with two common finite element terminologies and associated data structures (both are much used, especially the first one, while the other is more general):

elements,nodes, andmapping between local and global node numbers- an extended element concept consisting of
cell,vertices,degrees of freedom,local basis functions,geometry mapping, andmapping between local and global degrees of freedomThe meaning of the word “element” is multi-fold: the geometry of a finite element (also known as a cell), the geometry and its basis functions, or all information listed under point 2 above.

One normally computes integrals in the finite element method element by element (cell by cell), either in a local reference coordinate system or directly in the physical domain.

The advantage of working in the reference coordinate system is that the mathematical expressions for the basis functions depend on the element type only, not the geometry of that element in the physical domain. The disadvantage is that a mapping must be used, and derivatives must be transformed from reference to physical coordinates.

Element contributions to the global linear system are collected in an element matrix and vector, which must be assembled into the global system using the degree of freedom mapping (

dof_map) or the node numbering mapping (elements), depending on which terminology that is used.Dirichlet conditions, involving prescribed values of \(u\) at the boundary, are implemented either via a boundary function that take on the right Dirichlet values, while the basis functions vanish at such boundaries. In the finite element method, one has a general expression for the boundary function, but one can also incorporate Dirichlet conditions in the element matrix and vector or in the global matrix system.

Neumann conditions, involving prescribed values of the derivative (or flux) of \(u\), are incorporated in boundary terms arising from integrating terms with second-order derivatives by part. Forgetting to account for the boundary terms implies the condition \(\partial u/\partial n=0\) at parts of the boundary where no Dirichlet condition is set.