Show that $\int_S|\nabla w|^2 \operatorname{dA}\ge\int_S|\nabla u|^2 \operatorname{dA}$ 
Let $S$ be a bounded region of $\mathbb R^2$ and $\partial S$ be its
  boundary. Let $u$ be the unique solution to Laplace’s equation in $S$,
  subject to the boundary condition $u=f$ on $\partial S$, where $f$ is
  a specified function. Let $w$ be any smooth function with $w=f$ on
  $\partial S$. By writing $w=u+\delta$ show that $$\int_S|\nabla w|^2
 \operatorname{dA}\ge\int_S|\nabla u|^2 \operatorname{dA}$$

To start all I could think to do is to write $$\int_S|\nabla w|^2 \operatorname{dA}=\int_S \nabla w\cdot\nabla w \operatorname{dA}=\int_S|\nabla u|^2+2\nabla\delta\cdot\nabla u+|\nabla\delta|^2 \operatorname{dA}$$
but I don't know how to use the given conditions.
Any help wuld be appreciated, thanks
 A: The key (it seems to me) is the fact that $\delta = w - u$ vanishes on the boundary so you can integrate by parts with no boundary term: $$\int_S (\nabla w - \nabla u) \cdot (\nabla w - \nabla u) \, dA = - \int_S (w - u) \Delta (w-u) \, dA.$$ Since $\Delta u = 0$ you get after simplifying and integrating by parts again,$$- \int_S (w - u) \Delta (w-u) \, dA = - \int_S (w - u) \Delta w \, dA = \int_S (\nabla w - \nabla u) \cdot \nabla w \, dA.$$ Thus $$\int_S (\nabla w - \nabla u) \cdot (\nabla w - \nabla u) \, dA = \int_S (\nabla w - \nabla u) \cdot \nabla w \, dA.$$ This simplifies to $$\int_S |\nabla u|^2 \, dA = \int_S \nabla w \cdot \nabla u \, dA.$$
Can you complete the argument from here?
A: You want to minimize the functional $w\mapsto \int_S|\nabla w|^2 dx$ subject to the constraint $w = f$ on $\partial S$. If $w$ is a minimizer (and $w = f$ on $\partial S$) then for all smooth functions $\phi$ that vanish on $\partial S$ we have
\begin{eqnarray*}
 0
 & = & 
 \frac{d}{dt}\bigg|_{t = 0}\int_S |\nabla(w + t\phi)|^2 dx
 \\
 & = & 
 2\int_S \nabla w\cdot\nabla \phi dx
 \\
 & = & 
 2\int_S\phi \frac{\partial w}{\partial \nu} dS_x
 -
 2\int_S \phi \Delta w dx
 \\
 & = & 
 -2\int_S \phi \Delta w dx. 
\end{eqnarray*}
Since this is true for all $\phi$, $w$ must be harmonic in $S$. 
A: We are given that $u=w=f$ on $\partial S$.  Hence, if $w=u+\delta$, then $\delta=0$ on $\partial S$.  
In addition, since $\nabla^2 u=0$ in $S$, then in $S$ we have
$$\nabla u\cdot \nabla \delta=\nabla \cdot (\delta\, \nabla u)-\delta \,\nabla^2 u=\nabla \cdot (\delta \,\nabla u)$$
Equipped with these observations, we can write
$$\begin{align}
\int_S \nabla w\cdot \nabla w\,dA&=\int_S |\nabla u|^2\,dA+2\int_S \nabla u\cdot\nabla \delta\,dA+\int_S |\nabla \delta|^2\,dA\\\\
&=\int_S |\nabla u|^2\,dA+2\oint_{\partial S} \underbrace{\delta}_{=0\,\text{on}\,\partial S} (\hat n\cdot \nabla)\,dA+\int_S |\nabla \delta|^2\,dA\\\\
&=\int_S |\nabla u|^2\,dA+\underbrace{\int_S |\nabla \delta|^2\,dA}_{\ge 0}\\\\
&\ge \int_S |\nabla u|^2\,dA
\end{align}$$
as was to be shown!
