How do I setup the lagrangian for this problem?

958 Views Asked by At

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.

1

There are 1 best solutions below

6
On BEST ANSWER

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.$$