<s>[INST] Finding the maximum value of a function on an ellipse Let $x$ and $y$ be real numbers such that $x^2 + 9 y^2-4 x+6 y+4=0$. Find the maximum value of $\displaystyle \frac{4x-9y}{2}$.
My solution: the given function represents an ellipse. Rewriting it, we get $\displaystyle (x-2)^2 + 9(y+\frac{1}{3})^2=1$. To find the maximum of $\displaystyle \frac{4x-9y}{2}$, $x$ should be at its maximum and $y$ at its minimum. Solving the equations, I get that $x = 3$ and $\displaystyle y = -\frac{2}{3}$, but the answer i get is wrong. What am I doing wrong?
 [/INST] This is a classic application of the so-called Lagrange Multiplier. We want to maximise the value of $2x-\tfrac{9}{2}y$ subject to the constraint $x^2 + 9 y^2-4 x+6 y+4=0$. We define
$$\Lambda(x,y,\lambda) = \left(2x-\tfrac{9}{2}y\right)+\lambda\left(x^2 + 9 y^2-4 x+6 y+4\right)$$
The point(s) you are looking for come from solving $\Lambda_x=\Lambda_y=\Lambda_{\lambda}=0$.
Calculating the three partial derivatives gives:
$$(x,y,\lambda) = \left(\frac{6}{5},-\frac{2}{15},\frac{5}{4}\right) \ \ \text{and} \ \ \left(\frac{14}{5},-\frac{8}{15},-\frac{5}{4}\right)$$
The values $(x,y)=(6/5,-2/15)$ correspond to a minimum, where $2x-\tfrac{9}{2}y=3$.
The values $(x,y)=(14/5,-8/15)$ correspond to a maximum, where $2x-\tfrac{9}{2}y=8$.
</s>