# Approximating functions in $H_0^1(\Omega)$ by piecewise affine ones.

I'm trying to understand how one approximates functions in $H_0^1(\Omega)$ by piecewise affine functions. The normal construction I have seen begins by breaking up your domain $\Omega$ into cubes $Q_i$ and on each $Q_i$ defining an averaged gradient $\frac{1}{|Q_i|} \int_{Q_i} Du =: \xi_i$. I can see why this approximates $Du$ well in the $L^2$ norm, but why can we then conclude that have in fact an $H_0^1(\Omega)$ function?

In other words, how can we "glue" the different affine pieces together? How do we know we can even do this? My first guess was to think in two dimensions and consider a cube and the four cubes adjacent to it. So let $\xi_1$ be the value of the gradient in the 'center cube'. Then if $\xi_2$ is the gradient on the piece on top, then I think we need to make the boundary normal to $\xi_1 - \xi_2$ so that we can have a continuous function across the boundary. I then suppose we need to do the same for the other pieces.

Is there a clearer way of seeing what is going on/how to do this?

-

Certainly, a piecewise affine function $f$ (meaning, a function which is affine on each open simplex of some triangulation of the domain) is in $W^{1,\\ p}_{loc}$ for some $1\leq p\leq \infty$ if and only if it is continuous (the discontinuity set would be otherwise too large, a hypersurface). In particular, you really need your approximating function to be continuous, in order to be of class $H^1$. On the other hand, continuous functions that are affine on each cube of a cubic subdivision, are too a rigid class: they are of the form $f(x_1,\dots,x_n)=\phi_1(x_1)+\dots+\phi_n(x_n)$, with $\phi_i$ some continuous piecewise affine functions of one variable. If you instead consider general continuous piecewise affine functions (as defined above), you get a class with more satisfactory density properties. Since $C^1_0(\Omega)$ functions are $H^1$-dense in $H^1_0(\Omega)$, it is sufficient to approximate a function in $C^1_0(\Omega)$ by $C^0$ piecewise affine functions in the $C^1$ sense; this is classically done by affine interpolation on the points of the 0-skeleton of the triangulation (there is a unique such interpolation: that's the advantage of triangulations compared to cubic subdivisions). So in your case you should further subdivide each cube in $n!$ simplices, and take the approximation affine on each of them. If you are interested in the quantitative aspect, it should not be difficult to bound the $H^1$ distance of the approximation; I guess that books of numerical analysis cover completely this point.