Lagrangian of EM field 
I try to prove that:
  \begin{align}
\mathcal{L}=-\dfrac{1}{4}F_{\mu\nu}F^{\mu\nu}.
\end{align}
  Can be written in the form:
  \begin{align}
\mathcal{L}=\dfrac{1}{2}A^\mu[g_{\mu\nu}\partial^2-\partial_\mu\partial_\nu]A^\nu.
\end{align}

I solved as:
\begin{align}
F_{\mu\nu}~ F^{\mu\nu} = (\partial_\nu A_\mu-\partial_\mu A_\nu)~ (\partial^\nu A^\mu-\partial^\mu A^\nu) = \partial_\nu A_\mu ~ \partial^\nu A^\mu - \partial_\nu A_\mu ~ \partial^\mu A^\nu -\partial_\mu A_\nu ~ \partial^\nu A^\mu + \partial_\mu A_\nu ~ \partial^\mu A^\nu 
\end{align}
The terms $ \partial_\nu A_\mu ~ \partial^\nu A^\mu $ and $\partial_\mu A_\nu ~ \partial^\mu A^\nu $ went fine with me, that they equal $A^\mu g_{\mu\nu} \partial^2 A^\nu$, while I think i have something wrong with $\partial_\nu A_\mu ~ \partial^\mu A^\nu $ terms since they can't get $ A^\mu \partial_\mu\partial_\nu A^\nu$ 
Any smarter or right way in solving?
 A: The equality of both expressions only is guaranteed if they are integrated over a 4-volume. In that case you can benefit from partial integration:
$\partial_\nu A_\mu \partial^\nu A^\mu = \partial^\nu (\partial_\nu A_\mu  A^\mu) -  A_\mu \partial^\nu\partial_\nu A^\mu=\partial^\nu (\partial_\nu A_\mu  A^\mu) - A^\mu \partial^2 g_{\mu \nu}A^\nu$
$\partial_\mu A_\nu \partial^\mu A^\nu = \partial^\mu (\partial_\mu A_\nu  A^\nu)-  A^\nu \partial^\mu\partial_\mu A_\nu=\partial^\mu (\partial_\mu A_\nu  A^\nu)-A^\mu g_{\mu \nu} \partial^2 A^\nu$
$-\partial_\nu A_\mu \partial^\mu A^\nu=-\partial_\nu( A_\mu \partial^\mu A^\nu)+  A_\mu \partial_\nu\partial^\mu A^\nu = -\partial_\nu( A_\mu \partial^\mu A^\nu)+  A^\mu \partial_\nu\partial_\mu A^\nu$
$-\partial_\mu A_\nu \partial^\nu A^\mu=-\partial_\mu( A_\nu \partial^\nu A^\mu)+  A_\nu \partial_\mu\partial^\nu A^\mu = -\partial_\mu( A_\nu \partial^\nu A^\mu)+  A^\nu \partial_\mu\partial_\nu A^\mu$
Under the volume integral the total partial derivatives can  be transformed into surface integrals that finally will be zero as the field values on the surfaces are assumed to be zero. Then you are left with terms you need (may be moving some indices up and down) for the second expression modulo a minus sign you have to put because the $F_{\mu\nu} F^{\mu\nu}$ has the minus sign in front and we're done. 
A: The Lagrangian density is found inside an integral:
$$ S = \int d^4x \ \mathcal{L}. $$
If the Lagrangian includes a term like $A \partial_\mu B$, the action can be integrated by parts to give
$$ S = \int d^4x \ A \partial_\mu B = -\int d^4x \ (\partial_\mu A)B, $$
where the boundary term like $AB$ does not appear because of the physical assumption that all fields vanish at $\infty$. Therefore, Lagrangian densities can be simplified in general using the identity
$$ A \partial_\mu B = - (\partial_\mu A) B. $$
For example, in the case of the electromagnetic field, we have
\begin{align}
\partial_\nu A_\mu \partial^\mu A^\nu &= - A_\mu \partial_\nu \partial^\mu A^\nu \\
     &= -A^\mu \partial_\nu \partial_\mu A^\nu.
\end{align}
Renaming indices as needed should prove your result.
