First Law of Thermodynamics
Laws
When work $W$ is applied to a system with thermal energy $Q$, the following equation holds for the internal energy $U$:
$$ d U = \delta Q + \delta W $$
$\delta$ indicates an inexact differential.
Explanation
Since they do not have a primitive function in a clean form, it is necessary to calculate through line integration. It means that it is impossible to know exactly how much the thermal energy has changed or how much work has changed just by the change in internal energy. It might be helpful to think that whether it is $10 = 2 + 8$ or $10 = -5 + 15$, the left side is the same, which is $10$.
However, this is merely the limitation of the First Law of Thermodynamics, not the main point I want to make. On the contrary, it means that the change in internal energy can be calculated cleanly regardless of how thermal energy and work turn out. The following formulas are derived from the First Law of Thermodynamics.
Formula 1
For the distance $dx$ that the piston has pushed and the force $F$, $\delta W = F dx$
In fact, this form is hardly ever used in thermodynamics. Since the pressure $p$ and the force $F$ can be expressed as $F = pA$ for the area of the piston $A$, it is $A dx = - dV$.
Formula 2
For pressure $p$ and volume $V$, $\delta W = - p d V$
Unlike above, this form is used quite frequently, so pay special attention to the sign and memorize it.