So at the end of the previous lecture, I told you that we are now able to solve basically every first
order ordinary differential equation.
However, physical systems are not only described by a first order differential equations.
There are also higher order equations and especially second order differential equations play an important
role.
So here we have a second order derivative of why, with respect to T is given by some function that
depends on T y and the First Order derivative.
So this means overall we have t y first derivative and the second derivative of Y was respect to T.
So a very simple example for such a differential equation where we have a second order derivative.
And here we have none of these dependencies, but only a constant is actually the free form that we
are going to solve in the next lecture because there we will just have that.
The force is basically given by the acceleration and the mass.
And when we leave out the mass of, say, the mass is equal to one, then we have this differential
equation and the force becomes then or the acceleration then becomes the second order derivative of
the position with respect to time.
So the problem is that we cannot solve this equation with our Euler method because it's second order
equation.
However, there is a nice trick that we can use.
We can basically produce the order of the differential equation by setting up such a system of equations.
So we will transform a second order differential equation into two first order different differential
equations.
And this idea holds also in general.
For example, if we have a fourth order differential equation, then we can use a system of four different
equations, which are all a first order and which can all be solved with our Euler methods.
So the idea is as follows for the derivation and in an intermediate process, we will define new functions
the Z1 Z zero and then if we have higher order equations, then we would also have C two or three and
so on.
And they are just given by the function and by the first derivative, by the second, third, fourth
and so on.
And for the time being, we will consider these functions to be independent of each other, which they
are.
Of course not, because if you know the first derivative, then you can easily calculate the second
derivative.
But this is here the trick how we can change the order of differential equations because now we can
ask ourselves, OK, we know what z zero is, we know what Z one is.
Then of course, we also know what the first derivative of C zero is and what's the first derivative
of Z one?
Because the first derivative of Z zero is equal to the first derivative of Y of Ti.
And this derivative y of T is equal to z one.
So our first equation becomes the zero derivative is equal to one.
And for the other equation, if we derive this equation on both sides and we have z, one derivative
is equal to the second derivative of Y with respect to T.
And what's the second derivative of Y with respect to T?
It's the function F.
So this will be our second equation.
And now what we are going to do next is we will use a trick that we used already earlier when I introduce
to you the Euler methods.
So this was this one here, I wrote down.
Since a function, the derivative can be expressed by this difference in the Y values divided by the
small value h.
We can solve this for the Y at the time T plus h, and it will be given by this expression.
This is what we have programmed before.
And then we have also translated this in terms of iteration.
So in terms of indices where we had y with the index and plus one is given by the function f times h
plus y at the step and and this is pretty similar to what we see now here.
So I mean, to lead this line, let's go here.
So we know now that the next value of C zero is given by the old value, plus the change, which is
then z one since the derivative is equal to Z one times the step size h.
And similarly, for Z one, we have that the next value with the higher index of C one is equal to the
old value, plus the change which is given to or given by f and timestamp size.
And now, since we have this relation for the C function c0 and C1, we we can just transform back to
why and the first derivative of why.
So we know now from this equation, from this one that the new value of Y will be equal to the old value
plus h times the derivative.
And we know that the next value for the derivative will be the old value for the derivative plus f and
times the step size.
And that's all that we have to program now.
So since we will program this in a very similar manner, as for our first order solution, let me scroll
up and let me copy the code this one here where we have to find Euler only.
So I will copy and paste it here, and I will call this function only two for second order.
So since it's now a second order differential equation and we have two of these equations here, we
do not only need a starting value for Y, but we also need a starting value for the first derivative
of Y.
So I would call these values y zero zero and y one zero zero zero of its starting value of Y and y one
zero will be starting
value of y of T.
OK, so we have to find these functions and what is the starting values?
And now we will, of course, have to change this one here a bit.
So we will have to introduce not only why, but also why one and we have to, first of all, said both
of these equal to the starting values.
And now we have to change here.
This one, for example, would make a list for the y 0s, which means the actual values and the Y ones
for the first derivatives of Y.
And then also, we have to change this, of course, here and we will have to make another line of code
with the Y ones and then we have to be careful what comes here and what comes here.
Well, here comes the first derivative of Y.
So this would be y one.
And here comes the value of F.
So this will be f of T.
And then we have no two arguments, which will be y zero.
And we want corresponding to this y and the first duart of Y.
And now only we have to change.
Also here list of Y to y zero zero and y one by one.
And of course, also for the output.
Here we write y zero values and y for values.
And if I didn't make a mistake in typing this, then it should work and thus we will find out in the
next lecture.