Energy method for elliptic PDE I have a Energy functional of a PDE : $-\triangle u +u|u| =f$ in $\Omega$
$u=0$ in $\partial \Omega$, and corresponding energy functional below . 
$$
E(u)=\int_\Omega\Bigl(\frac12|\nabla u|^2+\frac1{3}|u|^3-f\,u\bigr)dx.
$$
Observe that $E(u)$ is well defined on the Banach space $X=H^1_0(\Omega)\cap L^3(\Omega)$.
I have the following difficulties in understanding it : 
a) How do we correspondingly change the Energy functional according to the given PDE ?
b) I am not able to understand why the above energy functional is well defined in $X$ ?
c) Suppose i define $u$ not to be in   $H^1_0(\Omega)\cap L^3(\Omega)$ , rather in say $H^2_0(\Omega)\cap L^2(\Omega)$ , How would  the setting of energy functional change ? 
Please help me to understand . Thanks a lot for giving time . 
 A: First of all I would highly recommend you consulting some text in calculus of variations. Some recommendations (in no particular order):

*

*Weinstock, Calculus of Variations with Applications to Physics and Engineering is a classic, small book. Available now through Dover for cheap.

*Gelfand and Fomin, Calculus of Variations is also available now through Dover publications.

*Jost and Li-Jost, Calculus of Variations from Cambridge University Press

Part (b) of your question was already resolved in the comments: the short of the matter is that by considering the functional on the choice of function space, we have restricted ourselves to a domain over which the functional is well-defined. (For example, over the space $H^1_0(\Omega)$ we have that by definition an element $u\in H^1_0(\Omega)$ satisfies $\int_\Omega |\nabla u(x)|^2\mathrm{d}x < \infty$.)
For part (a), the answer is that it is a bit like taking anti-derivatives: you develop some rules based on the reverse operation of finding Euler-Lagrange Equations. Let me elaborate a bit more.
Given a functional $S: H \to \mathbb{R}$ on some Banach space $H$, we are often interested in critical points of $S$ (physically this corresponds to Fermat's principle of least time or the principle of least action; in mathematics we are also interested in area minimizing surfaces or length minimizing curves). In all of those cases, we do what we do in freshman calculus: the critical point is where the derivative of $S$ vanishes.
Now, let $H$ be a space of functions defined on some domain $\Omega$ vanishing on the boundary $\partial\Omega$, and let the functional
$$ S[u] = \int_{\Omega} \mathcal{S(x,u,\nabla u)} \mathrm{d}x $$
for some function $\mathcal{S}$. By definition of the derivative, we want that for any function $v\in H$,
$$ S'[u]\cdot v = \lim_{t\to 0} \frac{S[u+tv] - S[u]}{t} = 0 $$
Doing a Taylor expansion on $S$ we have that
$$ \mathcal{S}(x,u+tv, \partial u + t \nabla v) = \mathcal{S}(x,u,\nabla u) + \left(\frac{\partial}{\partial u}\mathcal{S}\right)(x,u,\nabla u) \cdot tv + \left(\frac{\partial}{\partial \nabla u}\mathcal{S}\right)(x,u,\nabla u)\cdot t\nabla v + O(t^2)$$
which gives
$$S'[u]\cdot v = \int_\Omega \frac{\partial\mathcal{S}}{\partial u} v + \frac{\partial\mathcal{S}}{\partial\nabla u}\cdot \nabla v \mathrm{d}x $$
Integrating the last term by parts we get
$$ S'[u] \cdot v = \int_\Omega \left( \frac{\partial\mathcal{S}}{\partial u} - \nabla\cdot \frac{\partial \mathcal{S}}{\partial \nabla u}\right) v \mathrm{d}x $$
Since $S'[u]\cdot v = 0$ is supposed to hold for all $v\in H$ (when $u$ is a critical point), this requires that
$$ \frac{\partial\mathcal{S}}{\partial u}(x,u,\nabla u) - \nabla\cdot \left(\frac{\partial \mathcal{S}}{\partial \nabla u}(x,u,\nabla u)\right) = 0$$
The above expression is known as the Euler-Lagrange Equation associated to the functional $S$.
You see that in some sense, what you have done in computing the Euler Lagrange equation is computed the "gradient" of the functional $S$. And so, what you asked in part (a), that of finding an energy functional given an equation, is the opposite of this process, and hence very similar to finding the "antiderivative" of the equation.
The way to do this is by learning about rules which you can derive by inference after having done some of these computations. Many of these rules have direct analogue in calculus. Some examples:

*

*If $\mathcal{S}$ contains a term $|u|^p$, where $p \geq 2$, then the Euler Lagrange equation contains a term $p |u|^{p-2} u$.

*If $\mathcal{S}$ contains a term $|\nabla u|^2$, then the Euler Lagrange equation contains a term $-2 \triangle u$.

*If $\mathcal{S}$ contains a term $F(u)$, where $F$ is a real/complex valued functions of one variable, then the Euler Lagrange equation contains a term $F'(u)$.

*If $\mathcal{S}$ contains a term $V \cdot u$, then the Euler Lagrange equation contains a term $V$.

The four rules given here are the simplest and most common types of terms of the functional $S$. Here I've assumed that $\mathcal{S}$ does not depend on $x\in\Omega$. If it does, this introduces another layer of complication, as the second term of the Euler-Lagrange equation involves taking a physical space divergence $\nabla\cdot$ and whether derivatives hit the $x$ dependence of $\mathcal{S}$ we pick up additional lower order terms.
Just like solving anti-derivatives, finding the energy functional is mostly educated guess work involving experience and some memorised forms. Here I re-iterate what I said in the comments: just as in multivariable calculus where not all vector fields can be written as the gradient of a function, in the functional setting not all equations can be written as the Euler Lagrange equation of some functional. That is to say, not all PDEs are variational in nature.
Edit: As Theorem clarified in a comment:

Basically my question in part (c) is, how would the energy functional change if i define u to be in a different space ?

The answer is it won't. Once should be careful with one's goals and not "put the cart before the horse".

*

*In the case you are considering a given variational problem (minimise a functional over a certain function space), the function space is given and so it makes no sense to change the function space.


*In the case you are trying to solve a given PDE, the energy method is just an intermediate tool. The tool demands a particular form of energy functional. So you must choose a function space on which this energy functional is well-defined. But that's not all! To using the machinery of the calculus of variations, the functional has to be "sufficiently coercive" relative to the norm of your function space. This is because the analysis of such PDEs usually proceeds by (i) choosing a minimising/extremising sequence in the function space (ii) showing that it converges. For the problem you mentioned in the question, with standard functional analysis machinery one can show that there exists a bounded minimising sequence, which can be shown to weakly converge using standard abstract nonsense. To get strong convergence in this case we have to use the fact that the norm in which we measure the strong convergence can be controlled by the energy functional, and then we can exploit the convexity of the functional to show that the weak limit must be a strong limit in fact. (The above is very sketchy; I described the general method with a hair more detail in this answer.)
In other words, what I am trying to say is a bit of philosophy: in solving PDEs, one does not choose a function space first. Instead, one chooses a method and finds a function space in which the method can be applied. In fact, a large and necessary part of modern analysis of partial differential equations consists of clever choices of function spaces in order to implement certain solution schemes.
