Solution (source code)

= Solution

Reflect $u$ across the two endpoints of $I$ into a slightly larger interval, giving an $H^1$ extension, and multiply by a smooth <cutoff function> equal to one near $\overline I$. Convolve the resulting function on $\mathbb R$ with a <mollifier>. The convolutions $u_\varepsilon$ are smooth; differentiation commutes with convolution of the <weak derivative>. Continuity of translations in $L^2$ proves both $u_\varepsilon\to u$ and $u_\varepsilon'\to u'$ in $L^2(I)$, hence convergence in the <Sobolev norm>.

To obtain convergence <almost everywhere>, select a sequence with $\|u_n-u\|_2\le2^{-n}$. Then $\int\sum_n|u_n-u|^2<\infty$, so the summands tend to zero almost everywhere. Thus \b[a smooth approximating sequence converges both in $H^1$ and almost everywhere]. This is <density of smooth functions in a Sobolev space>; smooth functions need not vanish at the endpoints.