derivative of double integral in calculus of variation I am reading a paper skipping the details of its calculation. I am lost on the deriving of the Euler-Lagrange equation to search the stationary point of a functional:
$$I(r_t) = -A\int_0^Ldt \dot{r}_t^2 + \frac{B}{L^2} \int_0^L\int_0^Ldtds(r_t-r_s)^2$$
where $r_t=r(t)$ and $s$ is a dummy variable of $t$ to denote the double integral. $\dot{r}_t = \frac{dr(t)}{dt}$.
The result written in the paper is
$$\ddot{r}_t + \frac{2B}{AL}r_t - \frac{2B}{AL^2}\int_0^Lr_tdt = 0$$
Could someone help me? Thank you very much in advance.
 A: Suppose that $r : [0,L] \to \mathbb R$ is a stationary point for the functional $I$, defined on the set of twice-differentiable functions $[0,L] \to \mathbb R$ with the same boundary values as $r$. This means precisely that $$\frac{d}{d\epsilon}\Big|_{\epsilon = 0}I(r + \epsilon \phi) = 0$$ for all $\phi$ such that $\phi(0)=\phi(L)=0.$ Substituting in to the definition of $I$, passing the derivative through the integrals and simplifying, this becomes $$-2A\int \dot r(t) \dot \phi(t) \,dt + \frac{2B}{L^2}\iint (r(t)-r(s))(\phi(t)-\phi(s)))\,ds\,dt=0.$$
Integrating by parts (using the boundary conditions for $\phi$) changes the first integral into $\int \ddot r \phi$. The double integral can be written as $$\int_0^L\int_0^L \phi(t)(r(t) - r(s))\,ds\,dt + \int_0^L\int_0^L \phi(s)(r(s) - r(t))\,dt\,ds,$$ which is really the same integral twice with the dummy variables $s,t$ swapped; so we can just replace it with $2\iint\phi(t)(r(t)-r(s))\,ds\,dt.$ Factoring out the $\phi(t)$ then lets us write the stationary equation as $$\int_0^L \phi(t)\left(2A\ddot r(t)+\frac{4B}{L^2}\int_0^L (r(t)-r(s))\,ds \right) \,dt= 0.$$ Since this holds for all $\phi$, the parenthesized term must vanish, which yields the Euler-Lagrange equation
$$2A\ddot r(t) + \frac{4B}Lr(t) - \frac{4B}{L^2}\int_0^L r= 0.$$ 
