Linear algebra and notations
Contents
Linear algebra and notations¶
This section introduces the basic concepts of linear algebra and notations used in this course. The concepts are introduced in a self-contained manner, and you can skip this section if you are already familiar with the concepts.
Scalars, vectors, and matrices¶
Scalars: a scalar is a single number. In this course, if not specified, scalars are denoted by lowercase letters, e.g.
. When introducing a scalar, we will specify its type, e.g. , where is the set of real numbers.Vectors: a vector is an array of numbers, which are arranged in order. Usually we denote vectors as lowercase letters in bold, e.g.
where the superscript
denotes a common vector/matrix operation called transpose, which flips the row and column, e.g. , and . The elements of a vector can be accessed by their index, and denoted as a scalar with a subscript, e.g. is the first element of . We can also index a set of elements of a vector. For example, we can define the set and then access the 2nd and 4th elements of by , i.e. . We can also index a set of elements of a vector by a boolean array, e.g. , where . When introducing a vector, we can specify its type, e.g. if each element in is in , we can specify it as , where is the set of -dimensional real vectors.
Matrices: a matrix is a 2D array of numbers. Typically we denote matrices as uppercase letters in bold, e.g.
If a real valued matrix
has rows and columns, we can specify it as . We usually identify an element of a matrix as a scalar with its row and column indices, e.g. is the element in the 2nd row and 3rd column of . We can also access an entire row of a matrix by writing “:” for the coordinate of columns, e.g. is the 2nd row of . We can also access columns of a matrix in the same way, e.g., is the 3rd column of . The transpose of a matrix flips the rows and columns along the diagonal, e.g.
Operations on matrices¶
A matrix
can be multiplied by a scalar or add a scalar to a matrix:Addition and subtraction: we can add or subtract two matrices with the same shape. The result is that all corresponding entries are added, i.e.
Matrix multiplication: If the number of columns of matrix
is equal to the number of rows of matrix , the matrices can be multiplied in the order , . The result will be a new matrix , that has the same number of rows as and the same number of columns as . The entries will be the following combination of the entries of row of and column of , i.e.Element-wise multiplication: we can also multiply two matrices with the same shape element-wise, i.e.
where
is the symbol for element-wise multiplication, and is also called the Hadamard product of and .
Examples
The multiplication of a number and a matrix
The sum of two matrices of the same shape
The multiplication of two matrices:
Some properties of matrix multiplication:
. . . , where is the identity matrix. if and are square matrices. . . .
Special matrices¶
Diagonal matrices contain non-zero elements only on the diagonal, i.e.
for . For example, the following matrix is a diagonal matrix:All diagonal matrices are square.
Identity matrices are special diagonal matrices with ones on the diagonal (and zeros elsewhere), i.e.
for and for . For example, the following matrix is an identity matrix:Symmetric matrices are square matrices that are equal to their transpose, i.e.
, or . For example, the following matrix is a symmetric matrix:Invertible matrices are square matrices that can be multiplied with another matrix to yield the identity matrix. The inverse matrix of a matrix
is denoted as , and according to the definition . The inverse matrix of an identity matrix is itself, e.g.An Orthogonal matrix is a square matrix whose columns are mutually orthogonal and have unit length, i.e.
, where is the identity matrix.
Exercises¶
1.
What kind of matrices is it? There can be multiple answers.
a. Diagonal
b. Identity
c. Symmetric
d. Invertible
e. Orthogonal
Compare your answer with the solution below
Click to show
a , c, d.
The given matrix has values only in the diagonal; that’s why it’s a diagonal matrix. The diagonal values are not 1, so it’s not an identity matrix. If you transpose the given matrix, it will equal the given matrix, so it’s symmetric. A diagonal matrix without any zero on its diagonal is always invertible, so this is an invertible matrix. For the orthogonal matrix
2.
Calculate the following matrix operations by hand.
i.
ii.
iii.
Compare your answer with the reference solution below
Click to show
i.
ii.
iii.