So we've just learned that four large time starting values are a numerical solution will be different
to the analytical solution, which is just due to the fact that the analytical solution was only true
for an approximation.
And so in the following, we will not consider it anymore.
We will only trust our numerical results.
So now we really have a tool that helps us to understand the harmonic oscillator and the pendulum.
So let's go ahead and make the problem even more difficult by adding more terms.
So we have defined already our differential equation here so that we copy this, maybe all of this and
paste it here and now.
This time I will consider a damping, and the damping is the zero point five.
And what else will I consider?
I will stick to the larger starting value, but I will go back to the a shorter calculation time.
Maybe we can.
We can change this later on.
And though, as I said, we will not compare this to the analytical solutions that we will just use
this one here.
So if I run this and I get the solution for the pendulum and you see what happens, we start from a
large value theta zero of two and then we can now change this also to plot.
And then it oscillates it has still the characteristic time periods.
What do you see?
The amplitude decreases?
This is, of course, due to the damping term that we have now turned on and like in reality, when
you leave a pendulum swinging, then it will just decrease its amplitude over time.
It's not.
What we can also do is checking what happens if we decrease the step size.
But I think there wasn't that much of a difference.
So it seems like the solution is already converged and this is the behavior now with the damping term.
Likewise, we can also modulate a driven oscillator.
So this is when we change the differential equation once more, so we can do this by adding here another
term.
So we're right on minus these times and peer sine of omega tones T and D will be essentially the amplitude
of the gravity of the external force that we have just added.
So let's just test 1.0.
I don't know if it's good.
And also, we have to define Omega, which is the frequency of the external force.
So what we have done is we have added here a term to the to this differential equation where the right
side of the differential equation has a linear term and theta, which is the damping.
It has a linear or sine theentire term, which is the gravitational force, and then it has a term which
doesn't depend on theta at all.
It is a term that only depends on the time explicit explicitly.
So this is now a sign omega t term, which corresponds to when you, for example, apply some kind of
motor to your or some, some some some engine that moves the pendulum while you leave it swinging.
And so it's really interesting to analyze what happens when this swinging frequency omega is different
compared to the eigen frequency of the pendulum.
So let me just show you one more thing.
Let me go back to the theory part where we have introduced our second order differential equation here.
We have written down that the second order differential equation in general is characterized by a second
or the derivative that is given by a function that depends on first derivative, the function itself.
And then also T.
And now we really have all three of these terms in our differential equation.
So this is like the most general case that we can solve with our new method.
So let's see how it works.
Um, let me think about the parameters.
Maybe at first, let me go back here a bit.
And let's solve this.
So you see the EU, yeah, the time depends of SETA is no very confusing.
In the very beginning, it looks maybe a bit similar to the UN driven and just -- oscillator.
But then since we have this new fourth term here, it will not decay to zero, but it will still be
oscillating.
And it also seems like there is no clear trend after 20 seconds.
So let's go to a larger time.
Let's increase the step size, for example, and then we see that this solution looks like this.
We could also just increase this one here and then it will look like this, and we can even play a bit
with the parameters.
For example, we could change the sign of the the amplitude.
Then it will look more like this, or if we increase the step size again, we get such a result.
But since in the following, I want to compare this result with this two step Euler method with more
of the optimized methods.
I want to have a more difficult time dependence of data and more change in this curve.
So what I will do, I will I will decrease the damping parameter.
So let me try this so that we have less damping and then hopefully we get more difficult looking time
dependence.
Yeah, I think this is pretty good.
We have now some strange oscillations in the beginning.
This is because the oscillator the pendulum doesn't lose enough energy in the beginning because of damping
is now much smaller and the external force is quite large and it really is in conflict.
It's fighting with the oscillation of the pendulum itself, so it tries to get the pendulum out of its
eigen frequency and eigen pendulum motion, and it tries to dictate the external force with the period
omega onto the pendulum.
And this really takes about one minute until the process is finished and hear the motion looks very
chaotic.
And then after this time, it finally moves in the periodic manner, according to this omega T sine
function.