\section{Convexity}
\label{section:convex-functions}

\begin{definition}[Epigraph]
\label{definition:epigraph}
    Let $E$ be a vector space over $\real$ and $f: E \to (-\infty, \infty]$, then the \textbf{epigraph} of $f$ is the set
    \[
    \text{epi}(f) = \bracs{(x, y) \in E \times \real| y \ge f(x)}
    \]
\end{definition}


\begin{definition}[Convex Function]
\label{definition:convex-function}
    Let $E$ be a vector space over $\real$ and $f: E \to (-\infty, \infty]$, then the following are equivalent:
    \begin{enumerate}
        \item For every $x, y \in E$ and $t \in [0, 1]$, 
        \[
        f((1 - t)x + ty) \le (1 - t)f(x) + tf(y)
        \]
        \item $\text{epi}(f)$ is convex. 
    \end{enumerate}
    
    If the above holds, then $f$ is \textbf{convex}. 
\end{definition}
\begin{proof}
    (1) $\Rightarrow$ (2): Let $(x, \alpha), (y, \beta) \in \text{epi}(f)$ and $t \in [0, 1]$, then
    \begin{align*}
        (1 - t)\alpha + t\beta &\ge (1 - t)f(x) + tf(y) \\
        &\ge f((1 - t)x + ty)
    \end{align*}

    so $((1 - t)x + ty, (1 - t)\alpha + t\beta) \in \text{epi}(f)$. 

    (2) $\Rightarrow$ (1): Let $x, y \in E$ and $t \in [0, 1]$, then
    \[
    ((1 - t)x + ty, (1 - t)f(x) + tf(y)) \in \text{epi}(f)
    \]

    so $f((1 - t)x + ty) \le (1 - t)f(x) + tf(y)$. 
    
\end{proof}

\begin{lemma}
\label{lemma:convex-domain}
    Let $E$ be a vector space over $\real$ and $f: E \to (-\infty, \infty]$, then $f$ is convex if and only if $\bracs{f < \infty}$ is convex and $f|_{\bracs{f < \infty}}$ is a convex function. 
\end{lemma}
\begin{proof}
    If $f$ is convex, then for any $x, y \in \bracs{f < \infty}$ and $t \in [0, 1]$, 
    \[
    f((1 - t)x + ty) \le (1 - t)f(x) + tf(y) < \infty
    \]

    so $\bracs{f < \infty}$ is convex, and the restriction $f|_{\bracs{f < \infty}}$ is a convex function. 

    On the other hand, for any $x, y \in E$ and $t \in [0, 1]$, if $f(x) = \infty$ or $f(y) = \infty$, then
    \[
    f((1 - t)x + ty) \le = \infty (1 - t)f(x) + tf(y)
    \]

    Otherwise, $x, y \in \bracs{f < \infty}$, and
    \[
    f((1 - t)x + ty) \le (1 - t)f(x) + tf(y)
    \]

    by convexity of $f|_{\bracs{f < \infty}}$. 
\end{proof}

\begin{lemma}
\label{lemma:convex-reverse}
    Let $E$ be a vector space over $\real$ and $f: E \to (-\infty, \infty]$ be convex, then for any $x, y \in E$ and $t \in \real \setminus [0, 1]$, 
    \[
    f((1 - t)x + ty) \ge (1 - t)f(x) + tf(y)
    \]
\end{lemma}
\begin{proof}
    Via an affine transformation, assume without loss of generality that $x = 0$ and $f(x) = 0$. By exchanging $x$ and $y$, assume without loss of generality that $t > 1$. In which case, since $f$ is convex and $y = t^{-1}ty$, $f(y) \le t^{-1}f(ty)$ and $tf(y) \le f(ty)$. 
\end{proof}

\begin{proposition}
\label{proposition:convex-differential}
    Let $E$ be a vector space over $\real$, $f: E \to (-\infty, \infty]$ be convex, and $x \in \bracs{f < \infty}$, then for any $h \in E$,
    \[
    \lim_{t \downto 0} \frac{f(x + th) - f(x)}{t} = \inf_{t > 0} \frac{f(x + th) - f(x)}{t}
    \]

    exists in $[-\infty, \infty]$. 
\end{proposition}
\begin{proof}
    Let $0 < s \le t$, then since $f$ is convex, 
    \begin{align*}
        f(x + sh) &\le \paren{1 - \frac{s}{t}}f(x) + \frac{s}{t}f(x + th) \\
        f(x + sh) - f(x) &\le \frac{s}{t}[f(x + th) - f(x)] \\
        \frac{f(x + sh) - f(x)}{s} &\le \frac{f(x + th) - f(x)}{t}
    \end{align*}
\end{proof}


\begin{proposition}
\label{proposition:convex-extension}
    Let $E$ be a vector space over $\real$, then:
    \begin{enumerate}
        \item For any $f, g: E \to (-\infty, \infty]$ convex and $\lambda \ge 0$, $\lambda f + g$ is convex. 
        \item For any convex functions $\cf \subset (-\infty, \infty]^E$, $\sup_{f \in \cf}f$ is convex. 
    \end{enumerate}
\end{proposition}



