Week 6: Extrema and Optimization#

Exercises – Long Day#

1: Stationary Points and Extremum Values#

A function \(f: \mathbb{R}^2 \to \mathbb{R}\) is given by

\[\begin{equation*} f(x,y)=xy(2-x-y)+1. \end{equation*}\]

Question a. By Hand#

Find all stationary points of \(f\). Calculate the function value at all stationary points.

Question b. SymPy#

Plot the level curves of the function and describe their shape. You do not need to provide a precise mathematical description of the level curves.

Question c#

Find a parametric representation \(\pmb{r}(t)\), \(t \in \mathbb{R}\), for a straight line through one of the stationary points. Plot the graph of the composite function \(f \circ \pmb{r}\).

Question d#

Repeat Question c but choose a different straight line through one of the stationary points.

Question e#

On Short Day, we will study methods to determine whether stationary points are maximum points, minimum points, or neither. Based on what you know about the function, for example from your plots, you should make a qualified guess as to whether the found stationary points are maximum points, minimum points, or neither.

2: A Return to Theme Exercise 1#

In Theme 1: The Gradient Method, we considered three functions of the form \(f_i: \mathbb{R}^2 \to \mathbb{R}\). All the functions had exactly one minimum but no maximum as they grew towards infinity. You may use this information without proof.

Here, we use the functions (with their default values) given in Python by:

# Variables and parameters that are involved in the functions
x1, x2 = symbols('x1 x2', real=True)
a, lambda1 = symbols('a lambda1',  positive=True)
def f1(x1, x2, a = S(1/2)):
    return a * x1**2 + 1 * x2**2

def f2(x1, x2, lambda1 = 0.5):
    Q = 1/sqrt(2) * Matrix([[1,1],[1,-1]])
    A = Q.T * Matrix([[lambda1,0],[0,1]]) * Q
    b = Matrix([-2,4])
    x = Matrix([x1,x2])
    q = x.T * A * x + x.T * b
    return q[0] 

def f3(x1, x2):
    return (1 - x1)**2 + 100*(x2 - x1**2)**2

In the theme exercise, we used the gradient method to search for the minimum point and minimum value. This is a good method, for example, when the function has many (possibly infinitely many) points where it is not differentiable. However, for well-behaved functions (such as functions that are infinitely differentiable, so-called smooth functions), like the three considered functions, it is much easier to simply find the points where the gradient is equal to the zero vector.

Find all stationary points and the corresponding minimum value for each of the three functions. Even though the functions are given in Python, you are welcome to solve this task by hand – that will not take longer.

State the image set of each function.

3: Extremum or not. By Hand#

Let \(f: \mathbb{R}^2 \to \mathbb{R}\) be given by

\[\begin{equation*} f(x,y)=x^2 y + y. \end{equation*}\]

Determine all local extrema of \(f\).

4: A Function that is not Differentiable Everywhere#

Let \(f: \mathbb{R}^2 \to \mathbb{R}\) be given by

\[\begin{equation*} f(x,y)=-|x| ((y-1)^2+1). \end{equation*}\]

Question a#

Find all points where the function could have an extremum value.

Question b#

Find the global maximum and minimum value of the function.

5: Global Maximum and Global Minimum#

Let \(f: A \to \mathbb{R}\) be given by:

\[\begin{equation*} f(x,y)=xy(2-x-y)+1, \end{equation*}\]

where \(A \subset \mathbb{R}^2\) denotes the region in the \((x,y)\) plane where \(x\in\left[ 0,1\right]\) and \(y\in\left[ 0,1\right]\). Note that the functional expression for \(f\) is the same as in 1: Stationary Points and Extremum Values.

Question a#

Find by hand all stationary points of \(f\) in the interior of \(A\).

Question b#

Determine the global maximum value and the global minimum value for \(f\) as well as the points where these values are attained.

Question c#

This exercise is about a differentiable function of two variables defined on \([0, 1]^2\). How would you approach the problem if it was about a differentiable function of five variables defined on \([0, 1]^5\)? Discuss a possible approach. You can include a good AI chatbot, such as https://chatgpt.com/ or https://copilot.microsoft.com/, in the discussion.

Question d#

Determine the image set of \(f\).

Question e#

Plot the graph of \(f\) along with points that show where on the graph the largest and smallest values are attained. Do a visual check that your results look reasonable.

6: Global Maximum and Global Minimum again#

Consider the function \(f:\mathbb{R}^2\rightarrow\mathbb{R}\) given by

\[\begin{equation*} f(x,y)=x^2-3y^2-3xy \end{equation*}\]

as well as the set \(A=\lbrace(x,y) \in \mathbb{R}^2 \,| \, x^2+y^2\leq 1\rbrace\).

Justify that \(f\) has both a global maximum and a global minimum on \(A\), and determine these values as well as the points where they are attained.

7: Stationary Points for Quadratic Forms#

Let \(q : \mathbb{R}^n \to \mathbb{R}\) be a quadratic form. In other words, \(q\) has the functional expression

\[\begin{equation*} q(\pmb{x}) = \pmb{x}^T A \pmb{x} + \pmb{x}^T \pmb{b} + c, \end{equation*}\]

where \(A\) is an \(n \times n\) matrix (which is not the zero matrix), \(\pmb{b} \in \mathbb{R}^n\) is a column vector and \(c \in \mathbb{R}\).

It holds that \(q\) is a differentiable function with \(\nabla q(\pmb{x}) = (A + A^T) \pmb{x} + \pmb{b}\) according to this example. This does not need to be shown (until the last exercise).

Question a#

Write a system of equations whose solution describes the stationary points. Argue that \(q\) can have either zero, one, or infinitely many stationary points.

Question b#

Assume that \((A + A^T)\) is invertible. Argue that \(q\) has exactly one stationary point. Find the stationary point (i.e., derive a formula or expression for the stationary point).

Question c#

Assume \(A\) is symmetric. Argue that \(q\) has exactly one stationary point if and only if \(\lambda = 0\) is not an eigenvalue of \(A\).

Question d (Optional)#

Derive the formula we started out by assuming: \(\nabla q(\pmb{x}) = (A + A^T) \pmb{x} + \pmb{b}\)

8: A Challenge in Linear Algebra#

Let \(A\) be an \(n \times n\) matrix. Does it hold that the symmetric matrix \((A + A^T)\) is invertible, if \(A\) is invertible? Proof it or provide a counterexample!


Exercises – Short Day#

1: Usage of Hessian Matrix. By Hand.#

Consider the function \(f:\mathbb{R}^2\rightarrow\mathbb{R}\) given by

\[\begin{equation*} f(x,y)=x^2+4y^2-2x-4y. \end{equation*}\]

Question a#

Argue that the function \(f\) has exactly one extremum. Determine this extremum point and the corresponding extremum value.

Question b#

What is the difference between an extremum and a strict extremum, also sometimes called a proper extremum? Is the extremum we found a strict extremum?

2: Local Extrema and Approximating Second-Degree Polynomial#

Given function \(f:\mathbb{R}^2\rightarrow\mathbb{R}\) with the expression

\[\begin{equation*} f(x,y)=x^3+2y^3+3xy^2-3x^2. \end{equation*}\]

Question a#

Show that the points \(A = (2, 0)\), \(B = (1, -1)\), and \(C = (0, 0)\) are stationary points for \(f\), and determine for each of them whether there is a local maximum or a local minimum (or neither) there. If so, indicate the local maximum/minimum value attained at the point, and determine if it is strict.

Question b#

Show that the approximating quadratic polynomial for \(f\) with the expansion point \(A\) can be written as an equation in the unknowns \(x\), \(y\), and \(z\) in the following form:

\[\begin{equation*} z-c_3=\frac 12\lambda_1(x-c_1)^2+\frac 12\lambda_2(y-c_2)^2. \end{equation*}\]

What surface does this equation describe, and what do the constants represent?

Question c#

Plot the graph of \(f\) along with the graph of the approximating second-degree polynomials for \(f\) with the expansion points \(A\), \(B\), and \(C\). Discuss whether the eigenvalues of the Hessian matrices at the three points can determine the type of quadric surface described by the second-degree polynomials.

3: A Return to Theme Exercise 1 once more#

We consider the quadratic form \(f_2: \mathbb{R}^2 \to \mathbb{R}\) from Theme 1: The Gradient Method. It is given by \(q: \mathbb{R}^2 \to \mathbb{R}\)

\[\begin{equation*} q(\pmb{x}) = \pmb{x}^T A \pmb{x} + \pmb{b}^T \pmb{x}, \end{equation*}\]

where \(A\) is a \(2 \times 2\) matrix that depends on \(\lambda_1 \in \mathbb{R}\),

\[\begin{equation*} A = Q^T \Lambda Q, \quad Q = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}, \quad \Lambda = \begin{bmatrix} \lambda_1 & 0 \\ 0 & 1 \end{bmatrix}, \end{equation*}\]

and where \(\pmb{b} = - 2 A [1,2]^T\). We will change the following from the Theme exercise: 1) \(\lambda_1\) may be zero or negative, and 2) we use a new definition of \(\pmb{b}\).

Question a. By Hand#

Find the eigenvalues of \(A\).

Question b. By Hand#

Find all stationary points of \(q\) when \(\lambda_1 \neq 0\).

Question c#

How is \(A\) and the Hessian matrix \(\pmb{H}_f\) related? Find the result in the book if you cannot remember. Describe the stationary point for each of the three cases \(\lambda_1 > 0\), \(\lambda_1 = 0\) and \(\lambda_1 < 0\).

Question d#

How is \(q\) and the approximating second-degree polynomial (with an arbitrary expansion point) related? Plot \(q\) for each of the three cases \(\lambda_1 > 0\), \(\lambda_1 = 0\) and \(\lambda_1 < 0\). Which normal forms are we dealing with (see https://en.wikipedia.org/wiki/Quadric#Euclidean_space)?

4: Global Extrema for Function of Three Variables#

We consider the function \(f:\mathbb{R}^3\rightarrow \mathbb{R}\) given by

\[\begin{equation*} f(x,y,z)=\sin(x^2+y^2+z^2-1)-x^2+y^2-z^2 \end{equation*}\]

as well as the solid unit sphere

\[\begin{equation*} \mathcal{K}=\left\{(x,y,z)\in \mathbb{R}^3 \mid x^2+y^2+z^2\leq 1\right\}. \end{equation*}\]

Question a#

Show that \(f\) in the interior of \(\mathcal{K}\) only has one stationary point, that being \(O=(0,0,0)\), and investigate whether \(f\) has an extremum at \(O\).

Question b#

Determine the global maximum value and the global minimum value of \(f\) on \(\mathcal{K}\) as well as the points where these values are attained.

Question c#

Determine the image set of \(f\) on \(\mathcal{K}\).

5: Where are the Global Extrema?#

Given function \(f:\mathbb{R}^2\rightarrow\mathbb{R}\) with the expression

\[\begin{equation*} f(x,y)=\exp(x^2+y^2)-4xy. \end{equation*}\]

Keep in mind that \(\exp(x^2+y^2) = \operatorname{e}^{x^2+y^2}\).

Question a#

Find all stationary points of \(f\).

Question b#

Find all local extrema.

Question c#

Determine whether the function \(f\) has a global maximum or minimum. If so, state the values of them.

Question d#

State the range of the function.