‫Welcome back.
‫So in the previous videos, we talked about the fact that there is a more advanced method to integrate
‫states and then method is called.
‫The fourth order, wrong Akutan method.
‫So so far, we have been using this formula here in order to compute our new state at K one, using
‫the present state at K, plus the time derivative of the state at K times, the sample time interval
‫divided by N.
‫And again, this end chops this sample time interval into smaller pieces, and so this method is called
‫the oilor method.
‫And this method is not wrong, however, people tend to use wrong Akutan method now because the other
‫method has certain issues.
‫Here you can see a graph, you have time on the horizontal axis and you have a random state on the vertical
‫axis.
‫Let's imagine that you're at time t.
‫And this point here is T plus T.
‫S, so this interval here, that's your sample time interval.
‫So on the vertical axis, this point here is your state at and this point here is your state at K plus
‫one.
‫And so you are using the other method to be able to predict that new state at K plus one.
‫And you do it like this, you compute the time derivative here in this point, which is the slope,
‫and you projected to T plus Tietz.
‫And so you're going to end up being here, so this WidePoint here, that's your true new state.
‫So it's this point here and this Redpoint here, that's your predicted new state by oilor method.
‫So it's this one here.
‫As you can see, this method can give you quite an imprecise answer, because this would be your error
‫here.
‫This difference in purple, that would be your error.
‫So when you project the derivative that you get at time T til time T plus two seconds, you might have
‫an error between the true state and your predicted state that is unacceptably large.
‫Then in the previous course, we solved this problem like this, we took this time sample interval and
‫we chopped it into several pieces and we used the exact same method is just now.
‫We did that on a smaller interval.
‫So we computed a derivative here.
‫And we projected it to here to this point, then here we computed another derivative and we projected
‫it till this second point here like this.
‫Then again, we computed a new derivative in this point here, and we projected it till this point here.
‫And then a new derivative here that was projected till this point here.
‫And finally, a derivative here that was projected till this point here.
‫That approach did increase the precision and reduce the error.
‫As you can see, your final error is now much smaller because you did this integration over a smaller
‫time, sample period.
‫So maybe now your final error would be this one here, this distance, so a much better improvement,
‫right?
‫However, the truth is that in real life, this approach can be impractical.
‫One of the reasons is computational cost when your system is very complex and requires a lot of computations.
‫Then you have to understand that calculations, even if made by computers, they need time.
‫So when time is an issue, then you really want to minimize the amount of mathematical operations and
‫the amount of iterations in the program, especially when you're doing something real time and calculations
‫need to happen real time.
‫Meaning that you want your for or while loops in the program run less cycles, and so luckily, instead
‫of breaking down teams or the sample time interval into multiple pieces, we can avoid doing that by
‫using the fourth order wrong kouta method.
‫It is a very popular and widely used method in engineering.
‫And like I mentioned before, Matlab, for example, has an integrative function which is called.
‫Oh, the forty five and Oddisee stands for ordinary differential equations and four words for fourth
‫order wrong kouta.
‫And so that shows that Runga Ceuta is a pretty popular thing and something that is good to know.
‫And by the way, when you work in Matlab and you want to use this function, then you have to have your
‫differential equations in the form of states based equations.
‫Meaning that they all have to be first order differential equations, which we have in discourse, in
‫other words, you cannot have something like this when your state is X and then you have something else,
‫and then all that equals X double dot.
‫That's not a first order differential equation.
‫A first order differential equation would be if your state plus something else would equal X dot.
‫Or if you want to use X double dot, then that means that your state has to be X dot and only then you
‫can use this Matlab function.
‫At least that's based on my experience.
‫And you can find information on math works about how this function works.
‫But again, my point is that it uses the fourth order wrong Akutan method, so I'm going to teach you
‫this method now so that it would not be a mystery to you.
‫And just to reiterate, in this course, I use wrong Akutan method in my code.
‫And when I use my wrong Akutan method in my code, then I did not break this sample time interval into
‫several pieces.
‫And the code worked very well and the simulation also ran very well.
‫So it's a good method to learn and it can save you some computational time.
‫So let's get started.