Q:

Cancelling while integrating

Please help in understanding the following integrals. 
You're allowed to do something like the following, but not because you are actually cancelling dt/dt.  Right?  Can someone please explain how and why (and if) this works ? 
$$\int u_n \frac{\mathrm{d}u_n}{dt} \mathrm{d}t = \int u_n \mathrm{d}u_n$$
$$\int u_n \frac{\mathrm{d}u_{n+1}}{\mathrm{d}t} \mathrm{d}t = \int u_n \mathrm{d}u_{n+1}$$
Note that $u_n$ (position of mass $n$) and $u_{n+1}$ is a function of $t$ (time). 
I think I this answer to say that I need to integrate $u_n \frac{\mathrm{d}u_n}{dt}$ w.r.t.  $t$, evaluate that answer at the bounds of the integral and use the result as the bounds of the integral $\int \mathrm{d}t$. Right?  But I don't have bounds and $u_n \frac{\mathrm{d}u_n}{dt}$ doesn't integrate easily w.r.t.  $t$.
(OPTIONAL) I ask because it seems I am applying this rule wrong because I am getting the wrong answer to a bigger problem (see image below).  I'm actually trying to find the potential energy by integrating force times velocity with respect to time, like this (correct answer is on top; you can ignore the issues, like that I think I defined $\mathbf{v}$ backwards, not relevant to my question). 

A:

The problem occurs in dealing with the two terms in the middle;
you can write them as $-\int u_{n}\frac{du_{n+1}}{dt}dt-\int u_{n+1}\frac{du_{n}}{dt}dt=-\int\big(u_{n}\frac{du_{n+1}}{dt}+u_{n+1}\frac{du_{n}}{dt}\big)dt=-\int\frac{d}{dt}(u_nu_{n+1})dt$
$=-u_{n}u_{n+1}+C$ using the product rule
For the answer to your original question, though, the formula
$\int u_{n}\frac{du_{n}}{dt}dt=\int u_{n}du_{n}$,
which we could also write as $\int f(t)f^{\prime}(t)dt=\int udu$,
is correct, since it is just an application of u-substitution.