2.1 Matrices and Matrix Operations — Transcript
Full transcript
- 0:01Hello again. So, today we are going to
- 0:03move on to module number two, which is
- 0:06which talks about matrices.
- 0:08So, we're going to learn uh matrices,
- 0:11matrix shapes, and matrix operations.
- 0:14And we're going to see how matrices
- 0:16arise naturally from a system of linear
- 0:18equations. So, let's begin.
- 0:21What is a matrix? A matrix is a
- 0:23rectangular array of numbers, as we see
- 0:25in the example. It's represented either
- 0:28with square brackets or parentheses. And
- 0:32in the matrices, we have some numbers
- 0:35inside it. We have also rows and
- 0:38columns.
- 0:39So, the numbers are called the entries
- 0:42or the coefficients of the matrix.
- 0:44But what we use in general, the
- 0:47terminology that we use very often are
- 0:49the entries.
- 0:50Then, every matrix is characterized by
- 0:53the number of rows and the number of
- 0:55columns. So, in this case, we have 1 2 3
- 1:00rows. And we count the columns 1 2 3 4
- 1:05columns.
- 1:06So, we say that the matrix is a 3 by 4
- 1:10matrix. And that is the size of the
- 1:13matrix. So, the number of rows will be
- 1:16uh
- 1:17indicated first, which is three, and
- 1:20then the number of columns next, which
- 1:22would be four.
- 1:25Let's look at the general form of the
- 1:27matrix. So, an m by n matrix, it means
- 1:30that we have m rows and then n columns.
- 1:33So, it's given by
- 1:35uh all of these entries. And every
- 1:37single entry has two indices.
- 1:40One The first index will indicate in
- 1:43what row we are, and then in the second
- 1:45index, in what column we are.
- 1:47So, every single entry has two indices,
- 1:52i and j, just to indicate that we are in
- 1:55the ith row and then the jth column.
- 2:00So, for the general form of a matrix, we
- 2:04would have a11 standing for the first
- 2:07entry in the first row, first column,
- 2:09all the way to a1n. This would stand for
- 2:13the first row and the nth column. Then
- 2:16going all the way to amn, all the way to
- 2:19amn. So, amn would be the entry that is
- 2:22situated in the mth row and the first
- 2:25column. Those notations are very
- 2:27important notations that are going to be
- 2:30with us up until the end of this course.
- 2:34So, as I mentioned, aij is the ijth
- 2:37element of the matrix. I is the row
- 2:39index, j is the column index. For
- 2:41instance, look at this example. So, what
- 2:44do you think a23
- 2:46would be?
- 2:48So,
- 2:49a23 would stand for the second row,
- 2:53third column. So, we're going to count
- 2:55row one, row two, and then one, two,
- 2:59three. So, a23, second row, third column
- 3:03would be 3.2.
- 3:06So, a23 is the entry 3.2.
- 3:11What are a12 and a34? Take just a moment
- 3:14to think about a12 and a34. So, a12,
- 3:19first row,
- 3:20second column. First row, second column.
- 3:24So, that's would be -1.
- 3:26a34,
- 3:28third row, one, two, three, fourth
- 3:31column.
- 3:33So, this would be 2.2, and that is a34.
- 3:38So, as we have seen, indices in matrices
- 3:42start at one. However, in computer
- 3:45languages, they are going to start at
- 3:47zero, and you are going to see that in
- 3:50your Python course.
- 3:53Next, we are going to look at matrix
- 3:55shapes. An m by n matrix A is tall if m
- 3:59is greater than n. What do you think?
- 4:01What does it mean for m to be greater
- 4:03than n? It means the number of rows is
- 4:07greater than the number of columns. So,
- 4:10just an example of a tall matrix, let's
- 4:13talk about A. 1 2 -1 0 -1 3 square root
- 4:19of 10
- 4:2111. So, this is a matrix. What's the
- 4:24size of the matrix? It has 1 2 3 rows
- 4:29and two columns. So, it's a 4 by 2
- 4:32matrix and the four is standing for the
- 4:35number of rows, which is m, and then two
- 4:37is standing for the number of columns,
- 4:40which is n. And in this case, m is
- 4:42strictly greater than n.
- 4:45A matrix is wide if m is less than n.
- 4:48What does it mean wide matrix? m being
- 4:51less than n meaning the number of rows
- 4:54is less than the number of columns. Just
- 4:56a quick example, let's take a 2 by 3
- 5:00matrix now. So, m being less than n, we
- 5:03have 1 2 3 4 5 6.
- 5:06So, this is a matrix where it that has
- 5:09two rows and then three columns and then
- 5:12m, which is equal to two, is less than
- 5:14n, is equal to three. So, the number of
- 5:16rows are less than the number of
- 5:18columns.
- 5:20How about a square matrix? And this is a
- 5:22very important matrix. The square matrix
- 5:25is a matrix such that the number of rows
- 5:28and the number of columns are just the
- 5:30same. So, let's just look at a 3 by 3
- 5:34matrix. A 3 by 3 matrix will have
- 5:38the same exact number of rows and this
- 5:41exact number of columns, which are
- 5:42three. So, I'm just going to plug in
- 5:44some entries, some random entries as an
- 5:47example, 10 11 and let's suppose 12. So,
- 5:51this is a 3 by 3 matrix having three
- 5:53rows and three columns.
- 5:56So, example of matrices, let's look at
- 5:59the following image. It's a grayscale
- 6:01image
- 6:02and it will be represented by numbers
- 6:05between 0 and 1. 0 being black, 1 being
- 6:11white, and in between it's going to be
- 6:13the all the shade between black and
- 6:15white. So, the shades of gray.
- 6:18Then, if you zoom in a little bit and
- 6:20you look closely at the small area that
- 6:26we are representing.
- 6:28So, the area where you can see the white
- 6:31hand side, which is on the bottom left
- 6:34of this area, will be represented by
- 6:36some numbers which are close to 1.
- 6:39And on the top part, those are numbers
- 6:42which are close to 0 because they would
- 6:44indicate the black
- 6:48the black color.
- 6:50A second A second example would be the
- 6:52prices for multiple supplier.
- 6:56So, the PIJ is the price that vendor J,
- 7:00so the vendors are represented in
- 7:02columns. I have five columns that are
- 7:06charging for good I. And how many goods
- 7:09do I have? 1 2 3 4 5 and 6. And this is
- 7:14how people just compare to see where
- 7:17which vendor they will adopt, which
- 7:18vendor they will be buying from.
- 7:22Special matrices. Special matrices are
- 7:24matrices that appear everywhere.
- 7:27So, if you remember last time we talked
- 7:29about the zero vector, so it's the same
- 7:32way. The zero matrix is just a matrix of
- 7:36size n by n and with entries zero
- 7:40everywhere.
- 7:42And we denote it by just zero. Some Some
- 7:45In some books, you will see the notation
- 7:47as zero n by n just to say that we are
- 7:50in an n by n [clears throat] matrix.
- 7:53The identity matrix is a very special
- 7:56matrix. It is a square matrix, not like
- 7:59the zero matrix with the zero matrix can
- 8:01be non-square.
- 8:02So, the identity matrix is a square
- 8:06matrix with entries one all over the
- 8:08diagonal and zero everywhere else as we
- 8:12see and also the example. So this is the
- 8:15identity of 2 by 2 matrix I'm sorry 3 by
- 8:183 matrix. This is the identity of a 2 by
- 8:202 matrix.
- 8:22Sparse matrices sparse matrices most
- 8:25entries are zero. For example, the zero
- 8:27matrix and I are sparse matrices
- 8:30and can be stored and manipulated
- 8:33efficiently.
- 8:35Diagonal and triangular matrices those
- 8:38are also particular matrices. They are
- 8:41square matrices. So square matrices we
- 8:46cannot talk about diagonal matrices
- 8:48lower triangle or upper triangle unless
- 8:51M is equal to N the number of rows is
- 8:54equal to the number of columns.
- 8:56The diagonal matrices are just matrices
- 9:00where the A I J is zero whenever I is
- 9:05different than J. Whenever I is
- 9:07different than J. So you have only
- 9:10non-zero entries if they are appearing
- 9:12they should be on the diagonal. What is
- 9:15exactly the main diagonal of a matrix?
- 9:17So for a square matrix the main diagonal
- 9:21is the this whole strip that is formed
- 9:24by the A I I's meaning when the number
- 9:28of row is equal to the number of
- 9:30columns. So this is the entry 1 1 this
- 9:33would be the entry 2 2 this would be an
- 9:36entry 3 3 for the 3 by 3 matrix.
- 9:39So A I J is equal to zero whenever I is
- 9:42different than J. So you have zero
- 9:45everywhere else outside the diagonal.
- 9:48You have some different some numbers
- 9:50that are different than zero they these
- 9:52numbers may also be zero on the diagonal
- 9:55but if there are numbers that are
- 9:57different than zero they have to appear
- 9:59on the main diagonal. For example, I'm
- 10:01just going to put a three here a two
- 10:03here then maybe a zero here. So this is
- 10:06a diagonal matrix. I do not have any
- 10:09non-zero entries outside the diagonal.
- 10:12So, again, the main diagonal, let me
- 10:14just put this one here. The main
- 10:16diagonal is just this band where is
- 10:21collecting all these Aii's,
- 10:24A11, A22, and A33.
- 10:27A lower triangular matrix. What is a
- 10:29lower triangular matrix? It's a matrix
- 10:31whenever
- 10:33A i j is equal to zero whenever we are
- 10:38going to compare i and j. So, let's
- 10:40Let's try to think a little bit about a
- 10:42lower triangular matrix. So, a lower
- 10:45triangular. So, it comes from the the
- 10:49terminology lower triangular. So, I have
- 10:53entries in the lower part.
- 10:56So, my entries, for example, I'm going
- 10:59to have 5 10 -1. So, these entries in
- 11:02the lower part are non-zero entries. So,
- 11:05this is a lower triangular, which gives
- 11:07me a condition that this upper part,
- 11:10these entries in the upper part must be
- 11:12equal to zero.
- 11:14So, how do we compare the indices? So,
- 11:16if we go back to the general form of the
- 11:18matrix, the first entry here is A11.
- 11:23The second entries is A12. So, this is
- 11:26A12. This one is A13. This is A
- 11:31second row, third column, A23.
- 11:35So, if we notice all of the indices of
- 11:39these Aij's have the properties that i
- 11:43is less than j.
- 11:46So, i must be less than j. One is
- 11:49strictly less than two. One is strictly
- 11:52less than three, and two is strictly
- 11:54less than three.
- 11:57Then, we are going to move on to the
- 11:59upper triangular matrix.
- 12:01So, it's the same way. It's the same
- 12:03idea. So, in the upper triangular
- 12:05matrix, we have
- 12:08a matrix. Let's give an example where
- 12:10the non-zero entries should be situated
- 12:14in the upper side. You can also have
- 12:17zeros entries, no problem, but if there
- 12:19are entries that are non-zero, they
- 12:21should appear on the upper part. And in
- 12:24the lower part, all these entries are
- 12:26zero. So, upper and upper triangular
- 12:28matrix has the property that Aij is zero
- 12:33whenever
- 12:34I now is greater than J.
- 12:38So, if we combine both together, so the
- 12:42lower and the upper triangular is going
- 12:45to give you what? A diagonal matrix. So,
- 12:48if we combine these two together, it's
- 12:50going to give you a diagonal matrix.
- 12:54Next, we move on to discuss the
- 12:56transpose of a matrix. What is a
- 12:58transpose of an m by n matrix A?
- 13:02So, the transpose of an m by n matrix A
- 13:05is denoted by A T. This T is standing
- 13:09for transpose, and is defined by
- 13:12converting column to row vectors and
- 13:15vice versa. So, the columns becomes the
- 13:17rows and the rows becomes the columns.
- 13:19So, for example, when A is equal to 0 6
- 13:232 3 1 -1, the transpose of A would be
- 13:29So, the the size of A is a 3 by 2. So, A
- 13:35is a 3 by 2. A transpose would be a 2 by
- 13:383. And the first column becomes the
- 13:41first row,
- 13:43and then the second column will become
- 13:46the second row.
- 13:48So, as we have seen earlier on in the
- 13:51previous module, that the transpose of a
- 13:53single row vector is a column vector.
- 13:57The symmetric matrices, those are also
- 13:59particular matrices where the transpose
- 14:01of A R is equal to A. So, when you
- 14:04transpose A, you have to get back to A
- 14:07itself. So, A For A to be symmetric, A
- 14:11has to be a square matrix. That's my
- 14:13first condition. And what is the shape
- 14:16of A? So let's look at a small example.
- 14:19So you have the entries on the diagonal.
- 14:21I'm just looking at an example.
- 14:24And for A to be symmetric, if the rows
- 14:27and the columns the rows becomes the
- 14:28columns and the columns becomes the rows
- 14:30and both matrices are equal, it means
- 14:33that if I'm looking at this entry five
- 14:35over here, so you have a symmetry with
- 14:38respect to the diagonal. This entry must
- 14:40be equal to five. What's the reason?
- 14:43Because if A is squared, A I J must be
- 14:47equal to A J I.
- 14:49So if I'm looking at this entry five
- 14:51over here, this is A 1 2, must be equal
- 14:55to A 2 1. So the symmetry is happening
- 14:58with respect to the diagonal.
- 15:00So if I'm taking an example, this is
- 15:03three, this would be three as well. If
- 15:05this is two, this would be two as well.
- 15:08So you are obtaining a symmetry with
- 15:10respect to the diagonal.
- 15:14Then we're moving to matrix operations.
- 15:16The very first matrix operation that
- 15:18we're going to see is the matrix
- 15:20addition. So just like vectors, exactly
- 15:23like vectors, matrix can be added,
- 15:26subtracted, or multiplied by a constant.
- 15:30However, to add two matrices, you have
- 15:33to have the same size. So having the
- 15:36same size of the matrices will allow you
- 15:38to add both matrices. How do we add A
- 15:42plus B?
- 15:43We just add the corresponding entries.
- 15:46So A 1 1 plus B 1 1 all the way up to A
- 15:491 N plus B 1 N and so on. So
- 15:53corresponding entries are added
- 15:55together.
- 15:56And what is the size of A and B in here?
- 15:59So how many rows do we have? Each matrix
- 16:03has M rows and N columns.
- 16:07So an M by N matrix A was added to an M
- 16:10by N matrix B. And the subtraction is
- 16:14just similar.
- 16:16The same thing as we've done in factors,
- 16:18we can do a scalar multiplication. So,
- 16:21we can take a matrix A and multiply it
- 16:24by a scalar K. And how do we do that?
- 16:27So, we uh multiply every single entry by
- 16:30the scalar K, no matter what the size of
- 16:33the matrix is.
- 16:34So, A is an m by n matrix in this case,
- 16:37and then we are multiplying K by A
- 16:41involves multiplying every single entry
- 16:43by K. And we have these obvious
- 16:46properties.
- 16:47A plus B is B plus A. The matrix
- 16:50addition is commutative.
- 16:53K times A plus B is KA plus KB. So, we
- 16:57can always distribute the scalar to the
- 17:00addition of both matrices.
- 17:02The transpose of the sum is the sum of
- 17:06the transpose. So, A plus B transpose is
- 17:09A transpose plus B transpose.
- 17:13Example.
- 17:14So, let's look a little bit about at
- 17:16this example. We have A, the size of A
- 17:19is a 2 by 3
- 17:21matrix. B is also 2 by 3 because we have
- 17:24two rows, three columns. C is a 2 by 2.
- 17:29So, we can add A plus B. What is the
- 17:33answer for A plus B? So, first of all,
- 17:36we are going to get a matrix of the same
- 17:38size as A and B, which is a 2 by 3.
- 17:42And what do we do in order to get to the
- 17:44result of A plus B? We need to add the
- 17:48corresponding entries together.
- 17:50So, the first row, first column of A is
- 17:54-1 added to the first row, first column
- 17:57of B, which is +1. -1 +1 is a zero. I
- 18:02move on to the second entry. 0 + -1 is a
- 18:05-1. 0 + 1 is 1. 2 + 3 is 5. 3 + 1 is 4.
- 18:11And 0 + 0 is just 0.
- 18:15So, A plus B is oh, again, a 2 by 3
- 18:19matrix obtained by adding the
- 18:21corresponding entries of A and B.
- 18:24How about -2A + B? So, in order to to
- 18:28add -2A + B,
- 18:30we will
- 18:32we will add Let me just try to write it
- 18:35in here. -2A
- 18:38+ B. So, I'm going to multiply A by -2.
- 18:43-1 0 0 2 3 0 and I'm going to add B to
- 18:48it. 1 -1 1 3 1 0. So, what do we do
- 18:53first? What do you think we should do
- 18:55first? We need to multiply all the
- 18:58entries of A by -2. -2 * -1 is a 2 * 0
- 19:03is 0. -2 * 2 is -4. -2 * 3 is -6. 0. And
- 19:10we add it to 1 -1 1 3 1 0. Let's obtain
- 19:15the answer. The final answer would be
- 19:17adding the corresponding entries of -2A
- 19:21with the corresponding entries of B. 2 +
- 19:231 is 3. -1 1 -4 + 3 is -1. -5. And then
- 19:30finally, 0.
- 19:34So,
- 19:35what about A + C? What do you guys think
- 19:38about A + C?
- 19:40So, A + C A is a 2 a 2x3 matrix.
- 19:47C is
- 19:50a 2x2 matrix. So, A + C cannot be
- 19:55performed.
About this transcript
This page contains the full transcript of 2.1 Matrices and Matrix Operations by KAUST Academy, generated from the public captions YouTube serves with the video. The transcript has 2,924 words across 409 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.