Motivation
A differential equation can be difficult to solve point by point when its coefficients or solution have limited smoothness, or when the domain has a complicated shape. A weak formulation asks instead that an integrated residual vanish against suitable test functions. Finite elements then replace an infinite-dimensional function space by a finite-dimensional space whose basis functions are local. Integration and linear algebra convert the problem into a sparse system.
We use a one-dimensional problem to expose every step. The model, function space, boundary conditions, and quadrature are all part of the method. A matrix obtained from one problem should not be transferred blindly to another.
Definitions
Definition 3.1.1
(Model and weak solution)
Let . Seek satisfying on and . The weak problem is: find such that
Here consists of square-integrable functions with square-integrable weak derivative and zero boundary trace. Derivatives in the integrals are weak derivatives.
For a twice continuously differentiable solution, multiply by a smooth test function vanishing at endpoints and integrate by parts. The boundary term vanishes, giving the weak equation. Conversely, a sufficiently smooth weak solution satisfies the differential equation in the interior and the specified boundary values. A weak solution need not possess a classical second derivative everywhere; the formulation remains meaningful with only a square-integrable first derivative.
Choose nodes and let consist of continuous functions that are linear on each interval and vanish at both endpoints. The basis function has value one at interior node , zero at all other nodes, and is linear between adjacent nodes. These hat functions overlap only with immediate neighbors. The Galerkin approximation is satisfying for every . Testing the basis gives with and .
Main results
Theorem 3.1.2
(Existence, uniqueness and energy minimization)
For , the weak problem has a unique solution. Its Galerkin approximation exists uniquely and minimizes over .
Proof
(Coercivity, Lax–Milgram and the energy expansion)
The Poincaré inequality bounds by a constant times for ; hence is continuous and coercive in the norm, while Cauchy–Schwarz makes continuous. The Lax–Milgram theorem gives the unique weak solution. On , forces almost everywhere, hence by the boundary condition. The finite stiffness matrix is therefore symmetric positive definite and invertible. For any , expanding and using the Galerkin equation gives , with equality only for .
Theorem 3.1.3
(Galerkin orthogonality and best energy approximation)
With , the error satisfies for all and
Proof
(Orthogonality removes the cross term)
Subtract the Galerkin equation from the weak equation restricted to . For any , write . Orthogonality removes the cross term in the squared energy norm, giving . The minimum occurs at .
Proof X-ray
Where best approximation comes from
The proof has two dependencies. First, both and satisfy the same weak equation when tested with a function in ; subtraction gives orthogonality. This uses conformity, , so that is an admissible test function for , and exact evaluation of and . Second, the symmetric positive-definite form is an inner product, so expanding a squared norm produces the usual cross term . The key move is to split at , so that the second piece lies in and orthogonality removes precisely that cross term, leaving a sum of two squares. If the trial and test spaces or forms differ, or the form is not symmetric, this Pythagorean argument does not apply; a different stability estimate is needed, and it typically bounds the error by a constant times the best approximation error rather than by the best error itself.
This identity uses the same symmetric bilinear form to define both the approximation and the energy norm. It is not a universal statement that every discretization gives the best pointwise approximation.
Worked examples
Worked example 3.1.4
(Assemble two linear elements)
Use nodes and . There is one interior hat : its derivative is on the first element and on the second. Thus and . Therefore . The exact solution has value at the middle node, although its quadratic graph is not equal to the piecewise-linear approximation between nodes.
Worked example 3.1.5
(Local-to-global assembly)
On an element of length , the two local basis derivatives are and . Their local stiffness matrix is
For three equal elements, , summing shared-node contributions and removing boundary degrees of freedom gives . With , each interior load is the area of a hat, . The system gives , matching the exact solution at those two nodes.
Worked example 3.1.6
(A nonzero boundary value changes the load)
Suppose instead , , , on the two-element mesh. The full assembled equation for the middle node is . Substituting and yields , so . Simply deleting the boundary columns without moving their known contributions to the right-hand side would give the wrong answer.
Methods and reasoning
Locality is the computational advantage. On an element, only the two adjacent basis functions are nonzero, so its matrix is added into the corresponding global rows and columns. The load must also be integrated. If is not constant, numerical quadrature may be used, but then the assembled method solves a perturbed variational problem; quadrature error must be included in an accuracy analysis. Boundary conditions must be imposed consistently. For a prescribed nonzero boundary value, a lifting function can reduce the problem to zero boundary values, or known nodal contributions can be moved to the load as in the example.
Suppose additionally and let be the maximum element length. Standard one-dimensional interpolation estimates give , with independent of the mesh size. Since , the best-approximation theorem gives . This is an energy-norm upper bound under the stated regularity, not an exact error or a universal pointwise rate. Coefficient jumps, singularities, inexact quadrature, and different boundary conditions need additional analysis. Refining a mesh cannot increase the best approximation error for nested spaces, but numerical conditioning and work can worsen.
For general diffusion with almost everywhere and bounded , replace by . Coercivity remains valid. Removing the boundary conditions altogether changes the problem: with pure Neumann data, constants lie in the kernel, compatibility of forcing and boundary flux is required, and an additional normalization fixes the additive constant. A singular matrix in that setting can reflect the mathematics rather than a coding error.
Deriving the element entries
On , write and . Their values interpolate the two nodal coefficients exactly. Differentiating gives constant slopes and . For example, the off-diagonal entry is . The diagonal entries are . Each local matrix annihilates the constant vector , because a constant function has zero derivative. A single local matrix is therefore positive semidefinite, not positive definite. Global zero boundary values remove the constant mode and make the assembled interior matrix positive definite.
For constant forcing , each local load entry equals , the area under a triangular shape function times . An interior node receives contributions from both adjacent elements. On a nonuniform mesh its load is , and its stiffness diagonal is . Thus the uniform tridiagonal formula is a special case, not a rule to use on an arbitrary mesh. Assembling with a local-to-global index table makes shared-node addition explicit.
The energy error in a complete example
For and two equal elements, and is the hat function multiplied by . On the first element, and . The local squared energy error is
Symmetry gives the same value on the second element, hence total squared error . Notice that the nodal error is zero even though the energy error is positive. Nodal agreement here comes from a special feature of one-dimensional constant-coefficient problems, explained below, not from a general finite-element guarantee. For nonconstant forcing, computing the load exactly is essential even to make such comparisons meaningful.
Boundary terms are part of the model
Integration by parts gives for a smooth solution. In our original problem vanishes at both ends, so the boundary term disappears. If instead and , test functions vanish only at zero and the weak equation becomes . The endpoint value is a natural boundary term in the load; it is not imposed by setting a nodal value. Signs for an outward flux depend on the chosen differential operator and normal convention and should be derived from the integration-by-parts identity.
If only derivative data are prescribed at both endpoints, taking in the weak formulation gives the compatibility condition. For , , , it is . The Dirichlet Poincaré argument cannot be applied unchanged to this space because constants have zero derivative.
Counterexample mode
Dropping the Dirichlet condition loses existence and uniqueness
Claim: for every the problem , has exactly one weak solution in , that is, for all . For , the test function gives on the left and on the right, so no solution exists. For , every constant satisfies the equation, so solutions are not unique. The repaired statement requires the compatibility condition, here , and fixes the constant by a normalization such as ; the difference of two normalized solutions has zero derivative and zero mean, hence vanishes.
Approximation and algebraic error
The computed coefficient vector may be an approximation to the exact discrete vector . With , the triangle inequality separates into discretization error and algebraic error . The first is controlled by approximation and regularity; the second depends on the linear solver and its stopping rule. Solving more accurately cannot remove the first error, and refining the mesh without solving the resulting system adequately does not guarantee the expected total accuracy.
Mesh refinement also changes the matrix. For the uniform one-dimensional stiffness matrix, the largest eigenvalue grows on the scale and the smallest on the scale , so its spectral condition number grows on the scale . This statement concerns the usual Euclidean coefficient norm; scaling or preconditioning changes the linear algebra representation. It explains why a smaller mesh may demand more care from an iterative solver even as the approximation space improves.
Why the load integral matters
With the two-element mesh and , the middle load is not obtained by taking the midpoint value alone without a stated rule. Direct integration gives
The stiffness remains , hence . Here a midpoint evaluation times the hat area happens to give the same result by symmetry, but that coincidence does not hold for arbitrary or an asymmetric mesh. For the exact value is , whereas midpoint evaluation times the hat area gives . A quadrature choice should be recorded and checked against the desired degree of accuracy.
The load is a functional, not generally a list of point values. This distinction becomes especially useful for weak data: even when a forcing term has limited smoothness, integration against a test function may still be well defined. In contrast, evaluating that forcing at an isolated node may be undefined or not represent its equivalence class in . The weak formulation explains which data the problem needs.
Common misconceptions
Weak does not mean inaccurate: it specifies the sense in which the equation is satisfied.
Common mistake
(Testing a piecewise-linear function element by element)
A piecewise-linear function has a piecewise constant first derivative and generally has derivative jumps at nodes. Its classical second derivative is zero inside every element, so inserting it into element by element would suggest and misses the nodal contributions. The integrated formulation, tested against hat functions, is the correct test.
Common mistake
(Reading nodal agreement as equality between nodes)
In the first example , yet the squared energy error is . Agreement at selected nodes does not prove equality between nodes, and in general it does not even hold at the nodes.
Common mistake
(Treating a small residual as a small error)
A small algebraic residual for measures how well the discrete system was solved. It says nothing by itself about the discretization error , which is controlled by the approximation space and the regularity of .
Quick check
Quick check
(On an element of length , what diagonal stiffness entry does one linear basis function contribute, and why is the off-diagonal entry negative?)
Solution · Answer
The basis slope is , so the diagonal contribution is . The off-diagonal entry is : it is negative because the two local basis functions have opposite slopes, not because any energy is negative.
Exercises
Quick check
(For the two-element mesh and , find and compare its middle-node value with the exact solution.)
Solution · Answer
The stiffness is and the load is , hence the middle value is . The exact solution has the same middle value; is the corresponding hat times .
Quick check
(On a uniform mesh with four elements of length , write the interior stiffness matrix.)
Solution · Answer
Each interior diagonal receives two contributions and each adjacent off-diagonal receives . Thus .
Quick check
(Show directly that the energy norm of a nonzero is positive.)
Solution · Answer
If , its derivative vanishes on every element, so continuity makes it constant throughout the interval. Its zero endpoints force this constant to be zero, contrary to the hypothesis.
Quick check
(With on , compute the exact energy error of the two-element approximation from the first example.)
Solution · Answer
The exact derivative is ; the numerical derivative is on and on . The squared error is , so the energy error is .
Further study
Higher-order elements, two-dimensional meshes, variable coefficients, natural boundary conditions, adaptive estimators and solver preconditioning require further work. The one-dimensional construction demonstrates the method but does not constitute complete finite-element coverage.