Course Webpage

Maximum and minimum with inequality constraints. Symbolic and numerical calculus

Find the maxima and minima of the function

$$f(x,y)=x^2-2y^2$$

with the constraint $x^2+y^2 \leq 4$.


Analytically

The Extreme Value Theorem says that if $$f: A \in \mathbb{R}^n \rightarrow \mathbb{R}$$ is continuous on a closed and bounded subset of $\mathbb{R}^n$, $f$ reaches an absolute maximum and minimum within such subset.

This is our case.

The border of the zone that meets the condition is bounded by $x^2+y^2=4$ that is the circunference centered in the origin with radius 2.

The circunference divides the plane into three zones

  • $x^2+y^2 \lt 4$ is the zone inside the circunference, that is, the circle.
  • $x^2+y^2 = 4$ is the circunference.
  • $x^2+y^2 \gt 4$ is the zone outside the circunference.

thus, the zone where we are searching for maxima and minima is the circle and the circunference.

We perform the following steps:

  1. We look for local extrema.
  2. We look for extrema at the borders.
  3. We add the intersection points between the borders (if necessary).
  4. We consider the value of the function in all the previous points, and the points for which the function have the smallest value, are the minima and for the greatest value, we have the maxima.

We look for local extrema

The extreme necessary condition for a point $\left(x_{m},y_{m}\right)$ is that $\nabla f\left(x_{m},y_{m}\right)=\left(f^{\prime}_{x},f^{\prime}_{y}\right)=\left(0,0\right)$. That is, for

$$ f(x,y)=x^2-2y^2 $$

we have

$$ \begin{cases} f^{\prime}_{x}=0\\ f^{\prime}_{y}=0 \end{cases} \qquad \begin{cases} 2x=0\\ -4y=0 \end{cases} \qquad \begin{cases} x=0\\ y=0 \end{cases} $$

And we have obtained a point (red in the plot)

$$\fbox{(0,0)}$$

We look for extrema at the borders

Function $f(x,y)=x^2-2y^2$ and constraint $x^2+y^2-4 = 0$.

The Lagrangian function is $L(x,y,\lambda)=f(x,y)+\lambda g(x,y)$

$$ L(x,y,\lambda)= x^2-2y^2 +\lambda (x^2+y^2-4) $$

We calculate the partial derivatives and make them equal to zero

$$ \begin{array}{l} L'_x = 2x +2\lambda x=0\\ L'_y = -4y +2\lambda y =0 \\ L'_{\lambda} = x^2+y^2-4 = 0 \end{array} \quad \begin{array}{l} \rightarrow\\ \rightarrow \\ \rightarrow \end{array} \quad \begin{array}{l} x\,(2 +2\lambda)=0\\ y\,(-4 +2\lambda)=0 \\ x^2+y^2-4 = 0 \end{array} \quad \begin{array}{l} \rightarrow\\ \rightarrow \\ \rightarrow \end{array} \quad \begin{array}{l} x=0\quad \mathrm{or}\quad 2 +2\lambda=0\\ y=0\quad\mathrm{or}\quad-4 +2\lambda=0 \\ x^2+y^2-4 = 0 \end{array} $$

And $$ \begin{array}{l} x=0\quad \mathrm{or}\quad \lambda=-1 \\ y=0\quad\mathrm{or}\quad \lambda=2\\ x^2+y^2-4 = 0 \end{array} $$

And these three conditions must be met simultaneously.

  • If we take $x=0$ from the first equation and we substitute it in the third equation, we have $0^2+y^2-4=0$, that is, $y = \pm 2.$ Now we take these to the second equation that is the only one we have not used yet. As the condition $y=0$ is not met, we must choose the other condition, $\lambda=2.$ (Here we are not using the $\lambda$ value, as we are not using the Hessian matrix to ascertain if it is a maximum or minimum). So we obtain two points $$\fbox{$(0,2)\quad \mathrm{and} \quad (0,-2)$}$$

  • If we take $y=0$ from the second equation and we substitute it in the third equation, we have $x^2-4=0$, that is, $x = \pm 2.$ Now we take these to the first equation that is the only one we have not used yet. As the condition $x=0$ is not met, we must choose the other condition, $\lambda=-1.$ So we obtain two points $$\fbox{$(2,0)\quad \mathrm{and} \quad (-2,0)$}$$

We add the intersection points between the borders

As we have only a border, the circunfence, there are not intersection points between the borders.

We consider the value of the function at the points

Therefore, we have 5 candidate points that we place in the first column. The first thing is to check if they meet the constraints:

  • $(0,0)$ Does it meet the condition $x^2+y^2\le 4$? As $0^2+0^2 \le 4$, it does.

  • The other 4 points belong to the circunference, that is in the region we are studying.

Five points have passed the first filter. Now, we evaluate the function at these five points

$$ \begin{array}{|c|c|r|c|c|} \hline \mathrm{Point} & \mathrm{Within}\; \mathrm{domain?} & f(x,y) & \mathrm{Minimum}& \mathrm{Maximum}\\ \hline (0,0) & \mathrm{Yes} & 0 & & \\ (0,2) & \mathrm{Yes} & -8 & \mathrm{Yes}&\\ (0,-2) & \mathrm{Yes} & -8 & \mathrm{Yes}&\\ (2,0) & \mathrm{Yes} & 4 & & \mathrm{Yes}\\ (-2,0) & \mathrm{Yes} & 4 & & \mathrm{Yes}\\ \hline \end{array} $$

The smallest values are $-8$ and the minima are in (0,2) and (0,-2). And the greatest values are $4$ and the maxima are in (2,0) and (-2,0).

Numerically: penalty function

We will search a minimum. In this case we have two. If we use a descent method the found minimum will depend on the initial guess.

To obtain a maximum, change the sign an proceed similarly.

The idea of the penalty method is to replace the objective function $f$ by another function

$$F(x,y)=f(x,y)+c\,P(x,y)$$

and solve the problem without constraints. For this, we take $c$ as a positive constant and we must choose $P$, the penalty functions, in such a way that:

  • $P$ is continuous in the domain of $f$.

  • $P(x,y)\geq 0$ for every point in the domain of $f$, and

  • $P(x,y)=0$ if and only if the point $(x,y)$ satisfies the constraints.

A possible function to approximate a minimum would be

$$ F(x,y) = f(x,y) + 5 P(x,y)$$

where

$$ P(x,y)=\begin{cases} 0 & \mathrm{if} & x^2+y^2\le 4\\ x^2+y^2-4 & \mathrm{if} & x^2+y^2\gt 4 \end{cases} $$