So the noise that you're in the background, that's just the tractor playing the field. So what we're going to talk about in this video is just about vectors in Euclidean space, so introduction to linear algebra. But what I want to motivate for is to make your notes inside of a computer coding environment and to use that computer language to help you understand the topic and also to prepare you for the future. If you're going to learn linear algebra, linear algebra is used in many fields from data science to engineering physics. It's just used everywhere. You might as well learn to use linear algebra with a coding language. So I think there are many positives and it's easy to motivate for the fact that you should do your work with a computer language. So we're going to use Julia. Julia is a language for scientific computing and we're going to use one of its coding environments called Pluto which is a notebook which runs inside of your browser and I've got other videos here on YouTube which just shows you how to use and install it. This video though is about vectors and about Euclidean space and so our notes are going to be nice and neat and we're also going to use just a bit of easy very simple code just to check our results using vectors in Euclidean space.  If you want a video on the proofs you'll hear me mention in the video then certainly make one and I'll try make some notes available that is very clear and precise about how to construct the proofs when you are dealing with vectors in Euclidean space and so let me show you what it looks like to do your work, to do your linear algebra and to study really using a computer language inside of a coding environment. I've opened the Pluto notebook and as you can see there there we go the whole lot so everything is typed all the notes are available in the link down below so you can load this notebook for yourself. So vectors in Euclidean space yes you can do your mathematics work right here inside of a Pluto notebook it looks very neat as you can see you can draw figures there you can write very beautiful code and I'll just along the way show you so it's a lot to learn and we're going to learn about vectors in Euclidean space we're going to learn how to do calculations in the Julia language and then also how to how to generate a notebook such as this so these are the cells right at the top so you'll see there's a little eyeball sign there with a line through it that show and hide the code so if I open that we can see the code so in the Pluto notebook of course the code is below the cell it's at the bottom of the cell and you see the execution up above the MD stands for mark down and then a set of quotation marks open a closed quotation marks and inside of there would go some normal English so there's my name but there's also that little greater than sign and that indicates to Pluto that it should make this this background here and make the code or make the execution at least of that cell look good and I can just hide the code there and you see the pluses on top of the bottom so if I wanted to insert a new cell to write some code that'd be fine so here's my title and that will also be a mark down cell so MD with open and closed set of quotation marks there and then we're going to use these hashtag symbols in a space so single hashtag that will be the largest text that'll be an h1 tag and html and if I open the setup you'll see the setup slightly smaller the text than the title so this will be one smaller so two hashtags there and that's just how you do it you can go up to six hashtags that'll be the smallest but you put the MD and the opening closing quotation marks there to indicate that a cell is just a mark down cell as opposed to a cell with some code in and here we see the code and if you're familiar with Julia you'll have to be a little bit familiar with Julia before we start the start of this but what I've done here with the setup I've created a computer variable called file and I'm using the assignment operator and in quotation marks I've got this address to this project dot to ml file inside of this folder structure my hard drive and that project dot to ml file that is a specific environment for which we have this linear algebra with Julia this project that I do have and you can watch my video the description the link in the description down below how to set up a notebook and a Julia environment so we're going to use the package pkg package we're going to then activate use pkg.activate to activate this project dot to ml file by just passing file as an argument to the activate function there we're also going to use the linear algebra package that's built into Julia we're going to use the plots package with the plotly back end so you'll have to install those uh in this environment and again the link will show you in the description will show you how to do that and we can also use the random the random module or random package that's built in and then also pluto ui so you'll have to install pluto ui as well so that's the setup so that is how you bring extra functionality into Julia and how you activate this environment so a little bit then about what this video is all about just vectors in euclidean space so you know we use vectors quite a lot they're important as mathematical objects as physical objects they find the uses in data structures in engineering physics many other fields throughout this notebook we're going to just be concerned with these vectors in euclidean space so that's the fundamental space in classical geometry where we have the the real number line as you can see here if we get to points let's get to those points remember we have the real number line and then we have the cartesian plane that's our two real number lines orthogonal to each other with an intersection at x equals zero and y equals zero all those x's are real numbers all the y's are real numbers and that gives us these the ability to plot these points in the cartesian plane if we add another orthogonal access to that another real number line the z line according to the right hand rule we now have euclidean space three-dimensional space etc so just have this point now point requires two real numbers in in these in these x's that you see in x axis and y axis remember they're both real numbers so we create this two tuple a tuple is just a set of values and they two of them in this instance so if we want to plot a point in the cartesian plane we need a two tuple and so there we see a point there p3.2 so a point will we'll use uppercase letters and then no space open close parentheses 3.2 so that means on the first real number would be three so three along this and you can see the three there at the bottom and then two along the second real real line so i'm just taking two elements one from each set of real numbers and that gives me this idea of r2 and by the way back and forth between code and the notebook and the actual topic under discussion vectors euclidean space so let's let's just look at this so if i open that to show the code again that'd be a markdown cell there we go so it's got to have the open and close set of quotation marks and how would i do that too as a as a as a number well we use la tech and all la tech code goes in a side of a set of dollar symbols and there we go here at the end this double struck r or blackboard r to indicate a set of real numbers that'll be backslash math bb for math blackboard and then r and then shift six or my keyboard for the carrot symbol two that means the uppercase or superscript two and again all of that is in in a set of dollar symbols to indicate to the notebook that this is la tech code and that's just how you construct these so i'm showing you here so that i can peak your interest so that you can go look up and explore for yourself how to do this so there's our figure we're going to use the plots package for that and in pluto remember if i have more than one line of code i've got to wrap that into a begin and end statement and so i'm going to make x this array with a single value in it three y i'm going to assign the computer variable y to this array with a single value two then i'm going to say plot x comma y and the series type is a symbol and symbol in julia is always a colon then a word so this will be colon scatter that's the scatter symbol telling the plot function here that we want a single scatter plot at least and i'm giving in a title there's one of the arguments figure one so that's where the figure one comes show axis is false and the label is point so three comma two is going to be this point up here so i can just click on that point to to isolate it well in any way here at the top you can see i can download this as a png we can zoom in a little bit and then we can go back home etc and that's why i love i love plotly because we have this great interactivity now we've got this point on a real number line now we've got this point in a plane but we needn't stop there of course we can go to the cartesian plane and rectangular coordinates there will be three elements and we can go up from there and we just denote hyperspace there as this double struck double struck r or blackboard r with a superscript n so that just means you know we can go beyond three space so let's look at vectors as geometric objects so what i can do with this point is let's connect the origin to the point such as that i have this little arrow so this would be the tail of the arrow at zero comma zero and that will be the head of this arrow at the point and now this makes it a vector so instead of just a point i now have a vector and the idea behind this vector would be that it has a magnitude we'll see it is of a certain length and it makes a certain angle with a positive x-axis so there'll be an angle so this vector idea is a physical object a geometric object at least this is going to be this something that has a length and a direction but you can see clearly it comes from a point and i needn't have the tail at the origin later on we'll see that the tail can be anyway but if we bring it down so that the tail is at the origin here it becomes a what we call position vector so it's easy to understand or intuitively understand a vector as a geometric object but we're more interested in vectors as mathematical objects so there are various ways that we can denote this how we can write this usually we'll name a vector in your textbook it'll usually be an boldface lowercase symbol so that's a boldface there u so let's just open this up back to the notebook just to pq your interest so this is how it's done it's a markdown cell we see it's in the opening and closing dollar symbols so that's going to be uh lartech code and to get the the boldface u would be math bf so that's backslash math bf so that's a keyword in lartech uh u that goes inside of the set of curly braces and then this large angle brackets we do that with a left backslash left uh less than symbol and then close it with the backslash right greater than symbol and that changes it to these big angle brackets and then just the 3 comma 2 inside of there so it's very easy to pick up at least this type or the subset of lartech that's used in notebooks anyway so we can use these angle brackets to denote this vector 3 2 so it'll go from the origin to the point 3 2 in the cartesian plane we can also use this column vector notation and in linear algebra you'll see a lot of this column vector and column vectors we can write them those angle brackets or the large parentheses doesn't really matter and then we have the fact that we have the different axes here so the first one will appear at the top and then the second one if we had a third one as we can see here here u our vector is an element of r3 so we'll have x y and z but i told you we need to stop there so just then some genetic vector as an element of rn will have components these are all called components and we write them down here as a single column vector column meaning there's a single column multiple rows so we spoke about this length idea of a vector so let's look at that magnitude of a vector now it's very easy to work out the magnitude of a vector even if i didn't tell you tell you you would know because if i have a vector like that i can just close it off as this right angle triangle and if i have a right angle triangle that becomes the hypotenuse the vector is now hypotenuse and we all know how to do how to calculate the length of the hypotenuse we just use the Pythagorean theorem so that'll be just the square root of this component the x component plus the square well the square root of the square of these two added to each other so it's the square of the x component the square of the plus the square of the y component and we just take the square root of that and that gives us hypotenuse so you can see again how i just constructed uh use some Julia code in the plots library to construct that little figure three there so what we have here and i'm going to use both of the terminologies that we have um this this almost looks like an absolute absolute symbol there so the absolute value of minus three is three so you can have the double lines there or the single lines i'm going to you're going to use both we have just used the single lines but clearly that's a both face u so that's a vector and it's just the square of all the components and with the Pythagorean theorem we need not to stop at the Cartesian plane we can go up into hyperspace and that means i just square all the components add all of that those squares and take the square root of that so let's see in Julia we have we have this idea of creating a vector in Julia so i'm going to call my vector u so that's a computer variable and i assign something to that so how computer language works remember or Julia at least is this single equal sign is an assignment operator it assigns what is to the right to what is to its left so look let's have a look at what is to its right to its right is this two values separated by semicolon and it's enclosed in the square brackets that denotes a certain type and that type is a is an array and this array has two elements and they separated by semicolon and that really means that they are it's going to be like a column vector and we're going to use an array and we're going to express it or use it as a column vector so this thing on the right is an array this is one instance of an array so i am assigning an instance of an array to a computer variable u that u just denotes there's some physical space in memory and we're going to store this instance of this array into that computer variable into that space and you can see the return there is a 64 bit integer array 3 comma 2 and if i tool that down you'll see the first value is three the second value is two denoting this idea of this being a column vector if we use the type of function u there we see indeed that that'll tell you if you pass anything to it to the type of function it'll tell you what kind of julia data type this is and it says well it's an array of 64 bit integers along axis one now axis one is the column axis as soon as you have rows or different columns more than one column that that becomes axis two and that'll change to a two and that's how you'll get a matrix or a row vector we'll see that later so just just to show you that we've created this vector this column vector but it is an actual fact an array so we can also just use the vector function uppercase v again i'm now just going to use this this array notation and i'm just going to separate things by a comma and that's just an alias for what we've done right up there just note the difference but what we have is exactly the same thing and if we see the type of vector and then this list of elements 3 comma 2 that's still going to be an array of 64 bit integers along one axis axis one so let's look at our first problem then and so you might get this that you have this vector in r4 with components 3 3 negative 1 and 2 and we want to know what is the magnitude of that vector now first of all you can't really visualize that vector because where you're going to put the fourth dimension but there's no problem in mathematics and we're just going to use the Pythagorean theorem or we weigh up again here with this equation we had equation 5 remember that's how to do it so all we're going to do we're just going to square all those components and we're going to add that and take the square root of that and that's approximately 4.796 that's of course tedious to do maybe you'll have to do it and pencil and paper pen and paper but of course in julia here i can use the norm function and the norm function because the norm of a vector is the same as the magnitude of a vector use it in slightly different contexts but anyway i'm just passing this column vector to it and i remember i'm using this notation the square bracket notation where i put semicolons in between each of these values so the 3 the 3 the negative 1 and the 2 the all the components i pass that as an argument to the norm function and when i execute that i get the result there 4.796 rounded off and that's exactly what we get there if you did it by hand and use the calculator or whatever of course this is julia let me just show you so let's just add a new little line right there i'm going to go to that plus symbol there and what is the square root of 23 so sqrt is the function for square root i'm going to say 23 i'm going to hold down shift and hit return or shift enter and there we go we see the result there so i really wasn't lying so that norm function is no matter what vector you give it or array then a column with with column values you're going to get you're going to get the solution so we also talked about the the idea of the direction a vector takes now once again if we scroll all the way back up very easy to do with trigonometry because we still have right angle triangle and we have this length we the y length we have the x length and in in trigonometry that's just the opposite and adjacent angles and the tangent of this angle here would be opposite divided by adjacent so that's a simple really simple as that so the tangent of that angle is y over x the y component of the x component and if we take the inverse tangent function or the arc tangent function of that we just get the angle so here we have another little problem um calculate the direction of the vector in the first quadrant with components x equals 3 and y equals 2 well very easy i'm going to use the a tan function a tan for inverse tangent or arc tangent and i'm going to say 2 over 3 and remember you don't have a symbol on your keyboard a divide symbol so we just use the 4th slash 2 divided by 3 and that gives me this solution in radians and if you want it in that in degrees there's also the rad 2 deg radians 2 degrees function and then i pass this again this calculation a tan of 2 over 3 to it and i see it's about 33.69 degrees very simple to do let's do another problem calculate the direction of the vector in the second quadrant of the plane so components x equals negative 3 and y equals 2 so now what happens is we're interested in the angle between the positive x axis and this vector pointing towards the point from the origin to the point negative 3 comma 2 so we're going to have this obtuse angle we're always going to go from the positive x axis counterclockwise that's what we're interested in in quadrants 1 and 2 but we see we get this result negative 0.58 so what that is telling us what the result is showing us if we just think about the the inverse tangent function is that's going to give us the angle going in a clockwise direction from the negative x axis up to our vector and to get the the expression that we really want we really want we've just got to add pi radians to that and that's going to give us the other side in other words from the positive x axis all the way around counterclockwise to the vector so we get the real solution there 2.55 radians now we're going to get to quadrants 3 and 4 now there we express things differently so in quadrants 1 and 2 we want this idea of going counterclockwise from the positive x axis so we're going to get this acute angle in quadrant 1 and this obtuse angle in quadrant 2 but if we get to quadrant 3 and 4 what we actually want to do there is still go from the positive x axis but go go downwards clockwise to the vector and then because it's clockwise we want that expressed as negative angles so in the fourth quadrant it'll be this negative acute angle and then the third quadrant it's this negative obtuse angle so let's just see so we've got this idea of where were we we've got this calculate the direction of the vector in the third quadrant of the plane with components x equals negative 3 and y equals negative 2 so if we do that we get this solution 0.58 but what that is going to do that's again that is from the negative x axis going counterclockwise and that's not what we want we want from the positive x axis going downwards clockwise to that so what do we have to do we've got to add that to negative pi radians and I've shown you pi there all along let me just show you how nice it is to get a pi symbol and code that's something you can't do in many other languages I'm going to just hit in a code cell my backslash and then pi and then the tab symbol and that should give me pi and there we go pi and if I just do that it's going to give me an approximation for the value of pi so that's as simple as that to get pi and if I go just there I can just delete that cell so it's negative pi plus that arc tangent and then we're going to get the the real solution negative 2.55 radians that's going from the positive x axis counterclockwise so clockwise I should say downwards this obtuse angle and then when we get to the fourth quadrant say x equals 3 y equals negative 2 we get this value that we're interested in this negative acute angle positive x axis downwards clockwise to that so the only place that we need to make changes is in the second and third quadrants so using the arc tangent function so in the second quadrant we're going to add pi to the solution and in the third quadrant we're going to add negative pi to it so if you remember that you're never going to make a mistake in calculating in calculating the correct angles or expressing them correctly so when our vectors vectors equal so we see these two vectors there now I think you would agree just looking at it and that is how I design them they're pointing in the same direction and they have the same magnitude in vectors for us for looking from a linear algebra linear algebra point of view those are exactly the same thing so I can have this translation on in space or on the plane but it remains the same vector I can move that so the tail of the bottom one the purple one the vector two is also at the origin and then those two points the two heads will coincide and we have exactly the same vector so vectors no matter where I draw them on the plane if they have the same magnitude in same direction they exactly the same thing nothing changes and you see my little argument there so that p I've got the two the vector p the point p and the point q so p would be at zero zero and q would be at three two so that would be this zero zero there and three two okay if I look at the vector pq that'll be just q one minus q two and q one minus p one and q two minus p two and that gives us this three comma two because it's three minus zero and two minus zero and if I have this p point p prime and p and q prime p prime sub one being negative one p prime sub two being negative one and you see the values there for q prime the two points but if I do the subtraction once again I also end up at three comma two so really pq equals p prime q prime but you can you can see that so intuitively there same direction same magnitude is exactly the same vector that being just to this idea of row vectors so we express them as a column and mathematical and we do some calculations and future notebooks if we get the row vectors become quite important as well and we can take a column vector and we have this in this operation called the transpose so you just make the column into a row so the column component becomes an element in the row component so remember u there was u and it was three comma two I can twirl it down it's three comma two now you use the transpose on that and now it becomes this 64 bit integers in an array so it's an array of 64 bit integers expressed in this way three two and so instead of it being a column there you see it's now a row and this is how you do it there's equation eight makes should make it all clear I have this vector u and r in space u one u two all the way to un and I take the transpose of that so that the u and then this superscript uppercase t and every element there in the column becomes an element in the row so as simple as that you transpose and that becomes a useful thing to do now let's look at a bit of vector arithmetic very important so we're going to start by looking at vector addition and we see how we have how we define vector addition this is how we define it and it's very intuitive as well from from figure number five so I've got my two vectors here this one at the bottom this red one and then this purple one here and all I'm doing this purple one was also expressed as a position vector so its tail was also down here and its head was was somewhere here but we just move it so that its tail is at the head of the first vector and then if we add them it's just adding the x components of the two and adding the y components of the two to get this top one this resultant vector so if you look at equation nine there we just add the two components u one and v one u two and v two all the way down so for all so this upside down a that means for all we just show you the lartic for that that's all the lartic there if you get your hands on the notebook you can study that so we're just adding these components as you can see so for all u and v elements of r in it follows that u plus v is that we're just adding the components and and from this figure should make intuitive sense so we are task in problem six was creating two random vectors in r4 we're going to add them so in the random package there's this idea of this function random dot seed exclamation mark that exclamation mark it's called a bang and you can pass to that any integer I'm passing 12 to it so if I execute that and then I use the random package to generate random values well they pseudo pseudo random values it's going to generate the same values every time because I've seeded the pseudo random number generator so what are we going to do rand function there from the rand package we use a unit range one colon five and because we don't have a step size the default step size of this unit range is one so from one to five it'll have elements one two three four five so I'm saying take from the elements one comma two comma three comma four comma five and and give me four back at random please so what happens there's one two three four and five is in a bucket piece of papers in a five piece of paper and I draw a piece of paper and the first one was a five so I jot it down throw the five back mix them up again draw random again so every time each of those five values has an equal likelihood of being chosen so what it came up with was five four two four and if you seeded the pseudo random number generator at twelve as well you're going to get exactly the same random values I've created another vector vector underscore two and again just from the random rand function again with the same unit range four values and it gave me vector one five four three and I just say vector one plus vector two and indeed five there's the five the first component there we go for the five plus the one that's the six that's how I get with that's the six the four the five is nine etc very simple but if you do that in code it's even simpler vector underscore one plus vector underscore two is going to give you that column vector very simple very simple scalar vector multiplication is just as simple so we're going to take this scalar c element of of a real number and u that's an element of any arbitrary vector then n space it follows that cu equals just multiplying every component by that scalar and that's scalar vector multiplication as simple as that so problem seven multiply vector one by three that'll just be three times vector one as simple as that and each element in vector one is now just multiplied by by three what does that do though so one reason to like these puto notebooks is that you have the puto ui package that we imported and that allows us to create this variable c here and we're going to use the macro at bind and we're going to bind to see this slider and the slider uses a unit range from negative two to two as I said we don't have a step size so the step size by default is one so negative two negative one zero one and two so this slider is going to be linked to that to those values so what I've done here at the bottom is I've created this vector two comma two but I'm multiplying each one of them by c so what I'm doing here is this this vector two comma two and all we're doing to this vector we're scaling it so that'll be negative two times the vector two comma two and that will be negative one now it gets a bit shorter zero there's no vector because if I zero times two zero zero times two zero one there's my original vector and it scales so what does scalar vector multiplication do well it just scales a vector makes it shorter and longer doesn't change the direction and that in as much as the line that runs through that it can go in the 180 degrees or pi radians opposite direction by making the scalar negative for sure but it stays in that same stays in that same line so we can also then think of what it does to the magnitude so the magnitude of this scalar vector multiplication is just take that vector and just multiply it by the scalar the magnitude of that vector multiplied by the scalar as simple as that and that gives us this idea of how to subtract vectors from each other because what I can do is I can just multiply the second vector by negative one the scalar negative one now points in the opposite direction so instead of a plus v I have a plus negative v and that's the same as or u plus negative v that'll be same as u minus v exactly the same thing u minus v is just u plus scalar vector multiplication that a negative one times v and that also gives us this sort of scalar vector division in as much as as long as that scalar is not zero I can have this idea of dividing a vector by a scalar and it's just this reciprocal one over the scalar times u so every element will just be multiplied by one over that scalar so that's very simple vector addition that's basically all we have because vector subtraction is still vector addition by adding a bit of scalar vector multiplication and just making that scalar negative one so when you have these two operations basically vector addition and scalar vector multiplication now we get to something a bit different and that's the dot product between two vectors and you'll have to do a lot of examples I think in your exams etc of dot product and the other one is a cross product let's start with the dot product and we see the definition here in equation 14 so for all vectors u and v element and r n so you can take any two vectors in that space as far as that u dot v we write that as the utranspose dot v and what that really is and when we get to matrices we'll see what that really means is that we just multiply the components pair by pair and we just add all of those so u1 times v1 plus u2 times v2 plus so you can see the answer is going to be a scalar so let's look at problem eight so we ask to generate two vectors in r4 and calculate their dot product so again I'm going to see the pseudo random number generator I'm going to use the ran function twice and just generate these four now I've just said one to five but you can choose any unit range you want so that you don't just get elements between one and five you can make negative five to five whatever you want but four elements that's important so I've got my two vectors again and because the pseudo random random number generator was was seeded with a value 12 we get exactly the same two vectors as before and then to do the dot product is very simple in as much as we use the dot function dot function and then we just put in these two vectors separated by a comma and we get the answer 45 and here we go I'm just going to show you there's my two column vectors that we generated up there so it's five times one plus four times five plus two times four plus four times three that's five plus 20 plus eight plus 12 and that gives us 45 and there's the dot products 45 no problem so what about the dot product of a vector with itself so we read here the dot product has some interesting properties first the dot product of a vector with itself is always positive or it can be zero so I'm talking u dot u now it's always positive because what we're doing is component times component in other words that's component square if the vector is dotted with itself and square is always positive so we're just going to get a positive in the only way that we can get zero is if it's the zero vector and lo and behold the zero vector of course does exist all the elements are just zero so if we look at u dot u there and if the vector is three comma four comma negative three and problem eight it's three square plus four square plus negative three squared and that gives us 34 and again if I do that with a dot product I'm going to get the same answer 34 as simple as that so in actual fact what we're doing here is just taking the dot product there's nothing other than just taking the magnitude of the vector and squaring it as simple as that another interesting fact that we'll see is if the two vectors are orthogonal which is a fancy word for perpendicular to each other their dot product always be zero or then if you do the dot product between two non-zero vectors and it turns out to be zero you know that those two vectors are orthogonal to each other and you can see the code there so let's take these two they clearly orthogonal three and five and negative five and three and if you take the dot product between those it's zero now there's three more properties that you'll see in your textbook is that there's this commutative property in vector and the dot product between two vectors we have this distribution of addition so u dot v plus w that should be u dot v plus u dot w and this distribution of the scalar as well as you can see there so let's look at the dot product a bit differently because what is it I mean we're just multiplying the component wise and adding all the products but what is it and the first way we're going to look at it is just this the dot product is a function of the angle between two vectors and what we're going to do is we're going to use this the the law of cosines so if I have two sides of a triangle a and b and the angle between them being theta and then opposite theta we'll get the other side of the triangle we'll call that c and then we get this idea of the law of cosines that c square equals a square plus b squared minus two b c cosine theta now think about a triangle let's make a the length of a let's make a a vector and b a vector and c a vector and if a is a vector its length is going to be the magnitude of a and the length of the side b is going to be the magnitude of the vector b and then c and I want you to play with that c would be a minus b so draw yourself on paper some vectors and look at a minus b so that's a plus negative b and translate that vector and you'll see it neatly forms that third side of the triangle so to write this out c would then be c squared would be a minus b that magnitude of that different squared a squared would be the magnitude of a squared b would be the magnitude of b squared minus two b c so there should be b c there so let's fix that so that's minus two oh a b is right up there should be a b there here we go minus two a b here we go fixed c squared equals a square plus b because squared minus two a b cosine theta and that's what we have there but let's look at what an equation line what a minus b is remember that will be component wise subtraction a one minus b one and a two minus b two as a vector and if we take the magnitude of this a minus b which is c there'll be a one minus b one square plus a two minus b two squared and add that and take the square root of all of that and if we square both sides that's what we have and if on the right hand side we just expand these two squares that's what we get and we just group these terms together then we get a one squared plus a two squared well that's the magnitude of a squared b sub one squared plus b sub two squared well that's the magnitude of b squared and minus two times a one b one plus a two b two well what is that well that's a dot b so this is what we have left so now a minus b magnitude squared we have two equations for it there's one in 18 and there's two in number two and 19 so we just equate these two to each other so that these magnitude squares they all cancel out the negative twos cancel out and I have this new way to look at the dot product the dot product is the magnitude of a times the magnitude of b times the cosine of the angle between them or we can just take the arc cosine well take the magnitude towards the other side and take the arc cosine or inverse cosine function and that gives me theta so let's just do that calculate the angle between these two vectors so that's very simple and you can see the code for there using the arc to a cos for arc cosine or inverse cosine function I'm taking the two the dot product of those two vectors and dividing it by the product of the two magnitudes using the norm function and again I can express this as radians two degrees with that function and that gives us 38 degrees as simple as that the Cauchy Cauchy Schwarz inequality you see that there you might be asked to do that and there's a little problem for you there using the dot product and we also get this Minkowski triangle inequality what you see there now I don't do any proofs in this video set but let me know if you want a video on how to do the proofs of these they actually quite fun fun to do but you can see that we have this little problem 11 then the solution just taking the norm of the addition and then the addition of the norms there and you'll see of course that one is smaller than the other I skip over those quite quickly because what I want to get to really is this idea of orthogonal projections because that's really what a dot product is remember we're getting a scalar out so let's look at these two I have vector w in this image here and vector a there and I can take this idea of the orthogonal component of of w along a so from w I draw this line down to a and it's orthogonal to a so that I can decompose w into two components so that the one component is along a and the other component is of course orthogonal to a so what the dot product really is and what we're going to see is is really the multiplication of the component of w along a called the projection of w along a and multiplied by a and let me let the cat out the bag if you think of physics work equals force times distance but it's only the component of the force along the displacement force times displacement but only the component of the force along the displacement contributes to the work and now you can think why if I have two orthogonal vectors that the dot product is zero because of my force is totally orthogonal to the displacement that force is doing no work whatsoever because there's no component of that force along the displacement vector anyway if you have a png file saved on your hard drive you can use this local resource function and that local resource function is of course a function in the plot uh pluto ui package and you can just reference it the way it is on your hard drive and it'll draw the figure for you the the the png file for you there so that is the derivation of this idea of the projection of w along a so w if you think of w I can get deconstructed into u plus v in other words use w minus v just a bit of simple algebra so you remember we're gonna that is the projection of w along a and that's how we write it p roj of w along a so the little subscript a there that is u it's just a different notation for you so that's w minus v but if you think of what u is it's now along a so it's just a scalar multiple of a so we can write it as k times a and that k times a there remember that k is just a scalar so now that we have another way to write w another way to write you I should say we started with with w equals u plus k so we can rewrite w equals k a plus v so what are we gonna do if we have w dot a that's what we're interested in here well I have w written differently here k a k times a plus v dot a so it's just rewriting w because we've got another way to write w there and if I do this we've looked at those properties that will be k times a dot a plus v dot a look back at those properties and a dot a remember that's the square of the magnitude so I have k times the square of that magnitude of a plus v a but v and a they orthogonal to each other if you look at the image so that's zero so just solving for k I have k equals w dot a divided by the magnitude square of a so we have what k is now we can just put k back into what we have here u equals k times a so u being the projection of w along a that is the dot product of w and a divided by the magnitude of a squared times a so w dot a that is going to give us a dot product and that is a scalar divided by the magnitude that's a scalar so we have this big scalar times a and that's exactly what you is it's this scalar vers scaled version of a now we can also work out this idea of the magnitude of the projections so we just take the projection here of u and so that will be you can also put double lines there which means we can take this a out as on the right hand side here as a magnitude and we have a magnitude over magnitude squared so that's going to cancel so this length of this component of w long a or the length of u we see the as the absolute value of the dot product divided by a's magnitude and that's exactly where we get this idea of work equals force times difference times the displacement those vectors so it's this idea of w if w is the force and a is the displacement it's this idea here I'm just bringing the a over to the other side of the projection so you get this idea of what the dot product is used for so instead of the dot product we also get the cross product but first we just have to look at the unit vectors and that's just taking a vector and scaling it down so that it's magnitude is one and the way that we do that is we just take a vector and we divide it by and we've already seen this one over c times a vector so it's a type of scalar vector multiplication but at the bottom we have the magnitude of u so each component is just going to be divided by the magnitude and then we put this little hat symbol on top of it and it's no longer bold face and that's the unit vector of u so it's still in the same direction as u it just has now has a magnitude of one so there's problem 12 I have u and that is three four and zero and I just want the magnitude of that so I'll take the norm of that so I've created the vector underscore u there take the norm of that the norm is five and so I'm going to take vector u and divide it by five so each component is going to be divided by five and then I get 0.608 and zero so that's still in the same direction it is just now has a unit length so its magnitude is one of course if we think of the three axes of the cut of Cartesian space or the Cartesian plane then with this two component we have this unit vectors along each of the axes and we call those the unit basis vectors and we write those as i hat j hat and k hat and you can see the components there making absolute sense because we have now this idea of a cross product so what you have what happens is with the cross product is a cross product is orthogonal to the plane created by the two vectors that you're taking the cross product on so if the two cross products are in the plane the result will be perpendicular to the plane so I need that to have that third dimension and it's also the right hand rule and your thumb points in the in the direction we write it as u cross v as you can see there and we do that by taking the determinant of this matrix here but we haven't studied matrices so I can't really explain to you what's going on there just trust me then that if you take the determinant of this matrix and you write on the first row the three unit basis vectors and as a as row vectors you write the two others now you have a little three by three matrix you take the determinant of that and that is just going to give you the cross product we can also be easy in Julia just use the cross function create my two vectors in the cross function cross with that would be now look at this my vectors were along 2 comma 0 2 2 comma 1 comma 0 so I've got to express even though those vectors on the plane I've got to express them as as vectors in three space in r3 because my result is going to be in r3 so I have these two vectors on the in the plane but look at the cross product it'll have 0 0 in the x y plane their components but negative five in the z component so it is going to be orthogonal to the plane so what's the physical interpretation even though we can't yet explain exactly what's going on here before we've looked at matrices is that if I have these two vectors now look at this vector down the bottom here and this red vector going there and all I've done is I've completed them by translation so that I can form this parallelogram so this parallelogram has an area in the base of it is well there's the point three so it has a base of three and the height of two so it's base times perpendicular height three times two is six the area of this parallelogram formed by these two vectors these two position vectors the red one here and the brown one down here they form a parallelogram if we extend it and translate the two of them in the area of that well that's the cross product we said it was six and lo and behold if you take the cross product of those two vectors three and zero and five and two you get the the norm of that magnitude the norm of that vector that would just be six its length is six and that magnitude at least is the area of this parallelogram the magnitude of the cross product then we get this thing called the scalar triple product so I'm going to take first the cross product between the two vectors and that resultant orthogonal vector to those two vectors I dot that with you and then I get the scalar triple product and this is how we do it the determinant of the three vectors written here as row vectors and if I get that determinant that's going to give me the scalar triple product and what that really is is those three vectors if they all position vectors they form a parallelepiped and this this scalar triple product which is a scalar gives me the volume of that parallelepiped which brings us to this last idea of spanning now if I think of the vectors the unit vectors basis unit vectors i hat and j hat a linear combination of them and this is a linear combination is that I just take a vector and I'm multiplied by a scalar and another vector multiplied by scalar and I add that that I can get to any vector or any point in the plane so scalar multiple a scalar um a linear combination of vectors so I take one comma zero that's the unit vector along the x axis and I'm multiplied by some value say three that ends me up at three comma zero and I add to that three times the unit vector on the on the y axis which is zero one that gives me say I multiply that by five so that becomes zero five and zero five and three zero leaves me at three five so I can get to the vector three five so I can get to anywhere with these two basis vectors and what we say about them is they span the whole of r2 those two vectors span because the linear combination of them can get to any vector in the plane so if I use i j and k so zero one zero zero zero one zero and zero zero one is my three standard basis vectors in r3 a linear combination of them can get to a vector anywhere in space in three space anyway those three vectors span the space alternatively we say they are a basis for that space and it's because they are linearly independent and when our vectors linearly independent well we can test for that and that's in a future book is that one cannot be written as a linear combination of the other there's no way with a with a vector i hat to get a linear combination of it in other words multiplying it by a scalar adding another multiple of it to it and another multiple it I can never get to one zero there's just no way I can never get away from the x axis if I just have one zero in other words these two vectors are linearly independent of each other and if they're linearly independent of each other then they form this basis of they are a basis of that space and we'll review all of that because it becomes very important that this notebook is all about the intuition though that somehow that they that you can develop this idea in your head that they span a space because a linear combination of them can reach anyway in that space so three things you've learned here first of all is the idea behind this is vectors nucleon space then how to use a notebook to generate your notes so that they look very nice and then how to just use Julia code to do all your your work for you so you might have to do it in pen and paper but you can just always just verify your work with a single line of code and having your notes as neat as this being able to visualize it and check your results with some code I think that's a very neat way of understanding your mathematics and doing your mathematics