Variation in Hamiltonian mechanics I have a question about a property of variational calculus used in following bachelor thesis:
http://users.physik.fu-berlin.de/~pelster/Bachelor/fraessdorf.pdf
Here the excerpt:

Why it is possible to pull the variation $\delta$ into the integral? Namely why is 
$$\delta \int dt[p_i \dot{q}^i -H(p,q)-\lambda^r\phi_r(p,q)] = \int dt \text{ }\delta [p_i \dot{q}^i -H(p,q)-\lambda^r\phi_r(p,q)]$$
a correct step? 
I encountered often in other lectures treating Hamiltonian mechanics similar intergal-variation-interchange steps but they were never justified.
 A: It is because the integral of the difference of two quantities is equal to the difference of the integrals:
If $\delta f(x)= f_2(s) -f_1(x)$ and 
$$ 
\delta \int f(x) \,dx = \int f_2(x)dx-\int f_1(x) dx
$$
then 
$$
\delta \int f(x) \,dx =
\int \left( f_2(x)-f_1(x)\right)dx =\int \delta f(x)\,dx.
$$
A: The basic reason that it is justified is that the time integral is a linear operator.
So let's step way back into the abstract, what you really have is some configuration space $\mathcal C$ of possible configurations of some system, and some space of paths $\mathcal P$ through that, which is some subset of the functions $[0,1]\to \mathcal C$. Inside of this configuration space we may have a time coordinate, position coordinates, velocity or momentum coordinates...
Then we have some functions of these paths, $X:\mathcal P \to \mathbb R.$ Some of them have the format, $$\mathcal A[\mathbf P] = \int_0^1 ds~L\big(\mathbf P(s)\big).$$
We want to do calculus with whole paths, so we want to consider the difference $$\delta \mathcal A = \mathcal A[\mathbf P + \epsilon\mathbf p] - \mathcal A[\mathbf P],~~ \epsilon \approx 0$$ Note that this in theory depends on both the path big-$\mathbf P$ that we use to evaluate the action and the path little-$\mathbf p$ that we use to perturb it, but we're typically going to take the approach of trying to find the big-$\mathbf P$ such that this $\delta \mathcal A$ is zero to first order in $\epsilon$ or so, irrespective of little-$\mathbf p$. 
Just putting those two together and using the linearity of the integral, we have $$\delta\mathcal A = \int_0^1 ds~\Big(L\big(\mathbf P(s) + \epsilon \mathbf p(s)\big) - L\big(\mathbf P(s)\big)\Big),$$and the internal term could meaningfully be called $\delta L$. It doesn't mean exactly the same thing as it is applied "pointwise" to the path, but if we were instead to write this as $L[\mathbf P](s)$ or some similar notation then it would indeed be $\delta L[\mathbf P](s)$. 
The rest of your expression then follows from the Leibniz property of this $\delta$ operator, which depends on understanding that we are taking a limit etc.,  which is nontrivial of course.
A: In simple words it can be put together as:

*

*Derivative operator ($dx$) and Variation operator ($\delta x$) commmutes with each other.

Now what do I mean by that:
The commutativity is one property of operators, $i.e.$ if say two operators, $A$ and $B$ acting on some parameter $x$ [correspondingly: $A(x)$ and $B(x)$], gives same value for both $A(B(x))$ and $B(A(x))$, or
$[A.B] = A(B(x)) - B(A(x)) = 0$, this means, irrespective of the order of implementation, the operators give out same result, and we say then, $A$ $commutes$ $with$ $B$, or vice versa.
Here in the same way, $ \delta (dx) = d(\delta x)$
