Solution (source code)

= Solution

Choose the <Sobolev space> $V$ encoding the homogeneous essential <boundary conditions>, set
$$
a(u,v)=\langle\mathcal Lu,v\rangle,
\qquad \ell(v)=\langle f,v\rangle,
$$
after the appropriate <integration by parts>, and define the <energy functional>
$$
J(v)=\frac12a(v,v)-\ell(v).
$$
Its first variation is $J'(u)v=a(u,v)-\ell(v)$, so its stationary points are exactly the solutions of the <weak formulation>
$$
a(u,v)=\ell(v)\qquad(v\in V).
$$
If $a$ is bounded, symmetric, and coercive and $\ell\in V'$, the <Lax-Milgram theorem> supplies a unique <weak solution> $u$. Moreover, for every $w\in V$,
$$
J(u+w)-J(u)
=a(u,w)-\ell(w)+\frac12a(w,w)
=\frac12a(w,w)>0
$$
unless $w=0$. Thus $J$ is <strictly convex function>[strictly convex], and $u$ is its unique global minimizer. This proves existence and uniqueness of the minimizer and of the weak solution simultaneously.