0% found this document useful (0 votes)
10 views21 pages

Lecture 2

The document discusses matrices including how to represent systems of equations using matrices. It covers matrix operations like addition, multiplication, transposition, and dot products. It also shows how to perform these operations using Python commands.

Uploaded by

100475175
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views21 pages

Lecture 2

The document discusses matrices including how to represent systems of equations using matrices. It covers matrix operations like addition, multiplication, transposition, and dot products. It also shows how to perform these operations using Python commands.

Uploaded by

100475175
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

DS2810

Lecture 2
Addition, Multiplication of Vectors
Linearity
By. Professor Wu
We previously learned about vectors

They look We can tell their dimensions


like this with this notation

Today, we are learning “what is a matrix?”


They look We can tell their dimensions
like this with this notation

Matrices can take on


Notice that instead any dimension.
of a lower case
letter, matrices are
represented with
Capital letters
Just like vector, we can also How to transpose a matrix
Transpose matrices
Try it yourself, find the transpose of each matrix
Multiplying Matrix by a constant

Addition by a constant
Matrix Hadamard Product

Hadamard product can be


performed between any two
matrices of the “same”
dimension.
You pair up every
Matrix dot Product combinations of vectors with
each other.

Matrix dot product is the default


multiplication. So a dot is not Unlike hadamard product, the size doesn’t have to be the
necessary. It is almost always same.
omitted.
Instead, the number of columns on the left must be the same
as the number of rows on the right.

The Transpose of two matrices


multiplied together is the
transpose of each individual
switched in location
The order of the Matrix dot Product cannot be flipped.
Inner product is basically the
Matrix inner Product same as the dot product, you
just need to transpose the 1st
matrix.

In dot product : The # of columns of X = The # of rows of Z


In inner product : The # of rows of X = The # of rows of Z
Try it yourself
Try it yourself
We’ll do a couple together
We’ll do a couple together
We’ll do a couple together
We’ll do a couple together
We’ll do a couple together
We’ll do a couple together
Notice that large equations can be compressed into matrix format
Compressing Large Equations with multiple inputs/outputs

Compact way of representing


thousands of equations
simultaneously.
Commands in Python >>> A.dot(b)
array([ [ 5],
>>> import numpy as np [ 8],
>>> A = np.array([ [1,2],[2,3],[4,4] ]) [12]])
>>> A
array([ [1, 2], >>> A.dot(C)
[2, 3], array([ [ 5, 5],
[4, 4]]) [ 8, 8],
[12, 12]])
>>> b = np.array([ [1],[2] ])
>>> b >>> A*D
array([ [1], array([ [3, 2],
[2] ]) [4, 3],
[4, 4]])
>>> C = np.array([ [1,1],[2,2] ])
>>> C >>> A.T.dot(D)
array([ [1, 1], array([ [11, 7],
[2, 2]]) [16, 9]])

>>> D = np.array([ [3,1],[2,1],[1,1] ])


>>> D
array([ [3, 1],
[2, 1],
[1, 1]]) In real world, you won’t want to
perform a huge matrix multiplication
by hand. This is much faster.
Practice Converting systems of Practice Python Commands
equation into Matrix format

Converting the Matrix format in a


systems of equation
You are welcome to ask a friend or TA for help if you are confused.

You might also like