 And in this lecture something very exciting, let's have a look at differential equations. We're going to start with simple ordinary differential equations with constant coefficients and perhaps later we'll look at something more complex. So let's just define, we've got to learn how to define a variable as a function. Now before we used variables and we defined them as symbols but you can also define them as functions and you really are going to need to do that if you want to solve differential equations. Again I'm using the abbreviation SYM there for some pi, so I've got to refer to it SYM.init, underscore printing open and close, so I'm going to use pretty printing. I'm going to have this variable t mapped to this symbol t as we did before but now there's a new thing I am going to have the variable y mapped to this function y, function with a capital F and this is how we use it. I'm going to print to the string the second-order ordinary differential equation and this is how we construct it. I'm going to use an equation, so SYM.equation we did that before, so we're going to have open and close parenthesis for this, open and there's my closing parenthesis. I take two arguments separated by a comma and what is before this comma is the left-hand side of my equation what is to the right of the comma or after the comma is the right-hand side of my equation. On the left-hand side I'm going to have y it's open and close parenthesis t so it's a function y that's my dependent variable of this independent variable t but it's not y of t I want I want the second derivative of it so imagine it's y prime prime of t so I'm going to put dot diff remember how to do just derivatives so dot diff now this is this for printing nothing gets not solving it yeah I just want to print it so you use dot diff and then how many times you want that derivative twice so this would be how to write y prime prime of t and I can use this y open and close t because I've defined y not as a symbol but as a function so it expects these open and close parentheses with the dependent variables listed there so this is a single dependent variable y of t it's the second derivative of it minus the y of t and that's got to equal e to the power t which I have got to invoke sym dot exp of t let's execute that code now it's going to do it in a way that you're not used to writing it but the order doesn't matter that's this is the way that the order is going to be done so it's y prime prime of t minus the y of t equals e to the power t so very simple to do so you've got to declare them as functions so that means they can take dependent variables and then you just have to say dot diff and how many times you want that derivative to respect to what so this is d squared d t squared of the y of t so y prime prime twice of t that's with respect to t so that's why the t comes in there and I wanted twice minus the y of t which is to stay comma and then on the right hand side I have e to the power t to solve this is just as easy so it's sim dot sim dot dissolve now we had solved before when we did the algebra this is differential equation so we're going to use this key with d solve this command d solve and then open close parenthesis yeah I still have this equation just as I had there before so d solve is going to take my equation my differential equation just as I had that there before now it gets a bit confusing and that's why I'm going to do the next example so the d solve takes two arguments in this instance the more that you can add get perhaps get into that in the later videos but I'm only using two arguments for d solve here the first is my differential equation on the left hand side and the right side is I wanted to be solved for this for y of t let me just execute that and show you and I mean be honest that is fantastic so I have y of t equals there's my first constant my second constant if you just multiply these out to this differential equation by hand you'll see that is indeed the answer I just wanted to make things slightly easier to understand I've taken a function here and I've attached it to a variable f that's not a function f I haven't declared it up here as anything so I'm using it purely as a variable and I'm setting that to this equation so it's an equation with my open and close parenthesis it has a comma so whatever comes before the comma is the left hand side of my equation whatever comes on the right is the right hand side it's exactly the same what we had it's the second derivative of y plus two times oh no that's a bit different I had minus y of t plus twice the first derivative plus y of t and just if I just put f there now it's just going to print to the screen this variable f and this variable f it's just attached to this I'm just doing this for clarity's sake so look at this I have y prime prime of t plus two y prime of t plus y of t equals e to the power t and now I just wanted to show you so that I don't have to rewrite that whole equation I'm just referring to that whole differential equation by its variable name and there's the variable I attached it to so it's sym.d solve and I'm just using two arguments here as I say there are more arguments to use but yeah very simply I'm going to have f and I'm going to I want solutions for the y of t so if I do that there is my solution at the press of a button now let's look at something that you can do in your head just to show you this really does work again I'm just going to use this variable g don't get confused this is not a function it's not the g of t or the g of y or the g of x anything that's I'm just using it as a normal variable just so that I can have cleaner code so g equals an equation and it is y of t y remember still a function so it takes an independent variable so y of t the first derivative of that so that's why this says y prime of t comma on the right hand side of my equation because I'm making this an equation I just have t over the y of t so I can't just write here t over y remember y was declared as a function it must have that t in it and I'm just printing my variable g to the screen so there we have it y prime of t equals t over y now you can do this one in your head you can bring y t over to this side and the dt over to that side and the dt over to that side so you're going to have y of t dy or dy actually and on this side you're going to have t dt so you're going to have y dy on this side and t dt on this side if you just solve that and here we go I'm going to say sym.d solve g y of t you know you're going to end up with plus minus the square root of t squared plus the constant and lo and behold and it's really a pretty simple equation you can do in your head and there we have two solutions for y there's the first one there's the sigma negative the square root of a constant plus t squared and positive the square root of a constant plus t so you just have to get used to how to write these equations that you want to get the solutions for so you have to declare that y as a function of some dependent variables and that variable you have to declare as a symbol you don't want it to be a normal variable and whatever's on the left and right hand side of your differential equation and to make it prime prime prime prime prime it just depends how many times you put your with respect to what is after the dot diff so it's very easy to do once the first time you see it it's very confusing what is going on here just tease it out it's very easy to construct these differential equations and just as easy to get the analytical solutions for that if you watch my second series on ordinary differential equations we do numerical calculations you see you can use python to write beautiful little pieces of code that will just do numerical analysis for you for differential equations that you can't do analytically but yeah these can be solved analytically these examples that abuse here and then you have your beautiful solutions really nice