Now, let's talk about constrained dynamical systems. We keep jumping back to quaternions, what about quaternions like? Well, there are often reasons why we might want to have a redundant set of coordinates, and we can avoid singularities, especially from attitude dynamics, with redundant sets of coordinates. How do we handle that? But also if you have a multi-body system, I'd have to write out the 16-link system and something is coming in and then it ducks all of a sudden. To do it all in a minimal set is very unwieldy or may not even be possible at that point, versus if you can say, look, here's a six staff system subject to these two corners are hinged with a spherical joint, how do we do that? Then we can write this out. Let me see. I want to jump back to the very basics of what we were doing. We wrote virtual work here as the force dotted with the miscible variations. That was the work done. If this thing wasn't here, but here this force is acting on it, what work could have been done there? Now, in this part, we're going to have something that's going to look similar but different, and I'm not sure why we have different letters. But instead of f dotted with virtual displacements, we have f minus ma, which is what we did with Domo bears. This is also still called the virtual work, but it's a different W Domo what we have defined earlier. That was the work on a particle. Here it's force minus the accelerations dotted with that. I just wanted to give that leap, when I call it virtual work typically done that way in the text, but it's a different virtual work than what we're seeing earlier. To find this way, if this has to be zero, you can find there is a function W whose first variation must go to zero. Where else have we seen that? To find the answer we look for, the first variation has to be zero. Remember optimization? We had a function Phi, which could have been how much money can you make in gambling or whatever? It could have been anything. For Phi, to find an extremum of Phi, what must be true of Phi? The first variation. Yeah. The first variation of Phi had to be zero. It's like y is equal to f of x, and to find the flat spots, you have to find y dots. The derivative's going to zero. It's always the case. Think of it this way, so we have this function here, what this means is we're really finding the dynamics become an extremum point of this W function. That's how we get these equations of motion. Now, when we did this earlier, we assumed these were minimal. When we have variations in position and position was written in terms of generalized coordinates x, y, Theta, who knows? Then you did a partial, and we expanded that so that they'll also come in here, so this is f dotted with these partial velocities times Del q, I factored out Del q. This bracketed term is really looking a lot like Kane's equations, virtual power form that we had. I'm just jumping through several steps, go right into. This is what we had, and then this would have to be zero if what can be said about these Del q_j's. Ricardo, I haven't talked with you today. When we were doing earlier, we argued the big bracket had to be zero individually. What had to be true of these variations in generalized coordinates? They have to be independent of variations. Another way to say it, they have to be independent? Yeah. I can vary x independently from R, independently from Theta, because then I can't have the summation go to zero if those bracketed terms must be zero times any variation plus zero times any variation. That's only true if the variations are independent. If all of a sudden I move x and that affects where my Theta variations can be to satisfy some constraint, well, then those are not independent, and therefore this wouldn't hold. When we did this, this became your generalized force. For the Lagrangian, for example, we're going to focus on the Lagrangian approach, but I want to say, for generality, you could do the same thing with Pfaffian and the other ones as well. I'm not going to go through those steps. I'm going to show you the constraint formulation for Lagrangians and how we derive them. If we derive this for the Lagrangian at all this stuff with some manipulation was nothing but this Lagrangian operator on kinetic energy and you plug that in, we got this bracket. This is an alternate way to derive Lagrange's equations, really. If all the variations Del q_j are independent, then that's it. That's the answer. This will give you n differential equations for an n degree of freedom system. Cool. But what if they are not independent? You're particles moving on a circle so your x, y, and z coordinates are now dependent. I cannot arbitrarily change all three of them and be compliant. But also, this is the first variation of this W function of this virtual work definition up there. We're trying to find the extremum point of this W function subject to these variations, but we can impose constraints on the variations. How did we solve that with our general optimization section we discussed? What did we ended up doing to Phi? Josh, you remember? We derived the Lambda of Phi. Yeah. We have the augmented cost function. We ended up being Phi plus Lambda times Psi, and Psi was some constraint that had to be imposed in a holonomic form using dynamics language. But that was done in a very general mathematical, nothing really dynamic specific. We ended up with a constrained optimization with an augmented cost function. Let's look at that. This is if we had independent, but now they aren't. Let's look at our constraints, and we're going to use them in Pfaffian form, because every holonomic constraint if R minus l must be zero, I can take derivative and say that R dot must be zero. I can always take a holonomic constraint and turn it into a Pfaffian. By looking at the Pfaffian formulation, I've included both types of constraints all in one. We had it defined this way that you had some the rates appeared linearly with some sensitivities domain that was they are the terms that appear, and then you had something that didn't have rates in it and in general form. Those all have to sum to zero. Along our trajectory that differential ones is basically dq dt you multiply times dt. This gives you your differential motion including time. How would you move through there? But if we're looking at instantaneous displacements, it's only displacements in states, not time. We're not considering ourselves to be three seconds in the future all of a sudden. We're just thinking out right now what we've resolved if I would have just gone to the left one inch and these forces are acting on it? In that case, this is what we had earlier. For the Pfaffian part, these constraints to satisfy this to first order, must abide by this equation. Here we had dots, we don't have dots anymore, because we went through this step. This now tells me you have little n number of coordinates and m constraints. This gives me m algebraic equations that must be satisfied. With quaternions, we had one that was the sum square of all the quaternions had to be one, that was your constraint equation. That's essentially what we have here. If you took variations of that and you could plug it in, you would have all the right A's. Good. Now we have our constraint form, this is our Psi function in our optimization review that we did. If we want to optimize the Phi, and here is not just how to maximize your gambling return in Vegas but it is really a dynamic system so we're picking generalized coordinates, there is something we're trying to find an extremum for and then you do the partials and you get this and subject to some constraints and we have to take the first variation of that constraint and set it equal to zero, which we have here. There's more partials, and you'll recognize now from the holonomic and Pfaffian discussion, these partials are nothing but the A_kj components when you expand that. If you had holonomic constraints, you would take the partials to get this. If it's a Pfaffian form, you're already given the A_kj terms that you need. Now, when we solve this, we ended up writing, we didn't define the extremum of the cost function, we defined the extremum of the augmented costs, where for m number of constraints, you would have m Lagrange multipliers times that, and you found the extremum of this. Now we have not just the generalized coordinates but also the Lagrange multipliers. You take the partial of the augmented with respect to the coordinates but also with respect to the Lagrange multiplier. You regain the constraint equations that must be satisfied plus these partial equations. This gave you a differential algebraic equations we have to solve to find the extremum. We did this. We did some examples on solving that. But that's what we can use now. Instead of finding variation of Phi being equal to zero, we're simply going to say the first variation of W that we defined has to be equal to zero subject to this is my first variation of holonomic constraints. This is the same thing that we need for Pfaffian and we can put those in right away. How do we solve that? Then the extremum that you're going to find is this is what we had before that would give you the unconstrained equations of motion but constrained we have to add Lagrange multipliers times Del q_j that was what we would have here in that. Then this part gave us the Lagrangian dynamics unconstrained. This term gives you a constraint forces that will make sure your marbles are rolling on a table or whatever it has to be. We have to add that one term that's what we're doing here, and I'm using the Pfaffian notation, so I have the kj matrix written out. Now the equations of motion, this looks the same, this looks the same plus this is essentially your constraint forces. What force makes you roll on a surface? What force makes your particle move in a circle if it's attached to a string that you're trolling over your head? That's essentially where this comes. We've seen earlier examples where we just did Newtonian mechanics plus constraints that look very similar. Here you can see a rigorous proof of why we have now a constrained optimization that we're doing and we get our equations of motion. This will give us little n differential equations plus m algebraic constraints, and yes there's a dot here. The reason this is algebraic in this form is because the differential equations are double dots, and then everything else, states and rates, are just that's the rest of the states. For second-order system, this is considered the algebraic part, not the differential. This is the differential. This gives you your equations. How do we solve these? You've seen this before when we did the pendulum in terms of x and y coordinates subject to a constraint. You might have to differentiate the constraint. Here it's already once differentiated. If we differentiated it one more time, you could plug in these, solve for the Lambdas, and then back solve for the x double dot y double dot equations. There's ways to substitute it to general forms. We'd have to solve for the Lambdas and these because we have a constraint dynamical system. We no longer have to use minimal coordinate sets, which is nice. This is the T, and of course as before, if you have conservative stuff, nothing really changes, we can replace T with the Lagrangian operator, script L, and then this q would have to be the non-conservative part that remains. Be careful not to put your gravity force both in the generalized big Q and the V function because then you're double counting gravity and you won't get the right stuff. We can do that. That's an alternate form of this, instead of T, we have the Lagrangian. It just this q has a slightly different definition, it shouldn't include conservative stuff. Any questions?