Although both heat and work involved in the transformation of a system from one state to another is path-dependent, the quantity “Q + W” is experimentally found to be path-independent.
In other words, Q + W depends only on the initial and final states of the system!
For a cyclic process (i.e., a process that starts and returns to the same state), irregardless of whether it is reversible or not:
$$\begin{aligned} \oint \delta (Q + W) &= 0 \\ \oint (\delta Q + \delta W ) &= 0 \end{aligned}$$
Note that $\delta$ is used here rather than “d” to denote a path variable
This rearranges to:
$$\oint \delta Q = \, – \oint \delta W$$
which means that the net work output from the system in a cyclic process is exactly compensated by the net heat input.
Since $\oint \delta(Q + W ) = 0$,
(Q + W) can define a state variable.Let us call this state variable the internal energy E:
$$dE = \delta (Q + W)$$
and we get the first law of thermodynamics! Notice that:
$$\oint dE = \oint (\delta Q + \delta W) = 0$$
Note: While both Q and W are path variables, E is a state variable. Another common symbol for internal energy is U.
Next: Definition of first law of thermodynamics