Total energy vs the kinetic energy of a body Now, we know,
$$∆T = \int_a^b\vec F_\text{ext}\cdot d\vec s = W$$
Where $∆T$ is the change in kinetic energy of the object and $W$ is the work done on the object by $F_\text{ext}$.
In some books, they say that work done by external forces is equal to change in total energy $E$. Now $E$ is not the same as $T$ when there is a change of potential energy, however I've also read the same thing in many cases where $U$ is also changing. How is this possible?
 A: It is important to keep track of what all the symbols mean in a formula. What you wrote is the work energy theorem. It is often given for a classical point particle which has no internal energy. For such a particle $E=T$ (note that $U$ is external to the particle) and there is no ambiguity.
If you have a more complicated system which does have some form of internal energy then the work energy theorem is a little ambiguous. To clarify, it should be written $$∆T = \int_a^b\vec F_\text{net}\cdot d\vec s_\text{CoM} = W_\text{CoM}$$ where CoM indicates the center of mass and $F_\text{net}=\Sigma_i F_i$. So the position $s$ specifically refers to the center of mass and the work is not the total work done but just the work done on the center of mass by the net force (often this is confusingly called the “net work” which is confusing because it is not the same as the total work).
Now, for a system with internal energy we have a different expression which describes the total work: $$∆E = \Sigma_i \int_{a_i}^{b_i} \vec F_i \cdot d\vec s_i = W_\text{total}$$ where $i$ enumerates each of the external forces. This is the expression to use when considering a system with internal energy also. It allows for changes in KE as well as PE.
For example, consider a system consisting of a spring of mass $m$. Let the spring be placed against a wall and then the spring is compressed from equilibrium at a constant rate by a force at the opposite end for a distance $d$.
Since the rate is constant the CoM is not accelerating so $F_\text{net}=0$. Then $W_\text{CoM}=0=\Delta T$
Since the wall does not move the work from the force at the wall is 0 so $W_\text{total}=\int_0^d kx \ dx = \Delta E$. So $\Delta U = \Delta E - \Delta T = \Delta E$ as expected physically.
A: I would like to continue what I and @garyp mentioned in the comments.
When you consider equilibrium of a system then the internal forces don't matter since they get cancelled up in pairs.
But when you are talking about work done then the work by the internal forces don't cancel and they give a finite value.
Let me give you an example:
Suppose we have two opposite charges initially at rest (assume of same mass). Both will attract each other and if you consider both as a system, then the center of mass of the system is still at rest.
What will you say about the work done on the system at some time $t$ ?
Since both moves same distance and the angle between the force on both and their displacements is $0°$, so work on both is non - zero.
So it is clear that internal forces fo matter while considering work. Now as I said earlier in the comments, the change in kinetic energy equals the work done by net force and the work done by external force equals change in total energy.
