//Aarhus University / Physics / Subatomic / Theory >

Practical Programming and Numerical Methods 2022

[ wiki/List | ../tmp | ./exercises | ./homeworks | ./notes | ./lectures | ./matlib | ./examples | old homepages ]
[//aarhusuniversity.zoom.us/j/4106164110]
[list of the examination projects]
[ LinEq | LeastSq | EVD | Krylov | ODE | quad | mc | roots | min | optim | ann | fft ]

NB

Schedule

Plan

  1. Introduction.
    • About the course; exercises/homeworks; code repositories; examination.
    • POSIX [] (UNIX) systems; clusters and supercomputers [CSCAA, top500 supercomuters].
    • Programming languages for scientific computing [n-body benchmark].
    • We shall only use open software in this course [libresoft].
    ⊕ Exercise "posix".

  2. Code repositories. Makefiles.
    • Distributed Version Control [] systems and code repositories; Mercurial [] (hg) and Git [] (git);
    • POSIX make utility [] for managing projects on a computer.
    • C-sharp [] mono [] framework for POSIX programming.
    ⊕ Reading: note "make" [], introduction to Git from atlassian [].
    ⊕ Exercises: exercise "git", exercise "hello";
    ⊕ Extra reading: Chapter "Introduction To Makefiles"[] in the "GNU make manual";
    ⊕ Extra extra reading: Chapter "make - maintain, update, and regenerate groups of programs", of the POSIX standard [IEEE Std 1003.1-2017 (POSIX.1-2017)]

  3. Basics of C# programming.
    • Structure of a C#-program; Main function.
    • Basic types: int double string complex; Scope of variables; Variable shadowing.
    • Compiling, linking, and running C#-programs with mono.
    • Simple output with System.Console.Write method.
    • Mathematical functions in the System.Math class.
    ⊕ Exercises: "math";
    ⊕ Reading: notes "C#-program"[], "Scope"[], "Simple output"[], "Compile/link/run"[];
    ⊕ Reading: Makefile automatic variables[]: $@ (the target), $< (the first prerequisite), $^ (all prerequisites).
    ⊕ Extra reading: C#-syntax / Program structure[], C#-syntax / Operators[];
    ⊕ Extra reading: Math functions in the System.Math class []; the System.Console.Write method[] method for simple output;
    Hints:

  4. More Csharp: conditionals, loops, classes.
    • Conditional if else; Loops for, while, do while; Loop foreach;
    • Arrays; Classes/structs; Value/reference type; Example: "vec" class;
    ⊕Reading: C# conditionals []; C# loops []; C# arrays []; C# classes [];
    ⊕Exercises: "wiki", "epsilon";
    ⊕Homeworks: "vec";
    ⊕Quiz:
    1. Rewrite the for-loop for(init;condition;increment)body using the while-loop.
    2. Rewrite the while-loop while(condition)body using the for-loop.
    3. Rewrite the do-while-loop do body while(condition) using the while-loop.
    4. Rewrite this piece of code, (condition?iftrue:iffalse), using the "if" statement. Hint: google "ternary conditional".
    5. What is the difference between "class", "static class", and "struct"?
    6. What is the difference between "value type" and "reference type".

  5. File input/output.
    • Standard streams, redirections, piping; File streams;
    • Command-line arguments to Main function;
    ⊕ Exercise: complex;
    ⊕ Homework: Input/Output;
    ⊕ Reading: note "Input/Output";
    ⊕ Extra reading: Standard streams []; Standard streams in C# []; Redirection and piping []; Microsoft docs: command line arguments [];
    ⊕ Quiz:
    1. What are the types of System.Console.Out and System.Console.In?
      Hint: try //docs.microsoft.com/dotnet/api/system.console.out and //docs.microsoft.com/dotnet/api/system.console.in
    2. What are the delimiter-charactes in the command-line string?
    3. What are the arguments to the Main(string[] args) function after this command,
      mono main.exe $(echo -e 1 '\t \n \t' 2     '\t\t' 3)
      
    4. What is the maximum length of the command-line in your system?
      Hint: try getconf ARG_MAX and/or (if you use GNU) echo|xargs --show-limits.

  6. More C-sharp: generics; delegates; closures.
    • C-sharp generics;
    • Passing functions around: delegates; Anonymous delegates; Closures;
    ⊕ Reading: note "generics"; note "delegates";
    ⊕ Exercise "pass functions";
    ⊕ Homework "generic list";
    ⊕ Extra reading: C-sharp generics[]; C-sharp delegates[]; System.Func delegate[]; Closures in computer programming[];

  7. Multithreading, multiprocessing, parallel computing.
    • Symmetric multiprocessing; threads;
    • System.Threading.Thread class: preparing, running, and joining threads;
    • Pitfalls in parallelism;
    ⊕Reading: note "multiprocessing";
    ⊕Exercise "multiprocessing";
    ⊕Extra reading: system.threading.thread class []; potential pitfalls in parallelism.

  8. Scientific plots with pyxplot/gnuplot/plotutils.
    ⊕Reading: Pyxplot manual, chapters Introduction, Installation, First steps.
    ⊕Extra reading: Gnuplot manual, Graph manual.
    ⊕ Homework "plots";
    ⊕ Quiz:
    1. In pyxplot, how do you specify the ranges on the x- and y-axis?
    2. In the datafile for pyxplot, how do you separate data intended for separate lines on the plot?
      Hint: pyxplot: plotting datafiles.
    3. Suppose you have a data-file with several columns of data. With pyxplot, how would you plot, say, third column vs. second?
      Hint: pyxplot: plotting datafiles.
    4. Suppose you have a data-file with (x,y) data organised in two columns. How would you plot, say, vs. x?
      Hint: pyxplot: plotting datafiles.
    5. Explain the syntax `command` and $(command) in bash. Hint: Bash command substitution; POSIX shell command substitution.
    6. Why do you need double-dollar, $$(command), in the Makefile? Hint: GNU make: variables in recipes.
    7. What will the following Makefile print?
      pwd = a string
      test:
      	@echo pwd
      	@echo `pwd`
      	@echo $(pwd)
      	@echo $$(pwd)
      

  9. (to be removed next year) Making scientific reports with LaTeX
    • LaTex basics, math, figures.
    ⊕ Reading: chapters "Basics", "Document Structure", and "Importing Graphics" in the LaTeX wikibook.
    ⊕ Exercise "latex".

  10. Matlib Csharp mathematical library
    • Compiling, linking, and using matlib.
    ⊕ Exercise "integration".
    ⊕ Exercise "odeint".

  11. Interpolation 1 [chapter "Interpolation"] [homework "splines"]
    • Polynomial interpolation;
    • Spline interpolation: linear, quadratic, cubic splines;
    • Object oriented and functional programming styles.

  12. Interpolation 2
    •Akima sub-spline (→exam) and monotone cubic interpolants;
    •Rational function interpolation, Berrut interpolants (→exam);
    •Bilinear interpolation on a rectilinear 2D grid (→exam);

  13. Linear equations [chapter "Linear equations"] [homework "linear equations"]
    • Triangular systems, back/forward-substitution;
    • QR-decomposition: modified Gram-Schmidt algorithm, Householder reflection algorithm, Givens rotation algorithm;
    • LU-decomposition: Doolittle algorithm (→exam);
    • Cholesky decomposition (→exam);
    • Determinant of a matrix;
    • Matrix inverse.

  14. Ordinary least-squares problem [chapter "Ordinary least-squares"] [homework "least-squares"]
    • Least-squares problem;
    • Least-squares solution with QR-factorization; Pseudoinverse of a matrix (→exam?);
    • Ordinary least-squares fit, fit errors and covariance matrix.

  15. Eigenvalue (EVD) and singular value (SVD) decompositions of matrices [chapter "Eigenvalues"] [homework "eigenvalues"]
    • Eigenvalues and eigenvectors; Eigenvalue decomposition (diagonalization) of a matrix;
    • QR/QL algorithm; Jacobi eigenvalue algorithm;
    • Rank-1 and Rank-2 updates of an EVD (→exam);
    • Singular value decomposition of a matrix (SVD) (→exam);

  16. Power methods and Krylov subspaces (linear algebra) [chapter "Power methods"]
    • Power and inverse iteration methods (→exam);
    • Arnoldi and Lanczos methods (→exam);
    • GMRES (Generalized Minimum RESidual) method for aproximate solutions to systems of linear equations.

  17. Ordinary differential equations (ODE) - 1 ["chapter ODE"] [homework "ODE"]
    • Runge-Kutta (one-step) methods;
    • Local error estimate;
    • Adaptive step-size strategy;

  18. Ordinary differential equations (ODE) - 2
    • Implicit, multi-step, and predictor-corrector steppers;

  19. Numerical integration (quadratures) [chapter "Integration"] [homework "quadratures"]
    • Newton-Cotes quadratures (quadratures with regularly spaced abscissas);
    • Adaptive algorithms with regularly spaced abscissas;
    • Quadratures with optimized nodes; Gauss and Gauss-Kronrod quadratures;
    • Variable transformation quadratures; Clenshaw-Curtis quadrature;

  20. Monte Carlo integration [chapter "montecarlo"] [homework "Monte Carlo"]
    • Plain Monte Carlo sampling; pseudo- and quasi-random (= low discrepancy) sequences.
    • Importance and Stratified sampling.

  21. Nonlinear equations / root-finding [chapter "roots"] [homework "roots"]
    • Modified Newton's method with backtracking linesearch;
    • Quasi-Newton methods;

  22. Minimization 1: locally convergent methods [chapter "Minimisation"] [homework "Minimisation"]
    • Modified Newton's method with backtracking linesearch;
    • Quasi-Newton methods: Broyden and SR1 updates;
    • Dowhill simplex method (Nelder-Mead);

  23. Minimization 2: globally convergent methods [chapter "Optimization"]
    • Simulated annealing;
    • Particle swarm optimization;

  24. Artificial Neural Networks [chapter "Artificial Neural Networks"] [homework "neural network"]
    • Artificial neurons and neural networks;
    • Three-layer feed-forward neural networks; input, output, and hidden neurons;
    • Network training;

  25. Fast Fourier transform and applications [chapter "FFT"]

  26. Numerical methods for solving the few-body (partial differential) Schrödinger equation

References

  1. Gnuplot documentation [];
  2. Pyxplot user's guide [];
  3. LATEX wikibook [];