In 1856, Rudolf Clausius, referring to closed systems, in which transfers of matter do not occur, defined the second fundamental theorem (the second law of thermodynamics) in the mechanical theory of heat (thermodynamics): "if two transformations which, without necessitating any other permanent change, can mutually replace one another, be called equivalent, then the generations of the quantity of heat Q from work at the temperature T, has the equivalence-value:"
In 1865, he came to define the entropy symbolized by S, such that, due to the supply of the amount of heat Q at temperature T the entropy of the system is increased by
In a transfer of energy as heat without work being done, there are changes of entropy in both the surroundings which lose heat and the system which gains it. The increase, , of entropy in the system may be considered to consist of two parts, an increment,  that matches, or compensates, the change, , of entropy in the surroundings, and a further increment,  that may be considered to be generated or produced in the system, and is said therefore to be uncompensated. Thus
This may also be written
The total change of entropy in the system and surroundings is thus
This may also be written
It is then said that an amount of entropy  has been transferred from the surroundings to the system. Because entropy is not a conserved quantity, this is an exception to the general way of speaking, in which an amount transferred is of a conserved quantity.
From the second law of thermodynamics it follows that in a spontaneous transfer of heat, in which the temperature of the system is different from that of the surroundings:
For purposes of mathematical analysis of transfers, one thinks of fictive processes that are called reversible, with the temperature  of the system being hardly less than that of the surroundings, and the transfer taking place at an imperceptibly slow rate.
Following the definition above in formula (), for such a fictive reversible process, a quantity of transferred heat  (an inexact differential) is analyzed as a quantity , with  (an exact differential):
This equality is only valid for a fictive transfer in which there is no production of entropy, that is to say, in which there is no uncompensated entropy.
If, in contrast, the process is natural, and can really occur, with irreversibility, then there is entropy production, with . The quantity  was termed by Clausius the "uncompensated heat", though that does not accord with present-day terminology. Then one has
This leads to the statement
which is the second law of thermodynamics for closed systems.
In non-equilibrium thermodynamics that makes the approximation of assuming the hypothesis of local thermodynamic equilibrium, there is a special notation for this. The transfer of energy as heat is assumed to take place across an infinitesimal temperature difference, so that the system element and its surroundings have near enough the same temperature . Then one writes
where by definition
The second law for a natural process asserts that