﻿1
00:00:00,720 --> 00:00:01,530
‫Welcome back.

2
00:00:02,130 --> 00:00:10,350
‫So in the previous videos, we talked about the fact that there is a more advanced method to integrate

3
00:00:10,350 --> 00:00:13,440
‫states and then method is called.

4
00:00:14,610 --> 00:00:17,580
‫The fourth order, wrong Akutan method.

5
00:00:18,780 --> 00:00:28,800
‫So so far, we have been using this formula here in order to compute our new state at K one, using

6
00:00:28,980 --> 00:00:36,930
‫the present state at K, plus the time derivative of the state at K times, the sample time interval

7
00:00:36,930 --> 00:00:38,880
‫divided by N.

8
00:00:39,880 --> 00:00:48,970
‫And again, this end chops this sample time interval into smaller pieces, and so this method is called

9
00:00:49,390 --> 00:00:50,620
‫the oilor method.

10
00:00:51,610 --> 00:00:58,960
‫And this method is not wrong, however, people tend to use wrong Akutan method now because the other

11
00:00:58,960 --> 00:01:00,730
‫method has certain issues.

12
00:01:01,990 --> 00:01:09,640
‫Here you can see a graph, you have time on the horizontal axis and you have a random state on the vertical

13
00:01:09,640 --> 00:01:10,150
‫axis.

14
00:01:11,210 --> 00:01:14,690
‫Let's imagine that you're at time t.

15
00:01:15,810 --> 00:01:20,310
‫And this point here is T plus T.

16
00:01:20,310 --> 00:01:26,220
‫S, so this interval here, that's your sample time interval.

17
00:01:27,390 --> 00:01:38,700
‫So on the vertical axis, this point here is your state at and this point here is your state at K plus

18
00:01:38,700 --> 00:01:39,150
‫one.

19
00:01:40,370 --> 00:01:48,200
‫And so you are using the other method to be able to predict that new state at K plus one.

20
00:01:49,180 --> 00:01:57,370
‫And you do it like this, you compute the time derivative here in this point, which is the slope,

21
00:01:58,210 --> 00:02:02,290
‫and you projected to T plus Tietz.

22
00:02:03,360 --> 00:02:13,110
‫And so you're going to end up being here, so this WidePoint here, that's your true new state.

23
00:02:13,990 --> 00:02:26,370
‫So it's this point here and this Redpoint here, that's your predicted new state by oilor method.

24
00:02:27,030 --> 00:02:29,100
‫So it's this one here.

25
00:02:30,280 --> 00:02:38,920
‫As you can see, this method can give you quite an imprecise answer, because this would be your error

26
00:02:38,920 --> 00:02:39,370
‫here.

27
00:02:40,530 --> 00:02:44,380
‫This difference in purple, that would be your error.

28
00:02:45,450 --> 00:02:57,180
‫So when you project the derivative that you get at time T til time T plus two seconds, you might have

29
00:02:57,180 --> 00:03:04,890
‫an error between the true state and your predicted state that is unacceptably large.

30
00:03:05,960 --> 00:03:14,030
‫Then in the previous course, we solved this problem like this, we took this time sample interval and

31
00:03:14,030 --> 00:03:23,110
‫we chopped it into several pieces and we used the exact same method is just now.

32
00:03:23,900 --> 00:03:26,480
‫We did that on a smaller interval.

33
00:03:27,860 --> 00:03:30,500
‫So we computed a derivative here.

34
00:03:31,520 --> 00:03:43,130
‫And we projected it to here to this point, then here we computed another derivative and we projected

35
00:03:43,130 --> 00:03:47,170
‫it till this second point here like this.

36
00:03:48,500 --> 00:03:57,650
‫Then again, we computed a new derivative in this point here, and we projected it till this point here.

37
00:03:58,910 --> 00:04:04,540
‫And then a new derivative here that was projected till this point here.

38
00:04:05,480 --> 00:04:12,110
‫And finally, a derivative here that was projected till this point here.

39
00:04:13,050 --> 00:04:17,110
‫That approach did increase the precision and reduce the error.

40
00:04:17,450 --> 00:04:26,270
‫As you can see, your final error is now much smaller because you did this integration over a smaller

41
00:04:26,270 --> 00:04:27,770
‫time, sample period.

42
00:04:28,900 --> 00:04:37,750
‫So maybe now your final error would be this one here, this distance, so a much better improvement,

43
00:04:37,750 --> 00:04:38,080
‫right?

44
00:04:39,010 --> 00:04:46,010
‫However, the truth is that in real life, this approach can be impractical.

45
00:04:47,080 --> 00:04:55,660
‫One of the reasons is computational cost when your system is very complex and requires a lot of computations.

46
00:04:56,050 --> 00:05:04,820
‫Then you have to understand that calculations, even if made by computers, they need time.

47
00:05:05,470 --> 00:05:13,870
‫So when time is an issue, then you really want to minimize the amount of mathematical operations and

48
00:05:13,870 --> 00:05:21,130
‫the amount of iterations in the program, especially when you're doing something real time and calculations

49
00:05:21,130 --> 00:05:23,020
‫need to happen real time.

50
00:05:23,950 --> 00:05:34,930
‫Meaning that you want your for or while loops in the program run less cycles, and so luckily, instead

51
00:05:34,930 --> 00:05:45,700
‫of breaking down teams or the sample time interval into multiple pieces, we can avoid doing that by

52
00:05:45,700 --> 00:05:50,350
‫using the fourth order wrong kouta method.

53
00:05:51,220 --> 00:05:55,330
‫It is a very popular and widely used method in engineering.

54
00:05:56,230 --> 00:06:02,860
‫And like I mentioned before, Matlab, for example, has an integrative function which is called.

55
00:06:03,940 --> 00:06:14,710
‫Oh, the forty five and Oddisee stands for ordinary differential equations and four words for fourth

56
00:06:14,710 --> 00:06:15,870
‫order wrong kouta.

57
00:06:16,960 --> 00:06:23,050
‫And so that shows that Runga Ceuta is a pretty popular thing and something that is good to know.

58
00:06:23,990 --> 00:06:31,640
‫And by the way, when you work in Matlab and you want to use this function, then you have to have your

59
00:06:31,640 --> 00:06:36,320
‫differential equations in the form of states based equations.

60
00:06:37,290 --> 00:06:43,950
‫Meaning that they all have to be first order differential equations, which we have in discourse, in

61
00:06:43,950 --> 00:06:52,800
‫other words, you cannot have something like this when your state is X and then you have something else,

62
00:06:53,220 --> 00:06:56,220
‫and then all that equals X double dot.

63
00:06:56,700 --> 00:06:59,820
‫That's not a first order differential equation.

64
00:07:00,450 --> 00:07:08,550
‫A first order differential equation would be if your state plus something else would equal X dot.

65
00:07:09,680 --> 00:07:17,930
‫Or if you want to use X double dot, then that means that your state has to be X dot and only then you

66
00:07:17,930 --> 00:07:20,600
‫can use this Matlab function.

67
00:07:21,020 --> 00:07:23,750
‫At least that's based on my experience.

68
00:07:24,860 --> 00:07:29,900
‫And you can find information on math works about how this function works.

69
00:07:31,110 --> 00:07:38,940
‫But again, my point is that it uses the fourth order wrong Akutan method, so I'm going to teach you

70
00:07:38,940 --> 00:07:43,530
‫this method now so that it would not be a mystery to you.

71
00:07:44,400 --> 00:07:50,160
‫And just to reiterate, in this course, I use wrong Akutan method in my code.

72
00:07:51,230 --> 00:08:00,500
‫And when I use my wrong Akutan method in my code, then I did not break this sample time interval into

73
00:08:00,530 --> 00:08:01,790
‫several pieces.

74
00:08:02,670 --> 00:08:07,570
‫And the code worked very well and the simulation also ran very well.

75
00:08:08,310 --> 00:08:14,620
‫So it's a good method to learn and it can save you some computational time.

76
00:08:15,090 --> 00:08:16,530
‫So let's get started.

