SimReal / Python / Matlab: Programming - Exercise - Mathematics - Linear Algebra UiA Logo




SimReal - Python - Matlab
001 - Matrix Addition

Program an application that add two matrices:
1. Use the add-operator in numpy
2. Without use of the add-operator in numpy, instead use double for-loop


SimReal - Python - Matlab
002 - Matrix Multiplication

Program an application that multiply two matrices:
1. Use the dot-operator in numpy
2. Without use of the dot-operator in numpy, instead use triple for-loop


SimReal - Python - Matlab
003 - Matrix Operations

We have two matrices A and B (see fig).

Compute the product of A and B.

For matrix A compute:
- inverse
- determinant
- dimension
- eigenvalues
- eigenvectors


SimReal - Python - Matlab
004 - Equations

Solve the following equations:
3y + 2x = z +  1
3x + 2z = 8 - 5y
3z -  1 = x - 2y 
  


SimReal - Python - Matlab
005 - Matrix Operations - Symbolic

Almost the same as exercise 003, but this time use SymPy (symbolic algebra) to solve the following:

We have two matrices A and B (see fig) and the vector c = [12,5].

Compute the product of A and B.

For matrix A compute:
- inverse
- determinant
- eigenvalues
- eigenvectors

Solve the following equation: Ax = c


SimReal - Python - Matlab
005 - Matrix - Neighbor matrix - Given length of a path

In the figure you see four nodes (a,b,c,d).
You also see it's a connection from a to b, a to c, a to d, b to c and d to c.
Construct a 4 x 4 matrix M where the element M(i,j) is equal to 1 if there is a connection from i to j, 0 else.
If we multiply this matrix by itself, then we will have information about the number of path of length 2 between any nodes.
Here we will have the element (a,c) in the product matrix equal to 2 because there are two paths of length 2 from a to c (ab + bc and ad+dc) all other elements will be 0.
The power matrix Mn will give information about paths of length n.

1. Program an application to give the solution of this problem
2. Generalize the application to find the paths of any length between nodes.

Example: How many flights between two given cities will have n stopovers.


SimReal - Python - Matlab
007 - GPS

Program an application that simulate a GPS,
that is: Find the shortest distance between nodes.
As an example, use the graph in the figure.
Here you see four nodes: R, S, T, U and distances between the nodes.

1. Find the shortest distance between the nodes
2. Extend the application to give also the shortest path between nodes (that is, the way to travel)

MatRIC Logo