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:
- Create a 3x3 matrix
A
and a 3x1 vector b
in Julia. Print their dimensions and types.
- Perform element-wise multiplication and division on matrix
A
.
- Calculate the transpose of matrix
A
and store it in
A_t
.
- Compute the dot product of two vectors of your choice.
- Calculate the cross product of two 3D vectors.
- Find the Euclidean norm (L2-norm) of vector
b
using
Julia’s built-in function.
- Normalize vector
b
(make it a unit vector).
Matrix Multiplication & Linear Systems:
- Multiply matrix
A
by vector b
. Check if
the dimensions are compatible.
- Create another 3x3 matrix
B
. Multiply A
and B
.
- Calculate the inverse of matrix
A
(if it exists).
Handle the case where the matrix is singular.
- Solve the linear system
Ax = b
for x
using
Julia’s backslash operator (\
).
- Verify the solution by substituting
x
back into the
equation Ax = b
.
- Implement Gaussian elimination with partial pivoting to solve the
same linear system. Compare the result with the
\
operator
solution.
Special Matrices & Decompositions:
- Create an identity matrix of size 4x4.
- Create a diagonal matrix with specified diagonal elements.
- Create a symmetric matrix. Verify its symmetry.
- Create an orthogonal matrix. Verify its orthogonality (A * A’ =
I).
- Perform the LU decomposition of matrix
A
using Julia’s
lu
function.
- Perform the QR decomposition of matrix
A
using Julia’s
qr
function.
- Perform the Cholesky decomposition of a positive definite matrix
(create one).
Eigenvalues & Eigenvectors:
- Find the eigenvalues and eigenvectors of matrix
A
using
Julia’s eigen
function.
- Verify that the eigenvectors are indeed eigenvectors by checking the
equation
Av = λv
for each eigenpair.
- Construct a matrix from its eigenvalues and eigenvectors.
- Calculate the trace and determinant of matrix
A
. Relate
these values to the eigenvalues.
Linear Transformations:
- Define a linear transformation represented by matrix
A
.
Apply this transformation to a given vector.
- 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:
- Implement a simple PageRank algorithm using matrix
multiplication.
- Use Julia to perform least squares fitting to a set of data
points.
- Explore Singular Value Decomposition (SVD) of a matrix using Julia’s
svd
function. Discuss its applications (e.g.,
dimensionality reduction).
- 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.