# Thread: Question about Lagrange multipliers for maximizing a function with two constraints

1. ## Lagrange multiplier for maximizing a function with two constraints?

Hi everyone.

I'm not that familiar with English math terminology so I hope that you'll bear with me.

Currently, I'm trying to maximize a function with two constraints, but I got stuck because of one of my constraints. My first constraint has both the variables $x$ and $y$, but my second constraint only has the variabley. The reason why I'm confused by this is that when I proceed to solve the problem, I have no use for the Lagrange multiplier $\lambda$. I can simply solve $L_{\lambda_{1}} = 0$ and $L_{\lambda_{2}} = 0$. This will enough to yield my results (the $x$ and $y$ coordinates). It is frustrating me because I need to put it into words, what I am doing (in terms of using Lagrange multipliers) and why I apparently had to skip the $\lambda$ all together.

The function that I'm trying to maximize is as follows:
$f(x,y) = -0,01x^2 + 395x + 100y$

My constraints are these:
$2x + y = 44,000$
$y = 20,000$

I know that the correct answer (through using other methods of optimization) is:
$x = 12,000$
$y = 20,000$

The way that I've proceeded to solve this problem is by putting the respective functions and constraints into a formula that was taught at school:
$L(x, y, \lambda_{1}, \lambda_{2}) = -0,01x^2 + 395x + 100y - \lambda_{1} * (2x + y - 44,000) - \lambda_{2} * (y - 20,000)$

I then proceed by figuring out the partial differentials of $L$ with respect to $x$, $y$, $\lambda_{1}$ and $\lambda_{2}$ to ultimately isolate $x$ and $y$. I am getting the correct results, but there's no need to solve $L_x = 0$ and $L_y = 0$. This is what's confusing me and what I'm having a hard time putting into words.

3. Originally Posted by tkhunny
$L_x = -0.02x + 395 - 2\lambda_{1}$

$L_y = 100 - \lambda_{1}$

$L_{\lambda_{1}} = -2x - y + 44,000$

$L_{\lambda_{2}} = -y + 20,000$

4. -0,02x -- but that doesn't seem to have bothered anything, since your complain is why this equation even exited.

You should not be disturbed that the solution is simple. $\lambda_{1}\;and\;y$ are immediate. Part of the idea of the method is to turn harder problems into simpler problems. Using the method, we've gone from quadratic to linear. This is good!

The difficulty is this, using $\lambda_{1}\;and\;x$, we get x = 9,750, but using $y\;and\;x$, we get x= 12,000. How do you suppose we should reconcile that?

5. Originally Posted by tkhunny
The difficulty is this, using $\lambda_{1};and\;x$, we get x = 9,750, but using $y\;and\;x$, we get x= 12,000.
Very interesting! I haven't even thought about using the partial derivatives of L with respect to λ1 and x to isolate x.

My immediate guess to solve this "new" problem would be to plug x = 9,750 into the partial derivative of λ1 and isolate y, which would yield the result y = 24,500. This new coordinate (9,750; 24,500) on my graph looks to be on the same linear function y = -2x + 44,000 as the initial coordinate (12,000; 20,000). Obviously, however, this solution does not adhere to my constraint of y < 20,000.

6. Originally Posted by tkhunny
How do you suppose we should reconcile that?
I suppose the solution would be to compare the different values of x and y and pick the combination that fits the constraints?

7. Originally Posted by johndoe69
Hi everyone.

I'm not that familiar with English math terminology so I hope that you'll bear with me.

Currently, I'm trying to maximize a function with two constraints, but I got stuck because of one of my constraints. My first constraint has both the variables x and y, but my second constraint only has the variabley. The reason why I'm confused by this is that when I proceed to solve the problem, I have no use for the Lagrange multiplier λ. I can simply solve the partial differential for λ1 and λ2. This will enough to yield my results (the x and y coordinates). It is frustrating me because I need to put it into words, what I am doing (in terms of using Lagrange multipliers) and why I apparently had to skip the λ all together.

The function that I'm trying to maximize is as follows:
𝑓(𝑥, y) = −0,01𝑥2 + 395𝑥 + 100
Well in English terminology this function is a constant equal to $494.9999.$

Or is it supposed to be a function in which the variable y appears or perhaps even two variables such as x and y?

My constraints are these:
2𝑥 + 𝑦 ≤ 44,000
𝑦 ≤ 20,000
Well, in English terminology, both constraints are incomplete. Two plus what?
What does not exceed 20,000?

I know that the correct answer (through using other methods) is:
x = 12,000
y = 20,000

The way that I've proceeded to solve this problem is by putting the respective functions and constraints into an algorithm:
L(x ,y, λ1, λ2) = −0,01𝑥2 + 395𝑥 + 100y - λ1 * (2𝑥 + 𝑦 - 44,000) - λ2 * (𝑦 - 20,000)
In English terminology, this sort of looks like a LaGrangian function for a DIFFERENT objective function. The original objective function contained no variables, but this seems to involve an objective function containing the variable y (but not x). But it is meaningless because the Lagrangian multipliers are simply multiplying constants and so their derivatives will be zero everywhere.

Then finding the partial differentials of x, y, λ1 and λ2 to ultimately isolate x and y. I am getting the correct results, but there's no need to find the partial differentials of x and y?
To use LaGrangian multipliers, you set up the function L, take ALL of its partial derivatives, set them ALL to zero, and solve the resulting system of simultaneous equations.

If you have one constraint, you have one multiplier, usually labeled $\lambda$.

If you have n constraints, you have n multipliers, not n + 1, and they are usually labeled

$\lambda_1,\ ...\ \lambda_n.$

8. Originally Posted by JeffM
Well in English terminology this function is a constant equal to $494.9999.$

Or is it supposed to be a function in which the variable $y$ appears or perhaps even two variables such as $x$ and $y$?
I suppose I should add some context to the problem. The function $f(x, y)$ is a contribution margin function where $x$ and $y$ are variables of two separate products. It is made up of two price functions for each product minus the variable costs. Product $x$ has different options for pricing, while product $y$ only has one available price point. This is why the one is linear and the other is constant.

What I'm trying to accomplish is to find the optimal amounts of both $x$ and $y$ that are within my constraints. The constraints are the restrictions set by a hypothetical factory, which produce the products $x$ and $y$.

Originally Posted by JeffM
Well, in English terminology, both constraints are incomplete. Two plus what?
What does not exceed 20,000?
The production time mustn't exceed $44,000$ hours. Product $x$ has a production time of 2 hours per $x$ and product $y$ has a production time of 1 hour per product $y$​.
The amount of $y$ produced mustn’t exceed $20,000$ units.

Hopefully that should've cleared up some things about the problem.

EDIT 1: I have a suspicion that the functions aren't showing up properly for you? Perhaps it's because I haven't used the LaTeX formatting? I shall try to rewrite my main post at some point soon.
EDIT 2: Done.

9. That is MUCH better.

The objective function is the contribution margin:

$c(x, y) = -\ 0.1x^2 + 395x + 100y.$

I shall assume that this is correct. Obviously, it is to be maximized. But it is subject to two constraints, namely:

$2x + y \le 44,000 \text {; and}$

$y \le 20,000.$

Now, as you have explained the problem so far, these two constraints do not make much sense to me, but I am going to assume that they do make sense when the problem is fully specified. I should point out that you probably also have non-negativity constraints, but let's ignore that little wrinkle.

Let's dispense with one minor source of confusion. There is a LaGrangian multiplier for each constraint. If there is only one constraint, the multiplier is conventionally shown as $\lambda$. If there is more than one constraint, they are conventionally distinguished by subscripts. So with two constraints, you will have $\lambda_1$ and $\lambda_2$ but no $\lambda$. Is that clear?

So we set up the LaGrangian function as you did (assuming those are the correct constraints).

$L = -\ 0.01x^2 + 395x + 100y - \lambda_1(44,000 - 2x - y) - \lambda_2(20,000 - y).$

We now take all four partials and set each to zero. It is frequently convenient to start with the lambdas in order of simplicity.

$\dfrac{ \delta L}{ \delta \lambda_2} = 0 \implies 20,000 - y = 0 \implies y = 20,000.$

$\dfrac{ \delta L}{ \delta \lambda_1} = 0 \implies 44,000 - 2x - y = 0 \implies 2x = 44,000 - 20,000 \implies x = 12,000.$

So in this case, we do not even need to take the other two partials.

EDIT: I wish I felt more confident about this. I do not know how you came up with the objective function or the constraints. I have got you to the answer that you say is correct, but I cannot confirm it.

10. As I read what you have written, I must assume that the objective function is:

$c(x, y) = -\ 0.1x^2 + 395x + 100y.$

But I see only one relevant constraint, namely $2x + y \le 20,000.$

How did you derive the two constraints?