So we've just figured out that we can take our numerical solution and do if we're it will transform
and we will see dominant peaks at the three eigen frequencies that we have previously calculated by
calculating the eigenvalues of the matrix that enters the equation of motion.
So the idea would now be to calculate or to generate our numerical results by superimposing three sine
functions.
Or we could also take three cosine functions.
And for the frequencies of these sine or cosine functions, we take, of course, the ion frequencies
omega one, two and three.
And I told you also already that we have three parameters for the amplitudes now.
And additionally, we have three parameters for the phase.
And so the idea is now that we fit these three, these six parameters in total so that we fit this model
function to our numerical solution.
And this is really exactly the same procedure that we have done in one of the previous sections with
where we have first discussed the fitting procedures.
So in fact, you can see here that I have copied even the code from these sections.
So as I wrote and as I told you back then, there are many reasonable definitions of an error function.
But the very common choice is this one here where you take the y values of the actual calculation,
which would be the numerical simulation in our case and then the values of our model functions.
And this will be then the error function and to minimize the error.
We do gradient descent.
We could also do other methods like Monte Carlo that we discussed in a different section.
But here we will do gradient descent.
So basically, we calculate the gradient of the error function with respect to these parameters.
So it would be this one.
And then we go along the opposite direction of the gradient several times until the error function is
minimized.
So I know that this is a bit difficult, but I think it's a good time for you to practice this because
we have already done a fit together.
And you know, now a lot about these coupled oscillators.
And now your task is to implement the fit.
So you can, of course, take the routines from the notebook that we have programmed back then.
The only thing that you have to take care of that is that now the gradient is a tiny bit different.
So until here, it's exactly the same thing as previously.
But the values of these derivatives of the model function is, of course, different because our model
function is now such a superposition of three harmonic functions and not on any anymore a polynomial.
So we have to calculate the gradient of this function with respect to eight.
And this would, of course, be for the first component cosine omega one t times a plus find one because
the derivative is just with respect to this one here.
So we get this term and then the derivative for respect to PHI one would be a one times minus sine omega
one T plus phi one, and there is no in a derivative here.
So it would just be this one.
And then for the other, it's really the same thing.
So yeah, pretty easy.
Calculating the gradient analytically.
So no, you just have to take the code from the other section and just change a few things and change
the gradient and then run the fit and see if you can really restore the numerical results by our fitted
function.
So please give it a try, or at least think about it.
And then you can, of course, watch my next video where I will show you my solution.