# LABORATORY FOR COMPUTATIONAL PHYSICS

## Learning outcomes of the course unit

At the end of the course the student will have better knowledge and understanding as she/he will: master basic foundations of numerical evaluation of integral and numerical integration of ordinary differential equations; master the basics of finite difference operators, recognising the relationship with the iterative solutions of linear systems; master the basics of Mathematica evaluation of symbolic expressions; master the basics of dynamical Monte Carlo methods.

The student will be able to apply knowledge and understanding and in particular she/he will be able to: make use of Matlab functions to numerically compute an integral and integrate an ordinary differential equation; pin down the finite difference solution of an elliptic partial differential equation; pin down a symbolic computation in the Mathematica environment; set up a Monte Carlo computation to solve a problem in statistical mechanics, with a clear strategy for the estimate of autocorrelations and errors.

The student will be able to make judgements and in particular she/he will be able to: understand when a problema asks for a numerical solution, an analytic solution not being available; recognise when the solution of a problem can be implemented by means of symbolic computation; recognise which Monte Carlo method is best suited for a given problem.

The student will also have acquired communication skills as she/he will be able to: present her/his results in a clean, precise and concise way; present her/his results both synthetically as for the overall picture and analytically as for the most delicate points; argue her/his thesis in public, in particular acting in a team.

Finally, the student will have acquired learning skills as she/he will be able to: understand numerical solutions which she/he will find applied to certain problems in the subsequent course of her/his studies in Physics, in particular with respect to solution of partial differential equations not discussed in this course; in the study of more advanced subjects in physics, recognise when reverting to a Monte Carlo method can be due and progress in the study of algorithms beyond what she/he has learnt in this course.

## Prerequisites

Mathematical Methods for Physics. Basics of computer programming.

## Course contents summary

The course aims at introducing basic notions and tools to numerically tackle problems in Physics (each subject will be presented in the context of the solution to a physics problem). The starting point will be an introduction to algorithms implementation and control on numerical errors.

Basics of numerical evaluation of integrals and numerical integration of ordinary differential equations will be discussed, with an emphassis on making use of Matlab functionalities.

Finite difference operators will be studied, also in the perspective of their application to partial differential equations. Basic tools for the iterative solution of linear systems will be provided.

Basic symbolic calculus will be introduced in the environment of Mathematica.

A large fraction of the course will be dedicated to dynamical Monte Carlo methods, discussed in the context of solution to statistical mechanics and quantum mechanics.

## Course contents

Linux environment. Interpreted and compiled languages. Basics in C/C++.

Algorithms and their implementation in programs. One particular example (computing the exponential function) will lead to the discussion of numerical precision and error control.

Basics on numerical integration of functions; dedicated functions in Matlab.

Basics on numerical solution of ordinary differential equations (Euler and Runge-Kutta schemes; a few concepts in explicit vs implicit schemes, stiff equations and stability analysis); dedicated functions in Matlab.

Finite difference operators. A problem in electrostatics will trigger an introduction to PDE and inversion of the Laplacian operator via iterative schemes for the solution of linear systems (Jacobi, Gauss-Seidel, SOR, conjugate gradient).

Introduction to symbolic calculus. Quantum mechanics perturbation theory in the environment of Mathematica.

Dynamical Monte Carlo methods. Markov processes and stationary distributions, detailed balance, autocorrelations and error estimate.

A few Monte Carlo algorithms (Metropolis, Heat bath, Swendsen-Wang, Hybrid Monte Carlo). Applications to statistical mechanics (spin systems).

Brief introduction to the functional integral and applications to quantum mechanics (in imaginary time).

## Recommended readings

Lecture notes will be provided, made available on ELLY.

A text on numerical analysis can be useful; a natural choice (due to simplicity and broad range of contents) is

- Numerical Recipes, the Art of Scientific Computing

For Monte Carlo methods useful references are

- A. Sokal "Monte Carlo Method in Statiscal Mechanics: Foundations and New Algorithms"

- A. Pellissetto - Lezioni alla scuola di Fisica Teorica di Parma

## Teaching methods

Lectures and exercises (with students involved). Students will be asked to have their laptop always with them (if they have one).

Numerical work will be mainly worked out in Matlab, but basics of C/C++ programming will be introduced and students will be encouraged to make use of this.

Problems will be assigned to be worked out at home: proving a certain assertion, finishing a computation or writing a computer program (of a small size). All the material will be made available on ELLY (codes, Matlab sessions diaries, lecture notes).

Style will be informal, always focusing a physics problem.

## Assessment methods and criteria

Oral exam to which the candidate is admitted after having delivered a report on a project. In due advance of the exam session, a project will be assigned to the student. It will be a natural completion of subjects worked out during the lessons, with a clear assignement of what the student is supposed to do: numerical simulations, working out a few anaytical results completing results obtained during the course, comparison of expected results and results stemming from simulations, computations of errors. Students will present their written report at the latest 24 hours before the oral exam takes place.

Discussing the report will be the starting point of the oral exam. Besides a clean presentation of the technical solutions adopted and of the motivations for them, during the exam it could be required to reproduce a few results (for example: showing a program at work, verifying the correctness of a program). Both the report (and the results obtained) and the oral discussion will contribute to the final grade.