by Daniel V. Schroeder, Department of Physics, Weber State University
This document gives software-specific information on solving problems in the book that require the use of a computer.
Several problems in the book (mostly in chapters 2 and 3) ask you to make tables of multiplicities and related quantities for systems of up to a few hundred particles. These tables, and the graphs that go with them, are most conveniently made in a computer spreadsheet program. However, most spreadsheet programs will overflow on several of the exercises in the book if you try to compute the multiplicities in terms of factorials. Instead, you need to use the built-in function to compute "combinations" (defined on page 51). Both Microsoft Excel and Corel QuattroPro have such a function; I'm not familiar with other spreadsheet programs.
In Excel, the function you need is called "COMBIN". To compute the number of combinations of 20 objects chosen from 100, or "100 choose 20", you would type "=COMBIN(100,20)", for instance. To compute the multiplicity of an Einstein solid with 100 oscillators and 50 units of energy, you would type "=COMBIN(50+100-1,50)".
In QuattroPro, the function you need is called "MULTINOMIAL". To compute the number of combinations of 20 objects chosen from 100, or "100 choose 20", you would type "=MULTINOMIAL(20,80)", for instance. (Note that 80 is 100 minus 20.) To compute the multiplicity of an Einstein solid with 100 oscillators and 50 units of energy, you would type "=MULTINOMIAL(50,100-1)".
For a brief introduction to version 4 of Excel, written for those who have never used a spreadsheet before, click here. (If anyone out there would like to write a similar introduction to QuattroPro or another spreadsheet, please tell me.) For more discussion and examples of these kinds of spreadsheet exercises, see the article " A different approach to introducing statistical mechanics" by Thomas A. Moore and myself in the January 1997 issue of American Journal of Physics (volume 65, pages 26-36). The article also describes how most exercises of this type can be done (though more awkwardly) on a graphing calculator.
The stand-alone program StatMech, written by Tom Moore, can be downloaded free of charge from the Six Ideas That Shaped Physics software page. This program constructs tables and graphs for a system of two interacting Einstein solids, as in Section 2.3.
You can plot a formula using a spreadsheet, by generating the data to plot in two columns and then creating a graph of these columns. This gets the job done, but it is tedious and doesn't produce the prettiest output. Graphing calculators are very convenient for plotting formulas, but usually are not connected to printers. I therefore recommend learning a more sophisticated software package such as MathCad, Maple, or Mathematica.
In Mathematica, the basic plotting function is Plot[], and the syntax is:
Plot[Exp[-x^2],{x,-3,3}]This instruction generates a plot of the Gaussian function e-x2 for values of x ranging from -3 to 3. Note that all Mathematica functions are case-sensitive, and that built-in functions such as Plot and Exp always start with capital letters. There are an enormous number of variations on the basic Plot function, which you can learn by reading Section 1.9 of The Mathematica Book.
For a brief introduction to plotting in MathCad (written by Phil Fraundorf), click here. (If anyone out there would like to write similar instructions for plotting with a different software package, please tell me.)
Before performing a numerical calculation it's usually a good idea to plot the relevant function(s) and estimate the answer graphically. Otherwise it's much too easy to get a wrong answer and not realize it.
Many scientific calculators can handle numerical integrals and root finding; just be sure to write down exactly what you punched into the calculator, in case you need to check for errors later.
Numerical calculations in Mathematica are easy. The numerical integration function is NIntegrate; here is an example:
NIntegrate[x^2*Exp[-x^2],{x,0,.5}]The syntax is exactly the same as for the Plot function, with the list in curly braces specifying the integration variable and the beginning and ending values. To solve a transcendental equation, use the FindRoot function:
FindRoot[Tanh[x]==x/2,{x,1.5}]Note the double = sign in the equation to solve. The number 1.5 tells Mathematica where to start looking for a solution (since there may be more than one); in this case the function returned 1.91501.
For a brief introduction to numerical calculations in MathCad (written by Phil Fraundorf), click here.
Section 8.2 of the book gives a "pseudocode" program for Monte Carlo simulation of the two-dimensional Ising model. I have implemented this program in Mathematica, True Basic, and Java; just click on the preceding links to see the actual source code in the language of your choice. There's also a much more elaborate version written in REALbasic, which you can download (as source code or a compiled Mac or Windows application) from here.
Last modified on January 22, 2003.