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?
 A: Hint
You found
$$(x-1)^2+(y+1)^2=4$$
which is the equation of a circle centered in $(1,-1)$ and with radius $2$. 
The function $x^2+y^2$ is the square of the distance of $(x,y)$ to the origin. Which point $(x,y)$ on this circle is located the furthest from the origin? It helps to make a simple sketch.

Alternatively, you can handle this as a constrained optimization problem and use for example the method of Lagrange multipliers.
A: By Minkowski (the triangle inequality) we obtain:
$$\sqrt{x^2+y^2}\leq\sqrt{(x-1)^2+(y+1)^2}+\sqrt{1^2+(-1)^2}=2+\sqrt2.$$
Id est, $$x^2+y^2\leq(2+\sqrt2)^2=6+4\sqrt2.$$
The equality occurs for $(x,y)=(1+\sqrt2,-1-\sqrt2),$ which says that we got a maximal value.
A: Thanks to StackTD, I have achieved my solution.
$x^2+y^2=2x-2y+2$
$(x^2-2x)+(y^2+1)=2$
$(x-1)^2+(y+1)^2=4$
We need to find the maximum distance from any point on the circle to the origin, squared(to find $x^2+y^2$).
By Pythagoras' theorem, the distance from the centre of the circle to the origin is $\sqrt{(-1)^2+1^2}=\sqrt2$.  We then add $2$, the radius of the circle.  We have $2+\sqrt2$, the maximum distance on any point on the circle to the origin.   However, this is only $\sqrt{x^2+y^2}$, so we need to square $2+\sqrt2$, as mentioned above, and will get $6+4\sqrt2$ as answer.
A: 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$.
A: You may solve this problem using geometry or you may use Lagrange Multipliers method. 
You have already found $$(x-1)^2+(y+1)^2=4$$ and you want to find a point on this circle which maximizes $$x^2+y^2$$. 
Graphing the first circle and finding the largest possible circle  $$x^2+y^2= R^2$$ to have a point on the circle $$  (x-1)^2+(y+1)^2=4$$ leads to the point with $ x=1+\sqrt 2$ and $y=-1-\sqrt 2$.
That implies $x^2= y^2 =3+2\sqrt 2 $ which in  turns gives   $$x^2+y^2= 2(3+2\sqrt 2) =11.6568.. $$
The Lagrange Multipliers Methods provides the same results.
A: We have the following quadratically constrained quadratic program (QCQP) in $\mathrm x \in \mathbb R^2$
$$\begin{array}{ll} \text{maximize} & \| \mathrm x \|_2^2\\ \text{subject to} & \| \mathrm x - \mathrm c \|_2^2 = 4\end{array}$$
where $\mathrm c \in \mathbb R^2$ is given. Let $\rm y := x-c$. Hence, we obtain the following QCQP in $\mathrm y \in \mathbb R^2$
$$\begin{array}{ll} \text{maximize} & \| \mathrm y + \mathrm c \|_2^2\\ \text{subject to} & \| \mathrm y \|_2^2 = 4\end{array}$$
Using the Cauchy-Schwarz inequality and $\| \mathrm y \|_2 = 2$, we obtain
$$\begin{array}{rl} \| \mathrm y + \mathrm c \|_2^2 &= \| \mathrm y \|_2^2 + 2 \, \mathrm c^\top \mathrm y + \| \mathrm c \|_2^2\\ &\leq 4 + 4 \| \mathrm c \|_2 + \| \mathrm c \|_2^2\\ &= \left( 2 + \| \mathrm c \|_2 \right)^2\end{array}$$
If $\rm c = (1,-1)$, then the maximum of the original problem is $\left( 2 + \sqrt 2 \right)^2$.
