So now we can finally start programming in the previous lecture, we have talked about the system and
have figured out the equation of motion.
And I think it's pretty important that we figure it out this matrix here because later on, we will
calculate its eigenvalues and then discuss the meaning of these eigenvalues.
And then you will understand why we can call this also an eigenvalue problem.
But actually, you may say now, why should we do this?
These are just couple differential equations, and we have learned already in the previous lectures
how we can solve these.
And this is, of course, totally true.
And for this reason, we will now, in this particular lecture, solve these equations as we did before
using our standard routines.
So don't worry, I will not bore you with another whole section about these differential equations.
This will just be a single lecture where we will just practice what we've learned before, and I will
show you that we can pretty easily solve these.
Now that we know how it's done, so we shouldn't lose any time, let's go ahead and find, first of
all, the constants case equal to one am as equal to one.
And then we must, of course, define the system of two differential equations.
So I call the function f underscore three oscillators and parameters.
Artie, which does not explicitly enter here, but you remember the integrated solve IBP routine requires
two time argument and then the coordinate argument.
So this is how we always did it and we will do it here as well.
So now we must return some function.
And of course, we want to return here to equate to the right and side of these equations.
So basically these three equations here, but hopefully you also remember that it's not so easy if you
have a second order differential equation.
So we have here a second order time derivative and not the first order one.
This means we must not only return to three right and side of the equation, but we must introduce another
variable first, which would be the first derivative of art.
And this is, of course, the velocity.
So we will return the velocity of the first oscillator, which I will call like this b zero.
Then we have we won and we have the two and then we have here the three right and sides of these equations.
So to make this more clear, I will first of all, remind you that our variable here and why.
We could also call it R or whatever we want is just the right insights of these equations.
But now we do not only have three of these, but we have six of these because we have to consider the
first order time derivative and the second order.
So I write R is equal to Y and then the first three entries and V the velocity is equal to Y and then
the other entries.
So three to six.
So remember, this means start from zero and go to two zero one two and here three four five.
All right.
And now I write Equation one is equal to no, I will write this one here minus R one.
So in our python indices, this would be our with the index zero.
And then we have.
Actually, we have this twice, as you can see here, so I have to ride two times are zero and then
minus one times are one.
And then, for example, I could write in brackets times minus K over M, and then we do a similar thing
for the other ones.
But I will, of course, now paste these here.
Equation with one equation two, Equation three and Equation two and three will, of course, look pretty
similarly.
So two and three and the two will be, as you can see here, minus.
Our zero plus two times our one minus her two and then the last one is, of course, also very easy.
So the only thing that you have to take care of is that you get the indices right because here in Python,
we count from zero one two and here we have one two three.
So please don't be fooled here.
And then everything will be good.
OK, I think it should work like this.
Let's run it.
OK, no error.
That's always a good thing.
And now we can continue and write T start is equal to zero and T and is equal to 100.
Then I will say the starting values for white would be also a six component vector.
And maybe we should specify now know of some specific numbers, but we can also go ahead and just simulate
some random oscillations.
For example, we could write some amplitude or some some magnitude of the variation, and then we generate
six random numbers in the range minus one to plus one.
So this would be minus notes.
It would be two times the random number.
So and people do random dot rounds six and then minus one.
So here it is, would mean now from minus 0.5 to plus 0.5.
This would mean from minus one to plus one, and this would mean from minus 0.3 to plus zero point three.
And then we'll also multiply this by our value a, which we had here, which is basically the year the
equilibrium position.
Or you could also see the letters constant here to the standard or in equilibrium, the distance between
two oscillators.
So we have to define it, of course, as well.
So like, let's say it's equal to one.
And now we have our starting conditions and hard times.
So this means we can now call our routine and stored solution.
And as previously we write, integrate dots, solve, underscore IVP, then we must specify the function.
So really, this is nothing new to this.
Exactly, as we have learned, isn't how we practice it.
Then from T start to T and his starting parameters would be why start?
The method would be R.K. forty five and this would already work, but I want to get a equally spaced
output for added time values or right here.
T sorry typo t evolve is equal to and point in space.
And it goes from tee start to tee and in steps of, let's say, zero point one.
So maybe like this.
OK, so I run this and once again, no error, which is even better.
And now we can plot its so we have a plot with an ex label for X or the x axis indicates the time and
the Y label indicates the coordinates of the three oscillators.
And now we can go ahead and plot pal t dot plot
and for the X values, we take the time.
So this would be a solution and a scroll and a go three or a C dot T.
And for the Y coordinates, we have a solution underscore three O C, Dot Y and then the zero index.
So let's try it and we see some wild oscillation.
So let's add the other two oscillators.
This would be one and two, and we see they are now on top of each other and it oscillates quickly.
Maybe it's good to shift them by their equilibrium position.
So basically, what we what we see now here is the solution for our transformed variables, which would
be these ones here.
So this would be the coordinate with respect to the equilibrium position.
But if you want to transform back to this one here, we have to add a two hour one to a two hour two
and three a two or three.
Then we are back in our old coordinate system.
So this is what I did here and I'll run it.
And you see, now they are oscillating apart from each other.
You see, the first one oscillates around one, the second one around to the third one, around three
one to three.
So of course, since I have chosen the starting conditions to be random for you, the solution will
probably look different.
So also, when I restart and run ourselves, we will get now a bit of a different solution.
But in all cases, we have here some oscillation, and you see, it's not really just a cosine oscillation.
So even though we have simple harmonic oscillators for each of these springs.
So for example, if we would leave out this whole part here and just consider this oscillator with this
spring, we would get a harmonic oscillator and as a solution, we would get some cosine or sine function.
However, here we see that there is some oscillation, but it's not harmonic.
This is because the system becomes very sensible or very, very unstable, you could even say.
And if you change the starting conditions, and this will pretty much affect also all of the other oscillators,
and they will oscillate in a pretty funny way.
However, it was no problem to solve this.
Using our standard routine solve dot, integrate dot solve underscore IBP as we did before, and now
we have our numerical solution.
So now in the next lecture, we can go ahead and analyze this equation of motion once again and solve
the problem with a different method.
And this will be something new.
So please stay tuned, and I hope you are excited for the next lecture.