Moving along friction surfaces If a particle moves along a one dimensional surface with constant friction. As the particle moves from point $A$ to point $B$ it loses an amount of energy equals $E(A,B)$. Consider that the particle returns back to point $A$. It loses another $E(A,B)$ units of energy so it loses total $2*E(A,B)$ of energy but doing integration to get the change of kinetic energy, We add integral of the force of friction from $A$ to $B$ to the same integral from $B$ to $A$ so we get zero. How can this happen?
 A: This is a simple sign error. The force of friction always opposes the direction of slippage between two surfaces (thanks to @JoeH for this correction). Therefore, when the particle changes its direction of motion, the direction of the force from friction also changes.
The work done against friction in moving the particle from A to B is
$$ E(A,B) = \int\limits_A^B F\,\mathrm{d}x = F\times(B - A).$$
It is important to note that $F$ is the force that the particle has to apply to the surface in order to overcome friction, so $F$ points in the same direction as the position vector pointing from $A$ to $B$. This ensures that E(A,B) is a positive quantity irrespective of your choice of sign conventions. The work done in moving the particle from $B$ to $A$, on the other hand, is
$$ E(B,A) = \int \limits_B^A (-F)\,\mathrm{d}x = \int\limits_A^B F\,\mathrm{d}x = E(A,B).$$
The total work done against friction by the particle (and hence the kinetic energy lost) is therefore $$E(A,B) + E(B,A) = 2 E(A,B) = 2 F \times (B - A). $$.
