 So, last class we have explained what is bank bank control with an example of a numerical example. Let us recap that or review that problem bank bank control problems. Let us call our system is given by x dot is equal to a x plus b u, u is the control input. So, our problem is we have to minimize the performance index that is a 0 to t f d t and this is t f that minimum within minimum time the initial state of the system. The control input should be such that initial state of the system will drive to the origin in a what is called with a maximum and minimum value of its control signal magnitude wise both the signals are same. So, this and also our control input constant is given that means the magnitude of u should not be greater than equal to 1. It cannot be greater than 1 this is the constant on input signal is given. So, ultimately our problem boils down to transfer the initial state x 0 to the final state in a minimum time t f that is the thing. So, we will proceed as we have considered earlier form a Hamiltonian function with the knowledge of the state equation. We form the Hamiltonian function that h is equal to this and this is the equation number 1 that 1 plus lambda t x t lambda 2 t of u t. Note this expression 1 is a Hamiltonian function that is expressed in terms of linear terms of u h is a linear terms of u. So, if you differentiate h with respect to u the u terms will not present in that. So, we will not be able to find out that u expression for this one and not only that that u is our case is bounded by a constraint that means u of t more u of t is less than equal to 1. So, if you now write the costate vector lambda dot this del minus del h of del x of t is equal to this from that our first costate vector is this and second costate vector from this expression. If you differentiate with a partial differentiation of h with respect to x you will get this one. Now, from this expression you see that lambda 2 dot is equal to lambda 1 dot and from lambda 1 dot is equal to a constant term lambda 1 with 0. By this one we can see that lambda 2 expression it depends on the initial value of lambda 0 and lambda 1 0 and lambda 2 0. And since I mentioned you earlier that if you differentiate partial differential of this with respect to u there will be no u terms is involved in the expression because the h is a h which is a function of u is not non-linear terms is exist in h of in non-linear terms of u is present in h. So, what we have to do now we have to do we cannot write it that because u is a discontinuous function either you are switching to 1 or minus 1. So, we cannot differentiate this with respect to u and assign to 0. So, what we can do it we can minimize point is on minimum principle we can apply it. Now, see this term I can make it negative with the choice of lambda is what if lambda 2 this value is let us call negative then we have to consider that u of t is 1. So, this product of this one remains what is called negative if lambda 2 is positive then u of t you have to switch to minus 1 that means this product will remain negative. So, with this procedure that we can minimize the what is called the Hamiltonian function in this one. So, this this plot is a signum function of u of t not u of t lambda 2 of t lambda 2 of t signum function of this we are plotting this one next. Now, let us see as we told you this function will be minimum when lambda is lambda of t less than 0 will switch to u is 1. So, this product will be a negative. So, if I put this that u of star is positive then what is the state equation boils down we will see x 1 dot is equal to x 2 and x 2 dot is equal to u star of t u star I put it 1. So, now from this equation I can write it that the solution of this one is that one. Similarly, x 2 x 1 dot is equal to x 2 and x 2 solution I know this I expressed it here. Now, so if you now indicate this one with respect to d t then x of t is equal to x 1 of 0 this is what is called this x of x of 0 t is equal to x and this is t square by 2 and after simplification this we will get this equation. So, x 1 t is equal to x 2 square x 2 square by 2 plus x 1 0 minus x 2 square 0 by 2 and this is the constant term that depends on the initial condition of the state where it is. So, this is nothing but a if you see the equation 6 is nothing but a parabola equation with a constant term c 1 is there. Similarly, if we apply if we switch the control is u star in minus 1 if I minus star minus 1 then our equation x 1 dot is equal to x 2 x 2 dot is equal to minus 1 and the solution of x 2 from this equation is this and again solution of x 1 dot x 1 dot is equal to this which solution of x 1 of t is finally, this one for u star of is minus 1. Now, see this equation also equation 7 also a parabolic equation with a constant term c 2 different c 2 that also depends on initial value of x 1 and initial value of x 2. Now, these two equation now question is when we will switch to u star when we will switch to u star is equal to when we will switch to u star is equal to 1 and when we will switch is equal to minus 1. So, that the Hamiltonian matrix is minimized with a from the sense of one contagion minimization that Hamiltonian function. So, let us now read out this one to explain more clearly about this figure. So, if you see this one. So, this is the equation that is what if you see this is the equation x 1 t is equal to x 2 square of t by 2 plus x 1 is equal to x 1 0 minus x 2 square 0 by 2 which equal to denoted by a c 1 for is equal to when it is plus similarly. So, this is the equation of the parabola similarly, when u which switch to u with minus 1 signal then solution f x 1 is equal to minus x 2 square t of 2 plus c 2 this is your c 2. So, this is also another what is called parabola. So, let us draw these two parabolas assume that c 1 is 0 let us call x 1 dot x 2 dot in that x 1 0 x 2. So, we have selected in such a way. So, that c 1 is 0. So, it is simply a parabola parabola equation which passes vertex passes through origin. So, this is the equation if you see this is the equation for a parabola when the control signal is switch to u is equal to plus 1 and this is the trajectory of x 1 in this direction x 1 and in this direction is x 2 of t. Now, for another initial condition different initial the c 1 let us call is positive greater than 0. If it is a positive if you bring it here then x 1 minus t minus c 1 c 1 is I have considered positive that means value of c 1 x 1 when x 1 is equal to c 1 then this vertex will pass from across the x x is this one and this is the parabola when c is I am now drawing sequence of parabola when c is greater than 0 c 1 is greater than 0 and it is increasing c 1 is increasing in this direction c 1 is increasing that this is for c greater than 0, but u is equal to plus 1. Now, c less than 0 that means when c this quantity is negative if you bring it to this one x 1 plus c 1. So, some value of x 1 which is negative that vertex will cross the x axis agree this this. So, and when it is a so this is our this is our parabola when u is positive, but c c 1 value is negative. We have selected that initial condition is such that c 1 is negative. So, this is the case is when c c 1 c 1 is less than 0 agree c 1 is less than 0 this is for this equation. Now, for this one when we switch the control input minus 1 then this is the equation of that parabola or trajectory between the phase plane of x 1 x 1 versus response is by given by this one. Again in the similar way we can say when c 2 is 0 then this is the equation of parabola agree this is the equation of parabola which shows by. So, this curve is c 2 is this curve is c 2 is 0 agree. Now, c 2 is positive quantity let us call c 2 is positive quantity then x 1 minus c 2 in reference side then what value of x 1 what value of x 1 this left hand side will be 0 some positive value over there. So, c 2 positive is this curve parabola and c 2 greater than 0 c 2 greater than 0 is this curves and when c 2 is negative when c 2 is negative then x 1 plus c 2 that means it will this parabola will cross the x x is in the negative directions. So, this is the this is c 2 is less than 0 and this is all the curves c that is c 2 is greater than 0. Now, this is the trajectory we have done for when the control input switch to plus 1 and when the control input switch to minus 1 this switching what is the proper way of sequence we have to switch plus u is equal to plus or u is equal to minus. Let us call we have a trajectory here let us call we have a trajectory we have a initial point is here somewhere here that is our that is our x 1 of 0 and x 2 of 0 this is our initial point x 1 of 0 and x 2 of 0. Now, question is whose direction whose direction the trajectory will move or at that point whether we will switch to u is equal to minus 1 or we will switch to u is equal to plus 1. Now, if you see here if you switch the u is equal to plus 1 if you switch u is equal to plus 1 then our trajectories if you see that our trajectory at this point u is equal to plus 1 is like this way. So, when it is plus 1 u is equal to plus or the trajectory is like this way now x 2 is positive x 2 positive means x 2 positive if you see the basic equation of this one x 1 dot is equal to our case is x 1 dot is equal to x 2. So, our basic equation x 1 dot is equal to x 2. So, our basic equation is x 1 dot is equal to x 2. So, if x 2 is positive then x 1 tends it will increase it it will go this side. So, it can go this side again x 1 is positive sorry x 2 is positive again it will increase. So, the trajectory will go from initial condition away from the origin. So, at initial initial point we have to if you switch to u is equal to minus 1 then trajectory was is the blue one. So, this that means this one it will follow this curve because u is equal to minus 1 this is that trajectory for this one. So, if you follow this one then you see this is that it is why when x 2 is negative as x 2 is positive x 1 dot is positive it indicates x 1 dot. So, x will increase then x 2 is decreasing and x 2 is decreasing, but its value is positive still it is increasing. Now, when it is x dot is negative here x dot is negative. So, x should decrease it. So, it is decreasing. So, when it hits here when it hits here when it hits at this point at this point you have to switch to u is equal to plus 1 then trajectory will move along this one. So, our optimal time required to drive the state from this point to origin is that this is the optimal rather I can draw it this is the optimal trajectory. It will hit this one u is equal to this indicates this trajectory it approaches to 0 when c 2 when this is the c you see this one the c is 0. So, this is c 2 so c 1 is equal to 0. So, it will come this one and it will go like this way and it will come origin in this one. So, this is the optimal trajectory in minimum time it will reach to origin if it is. Now, similar logic you can put any point in the trajectory any point in the what is called phase plane agree you have a initial condition is there where it will switch initially and final stage where it will switch whether u is equal to minus 1 or plus 1. So, we will summarize the results our things like this way. Let us consider that our c is equal to 0 there are two parabolas are there agree when c 1 is 0 it passes to origin when c 2 is 0 it also this parabola also passes to the origin. The segment of two parabolas the two portion of segment of this parabola passes through the origin and this equation we can write like this way. The segments of you see the segments of two parameters two parabolas segments of two parabolas this is the one parabola and this is the another parabola which is passing through the origin for c 2 is equal to 0 and this is for c 1 is 0 segments of two parabola through the origin form a switching curve. So, this is our switching curve. So, this is the our switching curve now what is the equation of this one and what is the equation of this one when c 1 is 0 if you see the when c 1 is 0 our equation is just I am writing when c 1 is 0 our equation is x 1 of t x 2 of t this plus c 1 which is equal to I assume 0 for u is equal to plus 1 and this is x 1 t is equal to minus x 2 square t by 2 plus c 2 this equal to 0 for the u is equal to minus 1. So, this two equation is nothing but this equation of this equation of this one and equation of this one. Now, I want to write this is our switching surface or switching line. So, this two equation commonly I can write it now if you see that s is equal to switching this x 1 of t plus half x 1 x 2 square of t plus x 2 of t sign signum function of that x 2 of t look this expression when x 2 is when x 2 is positive when x 2 is positive this is the switching surface when x 2 is positive in this region in this region x x 2 is along the surface x 2 is positive is here x 2 is positive x 2 positive here. So, when x 2 is positive that means sign of this positive and this is also positive. So, x 1 plus t plus this one then in this case the x 1 t plus s s x 2 square by 2 this is expression when x 2 expression that means when x 2 is positive it is represent this surface when x 2 is negative when x 2 is negative that negative sign will come that means x 1 minus half x 2 square. So, x 1 if you take this side minus half 2 square it represent this parabola means when you switch to use plus 1 that means this is the u plus 1. So, where we want to switch one so I just these two equation also one can write it x 1 t plus half x 2 t plus mod x 2 of t this and this equation are same. So, that switching surface suppose any point on this surface any point on the surface s is equal to what 0. So, therefore, any point on the switching surface s is equal to 0. So, now, if a point here what is the value of s a point is here if you look at this expression if you look at this expression that s will be greater than 0 how now you see suppose it is the point is here. So, x 2 a point is here x 2 is what negative x 2 is negative x 2 negative means this is negative x 1 minus this. So, u is equal to plus 1 that x 1 minus this equal to 0 now it is just below this one or anywhere below this line or above this not below above this line anywhere above this line this is the switching line anywhere above this line you can see from this expression you can see from this expression that s is greater than 0. So, we will write so now we will define as function of time a function of x is equal to x 1 of t plus half x 2 of t. So, x 2 square either you can write signum of x of t or it is same as x 1 of t plus half x of t mod x 2 this is 2 2 of t. So, if s is greater than 0 s is greater than 0 what does it mean this means s is greater than 0 this means that it is above the switching surface above the above the switching surface. So, x t lies above the switching surface. So, this is the A O B this switching curve I define the name is A 0 O and this is B this is the A O B above the and in this case if it is a if the initial condition above the switch is now I make a conclusion in initial condition if it is above the switching line above the switching line that means anywhere here then initially you switch to u is equal to minus 1. Again if you switch to minus 1 suppose it is here it will switch to minus 1 it will come here and it will hit here then it will go to the origin here suppose it is the initial condition is here. So, it will come to this one you have switch to minus 1 it will come here hit here and when it hits the switching surface then you put u is equal to plus 1. So, it will go like this way so the two switching you have to do it. So, now I am writing this is above the thing in this case u is equal to minus 1 if x is above the switch to minus 1 because or you write it switch to u is equal to minus 1 because the blue is the blue curve because the blue curve parabolas are directed towards the switching curve that means when it hits the switching surface then you switch to plus 1. So, our switching is minus 1 plus 1 when if the initial point above the switching surface that means if the our initial state above the switching surface first you switch u is equal to minus 1 then when hits the switching surface then switch to u is equal to plus 1 then your state will drive to origin in a minimum time. So, now if s is less than 0 from this figure from this equation you can see if s is less than either of this or this you can see if s is less than 0 x t lies below the switching a u b in that situation you switch first to see here suppose it is below the this one some point here. So, you first switch to u 1 if you switch it and this is the curve you switch to 1 then it will follow this one and once it follows this one it hits here the switching curve and when it hits switching curve u is equal to minus 1 and then it will follow like this way. That means if it is there it will move like this way this way and then it will come back to this one. So, switch to first switch to u is equal to plus 1 because the red curve parabolas are directed towards the switching curve. So, our switching is plus 1 minus if it is below the switching first you switch to plus 1 u then you switch to u is minus 1. So, this is our sequence. So, that is what we have discussed last class then. So, if you see recall our switching curve is that one is our switching curve this is c 1 is 0 and this is the c 2 is 0 and this is for u 1 u is plus 1 again and this is u is minus 1 and this is the switching curve when trajectory hits here it will go along this one if it hits here it will go along this one. So, if it is above the initial condition is above the switching curve then first you switch to u is equal to minus 1 then it will hit here when it will hit here this is u is equal to plus it will go to the origin in this fashion. So, this is your switching curve for this one. So, that is the that is we have discussed last class is done. Now, how to implement now tell me this one if it is whether it would lies here or not how you check it check is there you find out the value of s if the value of s x s s expression we have given it this is x expression you find out the value of x if s expression is very small let us call mod of s is less than 10 to the power of minus 4 and not only this one and if you see x is if it is less than this and x 2 is x 2 is greater than 0 if it is x 2 is greater than 0 then if x 2 is greater than 0 this is the x 2 if x 2 is greater than 0 that means which one here x 2 is greater than in this that in this switching region x 2 is greater than 0 and s is along this curve the s is 0 is very very small that means mod of s is less than 10 to the power of minus 4 like this then you switch to what is called u is equal to minus 1. Similarly, if s is 0 and x 2 is negative x 2 is negative then you switch to u is equal to plus 1 again. So, another situation you can write if s is equal to 0 say mod of s is 10 to the power of minus 8 something is equal to mod of s and x 2 of t is greater than 0 that means x of t means x of t means x 1 t x 2 t lies on the if this and x 2 is this this is x 2 lies on the switching curve a o s is 0 and s is greater than j that means it is lies on the switching curve this is if s is 0 mod of s is equal to 10 to the power of minus 8 and x 2 of t less than 0 then x t is equal to minus 0 that means x 2 of t curve lies on the switching curve on the switching curve b o this one this is mod of s very low, but x 2 is negative then it is lies to the switching curve. So, in this way you can check it then when you will switch to the u plus or u minus starting from u plus when you will switch to the u minus that you can check by satisfying this condition. So, now our next topic briefly I will just tell you know how to implement this control law you have to see how to implement that control law. So, you have a plant you have a plant and plant is given plant a x dot is equal to x 2 and x 2 dot is equal to u minus u of t and this is our control law we have generated how it will generated that will show control law. That means u star of t and this is our state x of t which is equal to x 1 of t and x 2 of t and this is we have taken with the knowledge of this two states we are implementing this. So, this is the implementation of you can say the figure is implementation of bank bank controller bank bank controller by a state feedback. Now, what is u we have selected u of t is equal to minus 1 I will select u of t is minus 1 when u of t is minus 1 when s of x t is greater than 0 agree s of x t is that means above the switching surface if it is there then switch to when this and then plus 1 when this is s when s of x t is below the switching surface and plus 1 will switch when again will do when x s of this mod of this is less than equal to epsilon and epsilon is let us call 10 to the power of minus 8 and x 2 of t is less than 0. So, you just write x 2 of t is less than 0. When x of a is greater than 0 then drive and then state will directed to the what is called to the switching surface and then you consider then from this one you write this is next this if. So, when it will hit the switching surface I will check whether it is hit or not as value should be very small 10 to the power of minus n and x 2 minus it will be negative. So, minus 2 plus it is switched again it is switched to place when s of x t is less than 0 and it will be switched to minus 1 when s of t is less than equal to epsilon and x 2 is greater than 0. So, this way you have to write the logic to switch that one. So, how will you implement in a this things one can see more clearly suppose we have a second order system what we have considered that is one by s that another is one by s then this output this is your u star of t and this output will be x if you see x this output will be x 2 because x dot is x 2 dot is equal to u. So, this is x t and this output of this one will be x 1 of t and this this is going here and from there we are taking a signal which is half x 2 half and another we are taking this signal this is absolute of x 2 of t function and this two outputs is multiplied this t signal is multiplied. So, I am at half x 2 then this signal absolute builder of this is multiplied this is the multiplied then this signal is going to the summer and this is our this x 1 this is our input not input that is our signal and that signal if it is a minus 1 then you it a delay. Now, you see this one this is our s. So, this is our s that x 1 plus half x 2 s 2. So, half x half x 2 into mod of x 2 this and this signal this is summed and this signal multiplied by minus 1. Now, I am checking that one if it is a greater than this signal if you consider this signal is z if this signal is greater than 0 then this is plus 1 if it is greater than less than 0 it will be a minus 1 and this output is the output of that one. Now, see this one I told you this that signal function is taking care of that one and then it is a ideal delay is kept it. So, this signal if it is if this signal multiplied by this minus 1 if it is a greater than 0 then it will switch to 1 and if it is less than 0 then it will switch to minus 1. So, this is the implementation of that control algorithms for bank bank control. Now, if you see this one that this s I have implemented here up to this. Now, question is what if s is positive I told you the if s is positive then you switch to minus u. So, if this is positive if s is positive you switch to minus 1. So, if it is a this signal if you directly put it then it will switch to 1 that is why you have multiplied by minus 1. So, it should take care of u is equal to if s is negative then it is switch to plus 1 if s is positive it will switch to minus 1 that one. So, now next is our topics that what we will consider we have considered the constrain input signal. There may be a situation where the state variables also we make constrain on the state variables then how to solve such type of problems that means constrain in control input state variables. So, our problem is considered one controller is subject to saturation that means u of t absolute value of u of t is less than equal to belongs to rather belongs to u of a for all t belongs to t 0 to t f. So, we made a constrain on the u that means that u belongs to that u of a and also second condition on the constrain on the state variables the constraints on the state variables that constrain in let us call we have a there are l constraints are there in the state variable out of n state there are n constraints are let us call n l constraints are there x of t x of t comma t this is less than equal to 0. So, our first constrain is that one equation number one second constrain is this equation number two. So, and we are assuming that psi is continuously differentiable with respect to x that psi psi is continuously differentiable with respect to x of t that is. So, we have a problem let us call x dot is equal to a x plus b u then we have a constraint on the u that u mod of u let us call scalar input mod of u belongs to u of a is given then this is the constrain on control input then state variables we have a state variables and constrain let us call x 1 may be greater than 0 and x 2 may be range minus 2 2 plus 2 all this constraints are there and that psi of this function is differentiable that one. So, our technique is the simple technique is convert this thing into a inequality constraint convert into a equality constraint. So, a technique is to convert to equation number two into equality constraint. So, what we did it we introduce a new state variable we introduce new state variable new state variable n plus 1 th new state variable. Suppose we have a system whose dynamic system matrix a whose dimension is n in n that means x x of t whose dimension is n cross 1. So, you have introduced a new state variable this and u has a let us call u of a the scalar quantity 1 cross 1 scalar quantity. So, we have introduced that one we have introduced that x n plus 1 dot is equal to f n plus 1 of function. What is this one that what is the constant equations are there psi 1 x of t of t this whole square into another function u s of psi 1 of t this is minus there are the another constraints are there psi 2 plus 1 of t x of t comma t whole square psi 2 of this. In this way we have a l constraints are there psi l x of which is a function of x psi is a function of x and t square psi x psi l dot 0 this this. So, let us call this is equation this is equation where u s psi i of x of t of t this is is a strict unit function unit step function and it is defined at u s is equal to psi of x t of t is equal to 0 when value of that constant value x of t this and this is less than equal to 0 for what is this is the constant when this constant less than equal to 0 then this is 0 and this is equal to 1 for psi of x t of t greater than 0 and i is equal to 1 2 dot dot l. So, this is equation number 4. So, now see this one x n plus 1 star of t is less than equal to 1 star of t is less than equal to 0 when it is less than equal to 0 from 3 and 4 from 3 I write it from 3 and 4 from 3 and 4 when this is is equal to less than equal to this if it is if it is less than equal to 0 if this constant is less than equal to 0 then this term is less than equal to 0 less than equal to 0 this then this term will be what if this is less than equal to 0 then u s value will be what this is a positive quantity less than equal to r 0 but this but is preceded with negative. So, it is a negative quantity, but u s of is if it is less than 0 then it is a unit step strictly unit step. So, this value is 0 this value is 0 this value if all this function is less than equal to 0 then this equal to 0 for all t now x n plus 1 dot t is equal to 0. Now, tell me when it will be 0 this quantity will be 0 when if this is greater than 0. That means, psi of this is greater than so if this is greater than 0 let us call then psi of this what greater than 0 this 1 and this will be a let us say. So, this if it is this is less than equal to 0 then psi of this that is u f is 0. So, if it is a negative quantity let us call this is negative quantity this is positive but this quantity is 0 and this quantity is similarly if all the when it will be a less than equal to 0 this is 0 this is 0 no and when it will be when it will be less than equal to 0 let us call when it will be when psi is let us say when psi is greater than 0 when psi is greater than 0 then this quantity is positive this is negative. But this quantity is 1 this quantity is 1 this quantity is 1 for that psi of s dot is value is 1 for when psi i dot is greater than 0. If psi i is a greater than 0 then this quantity is 1 1 1 all are negative all are negative. So, this is 0 for all t and this equal to 0 only at those times when all the constraints psi i of x t of t is less than equal to 0 if it is less than equal to 0 this is because it is may be 0 negative this is a negative quantity but this quantity is 0. So, this will be 0 for all values if it is less than equal to 0 psi 1 is less than 0 psi psi 2 is less than 0 then this quantity is 0 for all times. But if this is not equal to less than 0 it is greater than 0 then if it is greater than 0 then this quantity is 1 this is negative it is always greater than equal to 0 for all t. So, we will stop here today next class will continue this course once again.