[MUSIC] In this set of videos, I would like to talk about solving ordinary differential equations. This base arises naturally in virtually all branches of science and engineering. Basically, whenever you have process which somehow evolves in time, it's very likely that it's described by some form of a differential equation. What sort of processes, lots of them, it can be a car which drives along a road, a planet which orbits a star. A chemical reaction where concentrations of different components evolve in time, essentially anything. Somehow, this language of differential equations is very well-suited for describing things which happen in nature. All right, so let's set up a simplest possible problem. Suppose that we want to find a real function, a single valid function of a real argument t. I'll call t time, even though it doesn't have to be, specifically, real time, it can be anything. So suppose this function satisfies an equation which involves its derivative, here, dot represents a derivative with respect to t, and the value of the function itself. And here, f is some known function, which I suppose to be nice and smooth enough so that the solution of this sort of equation exists and is unique. In fact, for the solution to be unique, I need to set up an initial value, initial condition, so that's why it's called an initial value problem. So let's call this value at time equals 0 u0. Here, I only consider a single first-order equation, but that doesn't limit generality. Because the higher-order equations can be fairly easily converted to systems of first-order equation. For example, if we have something which involves the second derivative, we just define an auxiliary variable, let's call it w, for the first derivative. And identically rewrite the initial second-order equation as a system of two first-order equations. So it's enough to consider first-order equations, and for simplicity, I will only consider a single equation. Because the results can be easily generalized from a single equation to a system, so I will consider only one equation. So how do we solve these things numerically, the basic construction is discretization. First, I want to define a mesh, or a grid on my interval, from 0 to t to capital T. Just consider a collection of discrete values, call them t1, t2, etc., up to t N- 1, so that's N + 1 of them. And I want to define a mesh function, that's u, which only takes discrete values, which are somehow supposed to represent the values of my function, u at these times t at this mesh. So I apologize for the typo on this slide, this x should be u. So this mesh function y is supposed to represent the values of my ground truth unknown function u at times t and t N. So, graphically it would be, if this is my function u, I have a mesh, this is t0, t1 and so on. And I have a set of discrete values, these will be u0, u1, and so on. Right, so this is this mesh function, and it's supposed to somehow represent the value of u. And I want to construct a sort of algebraic equation for this mesh function, how do I construct those? Well, simple idea is to simply place my ODE, my ordinary differential equation, onto the grid, and use the finite difference approximation for the derivative. So I will replace u dot with this finite difference of y's evaluated at the mesh. And for simplicity, I will use the uniform mesh, where the step size is constant. Again, that's not a limitation, this can be easily relaxed. All right, so we approximate the derivative by finite differences. And for the right-hand side, we simply evaluate my right-hand side of the original equation on the grid. We use, this y_n here, as in the second argument of f. So we have this recurrence relation which involves this value of y at successive points on the grid, how do we solve it? Well, we need an initial condition, for which we use the initial condition from the original ODE. And then we just carry on, computing the current value of y based on the previous value, and the value of the right-hand side computed at that previous value. And this is known as the explicit Euler scheme, and the word explicit relates to the fact that I just directly compute the current value based on the previous ones. Clearly, that's not the only way of discretizing the original equation. In principle, instead of using the previous value of y, I can use the current one, and this will be known as an implicit Euler scheme. It's a little more complicated to work with, because on each step, I will have to solve a generally nonlinear algebraic equation for y_n. But at least I can write it, there is nothing which stops me from writing that sort of scheme. And if I'm feeling ambitious, I can actually use both current and the previous value of y, the right hand side, and take the sum of the right-hand sides. So clearly, I can write a variety of different schemes. So which one should I chose, or what are the criteria for choosing one or some other? That's coming up in the next video. [MUSIC]