Physics 410 : Computational Physics


Administrative Details:

Instructor: Moshe Rozali, e-mail:

TAs: Graham Reid: Office hours on Fridays 2-5 in room 310.s , Timothy Cox:

Lectures: Mondays, Wednesdays and Fridays, 11-12 in Hennings 202.

Computer Lab: Fridays, 10-11 or 12-1.

Office hours: Hennings 412, Wednesdays 12-1 or by appointment.

Changes to schedule: Class is cancelled November 13-17, makeup classes will be scheduled. The tutorial will go on that week.


Summary and Learning goals:

There are 3 intertwined themes in using numerics effectively:

Physics: Learning how to explore the situation of interest by making small and quick numerical explorations, or by planning and executing a deeper and longer study.

Mathematics: Understanding the relevant numerical analysis, so that we choose the correct algorithm for our goals.

Computer Science: Implementing our plans, making sure we optimize the resources that matter to us most (often, our time).

In this course I will try to focus on the first two aspects, assuming that on first pass efficient use of computer resources matters less than making the most of our time together. Consequently we will be using an interpreted, rather than a compiled language, which has less overhead in terms of low-level coding. Besides, as interpreters become faster and more sophisticated, this is the becoming the environment of choice for many purposes, even when doing "serious" numerical work.

We will use Matlab, which is a polished and professional framework with an intuitive interface. UBC conveniently has a site license, Matlab is installed on the computer labs on the second floor. Lowering the threshold to coding is aimed to encourage a spirit of free exploration, creating a feedback loop that makes learning more efficient, and more fun. I encourage you to experiment, this is the best road to discovery and real understanding.

Update: Matlab is available for students to install on their computers, see here.

Another common choice of interpreted programming language is Python, perhaps because some implementations of it are free. The syntax is very similar to Matlab, and some resources below use Python. I will focus mostly on Matlab for uniformity of presentation, and since most of you have more background in Matlab. After completing the course, picking up Python should be fairly easy, and I would encourage you to do that.



Linear Algebra, Integration and differentiation, some background in solving simple differential equations.

Some previous experience in programming. Matlab experience is preferable.

Examples will use knowledge of basic mechanics, electrodynamics and quantum mechanics.


Recommended Books:

There is no assigned textbook for the course. The following are presented in the order of relevance to the course.


A first Course in Computational Physics, Paul L. DeVries and Javier E. Hasbun (second edition).

A good combination of mathematics and physics, in Matlab, pitched at the right level. I will be following their presentation in some parts of the course.


Lecture Notes by Morten Hjorth-Jensen.

Very good notes, useful especially for Monte Carlo Methods.


Numerical Methods Using Matlab, John H. Mathews and Kurtis D. Fink (fourth edition)

Covers the same ground in slightly more detail, at more or less the same level, with no physics. Matlab files available online.


Numerical Analysis, Richard L. Burden and J. Douglas Faires (ninth edition).

Covering the same ground and much more, at a more elementary level, with no physics.


Computational Physics, Mark Newman (ninth edition).

Very good book, covering similar material at a similar level, in Python.


Special topics

An Algorithmic Introduction to Numerical Simulation of Stochastic Differential Equations, Desmond J. Higham, SIAM Review, Vol. 43, No. 3 (Sep., 2001), pp. 525-546.

The last part of the course, both paper and Matlab files available online.


Spectral Methods with Matlab, Lloyd N. Trefethen.

Beautifully written, a paradigm of a textbook that allows you to get into a subject easily, having lots of fun in the process. The book and associated Matlab programs are available online. Look for other resources by Threfethen, they are worth their weight in gold.


Course outline (ambitious):

We will cover some proper subset of the following, at no particular order.

-- A brief introduction to Matlab.

-- A brief introduction to computational methods: floating point numbers, sources of error, good programming habits.

-- Root finding.

-- Interpolation and approximation.

-- Differentiation and Integration.

-- Monte Carlo Methods

-- Ordinary differential equations.

-- Partial differential equations.

-- Stochastic differential equations.

-- Optimization.

-- Random Matrices.

The last few are pure fantasy, but feel free to petition me for any of them, or ask for references for self-study. For that matter, feel free to comment any time on the course and any improvement or changes you wish for.



The course will have some written homework, to practice the material, and a few small projects to construct solutions of physics problems using numerics. There will also be a final exam. The relative weights of each component will be determined later, depending on the workload. Roughly, the homework will count for about 30% of the mark, the projects for 50%, and the finals for 20%. The relative weight of the homework and projects will depend on the number of each.

Ordinary homework will be given roughly once a week, and will be due on the following week. No late homework will be accepted.

You are welcome to discuss the problems with the other students, but the submitted assignments must be your own work.

Submitted code can be in Matlab or Python, but should run on the TA's computers. You will be marked on achieving the goal, but also on good style (which will be discussed in class), and efficiency.

Please try to resolve grading issues for assignments with the markers first. Contact me if there are still unresolved issues after that discussion.


Matlab Code:


Simple bisection


Newton method


Barycentric polynomial interpolation.


Summaries of Tutorials:


Tutorial 1 (basic of Matlab)


Tutorial 2 (preparation for project 1)

Homework and Projects:


Homework 1, due Wednesday September 20. (Note an important typo was corrected in problem 1)


Project 1, due Friday October 6. Marking scheme.