<!-- Lecture 2 of 9, Math Camp, Maria Titova. Course overview: https://maria-titova.com/courses/math-camp.md -->

# Lecture 2: Real Analysis in ℝn

<a id="lecture-content"></a>

In economics, we often want to maximize a function subject to constraints:

$$
\max_{x\in D} f(x).
$$

 Here $f$ is the objective function and $D$ is the _feasible set_: the set of choices satisfying the constraints. There is little point in trying to solve this problem if no solution exists. This lecture develops the machinery to guarantee that a solution exists, in $\mathbb{R}^{n}$.

<a id="distance-and-sequences"></a>

## 1 Distance and sequences

We begin by defining Euclidean distance in $\mathbb{R}^{n}$. Note that there are other ways to measure and define distance, even in $\mathbb{R}^{n}$. We opt to only use Euclidean distance for most of this class.

<a id="def:lec02-norm"></a>

**Definition 1.1 (Inner product, norm, and distance).** For $x,y\in\mathbb{R}^{n}$,

-   the _inner product_ (also known as the _dot product_) of $x$ and $y$ is

$$
x \cdot y = \sum_{i=1}^n x_i y_i,
$$

-   the (Euclidean) _norm_ (or _length_) of $x$ is

$$
\lVert x \rVert=\sqrt{x \cdot x}=\sqrt{\sum_{i=1}^n x_i^2},
$$

-   the _distance_ between $x$ and $y$ is

$$
d(x,y)=\lVert x-y \rVert = \sqrt{\sum_{i=1}^n (x_i-y_i)^2}.
$$

For example, $x=(3,4)\in\mathbb{R}^2$ has $x\cdot x=25$ and $\lVert x \rVert=5$, and the distance between $(1,2)$ and $(4,6)$ is $5$ as well. In $\mathbb{R}^1$ the norm is the absolute value, so $d(x,y)=\lvert x-y \rvert$.

The inner product and the norm are related by the Cauchy–Schwarz inequality:

<a id="thm:lec02-cauchy-schwarz"></a>

**Theorem 1.2 (Cauchy–Schwarz).** For every $x,y\in\mathbb{R}^{n}$,

$$
(x\cdot y)^2\leq(x\cdot x)(y\cdot y),
$$

 and hence $\lvert x\cdot y \rvert\leq\lVert x \rVert\lVert y \rVert$.

_Proof (optional)._ If $y=0$, both sides of the first inequality vanish.

Next suppose $y\ne0$, so that $y\cdot y=\sum_{i=1}^n y_i^2>0$. For every $\lambda\in\mathbb{R}$, consider a vector $z = x-\lambda y$. By [Definition 1.1](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-norm), $z \cdot z = \sum_{i=1}^n z_i^2 \geq 0$. Hence, we have

$$
0 \leq z\cdot z=(x-\lambda y)\cdot(x-\lambda y)
    =x\cdot x-2\lambda\,(x\cdot y)+\lambda^2\,(y\cdot y).
$$

 Next, choose $\lambda=(x\cdot y)/(y\cdot y)$ so that

$$
0 \leq x\cdot x-2\frac{(x\cdot y)}{(y\cdot y)}\,(x\cdot y)+\left(\frac{(x\cdot y)}{(y\cdot y)}\right)^2\,(y\cdot y)
    = x\cdot x-\frac{(x\cdot y)^2}{y\cdot y}.
$$

 Multiplying it by $y\cdot y>0$ gives the first inequality in [Theorem 1.2](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-cauchy-schwarz). Taking square roots gives the second inequality in [Theorem 1.2](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-cauchy-schwarz), since $(x\cdot x)^{1/2}=\lVert x \rVert$ by [Definition 1.1](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-norm). ◻

Here are some useful properties of the norm.

<a id="thm:lec02-norm"></a>

**Theorem 1.3 (Norm properties).** For $x,y\in\mathbb{R}^{n}$ and $a\in\mathbb{R}$,

1.  $\lVert x \rVert\geq0$, and $\lVert x \rVert=0$ if and only if $x=0$ (positivity),

2.  $\lVert ax \rVert=\lvert a \rvert\lVert x \rVert$ (homogeneity),

3.  $\lVert x+y \rVert\leq\lVert x \rVert+\lVert y \rVert$ (triangle inequality).

_Proof._ Parts (1) and (2) follow from [Definition 1.1](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-norm). The triangle inequality is shown as follows:

$$
\lVert x+y \rVert^2
    =\lVert x \rVert^2+2\,x\cdot y+\lVert y \rVert^2
    \leq\lVert x \rVert^2+2\lVert x \rVert\lVert y \rVert+\lVert y \rVert^2
    =(\lVert x \rVert+\lVert y \rVert)^2,
$$

 where the first inequality uses the Cauchy–Schwarz inequality. Taking square roots gives the triangle inequality. ◻

Read in terms of the distance function $d$, the three norm properties say that the distance behaves as a distance should: for all $x,y,z\in\mathbb{R}^{n}$,

$$
\begin{gathered}
    d(x,y)\geq0,\quad\text{with equality exactly when }x=y,\\
    d(x,y)=d(y,x),
    \qquad
    d(x,z)\leq d(x,y)+d(y,z).
\end{gathered}
$$

 Here, nonnegativity is part (1) applied to $x-y$; symmetry is part (2) with $a=-1$; and the triangle inequality is part (3) applied to $x-z=(x-y)+(y-z)$. A function satisfying these three conditions is called a _metric_.

Equipped with a concept of distance, we can name the set of points lying within a given distance of a point.

<a id="def:lec02-ball"></a>

**Definition 1.4 (Open ball).** For $x\in\mathbb{R}^{n}$ and $r>0$, the _open ball_ with center $x$ and radius $r$ is

$$
B(x,r)=\{y\in\mathbb{R}^{n}:\lVert y-x \rVert<r\}.
$$

<a id="def:lec02-open-set"></a>

**Definition 1.5 (Interior points, open sets, and limit points).**

Let $D\subseteq\mathbb{R}^{n}$.

-   A point $x\in D$ is an _interior point_ of $D$ if $B(x,r)\subseteq D$ for some $r>0$. The set of all interior points of $D$ is its _interior_, written $\operatorname{int}D$.

-   The set $D$ is _open_ if every point of $D$ is an interior point.

-   A point $a\in\mathbb{R}^{n}$ is a _limit point_ of $D$ if every ball $B(a,r)$ contains a point of $D$ different from $a$; equivalently,

$$
B(a,r)\cap\left(D\setminus\{a\}\right)\neq\emptyset
        \qquad\text{for every }r>0.
$$

For example, let $a<b$ and take $x\in(a,b)$. The number $r=\min\{x-a,b-x\}$ is positive and $B(x,r)\subseteq(a,b)$, so $(a,b)$ is open. The endpoints of $[a,b]$ are not interior points, and therefore

$$
\operatorname{int}[a,b]=(a,b).
$$

 The limit-point condition says that points of $D$ different from $a$ can be found arbitrarily close to $a$; the point $a$ need not itself belong to $D$.

Geometrically, in $\mathbb{R}$ the ball $B(x,r)$ is the interval $(x-r,x+r)$, and in $\mathbb{R}^2$ it is the disk of radius $r$ around $x$ without its bounding circle.

<a id="def:lec02-convergence"></a>

**Definition 1.6 (Sequence and convergence).** A _sequence_ in $\mathbb{R}^{n}$ is a list $(x_k)_{k=1}^{\infty}$ with $x_k\in\mathbb{R}^{n}$. It _converges_ to $x\in\mathbb{R}^{n}$, and $x$ is its _limit_, written $x_k\to x$, if for every $\varepsilon>0$ there is $K\in\mathbb N$ such that

$$
k\geq K\quad\Longrightarrow\quad\lVert x_k-x \rVert<\varepsilon.
$$

 A sequence that has no limit in $\mathbb{R}^{n}$ _diverges_.

In the notation of [Definition 1.4](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-ball), the condition says that every ball $B(x,\varepsilon)$, however small its radius, contains all terms of the sequence from some index on.

We check the definition on two sequences in $\mathbb{R}$.

<a id="ex:lec02-sequences"></a>

**Example 1.7 (Convergence and divergence).**

1.  The sequence $x_k=1/k$ converges to $0$. Let $\varepsilon>0$ and take an integer $K>1/\varepsilon$. Then every $k\geq K$ satisfies

$$
\lvert x_k-0 \rvert=\frac1k\leq\frac1K<\varepsilon,
$$

 which is the implication [Definition 1.6](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-convergence) requires of $K$. Since $\varepsilon>0$ was arbitrary, $x_k\to0$.

2.  The sequence $x_k=(-1)^k$ diverges. Let $x\in\mathbb{R}$ be a candidate limit and take $\varepsilon=1$. By part (3) of [Theorem 1.3](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-norm),

$$
\lvert 1-x \rvert+\lvert -1-x \rvert\geq\lvert (1-x)-(-1-x) \rvert=2,
$$

 so at least one of the two numbers is at least $1$. The values $1$ and $-1$ both occur at arbitrarily large indices, so every $K\in\mathbb N$ admits some $k\geq K$ with $\lvert x_k-x \rvert\geq1$, and the implication in [Definition 1.6](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-convergence) fails for $\varepsilon=1$. Since $x$ was arbitrary, no limit exists.

A subsequence is exactly what is sounds like: a sequence drawn from another sequence by skipping some terms.

<a id="def:lec02-subsequence"></a>

**Definition 1.8 (Subsequence).** If $k_1<k_2<\cdots$ is a strictly increasing sequence of indices, then $(x_{k_j})_{j=1}^{\infty}$ is a _subsequence_ of $(x_k)$.

Here are some useful properties of sequences and their limits.

<a id="thm:lec02-limit-facts"></a>

**Theorem 1.9 (Basic limit facts).** Let $(x_k)$ be a sequence in $\mathbb{R}^{n}$.

1.  If $x_k\to x$ and $x_k\to y$, then $x=y$.

2.  If $x_k\to x$, then $(x_k)$ is bounded: there is $M>0$ with $\lVert x_k \rVert\leq M$ for every $k$.

3.  The convergence $x_k\to x$ holds if and only if $x_{k,i}\to x_i$ in $\mathbb{R}$ for every coordinate $i=1,\ldots,n$.

4.  If $x_k\to x$, then every subsequence of $(x_k)$ also converges to $x$.

_Proof (optional)._ _Uniqueness._ Let $\varepsilon>0$. By [Definition 1.6](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-convergence) there is $K_1$ with $\lVert x_k-x \rVert<\varepsilon/2$ for $k\geq K_1$, and $K_2$ with $\lVert x_k-y \rVert<\varepsilon/2$ for $k\geq K_2$. Fix one $k\geq\max\{K_1,K_2\}$ and write $x-y=(x-x_k)+(x_k-y)$; parts (2) and (3) of [Theorem 1.3](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-norm) give

$$
\lVert x-y \rVert\leq\lVert x_k-x \rVert+\lVert x_k-y \rVert<\varepsilon.
$$

 So the nonnegative number $\lVert x-y \rVert$ lies below every positive $\varepsilon$, hence equals $0$, and part (1) of [Theorem 1.3](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-norm) gives $x=y$.

_Boundedness._ Left as an exercise: [Definition 1.6](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-convergence) with $\varepsilon=1$ leaves all but finitely many terms in $B(x,1)$, and a bound is the largest of $\lVert x \rVert+1$ and the norms of those remaining terms.

_Coordinates._ Write $a_j=x_{k,j}-x_j$. Since $a_i^2$ is one of the squares summed in [Definition 1.1](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-norm), and since that sum is at most $\left(\sum_{j=1}^n\lvert a_j \rvert\right)^2$, taking square roots gives

$$
\lvert x_{k,i}-x_i \rvert
    \leq\lVert x_k-x \rVert
    \leq\sum_{j=1}^n\lvert x_{k,j}-x_j \rvert.
$$

 Let $\varepsilon>0$. If $x_k\to x$, the left inequality lets any $K$ that [Definition 1.6](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-convergence) supplies for $\varepsilon$ serve the coordinate sequence $(x_{k,i})$ as well. Conversely, if every coordinate converges, choose for each $j$ an index $K_j$ beyond which $\lvert x_{k,j}-x_j \rvert<\varepsilon/n$; then $k\geq\max\{K_1,\ldots,K_n\}$ makes the right-hand sum, and hence $\lVert x_k-x \rVert$, smaller than $\varepsilon$.

_Subsequences._ The indices of a subsequence satisfy $k_j\geq j$: this holds at $j=1$ because indices are natural numbers, and $k_{j+1}>k_j\geq j$ forces $k_{j+1}\geq j+1$. Now let $\varepsilon>0$ and take the $K$ that [Definition 1.6](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-convergence) supplies for $(x_k)$. Every $j\geq K$ has $k_j\geq j\geq K$, and therefore $\lVert x_{k_j}-x \rVert<\varepsilon$. ◻

Limits also respect the arithmetic of $\mathbb{R}^{n}$, one operation at a time.

<a id="thm:lec02-algebra-of-limits"></a>

**Theorem 1.10 (Algebra of limits).** Suppose $x_k\to x$ and $y_k\to y$ in $\mathbb{R}^{n}$, and $a_k\to a$ and $b_k\to b$ in $\mathbb{R}$. Then

1.  $x_k+y_k\to x+y$,

2.  $a_kx_k\to ax$,

3.  $a_kb_k\to ab$,

4.  $x_k\cdot y_k\to x\cdot y$,

5.  $\lVert x_k \rVert\to\lVert x \rVert$,

6.  $a_k/b_k\to a/b$, provided $b\neq0$ and $b_k\neq0$ for every $k$,

7.  $x\geq y$, provided $x_k\geq y_k$ coordinatewise for every $k$.

Its proof is left as an exercise; the claims follow from part (3) of [Theorem 1.3](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-norm), which gives $\lvert \lVert x_k \rVert-\lVert x \rVert \rvert\leq\lVert x_k-x \rVert$, from [Theorem 1.2](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-cauchy-schwarz), and from the coordinatewise criterion in part (3) of [Theorem 1.9](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-limit-facts), together with the boundedness supplied by part (2).

<a id="suprema-and-compactness"></a>

## 2 Suprema and compactness

We first develop two ingredients for existence arguments: a way to describe the limiting upper value of a set, and a condition that makes sequences behave well inside a feasible set.

<a id="suprema-and-maximizing-sequences"></a>

### 2.1 Suprema and maximizing sequences

<a id="def:lec02-sup"></a>

**Definition 2.1 (Bounds and extrema).** Let $A\subseteq\mathbb{R}$ be nonempty.

-   A number $u$ is an _upper bound_ of $A$ if

$$
a\leq u\qquad\text{for every }a\in A,
$$

 and $A$ is _bounded above_ if it has an upper bound.

-   The _supremum_, or _least upper bound_, of $A$, written $\sup A$, is an upper bound $s$ of $A$ satisfying

$$
s\leq u\qquad\text{for every upper bound }u\text{ of }A.
$$

-   A number $z$ is the _maximum_ of $A$, written $\max A$, if

$$
z\in A
        \qquad\text{and}\qquad
        a\leq z\ \text{ for every }a\in A.
$$

_Lower bounds_, _bounded below_, the _infimum_, or _greatest lower bound_, $\inf A$, and the _minimum_ $\min A$ are defined by reversing every inequality above.

If a maximum exists, it is automatically the supremum. Conversely, if the supremum exists and belongs to $A$, it is the maximum. Thus

$$
\max A\text{ exists}
    \quad\Longleftrightarrow\quad
    \sup A\text{ exists and }\sup A\in A,
$$

 and then the two numbers are equal.

For example, the upper bounds of $(0,1)$ are precisely the numbers at least $1$, so

$$
\sup(0,1)=1,
    \qquad
    \inf(0,1)=0.
$$

 Neither bound belongs to the interval, so it has neither a maximum nor a minimum. The interval $[0,1]$ has the same supremum and infimum, but it contains both; hence $\max[0,1]=1$ and $\min[0,1]=0$.

[Definition 2.1](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-sup) does not guarantee that a supremum exists; it is possible for a set to have upper bounds but no least one. For instance, the set of rational numbers $q$ with $q^2<2$ is bounded above by $2$, but it has no least upper bound in $\mathbb Q$. When dealing with $\mathbb{R}$, we make a fundamental assumption that every nonempty set that is bounded above has a supremum. This is known as the completeness property of the real numbers.

<a id="ax:lec02-completeness"></a>

**Axiom 2.2 (Completeness of $\mathbb{R}$).** Every nonempty subset of $\mathbb{R}$ that is bounded above has a supremum in $\mathbb{R}$.

Note the role of both hypotheses of the axiom. First, the set $\mathbb{R}$ is nonempty but not bounded above, so it has no supremum. Second, the empty set $\emptyset$ is bounded above by every real number, but it has no least upper bound.

<a id="closed-bounded-and-compact-sets"></a>

### 2.2 Closed, bounded, and compact sets

Our existence argument will turn a sequence of feasible points into a candidate solution. For this to work, some subsequence must converge and its limit must remain in the feasible set. Compactness guarantees both.

<a id="def:lec02-compact"></a>

**Definition 2.3 (Closed, bounded, and compact sets).** A set $D\subseteq\mathbb{R}^{n}$ is

-   _closed_ if $x_k\in D$ and $x_k\to x$ imply $x\in D$;

-   _bounded_ if there is $M>0$ such that $\lVert x \rVert\leq M$ for every $x\in D$;

-   _compact_ if every sequence $(x_k)$ in $D$ has a subsequence converging to some point of $D$.

There are two failures to remember: $x_k=k$ runs off to infinity in $\mathbb{R}$, while $x_k=1/k$ converges to a point missing from $(0,1)$. Compactness rules out both.

In Euclidean space these conditions are related by a fundamental result that we use without proof.

<a id="thm:lec02-heine-borel"></a>

**Theorem 2.4 (Heine–Borel).** A set $D\subseteq\mathbb{R}^{n}$ is compact if and only if it is closed and bounded.

Thus every closed interval $[a,b]$ is compact, whereas $(0,1)$ and $\mathbb{R}$ are not. The empty set is compact, so compactness alone does not supply a feasible point.

<a id="continuity-and-existence"></a>

## 3 Continuity and existence

<a id="continuity"></a>

### 3.1 Continuity

So far, a limit has described the behavior of a sequence. We will also need to describe the behavior of a function as its input approaches a point.

<a id="def:lec02-function-limit"></a>

**Definition 3.1 (Limit of a function).** Let $D\subseteq\mathbb{R}^{n}$, let $f:D\to\mathbb{R}^m$, let $a$ be a limit point of $D$, and let $L\in\mathbb{R}^m$. We write

$$
\lim_{x\to a}f(x)=L
$$

 if, for every sequence $(x_k)$ in $D\setminus\{a\}$ such that $x_k\to a$, we have $f(x_k)\to L$.

In Euclidean space this sequential definition is equivalent to the familiar $\varepsilon$–$\delta$ condition: for every $\varepsilon>0$ there is $\delta>0$ such that

$$
x\in D,\quad 0<\lVert x-a \rVert<\delta
    \quad\Longrightarrow\quad
    \lVert f(x)-L \rVert<\varepsilon.
$$

The restriction $x\neq a$ is deliberate: a function limit depends on values near $a$, not on the value at $a$. The point $a$ need not be in the domain. For example, if $q(h)=h^2/\lvert h \rvert=\lvert h \rvert$ for $h\neq0$, then [Theorem 1.10](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-algebra-of-limits) gives $\lim_{h\to0}q(h)=0$, even though $q(0)$ is not defined.

For functions of one real variable, suppose $a$ is approached by points of $D$ from the indicated side. The notation

$$
\lim_{x\downarrow a}f(x)=L
    \qquad\text{and}\qquad
    \lim_{x\uparrow a}f(x)=L
$$

 denotes the _right-hand limit_ and _left-hand limit_, respectively. The first applies [Definition 3.1](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-function-limit) to $D\cap(a,\infty)$; the second applies it to $D\cap(-\infty,a)$. If the two-sided limit exists, then every one-sided limit that is defined exists and equals it.

<a id="def:lec02-continuity"></a>

**Definition 3.2 (Continuity).** Let $D\subseteq\mathbb{R}^{n}$, let $f:D\to\mathbb{R}^m$, and let $x\in D$. The function $f$ is _continuous at $x$_ if, whenever $x_k\in D$ and $x_k\to x$, we have

$$
f(x_k)\to f(x).
$$

 The function is _continuous on $D$_, or simply _continuous_, if it is continuous at every point of $D$.

At a limit point $x\in D$, [Definition 3.2](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-continuity) is equivalent to

$$
\lim_{y\to x}f(y)=f(x).
$$

 Equivalently, for every $\varepsilon>0$ there is $\delta>0$ such that, for every $y\in D$,

$$
\lVert y-x \rVert<\delta
    \quad\Longrightarrow\quad
    \lVert f(y)-f(x) \rVert<\varepsilon.
$$

 We will continue to use the sequential formulation because it fits our existence argument. In Lecture 4, the same function-limit notation will define derivatives: a difference quotient is evaluated only for $h\neq0$, while $h$ approaches $0$.

Here are the rules that let us build continuous functions out of simpler ones.

<a id="thm:lec02-continuity-operations"></a>

**Theorem 3.3 (Operations preserving continuity).** Let $D\subseteq\mathbb{R}^{n}$.

1.  If $f,g:D\to\mathbb{R}$ are continuous and $a\in\mathbb{R}$, then $f+g$, $af$, and $fg$ are continuous on $D$, and the quotient $f/g$ is continuous on the subset of $D$ on which $g\neq 0$.

2.  A composition of continuous functions is continuous.

Its proof is left as an exercise. Part (1) follows from [Definition 3.2](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-continuity) applied to an arbitrary sequence $x_k\to x$, together with [Theorem 1.10](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-algebra-of-limits); part (2) follows from [Definition 3.2](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-continuity) applied twice.

For example, constant functions and the identity function $f(x)=x$ are continuous on $\mathbb{R}$ by [Definition 3.2](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-continuity). Part (1) then makes every polynomial continuous on $\mathbb{R}$, and every rational function continuous off the zeros of its denominator, such as $(x^2+1)/(x-2)$ on $\mathbb{R}\setminus\{2\}$. Taking as known that $\exp$ is continuous on $\mathbb{R}$ and $\log$ on $(0,\infty)$, part (2) gives combinations: $e^{-x^2}$ is continuous on $\mathbb{R}$, and so is $\log(1+x^2)$, since $1+x^2$ stays positive.

<a id="the-weierstrass-theorem"></a>

### 3.2 The Weierstrass theorem

We are now ready to show existence. First, let us formalize what a solution to an optimization problem is.

<a id="def:lec02-argmax"></a>

**Definition 3.4 (Maximizers and minimizers).** Let $D\subseteq\mathbb{R}^{n}$ be nonempty and let $f:D\to\mathbb{R}$. The set of maximizers of $f$ on $D$ is

$$
\mathop{\mathrm{arg\,max}}_{x\in D}f(x)
    =\{x^*\in D:f(x^*)\geq f(x)\text{ for every }x\in D\}.
$$

 The set $\mathop{\mathrm{arg\,min}}_{x\in D}f(x)$ of minimizers is defined by reversing the inequality.

The main existence result is the Weierstrass theorem, which we can now state and prove.

<a id="thm:lec02-weierstrass"></a>

**Theorem 3.5 (Weierstrass).** Let $D\subseteq\mathbb{R}^{n}$ be nonempty and compact, and let $f:D\to\mathbb{R}$ be continuous. Then $f$ attains a maximum and a minimum on $D$; equivalently,

$$
\mathop{\mathrm{arg\,max}}_{x\in D}f(x)\neq\emptyset,
    \qquad
    \mathop{\mathrm{arg\,min}}_{x\in D}f(x)\neq\emptyset.
$$

_Proof (optional)._ We first prove that $f$ has a maximizer; the minimizer will follow at the end.

_Step 1: show that the attainable values $f(D)$ are bounded above._ Suppose they were not. Then for each $k$ there would be $y_k\in D$ with $f(y_k)>k$. By [Definition 2.3](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-compact), some subsequence satisfies $y_{k_j}\to y\in D$, and [Definition 3.2](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-continuity) gives $f(y_{k_j})\to f(y)$. Thus $(f(y_{k_j}))$ is bounded by part (2) of [Theorem 1.9](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-limit-facts). But $k_j\geq j$, so $f(y_{k_j})>k_j\geq j$ for every $j$, making the same sequence unbounded. This contradiction proves that $f(D)$ is bounded above.

_Step 2: construct feasible points whose values approach the best possible value._ The set $f(D)$ is nonempty because $D$ is nonempty. By Step 1 it is also bounded above, so completeness gives the real number $S=\sup f(D)$. For each $k$, the smaller number $S-1/k$ cannot be an upper bound of $f(D)$. Hence there is $x_k\in D$ with

$$
S-\frac1k<f(x_k)\leq S,
    \qquad\text{that is,}\qquad
    \lvert f(x_k)-S \rvert<\frac1k.
$$

 Since $1/k\to0$ by part (1) of [Example 1.7](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#ex:lec02-sequences), this proves $f(x_k)\to S$. The sequence $(x_k)$ is called a _maximizing sequence_.

_Step 3: obtain a feasible candidate for the maximizer._ Compactness of $D$ gives a subsequence $x_{k_j}$ and a point $x^*\in D$ such that $x_{k_j}\to x^*$. The membership $x^*\in D$ is important: the candidate remains feasible.

_Step 4: prove that the candidate is a maximizer._ Continuity gives $f(x_{k_j})\to f(x^*)$. On the other hand, because $f(x_k)\to S$, its subsequence also satisfies $f(x_{k_j})\to S$ by part (4) of [Theorem 1.9](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-limit-facts). Limits are unique, so $f(x^*)=S$. Since $S$ is an upper bound of $f(D)$, we have $f(x)\leq S=f(x^*)$ for every $x\in D$. Therefore $x^*$ is a maximizer in the sense of [Definition 3.4](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-argmax).

_Step 5: obtain a minimizer._ The function $-f$ is continuous by part (1) of [Theorem 3.3](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-continuity-operations). Applying Steps 1–4 to $-f$ gives a point that maximizes $-f$, which is exactly a point that minimizes $f$. ◻

Note that failure of any one of the three hypotheses — nonemptiness, compactness, or continuity — can lead to a function that does not attain its maximum or minimum.

<a id="ex:lec02-failures"></a>

**Example 3.6 (One failed hypothesis at a time).** None of the following problems has a maximizer, and in each one exactly one hypothesis of [Theorem 3.5](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-weierstrass) fails.

1.  In $\mathbb{R}^2$, let $f(x)=x_1+x_2$ on

$$
D=\{x\in\mathbb{R}^2:x_1\geq0,\ x_2\geq0,\ x_1+x_2\leq1,\ x_1x_2\geq1\}.
$$

 The feasible set $D$ is empty, so $f$ has no maximizer.

2.  $D=(0,1)$ and $f(x)=x$. The domain is bounded but not closed, since $x_k=1/(k+1)$ lies in $D$ and converges to $0\notin D$, so again it is not compact. Here $\sup f(D)=1$, while $f(x)<1$ for every $x\in D$.

3.  $D=[0,1]$, which is compact, and

$$
f(x)=
        \begin{cases}
            x, & 0\leq x<1,\\
            0, & x=1.
        \end{cases}
$$

 What fails is continuity, and only at $1$: the sequence $x_k=1-1/k$ lies in $D$ and converges to $1$, while $f(x_k)=1-1/k\to1\neq0=f(1)$, which [Definition 3.2](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-continuity) forbids. Again $\sup f(D)=1$ is not attained.

That said, a maximum might exist even if one of the hypotheses of [Theorem 3.5](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-weierstrass) fails. In that case, one must prove existence by other means, such as by finding a candidate and verifying that it is indeed a maximizer.

<a id="intermediate-values-and-fixed-points"></a>

### 3.3 Intermediate values and fixed points

While we need linear algebra to meaningfully study functions in $\mathbb{R}^{n}$, we can already prove some useful results about continuous functions in $\mathbb{R}$. The intermediate value theorem says that a continuous function on an interval takes on every value between its values at the endpoints.

<a id="thm:lec02-ivt"></a>

**Theorem 3.7 (Intermediate value theorem).** Let $f:[a,b]\to\mathbb{R}$ be continuous. If

$$
\min\{f(a),f(b)\}\leq c\leq\max\{f(a),f(b)\},
$$

 then there is $x\in[a,b]$ such that $f(x)=c$.

_Proof (optional)._ Assume first that $f(a)\leq c\leq f(b)$, and let

$$
A=\{x\in[a,b]:f(x)\leq c\}.
$$

 Then $A$ contains $a$ and is bounded above by $b$, so $s=\sup A$ exists by [Axiom 2.2](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#ax:lec02-completeness) and satisfies $a\leq s\leq b$. We show that $f(s)=c$.

_$f(s)\leq c$._ For each $k$, the number $s-1/k$ is smaller than $s$ and therefore not an upper bound of $A$, so we may pick $a_k\in A$ with

$$
s-\frac1k<a_k\leq s.
$$

 Then $a_k\to s$, since $1/k\to0$ by part (1) of [Example 1.7](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#ex:lec02-sequences), and [Definition 3.2](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-continuity) gives $f(a_k)\to f(s)$. Each $a_k$ lies in $A$, so $f(a_k)\leq c$ for every $k$, and part (7) of [Theorem 1.10](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-algebra-of-limits) carries the inequality to the limit: $f(s)\leq c$.

_$f(s)\geq c$._ If $s=b$, this is the hypothesis $f(b)\geq c$. If $s<b$, no point of $(s,b]$ lies in $A$, so $f(x)>c$ on $(s,b]$. The points $x_k=s+1/k$ lie in $(s,b]$ as soon as $1/k\leq b-s$, and $x_k\to s$, so [Definition 3.2](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#def:lec02-continuity) gives $f(x_k)\to f(s)$. Part (7) of [Theorem 1.10](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-algebra-of-limits) again carries $f(x_k)>c$ to the limit, giving $f(s)\geq c$.

This proves $f(s)=c$. In the remaining case $f(b)\leq c\leq f(a)$, apply what we have just proved to $-f$, continuous by part (1) of [Theorem 3.3](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-continuity-operations), and to the value $-c$: this produces a point $x$ with $-f(x)=-c$, that is, $f(x)=c$. ◻

From that, we obtain our first _fixed point theorem_ in $\mathbb{R}$ for free.

<a id="thm:lec02-fixed-point"></a>

**Theorem 3.8 (Brouwer in $\mathbb{R}$).** Let $a\leq b$. Every continuous function $f:[a,b]\to[a,b]$ has a _fixed point_: there is $x^*\in[a,b]$ such that $f(x^*)=x^*$.

_Proof._ Let $g(x)=f(x)-x$, continuous on $[a,b]$ by part (1) of [Theorem 3.3](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-continuity-operations). Since $f$ takes its values in $[a,b]$, we have $f(a)\geq a$ and $f(b)\leq b$, so

$$
g(a)=f(a)-a\geq0,
    \qquad
    g(b)=f(b)-b\leq0.
$$

 Hence $g(b)\leq0\leq g(a)$, and [Theorem 3.7](https://maria-titova.com/courses/math-camp/02-analysis-for-existence.md#thm:lec02-ivt) applied to $g$ with $c=0$ gives $x^*\in[a,b]$ with $g(x^*)=0$, which means $f(x^*)=x^*$. ◻


---

Previous: [Lecture 1: Sets, Functions, Logic, and Proofs](https://maria-titova.com/courses/math-camp/01-language-logic-proof.md) · Next: [Lecture 3: Linear Algebra](https://maria-titova.com/courses/math-camp/03-linear-algebra.md)
