<s>[INST] find the maximum of $x+\frac{1}{2y}$ under the condition $(2xy-1)^2=(5y+2)(y-2)$ Assume $x,y \in \mathbb{R}^+$ and satisfy $$\left(2xy-1\right)^2 = (5y+2)(y-2)$$, find the maximum of the expression $x+\frac{1}{2y}$.
$\because (5y+2)(y-2) \geq 0$ , $\therefore y\geq 2$ or $y \leq -\frac{2}{5}$, and we have $$2xy = \sqrt{(5y+2)(y-2)}+1$$
then $f(x,y)=x+\frac{1}{2y}=\frac{2xy+1}{2y}=\frac{\sqrt{(5y+2)(y-2)}+2}{2y}=g(y)$,$$\therefore g'(y) = \frac{2 + 2 y - \sqrt{-4 - 8 y + 5 y^2}}{y^2 \sqrt{-4 - 8 y + 5 y^2}}$$
and $2+2y = \sqrt{5y^2-8y-4} \Rightarrow y = 8+6\sqrt{2}$, with the help of graphing calculator ,i know this is the maximum point.  $$\therefore f_{\text{max}}(x,y)=g(8+6\sqrt{2})=\frac{3\sqrt{2}}{2}-1$$
Is there any other way to work out it?
 [/INST] Here is another way. Change variables to replace $x$ with $z$ under the relation $z=2xy\iff x=\frac{z}{2y}$. So now you are maximizing $\frac{z+1}{2y}$ subject to $(z-1)^2=(5y+2)(y-2)$.
Lagrange multipliers can handle this. You have a system of three equations in three variables $y,z,k$:
$$\left\{\begin{align}
(z-1)^2&=(5y+2)(y-2)\\
-\frac{z+1}{2y^2}&=k(-10y+8)\\
\frac{1}{2y}&=2k(z-1)
\end{align}\right.$$
Dividing sides of the latter two equations:
$$-\frac{z+1}{y}=\frac{-5y+4}{z-1}$$
So now we have a system of two equations (the first equation above and this new equation, each rearranged algebraically):
$$\left\{\begin{align}
z^2-2z+1&=5y^2-8y-4\\
-z^2+1&=-5y^2+4y
\end{align}\right.$$
Add these: $$-2z+2=-4y-4$$
So $z-1=2y+2$, which we can substitute back into the original constraint:
$$(2y+2)^2=(5y+2)(y-2)\implies0=y^2-16y-8$$ from which we solve $y=8\pm6\sqrt{2}$. Then $z=2y+3=19\pm12\sqrt{2}$. And finally
$$\begin{align}
\frac{z+1}{2y}&=\frac{20\pm12\sqrt{2}}{16\pm12\sqrt{2}}\\
&=\frac{5\pm3\sqrt{2}}{4\pm3\sqrt{2}}\cdot\frac{4\mp3\sqrt{2}}{4\mp3\sqrt{2}}\\
&=\frac{2\mp3\sqrt{2}}{-2}=\pm\frac32\sqrt{2}-1
\end{align}$$
$\frac32\sqrt{2}-1$ is a maximum, and $-\frac32\sqrt{2}-1$ is a minimum.
</s>