Lecturer: Masud Haque (haque@thphys.nuim.ie)

Lectures and Tutorials

Lecture schedule: (1) Thursdays 12-1, lecture (2) Thursdays 2-4, lab

Assignment

Assignment 10. Due: Wednesday December 9th.

Assignment 09. Due: Wednesday December 2nd.

Assignment 08.
Due: Wednesday November 25th.

Discussion/
hints on Assignment 08.

Assignment 07.
Due: Wednesday November 18th.

Discussion/
hints on Assignment 07.

Assignment 06.
Due: Wednesday November 11th.

Discussion/
hints on Assignment 06.

Assignment 05. Due: Wednesday November 4th.

Assignment 04. Due: Friday October 23rd.

Assignment 03. Due: Friday October 16th.

Assignment 02. Due: Friday October 9th.

Assignment 01. Due Friday October 2nd.

Lecture Slides

Problem collections

These collections of problems should give you a sense of what you are expected to have learned.

Problem collection 01: on random numbers, Monte Carlo methods, and using Monte Carlo for statistical physics problems.

Problem collection 02: on optimization algorithms.

Problem collection 03: on ODEs and linear systems (matrices).

Problem collection 04: on PDE's and Fourier methods.

Previous exam solutions

Some previous exam solutions below.

The lectures, assignments, and problem collections should provide
orientation for the topics to be addressed in the 2021 exam. (Some
topics might be different from previous years.)

MP468C 2018 exam with solutions.

MP468C 2019 January exam with solutions.

MP468C 2019 Repeat exam with solutions.

Lab Exercises

Lab 10 problems

for the virtual lab on 10th December.

Lab 09: For the virtual lab on 3rd December: Explore and
understand
this program implementing the forward-time-centered-space (FTCS)
scheme for the diffusion equation.

Use it for dt=0.0012 and dt=0.0013 to see if you can observe the
onset of instability.

Lab 08 problems

for the virtual lab on 26th November.

Feedback on lab 07, solving ODE using matrix
formulation:

Of course, you have to work out the matrix first, which is not
trivial. Trying to write or understand a computer program without
first figuring out the discretization into a matrix problem?
Unlikely to work.

Here is a
sample python program where the matrix is constructed by
simply looping through matrix indices.

Here is a
another sample program. This is a bit more sophisticated
because the matrix is created in sparse format. The nonzero
elements and their locations are first collected in three 1D
arrays called row, col and data.

Here are plots of the solution for N=10,
and for N=50,
and also for N=100.

Lab 07 problems

for the virtual lab on 19th November. Submit by moodle.

Lab 06 problems

for the virtual lab on 12th November. Submit by moodle.

Lab 05 problems

for the virtual lab on 5th November. Submit by moodle.

Lab 04 problems

for the virtual lab on 22nd October. Submit by moodle.

Lab 03 problems

for the virtual lab on 15th October. Submit by moodle.

Lab 02 problems

for the virtual lab on 8th October. Submit by moodle.

Some discussion/comments on the Lab 01 problems.

Lab 01
problems

For the lab on 1st October.

John Brennan's notes

John's notes for MP468: John Brennan has written notes for some part of what used to be covered in this module.

Online external links

Hope some of the following are helpful. Please let me know if any of the links are broken!

- General notes on random variables and
Monte Carlo:
Class slides on random number generation. Similar material as the first two weeks of MP468.

(Author: BenZvi, Rochester)Class slides on random number generation, Monte Carlo integration, etc.. Similar material as the first two weeks of MP468.

(Author: ?, Harvard)Class notes on Monte Carlo methods. (Author: Goodman, NYU)

Chapter 7 of the Numerical Recipes in C.

- Inverse Transorm sampling for generating random variables with desired
distribution:
Also known as Inverse CDF sampling. In previous versions of this module, the phrase Transformation method was used.

1986 book ``Non-Uniform Random Variate Generation ''. Chapter 2 describes inverse transform sampling and the rejection method.

A blog post describing inverse transform sampling. The code is not python but easy to read.

(Author: M.Bonakdarpour) - Rejection method for generating random variables with desired
distribution:
A blog post on rejection sampling, with python code.

(Author: A.Kristiadi)Another blog post on the rejection method, also with python code.

(Author: jyyuan)Wikipedia page. (Not a very easy read, I found.)

A youtube video on rejection sampling. . (The code is in Mathematica and not discussed in detail.)

(Author: Ben Lambert ) - Monte Carlo integration:
Wikipedia page. First part is a pleasant read. Importance sampling is also introduced.

Notes on Monte Carlo integration and importance sampling, with exercises.

(Author: ?, Brigham Y Univ)Lecture slides covering Monte Carlo integration. Also material on random number generation.

(Author: Rummukainen, Helsinki) - Markov chain Monte Carlo, Ising model:
An undergraduate report on MCMC calculations for Ising model.

Easy to read. See derivations, Equations (6) and (7), for specific heat and magnetic susceptibility.Another undergraduate report on same topic.

Easy to read.A detailed description of the 2D Ising model phase transition and its simulation.

Should also be easy to read.Lecture notes from Leuven: ``Advanced Monte Carlo Methods''

Chapter 2 explains the basics of equilibrium MCMC very clearly and in detail.Notes: ``Monte Carlo Simulations of Spin Systems''

(Author: W.Janke, Leipzig)``Introduction to Monte Carlo Methods''

(Author: Katzgraber)``Introduction to Monte Carlo Methods for an Ising Model of a Ferromagnet''

(Author: Kotze)Lecture slides for Monte Carlo, simulations, phase transitions

From Helsinki. - Optimization:

Textbooks and other general sources

- General texts on Numerical Analysis/ Scientific Programming /
Computational techniques:
There are many, many textbooks covering aspects of numerical
techniques. Some are listed or discussed below. Of course, not all
topics of MP468C are covered in every textbook.
*Numerical Recipes in C:*from the mid-1990's. This used to be a standard reference on computational techniques. The most relevant chapters for MP468 are probably Chapters 2, 7, 10, 16, 17 and 19.

It is publicly available --- you can obtain all individual sections from the publisher's webpage. There seem to be also pdf copies all around the internet, but I don't know the legality of those.

Some parts of the NRC are considered outdated, e.g., (1) the practice of using `float' instead of `double'; (2) the description of available software; (3) some naming conventions.

Nevertheless, you can learn a lot from this large text.MP468C was designed around Numerical Recipes, so many topics will be found there.

*Scientific Computing and Differential Equations: An Introduction to Numerical Methods*by G.Golub and and J.Ortega, 1992.

I like this book a lot and have learned a lot from it over the years.

Although this is also from the 1990's, the authors focus on fundamental principles which have not changed.*A Concise Introduction to Numerical Methods*by A.C.Faul, 2016.

A recent text; short and modern.*Numerical Methods in Physics with Python*by A.Gezerlis, 2020.

A new text; covers many topics in good detail.*Scientific Computing: An Introductory Survey*by M.T.Heath, 2nd ed. 2018.

Covers many of the MP468 topics.- The following two seem to be standard undergraduate texts on
numerical analysis nowadays. (I haven't used either of them myself.)
*Numerical Analysis*by Burden, Faires, Burden, 10th ed. 2015.*Numerical Analysis*by T.Sauer, 3rd ed. 2017.

- Python-specific information/texts:
- Information on python, numpy and scipy are widely available
online. Because there is so much information, avoiding unreliable
pages can be a problem.

I recommend whenever possible relying on the official documentation, e.g, the

official documentation for python, the

official documentation for numpy, and the

official documentation for Scipy.Regarding Q-and-A sites: my impression is that currently answers on stackoverflow.com tend to be reasonably informative and reliable, compared to many other sites.

Here is some serious documentation (``lectures'') for Scipy.

- There are by now quite a number of texts on scientific programming in
python. E.g.,
*A Primer on Scientific Programming with Python*by H.P.Langtangen, kindly made available online by the author.

- Information on python, numpy and scipy are widely available
online. Because there is so much information, avoiding unreliable
pages can be a problem.
- Texts on specific subjects covered in MP468C:
There are many texts on each of the following topics. In MP468C we can only introduce the basics of each topic, very superficially and very selectively. I list a (random-ish and very limited) selection of texts. Each of these texts covers the topic in far more depth than we can hope for in this module.

- Monte Carlo, random numbers, MCMC simulations:
In the next section, there are links to online sources for this part of the module. Some texts on the topic:

*Monte Carlo Methods in Statistical Physics*by M.E.J.Newman und G.T.Barkema, Oxford Univ. Press*Statistical Mechanics: Algorithms and Computations*by W.Krauth, Oxford Univ. Press*Explorations in Monte Carlo Methods*by R.W.Shonkwiler and F.Mendivil, Springer*A Guide to Monte Carlo Simulations in Statistical Physics*by D.P.Landau and K.Binder, Cambridge Univ. Press - Optimization:
*Nonlinear optimization: Methods and Applications*by H.A.Eiselt and C.-L.~Sandblom, Springer.*Algorithms for optimization*by M.J.Kochenderfer and T.A.Wheeler, MIT Press*Convex optimization*by S.Boyd and L.Vanderberghe, Cambridge Univ. Press*Numerical Optimization*by J.Nocedal and S.J.Wright, Springer - Linear equations, linear algebra,
matrices:
*Numerical Linear Algebra*by L.Trefethen and D.Bau, SIAM*Numerical Linear Algebra: An Introduction*by H.Wendland, Cambridge Univ. Press*Numerical Linear Algebra and Matrix Factorizations*by T.Lyche, Springer - Partial differential equations:
*Numerical Solution of Partial Differential Equations: An Introduction*by K.W.Morton and D.F.Mayers, Cambridge Univ. Press*Partial Differential Equations with Fourier Series and Boundary Value Problems*by N.Asmar, Dover

- Monte Carlo, random numbers, MCMC simulations:

Unix/ linux tutorial

Unix tutorial prepared by Jonivar some years ago