<s>[INST] Find largest possible value of $x^2+y^2$ given that $x^2+y^2=2x-2y+2$ 
Let $x, y \in \mathbb R$ such that $x^2+y^2=2x-2y+2$.  Find the largest possible value of $x^2+y^2$.

My attempt:
$x^2+y^2=2x-2y+2$
$(x^2-2x)+(y^2+1)=2$
$(x-1)^2+(y+1)^2=4$
I have no idea how to continue here.  Any help?
 [/INST] Try Lagrange Multipliers.  Set
\begin{align}
f(x,y) &= x^2 + y^2 \\
g(x,y) &= x^2 + y^2 -2x + 2y = 2 \\
\nabla f(x,y) &= \lambda\nabla g(x,y)
\end{align}
Then
\begin{align}
\nabla f(x,y) &= (2x,2y) \\
\nabla g(x,y) &= (2x-2,2y+2)
\end{align}
That is
\begin{align}
2x &= \lambda(2x-2) \tag1\label1 \\
2y &= \lambda(2y+2) \tag2\label2 \\
x^2+y^2-2x+2y &= 2 \tag3\label3
\end{align}
Add \eqref{1} and \eqref{2}: $(\lambda-1)(x+y)=0$


*

*$\lambda = 1$: we get $0 = -2$ in \eqref{1}, so this is rejected.

*$x + y = 0$: $g(x,y) = 2x^2-4x = 2 \iff x^2-2x-1=0$.  Solve it to get $(x,y) = (1 \pm \sqrt2, -1 \mp \sqrt2)$.


\begin{align}
f(1 - \sqrt2, -1 + \sqrt2) &= 2(\sqrt2-1)^2 \\
f(1 + \sqrt2, -1 - \sqrt2) &= 2(\sqrt2+1)^2
\end{align}
Hence the maximum of $f$ is attained at $(x,y) = (1 + \sqrt2, -1 - \sqrt2)$ and the maximum of $f$ is $2(\sqrt2+1)^2 = 6 + 4\sqrt2$.
</s>