# How can I find maximum and and minimum values of $f(x,y)=xye^{-(x+y)}$?

How can I find maximum and and minimum values of $f(x,y)=xye^{-(x+y)}$ in the region $(x-1)^2+(y-1)^2 \leq4$ ?

-

First look for critical points of $f$ in the interior $(x-1)^2 + (y-1)^2 < 4$. Do this by comparing the partial derivatives of $f$ to zero. Next search for critical values on the boundary $(x-1)^2 + (y-1)^2 = 4$ using Lagrange multipliers. Compute $f$ in these points and, by putting everything together, you will find the maximum and minimum of $f$ in the region.

EDIT: Computing the derivatives:

$$f_x(x,y) = x(1-y)e^{-(x+y)} \\\\ f_y(x,y) = y(1-x)e^{-(x+y)}$$

Comparing both to zero we get:

$$x(1-y) = 0 \\\\ y(1-x) = 0$$

Simultaneous solutions are $(0,0)$ and $(1,1)$, which are both within the interior (but as we will see these points don't matter anyway). Computing $f$ at these points gives $0$ and $e^{-2} \approx 0.135$ correspondingly.

Now to the boundary. It is given by $g(x,y) = 4$ where $g(x,y) = (x-1)^2 + (y-1)^2$ and the partial derivatives:

$$g_x(x,y) = 2(x-1) \\\\ g_y(x,y) = 2(y-1)$$

Using the Lagrange multipliers method, we have to solve $$g(x,y) = 4 \\\\ f_x(x,y) - \lambda g_x(x,y) = 0 \\\\ f_y(x,y) - \lambda g_y(x,y) = 0$$ to find the critical points on the boundary. Substituting:

$$(x-1)^2 + (y-1)^2 = 4 \\\\ y(1-x)e^{-(x+y)} - \lambda 2(x-1) = 0\\\\ x(1-y)e^{-(x+y)} - \lambda 2(y-1) = 0$$

Assuming $x,y \neq 1$ we can divide the last two equations by $(x-1)$ and $(y-1)$ correspondingly, so they become:

$$ye^{-(x+y)} = - 2\lambda \\\\ xe^{-(x+y)} = - 2\lambda$$

which implies $x = y$. Substituting into $g(x,y) = 4$, we have:

$$2(x-1)^2 = 4 \quad \implies \quad x = 1 \pm \sqrt{2}$$

Corresponding values of $f$ are $$f(1 - \sqrt{2}, 1 - \sqrt{2}) = (3 - 2 \sqrt{2}) e^{-2 + 2\sqrt{2}} \approx 0.393 \\\\ f(1 + \sqrt{2}, 1 + \sqrt{2}) = (3 + 2 \sqrt{2}) e^{-2 - 2\sqrt{2}} \approx 0.0466$$

For the case where $x = 1$ or $y = 1$ we plug them directly into $g(x,y) = 4$ to get

$$x = 1 \quad \implies \quad (y-1)^2 = 4 \quad \implies \quad y = -1, 3 \\\\ y = 1 \quad \implies \quad (x-1)^2 = 4 \quad \implies \quad x = -1, 3$$

Corresponding values of $f$ are $$f(-1,1) = f(1,-1) = -e^0 = -1 \\\\ f(3,1) = f(1,3) = 3e^{-4} \approx 0.0549$$

We conclude that the minimum value of $-1$ is attained at $(-1,1)$ and $(1,-1)$, and the maximum value of $(3 - 2 \sqrt{2}) e^{-2 + 2\sqrt{2}}$ is attained at $(1 - \sqrt{2}, 1 - \sqrt{2})$.

-
could you tell me if the critical points are (1,0) and (0,1) or not? I'm not sure – Muhammad Khalifa Dec 25 '12 at 21:41
@MuhammadKhalifaTranCer I don't think so. Recheck your computations. – ybungalobill Dec 25 '12 at 21:44
Fx =-xye^-(x+y) +ye^-(x+y) = 0 so -xy+y = 0 and then y(1-x)=0 so y=0 and x=1 is a point is that right? – Muhammad Khalifa Dec 25 '12 at 21:48
@MuhammadKhalifaTranCer The critical points are not $(1,0)$ nor $(0,1)$ see my reply below. – Fly by Night Dec 25 '12 at 21:53
@MuhammadKhalifaTranCer: Nope. You have $y=0$ or $x=1$. The same goes for $f_y$. But this only gives you the interior points, which according to wolfram happen to not be the maxima and minima in the region. The extrema actually achieved on the boundary, which is the second half of the question. – ybungalobill Dec 25 '12 at 21:53

There is a theorem, called the second derivative test for multiple variables, which states that you can find the maxima/minima of f by studying f at its critical points. You have limited the domain of this function, so we will only include values inside the domain, and use another method to find values on the boundary (Lagrange Multipliers). The theorem states that at a point $(a,b)$, where $f_x(a,b)=f_y(a,b)=0$, if f is defined on an open interval around $(a,b)$ then let $D=D(a,b)=f_{xx}(a,b)f_{yy}(a,b) - [f_{xy}(a,b)]^2$.

There are 3 cases for $D$:

1) if $D>0$ and $f_{xx}>0$, then $f(a,b)$ is a local minimum

2) if $D>0$ and $f_{xx}<0$, then $f(a,b)$ is a local maximum

3) if $D<0$ then $f(a,b)$ is neither a local minimum nor a local maximum (saddle point)

It's helpful to remember $D$ as the determinant of the hessian of the function. ie, $D=\left|\begin{array}{ll} f_{xx} & f_{xy} \\ f_{yx} & f_{yy} \end{array}\right| = f_{xx}f_{yy} - [f_{xy}f_{yx}]^2$

Note that we know though by Clairauts theorem, $f_{xy} = f_{yx}$

Ok, so coming back to your question:

$f_x = (1-x)ye^{-(x+y)}\\ f_y = (1-y)xe^{-(x+y)}$

So there are critical points at (1,1) and (0,0). These both lie in the domain...

And we also have that

$f_{xx} = (x-2)ye^{-(x+y)}\\ f_{yy} = (y-2)xe^{-(x+y)}\\ f_{xy} = (x-1)(y-1)(e^{-(x+y)})$

So $D(a,b)=e^{-2(a+b)}((a-2)(b-2)ab - (a-1)^2(b-1)^2)$

So evaluate D at the critical points:

$D(0,0) = e^0(-1) = -1 < 0\\ D(1,1) = e^{-4}(1-0) = e^{-4} > 0$

So $(0,0)$ is a point of inflection and $(1,1)$ is a local maximum...

The local maximum for the unbounded problem is then $e^{-4} \approx 0.02$

We're not done yet. It could be that it grows/decays arbitrarily so the bounds you gave may hold local maxima/minima too. To solve this we use Lagrange multipliers.

The way I like to do these is write the gradient of f as a linear combination of the gradients of the constraints. Often one can get away with little more than the AM-GM inequality. Never mind that though, onto Lagrange:

$\nabla f(x,y) = \lambda \nabla g(x,y)$

And

$g(x,y) = 4$

where here, $f(x,y) = xye^{-(x+y)}$ and $g(x,y) = (x-1)^2 + (y-1)^2$

I'll let you figure the partial derivatives for g out yourself. After that, we get the system:

$\begin{array}{lcl} (1-x)ye^{-(x+y)} = \lambda 2(x-1) \\ (1-y)xe^{-(x+y)} = \lambda 2(y-1) \\ (x-1)^2 + (y-1)^2 = 4 \end{array}$

One could treat this casewise,

if $x=1$ then $y=-1$ or $3$

if $y=1$ then $x=-1$ or $3$

and if $x$ and $y$ are neither $1$, then $x=y=1\pm \sqrt{2}$

Finally we must check these 8 points (2 boundary and 6 interior) as to which is maximal/minimal. My favorite way is to plug them in and see which are the highest/lowest... I've used python 2.7, my code is:

points = [(1,-1),(1,3),(-1,1),(3,1),(1+sqrt(2),1+sqrt(2)),(1-sqrt(2),1-sqrt(2)),(1,1),(0,0)]

def f(x,y):
return x*y*e**(-(x+y))

maxima = max(f(p[0],p[1]) for p in points)

minima = min(f(p[0],p[1]) for p in points)

for x,y in points:
if f(x,y)==minima:
print 'f(%d,%d) = %1.3f is a local minima' % (x,y,f(x,y))
if f(x,y)==maxima:
print 'f(%d,%d) = %1.3f is a local maxima' % (x,y,f(x,y))


You will find then that the minima in the boundary are at $f(\pm 1, \mp 1) = -1$ and the maximum is achieved at $f(1-\sqrt{2},1-\sqrt{2}) = (3-2\sqrt{2})e^{2(\sqrt{2}-1)}$.

-

It happens that we can answer this question easily without resorting to Lagrange multipliers. In the sequel, let $R=[-1,3]^2$ and $D=\{(x-1)^2 + (y-1)^2 \le 4\} \subset R$.

Let us deal with the minima first. Note that $f(x,y)=g(x)g(y)$ where $g(t)=te^{-t}$. The function $g$ is unimodal and its global maximum occurs at $t=1$, with $g(1)=e^{-1}>0$. Also, $g(t)\searrow-\infty$ when $t\rightarrow-\infty$ and $g(t)\searrow0$ when $t\rightarrow+\infty$. Therefore, on the square $R=[-1,3]^2$, $f$ is the most negative when $g(x)$ is the most positive and $g(y)$ is the most negative (or when $g(y)$ is the most positive and $g(x)$ is the most negative). Hence $$\min_{(x,y)\in[-1,3]^2}f(x,y) = \max_{x\in[-1,3]}g(x)\min_{y\in[-1,3]}g(y)=g(1)g(-1) = -1.$$ Since $(1,-1)\in D\subset[-1,3]^2$, we see that $\min\limits_D f(x,y)=f(1,-1)=-1$. By symmetry, $(-1,1)$ is another global minimum point.

To find the maximum, we first note that, by a similar argument to the above, we have $\max_{D\cap[0,3]^2} f(x,y) = f(1,1) = e^{-2}>0$. It remains to compare this maximum value to $\max_{D\cap[-1,0]^2}$. Now, when $x,y\le 0$, we have, by A.M.$\ge$G.M., \begin{align} (-x)(-y) e^{-(x+y)} &\le \left[\frac{(-x)+(-y)}{2}\right]^2 e^{-(x+y)}\\ \Rightarrow\quad g(x)g(y) &\le g^2\left(\frac{x+y}{2}\right). \end{align} In other words, on $D\cap[-1,0]^2$, the maximum of $f$ occurs when $x=y$. Since $g(t)\le0$ and $g(t)\searrow-\infty$ when $t\rightarrow-\infty$, $f(x,x)$ attains maximum on $D\cap[-1,0]^2$ when $(x-1)^2+(x-1)^2=4$, i.e. when $x=1-\sqrt{2}$. As $f(1-\sqrt{2},\,1-\sqrt{2})=(3 - 2 \sqrt{2}) e^{-2 + 2\sqrt{2}}>e^{-2}$, we have confirmed that $(1-\sqrt{2},\,1-\sqrt{2})$ gives the global maximum of $f$ over $D$.

-