Welcome back.
And now we will continue our comparison of the results given by Oyler methods compared to the new commands
IVP that is provided by Python or more precisely by Typekit.
So here we will go now to the pendulum and we will consider straight away the most difficult case of
the pendulum for the last one that we had considered previously, which was this jammed and driven pendulum
which gave us this results.
And you can see I just copy the code from this cell and pasted it at the back or at the bottom of our
notebook.
We're on it.
And here we get this result for theta over tea.
Now, for the new result, we of course, have to once again consider this syntax very similar to this
one.
So let me copy this.
These two cells, this one as well.
And let's change them according to our needs.
So our differential equation will be pretty similar to this one.
So we could just copy this here.
But of course, we have to make sure that we make this one correct.
So I write to Peter and then I write C to see the one like because it there's no list with two elements
and this one will be the zero element of SEATO.
And this one we can leave as it is.
And then like previously for the free fall, we have to provide also the other components.
So I write.
Peter, one, come.
So this is really exactly the same way we changed the ordinary differential equation for the fall.
But now we have just adapted to the other differential equation of the pendulum.
So really nothing new here.
Then we need to starting values to zero zero, which was two and three to zero one zero, which was
zero.
And now we just have to change you to values to fit them to our previous calculations.
So if it's zero zero and ft one zero and.
You know what?
What should we use here, maybe?
I think we did it like this.
Let's compare.
Yeah, we are 200 times steps at a total time of 100.
So that's exactly what we have now here.
And I think this should work already.
Now we can just go ahead and change this one to theto and run it.
So it looks pretty confusing at first, but we can just wait here not to connect the dots.
And you see, now it looks much better.
And I will write here that this is supposed to be read and I want to compare it to the previous solution,
which was this one.
So we can just copy this because these solution variables are still, you know, haven't been deleted,
they're still valid, so we can still use them, of course.
And so we can compare the different results.
And so the new results are indirect ones.
The old ones are the blue ones.
And you see in general, it looks pretty similar, but in details they will differ a bit.
And so we have discussed this earlier during a quarter, 45 methods can be pretty much different compared
to the old methods, not only in terms of efficiency, where it is much more efficient and much faster,
but also in terms of accuracy.
And you see this here, for example.
And now for the remaining part, I just want to show you that we can compare different methods and I
just want to show you that they differ a tiny bit and just want to introduce to you to different methods.
So here's what I found on this website where the sniper module integrates thoughts of undescribed is
explained.
There it is written.
That's the optional argument.
Methods can have the following values we have used so far our K five, but there are also other methods
and we will explore them now in the following.
So the good thing is, you're really that we can just use the same syntax as before by writing solution
underscore R.K. 45 and then the integrates of IVP with all the arguments and then the methods.
And the only thing that we have to change now is this one and this one, and we will go through all
these methods.
So I've prepared this already.
So let me just copy this so that we don't lose too much time.
If you want, you can type along and basically just have to copy this five times enough to change these
names and these names.
So it isn't that much of an effort.
And then we can go ahead and there's a problem here.
Oh, this is because I didn't define the Tara.
Tara is basically this one.
So I write to pray like this.
Yeah, now it works.
And now we want to plotz and for the plots.
I will.
Yeah.
How should we do it?
I would say we will compare all these solutions in comparison to the R.K. 45 methods.
So for example, for this solution here of our old methods, I would write solution and then or maybe
let me do it like this.
Sorry, I used the archive 45, and then I will just subtract here the solution
from our old method.
And then you see, this is the difference between the two curves.
I'm not quite sure if this is correct now, but it should be.
Yeah.
So it looks a bit maybe exaggerated at first, but it is really a large, large difference at points.
This is because here, for example, it looks as the difference is pretty small because it only appears
to be shifted.
But for example, this value here corresponds to some value here, for example.
So the difference is really larger than two.
So it's really a gigantic difference.
And now, of course, we can continue and compare this also to the other functions.
And this I have prepared as well.
So basically using the same syntax, we used a solution of the R.K. 45 and subtracted solutions of all
the other methods here.
Going run this.
We get a curve like this where you can see basically only the black curve has a very large differences,
and then the others have pretty small differences.
For example, the blue one seems to have only know of almost no difference.
So this is OK.
23.
So it means that our whole our method that we have programmed ourselves to are the method seems to be
the first method of all because it is the only one that really is different to all the other methods.
So, yeah, bad news.
Our our own method is the worst, unfortunately, but this was pretty clear and was expected because
it's also the most simple one.
So in the following, I will just copy these all of these actually, and I will just change the plot
range a bit.
So Peel T Dot X.
And we could go from zero to 22 of this range here.
And then for the Y range we go from, yeah, we have to zoom in here a bit, maybe minus zero point
one to zero point one.
And also, we know that the black curve is gigantic.
So let's just look plotted here.
Yeah, so that's it.
So now we can pretty much see how the different methods compare to each other.
So overall, I can't really see what's the correct method to use, and probably the correct solution
is even difference to these that are suggested here.
But the point is that all of these methods are pretty close to each other.
And the only difference you see is that the R.K. 23 is pretty close to the arcade.
Forty five, it's has the slowest deviation.
So that's of course, because they are they belong to the same family of methods.
So of course, the results will be pretty similar than we have here.
The green and the red one, which art is the top eight, five, three and around all methods, and they
are pretty similar.
And then we have the purple and the yellow one or orange, which are the PDAF and also the which are
themselves pretty similar, but they have the largest deviation from the R.K. methods.
So as I said, it doesn't mean that one of these methods is wrong and the other one is correct.
It just means that you see that overall, they give pretty similar results and we can check this, by
the way, by just.
Plotting this one more time and just plotting here like this so that we don't show difference, but
the actual value and you will see that they are very much the same.
So you see there is almost no difference that can be can be seen here.
Especially important is, of course, the ending.
So we could zoom in here a bit more at the ending parts of 90 to 100 and in the range of the law.
Like this?
Maybe.
And still, you cannot really see that much of a difference.
So overall, it doesn't matter so much which of the methods you use.
But if you want to have the correct result, you should probably use one of these methods that belonged
to the of IBP module, and you should probably not use to oil the method that we have programmed ourselves.
Still, I think it was revolting and useful that we have programmed the oil method ourself because only
in this way we know how to solve such problems and how to program such algorithms and to really understand
what's happening in the background.
And also, we have seen to some extent, especially for the analytical examples like in the beginning
here, for example, this one was at a time of amplified decay.
We could really restore the analytical solution, and the old method wasn't so bad, after all.