How to derive equation for thermal energy ($E$ thermal = Friction force X Distance) We are covering the energy principle in my physics course and so far we have been using the equation $$\Delta KE + \Delta E_{th} = W_{Ext}$$ which is change in kinetic energy plus change in thermal energy equals the work done by an external force for some system (no potential energy because all of our questions have been 1-dimensional so far).
To solve for thermal energy, our textbook gives the following example:

In the example, a box is being pulled over a rough surface at a constant speed with a string enacting a horizontal force in the direction of motion. The system is defined as the box and the surface. Because the speed is constant, we know that $$\Delta KE = 0$$ The tension is the only external force acting on the system, and because the speed is constant, we know $$F_{net} = 0 \rightarrow T - F_k = 0 \rightarrow T = F_k$$ And because work is defined as force times displacement, we have $$W_{Ext} = T\Delta s \rightarrow W_{Ext} = F_k\Delta s$$ Substituting these values back into the energy principle equation, we get $$\Delta E_{th} = F_k\Delta s$$ This value makes sense, and I can understand why the change in thermal energy would be equal to the friction force times the displacement in this example.
Fast forward to the next part in my textbook where they have this example:

This example uses the knowledge from the previous example and asks to find the final velocity of an object after being pulled a certain distance. This problem has almost the same scenario as the last example, except that the object starts at rest, and travels a total distance of 3 meters. The tension of the string, mass of the object, total displacement, and coefficient of kinetic friction are given.
The textbook solves this problem by again using the energy principle. They solve for the change in thermal energy by multiplying the friction force by the displacement, they calculate the work by multiplying the tension by the displacement, and then they subtract the change in thermal energy from the work to solve for the change in kenetic energy, and solve for the final velocity by rearranging the equation $$\Delta KE = \frac{1}{2} m (v_f)^2 - \frac{1}{2} m (v_i)^2 \rightarrow v_f = \sqrt \frac{2\Delta KE}{m}$$
because the initial velocity is 0.
My hangup with this explanation comes with the first step where they use $$\Delta E_{th} = F_k\Delta s$$ to find the thermal energy.
In the last example, we knew that the thermal energy was equal to the frictional force times the work, because there was no change in kinetic energy, and the tension in the string just happened to be equal to the frictional force because there was no net acceleration.
But here we do know there is a change in kinetic energy because the object starts moving from rest, and while we do know what the tension is, it's not equal to the frictional force. It would seem to me that if the tension is 30N, the equation that we have is $$ \Delta KE + \Delta E_{th} = 30$$ with the change in thermal energy and the change in kinetic energy as unknowns.
The textbook makes the assumption that the change in thermal energy is equal to the friction force times the displacement, but that assertion doesn't seem warranted because the scenario is different from the last example. It seems to me that this "proof" only works in a scenario where we know that the tension is equal to the friction force and when there is no change in kinetic energy.
With that in mind, how can know for sure that the thermal energy is equal to the frictional force times the displacement if the tension is not equal to the frictional force and if there is a change in kinetic energy (or if the scenario is in any way different from the initial example)?
 A: I think your confusion is warranted, but the book is correct (it just doesn't completely justify the use of $\Delta E_{\textrm{th}} = f_k\Delta s$). Here's how I would think about this.
As the book says, you have to be careful when calculating work done by dissipative forces.  However, you can still derive a kinematic relationship between the energies in the usual way.  That is, starting from the forces acting, we can compute the change in kinetic energy of the particle.  To wit,
$$
m a_x = T_x+f_x\Longrightarrow a = \frac{T}{m}-\mu  g\,.
$$
Then, since the acceleration is constant, we can use the constant-acceleration kinematic equations; in particular,
$$
v_{f,x}^2 = v_{i,x}^2 +2a_x(x_f-x_i)\,,
$$
so that
$$
v_{f}^2 = v_i^2 +2\left(\frac{T}{m}-\mu  g\right)d\,,
$$
where $d$ is the total distance traveled by the crate during the process. Then, multiplying by $m/2$ and rearranging, we get
$$
\frac{1}{2}mv_{f}^2 -\frac{1}{2}m v_i^2  = Td-\mu mgd\,,
$$
so that
$$
\Delta K_{\textrm{crate}}=W_\textrm{on crate by rope}-\mu mgd\,.
$$
It's tempting to call that second term the "work done by the frictional force", and it is sometimes okay to call it that, but as the book notes, we need to be careful about its interpretation, because really it is responsible for increasing the thermal energy of the two surfaces in contact, and so there's not a good sense in which it's equal to the change in translational kinetic energy of either the crate or the surface.
However, once we're here, we see can see that the change in kinetic energy really is equal to the work done by the crate minus the "kinematic work" done by friction.  Rearranging this into
$$
W_\textrm{on crate by rope} = \Delta K_{\textrm{crate}}+\mu mgd\,,
$$
and reinterpreting $W_\textrm{on crate by rope}$ as $W_\textrm{on crate-surface system}$, we can see that that extra change in system energy equal to $\mu m g d$ must correspond to an increase in thermal energy, because there is no other place for that energy to go.

The upshot is that the book is correct in using $\mu m g d$ as the change in thermal energy of the system, but the text preceding the Example doesn't actually justify this for the case of a non-zero acceleration.  If you generalize what I've done above, you can see that justification will arise.
