Statistical Physics Using Mathematica

James J. Kelly
Department of Physics
University of Maryland
College Park, MD 20742

    For several years I taught an introductory graduate course entitled Methods of Statistical Physics at the University of Maryland that emphasizes ensemble methods for equilibrium statistical mechanics and thermodynamics.  Details of the syllabus can be found at the course web page, PHYS603.  Here we offer courseware using Mathematica that instructors and students may find useful at other universities also.

    Although many good textbooks on Statistical Physics are available, I noticed while preparing my first set of lecture notes that figures were often reproduced from one generation of textbook to the next with decreasing fidelity, with the result that significant distortions or even outright errors eventually appeared in some recent books.  The problem appears to be that creation of these figures often requires substantial numerical effort that recent authors eschewed, relying instead upon illustrators to produce faithful adaptations from classic texts.  Unsatisfied with this approach, I endeavored to reproduce many of these figures and found that performing the numerical work was often quite instructive in itself.  Not being a specialist in statistical physics, I derived considerable satisfaction from performing both the derivations and the computations needed to solve a wide variety of problems and to produce accurate figures.  Therefore, I decided to provide my students with course materials that would help prepare them for computational methods of problem solving.  After all, first-year graduate students are not specialists yet either and hopefully would appreciate achieving self-sufficiency also.

    Traditional physics education tends to limit its choice of problems to those which a clever mathematician can solve in symbolic form, but modern research depends upon computational tools because relatively few interesting problems can be solved using purely analytical techniques.  Furthermore, even if a symbolic solution is possible, it is often very difficult to produce accurate sketches of the dependencies of various thermodynamic properties upon the relevant variables without the assistance of a computer program.  Although such plots are essential to the development of understanding and physical insight, few students can produce realistic sketches unaided; in fact, most instructors reproduce on the blackboard figures produced by computers and imply that students should achieve comparable accuracy without such assistance.  

    Mathematica is a powerful symbolic manipulator which provides very useful tools for solving problems and exploring the results. Its symbolic, numerical, and graphical tools allow the student to focus more upon physics than upon either algebra or numerical algorithms.  Although custom programs using compiled languages like Fortran or C can provide faster large-scale computation, I often develop the outline of a solution and numerical algorithms using Mathematica first and then test my compiled programs against it.  The sooner that students become proficient with computer-aided mathematics, using Mathematica or a related system, the more productive researchers they will become.  It may not be a panacea, but such tools are essential to modern science.  The present courseware for statistical physics assumes that the reader is already familiar with Mathematica, but we also offer a course entitled Essential Mathematica for Students of Science that teaches the fundamentals of Mathematica using a tutorial approach that is suitable for self study; the getting started notebook provides sufficient background for this course.

    Two types of notebooks are provided.  Formalism notebooks present the formalism of equilibrium statistical physics in a format that is similar to that of traditional textbooks, except that hyperlinks are often provided to related materials.  These notebooks use the typesetting features of Mathematica to present and discuss the theory of statistical physics, but do not include Mathematica code.  Application notebooks use the symbolic, numerical, and graphical tools of Mathematica to solve problems in statistical physics.  All code needed to produce these solutions is present and can be used by students as templates for the solution of their homework problems.  Most of the figures shown in the formalism notebooks were actually produced in one of the application notebooks, as were most of the symbolic developments.  

    The formalism notebooks and many of the application notebooks include many "end-of-chapter" problems.  Some of these problems can be solved by traditional means, but many require numerical methods.  Although some are purely formal in nature, most would benefit from the computational or graphical capabilities offered by Mathematica.  Students are encouraged to submit well-formatted notebooks that utilize the typesetting features of the system.  Detailed solutions are available to all problems assigned as homework in the last few years and can be supplied to qualified instructors upon request.  These solutions have not been made public so that instructors can assign homework without the solutions being in general circulation.

    The notebooks may be accessed using the hyperlinks below.  To view the files directly, you must configure your web browser to launch either Mathematica or MathReader for files with the nb extension.  MathReader is a free program that will display or print a Mathematica notebook, but it cannot evaluate or edit notebooks.  Alternatively, you may download files to your computer and launch the application manually.

    Most of the application notebooks were originally written in 1996, but have been extensively revised in subsequent years; please check the dates to make sure that your copies are current.  The present versions were prepared using Mathematica 4.1, but most should still run under Mathematica 3.0 with little or no change.  The formalism notebooks were written in 2000 and 2001 to provide a more consistent presentation than was possible using textbooks with different notational conventions for formal development of the theory.  Although several different traditional textbooks were chosen for the course in various semesters, their usefulness has decreased as the present materials became more complete.

Last updated: June 25, 2002


Reviews thermodynamics and some of the techniques for derivation of thermodynamic relationships.
Revised May 11, 2002
The basic postulates of statistical mechanics are used to derive and explain the laws of thermodynamics.  Our approach relies upon the information-theory concept of disorder and identifies the disorder within a statistical ensemble with thermodynamic entropy.
Revised May 11, 2002
Two methods for construction of canonical probability distributions are presented.  The first is based upon thermal interaction between a sample and a much larger reservoir of heat.  The second maximizes entropy subject to constraints upon mean values of energy and perhaps other variables.  The microcanonical, canonical, and grand canonical ensembles are developed in detail. 
Revised May 11, 2002
The properties of ensembles composed of points in classical phase space are studied.  Two important theorems, equipartition and virial, are developed.  Correspondence with quantum mechanics is used to establish a fundamental cell size in phase space that permits computation of finite entropy for semiclassical ensembles.  Applications are made to ideal gases and diatomic molecules.  
Revised May 14 2002
The effects of intermolecular interactions upon the mechanical and thermal equations of state are studied for classical fluids.  The temperature dependence of the second virial coefficient, which governs these effects for dilute systems, is derived for realistic potentials and explained using a model from which one can also derive the van der Waals equation.  Next we discuss the measurement of the pair correlation function in denser systems using X-ray or neutron scattering.  Finally, the relationship between correlations and density fluctuations is developed. 
Revised May 29 2002
The indistinguishability of identical particles has profound effects at low temperatures and/or high densities where quantum mechanical wavepackets overlap appreciably.  The occupation representation is used to study the statistical mechanics and thermodynamics of ideal quantum gases satisfying Fermi-Dirac or Bose-Einstein statistics.  This notebook concentrates upon formal and conceptual developments, while the auxiliary notebooks occupy.nb, fermi.nb, and bose.nb provide technical support and further developments. 
Revised May 14, 2002


Uses the microcanonical ensemble to investigate the paramagnetism of spin-1/2 systems. The physical interpretation of the phenomenon of negative spin temperature is discussed in some detail.
Revised May 29, 2002
Uses the microcanonical ensemble to investigate the thermodynamics of independent oscillators. The Einstein model of lattice vibrations is presented.
Revised May 29, 2002
The combinatorial method is used to solve the Ising model for a one-dimensional chain of spin-1/2 atoms in an external magnetic field with nearest neighbor spin-spin interactions.
Revised May 29 2002
Uses the canonical ensemble to investigate the thermodynamics of binary systems. The Schottky effect is discussed as a manifestation of the quantization of the excitation-energy spectrum.
Revised May 29, 2002
Investigates the thermodynamics of paramagnetism for arbitrary spin using the canonical ensemble. The classical limit is developed also.
Revised May 29, 2002
Uses a mean-field model to study spontaneous magnetization for ferromagnetic systems, with particular attention to behavior near the critical point.
Revised May 14 2002
Compares the Debye and Einstein models of lattice vibrations of a crystal. The Grueneisen model of expansivity is also developed.
Revised May 14, 2002
Compares the Planck model of black-radiation with earlier classical models. Also discusses Hawking radiation from black holes.
Revised May 14, 2002
Studies rotational and vibrational contributions to the heat capacity of ideal gases composed of diatomic molecules.
Revised May 29, 2002
The second virial coefficient for classical gases is evaluated for realistic intermolecular potentials.
Revised May 29, 2002
Properties of the van der Waals gas, including the Maxwell construction, are developed.
Revised May 29, 2002
Investigates the statistics of occupation numbers for the Fermi-Dirac, Bose-Einstein, and Maxwell-Boltzmann distributions. The dependencies on both temperature and chemical potential are evaluated.
Revised May 14, 2002
Investigates the thermodynamics of ideal nonrelativistic Fermi-Dirac gases.
Revised May 14, 2002
Investigates the thermodynamics of ideal nonrelativistic Bose-Einstein gases.
Revised May 14, 2002


    Please notify me of any errors you find.  Comments and suggestions are welcome.  My e-mail address is