Matrix Multiplication and inversion

One of the most important operations involving matrices is multiplication of two matrices. There are two main ways to compute the product of two matrices and you will learn about them today. Next you will learn about how to compute the inverse of a matrix, and lastly on Wednesday, you will learn how you can apply the concepts learned so far to solve for a system of linear equations.

Today's learning objectives

  • Understand how to compute element wise product between matrices.
  • Understand how to compute a dot product between matrices.
  • Understand how to invert a matrix.

Matrix multiplication

The matrix product of matrices A and B is a third matrix C. A key condition that has to be satisfied before two matrices A and B can be multiplied is that A must have the same number of columns as B has rows. If A is of shape m X n and B is of shape n X p, then C is of shape m X p.

Matrix multiplication if often denoted by just placing the matrices next to each other. C = A.B

Element-wise Multiplication

The simplest form of matrix multiplication is to just multiply the individual entries. This of course requires the two matrices to be of the same dimensionality (equal number of rows and columns.). It is often termed as element-wise product or Hadamard product, and is denoted a circle with a dot in it.


Dot product

The dot product between two vectors x and y of the same dimensionality is the matrix product xTy.

what does the symbol " T " represent?

We can think of the matrix product C = A.B as computing Ci,j as the dot product between row i of A and column j of B.


Please watch this video to see an example of how to multiply two matrices.

Matrix inversion

The matrix inverse of A is denoted as A−1, and it is defined as the matrix such that A−1A = I. Where I is the identity matrix.

what is an identity matrix?

Please watch this video to get an intuition behind matrix inversion.

Similar to a determinant, at this moment it is more important to understand the mechanics of how to invert a matrix in contrast to what does matrix inversion actually achieve. That will again come with experience and practise and kindly be patient.

Please watch this video to understand the mechanics of matrix inversion.

Note that a key condition for a matrix inverse to exist is that the determinant of a matrix should not be 0


In practice, you rarely solve for a matrix inverse by hand, typically this is done using computers. In Python, NumPy provides functions that automatically compute the inverse of a given matrix - numpy.linalg.inv.

Assignment

a) Please read until (and including) Section 2.3 of the linear algebra text you can find here.

Note: Do not worry if you find it hard to understand the notation at the moment. That comes with practice and experience.