MS-252 Linear Algebra
Nazar Khan
Department of Computer Science
University of the Punjab
2. Matrix Arithmetic
Matrix Multiplication Matrices and Linear Systems Properties
Matrices
I Rectangular arrays of numbers with m rows and n columns.
I If m = n, we have a square matrix of order n.
I Entries a11 , a22 , . . . , ann constitute the main diagonal.
I Transpose by swapping rows and columns.
I In matrix arithmetic
I size matters
I A + B is valid only if dimensions are equal
I A ∗ B is valid only if dimensions match
I order matters (A ∗ B 6= B ∗ A generally)
Nazar Khan Linear Algebra 2 / 14
Matrix Multiplication Matrices and Linear Systems Properties
Matrix Multiplication
I Multiplication is valid if columns of first matrix are equal to rows of
second.
I Multiplication is carried by taking the dot-product of row i of A with
column j of B.
(AB)ij = ai1 bj1 + ai2 bj2 + · · · + ain bjn
Nazar Khan Linear Algebra 3 / 14
Matrix Multiplication Matrices and Linear Systems Properties
Matrix Multiplication
4 1 4 3
1 2 4
0 −1 3 1 =
2 6 0 26
| {z } 2 7 5 2
2×3 | {z } | {z }
3×4 2×4
(AB)23 = a21 b31 + a22 b32 + · · · + a2n b3n = 2 · 4 + 6 · 3 + 0 · 5 = 26
Fill the rest.
Nazar Khan Linear Algebra 4 / 14
Matrix Multiplication Matrices and Linear Systems Properties
3 ways of looking at a matrix
a11 a12 a13 a14 a11 a12 a13 a14 a11 a12 a13 a14
a21 a22 a23 a24 a21 a22 a23 a24 a21 a22 a23 a24
a31 a32 a33 a34 a31 a32 a33 a34 a31 a32 a33 a34
Set of rows Set of columns Set of blocks (sub-matrices)
I Vector-matrix multiplication can be seen as a linear combination of
matrix rows.
I Matrix-vector multiplication can be seen as a linear combination of
matrix columns.
I Matrix-matrix multiplication can be seen as column-row expansion
(sum of outer-products).
Nazar Khan Linear Algebra 5 / 14
Matrix Multiplication Matrices and Linear Systems Properties
Matrix Form of a Linear System
Every linear system can be expressed in matrix-vector form and vice versa.
The linear system
a11 x1 + a12 x2 + a13 x3 + a14 x4 = b1
a21 x1 + a22 x2 + a23 x3 + a24 x4 = b2
a31 x1 + a32 x2 + a33 x3 + a34 x4 = b3
can also be written as Ax = b
x
a11 a12 a13 a14 1
b1
a21 a22 a23 a24 x2 = b2
x3
a31 a32 a33 a34 b3
| {z } x4 | {z }
A | {z } b
x
where A is called the coefficient matrix, x is the vector of unknowns and b
is the vector of constants.
Nazar Khan Linear Algebra 6 / 14
Matrix Multiplication Matrices and Linear Systems Properties
Trace
There are some operations/concepts that are defined only for square
matrices.
I Trace (sum of entries on the main diagonal)
I Determinant
I Inverse
I Identity
Nazar Khan Linear Algebra 7 / 14
Matrix Multiplication Matrices and Linear Systems Properties
Matrix Arithmetic Properties
Nazar Khan Linear Algebra 8 / 14
Matrix Multiplication Matrices and Linear Systems Properties
Matrix Multiplication
Be Careful!
I While most matrix arithmetic follows the rules of basic scalar
arithmetic, there are some important exceptions.
I There is no such thing as matrix division!
Scalar Matrix
ab = ba AB 6= BA
ab = ac =⇒ b = c AB = AC =⇒ 6 B=C
ab = 0 =⇒ a = 0 and/or b = 0 AB = 0 =⇒6 A = 0 or B = 0
a−1 = 1a A−1 6= A1
(a + b)2 = a2 + 2ab + b 2 (A + B)2 6= A2 + 2AB + B 2
Nazar Khan Linear Algebra 9 / 14
Matrix Multiplication Matrices and Linear Systems Properties
Identity Matrix
I Identity matrix is a square, diagonal matrix containing only 1s on the
diagonal and 0s elsewhere.
I In denotes the n × n identity matrix.
I Plays the role that 1 plays in scalar arithmetic.
I AIn = A and In A = A.
I Reduced row-echelon form of a square n × n matrix is either In or
contains a row of zeros.
Nazar Khan Linear Algebra 10 / 14
Matrix Multiplication Matrices and Linear Systems Properties
Matrix Inverse
Content in this slide applies only to square matrices.
I If A is a square matrix and if there exists another square matrix B
such that AB = BA = I , then A is invertible (or non-singular) and B
is the inverse of A.
2 −5
I [ 31 52 ] is an inverse of −1 3 . Verify it.
I Any matrix with a column (or row) of zeros is not invertible. Why?
I If A and B are invertible matrices with the same size, then AB is
invertible and (AB)−1 = B −1 A−1 . Prove it.
−1 −1
I Similarly, (A1 A2 A3 . . . An )−1 = A−1
n . . . A2 A1 .
Nazar Khan Linear Algebra 11 / 14
Matrix Multiplication Matrices and Linear Systems Properties
Powers of a matrix
Content in this slide applies only to square matrices.
I A0 = I
I For any integer n > 0, An = AA . . . A}.
| {z
n
I Also, A−n = |A−1 A−1 −1
{z. . . A }.
n
I Ar As = Ar +s .
I (Ar )s = Ars .
I For non-singular A, kA is invertible for any nonzero scalar k, and
(kA)−1 = k1 A−1 . Verify that their product yields I .
Nazar Khan Linear Algebra 12 / 14
Matrix Multiplication Matrices and Linear Systems Properties
Properties of the Matrix Transpose
I (AT )T = A
I (A + B)T = AT + B T
I (A − B)T = AT − B T
I (kA)T = kAT
I (AB)T = B T AT
I (A1 A2 A3 . . . An )T = AT T T
n . . . A2 A1 .
I (AT )−1 = (A−1 )T . Verify it.
Nazar Khan Linear Algebra 13 / 14
Matrix Multiplication Matrices and Linear Systems Properties
Questions
I Exercise 1.3
I 7, 8, 11, 13, 17, 25, 27, 28, 30, 35, 36, all true-false questions.
Nazar Khan Linear Algebra 14 / 14