# How to compute the $L^{2}$ error of the gradient in the Finite Element Method

Let $$\Omega\subset \mathbb{R}^{2}$$ and $$\tau_{h} = \{\Omega_{k}\}_{k=1}^{N}$$ be a triangulation of $$\Omega$$. The $$L^2$$ error for a FEM approximation $$u_{h}$$ is given by:

$$|| u-u_{h} ||_{L^2} = \sqrt{ \int_{\Omega} \left( u-u_{h} \right)^2 } = \sqrt{ \sum_{k=1}^{N} \int_{\Omega_{k}} \left( u-u_{h}^{k} \right)^2 }$$.

Where $$u_{h}^{k}$$ is the approximation in the element $$\Omega_{k}$$. Suppose that I also have an approximation $$q_{h} = ( q_{1h}, q_{2h} )$$ for the gradient $$q = ( q_{1}, q_{2} ) = \nabla u$$.

My question is: how do you compute the $$L^{2}$$ error for the gradient? i.e, $$|| q-q_{h} ||_{L^2} =$$ ?

I was thinking in something like $$|| q-q_{h} ||_{L^2} = \sqrt{\int_{\Omega} \left( q_{1}-q_{1h}^{k} \right)^2+\int_{\Omega} \left( q_{2}-q_{2h}^{k} \right)^2 }$$, but I'm not sure if it is correct. Thanks!

Like any other integral, you evaluate the error integral through quadrature. Your suggestion at the end of the question is exactly what you would do: The norm of the gradient error square is a sum of two integrals (or one integral whose integrand is a sum of two terms) which you would evaluate through quadrature. That is, you will have to evaluate the two components of $$q$$ and $$q_h$$ at quadrature points on each cell, multiply by the quadrature weights of these points, and sum up.