In thermodynamics and engineering, it is natural to think of the system as a heat engine which does work on the surroundings, and to state that the total energy added by heating is equal to the sum of the increase in internal energy plus the work done by the system. Hence formula_1 is the amount of energy lost by the system due to work done by the system on its surroundings. During the portion of the thermodynamic cycle where the engine is doing work, formula_1 is positive, but there will always be a portion of the cycle where formula_1 is negative, e.g., when the working gas is being compressed. When formula_1 represents the work done by the system, the first law is written: