The First law of thermodynamics states that energy is neither created nor destroyed. Thus the total energy of the universe is a constant. However, energy can certainly be transferred from one form to another form.
The 1st law of thermodynamics can be mathematically stated as follows:
§dQ = §dW
During a thermodynamic cycle, a cyclic process the systems undergoes, the cyclic integral of heat added is equal to integral of work done. The first law equation can also be written in the form,
§(dQ – dW) = 0
Equation dU = dQ – dW is a corollary to the first law of thermodynamics. It shows that there exists a property internal energy (U) of the system, such that a change in its value is equal to the difference in heat entering and work leaving the system.
The sign convention for heat and work in the first law of thermodynamics is represented in the picture below.
H = U + pV
For a reversible process, since dW = pdV, the first law of thermodynamics can also be written as
dQ = dU + pdV