<s>[INST] Optimization problem Kuhn Tucker i'm stuck on this problem because i don't know what to do next
$$\begin{cases} \text{maximize } &f(x,y) = -(x-2)^2-(y-1)^2 \\ \text{subject to } &g_1(x,y) = -x-y+1 \leq0,\\&g_2(x,y) = x^2+y^2 \leq 1 \\ \end{cases}$$
Since we are in a compact set we can use Kuhn Tucker conditions :
$\lambda_i \geqslant 0$
$L(x,y,\lambda_1, \lambda_2) = -(x-2)^2-(y-1)^2-\lambda_1(-x-y+1 )-\lambda_2(x^2+y^2 -1) $
Let's start with $\lambda_i \neq 0$
\begin{align} \ \frac{dL}{dx} &= -2(x-2)+\lambda_1x-\lambda_22x = x(-2+ \lambda_1-2\lambda_2 ) + 4 = 0\\ \frac{dL}{dy} &= -2(y-1) + \lambda_1y-2\lambda_2y = y(-2+\lambda_1-2\lambda_2) +2 = 0 \\ \frac{dL}{d\lambda_1} &= -x-y+1 = 0 \\ \frac{dL}{d\lambda_2} &= x^2+y^2-1=0  \end{align}
I found this $ x = \frac{-4}{-2+\lambda_1-2\lambda_2}$ $y = \frac{-2}{-2+\lambda_1-2\lambda_2}$
I don't know what to do, any help will be appreciated
 [/INST] Consider for your Lagrangian instead with $f = -(x-2)^2-(y-1)^2$
$$
L(x,y,\lambda_1, \lambda_2,s_1,s_2) = f+\lambda_1(-x-y+1+s_1^2 )+\lambda_2(x^2+y^2 -1+s_2^2)
$$
Here $s_1, s_2$ are slack variables to transform the inequalities into equations.
The stationary points are the solutions for
$$
\nabla L = \left\{
\begin{array}{l}
 \lambda_1=2 (\lambda_2-1) x+4 \\
 \lambda_1=2 (\lambda_2-1) y+2 \\
 \lambda_1 s_1=0 \\
 \lambda_2 s_2=0 \\
 s_1^2+1=x+y \\
 s_2^2+x^2+y^2=1 \\
\end{array}
\right.
$$
so we obtain
$$
\left(
\begin{array}{ccccccc}
f & x & y & \lambda_1 & \lambda_2& s_1^2& s_2^2\\
 -4 & 0 & 1 & 4 & 2 & 0 & 0 \\
 -2 & 1 & 0 & 2 & 0 & 0 & 0 \\
 -2 \left(3-\sqrt{5}\right) & \frac{2}{\sqrt{5}} & \frac{1}{\sqrt{5}} & 0 & 1-\sqrt{5} & \frac{3}{\sqrt{5}}-1 & 0 \\
\end{array}
\right)
$$
Here $s_k = 0$ means that the corresponding restriction is actuating. The stationary point with the highest value is represented in the last row. We can verify that the second restriction is actuating. Follows a plot showing in black the level surfaces for $f(x,y)$ in black the $\nabla f$ at each stationary point and in red $\nabla g_1, \nabla g_2$ for each restriction. As we can observe, the stationary points located at the chord extrema, are not feasible maxima because doesn't verify $\nabla f = \mu_1\nabla g_1+\mu_2 \nabla g_2$ with $\mu_1 \ge 0, \mu_2 \ge 0$. The stationary point located over the sector circumference is a feasible maximum because there we have $\nabla f = \mu_2\nabla g_2$ with $\mu_2 > 0$

</s>