About the discrete $H^1$ norm

I need to understand what is the right expression for the "discrete $$H^1$$-norm of a function v(which of course need to be in $$H^1$$).

By definition, $$||v||_{H^1}^2 = ||\nabla v||_{2}^2 + ||v||_2^2$$

so far I'm still in the continuous case. In practice if I need to compute it I have to do the discrete $$L^2$$ norm of the gradient and of $$v$$.

For $$v$$ I have: $$||v||_2^2 = h \sum_{i=0}^{N} v(x_i)^2$$

But what about the $$||\nabla v||_2^2$$? How can I approximate it?

• That definition for $\|v\|_2$ (which I assume to mean the $L^2$ norm) doesn't make sense because point values are not unique for $L^2$ functions and, hence, $v(x_i)$ doesn't make sense. Also, what is $x_i$ in your definition? – knl Jan 26 '20 at 11:17
• But I am in a discrete setting, because usually $v(x_i)$, or better $v_i$ are elements of the vector $v$ that comes from a numerical method – Vefhug Jan 26 '20 at 11:21
• Which numerical method are you talking about? In finite element methods, as we have $\|v\|_2^2 = \int_\Omega v^2 \,\mathrm{d}x$, in the discrete setting we usually evaluate $\|v\|_2^2 = \sum_{K \in \mathcal{T}_h} \|v\|_{2,K}^2$ where $\mathcal{T}_h$ is a set of non-overlapping elements and $v|_K$ is polynomial so the norm is easy to evaluate explicitly and exactly. – knl Jan 26 '20 at 11:26
• For example finite differences, let's say I solve the equation and want to compute the error w.r.t the analytical solution $f$. I have just the values at points $x_i$, call them $v_i$. So I consider the error vector $\vec{e} =( v_i - f(x_i))_i$ I want now to compute the discrete $H^1$ norm of this vector – Vefhug Jan 26 '20 at 11:28
• It seems like you are working in a finite difference/finite volume method. You can use a finite difference approximation for the gradient. E.g., see this book springer.com/gp/book/9781447154594 or lecture notes on website of Prof. Endre Suli people.maths.ox.ac.uk/suli/nspde.pdf which shows how to work with discrete Sobolev norms. – cfdlab Jan 26 '20 at 11:31

Assuming 1-D and equidistant gridpoints with spacing $$h$$ and some form of homogenous boundary conditions, we can use $$\|\nabla v\|^2\approx -h\sum_{i=1}^nv(x_i)D_2v(x_i)$$, where $$D_2$$ is a finite difference discretization of the Laplacian operator, which is usually some variant of a tridiagonal matrix with values $$(1,-2,1)/h^2$$ along the sub/main/super diagonal, respectively. I'm pretty sure this approximation is $$O(h)$$. This formula comes from integration by parts:
$$-\int_\Omega v\Delta vdx = \int_\Omega\|\nabla v\|^2dx-\int_{\partial\Omega}v\nabla v\cdot dS.$$ Any boundary conditions that make the boundary terms disappear will make this approximation work. This can also be extended to higher dimensions as long as you can approximate the Laplacian and the integral well, which are usually not too hard if you are already discretizing things in some sort of scheme.