Choose a partition , with the usual nodal piecewise-linear hat functions , including the half hats at the endpoints. Write with . Differentiating the Ritz method energy with respect to , , gives
On an element of length , its two basis functions are and . Direct integration yields the element matrix
For example the first weighted diagonal is ; the off-diagonal is . This gives the affine-weighted hat mass matrix and explicit equations on any partition by assembling adjacent elements.
For the uniform choice , , the assembled interior equations are
The last node contributes only one element, so its equation is
In the first interior equation the known term moves to the right, giving . For only the endpoint equation is needed. The last row enforces the weak Neumann boundary condition, so no artificial value outside the interval is introduced. The matrix on is a symmetric positive-definite matrix: its quadratic form is for every nonzero trial variation . The discrete minimizer is therefore unique.
Take a uniform finite element mesh , , , and interior piecewise-linear hat functions . Write . The Ritz method gives with
The derivative part has diagonal , neighboring entries and zero other entries. For the affine-weighted hat mass matrix, symmetry around gives
On , the product of the two hats is symmetric about the midpoint, integrates to , and therefore has weighted integral
Consequently the explicit tridiagonal equations are
for , with . The reaction coefficient has been integrated exactly; replacing it by an unweighted constant mass matrix would give a different system. For a nonzero coefficient vector, the represented function is nonzero and , so the matrix is symmetric positive-definite and the algebraic solution is unique.
Uniform spacing is a choice, not a requirement of the method. On a general finite element mesh with , the corresponding entries are
with symmetric lower entries. These reduce to the displayed uniform-grid system.
Put and . The interior piecewise-linear hat functions are
They are a basis of the continuous piecewise-affine functions vanishing at both endpoints. The support of a function for each hat only overlaps those of neighbouring hats, so the stiffness matrix is a tridiagonal matrix. Direct integration gives the derivative contribution on the diagonal and on adjacent diagonals.
For the potential contribution, symmetry about gives . On the overlap of and , their product is symmetric about , and its integral is . This is the affine-weighted hat mass matrix calculation. Consequently,
and all other entries vanish. The exact right-hand side is
Thus, with , the requested scalar equations are
At the endpoints the coefficient multiplying the zero boundary value is simply omitted. Since , its point values are not even well defined; replacing by would require an additional quadrature rule convention and regularity hypothesis, not present here. The exact Ritz method uses the displayed integrals. The finite element interpolation estimate and Céa lemma, using , give an energy norm error; the Aubin–Nitsche duality argument gives in the L2 norm on this interval.