For simplicity, we will first consider the Poisson problem on some domain Ω, subject to the boundary conditionu = 0 on the boundary of Ω. To discretize this equation by the finite element method, one chooses a set of basis functions defined on Ω which also vanish on the boundary. One then approximates The coefficients u1,..., un are determined so that the error in the approximation is orthogonal to each basis functionφi: The stiffness matrix is the n-element square matrix A defined by By defining the vector F with components Fi =, the coefficients ui are determined by the linear systemAU = F. The stiffness matrix is symmetric, i.e. Aij = Aji, so all its eigenvalues are real. Moreover, it is a strictly positive-definite matrix, so that the system AU = F always has a unique solution. Note that the stiffness matrix will be different depending on the computational grid used for the domain and what type of finite element is used. For example, the stiffness matrix when piecewise quadratic finite elements are used will have more degrees of freedom than piecewise linear elements.
The stiffness matrix for other problems
Determining the stiffness matrix for other PDE follows essentially the same procedure, but it can be complicated by the choice of boundary conditions. As a more complex example, consider the elliptic equation where A = akl is a positive-definite matrix defined for each point x in the domain. We impose the Robin boundary condition where νk is the component of the unit outward normal vectorν in the k-th direction. The system to be solved is as can be shown using an analogue of Green's identity. The coefficients ui are still found by solving a system of linear equations, but the matrix representing the system is markedly different from that for the ordinary Poisson problem. In general, to each scalar elliptic operatorL of order 2k, there is associated a bilinear formB on the Sobolev spaceHk, so that the weak formulation of the equation Lu = f is for all functions v in Hk. Then the stiffness matrix for this problem is
Practical assembly of the stiffness matrix
In order to implement the finite element method on a computer, one must first choose a set of basis functions and then compute the integrals defining the stiffness matrix. Usually, the domain Ω is discretized by some form of mesh generation, wherein it is divided into non-overlapping triangles or quadrilaterals, which are generally referred to as elements. The basis functions are then chosen to be polynomials of some order within each element, and continuous across element boundaries. The simplest choices are piecewise linear for triangular elements and piecewise bilinear for rectangular elements. The element stiffness matrixA for element Tk is the matrix The element stiffness matrix is zero for most values of i and j, for which the corresponding basis functions are zero within Tk. The full stiffness matrix A is the sum of the element stiffness matrices. In particular, for basis functions that are only supported locally, the stiffness matrix is sparse. For many standard choices of basis functions, i.e. piecewise linear basis functions on triangles, there are simple formulas for the element stiffness matrices. For example, for piecewise linear elements, consider a triangle with vertices,,, and define the 2×3 matrix Then the element stiffness matrix is When the differential equation is more complicated, say by having an inhomogeneous diffusion coefficient, the integral defining the element stiffness matrix can be evaluated by Gaussian quadrature. The condition number of the stiffness matrix depends strongly on the quality of the numerical grid. In particular, triangles with small angles in the finite element mesh induce large eigenvalues of the stiffness matrix, degrading the solution quality.