Introduction to Computational Physics

Prof. Dr. Gerson J. Ferreira
Institute of Physics, Federal University of Uberlândia

About the course

These are the class notes for the course Computational Physics, lectured to the students of Bacharelado em Física, Física Médica, and Licenciatura em Física from the Instituto de Física, Universidade Federal de Uberlândia (UFU). Since this is an optional class intended for students with diverse knowledge and interest in Computational Physics and computer languages, I choose to discuss selected topics superficially with practical examples that may interest the students. Advanced topics are proposed as home projects to the students accordingly to their interest.

Note

Initially, I had written a book draft with examples in Julia, but since then this language has changed a lot (improved, actually!). The idea of this new webpage is to move the content of the book here and write examples in many languages (Julia, Python, and C). This will be a long process and I’ll start with Python because its documentation is more accessible to new students. Later I’ll add examples in Julia and C, these will show up as in this Hello, world! example:

print("Hello, world!")
println("Hello world!")
#include <stdio.h>

int main() {
   printf("Hello, world!\n");
   return(0);
}

Warning

TO DO! I have skipped, but we need to discuss:

  • Read/save files and string manipulation
  • Plot images / matrices with: plt.imshow(…) or plt.pcolormesh(…)
  • 3D plot with matplotlib
  • Basic calculus: contents sent by PDF, I’ll update this page as soon as possible

Topics

Since this is an introductory course, we’ll focus on simple topics that are useful to solve physics problems. Namely:

  1. Introduction to the computer language
  2. Plotting beautiful figures
  3. Numerical calculus: integrals, derivatives, root finding, …
  4. Linear algebra: system of eqs., eigenvalues, …
  5. Differential equations: initial value problems and boundary value problems
  6. Fourier transforms
  7. Random numbers and statistics
  8. Machine / Deep learning (soon)

All these topics will be applied to solve physics problems in exercies along the course.

A very quick introduction

Let’s start with a very short introduction. In computational physics a lot of things work by dropping the limits:

\[\begin{split}\begin{align} \dfrac{\partial f(x)}{\partial x} &= \lim_{\Delta x \rightarrow 0} \dfrac{f(x+\Delta x) - f(x)}{\Delta x} \approx \dfrac{f(x+\Delta x) - f(x)}{\Delta x} \\ \int f(x) dx &= \lim_{\Delta x \rightarrow 0} \sum_n f(x_0 + n \Delta x) \Delta x \approx \sum_n f(x_0 + n \Delta x) \Delta x \end{align}\end{split}\]

That’s it. Everything else is variations of these approximations. Now, let’s go into the details.

Main references

Let’s split the main references into online tutorials, links to examples and books. I’ll add more general references here as I write about each topic, while each topic will have specific references in the text.

Online tutorials, documentation and useful links

  1. Python at Tutorial’s point: [python], [numpy], [matplotlib]
  2. Official documentation for [numpy - scipy - matplotlib]
  3. Python’s Anaconda distribution

Books

About computational physics and related:

  1. Nicholas J. Giordano & Hisao Nakanishi - Computational Physics
  2. Tao Pang – An Introduction to Computational Physics
  3. Jos Thijssen – Computational Physics
  4. Philipp O. J. Scherer – Computational Physics: Simulation of Classical and Quantum Systems
  5. Cláudio Scherer – Métodos Computacionais da Física
  6. Páez & Bordeianu – Computational Physics – Problem Solving with Python
  7. Saul Teukolsky, William H. Press, and William T. Vetterling - Numerical Recipes

Numerical calculus:

  1. Neide B. Franco - Cálculo numérico
  2. Selma Arenales, Artur Darezzo - Cálculo numérico: aprendizagem com apoio de software
  3. John C. Butcher - Numerical methods for ordinary differential equations