\chapter{Functions}
We discuss functions of one and several variables and their basic properties. Recall that a function $f$ from a set ${\cal A}$ to a set ${\cal B}$, denoted as
\[
f:{\cal A} \to {\cal B},
\]
is a rule that assigns to each $\b x \in {\cal A}$ a unique element $\b y \in {\cal B}$. The set ${\cal A}$ is the domain of $f$ and the range of $f$ is a subset of ${\cal B}$, not necessarily the whole of ${\cal B}$.

If $f:{\cal A} \to {\cal B}$ and a set ${\cal S} \subset {\cal A}$, then the function $g:{\cal S} \to {\cal B}$ defined by $g(z)=f(z)$, for $z\in {\cal S}$, is called the {\em restriction\/} of $f$ to ${\cal S}$.

Let $f:{\cal S} \to \mb{\Bb R}$, where ${\cal S}$ is a subset of $\mb{\Bb R}$. Then, $f$ is said to be continuous at $z_0 \in {\cal S}$ if for every $\varepsilon >0$, there exists $\delta=\delta(\varepsilon,z_0)$ such that $z\in{\cal S}$, $|z-z_0|<\delta$ imply $|f(z)-f(z_0)|<\varepsilon$. This is also written as $f(z)\to f(z_0)$ as $z\to z_0$. If $f$ is continuous at every point of ${\cal S}$, then we say that $f$ is continuous on ${\cal S}$.

We say that the function $f$ is bounded on a set ${\cal S}$ if there is $M\ge 0$ such that for any $\b z \in {\cal S}$ we have
\[
|f(\b z)| \le M.
\]

\begin{lemma}
\label{lemma:bounded}
If $f$ is continuous on $[a,b] \subset \mb{\Bb R}$, then $f$ is bounded on $[a,b]$.
\end{lemma}
{\bf Proof}\quad Consider the set
\[
\{x:x\in [a,b],\mb{ and {\em f} is bounded on } [a,x]\}.
\]
This set is nonempty and bounded above by $b$. Let
\[
c=\sup\{x: f \mb{ is bounded on } [a,x]\}.
\]
We now show that $c=b$. Suppose that $c<b$. From the continuity of $f$ at $c$ it follows that $f$ is bounded on $[c-\delta,c+\delta]$ for some sufficiently small $\delta > 0$. Being bounded on $[a,c-\delta]$ and on $[c-\delta,c+\delta]$, it is bounded on $[a,c+\delta]$. This contradicts our choice of $c$. We therefore conclude that $c=b$. This means that $f$ is bounded on $[a,x]$ for all $x<b$. From the continuity of $f$, we know that $f$ is bounded on some interval $[b-\delta,b]$. Hence, $f$ is bounded on $[a,b-\delta]$ and on $[b-\delta,b]$, which means that $f$ is bounded on $[a,b]$.\\
\hspace*{5.5in} $\Box$

With the help of the above lemma, we can now prove the maximum-minimum theorem of Weierstrass.
\begin{thm}[The Maximum-Minimum Theorem]
If $f$ is continuous on an interval $[a,b]$, then it takes on both its supremum and infimum values on $[a,b]$.
\end{thm}
{\bf Proof}\quad By Lemma~\ref{lemma:bounded} on page~\pageref{lemma:bounded}, the function $f$ is bounded on $[a,b]$. Let
\[
M=\sup\{f(x):x \in [a,b]\}.
\]
We now show that there is a $c \in [a,b]$ such that $f(c)=M$. Let
\[
g(x)=\frac{1}{M-f(x)}.
\]
If $f$ does not take on the value of $M$, then $g$ is continuous on $[a,b]$, and thus by virtue of Lemma~\ref{lemma:bounded} on page~\pageref{lemma:bounded} the function $g$ is bounded on $[a,b]$. But $g$ cannot be bounded on $[a,b]$. Thus, the assumption that $f$ does not take on the value $M$ has led us to a contradiction. The other case that $f$ takes on its infimum value can be proved in a similar manner.\\
\hspace*{5.5in} $\Box$

We now prove Lemma~\ref{lemma:bounded} for real-valued functions of several variables.
\begin{lemma}
\label{lemma:many}
Let $f:\mb{\Bb R}^n \to \mb{\Bb R}$ be a continuous function on a closed and bounded, that is, compact set $\Omega \subset \mb{\Bb R}^n$. Then, $f$ is bounded on $\Omega$.
\end{lemma}
{\bf Proof}\quad We prove the lemma by contradiction. So, we assume that $f$ is continuous on a compact set $\Omega$, but $f$ is not bounded on $\Omega$. Since $f$ is unbounded on $\Omega$, we can find a sequence $\{\b x_n\} \subset \Omega$ such that $f(\b x_n) > r(n)$, where $r(n) \to \infty$ as $n\to \infty$, that is, $f(\b x_n)\to \infty$ as $n \to \infty$. The sequence $\{ \b x_n\}$ is bounded because, by assumption, the set $\Omega$ is compact. Therefore, by the Bolzano-Weierstrass theorem, there is a convergent subsequence, say, $\{\b x_{n_k}\}$ that converges to a point $\b x^* \in \Omega$. The function is continuous on $\Omega$. Hence,
\[
\lim_{k\to \infty}f(\b x_{n_k})=f\left(\lim_{k\to \infty}\b x_{n_k}\right)=f\left(\b x^* \right),
\]
which is a contradiction because, by Lemma~\ref{lemma:many}, $\arrowvert f\left( \b x^*\right)\arrowvert < \infty$ on $\Omega$. Therefore, a continuous function on a compact set in $\mb{\Bb R}^n$ must be bounded.\\
\hspace*{5.5in} $\Box$

We next prove the theorem of Weierstrass for real-valued functions of several variables.
\begin{thm}[Theorem of Weierstrass]
If $f:\mb{\Bb R}^n \to \mb{\Bb R}$ is a continuous function on a compact set $\Omega \subset \mb{\Bb R}^n$, then $f$ achieves its supremum and infimum.
\end{thm}
{\bf Proof}\quad Let
\[
l=\sup_{\b x\in \Omega}f(\b x),
\]
that is,
\[
f(\b x)\le l\quad \mb{for all}\quad \b x\in \Omega.
\]
The function $f$ is continuous on $\Omega$, hence for an arbitray $\varepsilon>0$, we can find a point $\b x^*\in \Omega$ such that
\[
f\left( \b x^*\right)\ge l-\varepsilon.
\]
We can then construct a sequence $\{\b x_n\} \subset \Omega$ that converges to the point $\b x^*$ such that
\[
l-\frac{1}{n} \le f\left( \b x_n\right)\le l.
\]
Hence,
\[
\lim_{n \to \infty}f\left( \b x_n\right)=f\left( \b x^*\right),
\]
which means that $f$ reaches its supremum on $\Omega$.

To prove that $f$ also reaches its infimum, it is enough to consider the function $-f$ and repeat the above arguments.\\
\hspace*{5.5in} $\Box$

There is a special type of continuity that we will use later.
\begin{defn}[Uniform continuity]
Let $f:{\cal X} \to {\cal Y}$. Then, $f$ is called uniformly continuous on ${\cal X}$ if for every $\varepsilon>0$ there exists $\delta=\delta(\varepsilon)>0$, depending only on $\varepsilon$, such that $|x-x'|<\delta$ implies $|f(x)-f(x')|<\varepsilon$, where $x,x'$ are in ${\cal X}$
\end{defn}
Every uniformly continuous function is continuous, but necessarily conversly. Indeed, $f(x)=1/x$ is continuous on $(0,1)$ but not uniformly continuous.