Computational Physics with
Python


Book: Computational Physics

The materials on this page are taken from the book Computational Physics, 2nd edition, by M. Newman, an introduction to the field of computational physics using the Python programming language. If you're interested you can find information about the book here. The book itself is available from the usual booksellers or online here.

The Python programming language is an excellent choice for learning, teaching, or doing computational physics. It is a well-designed, modern programming language that is simultaneously easy to learn and very powerful. It includes a range of features tailored for scientific computing, including features for handling vectors, inverting and diagonalizing matrices, performing Fourier transforms, and creating graphics.

This page contains a selection of resources I've developed for teachers and students interested in computational physics and Python.



Chapters for download

Here are several complete book chapters on Python computational physics. You're welcome to download these chapters, print them out, use them in class, or just read them for yourself. Comments or questions are welcome.

Subsequent chapters 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, Monte Carlo methods, and data analysis. For a full table of contents, see here.

Example programs

The following files contain copies of the example programs from the chapters above.

Chapter 2:

Chapter 3:

Chapter 4:

Chapter 5:

Data sets

Here are some data sets that accompany the examples and exercises in the chapters above:

Miscellaneous useful code

Here are a few other pieces of Python code that are useful for some of the exercises.


Last modified: November 24, 2025

Sources for data sets:

Mark Newman