1
00:00:00,390 --> 00:00:06,330
So we've just figured out that we can take our numerical solution and do if we're it will transform

2
00:00:06,750 --> 00:00:14,400
and we will see dominant peaks at the three eigen frequencies that we have previously calculated by

3
00:00:14,400 --> 00:00:19,800
calculating the eigenvalues of the matrix that enters the equation of motion.

4
00:00:20,700 --> 00:00:32,220
So the idea would now be to calculate or to generate our numerical results by superimposing three sine

5
00:00:32,220 --> 00:00:32,820
functions.

6
00:00:32,820 --> 00:00:35,370
Or we could also take three cosine functions.

7
00:00:36,150 --> 00:00:41,190
And for the frequencies of these sine or cosine functions, we take, of course, the ion frequencies

8
00:00:41,190 --> 00:00:42,870
omega one, two and three.

9
00:00:43,380 --> 00:00:50,040
And I told you also already that we have three parameters for the amplitudes now.

10
00:00:50,370 --> 00:00:53,520
And additionally, we have three parameters for the phase.

11
00:00:54,570 --> 00:01:03,210
And so the idea is now that we fit these three, these six parameters in total so that we fit this model

12
00:01:03,210 --> 00:01:05,700
function to our numerical solution.

13
00:01:06,660 --> 00:01:12,560
And this is really exactly the same procedure that we have done in one of the previous sections with

14
00:01:12,600 --> 00:01:16,260
where we have first discussed the fitting procedures.

15
00:01:17,160 --> 00:01:22,050
So in fact, you can see here that I have copied even the code from these sections.

16
00:01:22,770 --> 00:01:28,710
So as I wrote and as I told you back then, there are many reasonable definitions of an error function.

17
00:01:28,710 --> 00:01:35,610
But the very common choice is this one here where you take the y values of the actual calculation,

18
00:01:36,060 --> 00:01:41,580
which would be the numerical simulation in our case and then the values of our model functions.

19
00:01:42,270 --> 00:01:47,790
And this will be then the error function and to minimize the error.

20
00:01:47,820 --> 00:01:49,550
We do gradient descent.

21
00:01:49,560 --> 00:01:54,900
We could also do other methods like Monte Carlo that we discussed in a different section.

22
00:01:55,410 --> 00:01:57,810
But here we will do gradient descent.

23
00:01:57,900 --> 00:02:03,630
So basically, we calculate the gradient of the error function with respect to these parameters.

24
00:02:03,750 --> 00:02:04,800
So it would be this one.

25
00:02:05,460 --> 00:02:13,620
And then we go along the opposite direction of the gradient several times until the error function is

26
00:02:13,620 --> 00:02:14,220
minimized.

27
00:02:15,300 --> 00:02:21,300
So I know that this is a bit difficult, but I think it's a good time for you to practice this because

28
00:02:21,300 --> 00:02:23,430
we have already done a fit together.

29
00:02:23,880 --> 00:02:26,790
And you know, now a lot about these coupled oscillators.

30
00:02:27,210 --> 00:02:30,210
And now your task is to implement the fit.

31
00:02:30,420 --> 00:02:36,120
So you can, of course, take the routines from the notebook that we have programmed back then.

32
00:02:36,600 --> 00:02:42,510
The only thing that you have to take care of that is that now the gradient is a tiny bit different.

33
00:02:43,260 --> 00:02:46,860
So until here, it's exactly the same thing as previously.

34
00:02:47,190 --> 00:02:53,330
But the values of these derivatives of the model function is, of course, different because our model

35
00:02:53,350 --> 00:02:59,790
function is now such a superposition of three harmonic functions and not on any anymore a polynomial.

36
00:03:00,960 --> 00:03:05,370
So we have to calculate the gradient of this function with respect to eight.

37
00:03:05,820 --> 00:03:13,770
And this would, of course, be for the first component cosine omega one t times a plus find one because

38
00:03:13,770 --> 00:03:16,380
the derivative is just with respect to this one here.

39
00:03:16,590 --> 00:03:25,260
So we get this term and then the derivative for respect to PHI one would be a one times minus sine omega

40
00:03:25,260 --> 00:03:28,740
one T plus phi one, and there is no in a derivative here.

41
00:03:29,190 --> 00:03:30,450
So it would just be this one.

42
00:03:30,810 --> 00:03:33,990
And then for the other, it's really the same thing.

43
00:03:33,990 --> 00:03:35,580
So yeah, pretty easy.

44
00:03:35,760 --> 00:03:37,760
Calculating the gradient analytically.

45
00:03:39,030 --> 00:03:46,650
So no, you just have to take the code from the other section and just change a few things and change

46
00:03:46,650 --> 00:03:54,540
the gradient and then run the fit and see if you can really restore the numerical results by our fitted

47
00:03:54,540 --> 00:03:54,990
function.

48
00:03:55,770 --> 00:03:58,530
So please give it a try, or at least think about it.

49
00:03:58,530 --> 00:04:02,790
And then you can, of course, watch my next video where I will show you my solution.

