The Applications of Matrices | What I wish my teachers told me way earlier

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this video is sponsored by dash lane circuits and electronics image processing computer graphics quantum mechanics the Google page rank algorithm any kind of network other stuff these are the kinds of things where matrices are used and extremely important for understanding or analyzing different systems and although I can't discuss everything in one video this should give you some insight into the applications of matrices beyond an introductory course might include now in the beginning matrices can be one of the most boring subjects we learn in math maybe now for everyone but least that's how it was for me I mean we're told hey here's how matrix addition works real simply just some of the corresponding entries and you have your answer then multiply a matrix by a single number is as simple as multiplying every entry by that value but when it comes to matrix multiplication we do this weird row by column dot product multiplication which some teachers just give no context to so yeah this isn't the kind of stuff that makes you in a major in matrix math anytime soon I mean you might learn more in high school but overall a lot of it just isn't that exciting however I promise matrices are used way more than you probably think but the first thing we need to realize is that matrices do things two vectors don't take this as a definition cuz it's obviously not but we do need to see what happens when we multiply a matrix by a vector for example a vector that starts at the origin and ends at 1 comma 1 can be written in matrix form as shown X component on the top and Y component on the bottom and when you multiply by a 2x2 matrix like this through the multiplication rules we get a new vector out in this case of 1 comma 3 so we put a vector in and the matrix scaled and rotate it to get a new vector out this is what I mean by the matrix doing things to the vector and in this case different inputs will be rotated and scaled differently which we'll see in a sec now some matrices are much simpler like this one here just rotates put a vector in aka multiplied by the matrix and out will come the same vector rotated 90 degrees counterclockwise this matrix on the other hand will just scale any vector that goes in comes out twice as long but most two-by-two matrices like this when we were analyzing aren't as simple different input vectors I'll just put a few here as an example gets scaled and rotated differently however the transformations are all linear as in any vector on the same line as one of those inputs will be mapped to a vector on the same line as the corresponding outputs these linear transformations are why we called the first in-depth class on matrices linear algebra anyways I'm going to redo those transformations once more but this time pay attention to this vector here you'll notice it's the only one that is just scaled it doesn't rotate at all and this would happen to any vector on that same line because of what we just saw any vector that is only scaled by a matrix is called an eigen vector of that matrix and how much the vector is scaled by or two in this case since the length doubled is known as the eigen value I'm not going to go through how to solve for these but the vocabulary will come up later now the last thing to mention is that the first application of matrices we typically learn is how they help us solve systems of equations the coefficients can go into a matrix the variables go into another and the outputs go here notice I'm using the same matrix as the one from the last slide by the way using the rules of matrix multiplication you can see that this and this are the exact same so really what this is asking is which input vector does this matrix map to 1 comma 3 well we already saw the answer to this 1 comma 3 is this output and the question of which vector will the matrix map to this involves us just doing the same transformations as before but backwards to find the answer is 1 comma 1 that will be our solution going backwards is like applying an inverse matrix and when the desired output is the one being multiplied then the vector it came from comes out so x equals 1 and y equals 1 are the solutions if we plug those into the some equations than both are satisfied which is exactly what we were looking for if you haven't seen three blue one Browns essence of linear algebra series definitely check that out this will make a lot more sense but here we're focused on applications which we're going to get to now now in systems of equations get more complex all we have to do is expand our matrix and we can analyze the system with as many variables as we want the reason matrices are used in circuits and electronics for example is because these can be represented by linear equations in which all the voltages and currents are the unknown variables when the circuits get hectic where we don't want to solve it by hand we can just have a computer find an inverse matrix and we'll have our currents and voltages but that's still not too exciting so what about a system that continuously evolves over time like for example let's say there's a zombie outbreak at the local high school pretty standard situation and the place is quarantined so no one can go in or out but the zombie infection is spreading so we've got humans in the school and zombies but no one is coming in or out so the population remains the same now let's say every hour 20% of humans will turn into zombies due to being infected there is a cure for the disease luckily however it's not always guaranteed to work so we'll say that every hour 10% of the zombies will return back to humans at this moment if there are 150 zombies and 150 humans the question is what is going to happen in the long run now we're going to assume the changes happen in discrete intervals at the hour so let's see what happens in the first hour for the humans of the 150 starting out 80% of them are going to stay human or not become infected but we also have to add the 10% of the 150 zombies that become cured and turned back to human this leaves us with a hundred and thirty-five humans after that first hour it went down just a bit for the new total of zombies we would take the 20% of humans that got infected plus the 90% of the 150 zombies that are not cured giving us a total of of course 165 since these two numbers add together muster 300 but we want to know what happens after a long time so we got to keep going after another hour we write the same percentages except now the number of humans is 135 instead of 150 and for the zombies we got 165 instead of 150 this now puts 125 for the humans and 175 for the zombies so we seem to keep losing humans but will this continue well what we have here is some linear equations that can be represented as a matrix of those percentages which don't change this is multiplied by the inputs hmz or the current population of humans and zombies at any time and all of this equals the populations after that given our this is called a markov matrix by the way since its column sum to 1 and it has no negative values but this is like what we just saw the matrix we have is going to do stuff to or scale and rotate the input vector the first input was 150 comma 150 the initial human and zombie populations and after 1 hour or multiplication it gets moved to 135 comma 165 but we have to keep going and apply another transformation sending it to 125 comma 175 the populations we found after 2 hours so as we keep applying these multiplications the real question is where does this vector go well let me put a few vectors on the graph to show this each representing populations which add to 300 if we do the matrix multiplication and look at the transformations you'll notice this vector or anything on this line stays put while everything else moves towards it that vector is an eigenvector of our matrix the associated eigenvalue is 1 since it doesn't scale and since that vector doesn't rotate or scale it is the equilibrium of the system and therefore the answer to our question after a long time the populations will settle to numbers which lie on this line and add to 300 which would be 100 for the humans and 200 for the zombies any other population values we'll just move a little closer to these after each hour if you put those values inside the equations from before you'll see the output remains 100 and 200 for the humans and zombies respectively then if the percentages were to change the question just comes down to what is the eigenvector of the new matrix there may not be a zombie infestation anytime soon but this kind of math could be used to analyze how a virus will spread throughout a population for example and one of my favorite applications of this is the Google page rank algorithm which involves Markov matrices and ranks websites by treating outgoing links as probabilities of transitioning from one site to another for more on that I have a dedicated video which I'll link below now moving on here's a happy story not at all on April 29 1992 a man named Reginald Denny was beaten nearly to death live on national TV and this was just a completely innocent man who had done nothing wrong you can see Reginald laying here probably unconscious after the attack the attack itself can be seen here on YouTube but in an attempt to knock an age-restricted like that video is I'm only showing the portion right after now the back story here is that April 29th 92 was the first day of the Rodney King riots in Los Angeles Reginald Denny was a truck driver whose route for the day involved going through an area where rioting was taking place which he was not informed about when he got there he was stopped by rioters dragged out of his truck and that's when the beating took place now identifying who assaulted Denny was not easy since the quality of the live footage wasn't amazing but what help law enforcement confidently identify one of the attackers with some advanced math to understand how this was accomplished we need to first look at what a digital images a digital image when you look real closely is just made up of a bunch of pixels each of a single color those colors can then be represented by some numerical value which means like a square picture made up of a million pixels 1000 on each edge could be represented by a thousand by 1,000 matrix where the entries are the color values of each pixel working with black-and-white pictures is much easier though because the black pixel come you represented with a zero and a white can be a 1 let's say well actually work with grayscale images here though meaning anything in between zero and one can exist which will correspond to a different shade of grey so when it comes to image processing and manipulation whether it be blurring an image detecting edges sharpening an image and so on it all comes down to manipulating the pixels in a very specific way to see an example let's mathematically blur this image of the number 1 to do so I'm going to make a 3 by 3 matrix where every entry is 1/9 this is known as a kernel and image processing by the way then what we're going to do is lay this kernel over our image matrix and multiply the individual entries in each square together then add the results in this case it's just 1 times 1/9 nine times so the sum of all those is one yes this kernel is really just finding the average of the pixels inside it from there we're going to take that sum of one and set the center pixel to that color in the new image it just so happened not to change it's still 1 or white but that won't always be the case now you'll notice this grid on the right where the blurred image will go is the same size as the one on the left to get the entire blurred image we're just going to sweep that red section across the original one when we slide it over once all those pixels are still 1 so the average is also 1 and that's where this new pixel becomes but after sliding over again the kernel contains a black pixel so we find the average of 8 ones and a zero which is about point eight nine this corresponds to a very light shade of gray which we will put in that middle square after sweeping across the image mapping each new number to the blurred image these will be the values I know this method doesn't really account for the border but for our purposes we're just going to keep that white now I'll actually color and the pixels based on their values and we get a blurred image of the number one actually this is extremely blurred almost beyond recognition but if we put an outline along the colored region we can see the one is still kind of there the reason this is so blurred is because we're only working with a hundred pixels but what the kernel did was kind of took this sharp edge in the original image between black and white and smooth or averaged it so we get this fading from dark to light in the blurred image the kernel we use represents a type of blur known as a box blur and from Wikipedia if you input a picture with many more pixels then apply the blur this is the output you get but there are several other kernels that'll all accomplish different things a Gaussian blur also of course blurs the image but it assigns more weight to the middle square so dark pixels stay fairly dark and vice versa there's a sharpen kernel and there's edge detection kernels which search for sharp changes in color you'll notice that all the numbers in this kernel sum to zero so if we put it over a section of an image where all colors are roughly the same multiplying by these numbers then adding the results would just yield zero or a black pixel which is why that corresponding area is black the only sections that aren't are where we find sharp changes in color aka an edge as another example of edge detection here's a poorly taken photograph of someone's arm and by using edge detection algorithms researchers were able to identify a region of some kind of birthmark or tattoo well this is actually a zoomed in portion of this image where those men can be seen beating Reginald any using image processing techniques similar to what we've seen one company was able to determine that this mark was a rose tattoo affiliated with a certain gang in Los Angeles and it was this that helped him eventually secure a conviction of one of the perpetrators of the attack now all this may not have involved much matrix math like we saw earlier but no I did simplify some things to avoid going in too much detail and not only image processing but computer graphics heavily use matrices with these what we can do is take geometric data and incorporate it into a coordinate system we can then scale rotate reflect shift images and more through matrix manipulation but things do get much more complicated like when you want to project a 3d image into a 2d plane we can use matrix map to map the 3d points and find where they would appear on the flat screen not going to go into much more detail in that but again computer graphics are another very useful application of matrices but for those wanting some real tangible results that come from matrix math let's look at networks and graph theory graphs can represent a lot of things people and who they're friends with connections on a dating app networks of cities and how they're connected websites and how they link to each other and so on with small networks it can be easy to intuitively understand what's going on like if I said here's a group of coworkers and connections represent mutual friendships it wouldn't be hard to see like this is the most popular person and this is the least popular with only one friend if you had to find how many mutual friends these two people have no big deal you can just count and see that's three but when the networks get more complex we need mathematical tools to help us identify key things this could be like which website should be ranked the highest on the web which I mentioned earlier it could be finding who is more likely to spread a disease and a college full of students for which people involved in the 9/11 terrorist attacks were most critical to the operation and should be prioritized by law enforcement yes they actually did this after 9/11 which I have discussed in a previous video we need some mathematical techniques in these cases so we can find things that our eyes aren't always able to when the connections get this chaotic but let's do a matrices can reveal when it comes to dating apps imagine this app only has three men signed up that will label 1 through 3 and 3 women labeled 4 through 6 and there together as shown these are mutual connections by the way like both people swiping right and you'll know for now there are no same-sex matches we see this first guys matched with all three women the second guy with two and the third with one now this graph provides a nice visual for this situation but what we can also do is make a table with six rows and six columns for the six people and analyze this instead we'll say if two people are matched like person one in person for our then in the square located and in column 1 and row four we will put a 1 however since these are mutual connections we need to also include a 1 in column 4 and Row 1 basically if one matches with 4 then of course 4 has matched with 1 so the data has to reflect that so that means yes the tables going to be symmetric about the diagonal then if two people are not connected like person 1 and 2 we'll put a 0 in that square in this case column 1 in row 2 but of course we can't forget column 2 and row 1 since no one matches with themself the diagonal is going to be all zeros and then these would be the rest of the connections so if you want to know whether person 5 and 2 are connected by the table just go to column 5 and Row 2 or vice versa and see if there's a one or a zero there from this there are obvious things we can see like for person 1 we can look down their column or across the row and find they have three matches in total because of the three ones but we're going to use some slightly more advanced math to analyze this graph so instead of considering this a table we're going to call it a matrix but it's taking away the gridlines but otherwise nothing has changed when it comes to graphs this is known as an adjacency matrix another way to interpret this though is that it tells us how many paths of length one exists between any two nodes oh and for the rest of this video when I say path I just mean any sequence of edges that joins a sequence of vertices basically just a walk those no graph theory may not like this because a path is usually more specific but I am being generic here okay so what's this really mean we'll look at column 6 and row 1 we know this says that those two people are matched no big deal but it also means there is one path of length one that exists between them those are saying the same thing if we put a dot at person 1 and can only traverse one edge well there's one way to get to person 6 that's what this one represents on the other hand there are zero ways to get from person 1 to person 2 in one edge if you start a person 1 there are paths to person 2 but they all have a length of 2 which is not what we were looking for but now what if I want to see quickly how many mutual matches two people have well if we look at person 1 and 2 this isn't tough we see there are 2 mutual matches however this question of mutual matches is no different than asking how many paths of length 2 exists between person 1 and person 2 well we just saw that the answer is 2 as expected since it's the same question again if I start at 1 and go to 4 than 2 or 5 than 2 those two paths mean two mutual connections the cool thing though is that we can find how many of these paths of length 2 exist between any two nodes by just multiplying the adjacency matrix by itself or squaring it we see for person 1 and 2 there are 2 mutual connections so that checks out then if you look at the graph for person 2 and 3 they have no mutual connections and on the matrix this checks out as well from column 3 and Row 2 having a 0 however person 1 and 3 are both connected to 6 and no one else which we can also find in the matrix and you get the idea but now what would the diagonal mean well that's how many paths of length 2 it exists between a person and themselves aka how many matches they have think about it for person 1 if I start there to get back to 1 in two edges I can go into 4 than 1 5 than 1 or 6 and 1 3 options for the 3 connections this is why we see a 3 there in the matrix person 2 that has two matches and it goes up then if we multiply the new matrix by the original the same as finding the original cubed we get all the paths of length 3 from one person to another see the original matrix to some power tells us how many paths of that length exist between any two notes now if we have a same-sex connection and link one to two let's say all we have to do is add a 1 to the original matrix in the first column second row and vice versa see when implementing this in the software we just have to make small tweaks to the adjacency matrix and from there squaring or cubing it tells us a lot actually something I found interesting was what the matrix cube tells us specifically the diagonal for one it tells us how many paths of length three exists between a person and themselves but looking at the graph a length three path back to yourself tells us there's a triangle there I'm not going to explain this one in depth but if you sum the numbers along the diagonal also known as the trace of the matrix and divide by six that tells you how many triangles in total there are in the network I just found that to be a cool thing the matrix tells us which you wouldn't think about it first then on another topic something I haven't even mentioned yet is machine learning and neural networks which are coded with and manipulated by matrix math mathematically matrices are a huge aspect of what allows the machine to quote learn or in terms of security there's an example of an older kind of encryption method which is the hill cipher this cipher incorporates matrix operations in order to encrypt and decrypt messages although no it's not a modern encryption method and as much as I'd love to keep going into depth on different subjects this video is already quite long so hopefully this show just how powerful and impactful matrices are though but also regarding encryption and security I do want to thank dashlane for sponsoring this video a company that's dedicated to keeping you safe and secure on the internet - Lane is a password manager that well there's several things when it'll safely store all your passwords all in one place and sync them between devices so you never have to deal with resetting all those passwords you made months or years ago that you can't remember with this - lien will also autofill user names and passwords for any site you have stored in their vault making it just a little easier to navigate the internet something more important than remembering passwords though is having secure passwords and being safe from hackers which - lien takes care of we're totally shouldn't store the same password for different sites since being hacked in one place makes you vulnerable elsewhere now in dashlane that is solved as you have the option to have them auto-generate very secure passwords to be stored and used across all your devices you will have one single master password that you create when you sign up for dashlane and that is used to encrypt all others so even if someone were to gain access to internal servers they would just see gibberish you on the other hand can feel safe knowing you have different and very secure passwords for each site yet all you have to do is remember one single password plus four add security they'll notify you if any of your data has been compromised to give you a complete peace of mind as you browse the Internet pricing is already really cheap but if you sign up at the link below or go to - link comm slash major prep you'll get 10% off your premium subscription plus there's a 30-day free trial so no risk and just giving it a try again links are below and with that I'm gonna end that video there you guys enjoyed be sure to LIKE and subscribe don't forget to follow me on Twitter hit the bell if you're not being notified and I'll see you all in the next video
Info
Channel: Zach Star
Views: 2,770,910
Rating: undefined out of 5
Keywords: majorprep, major prep, matrices, applications of matrices, matrix math, linear algebra, what are the applications of matrices, how are matrices used in the real world, image processing, systems of equations, graph theory, matrix multiplication, eigenvalue, eigenvector, what is a matrix, applied math, mathematics, understanding matrices, matrix applications
Id: rowWM-MijXU
Channel Id: undefined
Length: 25min 15sec (1515 seconds)
Published: Fri Oct 11 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.