# FEM solution for Poisson is not exact at nodes

Let's consider the usual Poisson problem for FEM $$-u''(x)=1 \quad x \in [0,1]$$ with homogeneous Dirichlet boundary conditions. The solution is $$u(x)=-\frac{1}{2}x(x-1)$$

I know that the FEM solution (I'm assuming linear elements) is exact at nodes, as noted also here

I implemented my code with constant step size $$h$$. Looking at internal nodes, the stiffness matrix has entry $$(A)_{ij}=\int \phi_i' \phi_j' dx$$ For $$i =j$$ (diagonal elements) I obtain $$A_{ii}=2/h$$, while the extradiagonal are $$A_{i,i-1}=A_{i -1,i}=-1/h$$ .

The load vector has entries $$(f)_i=(1,\phi_i)=h$$ In the end, I obtain the same matrix as with finite differences and hence I would expect second order. Why is exact solution at grid points recovered? (Modulo machine precision)?

The finite difference scheme also gives exact solution at the nodes to the problem $$-u''=1$$ because $$\frac{u_{j-1} - 2 u_j + u_{j+1}}{h^2}$$ is exact for a quadratic function.
For the more general case $$-u''(x) = f(x)$$ if you compute the integral $$(f,\phi_i)$$ exactly in $$P_1$$ FEM, it gives exact solution at the nodes. The FD scheme will not be exact in the general case.
• Another last question: should I expect the exact solution also for the problem $-\alpha(x) u''(x)=f(x)$ with linear elements (assuming that I integrate exactly) both the $(f,\phi_i)$ and $(\alpha(x) \phi_i', \phi_j')$ ? @cfdlab – bobinthebox Mar 1 at 16:44
• For this particular problem you consider, if you use P2 FEM, you actually would find the exact solution $u_h=u=0.5x(1-x)$. In general, if the exact solution and the source function are sufficiently smooth, and if you evaluate the bilinear and linear forms exactly, you would expect the numerical solution and the exact solution to match at the nodes. (See interpolatory properties of continuous Galerkin FEMs) – Abdullah Ali Sivas Mar 1 at 16:45
• @AbdullahAliSivas Regarding my last question: is it possible that I'm seeing first order of convergence with linear elements for the problem $-\alpha(x)u''(x)=f(x)$ for $\alpha,f$ smooth functions like $\sin$ and $\cos(x)$? – bobinthebox Mar 1 at 16:49
• @bobinthebox, you need to be careful with $\alpha(x)$, it has to be positive everywhere in the domain for the problem to be well-defined. Other than that, the integration technique you use should be sufficiently high-degree and usually higher than twice the degree of the FEM (if $\sin$ and $\cos$ are involved with P1, I would probably use Simpson's method, for example) to guarantee optimal convergence rates. – Abdullah Ali Sivas Mar 1 at 16:54