So we have seen that it's pretty easy to use the command solve underscore IVP to solve differential
equations.
So in this case, we didn't have to define any function ourself.
We did not have to define the Arla function.
And we could even choose a method AKI 45, which seems to be superior compared to the Euler methods.
And in fact, it really is much better because you need fewer points.
The point size will rtd you judge to step with step size will be chosen accordingly, and it adapts
to the change of the function to get you always the good result, with only a few points for the calculation.
So it's really the best of both worlds.
And what we haven't done yet is looking at higher order differential equations.
So I want to show you here we can also solve second order differential equations like the free fold.
So I copy this and let's change it to our needs.
So what we need is we need to go to zero from zero to 10, and we need to provide the starting values
for why zero and zero.
So all rides, why zero is 10.
I think this is what we chose previously and V0 is 50 and now we only need to provide the function.
And for this, I will scroll up to our example where we have considered the free fall because I want
to show you the very important difference.
So of course, I could have just written the function myself, but I want to show you really what's
important to make sure that you changed this.
So I copy this from our previous example and go back down to our where we just left.
Um, so let me paste it here.
So the thing is, our function can be called f only e.
This is good.
And previously we had provided two arguments why zero and why?
One?
Because this is how we have programmed our Euler methods.
We had two separate variables y zero and y one.
And our output was only the value of the function.
However, in order to fulfill the syntax of solve IVP, we must provide the arguments in a different
way and we must provide the output in a different way because here y is a list like two starting values.
So this was the starting value.
So like the starting values, also, the arguments themselves are lists.
So it's just a single is called Y, and it will have two elements in this case.
And this we have to make sure that we respect here for the return function.
So we have to write the minus g.
This is good.
But then we have to also provide the other variable and this will just be the velocity.
And this is actually pretty similar to our trick that we have used before.
Let me briefly scroll up to the theory part.
So in your notebook, you can stay where you are.
Um, let me just go here.
But we have introduced a new variable.
For example, Z one is equal to the first derivative of Y.
And this is exactly what we are going to provide here.
The one variable will be the first derivative of Z.
One is equal to the function, which in our case is minus G.
And then the other variable will just be equal for the derivative will just be equal to see one.
This is what we right here see one or in this nomenclature that is used here, it's just y one.
So to be honest, it's not 100 percent necessary that you understand really all the details that go
on here.
Just remember that when you try to use T solve IVP methods to solve a second order differential equation,
you must provide a function that has to return arguments.
And so this one would be the actual function.
And then you just write y off one.
And if it's higher order function, then you use more terms and you write before you're y to y three
and so on and so on.
So I think now we have a good solution here and we can now go ahead and plot this.
So I will use the same command as before, but without an analytical solution.
This time I will just right here y.
And now, of course, I have to provide which of the two ys, I want to have zero or one.
And I want to have to coordinate, so I want to have zero.
So this is this.
Solution, and to be honest, it looks pretty confusing, so let's check if it is OK and we will do
this by copying the analytical solution from before, so I would just go up here.
Here it is.
Copy this.
Go back down and copy it here.
And let's see if it's correct.
Yes.
It seems to be correct, but for some reason we went way out of range here, so let's just go to 10
and then in steps of zero point one.
Yeah, exactly like this.
So you see, in fact, the solution from during a quota once again got it correct.
But a lot of points are missing here, which is not not not a problem at all.
If you just want to have the ending value here, but if you want to have to hold your victory, then
of course, it's pretty bad that there are no points here.
But still, overall pretty remarkable that this method is able to solve this problem by only using five
points for the propagation.
So what you can do to at this point is just to right, as we did before this one here to evaluate.
And then just make sure to get here to correct ranges.
So we want to go to 10 and and Max was one on one.
So you see, now we have a smooth curve and we have all the points that we wanted to have.