Temperature measures average kinetic energy per molecule. Heat flows from hot to cold. Entropy counts microstates and always increases in an isolated system. The Carnot cycle sets the theoretical maximum efficiency of any heat engine. Boltzmann connected the microscopic (atoms) to the macroscopic (temperature, pressure).
Temperature
Temperature is the average kinetic energy per molecule: (3/2)kT = (1/2)mv² on average, where k is Boltzmann's constant. At absolute zero, all thermal motion stops. Temperature is not energy; it is energy per degree of freedom.
Scheme
; Temperature and average molecular speed; (3/2) k T = (1/2) m v_rms^2; v_rms = sqrt(3 k T / m)
(define k 1.381e-23) ; Boltzmann constant, J/K; Nitrogen molecule: m = 28 * 1.66e-27 kg
(define m-N2 (* 28 1.66e-27))
(define (v-rms T m) (sqrt (/ (* 3 k T) m)))
(display "N2 molecular speeds:") (newline)
(display " At 300 K (room temp): ")
(display (round (v-rms 300 m-N2)))
(display " m/s") (newline)
(display " At 600 K: ")
(display (round (v-rms 600 m-N2)))
(display " m/s") (newline)
(display " At 77 K (liquid N2): ")
(display (round (v-rms 77 m-N2)))
(display " m/s")
Entropy
Entropy S = k * ln(W), where W is the number of microstates consistent with the macrostate. The second law says entropy of an isolated system never decreases. This is not a force law; it is statistics. Overwhelmingly many microstates look disordered, so systems drift toward disorder.
Scheme
; Entropy: S = k * ln(W); Coin analogy: 100 coins, how many microstates for each macrostate?
(define k 1.381e-23)
; Binomial coefficient C(n, r) = n! / (r! * (n-r)!); Use log to avoid overflow: ln(C(n,r)) = sum(ln(i)) for numerator - denominators
(define (ln-binomial n r)
(let loop ((i 1) (result 0))
(if (> i n) result
(loop (+ i 1)
(+ result (log i)
(- (if (<= i r) (log i) 0))
(- (if (<= i (- n r)) (log i) 0)))))))
; Number of microstates for 100 coins with h heads
(define (ln-microstates h) (ln-binomial 100 h))
(display "100 coins - ln(microstates):") (newline)
(display " All heads (0): ") (display (round (ln-microstates 0))) (newline)
(display " 10 heads: ") (display (round (ln-microstates 10))) (newline)
(display " 50 heads (max): ") (display (round (ln-microstates 50))) (newline)
(display "50/50 has overwhelmingly more microstates.") (newline)
(display "That is the second law.")
Carnot efficiency
The Carnot cycle is the most efficient possible heat engine operating between two temperatures. Its efficiency is eta = 1 - T_cold/T_hot. No real engine beats this. The closer T_cold is to T_hot, the less work you can extract.
Scheme
; Carnot efficiency: eta = 1 - T_cold / T_hot; All temperatures in Kelvin
(define (carnot-efficiency T-hot T-cold)
(- 1 (/ T-cold T-hot)))
; Power plant: steam at 600 K, coolant at 300 K
(define eta1 (carnot-efficiency 600300))
(display "Power plant (600K/300K): ")
(display (* 100 eta1)) (display "%") (newline)
; Car engine: combustion at 1500 K, exhaust at 400 K
(define eta2 (carnot-efficiency 1500400))
(display "Car engine (1500K/400K): ")
(display (round (* 100 eta2))) (display "%") (newline)
; Ocean thermal: 300 K surface, 275 K deep
(define eta3 (carnot-efficiency 300275))
(display "Ocean thermal (300K/275K): ")
(display (round (* 100 eta3))) (display "%") (newline)
(display "Small temperature difference = tiny efficiency.")
Boltzmann connected the macroscopic (pressure, temperature) to the microscopic (molecular velocities). The ideal gas law PV = NkT follows from averaging over molecular collisions. His tombstone reads S = k log W. The second law is not a postulate; it is a theorem of statistics applied to 10²³ particles.
Scheme
; Ideal gas law: PV = NkT; N molecules, each bouncing in a box
(define k 1.381e-23) ; J/K
(define N 6.022e23) ; Avogadro's number (1 mol)
(define T 300) ; K (room temperature); Volume of 1 mole of ideal gas at 1 atm
(define P 101325) ; 1 atm in Pascals
(define V (/ (* N k T) P))
(display "1 mol ideal gas at 300K, 1 atm:") (newline)
(display " V = ") (display V) (display " m^3") (newline)
(display " V = ") (display (* V 1000)) (display " liters") (newline)
; Should be about 24.6 liters
(display "PV = ") (display (* P V)) (display " J") (newline)
(display "NkT = ") (display (* N k T)) (display " J")
Neighbors
📡 Shannon Ch. 2 — Shannon entropy is Boltzmann entropy with a different logarithm base
∞ Analysis Ch. 8 — metric spaces provide the topology for phase space