Computer methods in theoretical physics - TMF057(ZS 2017-18)

News: (January 4, 2018) I translated LIST OF PROBLEM FOR CREDITS (Zápočtové úlohy) and I corrected few minor errors there.

(December 22, 2017) I am currently translating this web page to English. You can still see the previous version below. It contains most of the examples in Python (some using NumPy libraries) which you could see in the lecture. On the last lecture I presented preliminary LIST OF PROBLEM FOR CREDITS (Zápočtové úlohy). Only Czech version is currently available. You should select one of the problems and solve it in suitable programming language (C, C++, C#, Fortran, Pascal, Python) using floating point arithmetic. You will present your solution at the exam including your understanding of the theory related to the subject of the selected problem. The exam will consist of this presentation and one additional theoretical question. 

 

LESSON 1 – Round-off errors and numerical stability. (see [1], for deeper understanding see also [4,5,7])

Numerical demonstrations:

  1. Round-off error (trivial example) ...................... ……..demoL01.01_wrong_loop.py
  2. Sum forward = sum backward? .................................. demoL01.02_suma.py
  3. Cancellation of numbers.............................................. demoL01.03_cancelation.py
  4. Quadratic equation (optimization of round-off )......... demoL01.04_quadratic.py
  5. Why convergent series does not converge?................ demoL01.05_Taylor_exp.py

Exercise: Determination of pi according to Archimedes. (attempt1-unstable, attempt2-stable, attempt3-convergence acceleration)

LESSON 2 – Iterations and solution of nonlinear equations. (see [1], for deeper understanding also [5,7,8])

Numerical demonstrations:

  1. cos(cos(cos(...cos(1.0)...))).......................................demoL02.01_coscos.py
  2. Babylonian method of calculation of square root... demoL02.02_Babylon.py
  3. Aitken on cos cos.................................................demoL02.03_Aitken.py
  4. Aiten-Steffensen on cos cos..................................demoL02.04_AitkenSteffensen.py
  5. Newton fractal = answer to question: "Which root of  z3-1=0 you find using Newton algorithm started from given point of complex plain?" https://en.wikipedia.org/wiki/Newton_fractal

LESSON 3 - Interpolation and interpolation polynomials. (see [1], for deeper understanding [2,8])

Numerical demonstration: (using Turtle graphics from Python)

  1. Interpolation on regular grid....................................demoL03.01_regular.py
  2. Behaviour of polynomial omega................................demoL03.02_omega.gnu (script for gnuplot – tested with version 4.7)
  3. Interpolation of Chebyshev grid..............................demoL03.03_chebychev.py

LESSON 4 – Interpolation on regular grid, difference equations. (see [1], for deeper understanding [5])

LESSON 5 – Numerical differentiation and integration. (see [1], for deeper understanding [2,5,8])

Exercise: Numerical differentiation, discretization error and round-off error (values of numerical derivative for different h, graph of the error in log/log scale in using gnuplot).

Numerical demonstration: (Numerical derivative, discretization x round-off errors)

  1. Derivatives from different finite difference formulae .........demoL4.01_derivace.py
  2. Graphs of results..............................................demoL4.01_derivace.gnu (script for gnuplot)

LESSON 6 – Numerical integration of differential equations. (see [1], for deeper understanding [2,3])

Numerical demonstrations: (Numerical solution to ODE)

  1. Calculation of solution using explicit methods ...........demoL5.01_LIMUFO.py
  2. Drawing of the solution…… ....................................... reseni.gnu (script for gnuplot, shows data from previous *.py)
  3. Testing of convergence speed …………………............demoL5.02_global.py
  4. Graph of order of convergence ........................................... konverg.gnu
  5. The same as 1, 2,  but implicit methods .............................................................demoL6.01_implicit.py,    reseni.gnu
  6. The same as 3,4 but implicit ............................................................demoL6.02_stiff.py,         kstif.gnu

LESSON 7 - Numerical linear algebra – matrix factorisation. (see [2,4])

Numerical demonstrations: (QR factorisation and its application):

  1. Finding eigenfunctions of harmonic oscillator ..................DemoL8.01_QR_LHO.py
  2. Backward stability of QR factorisation..............................DemoL8.02_zpet_stabil.py
  3. Matrix rank using SVD………..........................................DemoL8.03_Hello.py

LESSON 8 – Numerical linear algebra - Gaussian elimination. (viz [2,4])

Numerical demonstrations: (Gauss elimination and LU decomposition)

  1. Gauss without pivoting......................DemoL9.01_LU_nestab.py
  2. Gauss with pivoting...........................DemoL9.02_LU_pivot.py
  3. LU decomposition from scipy library.........DemoL9.03_LU_linalg.py

LESSON 9 – Numerical linear algebra – matrix diagonalisation. (see [2,4,5])

Numerical demonstrations: (Diagonalisation using Jacobi method)

  1. Using numpy routine..........................DemoL10.01_eigval.py
  2. Jacobi method with "sweeps"..........................DemoL10.02_Jacobi.py
  3. Jacobiho method with elimination of maximum element......DemoL10.03_Jacobi_max.py

LESSON 10 - Discrete Fourier transform (I did not have time to do this year, for info: [2,3])

RECOMMENDED LITERATURE:

I am using mainly [1] and [4]. Suitable complement for practical implementation of algorithms is [2]. Other books for more details on speciffic tomics, see green notes.

Note on Pythonu: Above numerical demonstrations in Pythonu use libraries numpy and matplotlib. Python is available online for free. You could:

1 visit https://www.continuum.io/downloads and download anaconda
2 install
3 run Anaconda Launcher
4 run Spyder - IDE (interaktive console) or run Ipython-qtconsole - interactive python .


Informace z loňských stránek Karla Houfka naleznete naleznete zde.