So in the previous lectures, we have spent a lot of time with solving this particular example of considering
three harmonic oscillators that are couples, and it turned out that the numerical solution was quite
difficult.
So at first we could just say, OK, this is the solution, but we don't really know what it means.
But then we established the eigenvalue problem and solved the equation for the eigenvalues, which told
us the ion frequencies.
And we've seen that we can rediscover his ion frequencies in the four you transform.
And even we can take these characteristic frequencies and build harmonic functions and then superimpose
these three functions.
We've seen that when we fit the parameters, then we can even restore the numerical solution.
So everything, everything makes total sense and everything agrees well with each other.
And we have practiced here a lot of the previous topics that we have discussed early on.
So a bonus lecture that I want to show you here is that we can generalize the whole thing not only for
this system with three oscillators, but four and oscillators.
And here I want to show you this.
So we will solve it numerically.
We will calculate the ion frequencies and we will calculate the full year transform.
And the nice thing is we don't really have to change any of the code.
So just really tiny changes.
And the only thing that we really have to change here is the definition, of course, of the equations
of motion.
So there's a we will do first.
So I will write Def F and see if I would have written down here.
Three O C, we wouldn't have to change anything.
But I want to keep the old results.
So please make sure that whenever we wrote three and a c right note and or C, and the other thing that
we have to change for the eigen frequency is the definition of a.
So this is what I will do first and then we can just run the whole thing and see if this works also
for a general revised version.
And as an example, I will choose here already quite a difficult set up here with 20 oscillators.
So function will, of course, again have the arguments T and Y.
And now we have to think, how can we generalize this?
First of all, since we have now so many equations, I will write our is equal to y from zero to end
and then the value will be y from end to to end.
And the equations will I will, of course, not define explicitly because we don't know how many equations
we will have, this depends on the value of and so I will start with and p zero of 10 so that we start
with some blank equations.
And then I will write equation the second until the second last equation will be equal to minus our.
The first equation until the minus two, so basically leave out the last two and plus two times are
one to minus one and then minus.
Are two to the last one.
So this is what we have also seen in The Matrix, basically all the entries, except for the first and
last one, will have to form minus one to minus one.
And then many zeros, if we have more of these oscillators than we get when we go to the next one,
we shift these three numbers wants to the right.
And this is what we have programmed here, exactly.
So for every one of the middle equations, which means everyone except the first and the last one,
the equation will look like this.
And then we have to explicitly define the first and the last one, which will be equation zero, because
here it will be a bit different.
So there will be two times are zero minus are of one.
And then for the last one equation and minus one will be minus are off and minus two to the left neighbor.
And then the two later itself will be two times out of and minus one.
And then we have no right neighbors, so that's it.
But then we must return.
First of all, the values and then the equations, and we are missing still the factor.
So I wrote here minus K over m times equations.
So since these are lists and these are lists, we have to merge these lists.
So I write here and p dot concatenate.
And then it should work, I think.
But of course, here we are missing the brackets.
OK, now let's run it and you see we get a nice solution.
We have now 20 oscillators, and you see this motion looks very difficult.
But we also know that we could calculate the eigen frequencies, which we will do next.
And so we could recover each of these 20 oscillators by just superimposing of 20 harmonic functions
with the 20 eigen frequencies.
So let's go ahead and program the matrix and then calculate the EIGEN frequencies.
So a would be it.
That's something we will also encounter in a different lecture.
There's always a nice trick when you have such and such matrices that almost the zero and only have
values on the diagonal and then on the other diagonal right next to it.
So basically, we will just define this diagonal, this diagonal on this one.
And then we will use a command that is called and pitot diak and here will show you how this works.
He write, for example, minus one times.
And minus one.
So this would be just by itself, a list of minus one.
And this whole thing 19 times in this case, this would be not the main diagonal, but the one the right
next to it.
And since it's not the main diagonal, we right k is equal to one.
So if I call this, you see we have here these this vector here, not on the main diagonal, but on
the one right next to it.
Then we can add another one.
Copy this and now our right here, plus two times.
And because this is not a main diagonal, so it has and trees and key is equal to zero, this is to
shift.
And so now we have on the main diagonal a lot of twos.
And so only one thing is left.
This is the other one of those minus one.
And now it works.
Yeah, because here in the second line, we start with minus one to minus one.
And then it shifts the indices zero minus one to minus one until in the last line, we have a lot of
zeros and then minus one and two.
And we know that we get our ion frequencies by just calculating the square root of the eigenvalues and
multiplying by square root of K over them.
So you see, we have a whole lot of eigenvalues here.
Now we can continue and calculate the Fourier transform.
So here you only have to be careful because you have to change the solution three o c to solution and
our C because this is what we have named it, and then we can just go ahead.
And look at the frequencies, so here I've plotted several different things.
The first one would be the four you transform only of the first oscillator, which has the peaks, which
should correspond to these values that we have here.
For example, we can check we have here several values below zero at zero point one five zero point
three zero point four four five.
And this one here, for example, would be 0.3 zero point one five zero point four five.
The next one would be slightly above zero point five.
This would probably be this one.
So you see each of these eigen frequencies is indeed in the four you transform.
And then the second plot for the second plot I've used here a loop where I loop over all of these oscillators.
So here you see the different colors to different oscillators, and you see they have peaks at the same
frequencies, of course, but the amplitudes can be a bit different.
And this we have also seen already for the three example case and maybe even some of the some of the
coefficients of the eigenvectors on zero.
So then in this case, there would be no peak for this particular oscillator.
And then the last thing would be the same thing as here, but zoomed in, and you can really see that
we have these peaks at zero point fifteen zero point three zero point forty five and then another one
here at zero point five eight, which are exactly these eigen frequencies that we see here.
So you see the with the tools that we have, we can very quickly solve new problems.
And you see, we have not generalized the problem to 20 oscillators, which is, of course, if you
would want to solve it analytically by hand would be impossible to do.
But with our methods that we have established, it's very easy.
And you see, still, everything agrees very well.
We have the miracle solution.
We have the eigen frequencies.
We have to fully transform and we could even do to fit.
But I want I don't want to do this now because this was just be a time consuming and we know that it
would work, of course.