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.

### Course: Multivariable calculus>Unit 3

Lesson 5: Lagrange multipliers and constrained optimization

# Lagrange multiplier example, part 2

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

## Want to join the conversation?

• if this is how we get the maximum how do we get the minimum?
• Please correct me if I am wrong, but there seem to be several aspects for the minimization problem:

1) If you keep the constraint: Switch R(h,s) for a new function, R'(h,s) = - R(h,s), and optimize using this new function R'(h,s). By optimizing the negative of the function you would get the smallest possible value of R(h,s) given the whole budget being used.

2) If you abandon the constraint: Set your h = 0 and s = 0, which would be the trivial solution to minimization problem in this case.
• Can we divide both gradients by their magnitudes instead of using the LaGrange multiplier?
• I think you actually can! However it would result in worse expressions most of the time and lots of algebra involved.
• I get the process, but if the value (2000/3, 10/3) is our sole critical point. How do we know whether it is actually a maximum or minimum given the budget constraint?
• We can choose other values for s and h (for example s = 1, h = 900) that still satisfy the constraint and then see what the output of the function is. f(900, 1) = 9322, while f(2000/3, 10/3) = 11400. Hope this helps!
• This video was quite fun to watch. When will there be exercises to practice?
• I did not get, why Grant is multiplying 3/200 ?
• Assuming that the part you're asking about is at , Grant was simply using some algebra to isolate the u^1/3 variable to make it easier to work with.
• So there are two things I'd like to know:
1. what happens if the maximum of the function is in the middle of the circle? Because then , the gradient of the circle will not point into the same direction as the functions gradient.
2. If I look up the same method on the web, I allways find, that the Lagrange function is kind of the gradient(f) PLUS gradient(g) = L. How is it, that they add instead of substract?
• is this limited to two variable inputs or we can extend it to more input variables?
• You can normally extend it as long as it is possible (there may be extra rules like each function actually has first order derivatives, etc).

This is because a vector/function of n variables will have a gradiant vector of n components. We will also have the constraining function, resulting in a system of at max n variables, but n+1 equations, which is generally solvable, unless no solution exists of course (which wouldn't be due to a lack of equations necessarily.

But there are at least common examples for a 3 variable function. This power point for example shows a 3 variable function: http://tutorial.math.lamar.edu/Classes/CalcIII/LagrangeMultipliers.aspx
- [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.