Sample chapters

This page contains sample chapters from the book Computational Physics by Mark Newman. You're welcome to download these chapters, print them out, use them in class, or just read them for yourself. Comments and questions are welcome.

Chapter 2: Python programming for physicists – This chapter gives an introduction to the Python language at a level suitable for readers with no previous programming experience. It introduces the basic elements of programming with variables and arrays, assignments, arithmetic and functions, inputs, outputs, conditionals, and loops, all in the Python language. The ideas are illustrated with examples drawn from various branches of physics, including classical mechanics, special relativity, and quantum physics.

Chapter 3: Graphics and visualization – This chapter gives an introduction to some of Python's features for making scientific graphics, including graphs, density plots, and 3D visualizations of physical systems.

Chapter 4: Accuracy and speed – Very important for good scientific programming is an understanding of the limitations of the computer. Computers are neither infinitely fast nor infinitely accurate. This chapter explains how we estimate the accuracy of our calculations and how long they will take, and some of the pitfalls that can be encountered if we don't take care with such things.

Chapter 5: Integrals and derivatives – Having mastered the fundamentals of Python programming, we move on to the main business of computational physics. This chapter introduces methods for performing integrals and derivatives on the computer, including basic techniques like the trapezoidal rule and Simpson's rule, and more advanced techniques like adaptive methods, Romberg integration, and Gaussian quadrature. Example applications include the heat capacity of solids, thermal radiation, electrostatics calculations, and image processing.

Subsequent chapters of the book cover a range of further topics in computational physics, including the solution of linear and nonlinear systems of equations, the solution of ordinary and partial differential equations, Fourier transforms, stochastic processes, and Monte Carlo methods.

Appendices

Here are three appendices that accompany the chapters above: