# Finite element error for second order ODE at nodes equal to zero

I coded a finite element method with linear basis elements for the problem $$-u'' = f(x), x\in[0,1], u(0) = u(1) = 0$$ The nodes are uniformly spaced and I will denote them as $x_i$. I initially calculated the error of my method as $$\text{error} = \max_i |u(x_i) - \hat{u}(x_i)|$$ where $\hat{u}$ denotes the FEM solution. I kept getting approximately 0 as the error, and I'm thinking that's because the FEM solution interpolates the exact solution $u$ at the nodes $x_i$.

I then went back and got an approximation for $$\max_{x\in[0,1]} |u(x) - \hat{u}(x)|$$ and I got second-order convergence (as expected).

My question is does the FEM (with linear/quadratic/cubic piecewise basis functions) always give back an interpolation of the exact solution, and so should I expect an error of zero at the nodes?

• What is the expression for $f(x)$? Jun 21 '16 at 2:12
• I too have observed FEM yielding slightly better accuracy than in the interior of the elements. It doesn't always happen, nor does it necessarily yield error within floating point precision when it does happen. I think bill barth is right in that it is a special circumstance that occaisionally happens in numerical computation called 'superconvergence'. I don't remember the precise reason why it happens. It may have sonething to do with the function f that you chose. What was f in this case?
– Paul
Jun 21 '16 at 2:17
• I tried a few different functions for $f$. First was $f\equiv 2$, which has the exact solution of $u(x) = (1-x)x$. Then I tried $f(x) = -e^x (x^4 + 6x^3 + x^2 - 8x + 2)$, which has an exact solution of $u(x) = e^x (1-x)^2 x^2$. For both of them, the error was somewhere around $10^{-14}$.
– Kurt
Jun 21 '16 at 2:38
• Yes, for this problem, the solution is exact at the nodes provided your integrals in the weak formulation are exact. This is a nice assignment/exam question. Jun 21 '16 at 3:50

For this simple elliptic PDE, the finite-element approximation is indeed exact at the nodes (i.e., coincides with the true solution); this is usually called superconvergence (at the nodes).

Since it's such a nice homework problem, instead of the (simple) proof, here's a hint: Use the weak formulation with a hat function centered on $x_i$ as a test function, Galerkin orthogonality, and partial integration.

• @ChristianClason, I don't have time to dig up the books necessary. Feel free to edit or add your own answer that is better or doesn't make the robots sad. Jun 21 '16 at 13:46
• @ChristianClason, I that's a great edit, but I think you only left me with two definite articles. Maybe it'd be better in your own name? Jun 21 '16 at 13:56
• @ChristianClason, done. Maybe someone else will give the full proof as you outlined. Jun 21 '16 at 14:01
• Thanks! I think that's the same proof I had in mind, and I'm having a go at it right now.
– Kurt
Jun 21 '16 at 14:28
• I've mostly read things on Stackexchange and haven't posted much, so I'm not sure what I should do here. I wrote a proof, so should I post it as an answer and get feedback? Or should I edit my post?
– Kurt
Jun 21 '16 at 14:57