Given the function $f(x,y):=xy+x-y$. Let $D:=\{(x,y)\in\mathbb{R}^2:x^2+y^2\leq25\wedge x \geq 0\}$. Find the absolute maximum and minimum of $f$ on $D$.
My working is as follows:
$\begin{array}
& f_x(x,y)=y+1=0 & \qquad \qquad f_y(x,y)=x-1=0 \\
\Rightarrow y=-1 & \qquad \qquad \Rightarrow x=1
\end{array}$
$D(x,y)=\begin{vmatrix}
f_{xx}(x,y) & f_{xy}(x,y) \\
f_{xy}(x,y) & f_{yy}(x,y)
\end{vmatrix} = \begin{vmatrix}
0 & 1 \\
1 & 0
\end{vmatrix} = -1$
$D(x,y) = D(1,-1) < 0 \Rightarrow (1,-1)$ is a saddle point.
Also, just for interest, $f(1,-1)=1$
To find the maximum and minimum of $f$ subject to $x^2+y^2=25$ I will use a Lagrange multiplier.
$\nabla f(x,y) = \lambda \nabla g(x,y)$ where $g(x,y)=x^2+y^2-25$
$\langle y+1, x-1 \rangle = \lambda \langle 2x, 2y \rangle$
$\left\{\begin{array}{llll}
y+1=2\lambda x & \Rightarrow & y=2\lambda x -1 & (1) \\
x-1=2\lambda y & \Rightarrow & x=2\lambda y +1 & (2) \\
x^2+y^2=25 & & & (3)
\end{array}\right.$
Putting (1) into (2) and (2) into (1) gives
$$x=\frac{1}{1+2\lambda} \qquad \text{and} \qquad y=-\frac{1}{1+2\lambda}\tag{4}$$ Where $\lambda \neq \pm \frac12$
Putting (4) into (3) gives
$$\lambda = \frac{-5\pm \sqrt2}{10} \approx -0.64 \quad \text{or} \quad -0.36$$
Subsequently,
$$x \approx \pm 3.54 \quad \text{and} \quad y \approx \mp 3.54$$
Note that $x=-y$. So,
$$f(3.54,-3.54) \approx -5.43 \quad \text{and} \quad f(-3.54,3.54) \approx -19.57$$
By this calculation, (-3.54, 3.54, -19.57) would be a point of absolute minimum on the circle $x^2+y^2=25$. But $x\geq 0$.
Hmm. Let me try evaluating $f(0,5)$. $$f(0,5)=-5 \nless f(3.54,-3.54) \approx -5.43$$ Nope. What should I do now to find the minimum in a procedurally correct way?
I also cannot find the absolute maximum. $(1,-1,1)$ is not the absolute maximum because I have found that $(3.54, 3.54, 12.5)$ exists on $D$. Why did my calculation using Lagrange's multiplier not give me this point?
Best Answer
Let us focus our attention on the boundary of $D$. From your system we deduce $$ (4\lambda^2-1)y=1-2\lambda, $$ and then $x=-y$. This gives us a single admissible point $P_0$ whose coordinates are $x=\frac{5}{\sqrt{2}}$ and $y=-\frac{5}{\sqrt{2}}$. At this point, $f(P_0)=-\frac{25}{2}+5 \sqrt{2} \approx -5.42893$.
Now we must remember that the case $4\lambda^2-1=0$ must be treated separately. If $\lambda=1/2$, then the systems becomes $$ \begin{array}{ll} y+1=x \\ x-1 = y \\ x^2+y^2=25, \end{array} $$ which gives $x=4$ (the root $x=-3$ cannot be accepted), $y=3$, $f(4,3)=13$. Similarly, for $\lambda=-1/2$, $$ \begin{array}{ll} y+1=-x \\ x-1 = -y \\ x^2+y^2=25, \end{array} $$ and the same solution.
Finally, on the vertical segment $\{(0,y)\mid -5 \leq y \leq 5\}$ we have $g(x,y)=x=0$ as a constraint and therefore the system $$ \begin{array}{ll} y+1=\lambda \\ x-1 = 0 \\ x=0 \end{array} $$ and no solutions. However we must also consider the two singular points $(0,-5)$ and $(0,5)$, where $$ f(0,-5)=5, \quad f(0,5)=-5. $$ To summarize, the point $(5/\sqrt{2},-5/\sqrt{2})$ is the global minimum, the point $(4,3)$ is the global maximum of $f$. Here is the graph of $x \mapsto f(x,\sqrt{25-x^2})$:
Remark. I do not believe that the methods of Lagrange multipliers is the best one to apply. It is much better to parametrize the boundary by polar coordinates $x=25 \cos \phi$, $y=25\sin \phi$, $-\pi/2 \leq \phi \leq \pi/2$, and to look at $f$ on the vertical segment. Alternatively, use the parametrization $y=\sqrt{25-x^2}$ for $0 \leq x$.