<s>[INST] If $x$ and $y$ are real numbers such that $4x^2 + y^2 = 4x - 2y + 7$, find the maximum value of $5x+6y$. If $x$ and $y$ are real numbers such that $4x^2 + y^2 = 4x - 2y + 7$, find the maximum value of $5x+6y$.
I did a little bit of manipulation and got $4(x+1)(x-2) + (y+1)^2=0$. I then got $x=2$ and $y=-1$ which means the maximum must be $4$, but the answer key says it's $16$. How come?
 [/INST] We can rewrite the equation as follows:
$$4x^2 - 4x + y^2 + 2y - 7 = 0$$
By completing the squares, we obtain:
$$4\left (x^2 - x + \color{red}{\frac 1 4} \right ) + (y^2 + 2y + \color{blue}1) - 7 - \color{red}1 - \color{blue}1 = 0$$
that is,
$$\frac {\left (x - \frac 1 2 \right )^2} {\left ( \frac 3 2 \right )^2} + \frac {(y + 1)^2} {3^2} = 1$$
which represents the ellipse with center $(\frac 1 2, -1)$ and semiaxes $\frac 3 2, 3$.
For a given $k \in \mathbb R$, the equation $5x + 6y = k$ represents a straight line parallel to the line of equation $5x + 6y = 0$. We want to find the greatest $k$ such that the line $5x + 6y = k$ intersects the ellipse at a point $(x, y)$.
As $k$ increases, the line will intersect the ellipse in either $0$, $1$ or $2$ points (see the picture below). It should be clear that the greatest $k$ is such that there is only one point of intersection. Therefore, we want to find $k$ such that the system
$$\begin{cases} 5x + 6y = k \\ 4x^2 - 4x + y^2 + 2y - 7 = 0 \end{cases}$$
has exactly one solution.
By substituting $y = -\frac 5 6 x + \frac 1 6 k$ in the second equation, we get
$$169 x^2 - (10k + 204) x + (k^2 + 12 k - 252) = 0$$
which has exactly one solution if and only if its discriminant with respect to $x$ is $0$:
$$\Delta = (10 k + 204)^2 - 4 \cdot 169 \cdot (k^2 + 12 k - 252) = 0$$
This last equation has solutions $k = -23$ and $k = 16$.
Therefore, the maximum value of $5x + 6y$ is $16$.
The solution is represented in the following picture:

</s>