= Solution
Take a uniform <finite element mesh> $x_i=ih$, $0\leq i\leq J$, $h=1/J$, and interior <piecewise-linear hat functions> $\phi_i$. Write $u_h=\sum_{i=1}^{J-1}U_i\phi_i$. The <Ritz method> gives $KU=F$ with
$$
K_{ij}=\int_0^1\phi_i'\phi_j'\,dx+\int_0^1x\phi_i\phi_j\,dx,
\qquad F_i=-\int_0^1\phi_i\,dx=-h.
$$
The derivative part has diagonal $2/h$, neighboring entries $-1/h$ and zero other entries. For the <affine-weighted hat mass matrix>, symmetry around $x_i$ gives
$$
\int x\phi_i^2\,dx=\frac{2h}{3}x_i.
$$
On $[x_i,x_{i+1}]$, the product of the two hats is symmetric about the midpoint, integrates to $h/6$, and therefore has weighted integral
$$
\int x\phi_i\phi_{i+1}\,dx=\frac h{12}(x_i+x_{i+1}).
$$
Consequently the explicit <tridiagonal> equations are
$$
\boxed{\left[-\frac1h+\frac h{12}(x_{i-1}+x_i)\right]U_{i-1}
+\left[\frac2h+\frac{2h}3x_i\right]U_i
+\left[-\frac1h+\frac h{12}(x_i+x_{i+1})\right]U_{i+1}=-h,}
$$
for $1\leq i\leq J-1$, with $U_0=U_J=0$. 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 $U^TKU=a(u_h,u_h)>0$, 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 $h_i=x_i-x_{i-1}$, the corresponding entries are
$$
K_{ii}=\frac1{h_i}+\frac1{h_{i+1}}
+\frac{h_i}{12}(x_{i-1}+3x_i)
+\frac{h_{i+1}}{12}(3x_i+x_{i+1}),
$$
$$
K_{i,i+1}=-\frac1{h_{i+1}}+
\frac{h_{i+1}}{12}(x_i+x_{i+1}),\qquad
F_i=-\frac{h_i+h_{i+1}}2,
$$
with symmetric lower entries. These reduce to the displayed uniform-grid system.
Back to article page