Euler-Lagrange equation This is PDE Evans, 2nd edition: Chapter 8, Exercise 2:

Find $L=L(p,z,x)$ so that the PDE $$-\Delta u + D\phi \cdot Du = f \quad \text{in }U$$ is the Euler-Lagrange equation corresponding to the functional $I[w] := \int_U L(Dw,w,x) \, dx$.
(Hint: Look for a Lagrangian with an exponential term.)

First, one must note that $U \subset \mathbb{R}^n$ and $L(p,z,x)=L(Du,u,x)$, where $Du=\nabla u =\sum_{i=1}^n u_{x_i}$. 
One should also note that the Euler-Lagrange equation associated with the energy functional $I[w]:=\int_U L(Dw(x),w(x),x) \, dx$ is
$$-\sum_{i=1}^n (L_{p_i}(Du,u,x))_{x_i}+L_z(Du,u,x) = 0 \quad \text{in }U.$$
Here is my work so far:
I set $(L_{p_i})_{x_i}:= (p_i)_{x_i}-\phi_{x_i} p_i$ and $L_z:=-f(x)$ so that the LHS of the Euler Lagrange PDE is 
\begin{align}
0 &=-\sum_{i=1}^n (L_{p_i}(Du,u,x))_{x_i}+L_z(Du,u,x) \\
&=-\sum_{i=1}^n\left[(p_i)_{x_i} - \phi_{x_i} p_i \right] - f(x) \\
&= -\sum_{i=1}^n \left[u_{x_ ix_i} - \phi_{x_i} u_{x_i} \right] - f(x) \\
&= -\sum_{i=1}^n u_{x_ ix_i} + \sum_{i=1}^n  \phi_{x_i} u_{x_i} - f(x) \\
&= -\Delta u + D\phi \cdot Du - f(x).
\end{align}
This gives us the PDE $-\Delta u + D\phi \cdot Du = f$ as written in Exercise 2.
Now, how can I write $L(p,z,x)$? I was thinking $$L(p,z,x)=\frac 12|p|^2 - \qquad \qquad - zf(x),$$ so that, upon taking the derivative with respect to $p_i$ or with respect to $z$, we would obtain both the $L_{p_i}$ and $L_z$ that I have, respectively. However, I have trouble writing the middle term, which is why I left a blank space. The textbook author did say "look for a Lagrangian with an exponential term".
 A: Using the hint, we set 
$$L(p, z, x) = e^{-\phi(x)}\left(\frac 12|p|^2 - zf(x)\right).$$
Then the functional becomes
$$I(u) = \int_\Omega e^{-\phi} \left(\frac 12 |\nabla u|^2 - uf(x)\right)\, dx.$$
Thus
$$\frac{\partial}{\partial t}\bigg|_{t=0} I[u_t] = \int_\Omega e^{-\phi} (\nabla u \cdot \nabla v + vf) dx,$$
where $v = \partial_t u |_{t=0}$. Then by divergence theorem, it's
$$\int_\Omega v\big(-\nabla(e^{-\phi} \nabla u) -e^{-\phi} f\big)\, dx $$
which is
$$\int_\Omega e^{-\phi} v\big(\nabla \phi \cdot \nabla u - \Delta u  -f \big)\, dx $$
which means that 
$$\nabla \phi \cdot \nabla u - \Delta u - f = 0$$
and this is the same as your equation. 
Remark How I come up with this expression: First of all, as you know, I thought something like $D\phi \cdot Du$ would suffices. It's not true though, as if we write down $I'[v]$, we would get something like 
$$ D\phi \cdot Dv$$
and there is no way to isolate $v$ using integration by part and still have $D\phi$. The above term is also a hint that $L$ should contains only $\phi$, but not $\nabla \phi$ (or the Euler-Lagrange equation would contains second derivatives of $\phi$). 
So I tried $L = \frac 12 \phi |p|^2 - z f(x)$, then we have 
$$I'[v] = \int_\Omega \left( \phi \nabla u \cdot \nabla v - v f\right) \,dx = \int_\Omega v\left( -\nabla(\phi \nabla u) - f\right) \,dx.$$
This is almost correct as the EL equation is 
$$-\phi \Delta u - D\phi \cdot Du = f. $$
Then I realize that to deal with that $\phi$ in front of $\Delta u$, I should do $e^{\phi} |p|^2$ because I would get a term 
$$D e^\phi \cdot Du = e^\phi D\phi \cdot Du$$
and this extra $e^\phi$ can be grouped to that $e^\phi$ in front of $\Delta u$. 
