# Maximise $f(x,y)=x^2+y^2$ on contraint that looks like infinity sign

I would like to find the maximum of the function $$f(x,y)=x^2+y^2$$ on the constraint $$x^2-y^2=(x^2+y^2)^2$$. The level curve $$h(x,y)=0$$ of the function $$h(x,y)=x^2-y^2-(x^2+y^2)^2$$ looks like an infinity sign and, because of the radial symmetry of $$f$$, it is clear that it takes its maximum value at (-1,0) and (1,0).

My question is: How can I show this using Lagrange multipliers?

## 2 Answers

You first define the Lagrangian $$L(x,y, \lambda) = x^2+y^2 + \lambda (x^2-y^2 - (x^2+y^2)^2).$$ Then, the KKT conditions are given by: $$\begin{cases} \nabla f(x^{\star}, y^{\star}) + \lambda \nabla h(x^{\star},y^{\star}) = 0\\ h(x^{\star},y^{\star}) = 0\end{cases}.$$ If you compute the optimality conditions and primal feasibility you get the following system of equations:$$\begin{cases} 2x+2\lambda x - 4\lambda x^{3} - 4\lambda xy^{2} = 0\\ 2y-2\lambda y - 4\lambda y^{3} - 4\lambda yx^{2} = 0\\ x^{2} - y^{2} - x^{4} - y^{4} - 2x^{2}y^{2} = 0 \end{cases}$$ which gives you the solutions you intuitively found.

An alternative way without using Lagrange multipliers: notice that if $$x^2-y^2=(x^2+y^2)^2$$ it is impossible that $$x^2+y^2>1$$, as we would have $$(x^2+y^2)^2> x^2+y^2\geq x^2-y^2$$

Thus, we will have at most $$x^2+y^2=1$$. But this equality is reached at $$x=1,y=0$$ and $$x=-1,y=0$$, so the maximum of $$x^2+y^2$$ at the given curve is $$1$$.