If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Lagrange multiplier example, part 2

Finishing off the example from the previous video. Created by Grant Sanderson.

Want to join the conversation?

Video transcript

- [Instructor] So where we left off we have these two different equations that we wanna solve and there's three unknowns. There's s, the tons of steel that you're using, h the hours of labor, and then lambda, this Lagrange Multiplier we introduced that's basically a proportionality constant between the gradient vectors of the revenue function and the constraint function. And always the third equation that we're dealing with here to solve this, is the constraint itself. That gives us another equation that'll help solve for h and s, and ultimately lambda, if that's something that you want as well. So it's kind of a first pass here, I'm gonna do a little more simplifying but I'm gonna make a substitution that'll make this easier for us. So I see s over h here, and they're both to the same power, so I feel it might be a little bit easier if I just substitute u in for s divided by h. And what that'll let me do, is rewrite this first equation here as 200 thirds, 200 thirds times u to the power of one third. And that's equal to 20 times lambda. And then likewise, what that means for this guy, is, well, this is h over s, not s over h, so that one's gonna be 100 thirds, not times u to the power of two thirds, but times u to the negative two thirds because we swapped the h and s here. So that's u to the negative two thirds and this is just to make it a little bit cleaner, I think. We kind of want to treat h and s in the same package. Now I'm gonna go ahead and put all the constants together and then I'm gonna take this guy and multiply it by three divided by 200, multiply both sides of that just to cancel out what's on the left side here. And what that's gonna give me, and I'll go ahead and write it over here, kind of all over the place, u to the one third is equal to, let's see three over 200, so that 20 almost cancels out with the 200, it just leaves a 10, so that's gonna give me three tenths of lambda. And then similarly over here, I'm gonna take this full equation and multiply it by three over 100 and what that's gonna leave me with is that u to the negative two thirds, u to the negative two thirds is equal to, let's see this 2,000 when we divide it by 100 becomes 20, and that 20 times three is 60, so that'll be 60 times lambda. Alright, so now I want a way to simplify each of these, and what I notice is they look pretty similar on each side, you know it's something related to u equal to lambda, so if I can get this in a form where I'm really isolating u, that would be great. The way I'm gonna do this is I'm gonna multiply each one of them by u to the two thirds, so I'm gonna multiply it into this guy and I'm gonna multiply it into that guy, because on the top, it's gonna turn this into just u, which will be nice, and on the bottom it'll cancel out that u entirely. So it feels like it'll make both of these nicer, even though it might make the right side a little uglier, those right sides will still kind of be the same, and we'll take advantage of that. So, when I do that to the top part, like I said, that u to the one third times u to the two thirds ends up being u, and then on the right side we have our three tenths lambda, but now u to the two thirds. And then on the bottom here, we, when I multiply it by u to the two thirds, the right side becomes one, 'cause it cancels out with u to the negative two thirds, and the right side is 60 times lambda times u to the two thirds. Now these right sides look very similar, and the left sides are quite simple. So I'm gonna multiply this top one by whatever it takes to make it look exactly like that right side. So in this case I'm gonna multiply that top by 10, which will get it to three, and then by another 20 to make that constant 60, so I'm gonna multiply this entire top equation by 200, and what that gives me is that 200 times u is equal to 60 times lambda times u to the two thirds. And now these two equations, these two equations have the same right side. So this is the same as saying, 200 times u is equal to, well, one. Because each one of those expressions equals the same complicated thing. And now 200 times u, well that's s divided by h. So this is the same thing as saying 200 times s over h equals one, which we can write much more simply as h is equal to 200 times s. Great, so I'm gonna go ahead and circle that, h is equal to 200 times s. And now what we apply that to is the constraint, is the 200 times h plus 2,000 times s equals our budget. We'll go ahead and kind of write that down again. That are 20 times h, I think, 20 times the hours of labor plus $2,000 per ton of steel is equal to our budget of $20,000, and now we can just substitute in. Instead of h I'm gonna write 200 s, so that's 200, sorry, 20 times 200 s, 200 s, plus 2,000 times s is equal to 20,000. And now this right side, 20 times 200 is equal to 4,000, and I'm just gonna go ahead and kind of write so this here is 4,000 s, so the entire right side of the equation simplifies to 6,000, 6,000 times s is equal to 20,000 and when those cancel out, what that gives us is s is equal to 20 divided by six, which is the same as 10 divided by three. So that's how many tons of steel we should get. S is 10 over three, then when we apply that to the fact that h is 200 times s, that's gonna mean that h is equal to 200 times that value, 10 over three, which is equal to 2,000, 2,000 thirds, 2,000 thirds, that's how many hours of labor we want. So, evidently in our original problem, where we have this model for our revenue function for our Widgets with $20 per hour of labor, and $2,000 per ton of steel, with a budget of $20,000, the allocation that you should make is to buy 10 thirds of a ton of steel and 2,000 thirds hours of labor.