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

#### 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:
(, ) = −0,012 + 395 + 100

My constraints are these:
2 + ≤ 44,000
≤ 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,012 + 395 + 100 - λ1 * (2 + - 44,000) - λ2 * ( - 20,000)

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?

#### JeffM

Re: Question about Lagrange multipliers for maximizing a function with two constraint

$2 + \le 44000$ means what? Is there supposed to be a variable in there?

$\le 20000$ does not mean anything. There is nothing on the left hand side of the inequation.

If you have two constraints, you will have $\lambda_1$ and $\lambda_2$ And no $\lambda.$

But of course you are not multiplying your lambdas by anything except a constant so they have no effect on anything.

Please indicate what the constraints are, and we can proceed from there.

#### HallsofIvy

MHF Helper
Re: Question about Lagrange multipliers for maximizing a function with two constraint

The original post does not seem to have been edited but I see "$$\displaystyle 2x+ y\le 44000$$" and "$$\displaystyle y\le 20000$$".

#### JeffM

Re: Question about Lagrange multipliers for maximizing a function with two constraint

The original post does not seem to have been edited but I see "$$\displaystyle 2x+ y\le 44000$$" and "$$\displaystyle y\le 20000$$".
Actually I do not even see a function with variables.

#### HallsofIvy

MHF Helper
Re: Question about Lagrange multipliers for maximizing a function with two constraint

I see (minus some strange characters) the object function $$\displaystyle f(x, y)= -0.01x^2+ 395x+ 100$$ which, oddly, is a function of x only!

johndoe69, differentiating the object function minus $$\displaystyle \lamda_1$$ and $$\displaystyle \lambda_2$$ times the constraints with respect to $$\displaystyle \lambda_1$$ and $$\displaystyle \lambda_2$$ just give the constraints again which does not really help- you already know them. It is the derivatives with respect to x and y that are crucial! I do not understand why you say "there's no need to find the partial derivatives o x and y" (I assume you mean "with respect to x and y).

#### johndoe69

Re: Question about Lagrange multipliers for maximizing a function with two constraint

Yes, I see that there's been some problems with the formatting and some "spelling" issues when writing the equations. I'm not used to using LaTeX, but I'll try to rewrite some of the confusing things. Is there a way to edit/delete my original post, or do I have to write another reply to this thread?

EDIT: For now, I suppose I'll add it to the rest of this reply:

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 $$\displaystyle x$$ and $$\displaystyle 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 $$\displaystyle \lambda$$. I can simply solve $$\displaystyle L_{\lambda_{1}} = 0$$ and $$\displaystyle L_{\lambda_{2}} = 0$$. This will enough to yield my results (the $$\displaystyle x$$ and $$\displaystyle 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 $$\displaystyle \lambda$$ all together.

The function that I'm trying to maximize is as follows:

$$\displaystyle f(x,y) = -0,01x^2 + 395x + 100y$$

My constraints are these:

$$\displaystyle 2x + y \leq 44,000$$

$$\displaystyle y \leq 20,000$$

I know that the correct answer (through using other methods) is:

$$\displaystyle x = 12,000$$

$$\displaystyle y = 20,000$$

The way that I've proceeded to solve this problem is by putting the respective functions and constraints into an algorithm:

$$\displaystyle L(x, y, \lambda_{1}, \lambda_{2}) = -0,01x^2 + 395x + 100y - \lambda_{1} * (2x + y - 44,000) - \lambda_{2} * (y - 20,000)$$

Then figuring out the partial differentials with respect to $$\displaystyle x$$, $$\displaystyle y$$, $$\displaystyle \lambda_{1}$$ and $$\displaystyle \lambda_{2}$$ to ultimately isolate $$\displaystyle \lambda_{1}$$ and $$\displaystyle \lambda_{2}$$. I am getting the correct results, but there's no need to solve $$\displaystyle L_x = 0$$ and $$\displaystyle L_y = 0$$?

My partial derivatives are as follows:

$$\displaystyle L_x = -0.02x + 395 - 2\lambda_{1}$$

$$\displaystyle L_y = 100 - \lambda_{1}$$

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

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

Last edited:

#### romsek

MHF Helper
Re: Question about Lagrange multipliers for maximizing a function with two constraint

You've set $L$ up correctly

$\nabla L = \left(-2 \lambda _1-\dfrac{x}{50}+395,-\lambda _1-\lambda _2+100,-2 x-y+44000,20000-y\right)$

and each term must be set to 0 and the system solved .

The partials with respect to the $\lambda$'s are just the constraint conditions.

This system is easily solved as

$(x,y,\lambda_1, \lambda_2) = \left( 12000,20000,\dfrac{155}{2}, \dfrac{45}{2} \right)$

#### Idea

Re: Question about Lagrange multipliers for maximizing a function with two constraint

The method of Lagrange multipliers (with two constraints)

max or min $$\displaystyle f(x,y)$$ subject to the constraints $$\displaystyle g(x,y)=0$$ and $$\displaystyle h(x,y)=0$$

The constraints are supposed to be equations not inequalities

So how can we apply Lagrange multipliers if the constraints are inequalities?

Last edited:

#### johndoe69

Re: Question about Lagrange multipliers for maximizing a function with two constraint

The constraints are supposed to be equations not inequalities
Yeah, so what’s happened there is that I’ve copied over the inequalities from a different method of optimization. But yes, the inequalities are supposed to be equalities for the sake of using Lagrange multipliers.

#### Idea

Re: Question about Lagrange multipliers for maximizing a function with two constraint

Yeah, so what’s happened there is that I’ve copied over the inequalities from a different method of optimization. But yes, the inequalities are supposed to be equalities for the sake of using Lagrange multipliers.
so now the problem becomes trivial
because the solution of the system of equations

$$\displaystyle 2x+y=44000$$

$$\displaystyle y=20000$$

is a single point $$\displaystyle (x=12000,y=20000)$$

no need for Lagrange multipliers or anything else to find the max/min of f