My question is exactly the same as this question, but I cannot do the variation of integral referred in the Addendum, i.e., \begin{align} S_B\propto\int dx\; B^2=\int \left(\nabla\times A\right)^2\; dx, \end{align} where $S_B$ is some magnetic action, $B$ the magnetic field and $A$ the vector potential. I have problems when I vary wrt $A$. I don't understand how it can be obtainedobtain the last equality: \begin{align} \delta S_B\propto 2\int dx\;\left[\left(\nabla\times A\right)\cdot \left(\nabla\times\delta A\right)\right]=2\left[\delta A\times (\nabla\times A)\right]+2\int dx\; \left[(\nabla\times\nabla\times A)\cdot \delta A\right]. \end{align}