 So, last class first we have discussed the time optimal control means initial state, if the initial state x of 0 is here, we have to drive the state by proper control action so that it reached to the origin x t f, x t is equal to t f it reached to the origin, but that time requires must be optimal. So, we have discussed the time optimal control by using bang-bang control. Bang-bang control means we are using the combination of plus u u max plus 1 comma u min minus 1 combination or u min minus 1 comma u max plus 1 that combination we are we will be able to drive the initial state to final state at origin by using the control sequence plus minus combination or minus 1 combination. The time optimal control we have discussed then we have seen the how to really implement in hardware or in a software how to implement the bang-bang control to drive the initial state to final state in a minimum time. Next we have considered if you recollect that next we have considered that suppose we have a constraint on the control input and also in the state variables, but we are not dealing with the time optimal control, but minimizing the performance index which involved in minimizing the control effort or control energy that we want to minimize. So, our statement of the problem is that consider first let us call consider the system A x dot is equal to A x plus B u. Our problem is our problem is to minimize the performance index which is equal to the what is called your control effort minimization subject to the constraint that u of t magnitude belongs to u of A that for all t 0 to t f let us call this as t f and the constraint on the state variable is this one this is the constraint in the state variable we have made at l constraints are there and this constraint are differentiable with respect to t that is the time. So, our problem statement in this case is given the system which is described in state phase model our problem is to minimize the control effort or the control energy we have to minimize subject to the condition condition on input and also constraint on the state. Then this formulation is one of the simplest technique is that you introduce a new variable that if the number of the states in the system is n that we have discussed is here if it is a n then we introduce one additional variable let us call n plus 1 th state variable we introduce that this one that n plus 1 dot is equal to this is the constraint on the state the first constraint square multiplied by u s and u s is nothing but a strictly unit step function similarly, second constraint square multiplied by another unit strictly unit step function this step function when this psi of 2 value is greater than 0 then this value is 1 when it is less than equal to 0 that function value is 0. Similarly the l th constraint we have written that constraint square into strictly unit step function this. So, this is the new additional state is introduced state introduced this. So, we have made the all inequality constraint now is a equality constraint of that one what we have already discussed about the u s that is this u s is the when it is less than equal to 0 this value is 0 and when it is greater than 0 that it is a strictly unit and step function means 1. Now, look at this expression of 3 and 4 suppose this may be a situation that psi value some cases may be 0 less than equal to 0 or some cases 0 some cases may be greater than 0. So, whatever the this situation is there this expression is x dot of t that expression is less than less than 0 or less than equal to 0 this for all t this one. The another situation may arise this situation will arise when all the constraints are not satisfied then this situation is 0 when all the constraint state constraints are satisfied under this condition this will be equal to 0 x n plus 1 dot t is 0 for all times when all the constraints are satisfied. So, yesterday only we have come up to this point. So, we will now continue rest of the part. So, now if you now specify the boundary condition for if now we specify if we specify now specify the boundary condition for equation 3 the equation 3 is that one equation 3 is this equation the new additional state vector this is equation. Now, you introduce some specific boundary condition for equation 3 that x n plus 1 of t 0 initial time t 0 is equal to 0 and x n plus 1 t f is equal to 0 because this our things all the inequality constraint must be satisfied. So, at the terminal condition that must be satisfied that means this we made an assumption that boundary condition of x 1 t 0 0 and this is 0. If this is 0 and this is 0 then immediately I can write if x n plus 1 of t 0 is equal to 0 and x n plus 1 t f is equal to 0 then x n plus 1 t f is equal to 0. We can write x n plus 1 t is equal to 0 for all t 0 for all t belongs to t 0 to t f. How it is because if you see the dynamic equation x n plus 1 the dynamic equation this is equal to 0 because it must satisfy this is equal to 0 when all the constraints are satisfied. If you integrate this one you will get it this equal to what is called 0 provided x t and 0 is 0 and final condition also 0. So, for all the time this will be 0. So, this is x n plus 1 t is the solution of equation 3 if x n plus 1 dot 0 is equal to 0. So, x n plus 1 dot of t is equal to 0 for all t belongs to t 0 to t f this is the condition for this one. So, now we know that at x n t f also 0 x t 0 is 0 with this assumption we can make it x n plus 1 t is 0 for all time t if x dot of t is 0 when it will be 0 if all the constraints are satisfied from 0 to t f under this question. So, solution of the problem along with the solution of that problem along with the that the state equation constraint and additional boundary condition this is the boundary condition and with the additional boundary condition we will be able to solve the problem. Which problem that problem is given the state equation and we have to minimize a performance index means minimizing the control effort or control energy subject to the what is called constraint on the input as well as constraint on the state that problem we will be able to solve with if there is a constraint on the state we have to introduce a new additional state variables x n plus 1 and with the knowledge of the constraint equation we can write x n plus 1 dot is equal to that expression x n plus dot is equal to that expression and this expression x n dot plus 1 this expression is equal to 0 when all the constraints are satisfied over the interval t 0 to t f this condition. And with this assumption we made it we specify the boundary x t n 0 is 0 and x t f is 0 with this condition with this condition boundary condition of this one this x t n is 0 provided x n plus 1 t is 0 for all time this all time this is equal to when it will be 0 when the inequality constraint inequality constraint is satisfied. So, let us solve a problem of such type of problems that mean when input there is a constraint on the input as well as there are constraint on the state variables. So, example so minimize j is equal to 0 to t f half t square of t u t square or d t. So, you see here clearly this is not the time optimal control that means we do not want to drive the state from initial state to final state in a minimum time. Our objective is to minimize the control effort u square t control effort or control energy over the interval 0 to t f and at t f the state will the original state will drive to the final state at origin and what should be the sequence of control law for that situation. And subject to what x 1 dot is equal to x 2 this is the dynamic equation of the system and x 2 dot is equal to minus 2 x 1 of t plus u of t and our initial condition is given x of 0 which is nothing but a x 1 of 0 plus x 2 of 0 which is given as a 0 and 1. So, what is our problem transform transfer the initial state to the final state x 1 dot is equal to x of t f x 2 of t f is equal to 0 in minimum control effort with the following constraints. So, this is our problem what is the constraints are given this constraint is first constraint is u of t mod must be equal to less than 1 that mod of u is equal to minus 1. So, mellow will be less than 1 for all t 0 to belongs to all t belongs to for all t belongs to 0 to t f and second condition is state variable constraint state variable constraint what is this constraint x 1 is greater than equal to 0 and minus 1 x 2 is greater than minus 1 less than is equal to 2. So, this type of problems we have done in static optimization problem where we are minimizing the performance index subject to the constraints agree and there that equality constraint inequality constraint equality and inequality constraint was there. So, we have solved that type of problems earlier, but now this problem is dynamic optimization problem in sorry not dynamic dynamic that is the dynamic optimization problem our problem is to minimize the that performance index is nothing but a control effort minimize control effort. Subject to the constraint this is the dynamic equation and what we have to do that transform the initial state x what is this x of 0 initial state that is x of 0 to the final state at origin in minimum control effort with the following state constraints that following constraints input constraint and the state constraint. Next question is let us call this is the equation number one this is the equation number two and this constraints are equation three and this is equation four agree. So, our problem how to solve this problem. So, we have told you that all inequality constraint we have to write in this structure phi psi of this less than equal to 0 psi i i is equal to for our case i is equal to 1 2 3 now how psi 1 I am reading. So, x 1 is solution. So, x 1 now solution. So, psi 1 first I am writing psi 1 is what psi 1 x of t of t is nothing but a our things is what we can write this equal to that minus x 1 of t that is less than equal to 0. So, this problem we have to solve by augmenting one state x and plus one state we have to augment before that I am writing that inequality constraint in the usual form I am writing psi 1 is x 1 another condition is that one if you take the x t in this side that minus 1 minus this is x 2 minus 1 minus x 2 less than equal to 0. So, psi 2 of x of t of t is equal to minus x 2 of t minus 1 bracket close is equal to less than equal to 0. This is the second condition inequality constraint in the state third you can write it x 2 2 you bring it that side is less than equal to 0. So, psi 3 of x t of t is equal to x 2 minus 2 is that equal to less than equal to this and that is equation number 5 and each constraint is differentiable with respect to x of t. So, if you write it better small x because I have written the small x possibly yes I have written small x is equal to x 1 x 2. So, write it small x so that all this thing is differentiable with respect to x of t and time this is the thing. Now, we will form the new additional state the new additional state the new additional state. So, we have a secondary system x 1 and x 2. So, third state is x 3 dot is equal to we will write it minus that psi 1 of x of t comma t this whole square into u of s psi 1 x of t of t then minus psi 2 x of t and t whole square u of s psi 2 x of x 1 this is x. So, write it x of t or t this whole square of t this is function of x means x 1 x 2 this we have seen the inequality constraint is a function of x 1 x 2, but in your case some cases is a function of x 1 only some cases function of x 2. And some cases may be function of x 1 and x 2 also that if it is state constraint either it will be a state constraint is there either that the way we are writing here is a function of x 1 or function of x 2 if you this way. So, you can write more specifically it is a function of x 1 that second one is a function of x 2 and third is psi 3 x of 3 of t whole square u of s psi 3 x of t into comma t. So, you know already what is the value of this value this what is psi 1 of x just now we have calculate from this psi 1 of x is minus x 1 t minus x 1 t. So, psi 1 is minus x 1 t. So, minus x 1 t square that means x 1 square of t into u s psi 1 x t of t. The next is psi 2 is nothing but a minus x 2 minus 1. So, it will be ultimately square if you take x 2 of t plus 1 whole square u s psi 2 dot function of x of comma t. Then third one is this is x 2 minus 2 value x 2 minus 2. So, x 2 minus 2 whole square u s psi 3 of 3. Let us call this is the equation number 6. So, we have written the equality constant values here and square this all this case and this turns out to be like this way. Now, so equation you see the equation 6 is 0 when all the constant is 0 when all the constant in 5 that means all the constant in 5 this are true. If all the constant psi 1 psi 2 is true that means it is less than equal to 0 that means this value will be 0 this value will be 0 this value will be 0. So, equation 6 is 0 when all the constant state constant state variable constants are satisfied. When the state variable constants are satisfied less than 0 that this quantity is less than 0 that means that step function strictly step function is valid when this x psi of t value is greater than 0 or greater than 0 then it is valid. And equation 6 and equation 6 is less than equal to 0 when the constants are not satisfied when for all t when for all t the for all t when constants 5 are not constant 5 are not satisfied. So, this is the we made a conclusion from this one that that equation say x 3 dot is 0 when all the constants will satisfy x 3 dot is not equal to is less than equal to 0 is not equal to 0 means less than equal to 0 when this equal to that is constant are not satisfied. Now, we specify our boundary conditions specify the boundary condition what is the boundary conditions x 3 of 0 our t 0 is 0 is 0 and x 3 t f which you do not know is equal to 0. Then immediately you can write it then x 3 t is equal to 0 since for all t belongs to that t 0 to t f t 0 to t f since x 3 is equal to x 3 dot of t is equal to 0 why x 3 is equal to 0 because during this interval if all constants are satisfied then x 3 is 0. Now, you consider the Hamilton equation that our Hamilton Hamiltonian Hamiltonian equation including the new stage new state variable including the new state x 3 of t. So, now what is the Hamiltonian function Hamiltonian equation or Hamiltonian function for Hamiltonian function not equation function what is this one h x 3 of t this now dimension is x 3 that means x 3 is also involved x 3 of t then u of t then lambda 1 is equal to lambda 1 because 3 states are there 3 multipliers are there I am writing this one 3 multipliers and then t what is this one see the performing index our that integral the part inside the integral is that one. So, you have to write it this one half u square plus lambda 1 lambda 2 lambda 3 which is a function of time lambda transpose means lambda 1 to this multiplied by the state equations x dot is equal to x plus b u that I am writing state equation that first state equation x 1 dot is equal to x 2 this I am writing now you just say that I am writing this equation this equation x 1 dot this I can write it x 1 dot x 2 dot x 3 dot in terms of a x plus b u form. So, I am writing this multiplied by x 2 of t the next equation x 2 dot is equal to minus 2 x 1 of t plus u of t plus third equation is if you see the third equation this is that one I am writing. So, that is it will lend the expression, but I am writing let us call I am writing with a star and next page I am writing that what is that star that means 3 1 position that is the 3 1 position the space will I will not get it. So, I will write it that 3 1 position then what is this position is that one minus see what I am writing it that one minus x 1 square minus x 1 square u of s. So, I am writing minus x 1 the psi 1 square dot square then what is this one u s is psi 1 x is what minus x 1 of t. So, this minus psi 2 dot square u s and that value is you can write it that psi 2 or you can write it psi 2 psi 2 value is what minus x minus minus x 2 minus 1 that is the psi 2 value then this then third is minus psi 3 square dot u s what is this psi 3 value psi 3 value is x 2 minus 2. So, this is the this is the value of star that means 3 1 position that is the value of star that means 3 1 position that means 3 1 that that is the value of star. So, now you see from this expression what is the Hamiltonian function that half u square t lambda 1 t lambda 1 t multiplied by x 2 lambda 2 to e multiplied by minus x 1 t plus u t lambda 3 t multiplied by star that one. So, I am writing this Hamiltonian function h which is equal to that x of 3 which one x of t u of t lambda 1 t lambda 2 t lambda 3 t and t which is equal to I am writing half u square minus lambda 1. Now, see this one what is the value of lambda 2 into lambda 1 into x 2 lambda 1 into x 2 plus lambda 1 into x 2 plus lambda 2 into what is the value of that lambda 2 this one lambda 2 sigma psi 2 value is what psi 2 value is minus 1 lambda 2 psi 2 value is minus x 2 psi 2 value you just see it here the very psi 2 value is you see the psi 2 value. So, minus x 2 minus 1 so if you take minus common x 2 plus 1 minus specific with minus that square. So, it will nothing but a x 2 plus 1 square u s minus x 2 minus 1 plus x 2 or minus you just see then lambda 3 into that quantity lambda 3 into this quantity and lambda 3 is what just a minute just see this one manipulation. So, lambda 1 x 2 I have written lambda 1 x 2 then lambda 2 this lambda 2 I have written wrong thing here this should be a lambda 2 minus 2 x 1 t plus u of t this is wrong this is x 2 into u s not u s into there is no u s of t this one. So, see this one this lambda 1 into x 2 lambda 1 into x 2 I have written this one then this into this lambda 2 into minus 2 x 1 plus u 2 lambda 2 minus 2 x 1 plus u 2 this then lambda 3 next is lambda 3 lambda 3 is lambda 3 into that 3 1 position is that that one. So, this is the minus lambda 3 t and this will be what psi 1 square means x 1 square psi 1 is minus x 1. So, that square is minus x 1 square u s minus x 1 of t then minus if you take the minus common from this this will be plus psi 2 is your what minus 1 minus x 2 that means if you take minus common and square that will be plus. So, this will be a x 2 of t plus 1 whole square u s minus x 2 of t minus 1 this psi 2 value is see this one if you take minus common x 2 plus 1 then square is I have written then this then next is your psi 3 values psi 3 value is what x 2 minus x sorry x 2 minus 2 x 2 minus x 2 minus x 2 minus x 2 whole square see our equation x 2 minus this square into u s x 2 of t minus 2. So, this is this is the Hamiltonian function we have written now let us call that is the equation number 8 what is the equation number is this is 7 6 this is the equation number 6 we have given no this is the page number and last equation number is 5 and this is 6 and this is the equation number 5 and that is we have given the equation number 6 let us call this is we give the equation number 7 this all boundary condition equation number 7 and this is the equation number 8. Now, we can write our necessary condition the function to be optimized that means control afford to be minimized. So, what is the our problem is minimize with respect to minimize this with respect to all admissible control vector or in our case is a scalar in your case scalar because single input we have considered that u of t belongs to u of a for all t 0 to t f all for all for all t belongs to 0 to t f again that is for constant. So, minimize 0 with respect to all admissible control vector this to obtain u star of t in terms of x of t lambda of t and t. So, let us see what is our necessary condition del h del u of t is equal to 0 and which implies if you see the del h del u if you differentiate this Hamiltonian function with respect to u that means u of t is equal to this term there is no term u here is u. So, lambda of t there is u term is first term and third term no other terms u is involved. So, this will be a u of t is equal to u of t plus lambda t u of t plus lambda t lambda 2 t is equal to 0 and therefore, u of t is equal to minus limit 2 of this. So, let us call this is equation number 9 since our according to the our problem since u of t mod is less than equal to 1 according to our problem is less than equal to our 1. This expression that u of t value will get less than 1 when mod of lambda 2 t is less than 1 when mod of 1 for lambda 2 t is less than 1 when mod of 1 for lambda 2 t is less than 1 when lambda 2 of t mod will be less than equal to 1. So, then what is our control sequence is there suppose if it is a less than 1. However, when u of t when lambda 2 of t mod is greater than 1 the following control minimizes H Hamilton function. What is this? Now look at this is the condition necessary condition is there since we know the mod of u of t is less than equal to 1 this will be less than equal to 1 when lambda 2 mod is less than equal to 1, but there what is the guarantee that lambda 2 always will be less than equal to 1. It may be a situation that lambda 2 of t mod may be greater than 1 in that situation what should be the control law we should adopt. So, to minimize the what is called the Hamiltonian function. So, our control strategy should be like this way this equal to minus 1 for lambda 2 of t when is greater than equal to 1. If it is greater than equal to 1 now you see here if it is greater than equal to 1 now you see I am replacing u is minus 1. So, it is within the limit of that constant 1 control input now this is plus 1 for lambda 2 is less than minus 1, but it is lambda 2 of 2 for if for or if minus 1 greater than equal to lambda 2 will greater than minus 1 is less than equal to 1. So, this is nothing but a set function this is we call. So, we will apply the control sequence like this way if lambda 2 is mod of lambda 2 is less than equal to 1 we will apply whatever the lambda 2 is there we will apply same thing there. Now, if it is if greater than 1 we will switch to minus 1 because we have to make that u of 2 that if you if you greater than 1 we have to switch to minus 1 then u of 2 is 1 when u of what is called that u of 1 minus 1 minus 1 then we will switch to equal to plus 1. So, this is the control so set function this is called set function is defined like this way it is minus 1 when x is greater than 1 x of t it and when x of mod of x t is less than equal to 1 when it is a plus minus this is a plus 1 when it is sorry it is a plus 1 when you greater than this and when it is a this minus 1 when x of t is less than minus 1. So, when it is x of t x of lambda t is greater than 1 this is a plus 1 when this is less than this is minus 1 and this is when it is a this and it will be a simply lambda x of t not this x of t this is the set function we can write it. So, now see this situation when x is greater than 1 when it is greater than 1 we are putting is plus 1 that means u is minus 1 when it is less than x 2 is less than 1 then we are putting with minus minus means plus. So, in this way we are making the control sequence of that one now how to solve this problems our problem is now to solve once again I am telling you this that this is the necessary condition of this one now you see that this we got it lambda. So, u of t will be minus lambda of t so in order to make this thing what is called that mod of u less than 1 the mod of lambda 2 must be less than equal to 1 then we will get it that 1 mod of this less than equal to this, but when suppose lambda of t is positive lambda of t is positive then u is is negative u is coming negative. Suppose lambda of t less than 1, but negative then u of t is coming positive. So, in this way you have to see now when we will do this one now let us see this one lambda 2 is greater than 1 if lambda 2 is greater than 1 then I have to make it lambda 2 if it is greater than 1 then I have to make it with a minus sign sorry I made it this mistake here minus sign because u t is equal to minus of lambda t when lambda 2 is less than 1 less than 1 means that minus 2 let us call again. So, I have to make it is a positive sign u of t is positive 1 I have to switch to positive 1 only. So, because if it is a less than minus 1 that minus minus plus so I have to switch to minus 1 because I have to I need not to cross the limit of bound of 1. So, this behaves like a saturation function is like this way x is greater than 1 is 1 x is less than 1 is this less than minus 1 is minus 1 this is a saturation function. Anyway our problem is when x is in within the range when lambda 2 is within the range minus 1 to plus 1 which switch to lambda 2 and this. So, now next what we have to do it then we have to solve these problems. So, substituting u star in the Hamiltonian function if you put the Hamiltonian function x of t u star of t lambda t whose dimension 3 cross 1 t just I will put is to half u star of t square plus lambda 1 lambda 1 of t x 2 of t plus lambda 2 same thing only u is replaced by x 2 of t u star minus x 1 of t plus u star of t minus lambda 3 of t minus x 1 star of t u s minus x 1 of t plus x 2 t plus I am just repeating the same expression and writing x 1 of t plus u star is replaced by u is replaced by u star of t then minus then is plus x 2 of t minus 2 whole square u s x 2 of t minus 2 this is let us call equation number what is the last is 9 we have 8 we have come 9. Now, this we got it now you find out the state equation the another what is the rest of the necessary condition del h del lambda of t is equal to del lambda of t is equal to x dot of t if you do this one then you will get x 1 dot is equal to x 2 of t x 2 dot is equal to minus x 1 of t plus u star of t plus x 3 dot of t is equal to minus x 1 square of t plus u s minus x 1 of t minus x 2 of t plus 1 whole square u of t minus x 2 of t minus 1 then minus x 2 of t minus 2 minus x 2 of t minus whole square u of s x 2 of 2 this one that is what we will get it this is the state equation and then you find out costate vector equation costate vector equation how will you take costate vector equation then del h del lambda of t is equal to x dot of t minus x 2 of t minus that is your del x of t is equal to minus lambda dot of t. So, just differentiate what is called Hamilton function with respect to x of t and x of t dimension 3 cross 1 then you will write lambda 1 dot of t expression that will be finally, it will come like this way lambda 2 plus twice lambda 3 of t and lambda x 1 of t is equal to minus plus u s minus x of t then lambda 2 dot of t is equal to you will get it minus lambda 1 of t minus lambda 3 of t into 2 x 2 of t plus 1 into that bracket is this one into u s x 2 of t minus 2 this is the x 2 of t minus 1 this is the this is the minus 1 and here also minus 1 then next is your lambda 3 t minus into 2 x 2 of t minus 2 of t minus 2 u s x 2 of t minus 2 this. So, this is the expression similar and then lambda 3 of 3 is equal to 0. So, this is the costate equation we got costate equation state vector equation and we need boundary equation to solve this problem. What are the boundary equations are there boundary conditions are x 1 of 0 is 0 given x 2 of 0 is one initial condition is given then we want to drive the state x 1 at t f is equal to 0 x 2 at t f is equal to 0 then we are not x 3 state at 0 is equal to 0 x 3 t f is equal to 0 this is the boundary condition in addition to this there are boundary condition on where we will get another we will get the that is called for free end point system terminal condition. So, boundary condition for free end point systems. So, that I will write in next class that what is this one and once you know this costate equation you know the what is called the state equation and boundary condition you can solve this problem and depending upon the lambda 2 value if it is lambda 2 mod of lambda 2 is less than equal to 1 then put the u value is minus lambda 2 if it is greater than 1 the lambda 2 lambda 2 is greater than 1 switch to minus 1 and if it is lambda 2 is less than minus 1 switch to plus 1 and in this way you will drive the state into a origin in a minimum control effort if you have a both constant in the control input as well as in the state. So, we will complete this one next class thank you.