Now, what I'm going to do, I'm going to add dimensions to the cost function.
OK, now you're going to have more dimensions.
Now we're going to have 10 dimensions instead of five dimensions.
The five dimensions would be the errors at each sample tile, and the other five dimensions would be
the actual thrust values at each sample time.
So now I'm trying to find the sequence of trust values for the rocket, but I'm also including the thrust
values in my cost function.
Now let me show you why.
Let me just write it down for a second.
So remember, when you have a thrust value or in general a system input, it is shifted by one simple
back because essentially this is your input which influences what happens next.
OK, your Teekay is going to influence how high your lander will be and therefore what your error is
compared to the reference line.
So be six times DKA plus.
W seven o and also squared times, Teekay plus one squared plus the eight times Teekay plus two squared
plus W nine times T.
Kate plus three squared and plus W 10 times Teekay Plus.
Four squared.
And there you go.
This is your.
This is the second part.
Of your cost function, and now let's look at it, what do we see?
Well, we see that our cost function is a 10 dimensional cost function, but also that means that when
we minimize our J when we try to find that unique place where the J takes the smallest amount possible,
then now we don't only find the errors that correspond to this value, but also the thrust values.
So essentially, we're also now trying to minimize the usage of thrust and since actually the errors
depend on trust.
So if you apply more thrust, then you influence the error more, right.
Either in a positive way or in a negative way.
But in general, if you apply more thrust to your lander, then your error becomes influenced more.
And if you don't apply any thrust, then your error will not be influenced by thrust, because without
the thrust, only the force of gravity influences your error, which is a constant force.
So when we apply a lot of thrust, we influence the error a lot.
So let's say if we let our thrust values to vary as it pleases, right.
Just like we did here, then we can minimize the errors very much because the NPC will find a solution
that says that, OK, the best sequence for the thrust values is this, right?
Why?
Because then if your lander is falling to the ground, then the best way to minimize these errors is
to apply no thrust in the first sample period in a lot of thrust, an extreme amount of stress in the
second sample period y because then.
Your altitude, which is the way they mentioned and let's say this is your time axis and we're assuming
that our sample time is one second, because if we apply this kind of extreme thrust sequence, then
what's going to happen is that your rocket will fall very sharply.
Towards the ground, right?
And then all of a sudden.
When you apply a lot of trust.
This line will flatten out, right?
It will flatten out and therefore you would only end up with a small amount of error.
Right.
You only have error here.
A little bit of error.
Maybe he subcu plus one.
And here you already have no error because your rocket would be on the ground and therefore you wouldn't
have any air here.
E.K. plus three equals four and X plus five.
And so what you have done, you have minimized the some of the errors.
And if you want to minimize the some of the errors, then if you ignore the thrust part in the cost
function, then you will find the solution where indeed a good sequence is like this.
First no thrust and then a lot of thrust.
Then your rocket would land very quickly to the ground.
And so by applying this extreme thrust, you truly minimize the some of the errors by a lot, you will
only have a little bit of error here.
So you would achieve your objective.
But like we said, it might not be practical in real life.
And also, if you have cargo or passengers, then inside the rocket, they wouldn't feel very good.
But now, if you don't apply any thrust, then in real life your rocket would crash, right?
It would fall to the ground.
But mathematically, that's not what's going to happen.
Mathematically, this is what's going to happen.
So, again, if this is the altitude, right, this is your altitude and then this is your time in continuous
domain or samples in a discrete domain, then this is what would happen mathematically.
This is what the computer would think.
The computer would think that, OK, if I apply no thrust at all.
Well, then.
You would probably fall down something like in this way, right, because you would fall down faster
and faster.
And so you would have a lot of error.
Here and you can imagine if you have three more more samples, Kate, plus three Caples for Kate plus
five, then you would have a lot of errors like the some of the errors would be enormous.
That's why if you don't apply any thrust then for the computer, you wouldn't have a situation where
you're where the sum of your errors are minimized.
You would have a situation where where your errors would be very big.
And so that's why it would definitely give you a solution where you need to apply the thrust.
But again, like we said before, this kind of situation that we have here, it's not really feasible.
And therefore, now that you know, that our thrust influences the errors, you apply a lot of thrust
and a lot of thrust very fast, very sharply.
You minimize the some of the errors.
And if you don't apply thrust at all or applied very slowly, then your errors would be very big.
And so you have these two phenomena.
Right, and you form a cost function out of it.
And so now when you try to minimize your cost function, what you're trying to do, you're trying to
minimize your errors.
Right.
Which would imply that you would have to apply a lot of thrust very fast.
But at the same time, you are also now minimizing the usage of your thrust values since you're minimizing
your thrust values that in turn will cause the some of the errors to be a bit bigger.
And so in the end, what you're going to find, you're going to find a tradeoff, right?
You're going to find some kind of combination in the end.
Once you minimize your cost function, once you find your jamen, you will find like a unique combination,
like a vector a to attend dimensional vector where you would have E K plus one up until he K plus five
and then t k up until T K plus four.
Right.
So you will find a unique combination of variables, 10 variables that will give you the smallest possible
J you can have.
And so remember that this is also actually depends on DKA and this area here depends on T, K plus four.
But now the thrust values that you find are going to be different and they're going to be different
because while you minimized your cost function, you didn't only have errors as your dimensions or as
your variables in the cost function.
You also had thrust values themselves as your cost value variables.
And by minimizing your cost function, you also minimize your thrust values, right?
You minimize your errors, but you also minimize your thrust values.
And since they're kind of inversely related to each other, more thrussell, less error, less thrust,
more error, then in the end you will get this unique vector that will give you the smallest possible
J.
And out of this vector, you will get your unique Teekay Teekay plus one Teekay plus two t.K plus three
and t.K plus four.
This will be your unique system input vector.
And so this unique system input vector that you get will be different than it would have been if you
had only considered the first part of the cost function right now because you added a second part to
the cost function and you minimized an entire 10 dimensional cost function.
Now your system input vector is going to be different and it will result in a compromise between minimizing
your errors and your thrust values.
You can also look at it like this.
If you look at this cost function from a purely mathematical point of view, then you can see that by
minimizing the cost function, you minimize the total some of the error squared and thrust value squared.
And that also means that you minimize the total some of the absolute value of the.
Errors and trust values and remember here, minimizing errors means minimizing the state y or the altitude
because your reference altitude is zero meters, so your E squared is actually Y squared.
And so instead of something like this, instead of these extreme values that you had here at the beginning,
no thrust and a lot of thrust, maybe at the beginning you will have that much thrust, then you will
have that much thrust, then you will have that much thrust, then you will have that much thrust and
then you will have that much thrust.
Right.
So now as you can see, like you apply your thrust values way more smoothly and you can see that now
your thrust values at each sample are below this maximum cap of what your rocket engines can produce.
And so now, because you minimize a 10 dimensional cost function instead of a five dimensional cost
function, which means that you also try to minimize your thrust values in addition to minimizing your
error values.
Because of doing that, you will now get these kind of results.
Because of this result, your landing could be maybe something like this.
Right.
So first, your first error is like this, then your second there would be like this third, fourth
and fifth that.
OK, now of course, the sum of your errors is bigger than in this case.
Right.
In this case, your some of theirs was very small.
Now you're some of the errors is bigger, but at the same time you're OK with that.
You can accept that because you're landing is still smooth.
But the good thing about it is that now you also have normal, manageable thrust values and you got
that thanks to playing the second part to the cost function.