Göm meny

TATA53 Course Materials


Assignments

Information on deadlines and how to hand in the assignments are found in the respective document. After each deadline you need to attend one of the two associated seminars, and you should be ready to present your solutions in front of the class.

Slides

Code

  • matrix_basics.py
    How to perform basic matrix operations with in python with numpy.
  • LU.py
    The example from lecture 2 on LU-decomposition, comparing the speed of solving AX=b compared to solving two triangular systems L(UX)=b.
  • lights.py and lights_2d.py
    Interactive version of the light-puzzle, and for fun, a corresponding 2d-version.
  • matrix_mult.py
    Short script to compute SJS^{-1}, good for verifying answers related to Jordan forms.
  • jordan.py
    Uses sympy to find a Jordan decomposition A=SJS^{-1}. Remember that a complete solution is required on the assignments, so just writing an answer typically gives 0p. Also note that there are many options for the matrix S, it is not unique.
  • voronoi.py
    Visualizes how different p-norms affect how distances are measured in the plane by drawing an interactive Voronoi-diagrams.
  • perron.py
    Illustrates Perron's theorem by finding eigenvalues and eigenvectors of a randomly generated positive matrix.
  • page_rank.py
    Illustrates how PageRank works in an interactive graph. Add nodes by right clicking and add arrows by left-dragging between node centers. The program shows how the PageRank of the nodes depends on the graphs structure.
  • markov_sim.py
    Simulates the weather-Markov process from the lecture, transitions between the the three states according to the probabilities of the transition-matrix, and prints the total number of visits to each state.
  • power_method.py
    Uses the power method to find the Perron-vector of a matrix, modify the number of iterations to see how quick it converges.
  • SVD.py
    Uses numpy to find a singular value decomposition (SVD) and compact SVD of a matrix. Note that this is done numerically, so the output is an approximation. Noise in the matrix or rounding errors can change the rank of the matrix which changes the sizes of matrices in the compact SVD.
  • low_rank_image.py and low_rank_image_col.py
    Image compression example. Takes an image, converts it to grayscale, applies SVD, and produces low rank approximation. In the second file this is done for each color channel separately. In the lecture I used this image, put it in the same directory as the .py files (or use your own image by changing the filename to load in the script).
  • low_rank_webcam.py
    Interactive image compression of your webcam feed using low rank approximation via SVD, you can toggle color-mode and change the rank with the c/+/- keys, see the text in the top of the file.



Sidansvarig: jonathan.nilsson@liu.se
Senast uppdaterad: 2025-02-18