# Worksheet 7-3: Convex Functions (with Solutions)

Download: [CMSE382-WS7_3.pdf](CMSE382-WS7_3.pdf), [CMSE382-WS7_3-Soln.pdf](CMSE382-WS7_3-Soln.pdf)

```{warning}
This is an AI-generated transcript of the worksheet and may contain errors or inaccuracies. Please refer to the original course materials for authoritative content.
```

---

## Worksheet 7-3: Q1

Consider $\max{\{\mathbf{x}^{\top} Q \mathbf{x}\mid \|\mathbf{x}\| \leq 1}\}$ where $\mathbf{x} \in \mathbb{R}^n$ and $Q \succeq 0$.

(a) Does a maximizer exist? Justify by checking all the conditions of the relevant theorem.

```{dropdown} Solution
- The theorem says that if the function is continuous and convex defined over a convex compact set, then a maximizer exists. Further, it occurs at the extreme points of the set.
- The function $\mathbf{x}^{\top} Q \mathbf{x}$ is continuous and convex since $Q \succeq 0$.
- The set $\{\mathbf{x} \mid \|\mathbf{x}\| \leq 1\}$ is convex and compact. It actually doesn't matter which norm we choose, this will always be true. More on options for norms in the next question.
- Since it satisfies the requirements of the theorem, a maximizer exists.
```

(b) Let $\mathbf{x} \in \mathbb{R}^2$ (that is, assume $n=2$ above) and answer the following questions.

(i) Using $L_1$-norm for $\mathbf{x}$: Sketch the feasible region and point out where a maximizer, if it exists, can be found.

```{dropdown} Solution
The region where $\|\mathbf{x}\|_1 \leq 1$ is the diamond-shaped region shown in the figure. The extreme points of this set are the points where one of the coordinates is $\pm 1$ and the other is $0$. These are the points where a maximizer, if it exists, can be found.

![L1 norm unit ball](../../../figures/closed_unit_balls_L1L2-L1-only.png)
```

(ii) Using $L_2$-norm for $\mathbf{x}$: Sketch the feasible region and point out where a maximizer, if it exists, can be found.

```{dropdown} Solution
The region where $\|\mathbf{x}\|_2 \leq 1$ is the circular region shown in the figure. The extreme points of this set are the points on the boundary of the circle. These are the points where a maximizer, if it exists, can be found.

![L2 norm unit ball](../../../figures/closed_unit_balls_L1L2-L2-only.png)
```

---

## Worksheet 7-3: Q2

Consider the function

$$
\begin{array}{rccc}
f: & [0,\infty) & \rightarrow & \mathbb{R} \cup \{\infty\} \\
& x & \mapsto &
\begin{cases}
\infty & \text{if } x = 0 \\
1/x & \text{if } x > 0
\end{cases}
\end{array}
$$

- What is the effective domain of $f$, $\text{dom}(f)$?

```{dropdown} Solution
The effective domain of $f$ is $\text{dom}(f) = (0,\infty)$ since $f(x) = \infty$ for $x=0$ and $f(x) = 1/x$ for $x > 0$.
```

- Sketch the epigraph of $f$.

```{dropdown} Solution
![Epigraph of 1/x](../../../figures/Epigraph_1_over_x.png)
```

- Is $f$ convex? Justify your answer.

```{dropdown} Solution
The function $f$ is convex because the effective domain of $f$ is $(0,\infty)$ and $f(x) = 1/x$ is convex on this domain. This can be shown by computing the second derivative of $f$:

$$f''(x) = \frac{2}{x^3} > 0 \text{ for } x > 0.$$

Since the second derivative is positive for all $x > 0$, $f$ is convex on its effective domain. Additionally, since $f(x) = \infty$ for $x=0$, the function is convex on the entire domain $[0,\infty)$.
```

---

## Worksheet 7-3: Q3

![Epigraph problem](../../../figures/epigraph_problem.png)

For each of the functions shown in the figure, answer the following:

(i) Sketch the sublevel sets at level $\alpha$.

(ii) Sketch the epigraph.

(iii) **Based only on your sketches**, is the function convex? Justify your answer.

(iv) **Based only on your sketches**, is the function quasi-convex?

```{dropdown} Solution
![Solution to epigraph problem](../../../figures/epigraph_problem_solution.png)

(i) Not convex, but it is quasi-convex.

(ii) Not convex but quasiconvex.

(iii) Convex (which also implies quasiconvex).

(iv) Not convex, but it is quasiconvex.
```
