The Lagrangian equation (L = T - V) provides a systematic method to derive differential equations for mechanical systems by defining generalized coordinates, kinetic energy (T), and potential energy (V), then applying the Euler-Lagrange equations (d/dt(∂L/∂q̇) - ∂L/∂q = 0). This approach extends to two-dimensional systems, electrical circuits (where charge replaces position, inductance replaces mass, and capacitance replaces spring constant), and systems with external forces (where force is incorporated as -Fq in the potential energy). The method simplifies complex coupled systems, such as the inverted pendulum, by automatically handling constraints and coordinate transformations.
Lagrangian Equation for 2D Systems & Electrical Circuits | NPTEL
Added:[Laughter] [Music] In the last class, we have in the main seen that the differential equations of one-dimensional systems. Uh we could see how these are obtained from the lagenian equation. Let us now go to one stage higher to the two two dimensional systems. Two dimensional means two spatial dimensions. Now let's take as an example a simple 2D system. Here is the constraint, a flat plane with two uh walls and there are two masses. Uh they are linked with a spring and these are also connected to the walls by means of springs. And for the present moment we consider these as frictionless surfaces. Uh in that case how we will define the generalized coordinates. Can you suggest simply the positions of this? Okay. So this is say Q1 and this is say Q2 measured from some kind of a data say here. All right.
uh the moment we have written down these two as the generalized coordinates. So let's write now in terms of these two generalized coordinates we need to write down the kinetic energy and the potential energy.
So let us first write down the T. Pretty simple because this has say a mass m_sub_1 and this has mass m_sub_2. Let this be k1, k2 and k3. Then the kinetic energy is half m_sub_1 q1 dot² for the first one.
+/ m_sub_2 q2 dot² simple. Okay. Uh the potential energy V, the potential energy in this spring will be yes half K1 Q1².
This one is uh and yes Q1 minus Q2. Okay.
Any question?
Ah here there is a question. Okay. Let us uh for the sake of simplicity assume that for the this spring Q1 is measured from its unstressed position and for this spring Q2 is measured from its unstressed position. Huh? You could assume anything otherwise. What will happen is that these will have some constant terms which on differentiation will vanish. Huh? But this is easy way to write that's why we assume that way. So her question was where do you assume the data? Yes. Uh that we could assume anywhere but that would be a convenient way of doing it.
So the lag rangian function is t minus v that would be half m_sub_1 q1 dot² + half m_sub_2 q2 dot² + oh sorry minus -/ k1 q1² -/ Half K3 Q2² -/ is it visible?
Yes.
K2 Q1 - Q2. Now take the derivatives. Sorry.
the L engine with respect to say Q1 we'll have to write we'll have to write the L engine with respect to Q2 we'll have to write the L engine with respect to Q1 dot and we'll have to write it in terms of do this uh from here it is pretty simple affair you can see that the first one is uh this one would be minus K1 and Now here it will be uh minus k3 q2 plus here k2 q1 minus q2 Then with respect to the generalized velocities it is simple m_sub_1 q1 dot and m_sub_2 these are the momenta can you see that q2 dot the moment you have written down this uh remember there will be two differential equations coming out of the lag rangian formulism one along q1 another along Q2 H. So the differential equation along Q1 would be dt of dot minus Fine. Now if you write down it will be uh if you substitute m1 this fellow would be q1 dot because you are taking derivative with respect to time once again and then this would be minus let me copy from here this term plus k1 u1 plus k2 Q2 Q1 - Q2.
Okay.
Happy differential equation along Q2 will be notice the advantage of this formalism that simply by uh substituting Q1 Q2 you get the according differential equation. It will be just substitute this with uh change this two the equation with respect to q2 dot minus lag rang with respect to q2 is equal to z. Substitute you get M2 q 2 dot uh + k3 q2 minus k2 q1 minus q2. So this is the first equation and this is the second equation along two different directions.
Simple H. We didn't have to bother about individual bodies. And you can easily see that if there were n number of bodies, still we could do the same procedure pretty simply here. Let's take another Oh, we have already started doing one 2D problem the last day. Huh? Where were we? Let's see. Do we have Oh, I lost the paper. So that way the pro that day the problem was we took a spring pendulum H and our variables were theta and and if the total when it hangs vertically if the position is like this then this distance was a is it visible?
Yes. And here this distance was a + r. That is how we have defined r and theta are the coordinates. And then we have already written down the leng leng function.
H just recall the lag ranger function in this case was uh half m r dot² + half m a + r² theta dot² minus - half K R + MG by K. We have all done this earlier. So I'm not explaining I'm just writing down so that we can start up from there. Plus I'll just illustrate something that students often make mistake. That is why I'm doing this problem to its completion.
cos theta minus m g a that's what just check third term this is a square huh huh that would be a square fine Okay. So now you start writing the derivatives with respect to the two coordinates. The first derivative that you would write is lag region with respect to R. When you write in terms of R, uh this has to be differentiated. This has to be differentiated. This has to be differentiated. So how do you do it? You write it carefully.
Uh 2 comes forward. So it is m theta dot² a + r differentiated. So it should be a + r h then cancel. So this one comes to this then this one it will be minus k this thing will repeat r + mg by k h and then from here plus mg cos theta uh MGA basically.
Okay. So this is with respect to R. Then with respect to R dot what do you have? This remains. So M R dot enough. Huh? So you can see from these two I can write down the first equation and that would be dt of do lag rangian do r dot minus uh do lengian it would be uh r equal to z.
So substitute the first term will come to m r dot no problem about it h then the next term simply substituted minus m theta dot² a + r + k r + mg by k plus sorry minus plus cos theta = 0. Done. First problem completed.
Second, we write the same things with respect to theta. So, uh, lagian do theta will be well this was the form uh this vanishes, this vanishes, this vanishes. It's only here. Huh? So, it is pretty simple.
What remains?
H only this term.
Huh? It would be Yeah. minus because cos 2 sin mg a + r sin theta. That that does it. Then this term is the dot. Yeah.
Simple.
Okay. So now we have to write the second equation will be ddt of dot minus do theta equal to z. Now this has to be differentiated. Huh? If you differentiate what do you have?
Uh yes. So differentiate this with respect to this with with respect to ddt. You have to take ddt since these are both variables. So you have to do it carefully. That's what I wanted to point out. So you have uh by differentiating this you have m a + r cos² theta dot plus uh then you differentiate this one. So you have twice m theta dot a + r dot dot okay uh minus then it becomes plus yes m gg a + r sin theta = z. Now this is what students often I found in exams miss huh that uh here that both these are time variables and therefore when you differentiate with just time both have to be differentiated that is what often people miss and I have seen hundreds of answer scripts saying that this times theta dot no it's not h that is one pointer that is why I did this problem to its completion so these two are the differential equations of this system. So second equation is this.
First equation was this.
Clear. Notice that these equations are hopelessly nonlinear. Can you see these are not linear equations really? H. So in such simple systems also you are having nonlinear equation that that we'll deal with later.
Now uh okay we need to talk about electrical circuits because so far we were dealing with mechanical systems but we started with saying in our earlier class that the electrical systems are equivalent to mechanical system. You can have almost exact equivalence. So you might ask then it should be possible to do solve write equations for electrical circuits exactly the same way right yes that's true but in that case we what were the steps steps were step number one was that define the generalized coordinates that are consistent with the constants in a mechanical system it easy to see the constants a hanging ball with with the with the wire I can easily see the constraint. H electrical circuit do you see the constraint? Where is the constraint? Oh no no no that's not supply voltage is not the constraint.
Supply voltage is similar to a force.
Huh? That's not a constraint. The constraint is essentially the way the circuit is wired up. Circuit is connected. Some things are connected in series means the two branch currents are forced to be the same. That's a constant.
two lines are connected in parallel the voltages are forced to be the same that is the constraint. Okay. So the point is that uh in electrical circuit the constraints are the way the circuit is connected that impose the the uh the constraints. But now our job is to define the minimum number of position coordinates.
That's what we did in mechanical system.
And what is the equivalent of position in electrical circuits?
Charge. Okay. So we have to deal with charge. Charge is equivalent to the position. So charge becomes the configuration coordinate in electrical circuit. But charge where? Again the the rule was that I have to define the position coordinates the minimum number of position coordinates that uniquely define the positional status of the system. That was what we did in this case also we have to to think in terms of okay the circuit is connected this way. what are the different charges that I need to uh uh need to consider as the minimum number of coordinates H say suppose a circuit is like this um okay there is an inductor there's another inductor there is a capacitor there's a capacitor and there's another capacitor Then there is a charge flowing here.
There is a charge flowing here. There is a charge flowing here.
And what are the minimum number? Now there anything could be taken as the minimum number. But from your first year knowledge of electrical circuits course, you probably have learned that one simple possible solution to this problem is simply to consider the charges flowing in the loops. Huh? Like like so at least it is guaranteed that there would be the minimum number of independent coordinates. H that is what actually matters for us. So let's say we say Q1 is here, Q2 is here.
Simple H Q1 is here, Q2 is here. Say this is L1, this is L2. This is exactly why we did not write the lag engine as L in as in written in many of the physics textbooks. Huh? We wrote it with the script L because we wanted to distinguish from the inductance so that students don't get me mixed up.
C1 C2 C3 H. In this case also we will have to write down the kinetic energy and the potential energy. What is the equivalent of the kinetic energy in a electrical circuit?
No, not the charge. The energy stored in the inductor that is the equivalent of the kinetic energy and the energy stored in the capacitor is equivalent to potential energy because the capacitor has the character of being a compliant element equivalent to a spring. Huh? That is why we have to do it that way. So if that is so then you have your uh t in this case half L1 Q1 dot² Q1 dot is nothing but the mesh current.
Okay.
plus/ L2 Q2 dot² fine V the potential energy notice since we are writing the potential energy as V all the potentials or applied electromotive forces we always will write as E not V H because we don't want to have duplic duplicity of notations. V V is the charge energy stored here plus energy stored here plus the energy stored here.
Energies. How much is the energy here? 1x 2 C1. Notice here the C C is downstairs H in the denominator. 1x C1 into Q1² plus uh 1x uh C2 this will how much is the charge flowing through this Q1 minus Q2 q1 minus Q2 squared how much is the energy stored here 1x 2 C3 Q2² square.
Right? When we have written it the written the T and V this way, we can then write the L engine as half L1 Q1 dot² +/ L2 Q2 dot² minus T minus V 1 by 2 C1 Q1²us 1x 2 C2 q1 Q1 - Q2² - 1 by 2 C3 Q2². Now differentiate same procedure.
Uh strangely you will notice that it is yielding exactly the same equation as this. Is it not?
See here my Can you see all all of them?
Yes. Here my T is half L1 Q1 dot²/ M1 Q1 dot square half L2 Q2 dot square/ M2 dot square exactly the same only M and L are interchanged.
Therefore the kindinetic energy in these cases not only are conceptually the same even in magnitude are the same if provided that you are expressing M and L in the same quantities. Okay. Whatever the units are, V half K1 Q1 Q1 squared 1x2 C1 Q1²/ K3 Q2² 1x2 C3 Q2 squared exactly the same only K1 is equivalent to 1x C C1 K2 is equivalent to 1x C2 and all that and therefore even without writing the differential equations here I can tell you I can tell pretty blindly that it will yield the exactly the same differential equations as this that we have already obtained. Okay. So I don't need really need to write because these two systems are equivalent of each other. These two systems are equivalent of each other. Equivalent in what sense?
equivalent in the following sense that here what will happen if you say move this one and release it will oscillate it will transfer the oscillation here this will also oscillate so there will be some dynamics huh and the dynamics uh you will learn how to actually obtain the dynamics and plot it but it is not difficult to see that there will be dynamics Q1 and Q2 will vary and you can you can draw the waveforms H Q1 and Q2 in this case you aren't really moving something and releasing. What would be the equivalent of moving m1 and releasing? What is the equivalent here? Yes, position is changed which means the k1 is moved. K1 is mean some energy stored initially in k1 which is equivalent to some charge being stored initially in C1. So store some charge and switch it on. You will see that this this system will also oscillate.
The currents and voltages will also oscillate exactly the same way as this one one. And then if the L1, L2 and C1, C2, C3 are numerically the same as this, they will have exactly the same dynamics. H when its uh excursion Q1's excursion reaches the maximum point this current through the inductor its uh or charge through the through the inductor its excursion also reaches the same point H exactly the same dynamics that is why the electrical and mechanical system would be said to be system wise not only element wise system wise equivalent here.
Fine. So far we were considering systems that had only one type of potential either it was a uh we have considered system with gravitational potential. All right. We have considered systems where the potential is represented by a spring and the energy in spring. What about applied force?
If there is an applied force, can it still be uh is still a conservative system? What was the definition of conservative system? We said that if if you can write the force as minus the derivative of the potential function with respect to if you can do that then we say that it is a conservative system.
Now if you imagine here on this suppose I am applying some kind of a force here F that force could be a cinosidal forcing function or something like that but somebody is applying a force here.
Can that force be somehow included in this potential so that this is valid? Hm. Yes, that is true. That means even if there is a externally impressed force then also the system is conservative in the sense that it can be expressed in this form. But how? In that case the rule is that you have to add to the potential function force times the the direction of the generalized uh coordinate. that particular general generalized coordinate along which it is applied. So in this case we'll write v is equal to v is equal to uh f * q1 with a negative sign. Why? You'll soon see that it's necessary in order to set the signs right.
If we write it this way, the the V due to the uh applied force is this much.
Then we have already written the rest of the V. We have already written the rest of the V function. We'll only add if this is applied. Let's do it separately. Now we are talking about the system where And there is a force applied here F.
Here this is Q1 and here is Q2 H. Then what? Uh we have already written the rest of it. So let me write V is equal to K1 Q1² +/ K3 Q2² +/ K2 Q1 - Q2 this is there and this remains sorry square this remains what gets additionally added to this potential function so that the total force is still obtainable from that potential function by simple derivative H what I said is that here you have to add minus f * q1 that's it if you do so let's see what happens to the the lag engine equation the lag engine uh would be the kindinetic energy remain is the same. So I'll directly write the lag engine. It was half m_sub_1 q1 dot squared plus sorry half m_sub_2 q2 dot squared minus/ k1 q1 squared -/ k3 q2 squared minus/ k2 q1 - q2² plus fq1 one right because this is minus it becomes plus. Now when we write the lag engine with respect to Q1 what do you have now? Uh here minus K1 Q1 here. Uh what was it earlier? Let me just refer to that here. Earlier it was this huh minus K2 Q1 minus Q2. Now this will be added to that. So it would be plus fine but that will not happen if you differentiate with respect to Q2. So that remains the same minus K3 U2 plus K2 U1 minus Q2.
Okay. Now you write the first equation, first differential equation. These two remain the same as earlier. So when we write the differential equations, it will be M1 Q1 dot as usual. But then this one has to be written. It will be uh plus k1 q1 + k2 q1 - q2 h minus f =0. See that the science have been right because this is mass into acceleration. This is the force applied on it by the springs and this is the force applied externally. H. So that is how the equation is written which is right. The second equation remains exactly the same.
uh it will be m_sub_2 q2 dot uh + k3 q2 - q k2 q1 minus q without any difference. So it is trivial to take into account the external forces. What will happen if we want to do the same thing in electrical circuit?
The external force is equivalent to a battery externally applied emf. And what will be the equivalent of this? A force being applied in the Q1 direction. What is what is equivalent to that? A source. Notice notice here here is the M1 which is equivalent to the L1. And what is the character of this force?
This force shares the same velocity with M1. And in order to in order for that to happen in the electrical circuit, you have to apply a battery here. That's it. So if you really have a battery here and it's uh applied voltage is E in that case the equation and the process of derivation of the equation will exactly be the same. So in that case what we will do?
We will argue that here E is applied in the direction of the generalist coordinate Q1 and therefore with the V we will have minus E * Q1 that's it clear so that is how we will write the differential equation fine let us solve uh relative relatively difficult problem which has an applied force on it and which is a very practically relevant problem.
Slowly we are going into uh engineering problems. Uh have you seen ever launching of a uh spacecraft a rocket for example you must have seen in the in the TV right? So how does it happen? The spacecraft is launched. All right. But initially it has to be held there and it is held there with the help of braces.
Right? If the braces are there and it fires the whole thing will break off.
Right? So that cannot be allowed. So the braces have to come off. If it comes off then the rocket will fall. Right? So how to prevent rocket from falling? What happens is that down there there is actually a vehicle-l like thing. H there is actually vehicle- like thing uh which is allowed to move and that moves and thereby keeps it vertical. It's like a inverted pendulum. H the pendulum is vertical and here this point is allowed to move and it is actually a a control system enabling which you keep it vertically and then you fire. That's why it remains vertical and then it goes off. That is how the rocket launching is normally done.
And to to model such a thing, let us model the inverted pendulum problem.
Huh? So inverted pendulum problem is where you have the base along with the wall and there is a cart with wheels. Mhm.
And the pendulum is like this.
Say normally this could be a you know mass could be uniformly distributed. But let's assume for our simplicity that this is a a a mass concentrated at the top H. And here is another mass. Uh this will also has mass. So let's this be m1 and this will be m_sub_2 and then you have to apply force here in order for this to uh move and balance it. So that force is f. Okay. Well in this case how would you define the generalized coordinates? There are two generalized coordinates. one position of this fellow which has to be measured simply from the wall. You can be it can be measured from the wall and this fellow's position can be measured in terms of the angle.
uh either you call u this as q1 and this as q2 or if you want to retain the the physical things theta then let's call it x then it would be easier x and theta but in our case it is essentially q1 and q2 position coordinates now we are all set to write down the the differential equations so so the generalized coordinates in this case X and theta.
Fine. Now, uh potential energy, the kindinetic energy T kindinetic energy would be a combination of the two kindinetic energies. kinetic energy of this one and the kinetic energy of this one. For this one, it is simple half m_sub_1 then x1 dot square x x dot square. For this one, it is a bit complicated because it has a circumferential motion. There is no radial motion. All right? But that circumferential motion has to be broken into two components X and Y and X has this additional X dot added to it. Uh there are there are two components really. So uh the horizontal component is horizontal component of this motion if this is L then L theta dot is the circumferential motion. L theta dot uh cos theta would be no horizontal component and L theta dot sin theta would be the vertical component. The vertical component is unaffected by this motion. The horizontal component has this motion added to it. Simple. So that way we can write down the T. Okay. So what what will it be? The horizontal component would be uh plus/ m1 will uh sorry m_sub_2 m_sub_2 uh it would be l theta dot cos theta l theta dot cos theta uh plus x dot right? Yes. L theta dot cos theta is huh uh plus x they add up huh square plus/ m2 l theta sin theta l theta dot sin theta h square.
O yes, this is the kindinetic energy completed. Potential energy. H uh potential energy are there because of two components. One because of gravit gravitational energy in m_sub_2. This does not have any gravitational energy.
Moves horizontally. But also there will be another component of the potential due to F.
Fine. Uh so what will be this quantity?
It would be M g L cos theta theta. Now F is being applied in the direction of X. X increases in this direction. F is also applied in this direction. So it will be minus fx clear what?
Uh-uh. M2.
Yes. Now uh there will be a term here that will vanish.
There will be one term coming out of this that will have cos square theta and here is sin square theta and they will add up to one. So this can be simplified h just simplify that. So let us write down the lag engine. Lag engine is half m_sub_1 x dot². Let's break that that up. Half m_sub_2 L² theta dot² cos² theta +/ m_sub_2 x dot² plus uh half goes of m_sub_2 l theta dot cos theta X dot right I have broken up just check if I have written correctly I have just expanded this square H plus/ M_sub_2 L theta dot sorry I'll not write it l² theta square sin² theta minus m_2 g L cos theta plus fx that is the total lag h now you notice that uh this fellow and this fellow huh uh this term gets common cos square + sin square so I'll just drop this term and drop this term I can do that so it becomes relatively simpler expression for the lang now we We will need to take the derivative of the lagen with respect to x. It will be this goes off. This goes off. This goes off.
Simple. H.
Now we have m_sub_1 x dot from here this goes off here this remains.
So plus m_sub_2 x dot right this one remains but this is a complicated stuff differentiate it properly. H uh plus M2 L theta dot cos theta right. So okay let's uh write the other one before proceeding. No let me write the equation from here.
The equation would be then ddt of lag rangian with respect to x dot minus lang with respect to x equal to zero.
Now when we expand it when we expand it it will be write the ddt of this correctly write the dd of this correctly huh no I'm write saying this because most students make a mistake here huh write the dd of this correctly it will P M1 uh + M2 X dot H uh plus Yes. M2 L cos theta theta dot minus right now we have to differentiate this m_sub_2 l theta dot sin theta yeah sin theta theta dot square Oh.
Oh. Huh. Right. Uh, so this is the derivative of this. Now we have to write minus this.
So that would be - f =0. Done.
H. Next one.
uh derivative of lagrangian with respect to theta is if you do it with respect to theta.
Can you see the expression? Yes. This goes off. This goes off. This goes off.
This remains this remains. H. So take the derivative correctly. It will be minus m_sub_2 l theta dot sin theta x dot. Fine.
uh plus m_2 g l sin theta and with respect to theta dot is with respect to theta dot is this term remains this term remains uh m2 l² theta dot + M2 L cos theta x dot right now again take the derivatives properly when you uh write this it properly here we have this uh the first time is simple m_sub_2 l² theta dot no problem here next time we'll have problem plus m_sub_2 l cos theta x dot minus m_sub_2 l x dot sin theta the dot huh uh then plus this one. So plus m_sub_2 l theta dot sin theta x dot minus m_sub_2 g l sin theta equal to zero. Does anything cancel off?
No. Third and the fourth they cancel uh m2 cancels off. Huh? So it is actually simpler equation theta dot l theta dot plus cos theta x dot minus g sin theta =0. Does the other equation simplify? Huh? No. Okay. So that is the equation then. Good. So this is how the equations are to be written. Remember this if you try with any other method would be enormously complicated this particular problem. Huh? So that is why the strength strength of the lag engine approach becomes salient in these kind of problems. Okay. Thank you.
Up Next

Understanding Standing Waves and Harmonics in Music
@crashcourse
833.9K views•2016-08-11

21cm Hyperfine Transition in Neutral Hydrogen: Radio Astronomy Basics
@AaronRobertParsons
12.4K views•2011-10-13

Ceptr Oscillations & Stability in Stars: Gamma Condition
@IITKanpurNPTEL
334 views•2021-04-16

Entropy and the Second Law of Thermodynamics Explained
@veritasium
27.5M views•2023-07-01
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Physics

![[물리를 이해하며 함께하는 수학, 무리함수] Lagrangian의 정의로부터 Euler-Lagrange equation까지](https://i.ytimg.com/vi/rNgZ9apqeMw/maxresdefault.jpg)
![2 - Mecánica Teórica [Euler-Lagrange 1]](https://i.ytimg.com/vi_webp/_6vYEdTQxCs/maxresdefault.webp)






















![[MAI][Ejemplo] Función de Disipación de Rayleigh para el Péndulo Elástico](https://i.ytimg.com/vi/n1c37ttY1zU/maxresdefault.jpg)






![Linear Quadratic Regulator (LQR) Control for the Inverted Pendulum on a Cart [Control Bootcamp]](https://i.ytimg.com/vi_webp/1_UobILf3cc/maxresdefault.webp)






