So now we want to compare our three methods Euler, R.K., four and R.K. four or five.
And since so far, we have only implemented this for solving first or the differential equations.
We have to, of course, search for an example of where the differential equation was of First Order
and some of the most difficult one that we have considered.
So, for example, number two, two time amplified decay.
And so I will copy these to cells here and let me make a new one and copy this.
So here.
And also this cell here.
And then copy the whole thing and go to the bottom of the notebook.
So here we have it.
So when I run this, it gives me the solution for our oily methods.
So what we will add next is, of course, we will add new solutions.
And therefore, I would call this solution with the old methods solution.
Then I have to, of course, also update this one here and here.
And now I will calculate all sort of solutions with our other two solvers.
And we have only we modified the general syntax of the Euler function.
So the syntax here is really the same for the OK four in the arc, four or five.
So we can just change the name here, and it should work.
So this one will be our K four solution r k four.
Then we have our K four five.
And like this, and now we can just go ahead, copy this line of code and updates here, the R.K. four
and R.K. four or five.
And of course, also here for the Y component.
And when I run this, we do not see anything really, so it seems as if all three solutions are pretty
much the same and they are on top of each other.
So this is already a good sign because there is no large deviation comparing the three methods.
So now we go ahead and do something that we also did previously.
When we compare the methods that were implemented in the solve, underscore IVP solver of the integrate
module.
We will compare these differences here in the way value.
And so I will go ahead and copy this code here
and I will write T and paragraph off Y and then here I will just subtract the test value, basically.
So what we did previously is we find already here a test value test T and then test Y.
And the only thing that we have to make sure I think this one is not correct because here we are missing
a one because we only always start at two zero and then we go and next steps to h.
So we have in total and mixed +1 values.
And so now we also have here and makes +1 values.
Since I updated this, I have to rerun the South and now I can just write here
basically minus test y.
And then we do this for all three lines.
And now just to compare them, I will add colors.
So you know, they right blue.
Here I write red and green.
And then since you see this line here so thick, I will also change the catapult to just a regular plot
so that the points are connected by lines.
And if you won this, then we see we have a blue line here, which so let me just tell you again what
this shows here.
So this is basically the error of our method compared to the analytical solution.
And you see the blue curve, which is the only method has a very large error compared to the other two
methods.
So in fact, the green and the red one, you cannot even see anything different from zero here.
So what I will do next is I will copy this paste and just comment or delete this line of code so that
we do not show the blue one anymore and just concentrate on red and green.
And you see this one.
Or this time we have a 10 to the power of minus 10 arrows.
So these values have to be multiplied with 10 to the power of minus 10.
So this will be a very, very small value compared to this one, which is just 10 to the power of minus
three.
And you see, the red one has then an arrow, which is the Arc four method and the arc for five is an
even more accurate.
So we have really, really good solutions here and a very high accuracy.
And this is really the take home message of the section we can, of course, implement just are straightforward,
simple solutions like the older methods.
But we always have to keep in mind that this brings about some error and that there are other methods
that are much more accurate.
We have seen that deriving these problem.
The methods is, of course, very difficult.
In fact, we didn't do it because it was too difficult here to time consuming.
But if we just look at Wikipedia or other websites or books, you can find these tables here.
And it didn't take us more than five minutes to implement these tables here.
Of course, it's a bit tedious to write on all of these numbers, but you just have to do it once and
then you have implemented.
These are k four or five methods, and you see the error is really remarkably small.
So here we have two times 10 to the power of minus three for the other method.
We have 10 to the power of minus 10 for the quarter full methods and 400 cutoff for five methods.
I don't even know.
Let's see.
We have, yeah, four times 10 to the power of minus 13.
So really, really small error.
The very high accuracy.
I hope you see now that these methods to when we put our methods are very helpful and very useful.
And of course, one thing that I have to mention, as well as in our following codes, we could of course,
use this module here that we have implemented our K for five, which was a bit time consuming, but
maybe just five to 10 minutes to write on all the coefficients.
But of course, in the following mode we are going to use is we are going to use the solver of integrated
solve, underscore IVP and then rewrite method, for example, R K for five.
And then we have basically the same thing with even an adaptive step size, which is even better.
So just let's get back to this example here, where we have really large step sides, step sizes at
certain ranges.
Where to code releases?
OK, that function doesn't change that much here.
It's OK to make a large step, and the arrow will not be too large.
And so we can save a lot of time because here we only have to calculate a very few points compared to
maybe 500 points if we would have chosen an equidistant list of points for this range here.