30 Linear Algebra & Matrices Tutorial Questions with Julia

These questions cover fundamental linear algebra concepts and their implementation in Julia. They are suitable for undergraduate students learning the subject.

Basic Vector & Matrix Operations:

  1. Create a 3x3 matrix A and a 3x1 vector b in Julia. Print their dimensions and types.
  2. Perform element-wise multiplication and division on matrix A.
  3. Calculate the transpose of matrix A and store it in A_t.
  4. Compute the dot product of two vectors of your choice.
  5. Calculate the cross product of two 3D vectors.
  6. Find the Euclidean norm (L2-norm) of vector b using Julia’s built-in function.
  7. Normalize vector b (make it a unit vector).

Matrix Multiplication & Linear Systems:

  1. Multiply matrix A by vector b. Check if the dimensions are compatible.
  2. Create another 3x3 matrix B. Multiply A and B.
  3. Calculate the inverse of matrix A (if it exists). Handle the case where the matrix is singular.
  4. Solve the linear system Ax = b for x using Julia’s backslash operator (\).
  5. Verify the solution by substituting x back into the equation Ax = b.
  6. Implement Gaussian elimination with partial pivoting to solve the same linear system. Compare the result with the \ operator solution.

Special Matrices & Decompositions:

  1. Create an identity matrix of size 4x4.
  2. Create a diagonal matrix with specified diagonal elements.
  3. Create a symmetric matrix. Verify its symmetry.
  4. Create an orthogonal matrix. Verify its orthogonality (A * A’ = I).
  5. Perform the LU decomposition of matrix A using Julia’s lu function.
  6. Perform the QR decomposition of matrix A using Julia’s qr function.
  7. Perform the Cholesky decomposition of a positive definite matrix (create one).

Eigenvalues & Eigenvectors:

  1. Find the eigenvalues and eigenvectors of matrix A using Julia’s eigen function.
  2. Verify that the eigenvectors are indeed eigenvectors by checking the equation Av = λv for each eigenpair.
  3. Construct a matrix from its eigenvalues and eigenvectors.
  4. Calculate the trace and determinant of matrix A. Relate these values to the eigenvalues.

Linear Transformations:

  1. Define a linear transformation represented by matrix A. Apply this transformation to a given vector.
  2. Visualize the effect of the linear transformation on a set of vectors (e.g., by plotting them before and after the transformation).

Applications & Advanced Topics:

  1. Implement a simple PageRank algorithm using matrix multiplication.
  2. Use Julia to perform least squares fitting to a set of data points.
  3. Explore Singular Value Decomposition (SVD) of a matrix using Julia’s svd function. Discuss its applications (e.g., dimensionality reduction).
  4. Write a Julia function to determine if a given set of vectors is linearly independent.

Important Notes:

  • Encourage students to use Julia’s documentation and help features (e.g., ?function_name) to learn more about the functions used.
  • These questions can be modified or extended based on the specific topics covered in the course.
  • Encourage students to write clear and well-commented code.
  • Consider providing sample datasets or asking students to generate their own data for some of the exercises.
  • These questions are designed to be progressively more challenging, allowing students to build their understanding of linear algebra concepts and their practical implementation in Julia.