Magnetism and free energy