 Now that we know a little bit more about vectors and how to represent them and their reference frames in Python Let's look at vector-valued functions because that is what we are after First thing I do you see the first cell there is just heading one So it's just going to print out to the screen and then my second little cell importing the required Python libraries Let's do that. Let's see what I'm importing from some pie. I'm going to import the following Functions sine cosine tangent exponent. That's e to the power whatever the square root in it underscore printing Remember, that's pretty printing the Lartec printing so that on the screen. It looks like beautiful handwritten math I'm going to import the symbols function and this new one. I think we've seen it before eq equation Then from some pie dot physics dot vector again lazily. I'm going to import everything that star means everything Now from ipython dot core dot display We're going to import filter warnings from underscore underscore future underscore underscore import print function So this is version 3.4 of ipython of Python But in case someone runs this in 2.6 2.7 What whatever 2.x version the print function as is used here will still work And then from matplotlib.pyplot. I just import that as plt That is shorthand so every time I want to reference any of the functions in matplotlib.pyplot I don't have to type out matplotlib.pyplot.whatever I can just do plt and then matplotlib inline Okay, so of all of those let's just execute that to execute it Holding down the shift key and hitting enter or just hitting the play button there And then in it printing open and close parentheses So that will initialize this pretty printing and filter warnings ignore to so that I don't get those ugly pink boxes of text With all sorts of warnings in them if the code is not If there's problems with the code Visualizing a parameterized function How do we do that? Let's start with an equation first of all I'm just going to create these mathematical symbols x y and t so that when I use x y and t Python doesn't see it as computer variables, but as mathematical variables. So if I execute that nothing happens Now remember up here. We imported this eq function. So eq open and close parentheses. It takes two parameters One comma the other so it's a separated by a comma and whatever comes first That is just going to be to the left of the equal sign And it's on the after the commas can be the right of the equal sign and lo and behold it is an equation So I'm just saying y equals x squared. Remember the double star signs the double multiplication signs is They for power in Python as opposed to a carrot that People might be more familiar with if I execute that It says y equals x squared look at that x look at the superscript of the two there It's beautiful latic or pretty printing there as I initialized it up there Okay, now let's introduce a parameter now. We have this function y equals x squared f of x equals x squared But I want to parameterize it By that we actually mean we just going to We're just going to import Let's just fix parameter. I think doesn't that look better In we're going to introduce this parameter extra variable Into our equation and the first thing we're going to do now. I'm just printing this to screen to the screen This is not changing any of the math. I'm making a new equation x equals t And I'm only doing that they're not to execute any kind of code But just to print it to the screen, but if I do that what happens to y? Well, that's quite right y becomes t squared now the parameterization means if I plug in a value of t now, I'm going to get two other values. I'm going to get an x and a y So much so that that y is still going to equal x squared. I hope that makes sense It's got to make some form of intuitive sense. I've introduced this new variable t I've set it equal to x and that means from y equals x squared that means y must be t squared So for every value t I give you now and let's let t represent time so time zero I'll have x equals zero and y equals zero and I can plot that Zero comma zero. I can move t on time one second. I'm not going to get x equals one and y equals one For time equals two. I'm going to get x equals two and y equals four So instead of this line y equals x squared I'm now going to get this movement of a particle just because I've parameterized my function. I've included Inputed a new parameter and I've called the t here now. This is run a little bit of code here I'll explain to you what it is I'm making a new computer variable and I'm calling it time I can't use t because remember t is set up as a computer as a mathematical Variable, but I want to introduce a new computer variable time so it it Makes a little space in memory a Little bucket into which I can put stuff and we call that bucket time and we put the value zero inside of that little space in the computer Memory and this is called a while loop and the way Python does things it makes this indentation So see that colon after that line and if you then hit enter the text will be indented There'll be blank space there That is the way Python knows that this is a loop of code that it must run through and run through until It exits this little loop somehow. So I'm saying while time is less than 10 Well at the moment time is zero it zero is definitely less than 10. So it'll jump through and execute this PLT remember was mathplotlib.pyplot and it's got this function called plot. So I'm just gonna write plt.plot and Now I'm going to do it takes these parameters. It's usually it's plotting a two dimensional Point and the first one is time which is now zero and the second one is going to be time squared So it's t and t squared it takes a third argument comma and then it takes in these Parentheses single or double quotation marks. I should say b o b stands for blue and Zero, it's not zero. It's a lowercase o actually b o That means a circle, so it's going to be a blue circle So I'm going to plot little blue circles if I were to say red Let's say that would be red squares would be RS, but let's keep it blue Round little round circles. So it's going to plot that for me at the moment. It's going to be zero comma zero And it'll plot that on a figure and then time plus equals 0.5 Now that's just shorthand. That's just lazy coding I suppose most most people would do that, but it means time equals time plus one Now you can see what a computer variable is because that is not an algebraic expression I can't say t equals t plus one because if I subtract t from both sides, it'll say zero equals one That doesn't work the way that a computer handles Come a computer variable, and I called the time there, but I could have used Any letter there I could have said p equals p plus one and then I would have had to have p there and p up there and p there Anyway, it says what is time at the moment? It looks at the right-hand side of this equation first this computer equation It says well at the moment is zero I'm going to put one add one to add zero plus one is one and I'm now going to put that value one Into the new bucket. So at the moment now time equals one It's going to loop through and it'll do this conditional Statement first it says is Time less than 10 well one is less than 10. Yes, so it will loop through this again now It's going to make a new plot One comma one squared is one in a blue dot It's going to add another half. Oh, I said one I see I put down there half So it's going to increment by a half. Let's put the half there 0.05 A 0.5 I should say so this is going to increment by a half every time until we get to 10.5 10.5 or 10 actually because I put I could put the Equal sign there less than or equal to but I've done that so until it gets to 9.5 is still but if it gets to 10 It's not going to execute this little loop anymore It's going to jump outside of the loop and outside of the loop. It says plot dot show So that's just plotted the points in memory But now we actually want to plot this to the screen So you say plot dot show open and close parentheses now the semi colon What the semi colon's there for you need and put it if you don't have a semi colon It's going to give you some expression first and then the plot if you just want to skip that expression You can just leave it out. I'll show you the difference So let's have it like that first and low and behold there look at all those nice little dots It drew every time t increased by a half And you can well imagine if I made those little jumps smaller and smaller and smaller It would be the smooth curve But because I've parametrized the function it actually means something is moving in time It's it's gone from just being a two-dimensional curve To a path that something is actually traveling and that is what parameterizing a function does for us Let me just show you if I took that semi colon away and I execute that again Oh, I see in this instance my apologies in this version. It's not going to do that It's not going to write a little line of code there. Okay. We move on Parametrizing a function now So if we think about it the original function can now be written because I've Parametrizing something is something that maps a Value from R1 to R2 now, what does that R1 to R2 mean? Remember what a function is a function is just this machine that that you give input to it does something and it spits out Something if I say y equals x squared if I put in an x value of 2 It goes through the machine and it spits out 4 on the other side But 2 is a single value on a one-dimensional line I can find 2 on a long line of real numbers and what it spits out for if y equals x squared If it spits out for 4 can also be found on that line But if I parameterize a function, I'm going to do something else now I'm going to move from one space. So I'm going to find a Value on the real line We're going to put it into my machine and it's going to map that one value that I put into two other values which is now on a Two-axis coordinate system not just on a line. It's going to be somewhere on a plane So I put one value in and I get two values out. That's what this mapping R1 to R2 means Let's have a look remember for vectors first of all we have to set a reference frame I'm calling my reference frame C because I've imported everything from Sympi.physics.vector. I can just use the reference frame function without Putting anything in front of it. So I can just run that piece of code. It's in memory now We've got a reference frame. I'm going to make this computer variable called RT And I'm going to set to that this a vector value t times C sub x plus t times Plus t squared times C sub y so I'm creating a vector in two space. We've seen that before let's print that to the screen By just typing the computer variable RT and it prints beautifully So what have I done now? I have Parametrized this equation, but I've now turned it into a vector valued function. Have a look at this and This is how we write it. R of t is my new function. Remember we had f of x before We changed it to f of t Now we have this function we call it r of t and That is in one space in other words. I'm going to put one value in there for t if I had f of x equals x squared I'm going to put one value for x in there three or four or five or whatever that I find on the real line But it's going to throw out two values for me Values in two-dimensional space because this is a plane I get an x value and a y value Which I can plot on a plane as we did with this blue Dots up here so usually for vectors we write these Brackets these angled brackets and it's going to be x of t Remember x of t was a function of t. I said x equals t and I have a function y equals t y was t squared That's what I'm doing. So there's my vector. So this is why we call it a vector function because are Usually we use are because it's a position vector from the origin pointing to some point in space and for any time t Let's go back up here. I can imagine from for I can draw a little line from the origin here to every line and Every time t increases that vector is going to point to another one of these dots sequentially sequentially So that vector changes in time and you can see what this vector function is doing down here Every time I put another t value in I'm going to get another x and another y value both of x and y are functions of t So I'm mapping a One-dimensional value and I pop out on the other side a two-dimensional value good So in essence because x was t and y was t squared I have this r of t equals t comma t squared and if I were to plug in an R a Value for t of 2 I'm going to get the value 2 comma 4 so I'm plugging in a single value and I get out two values And that is a vector valued function note that we have this underscore here Just indicating that this is not just are not just a function. It is a vector function So for from parameterizing a simple equation I now have a vector value function and this is how we write it. It's all pretty intuitive