 All right, well, we'll go ahead and get started. So, we have a short week this week, obviously. Today's the only day of class, but nonetheless, we will have a homework assignment, and here it is. So, let me just walk you through it. I'll go ahead and turn off the lights so it'll be easier to see. Okay, so there are three problems, and the first two problems have to do with series expansions of functions. Okay, so in the first one, I want you to expand this function f of x equals 1 over 1 plus x in Maclaurin series. So, that means around the point x equals 0 over this interval. And I want you to do that in a table where you include expansions with 1, 2, 3, et cetera, up to 10 terms. All right, and then I want you to plot this function with a thick black line along with the various expansions that you create all on the same plot. Okay, so this is practically identical to an example that's in your notes. It's just a different function. All right, so the next one, number two, is a Fourier series expansion. So, I want you to take the parabola f of x equals x squared over the interval minus 1 to 1. So, it'll be a symmetric function over a symmetric interval. And from our discussion of the parity of functions, odd and even, this is an even function. And so, you should include in your Fourier series only terms with even numbers in the expansion. Okay, so go ahead and do that for 2, 4, 6, 8, and 10. This is a Fourier series expansion. And I want to point out to you that this interval minus 1 to 1 is not the default interval for the Fourier series. So, you'll have to change that. And there's an example of how to do that in the notes. All right, and then similarly to problem one, I've asked you to plot the function in thick black line and then these various Fourier series expansions in the colors. All right, so these two, like I say, they're practically identical to examples that are in the notes. So, I just want to see if you can basically reproduce those. And then the third one, this is just a one liner where I ask you to show using the symbolic Fourier transform in Mathematica that the Fourier transform of hyperbolic secant function gives you another hyperbolic secant function. So, it's similar to the Gaussian in the sense that the Fourier transform of the function has the same form as the function itself. Yes? So, no graph for the third one, right? No graph for the third one. That should just be a one liner. All right? Any other questions on the homework? Okay, so this should be pretty easy to get done in the lab sections tomorrow if you don't get it done before then. All right, so we're going to change subjects now. We're going to move from sums and series and Fourier analysis to vectors and matrices. Okay? So, just to calibrate me here, how many of you have not had a course in vector calculus? All right, that's good. So, most of what we'll do with vectors should be a review and an introduction to how to work with vectors in Mathematica. Okay, second question is, how many of you have had some exposure to algebra involving matrices? All right? So, not very many. All right, so we'll give you a crash course in matrices and a few aspects of linear algebra in this unit. Okay, so I'm going to go to the board and write some notes just to put us all on the same page with respect to some definition of vectors and some, whoops, some simple vector arithmet. Whoops, keep hitting the wrong one here, sorry. All right, so who wants to volunteer me a definition of a vector and better yet to contrast that with the definition of scalar? Come on, please. Yes. All right, that's a very good definition. So, a vector is a mathematical object that has both magnitude and direction whereas scalar has just a magnitude, all right? So, how can we represent a vector? Well, normally when we talk about vectors, they are objects in what's called a vector space and within a vector space, there's a special collection of vectors that are the so-called basis vectors. Okay, so for example, in Cartesian space, ordinary x, y, and z space, the basis vectors are unit vectors along the x, y, and z axes. Okay, but in general, we can write a vector which I'll call v as follows. It'll be the length of the vector along a direction e1, so that e1 is a basis vector and then another one in the direction of e2 and where I use these little carrots, those refer to unit vectors and when I draw an arrow, it's an arbitrary vector, not necessarily a unit vector and then this can go on and on out to vn where the space that we're in is n-dimensional. Okay, so that's one way that we can write a vector in terms of its components and the basis. But once we know what the basis is, so if I say, okay, I know that I'm in a vector space that has a basis, a set of basis vectors e1 through en, I don't need to write all the e's, so I can write it more compactly. So in fact, what I could do is I could just write this as a list of components, so v1, v2, dot, dot, dot, vn. And this is in fact the way that we'll specify a vector in Mathematica. It's just going to be a list of numbers and those numbers are the components of the vector with the basis either unspecified or understood, okay? All right, now let's talk about some other things about the vector. So if I have a vector like this, how do I calculate its length or its magnitude or its norm? Is that a square root sign? Okay, so let's draw a square root sign. It's the sum of the squares of the components. That's correct, okay? So that's the norm or the length if you like and the way I specify that here is the absolute value, all right? Okay, now suppose I want to construct a unit vector in the direction of v. How would I do that? So that a unit vector is a vector whose length is 1. Well, what I can do is I'll call that 1 u. I can create a vector in this direction by dividing each of its components by the length and then it will have a unit length, okay? So I can write that as v1 divided by v, v2 divided by v dot, dot, dot, vn, v, okay? So that creates a vector of length 1. You can see that because here we have the square root of all these components. You can see that it's going to give a vector of length 1 and it's in the direction of v. All right, now suppose I have two vectors and I want to multiply them. What are the ways in which I can do that? The dot product and cross product, okay? So let's suppose I have, I'm going to define two vectors, just three-dimensional so I'll call r is going to be equal to r1, r2, r3 and s is equal to s1, s2 and s3 and suppose now I want to take the inner or dot product, how does that work? Yes, so we just multiply each of the components together and add them up. And the dot product has a geometric interpretation. You remember what the geometric interpretation is? If I draw to the two vectors like this and define this angle theta, then we know that cosine of theta is equal to r dot s divided by the magnitude of r times the magnitude of s. Okay? So that's a useful, very useful relation. Okay, now there's another kind of product and someone mentioned that that's called the cross product. How do I make the cross product? Well, one way I can do it is by calculating this determinant. You remember how that works? Take this guy, e1 and then strike out these and create this r2 s3 minus r3 s2, okay? And then we take minus this one, strike, r1 s3 minus r3 s1 and then plus e3 strike r1 s2 minus r2 s1. And we can see that when we do the cross product, here in the dot product we get a scalar. It's just a number, right? But when we do the cross product we actually get a vector. And what's the geometric interpretation of that vector? Yeah, if I draw, now let's just draw r and s here. It's going to be a vector that's perpendicular to both r and s, but there's a handedness to it. I could draw two vectors perpendicular to r and s, right? One pointing down and one pointing up. Which one is it? The one pointing up? We get it by the right hand rule. So I take r and sweep in the direction of s and then my thumb goes in the direction of the cross product. So this would be r cross s, all right? And if I draw a unit vector here, which I'll call n, which is just a unit vector in the direction of r cross s, then I have another geometric relation between or relating the cross product to that angle. And do you remember what that is? R cross s equals r s sine theta times that unit vector, okay? So in other words, this is the magnitude of r cross s, all right? So let's see. I think that'll be good enough for now. So here's a few things that I presume you know. And if not, here's a quick review. And now what we'll do is we'll see how to do these various vector operations in Mathematica. And then we'll talk a little bit about, I just want to make you aware that some tools exist if you want to do some vector calculus. So we'll talk about vector differentiation after we get done with the introduction. Okay, so as I already mentioned, vectors are easy to define in Mathematica. They're just going to be a list of components, okay? So we'll define now four vectors, some symbolic and then some with numbers in them. So for example, we can set u equals, these are all going to be three-dimensional. So it's a list, so I need a curly bracket and then I have u1, u2 and u3. All right, so this is a three-dimensional vector with components u1, u2, u3. I can define v equals v1, v2, v3. And then I'll define r equals 1, 1, 1 and s equals minus 1, minus 2 and 1, all right? So I'll go ahead and enter that. Okay, now we didn't talk about it but we can see how it works. How do I add two vectors? We just add the components, all right? So u plus v is a vector with components u1 plus, excuse me, v1, u2 plus v2 and u3 plus v3, okay? I can add r and s, get a single vector with some numerical components. Subtraction works the same way. Just subtract the components and I can do r minus s, 2, 3, 0. Okay, now how do we multiply a vector by a scalar? So suppose I want to take a where a is just a number or a variable, a times v. What should that give me? It should scale each of the components by a. So there you have it. So that works, fine. I could take u divided by 2, same story, it's just multiplication by a half. So I get u1 over 2, u2 over 2, u3 over 2. I can ask for 5 times s and then I get some numbers. Okay, so these are simple vector arithmetic. All right, now let's see how to do the dot product. So there's two ways you can do the dot product in Mathematica. One is just to put a dot. So u dot v and you get the formula corresponding to the one that's written on the board for the dot product. Another thing we can do is we can say dot and then give two vectors and it will give us the dot product. So dot u comma v is the same. All right, what if I dot v onto u, what should I get? Same thing. So this illustrates that the dot product is what we call commutative. All right, u dot v equals v dot u. All right, what happens if we dot r and s? Then we get a single number as we should, a scalar. All right, now let's look at the cross product. So the cross product we get by saying cross and then we put in u or our two vectors, u and v. All right, and if you enter that you see that you get what we wrote down over on the board essentially. Okay, what happens if I cross, oops, cross v onto u, what should I get? Should I get the same thing as u cross v? No. In fact what I get is minus u cross v. So is the cross product commutative? No. Okay, that's a good thing to keep in mind. Okay, now suppose I want the length of u in Mathematica. Well the way you get that is you say norm and then you put in the vector and so notice here we get the square root of the sum of the squares of the components. Now notice the abs, we didn't write the abs down over there because over there I was assuming that the components are real but in general Mathematica considers that the number could be complex, the components and if the components are complex the absolute value ensures that you'll get a positive quantity for the norm for the magnitude. All right, we can do the norm of s. Oops, and we should just get a single number and we do and it's the square root of six. Okay, now suppose I want to construct a unit vector in the direction of v. Well as we said over there we take the components and we divide them by the length. You can do that all in one shot with Mathematica, the command is called normalize. So normalize v is going to return a vector, a unit vector in the direction of v. All right, so you see it adheres to the formula that we wrote on the board. Each component has been divided by the norm or the length. All right, we can normalize r and we get a vector with numerical components. What if we do just to check the length, right? So we can say normalize v and then we square the thing. What happened here? Oh, then we have to square root. Oh, I'm sorry, no, I wanted the norm of normalize, sorry about that, I'm improvising here. So norm of normalize of v. All right, so we want to put norm around normalize and we should get if we do full simplify as a post fix we get one. Okay, that's what I just wanted to show you that in fact once we use normalize we do in fact get a unit vector. Okay, a couple more little operations here to verify a few things. So I'm going to define the Cartesian basis vectors. So I'll call e1, this is going to be a unit vector along the x axis I'm assuming I'm in Cartesian space, that'll be 1, 0, 0, oops. All right, and then we'll define e2 is 0, 1, 0, e3 equals 0, 0, 1. Okay, so now I have my Cartesian basis vectors and now I just want to remind you of one other thing. So now if I take an arbitrary three-dimensional vector v, which we've already defined, and I dot that with e1, what we get is the component of the vector in the x direction, right, this is called the projection. We've projected v onto the x axis and the value we get is actually the x coordinate of the vector v. And likewise if we do v dot e2 we get the y component and v dot e3 the z component. All right, now next thing I'm going to do is I'm going to define this vector a, it's going to be 1, 1, 0. Okay, so if this is in Cartesian space, where would this vector be pointing? As the x component of 1 and a y component of 1 and the z component of 0. It'll be in the xy plane, which direction? It'll bisect the x and y axes, right? Okay, so its angle with respect to those axes should be 45 degrees. All right, so let's verify that. So the way we'll verify that, we'll do it with respect to the x axis, so what I'll do is I'll take a dot e1, so that's the x basis vector, and then I'm going to divide by the norm of a times the norm of e1. Now we know the norm of e1 is 1, but it's okay. And we'll put parentheses here. All right, so that should be the cosine of the angle. And if I want the actual angle itself I take the arc cosine, which in Mathematica is arc cos, and I should get 45 degrees. Is that 45 degrees? Pi radians divided by 4. What if we wanted to convert that to degrees? Well, it turns out there's a constant in Mathematica predefined that allows you to convert between radians and degrees. Okay, so it's called degree, so let's question mark degree. And what we see is that degree is the number of radians in 1 degree. Okay? So if we want to convert from radians to degrees, we should divide the angle in radians by this constant. And if we want to convert from degrees back to radians, then we multiply by this constant. Okay? So let's go ahead and we'll mouse this in, put it down here, and then we'll divide by degree. Pi over 4 degrees. How about n percent? 45. All right? So there you have it. And then just one other thing. We talked about the cross product, so let's just illustrate the relation between the cross product and the vectors that it's formed from, and we can do that easily by saying let's cross E1 with E2. What should we get? If E1 is a unit vector along X and E2 is a unit vector along Y, what should E3 be? Unit vector along Z. And it is. Okay? All right, so nothing too profound here, but hopefully you appreciate that it's nice that you can do all the familiar vector arithmetic that you've learned so well in your vector calculus class using Mathematica if you wish. Now the next thing that I want to introduce you to, and let me issue a disclaimer here, we're not going to actually use these things to do any homework problems, but I want to let you know that they exist if you ever want to use them in future. And this is some various types of vector derivatives. Okay? Some of them are probably familiar to you and others may not be, but you might or probably will encounter them in physical chemistry. And if you take upper-level physics classes, you will certainly encounter them there. All right? So I'm going to go back over to the board now and tell you what we're going to talk about. All right, so let's start with a clean slate. All right, so there are various kinds of vector derivatives. All right, so the first one, this one is certainly, must be familiar to you if you took your physics class. So I'm going to define a vector that's a function of a scalar. Okay, so I'm going to call this one R of T. Okay? And I'm going to make it a three-dimensional Cartesian vector where each of the components depends on T. So you might think of this as being the position of a particle in Cartesian space, at time T. All right, so it's going to have components X of T, Y of T, and Z of T. Now, if this was the position at time T and I wanted to evaluate the velocity at time T, what should I do? I take the derivative. All right, and what does that give me? Well, that gives me, so this is going to be R prime of T or DR by DT. And the way I do that is I just take the derivative of each of the components with respect to T. All right? So that would be X prime of T, Y prime of T, and Z prime of T. All right? So that's the velocity vector. All right, that one's fairly straightforward. Now, the next thing I want to do is I want to define a scalar function of a vector. Okay, so I might call this F of X, Y, and Z. All right? So this is a function, could be of the coordinates in Cartesian space. All right? Now, there are a couple of interesting derivatives of scalar functions. Okay, the first one that I want to remind you about is the so-called gradient of F. Have you seen the gradient before, this upside-down triangle called the del operator? And I put an arrow on it to remind us that this is a vector operator. It's going to produce a vector result. All right? So how do I form then the gradient? I take the partial derivative of F with respect to X and multiply that by the basis vector in the direction of X. Maybe you're used to seeing I, J, K. Yeah, that's also fine. All right? And then the same for Y and Z. Can you give me an example of where gradient would appear, say, in chemistry or physics? The del operator shows up in the definition of the momentum, yes, uh-huh. Another place where it shows up is if you know the potential, if you know the potential energy, so if F was the potential energy that a particle experiences at coordinate X, Y, and Z, the force would be minus the gradient of the potential energy. And then another example from electrostatics, you may or may not have seen, is that if F was the electrostatic potential, the gradient of F would be the electric field. Okay? So those are some examples. All right. Now, what if I take the gradient of F and then I take the gradient of that? Or actually, no, I don't take the gradient of that. I dot the del operator onto the result. I can write that as del squared, where now, since I've dotted two vectors, I get scalar. Those of you who are in PICM know what that is. All right? So this is the gradient. What do we call this one? Laplace. We have to respect the French name. Laplace. Laplacian. Okay? And how do we write that in Cartesian coordinates? Well, that's the second derivative of F plus. Okay? So there's your Laplacian. And you quantum mechanics experts, where does the Laplacian show up? Mm-hmm. Minus H bar squared over 2 times the mass times the Laplacian is the kinetic energy operator. And it operates on a wave function. All right. Another place where it shows up is in an equation relating charge density to electrostatic potential and electrostatics, which is called Poisson's equation. Anybody heard of Poisson's equation? Another French. Okay. All right. You may see that later on in physical chemistry if you study the Debye-Huckel theory, which I hope you will. Okay. In any case, so that's the Laplacian. And so just to reiterate, right, here we've got a vector operator and it produces a vector result. And here now we have a scalar operator and it produces a scalar result. All right. Now there's two other kind of differential operators that are useful to know about. And you may or may not have seen them before. One is, okay, so now what we have to do, we're going to define, so these are scalar functions or scalar fields, right? So I go out to a point x, y, and z and f has just a value. F is a scalar. Now what if I go out into f, I mean x, y, and z and I find a vector? Then that function, the function that defines that vector at points in space, that's what's called a vector field. Okay. And so let me write down a different function now which is now going to be a vector field. And I'll define that in terms of components which I'll call f sub x, f sub y, and f sub z. And each of these is understood to be a function of the coordinates. Okay. So do you see the difference between these? These two? This function gives a single number when evaluated at a point x, y, z, and this one gives a vector whose components I've defined as fx, fy, and fz. Okay. So this might be potential energy and this might be force or something like that. All right. Now, so when we have these vector fields, there are two common differential operations that we can do. One is we can dot, let me go up here and do this. You can take the del operator and dot into f. Has anybody seen this one before? Have you? This, yeah, I didn't, you normally don't see this in calculus class, I guess. This is what's called the divergence. Okay. And the divergence is an important quantity in physics and I guess in chemistry also. It's a measure of flux, a vector flux, okay, flow. All right. And notice it's a dot so there's a vector dotted with a vector so we should get out scalar. And so we get out, okay, take the derivative of the x component of the vector function with respect to x and then add that to and then, okay. So that's the divergence and just to reiterate, this is now a vector function, okay. All right. And then there's one more that I'll introduce you to and that one is what you get when you cross the del operator on a vector function. Has anybody seen that one? That one is called the curl and it may not be super obvious without a specific example but it tells you about rotation so if I had like a fluid flowing in one direction and in that fluid there was a ball that had some roughness the curl would measure a vector perpendicular to the rotation of this ball in the fluid, okay. So that's one example of the interpretation of the curl. But in any case, the way it's defined here is as the cross product so I won't multiply everything out but you can see how to construct it if you write it in this form, so that would be how you construct the curl, right, you take e1 and then it's going to be the derivative of fz with respect to y minus the derivative of fy with respect to z, et cetera, et cetera, okay. And it produces a vector result which gives this direction of the curl. All right, so lots of vector derivatives. Now like I said, I'm not going to ask you to do this stuff but I want to let you know that it's there in case you ever want to use it in future, all right. And most of this stuff is not part of the standard default package that you load in when you fire up Mathematica so I'll show you how to access it, okay. Now, the first one we'll do is we'll just, we'll do the position velocity one, all right. So I'll define an arbitrary function r of t so this might be the position colon equals and now it's going to be a vector whose components are x of t, y of t, and z of t, all right. So this might just be the coordinates of a particle in three-dimensional Cartesian space and now if I want to evaluate the velocity, I take the derivative. So I just say d of r of t with respect to t. And what I get out is an indication that I used r before so I think I need to clear r here and so now I get a clean result. And there's nothing profound here except just to show you that Mathematica knows to just take the derivative of each of the components and I get back a vector that would correspond to the velocity if r was the position of a particle, all right. So that was the first of the vector derivatives that we did. And now the rest of them we can only get to if we load in a package. Okay, and that package is called vector analysis. So just to remind you to load in a package we can say less than less than, give the name, vector analysis. And then we put in the left single quote and we enter. And if you want to see what's in there, say names, double quote, vector analysis. Left single quote, star double quote and you'll get a list of all the goodies that are in the vector analysis package, a lot of which probably don't sound particularly familiar to you, all right. But some of them are. So for example you can see there's Laplacian is in there. All right, now when you're working with the vector analysis package you have choices of different types of coordinate systems, okay. So today we're going to work in Cartesian coordinates, but next time we meet I'm going to show you how to change the coordinates. For example, to spherical polar coordinates which are ones that those of you who are in Chem 131 have seen. It's useful to be able to switch coordinate systems sometimes to make problems more convenient to solve, okay. But when you do work with the vector analysis package it helps if you define the coordinates yourself so that you know what you're referring to, all right. And so what I'm going to do now is I'm going to define what I'm going to call the Cartesian coordinate system, okay. And the way I'm going to do that is I'm going to use one of the commands from this package. It's called set coordinates. So I say, oops, set coordinates, all right, bracket. And then Cartesian, so Mathematica knows what Cartesian coordinates are. And then I'm going to define what the Cartesian coordinates are. And I'm going to use lowercase x, y, and z for those. So all this command is doing is just saying when I work in Cartesian coordinates x means x, y means y, and z means z, okay. Because otherwise that's not the default by the way. I think the default is big x little x, big y, little y, and big z, little z. I'm not sure about that. But in any case I want to use that. Okay, so we can enter that and it just tells us, okay. Understood. All right, now let's go ahead and get the gradient, all right. And I'm going to do this symbolically for an arbitrary function f of x, y, and z. Okay, so if I want the gradient, I say grad, bracket, and then I put in what I want the gradient of. Okay, so I'm going to say f of x, y, and z, all right. We haven't specified a function here, so we're going to get a generic symbolic result. If you actually had a function in there, you would be able to get its gradient evaluated. All right, so here it is. And you look at that and you might think, wow, that doesn't look like what you wrote down on the board. So this requires a little bit of explanation for what's the interpretation here. Okay, so first of all, as advertised, it does return a vector. Okay, so f of x, y, and z is an arbitrary scalar function. I get back a vector, right? There's three components here. What does this mean? Well, this is sort of a general prime kind of notation for a multi-dimensional function, all right. And the way you interpret it is that what this means is that it's the first derivative with respect to the first component, which is x in our case, of f, okay? And then similarly, 0, 1, 0 means the first derivative with respect to the second component, which is y, and then the first derivative with respect to z. Does that notation make sense? Okay, all right. So next thing we can do is we can construct the Laplacian of the same generic function, okay? And this time, I should get back a scalar. And you see that in fact I do, right? It's not a list of components. It's just a single object. Now, it's written in a funny order. This says the second derivative with respect to the third component, z of the function f plus the second derivative with respect to the second component, y, plus the first derivative. So it wrote it in a strange order, but it is in fact what we wrote down on the board, okay? So that's the Laplacian. All right. Next thing we're going to do is we're going to define a vector field, a generic vector field. Okay? So I'm going to define now f is equal to, so it's going to be a vector. So it's going to be fx of x, y, and z, fy of x, y, and z, and fz of x and y and z. Okay? So this is the mathematical version of what I wrote on the board, defining a vector field, which is a function that at the point x, y, and z is actually a vector, as opposed to a scalar. All right? Now, we have the vector field, so we can see what's the result of applying the divergence and the curl. All right? So to get the divergence, we say div, okay? And what we get out is, as advertised, a scalar, right, just a single number, where aside from the fact that it's been written in reverse order, it corresponds with what's on the board, right? So we have the first derivative of the x component of this vector field here, and then the first derivative with respect to y of the y component of the vector field plus the first derivative with respect to z of the z component of the vector field. All right? So that's the divergence. And then, finally, there is the curl, which is curl, and it operates on the vector field. And you see what we get is now a vector. This is the first component, second component, and third component. And if you evaluated that determinant over there, you would see that, in fact, this is consistent. All right? So it's the minus the first derivative of the y component with respect to z plus the first derivative of the z component with respect to y, etc., etc. Okay? So that's your brief introduction to accessing these vector derivatives in the vector analysis package using Mathematica. Does anyone have any questions on that? Like I say, this is for, this is a FYI primarily, just to let you know it's there, because you have this very powerful suite of vector analysis tools. We'll do some examples next time where you get to see a little more of what's in there, but I'm not going to ask you to do problems explicitly on this. Okay? All right. So we have a little time left today. So the next thing we're going to do is we will start a discussion of matrices. So we've already had an introduction to matrices in Mathematica, and we used them to store data. Right? So now we're going to see how to actually do algebra with matrices. All right? And this comes up a lot in physical chemistry, so hopefully it will be useful for you to see how to do these things in Mathematica, and I'm pretty sure that they're going to assign you problems in physical chemistry that are similar to the examples that we're going to do next time. Okay. So who wants to remind me what is a matrix? Just any old set of numbers? It's an array of numbers, right? A square or a rectangular array of numbers. All right? So let's go ahead and define one. Equals. And remember the way we hold matrices in Mathematica is it's a list of lists, okay? It's a list of rows, basically. So if I type in 1, 2, 3, that's a matrix whose first row is 1, 2, 3, has three elements in it, and then I can type in for the second row, 4, 5, 6, all right? And so I can put a semicolon, and then I just say, give me A, and I'll write it using this post-fix in matrix form, okay? So now it looks like a real mathematical matrix. Now, just a little bit of lingo that we might have touched upon before, but we're going to use this lingo a lot. So this matrix has two rows, so the rows go this way, and three columns, okay? And it's a rectangular matrix because the number of rows is not the same as the number of columns, all right? Now what I want to do is I'm going to define, well, let's do a little bit of arithmetic here. So what do I get if I multiply a matrix by a scalar? So let's have a look at that. So for example, I take 2 times A. Well, we've already seen earlier, let's go ahead and put that in matrix form, all right? So we get another matrix whose elements are just 2 times the elements of the original matrix. So multiplication by a scalar just scales all the elements by that scalar, all right? Now I want to talk about matrix addition, okay? So for this, and for some examples that will follow, I'm going to define two generic 3 by 3 matrices, okay? So I'm going to redefine A. So it's going to have, the first row is A11, A12, A13. Second row is going to be A21, A22, and A23. And the third row is going to be A31, A32, and A33, okay? So let's have a look at that A slash slash matrix form. All right, so this is a quite common notation for labeling the elements of a general matrix, okay? So typically the way it works, these would be subscripts in a textbook where the row is the first number and the column is the second. So this is first row, first column, first row, second column, first row, third column, et cetera, et cetera, okay? And when you have a square matrix, the elements along here, these are what's called, this is the diagonal elements, okay? Where I and J are equal. All right, now let's define another generic 3 by 3 matrix. We'll call it B, whoops, B equals. So this will be B11, B12, B13, and then B21, B22, and B23, and B31, B32, and B33, all right? And we can look at that in matrix form. All right, now I have two matrices that have the same dimensions, okay? Three rows, three columns, all right? So these are what we call 3 by 3 matrices. Now when you have matrices with the same dimensions, then you can do arithmetic operations with them, such as I can add them together, all right? So if I add A plus B, let's put that in matrix form, I get another 3 by 3 matrix where its elements are just the sum of the corresponding elements in the two matrices that I added, all right? So you see that matrix addition is very straightforward. Just take this element, add it to this element, and put it here, et cetera, et cetera, all right? Same thing for subtraction. So I could say A minus 2 times B, all right? So you see we take A11 and then subtract 2 times B11 and then et cetera, et cetera, okay? So addition is pretty straightforward. Now what about multiplication? Matrix multiplication. Multiply one matrix by the other. I think for this it will be helpful to go to the board just to show you this once, and then you'll see that it's easy to do in Mathematica, okay? So matrix multiplication is referred to as row by column multiplication. So I'm going to do this just for two 2 by 2s. I'm going to define this matrix, and then I'm going to multiply it by another 2 by 2, okay? Now the way this works is the 1, 1 element of the product is going to be, I take the first row of A and multiply it by the first column of B, okay? So that's going to be A11 times B11, and then plus A12 times B21, okay? And then the 1, 2 element will be first row of A times the second column of B. So that's going to be A11 B12 plus A12 B22. And I want you to notice something here. Notice if I look at the outer two numbers here, 1, 1, 1, 1, 2, 1, 2. Notice this is the 1, 1 element and this is the 1, 2 element, all right? All right, and then for the 2, 1, I take the second row of A, first column of B, A21 B11 plus A22 B21. Notice 2, 1, 2, 1 for the 2, 1 element. And then finally, take A21 times B12 plus A22 times B22. So notice 2, 2, 2, 2 for the 2, 2, 2 element. All right, so in general, you could write that this would be the sum over some middle index, which I'll call K, of Aik times Bkj, gives me the element of the product, which I can call this the product C, the ijth element of the product. So that's a compact way of writing it. And the sum goes over the number of elements. So in this case, it would be 1 to 2, all right? So that's matrix multiplication. So let's do that now in Mathematica. All right, so the way you do the matrix multiplication in Mathematica is you use the dot. So I can say, give me A dot B and then I'll go ahead and put that in matrix form, okay? Now, it goes off the screen, but I think if you stare at that for a second, you'll see that it is, in fact, it corresponds with that sum formula that I wrote over there, okay? It's the 3 by 3 version of what we just did by hand. Now, one thing that I want you to notice is that, let's look at the B dot A. Are they the same? In general, they're not. And you can see that already in the 1, 1 element, right? Okay, so this part's the same. But then when you get here, notice this is 1, 2. This is 2, 1. This is 2, 1. This is 1, 2. So this will only be the same if A1, 2 is equal to A2, 1 and B2, 1 is equal to B1, 2. And that's in general not the case. It's only the case for a class of matrices that are called symmetric matrices. Okay, so in general, matrix multiplication is not commutative, all right? Okay. Now, just a couple of more little things. All right, so what else can we do? Well, we can multiply a matrix times a vector. Let me show you how to do that, all right? So suppose I take now, let's get rid of this and just call. So if I have the case like here, 2 by 2, and this would be this two-dimensional vector, which I specify by two components, B1, 1 and B2, 1. This is a 2 by 1, okay? So if the number of columns in a matrix is equal to the number of rows in a vector, then I can multiply them together. And what I'll get out is something that has dimensions of 2 by 1, okay? And the way that works is I take this row and multiply it by this column and then this row by this column. So it's similar to the matrix multiplication. So that'll be a 1, 1, B1, 1 plus a 1, 2, B2, 1, and then a 2, 1, B1, 1 plus a 2, 2, B2, 1. All right, so once again we see 1, 1, 1, 2, 1, 2, 1. So we can do that also. All right, so we'll say R, well, let's clear R. I think we were using that earlier. And then we'll define R equals a vector, X, Y, and Z. And then we'll multiply A times R and put it in matrix form. All right, so there you have it. We took a 3 by 3 matrix, multiplied it by a 3 by 1 vector, and we got out a 3 by 1 vector. All right, what else? So there's a couple of other manipulations that are worth knowing about or ways to work with the matrices. So one of those is you can create what's called an identity matrix. So let's have a look at what's the identity matrix. All right, so what you do is you say, I want an identity matrix, and then you say how many dimensions you want. Okay, so I'll say 4, and now I'll put it in matrix form. So let's have a look at that. So notice what that gives me. It gives me a square 4 by 4 matrix because I put in 4 where all the diagonal elements are 1. So that's a 4-dimensional identity matrix. All right, and we'll see that it's useful to have such an object next time. Another thing I can do is I can quickly specify without typing a bunch of stuff in. I can specify a diagonal matrix, which is also kind of useful to be able to do. And what you do there is you say diagonal matrix, and then you just give a list of the elements that you want along the diagonal. So I might want to say, for example, D11, D22, D33, D44. And what this gives me, and let's put that in matrix form, what that gives me now is a 4-dimensional because I gave 4 diagonal elements matrix where the diagonal elements are in order what I put in. Okay? All right. Now, there's one other thing that I want to tell you about, actually, yeah, I guess we'll just do one other thing today, and that is the determinant, all right? So we already saw the determinant when we were talking about the cross product. The determinant, if you like, is a measure of the, it's kind of like a magnitude-type quantity of a matrix. All right, so way up here we define this 3 by 3 matrix A. We can take the determinant of A by saying debt A, all right? And the determinant is a single number, all right? And since you know how to calculate a determinant if you want, you can verify that formula. But notice that it's just a single number. Okay? All right, actually there's one more thing I want to tell you about, okay? Now, the last thing for today is the inverse, all right? And so if I have a matrix A and I often indicate matrices with a double squiggle, it's determinant, I mean, it's inverse is defined as follows, okay? Inverse is indicated by minus 1 and it's defined as the matrix by which I multiply A in order to get the identity matrix of the same dimension, okay? So if these are 3 by 3s, this is a 3 by 3 where with 1s along the diagonal, okay? And it's also the case that I can write this, okay? Now, if you want, you're welcome to look in the notes where I actually tell you how to do that by hand using Mathematica commands. But has anybody ever done the inverse matrix by hand? Yeah, is it tedious? It's tedious. So you will be happy to see that in Mathematica, you can do it easily by just saying inverse, all right? And you can see it's pretty messy. Actually, let's put that in matrix form, all right? So you can see it goes on and on and on and on. And that's just a 3 by 3, all right? So that's kind of a pain but, you know, some of you know how to do that by hand. Now let's just for the very last thing today, we'll just confirm that that is, in fact, the inverse of A. And the way we can do that is I'll just go ahead and define A, I, and V equals inverse of A, all right? Semi-colon. And then I'm going to multiply A times A, I, and V and put that in matrix form. And what should I get? I should get the three-dimensional identity matrix. But I didn't. I got a big hairball. Well, it turns out that Mathematica will be lazy sometimes doing algebra, okay? And we can force Mathematica to do algebra by saying full simplify. And when we do that, we find out that, in fact, it is equal to the identity matrix. And finally, let's just verify the last point which is we'll take A, I, and V and multiply it with A. And we should get the same result and we do. Okay. So that is going to conclude our brief introduction to some matrix manipulations. Next time, we'll talk about the eigenvalue problem, matrix eigenvalue problem. And then we'll do some cool examples from chemistry. All right? So that concludes today. I wish you all a very happy holiday. And I look forward to see you on Monday.