1
$\begingroup$

I have a function $y(x)$, that I would like to maximize, subject to two constraints. It is given by:

$$ \max_{x} \ y(x) = a \ cos(x) + b \ sin(x) \\ \text{subject to:} \\ x \geq 0 \\ x \leq \frac{2}{3}\pi $$

($a$ and $b$ are just scalars).

Anyway, I am not really sure how to constrict this lagrangian for this problem, given the constraints. I can solve the problem without constraints, but with those constraints, one that is less than, and one that is greater than, I am getting confused as to how to set the problem up.

How do I set up the lagrangian here?

Thanks.

$\endgroup$
  • $\begingroup$ Why do you need a Lagrangian ?. $\endgroup$ – Felix Marin Mar 2 '14 at 0:40
  • $\begingroup$ @FelixMarin Hi Felix, I am new to this, but I was under the impression that for the constraints here, I need to form a lagrangian before taking its derivative... $\endgroup$ – Spacey Mar 2 '14 at 0:40
2
$\begingroup$

Well, your problem is one-dimensional, so you don't need a Lagrangian. The only possible extremal points are those where $y'(x)=0$, and the end-points $0$ and $2\pi/3$. So you don't take any derivatives for the end-point, you simply compute the values.

You would need a Lagrangian for the boundaries, but only in more dimensions, for example when optimizing a function over a polygon in $\mathbb R^2$.


If you insisted in constructing the Lagrangians, then the one for the right boundary is as follows: The boundary condition is $g_1(x)=x-2\pi/3$, therefore your Lagrangian is $\Lambda(x,\lambda_1) = f(x) - \lambda_1g_1(x)$. Now you solve $\frac{\partial\Lambda}{\partial x}=0$ to find out that it has always got a solution $\lambda_1 = \frac{\partial f}{\partial x}$. We are not really getting anything reasonable, are we?


To show a different example, let's optimize $f(x,y)$ over the domain $y\geq0$ and $y\leq x^2-1$. This is a piece of plane with boundary consisting of two curves and two points. Now the maximum is maximum of:

  • $f(x,y)$ over the interior (solve by basic calculus);
  • $f(x,y)$ over $y=0$ and $x\in(-1,1)$ (solve by Lagrangians);
  • $f(x,y)$ over $y=x^2-1$ and $x\in(-1,1)$ (solve by Lagrangians);
  • $f(-1,0)$ (one point, so nothing to do);
  • $f(1,0)$ (one point, so nothing to do).

So you see, it's a lot of work. I'll just show the Lagragian of the parabola. You have $g(x,y)=x^2-1-y$ and $\Lambda(x,y,\lambda_1)=f(x,y)-\lambda_1 g(x,y)$. Now you search for $\lambda_1$ and $x,y$ such that: $$g(x,y)=0,\quad \frac{\partial\Lambda}{\partial x}=0,\quad \frac{\partial\Lambda}{\partial y}=0.$$

$\endgroup$
  • $\begingroup$ Hmm... ok, that's news to me! :-) So how would I solve this problem with those constraints? (I can already easily solve it without the constraints, by taking derivative of the objective, set to zero, check sign of second derivative, etc). Its this part with the constraints that I am wondering about. $\endgroup$ – Spacey Mar 2 '14 at 1:08
  • $\begingroup$ Well, you simply search (by the derivatives method) for maxima inside $(0,2\pi/3)$, let's call it $y_M$. Then the maximum you look for is simply $\max(y_M, y(0), y(2\pi/3))$. $\endgroup$ – yo' Mar 2 '14 at 1:13
  • $\begingroup$ You mean just solve normally, and then just pick the result between $0$ and $\frac{2}{3}\pi$ inclusive? I thought there would be a more analytical way of doing it, no? $\endgroup$ – Spacey Mar 2 '14 at 1:16
  • $\begingroup$ Also I thought we always form a lagrangian anytime we have a constrained optimization problem from my understanding of the google links... $\endgroup$ – Spacey Mar 2 '14 at 1:19
  • $\begingroup$ @Spacey This is analytical. You always need to treat the boundary seperately. Remember that $y(x)=2x$ has to global maximum, still it has a maximum in $[0,1]$, attained at $2$. You can actually construct Lagrangians for each of the boundary point, but the domains of these are single points, so it's a non-sense to do. $\endgroup$ – yo' Mar 2 '14 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.