%This is a LATEX document

%\documentstyle[leqno]{article}
\documentclass[a4paper, 11pt]{amsart}
\usepackage{color}
\usepackage{comment}

\setlength{\oddsidemargin}{0.0in}
\setlength{\evensidemargin}{0.0in}
\setlength{\textwidth}{6.5in}
\setlength{\topmargin}{0.0in}
\setlength{\textheight}{8.5in}
\renewcommand{\arraystretch}{1.5}

%\newcommand{\be}{\begin{equation}}
%\newcommand{\ee}{\end{equation}}

\newcommand{\calO}{{\cal O}}
\newcommand{\calL}{{\cal L}}
\newcommand{\calG}{{\cal G}}
\newcommand{\calH}{H }
\newcommand{\calM}{{\cal M}}
\newcommand{\calS}{{\cal S}}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollaire}[theorem]{Corollaire}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{question}{Question}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{definition and theorem}[theorem]{Definition and
Theorem}
\newtheorem{theoreme_et_definition}[theorem]{Th\'eor\`eme et d\'efinition}
\newtheorem{remarque}[theorem]{Remarque}
\newtheorem{remark}[theorem]{%$^* $
Remark}
\newtheorem{*remark}[theorem]{$^* $Remark}
\newtheorem{exercice}[theorem]{Exercice}
\newtheorem{*exercise}[theorem]{$^* $Exercise}
\newtheorem{**exercise}[theorem]{$^{** } $Exercise}
\newtheorem{exemple}[theorem]{Exemple}
\newtheorem{exemples}[theorem]{Exemples}
\newtheorem{propriertes}[theorem]{Propri\'ertes}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{spv}[theorem]{Sneak preview}
%\parindent0pt

\excludecomment{versionA}
%\includecomment{versionA}

\excludecomment{versionAA}
%\includecomment{versionAA}

\begin{document}

\title[IP for regime-switching stochastic vol models]{Inverse problems for derivative pricing in regime switching volatility models \\
    (hidden Markov model for volatility)
}

\author{Raymond Brummelhuis, Serge-Andr\'e Masson}

\maketitle

\section{\bf Introduction}

For local volatility models of option pricing (that is, models for which the instantaneous volatility is a function of the underlying asset and of time only) it has been known since Dupire \cite{Du} that knowledge, at some given date, of all European call options prices for all possible maturities and strikes allows one to reconstruct the local volatility function. It is natural to ask whether a similar result can be true for more general stochastic volatility models in which the volatility process has an independent component from the stochastic process which drives the stock price changes (or, if one prefers and in a Brownian motion setting, models for which volatility changes are not perfectly correlated with price changes). More generally, anticipating a possibly negative answer to this question, one can ask to what extend European call prices for all possible maturities and strikes determine the (parameters of the) volatility process. In this paper we examine this question for models in which the volatility is driven by a not directly observable finite state continuous-time Markov chain.

\section{\bf The model}

$\Rightarrow $ Literature-review: Elliott and co-authors, others (?) \textcolor{blue}{  - \`a faire}
\medskip

\subsection{The Regime-Switching Stochastic Vol or RSSV model} Let $(X_t )_{t \geq 0 } $ be a continuous time Markov chain with finite state space  $\{ 1, \ldots , N \} $, and risk-neutral transition probability rates $q_{ij } $ defined by
\begin{equation}
    \mathbb{P } (X_{t + dt } = j | X_t = i ) = \delta _{ij } + q_{ij } dt
\end{equation}
where $\mathbb{P } $ will denote the risk-neutral probability selected by the market for pricing traded assets.
\medskip

\textcolor{blue}{{\bf Commentaires}:
    \begin{itemize}
        \item Une fa\c con plus  propre de formuler ceci: $\mathbb{P } (X_{t + h } = j | X_t = i ) = \delta _{ij } + q_{ij }  h + o(h) $, $h \to 0 $
        \item Attention: changement de notation par rapport \`a celle utilis\'ee auparavant: $q_{ij } $ en lieu de $a_{ji } $
        \item Faire une r\'emarque sur les diff\'erentes probabilit\'es risque-neutres? Le mod\`ele (\ref{eq:RSSV_model}) avec un drift $\nu $ (plus un actif sans risque - compte en banque) n'est pas compl\`et.
    \end{itemize}
}
\medskip

We consider options written on a frictionlessly traded asset  whose risk-neutral price dynamics is given by
\begin{equation} \label{eq:RSSV_model}
    dS_t = r S_t dt + \sigma (X_t ) S_t dW_t ,
\end{equation}
where $r $ is the constant risk-free rate and $\sigma : \{ 1 , \ldots , N \} \to \mathbb{R } $ is some given function. We suppose that the Brownian motion $(W_t )_{t \geq 0 } $ is independent of the Markov chain $(X_t )_{t \geq 0 } . $
We note that the process $(S_t )_{t \geq 0 } $ has a.s. continuous trajectories (so we don't have to write $S_{t- } $ instead of $S_t $): the jumps are in the, not directly observable, instantaneous volatilities.

\begin{remark} \rm{We could also work directly with the Markov chain $\sigma _t  := \sigma (X_t ) $, whose state space is $\{ \sigma _1 , \ldots , \sigma _N \} $ where $\sigma _j = \sigma (j) \} $ and (infinitessimal) transition probabilities
        $$
            \mathbb{P } (\sigma _{t + dt } = \sigma _j | \sigma _t = \sigma _k ) = \delta _{ij } + q_{ij } dt .
        $$
        One advantage of using a hidden Markov process $X_t $ defined on an abstract state space is that the model then naturally extends to include for example stochastic risk-free interest rates, by specifying a second function $r : E \to \mathbb{R } $ and specifying price dynamics by
        $$
            dS_t = r(X_t ) S_t dt + \sigma (X_t) S_t dW_t .
        $$
        Similarly, one could add state-dependend dividend rates. As before, sample paths of $(S_t )_{t \geq 0 } $ are a.s. continuous: the jumps are in the (Ito-) derivatives of $S_t . $  For now we will take $r $ constant, and concentrate on the regime-switching stochastic volatilty model (\ref{eq:RSSV_model}).
    }
\end{remark}

\subsection{Derivative pricing in RSSV models} As explained in the introduction, we are interested in the inverse problem of determining the model parameters $\sigma _i $, $q_{ij } $ from observed European call option prices for all strikes and maturities. To that effect, we start by reviewing European option pricing in our model. The problem of option pricing in regime-switching models (not only models for stochastic volatility but also for example interest rate en credit risk models) has drawn a lot attention in the mathematical finance literature, notably in papers by Robert Elliott and his co-authors: see \textcolor{blue}{ [add string of references papers by Elliott et al]} and also \textcolor{blue}{[other papers?]}. The majority of these are concerned with the direct problem of computing option prices for a given set of parameters, though some papers also examine calibration issues: see for example Xi, Rodrigo and Mamo \cite{XRM} We will review the PDE approach to pricing, which for the model (\ref{eq:RSSV_model}) amounts to solving a system of PDEs for the option prices in the different Markov-chain states. We then, following an idea of \cite{XRM} derive a Dupire-type equation for call-option prices as function of strike and maturity.
\medskip

By risk-neutral pricing, a European derivative written on the asset $S_t $ and paying off an amount of $F(S_T ) $ at its maturity $T $ will have a time-$t $ price given by the discounted risk-neutral expectation
\begin{equation}
    V_t = \mathbb{E } \left(  e^{- r (T - t ) } F(S_T ) | \mathcal{F }^{S, X } _t \right) %\mathbb{E } \left( e^{- r (T - t ) } F(S_T ) | S_t = S, X_t = i \right) ,
\end{equation}
where $\mathcal{F }^{S, X } _t $ is the filtration generated by the process $(S_t, X_t )_{t \geq 0 } . $ Since the latter is Markov, we have that $V_t = V (S_t, X_t , t ) $, where
\begin{equation} \label{eq:European_option_price}
    V(S, i , t ) = \mathbb{E } \left( e^{- r (T - t ) } F(S_T ) | S_t = S, X_t = i \right) , i = 1, \ldots , N ,
\end{equation}
remembering that $X_t \in \{ 1 , \ldots , N \} . $ It will be convenient to collect these $N $ functions into a column vector
$$
    V(S, t ) := (V(S, 1 , t ) , \ldots , V(S, N , t )^T
$$
$^T $ standing for "transpose", and we will consequently write $V_i (S, t ) $ for $V(S, i , t ) . $
\medskip

The prices $V_i (S , t ) $ satisfy a system of PDEs.

\begin{theorem} \label{thm:Dynkin} Suppose that $f = f(S, X, t ) $ is a $C^{2, 1 } $-function\footnote{two times continuously differentiable with respect to $S $, once with respect to $t $} on $\mathbb{R } \times \{ 1 , \ldots , N \} \times \mathbb{R } . $ Then
    \begin{eqnarray} \label{eq:Dynkin}
        &&\mathbb{E } \left( df (S_t , X_t , t ) | S_t  = S , X_t = i \right) \\
        &=&= \left( \partial _t f (S , i , t ) + r S \partial _S f (S, i, t ) + \frac{1 }{2 } \sigma (i)^2 S ^2 \partial _S ^2 f (S, i , t ) + \sum _{j = 1 } ^N q_{ij }f (S , j , t ) \right) dt . \nonumber
    \end{eqnarray}
\end{theorem}

\noindent {\it Proof}. Conditioning first on the Markov chain at $t + dt $ and using that the Markov chain is, by assumption, independent of the Brownian motion, we have
\begin{eqnarray} \nonumber
    \mathbb{E } (f(S_{t + dt } , X_{t + dt }, t ) \, | S_t = S, X_t = i ) &=& \mathbb{E } \left( \mathbb{E } (f (S_{t + dt } , X_{t + dt } , t ) \,  | X_{t + dt } ) | S_t =S , X_t = i \right) \\
    &=& \mathbb{E } \left( \sum _{j = 1 } ^N f(S_{t + dt } , j , t ) (\delta _{ij } + q_{ij } dt ) \, | S_t = S \right) \nonumber \\
    &=& \sum _{j = 1 } ^N \mathbb{E } \left( f(S + r S dt + \sigma _j S dW_t , j ) \right) (\delta _{ij } + q_{ij } dt ) , \label{proof_Dynkin}
\end{eqnarray}
since to order $dt $ there can be at most on jump in $[t, t + dt ] . $ By Ito's lemma,
$$
    \mathbb{E } \left( f(S + r S dt + \sigma _j S dW_t , j , t ) \right) = f(S, j , t ) + \left( \partial _t f + r S \partial _S f + \frac{1 }{2 } \sigma _j ^2 \partial _S ^2 f \right) dt ,
$$
with $f $'s derivatives all evaluated in $(S, j, t ) . $ Substituting this into (\ref{proof_Dynkin}) and using that $ (dt)^2 = 0 $, we see that only the terms $f(S, j , t ) q_{ij } dt $ and $f(S , i , t ) + \left( \partial _t f + r S \partial _S f + \frac{1 }{2 } \sigma _j ^2 \partial _S ^2 f \right) dt $ remain which, after subtracting $f(S , i , t ) $, proves (\ref{eq:Dynkin}). \hfill $\Box $
\medskip

Assuming we would know that the $V _i (S, t ) $ are $C^{2, 1 } $ as a function of $S $ and $t $, the fact that $e^{-r t } V(S_t, X_t , t ) $ is a martingale, and therefore has drift 0, and theorem \ref{thm:Dynkin} applied to $e^{- r t } V_i (S, t ) $ immediately implies that they must satisfy the system of PDEs
\begin{equation} \label{eq:pricing_PDE}
    \partial _t V_i + \frac{1 }{2 } \sigma _i (S , t )^2 S^2 \partial _S ^2 V_i + r S \partial _S C + \sum _i q_{ij } V_j = r V_i , \ \ t < T ,
\end{equation}
with final condition $V(S, T ) = F(S) . $ It is possible to prove directly from (\ref{eq:European_option_price}) that the $V_i $'s are $C^{2 , 1 } $: see for example \cite{?}. Alternatively, one can use the theory of linear PDEs: the system (\ref{eq:pricing_PDE}) with the final condition $F $  has a unique smooth solution \textcolor{blue}{- reference? Friedman's book on parabolic PDE? - }. By theorem \ref{thm:Dynkin}, $e^{- r t } V(S_t , X_t , dt ) $ is a local martingale. If $F $ is for example bounded, then so is the solution $(V_i )_i $, which implies that the local martingale is a martingale, so that
$$
    e^{-r t } V(S_t , i,  t ) = \mathbb{E } \left( e^{- r T } F(S_T ) | S_t, X_t \right) ,
$$
and $V(S_t, X_t , t ) $ is the price of the derivative.
\medskip

\textcolor{blue}{Deux remarques:
    \begin{itemize}
        \item dernier argument \`a re-v\'erifier et \`a g\'en\'eraliser pour un call (dont le pay-off n'est pas born\'e)
        \item Le "payoff" $F $ peut en principe \'etre vectoriel, c'est \`a dire, d\'ependant de l'\'etat de la chaine de Markov \`a $T $, mais admettre de tels pay-off vectoriel impliqu\'erait que les \'etats de la chaine de Markov sont observables, ce qui n'est pas le cas pour notre mod\`ele, puisqu'on peut pas observer la volatilit\'e instantann\'ee $\sigma (X_T ) $ \`a $T $
    \end{itemize}
}
\medskip

We now specialize to European call options with (state-independent) pay-off $F(S_T ) = \max (S_T - K , 0 ) . $ We will denote the value of the call by $C(S , X , t ; K, T ) $ ($X \in \{ 1, \ldots , N \} $ and also as a column vector $C (S , t ; K , T ) = \left( C (S, 1, t ; K, T ) , \ldots , C (S, N, t ; K , T ) \right) ^T $, where $C_i (S, t ; K, T ) = C(S , i , t ; K, T ) . $ It will satisfy the system
\begin{equation} \label{eq:PDE_call}
    \partial _t C + \frac{1 }{2 } \Sigma ^2 \, S^2 \partial _S ^2 C + r S \partial _S C + Q C = r C ,
\end{equation}
where %$\Sigma := {\rm diag } ( \sigma _1 ^2 , \ldots , \sigma _N ^2 ) $,
\begin{equation}
    \Sigma ^2 = \begin{pmatrix} \sigma _1 ^2 & \      & \            \\
                \            & \ddots & \            \\
                \            & \      & \sigma _N ^2
    \end{pmatrix}
\end{equation}
is the diagonal matrix of the state-dependend volatilities, and $Q = (q_{ij } )_{1 \leq i, j \leq N } $ is the matrix of transition probability rates of the Markov chain. The matrix $Q $ is row-stochastic: if $\mathbf{1 } := (1, 1, \ldots , 1 )^T $, then
\begin{equation}
    Q \mathbf{1 } = 0
\end{equation}
Since the model is time-homogeneous, we can write $C (S , t ; K , T ) = C (S, K, T - t) $ (with a slight abuse of notation).
\medskip

The inverse problem we are interested in then is the following:

\begin{question} Suppose that at a given time $t_0 $ we observe all call prices $C_i (S_0 , t_0 ; K, T ) $ for arbitrary strike  $K > 0 $ and maturity $T > t_0 $, where $i $ is the state of the Markov chain in which we are in at time $t_0 . $ How much of the model parameters $N $ (the number of Markov states), $\sigma _i $ (the state-dependent volatilities) and $q_{ij } $ (the transition probability rates) can we reconstruct ?
\end{question}

We have a total of $1 + n + n^2 - n = n^2 + 1 $ parameters and a continuum of observed prices (in our idealized set-up), so the problem seems at first sight over-determined.
\medskip

\textcolor{blue}{{\bf Question}: is $2N - 2 = $ maximal size for which the matrix $\left( (A^j v , ^T A^k w ) \right) _{j, k } $ is of full rang? Here $A = z \Sigma + Q $ }

\subsection{Dupire's equation}

\begin{theorem} (Xi, Rodrigo and Mamon \cite{XRM}) Fix $S = S_0 , t = t_0 . $ Then as a function of $(K, T ) $, the vector of prices $C(S , t ; K, S ) $ satisfies the system of PDEs
    \begin{equation} \label{eq:Dupire}
        \partial _T C = \frac{1 }{2 } \Sigma ^2 \, K^2 \partial _K ^2 C - r K \partial _K C + Q C , \ \ T > 0 ,
    \end{equation}
    with initial value $C (S_0 , t_0 , K , 0 ) = \max (S_0 - K , 0 ) \mathbf{1 } . $
\end{theorem}

\begin{proof} Xi {\it et al.} \cite{XRM} first observe that $C $ is homogeneous of order 1 in $(K, S ) $ by showing that $C (\lambda S , t ; \lambda K , T ) $ and $\lambda C (S , t ; K , T ) $ both satisfy the $N \times N $-system (\ref{eq:PDE_call}), %system (\ref{eq:PDE_call}),
    since the (matrix-)coefficients of this system are constant. They both have the the same final value value $\lambda \max (S - K , 0 ) $ at $T $, and are therefore identical. The Euler relation
    $$
        S \partial _S C + K \partial _K C = C
    $$
    then allows to express derivatives with respect to $S $ in terms of derivatives with respect to $K $, and (\ref{eq:Dupire}) follows from (\ref{eq:PDE_call}). Alternatively, one can use the relation
    that $C (S, K , T - t_0 ) = S \, C (1 , K/S , T - t_0 ) $ to derive (\ref{eq:Dupire}).
\end{proof}

\noindent \textcolor{blue}{{\bf Interrogation}: la question se pose si c'est vraiement n\'ecessaire, pour notre probl\`eme inverse, d'utiliser une \'equation de Dupire, dans le sens qu'on peut d\'eduire, pour ce mod\`ele, une formule explicite pour la  transformation de Fourier du prix en r\'esolvant (\ref{eq:PDE_call}) dans l'espace de Fourier (apr\`es passage au prix logarithmique $x = \log S/S_0 $) comme on le fait pour Dupire ci-bas, formule qu'on peut ensuite manipuler en tant que fonction de $K $ ou de $\log (K/S_0 ) $ ($S_0 $ \'etant le prix du sous-jacent au moment de l'observation) et de $T . $ On peut peut-\^etre pour ce mod\`ele sp\'ecifique, en quelque sorte "court-circuiter" Dupire? \`A suivre.
}
\medskip

Passing to log-coordinates $x = \log K $ and letting $c (x, T ) := C (S_0 , e^x , T ) $ (suppressing the $S_0  $-dependence from the notions and taking welog $t_0 = 0 $) we find that
\begin{equation}
    \partial _T c = \frac{1 }{2 } \Sigma ^2 \partial _x ^2 c - \left(  \frac{1 }{2 } \Sigma ^2 + r \right) \partial _x c + Q c , \ \ T > 0
\end{equation}
with initial condition $c (x, 0 ) = c_0 (x) := \max ( S_0 - e^x , 0 ) \mathbf{1 } . $ It is natural to solve this using the Fourier transform: if we take $r = 0 $ to simplify, and if $\widehat{c }  (\xi , T ) $ is the Fourier transform with respect to the $x $-variable of the (vector-valued) call price function $c $, then
$$
    \partial _T \widehat{c } = - \left( \, \frac{1 }{2 } (\xi ^2 + i \xi ) \Sigma ^2 - Q \, \right) \widehat{c } ,
$$
with initial condition $\widehat{c } (\xi , 0 ) . $ If the initial condition would have been an integrable function, the solution is
\begin{equation} \label{eq: FT_call}
    c(\xi , T ) = e^{- T ( \frac{1 }{2 } (\xi ^2 + i \xi  )\Sigma ^2 - Q ) }\widehat{c } (\xi , 0 )  \mathbf{1 } ,
\end{equation}
%where we put $\zeta := \zeta (\xi ) := \frac{1 }{2 } (\xi ^2 + i \xi  ) $ and
where the exponential is a matrix exponential. In our case, $c (x, 0 ) $ is only a bounded function and thus a tempered distribution, as is its Fourier transform. To show that (\ref{eq: FT_call}) defines a tempered distribution we have to check that $\xi \to \exp ( - T ( \frac{1 }{2 } (\xi ^2 - i \xi ) \Sigma ^2 - Q ) ) $ belongs to the Schwarz-class of rapidly decreasing functions. While this is not in doubt, proving it is slightly technical since we are dealing with the exponential of a sum of two non-commuting matrices, and there are no simple opper bounds we are aware off of for example $|| e^{A + B } || $ en termes of $|| e^A || $ and $|| e^B || $ when $A $ and $B $ are non-commuting matrices.

\begin{lemma} \textcolor{blue}{ - lemme technique: peut \^etre saut\'e en premi\`ere lecture - } $\xi \in \exp ( - T ( \frac{1 }{2 } (\xi ^2 + i \xi ) \Sigma ^2 - Q ) ) $ is a rapidly decreasing function of $\xi $ (with values in the space of $N $-dimensional matrices), and (\ref{eq: FT_call}) is therefore well-defined as a tempered distribution, for ant tempered distribution $c(x, 0 ) . $
\end{lemma}

\begin{proof} We will exploit the fact that $P(t) := e^{t Q } $ is a row-stochastic non-negative matrix, since
    $$
        P_{ij } (t) = \mathbb{P } (X_t = j | X_0 = i ) ,
    $$
    and therefore $\sum _j P_{ij } (t ) = 1 . $
    If $|| v ||_{\infty } := \max _i |v_i | $ is the sup-norm on $\mathbb{C }^N $, then any non-negative row-stochastic matrix $P $ is a contraction with respect to this norm:
    $$
        || P v ||_{\infty } \leq || v ||_{\infty } ,
    $$
    as is easily checked\footnote{Since $P_{ij } \geq 0 $, $|| Pv ||_{\infty } = \max _i  | \sum _j P_{ij } |v_j | \leq \max _i \sum _j P_{ij } || v ||_{\infty } = || v ||_{\infty } $, since $\sum _j P_{ij } = 1 . $ }.

    Next, we recall Lie's formula \textcolor{blue}{(reference \cite{? })}:
    $$
        e^{A + B } = \lim _{n \to \infty } \left( e^{A/n } e^{B/n } \right)^n ,
    $$
    which implies that $|| e^{A + B } || \leq \lim _{n \to \infty } || e^{A/n } || ^n \, || e^{B / n } || ^n $ for any matrix-norm $|| A || $, and in particular for $|| A ||_{\infty } = \sup _{|| v ||_{\infty } = 1 } || A v ||_{\infty } . $ Applying this with $A = - T (\xi ^2 + i \xi ) \Sigma ^2 $ and $B = T Q $ and using that $|| e^{T Q / n } ||_{\infty } \leq 1 $ (in fact, equal to 1, since if $P $ is a stochastic matrix, $P \mathbf{1 } = \mathbf{1 } $, which shows that $\sup _{|| v ||_{\infty } = 1 } || P v ||_{\infty } = 1 $), we find that
    $$
        \left | \left | \, e^{- T(\xi ^2 + i \xi ) \Sigma ^2 + T Q } \, \right | \right | _{\infty } \leq \lim _{n \to \infty } \, \left | \left | \, e^{ - \frac{T }{n } (\xi ^2 + i \xi ) \Sigma ^2 } \, \right | \right | _{\infty } ^n
    $$
    If $\Lambda = {\rm diag} ( \lambda _1 , \ldots , \Lambda _N ) $ is diagonal, then $|| \Lambda ||_{\infty } \leq \max _i |\lambda _i | . $ Applying this to $\Lambda = \exp ( - \frac{T }{2n } (\xi ^2 + i \xi ) \Sigma ^2 ) $ with $\lambda _j = e^{- (T/2n ) (\xi ^2 + i \xi ) \sigma _j ^2 } $, we see that the right hand side equals
    $$
        \left | \left | \, e^{- T(\xi ^2 + i \xi ) \Sigma ^2 + T Q } \, \right | \right | _{\infty } \leq \lim _{n \to \infty } \left( e^{ - \frac{T }{2n } \xi ^2 \min _j \sigma _j ^2 } \right) ^n = e^{- T \xi ^2 (\min _j \sigma _j ^2 ) / 2 } ,
    $$
    which is rapidly decreasing in $\xi . $

    We next examine the derivatives with respect to $\xi \in \mathbb{R } $ of $e^{- T (\xi ^2 + i \xi ) \Sigma ^2 + T Q } . $ Again, there is no closed formula for the derivative with respect to $\xi $, since the matrices $\Sigma ^2 $ and $Q $ do not commute. We will use the following formula [Wilcox, R. M., Exponential operators and parameter differentiation in quantum physics, J. Math. Phys  (1967)]: if $A(\xi ) $ is a $C^1 $ matrix-valued function on $\mathbb{R } $, then
    $$
        \frac{d }{d \xi } e^{t A (\xi ) } = \int _0 ^t e^{(t - s ) A(\xi ) } A'(\xi ) e^{s A (\xi ) } ds .
    $$
    Applying this with $t = 1 $ to $A(\xi ) = - \frac{1 }{2 } T ((\xi ^2 + i \xi ) \Sigma ^2 - Q ) $ and using our estimate above for the norm of $e^{A(\xi ) } $ we find
    $$
        \left | \left | \frac{d }{d \xi } e^{A (\xi ) } \right | \right | _{\infty } \leq C (|\xi | + 1 ) \int _0 ^1 || e^{- s A (\xi ) } ||_{\infty } || e^{(1 - s ) A(\xi ) } ||_{\infty } ds \leq C (|\xi | + 1 ) e^{- T \xi ^2 (\min _j \sigma _j ^2 ) / 2 } ,
    $$
    with $C = T || \Sigma ^2 ||_{\infty } = T \max _j \sigma _j ^2 $, and where the $\ell ^{\infty } $-norm can of course be replaced by any other matrix norm. Higher order derivatives cab be treated by iterating Wilcox's formula, e.g.
    \begin{eqnarray*}
        \frac{d^2 }{d \xi ^2 } e^{t A (\xi ) } &=& \int _0 ^t e^{(t - s ) A } A''(\xi ) e^{s A } ds + \int _0 ^t \left( \int _0 ^{t - s } e^{(t - s - u ) A } A'(\xi ) e^{u  A } du \right) A'(\xi ) e^{s A } ds \\
        &\ & + \left( \int _0 ^t e^{(t - s ) A } A'(\xi ) \int _0 ^s e^{(s - u ) A } A'(\xi ) e^{u A } du \right) ds ;
    \end{eqnarray*}

\end{proof}

The fact that $\Sigma ^2 $ and $Q $ will never commute, except in trivial cases\footnote{if all $\sigma _i ^2 $ are distinct, then $[ \Sigma ^2 , Q ] = 0 $ with $Q \neq 0 $ implies that $Q $ is a permutation matrix \textcolor{blue}{(au moins, je crois)}. The row sums of a permutation matrix are all equal to 1, so $Q $ cannot be the generator of a Markov chain then.  If for example $\sigma _1 ^2 = \sigma _2 ^2 $, then $\Sigma ^2 $ can commute with non-zero generator matrices $Q $ whose non-zero elements correspond to transitions between states 1 and 2, but these will then have no effect on the volatility $S_t $} will be the cause of most of the technical problems in this paper, and makes the direct and inverse problem of option pricing in our hidden Markov model interesting and non-trivial, even in the simplest case of a two-state Markov chain.
\medskip

The (distributional) Fourier transform of $c(x, 0 ) = \max (S_0 - e^x , 0 ) $ can be computed explicitly, and is equal to
\begin{equation}
    \widehat{c } (\xi , 0 ) = i S_0 ^{1 - i \xi } \left( \frac{1 }{\xi + i 0 } - \frac{1 }{\xi + i } \right) ,
\end{equation}
where $(\xi + i 0 )^{-1 } := \lim _{\varepsilon \to 0+ } (\xi + \varepsilon )^{-1 }  = {\rm pv } (1 / \xi ) - i \pi \delta _0 (\xi ) . $
\medskip

\noindent \textcolor{blue}{{\bf D\'etails du calcul}: $c_0 (x) := \max (S_0 - e^x , 0 ) $ n'est pas int\'egrable, mais $c_{\varepsilon } (x) := e^{\varepsilon x } \max (S_0 - e^x , 0 ) $ l'est, pour tout $\varepsilon > 0 $, et $c_{\varepsilon } \to c_0 $ comme distributions temper\'ees, et donc $\widehat{c }_{\varepsilon } \to \widehat{c } . $ Or,
    \begin{eqnarray*}
        \widehat{c }_{\varepsilon } (\xi ) &=& \int _{\mathbb{R } } c_0 (x) e^{\varepsilon x - i x \xi } dx \\
        &=& \int _{- \infty } ^{\log S_0 } \left( S_0 e^{(\varepsilon - i \xi ) x } - e^{(\varepsilon + 1 - i \xi ) x } \right) dx \\
        &=& S_0 \cdot \frac{e^{(\varepsilon - i \xi ) \log S_0 } }{\varepsilon - i \xi } - \frac{e^{(\varepsilon + 1 - i \xi ) \log S_0 } }{\varepsilon + 1 - i \xi } \\
        &=& i S_0 ^{1 + \varepsilon - i \xi } \left( \frac{1 }{\xi + i \varepsilon } - \frac{1 }{\xi + i (1 + \varepsilon ) } \right) \\
        &\to & S_0 ^{1 - i \xi } \left( \frac{1 }{\xi + i 0 } - \frac{1 }{\xi + i } \right) .
    \end{eqnarray*}
}
Note that away from $\xi = 0 $, $\widehat{c } (\xi , 0 ) $ can be identified with a non-vanishing locally integrable function. It follows that if we would know all call prices $C_1 (S_0 , 0 ; K , T ) = (C(S_0 , 0 ; K, T ) , e_1 ) $, for all positive $K $ and $T $, assuming without essential loss of generality that at the time of observation $t = 0 $ we are in the hidden Markov state 1, then we would know the function $(c(x, T ) , e_1 ) $ and therefore its Fourier transform $(\widehat{c } (\xi , T ) , e_1 ) $ given by (\ref{eq: FT_call}). Since $\widehat{c } (\xi , 0 ) \neq 0 $ for all $\xi \neq 0 $, this implies that we would know the function
\begin{equation}
    \left( e^{ - T (\zeta \Sigma ^2 - Q ) } \mathbf{1 } , e_1 \right) ,   \ \ (\xi , T ) \in \mathbb{R } \times \mathbb{R }_{> 0 } ,
\end{equation}
where we put $\zeta = \zeta (\xi ) := \xi ^2 + i \xi $, to simplify notations. In particular, evaluating the derivatives $\partial _T ^k $ at $T = 0 $, we would know
\begin{equation} \label{eq:donn�es_Pb_Inv}
    \left( \, ( - \zeta \Sigma ^2 + Q ) ^k \mathbf{1 } , e_1 \right) , \ \ k = 0, 1, 2, \ldots
\end{equation}
and the inverse problem we study becomes

\begin{question} How much of the matrices $\Sigma ^2 $ and $Q $ can one reconstruct from knowledge of (\ref{eq:donn�es_Pb_Inv}) (under appropriate conitions on $\Sigma ^2 $ and on $Q $)?
\end{question}

We note in passing that since (\ref{eq:donn�es_Pb_Inv}) are polynomials in $\zeta $, if we know them for all $\zeta $ of the form $\zeta = \xi ^2 - i \xi $, we know them for all $\zeta \in \mathbb{C } $ (in fact, we only need to know their values on $k + 1 $ different points). %In particular, we can replace $- \zeta $ by $\zeta $, as we will sometimes do.
\medskip

\subsection{Relation between (\ref{eq:donn�es_Pb_Inv}) and observed option prices} We can take $S_0 = 1 $ without essential loss of generality. We first note that
$$
    (\xi ^2 + i \xi ) \widehat{c } (\xi , 0 ) =   \xi (\xi + i ) \cdot i \left( \frac{1 }{\xi + i 0 } - \frac{1 }{\xi + i } \right) = i ( (\xi + i ) - \xi ) = -1 ,
$$
(which is equivalent to $(\partial _x ^2 - \partial _x ) c(x, 0 ) = \delta _0 $). Therefore
$$
    (\xi ^2 + i \xi ) \widehat{c } (\xi , T ) %= c(\xi , T )
    = - e^{ T ( - \frac{1 }{2 } %(\xi ^2 + i \xi  )
            \zeta \Sigma ^2 + Q ) } \mathbf{1 } ,
$$
where $\zeta := \zeta (\xi ) := \xi ^2 + i \xi $, and
$$
    %\left( \,
    ( - \zeta \Sigma ^2 + Q ) ^k \mathbf{1 } %, e_1 \right)
    = - (\xi ^2 + i \xi ) \frac{\partial ^k }{\partial T ^k } %e^{- T ( \frac{1 }{2 } (\xi ^2 + i \xi  )\Sigma ^2 - Q ) }
    \widehat{c } (\xi , T ) |_{T = 0 } ,
$$
Now
$$
    ( - \zeta \Sigma ^2 + Q )^k = \sum _{j = 0 } ^k P^{(k) } _j (\Sigma ^2 , Q ) (-1 )^j \zeta ^j ,
$$
where $P^{(k) } _j (\Sigma ^2 , Q ) $ s a polynomial in the nonommuting (!) variables $\Sigma ^2 $ and $Q $: for example, $P^{(k)} _0 (\Sigma ^2 , Q ) = Q^k $, while
$$
    P^{(k)}  _1 (\Sigma ^2 , Q ) = Q^{k - 1 } \Sigma ^2 + Q^{k - 2 } \Sigma ^2 Q + \cdots + \Sigma ^2 Q^{k - 1 } .
$$
Note that since $Q \mathbf{1 } = 0 $,
$$
    \left( \, P^{(k) }  _1 (\Sigma ^2 , Q ) \mathbf{1 } , e_1 \, \right) = (Q^{k - 1 } \Sigma ^2 \mathbf{1 } , e_1 ) ,
$$
that is, only the first term survives when looking at the for us relevant matrix element.

Remembering that $\zeta = \xi ^2 + i \xi $, we therefore have
\begin{eqnarray*}
    P^{(k) } _j (\Sigma ^2 , Q ) &=& \frac{(-1 )^j }{(2j )! } \partial _{\xi } ^{2j } ( - \zeta \Sigma ^2 + Q )^k |_{\xi = 0 } \\
    &=& - \frac{(-1 )^j }{(2j )! } \partial _{\xi } ^{2j } \partial _T ^k \left( \, (\xi ^2 + i \xi ) \widehat{c } (\xi , T ) \right) |_{\xi = 0 , T = 0 }
\end{eqnarray*}
Now
$$
    - \partial _{\xi } ^{2j } (\xi ^2 + i \xi ) \widehat{c } (\xi , T ) = \mathcal{F }_{x \to \xi } \left( (ix )^{2j } (\partial _x ^2 - \partial _x ) c(x, T ) \right) ,
$$
so that we find that
\begin{equation} \label{eq:donn�es_IP_bis}
    p_{k, j } := \left( \, P^{(k) } _j (\Sigma ^2 , Q ) \mathbf{1 } , e_1 \, \right)  = \int _{\mathbb{R } } x^{2j } (\partial _x ^2 - \partial _x ) \partial _T ^k c_1 (x, T ) \big{\vert }_{T = 0 } dx
\end{equation}
Transforming variables back to $K = e^x $, we can also write this as
\begin{equation}
    %\left( \, p^k _j (\Sigma ^2 , Q ) \mathbf{1 } , e_1 \, \right) =
    p_{k, j } = \int _0 ^{\infty } (\log K )^{2j } \, \left( K^2 \partial _K ^2 \partial _T ^k C \right) (1 ; 0 , K, T ) \, \frac{dK }{K } \ \ (?)
\end{equation}
which can obviously be determined from observed option prices.

\section{\bf Inverse option pricing problem for a two-state Markov chain} In this subsection we show that if $N = 2 $, then (\ref{eq:donn�es_IP_bis}) with $k = 1, 2, 3 $ uniquely determine the $\sigma _k ^2 $  and the $q_{ij} . $ First of all, since the row-sums of $Q $ are 0 ($Q \mathbf{1 } = 0 $), we have
$$
    Q = \begin{pmatrix} - q_{12 } & q_{12 }    \\
                q_{21 }   & - q _{21 }
    \end{pmatrix}
$$
so $Q $ is determined by the two parameters $q_{12 } $ and $q_{21 } $ which, together with the two volatilies (squared) $\sigma _1 ^2 $ and $\sigma _2 ^2 $ makes for a total of 4 parameters to be determined. Next we look at $(- \zeta \Sigma ^2 + Q )^k $ which we expand for $k = 1 , 2 $ and $3 $: we put $\Sigma ^2 = V $, to simplify the appearance of the formulas and avoid confusion with the powers of $\Sigma $ which occur (which are forcibly even). For $k = 1 $ there is nothing to do, while for the other $k $'s we find
$$
    \begin{array}{cccc}
        (- \zeta V + Q )^2 & =  & \zeta ^2 V ^2 - (V Q + Q V) \zeta + Q^2            \\
        (- \zeta V + Q )^3 & =  & - \zeta ^3 V^3 + \zeta ^2 (V^2 Q + V Q V + Q V^2 ) \\
        \                  & \  & - \ \zeta (Q^2 V + QVQ + V Q^2 ) + Q^3
    \end{array}
$$
When applying this to the vector $\mathbf{1 } $, all terms starting with a $Q $ on the left will be 0, so (\ref{eq:donn�es_IP_bis}) will give us
$$
    p_{1, 1 } = (V \mathbf{1 } , e_1 ) = \sigma _1 ^2 , \ p_{2, 2 } = (V^2 \mathbf{1 } , e_1 ) = \sigma _1 ^4 ,  \ p_{3, 3 } = (V^2 \mathbf{1 } , e_1 ) = \sigma _1 ^6 ,
$$
which are all dependent. We already observed that $p_{1, 0 } = (Q \mathbf{1 } , e_1 ) = 0 $, and similarly for the other $p_{k, 0 } . $ Next,
\begin{equation} \label{eq:two_state_1}
    p_{2, 1 } = (Q V \mathbf{1 } , e_1 ) , \ p_{3, 2 } = ((V Q V + Q V^2 ) \mathbf{1 } , e_1 ) = \sigma _1 ^2 (Q V \mathbf{1 } , e_1 ) + (Q V^2 \mathbf{1 } , e_1 ) ,
\end{equation}
so that the last equation translates into
\begin{equation} \label{eq:two_state_2}
    (Q V^2 \mathbf{1 } , e_1 ) = p_{3, 2 } - \sigma _1 ^2 p_{2, 1 } = p_{3, 2 } - p_{1, 1 } p_{2, 1 } ,
\end{equation}
while finally
\begin{equation} \label{eq:two_state_3}
    p_{3, 1 } = (Q^2 V \mathbf{1 } , e_1 ) .
\end{equation}
Computing $Q V \mathbf{1 } = Q (\sigma _1 ^2 , \sigma _2 ^2 )^t $ and $Q V^2 \mathbf{1 } $, the first equation of (\ref{eq:two_state_1}) and (\ref{eq:two_state_2}) give
$$
    \begin{array}{ll}
        q_{12 } \, (\sigma _2 ^2 - \sigma _1 ^2 ) = p_{2, 1 } \\
        q_{12 } \, (\sigma _2 ^4 - \sigma _1 ^2 ) = p_{3, 2 } - p_{1, 1 } p_{2, 1 } .
    \end{array}
$$
Dividing the second equation by the first, we find $\sigma _2 ^2 + \sigma _1 ^2 = (p_{3 , 2 } - p_{1, 1 } p_{2, 1 } ) / p_{2, 1 } = (p_{3 , 2 } / p_{2, 1 } ) - p_{1, 1 }  $, so that
$$
    \sigma _2 ^2 = \frac{p_{3, 2 } }{p_{2, 1 } } - 2 p_{1, 1 } .
$$
The first equation then yields $q_{12 } $:
$$
    q_{12 } = \frac{p_{2, 1 } }{\sigma _2 ^2 - \sigma _1 ^2 } = \frac{(p_{2, 1 } )^2 }{p_{3, 2 } - 3 p_{1, 1 } p_{2, 1 } } .
$$
Finally (\ref{eq:two_state_3}) translates into
$$
    (\sigma _1 ^2 - \sigma _2 ^2 ) (q_{12 }^2 + q_{12 } q_{21 } ) = p_{3, 1 } ,
$$
with solution
$$
    q_{21 } = \frac{p_{3, 1 } + (\sigma _2 ^2 - \sigma _1 ^2 ) q_{12 } ^2 }{q_{12 } (\sigma _1 ^2 - \sigma _2 ^2 ) } = \frac{p_{3, 1 } }{q_{12 } (\sigma _1 ^2 - \sigma _2 ^2 ) } - q_{12 } = - \frac{p_{3, 1 } }{p_{2, 1 } } - q_{12 } .
$$
\textcolor{blue}{Calculs \`a v\'erifier encore; formuler tout ceci comme th\'eor\`eme;  }

\begin{theorem} Suppose all call-prices $C (S_0 = 1 , 0 ; K, T ) $ are known. If
    \begin{equation}
        %\left( \, p^k _j (\Sigma ^2 , Q ) \mathbf{1 } , e_1 \, \right) =
        p_{k, j } = \int _0 ^{\infty } (\log K )^{2j } \, \left( K^2 \partial _K ^2 \partial _T ^k C \right) (1 ; 0 , K, T ) \, \frac{dK }{K } ,
    \end{equation}
    then if $N = 2 $, the model parameters are given by ...
\end{theorem}

\begin{thebibliography}{article}

    \bibitem{XRM} X. Xi, M. Rodrigo and R.S. Mamon, 2012, Parameter estimation of a regime-switching model using an inverse Stieltjes moment approach?, In: {\it Stochastic Processes, Finance and Control (Festschrift in Honour of Robert Elliott's 70th Birthday)}, Advances in Statistics, Probability and Actuarial Science, Volume I , (eds.: Cohen, S., Madan, D., Siu, T. and Yang, H.), World Scientific, 549-569

\end{thebibliography}

\end{document}

\end{document}


\documentclass{memoir}
\usepackage{notestemplate}

% \begin{figure}[ht]
%     \centering
%     \incfig{riemmans-theorem}
%     \caption{Riemmans theorem}
%     \label{fig:riemmans-theorem}
% \end{figure}

\begin{document}

\begin{defn}[Power Series]
A \textbf{power series} is an infinite sum of monomials
\begin{align*}
	\sum_{n=0}^{\infty} a_n (z-z_0)^{n}
\end{align*}
where \(\left\{ a_n \right\},z_0  \in \C\) and \(z\) is a complex variable. We call \(z_0\) the \textbf{center} of the power series.
\end{defn}
Notice that we make no statements thus far in terms of convergence. Furthermore, one can take \(a_n = 0\) for \(n\geq N\) in order to express a finite power series.\\

\begin{anki}
TARGET DECK
Complex Qual::Complex Analysis
START
MathJaxCloze
Text: A **power series** is an infinite sum of monomials
{{c1::\(\begin{align*}
        	\sum_{n=0}^{\infty} a_n (z-z_0)^{n}
        \end{align*}\)}}
where \(\left\{ a_n \right\},z_0  \in \C\) and \(z\) is a complex variable. We call \(z_0\) the \textbf{center} of the power series.
Extra: One can take \(a_n = 0\) for \(n\geq N\) in order to express a finite power series.
Tags: analysis complex_analysis power_series defn
<!--ID: 1624504053797-->
END
\end{anki}

We briefly describe a stronger form of convergence before looking closer at the convergence of power series:
\begin{defn}[Uniform Convergence]
	Let \(\left\{ f_n \right\} \) be a sequence of complex-valued functions on a set \(\Omega\subset \C\). The sequence \(\left\{ f_n \right\} \) is \textbf{uniformly convergent} on \(E\) with
	\begin{align*}
		\lim_{n \to \infty} f_n = f
	\end{align*}
	if for every \(\varepsilon>0\), there exists an \(N \in \N\) such that, for all \(n\geq N\) and \(z \in \Omega\)
	\begin{align*}
		\left| f_n(z) - f(z) \right| \leq \varepsilon.
	\end{align*}
\end{defn}

\begin{anki}
START
MathJaxCloze
Text: Let \(\left\{ f_n \right\} \) be a sequence of complex-valued functions on a set \(\Omega\subset \C\). The sequence \(\left\{ f_n \right\} \) is **uniformly convergent** on \(E\) with
\(\begin{align*}
  	\lim_{n \to \infty} f_n = f
  \end{align*}\)
	if {{c1::for every \(\varepsilon>0\)}}, {{c1::there exists an \(N \in \N\)}} such that, {{c1::for all \(n\geq N\)}} and {{c1::\(z \in \Omega\)}}:
	{{c1::\(\begin{align*}
	        	\left| f_n(z) - f(z) \right| \leq \varepsilon.
	        \end{align*}\)}}
Tags: analysis complex_analysis defn complex_convergence
<!--ID: 1624504053886-->
END
\end{anki}

Of course, there are less strong and more general notions of convergence:

\begin{defn}[Absolute Convergence]
	A sequence of complex numbers \(\left\{ z_n \right\}\subset \C \) \textbf{absolutely converges} if
	\begin{align*}
	\sum_{n=0}^{\infty} \left| z_n \right|
	\end{align*}
	converges.
\end{defn}

\begin{anki}
START
MathJaxCloze
Text: A sequence of complex numbers \(\left\{ z_n \right\} \subset \C \) **absolutely converges** if
 {{c1::\(\begin{align*}
        \sum_{n=0}^{\infty} \left| z_n \right|
        \end{align*}\)}}
	converges.
Extra: A power series is absolutely convergent at a point \(z_1\) if the power series evaluated at \(z_1\) is absolutely convergent.
Tags:
<!--ID: 1624504053923-->
END
\end{anki}

We urge the reader to be cautious. The sum above is not a power series, and so it does not make semantic sense for a power series to absolutely converge. However, if we fix \(z = z_1\), then we can ask if the power series (absolutely) converges for \(z = z_1\).\\

\begin{prop}
	Absolute convergence implies convergence.
\end{prop}

Observe that if \(z = z_1\) is fixed and the power series is absolutely convergent for that \(z\):
\begin{align*}
	\sum_{n=0}^{\infty} \left| a_n (z-z_0)^{n} \right|
\end{align*}
then
\begin{align*}
	\sum_{n=0}^{\infty} \left| a_n (z-z_0)^{n} \right| = \sum_{n=0}^{\infty} \left| a_n \right| \left| z-z_0 \right|^{n}.
\end{align*}
We will use this form when discussing the absolute convergence of a power series at a point. One can verify that the first sum converges if and only if the second sum converges.

\begin{prop}
	Given a power series
	\begin{align*}
	\sum_{n=0}^{\infty} a_n (z-z_0)^{n},
	\end{align*}
	assume it converges absolutely for some \(z=z_1\). Then the power series converges for all \(z\) such that \(\left| z-z_0 \right| \leq \left| z_1-z_0 \right| \).
\end{prop}
This is a slight simplification. Absolute convergence is uniform in every closed subdisc-- that is, every compact subset within the disc is absolutely convergent. In other words, if a power series absolutely converges for \(z = z_1\), it convergences absolutely and locally uniformly within the disc determined by \(z_1-z_0 \).

\begin{thm}
	Given a power series \(\sum_{n=0}^{\infty} a_n (z-z_0)^{n}\) there exists \(0\leq R\leq \infty\) such that:
	\begin{itemize}
		\item If \(\left| z-z_0 \right| <R\) the series converges absolutely
		\item If \(\left| z -z_0\right| >R\) the series diverges
	\end{itemize}
	Using the convention that \(\frac{1}{0}= \infty\) and \(\frac{1}{\infty}=0\), then \(R\) is given by Hadamard's formula:
	\begin{align*}
		\frac{1}{R}= \limsup \left| a_n \right|^{1 / n} .
	\end{align*}
	The number \(R\) is called the \textbf{radius of convergence} of the power series, and the region \(\left| z-z_0 \right| <R\) is the \textbf{disc of convergence}.
\end{thm}

Notice that the theorem above makes no statement as to convergence on the boundary. On the boundary, it is unclear whether we have convergence or divergence.

\begin{proof}

\end{proof}

\begin{anki}
START
MathJaxCloze
Text: Given a power series \(\sum_{n=0}^{\infty} a_n (z-z_0)^{n}\) there exists \(0\leq R\leq \infty\) such that:

* {{c1::If \(\left| z-z_0 \right| <R\) the series converges absolutely}}
* {{c1::If \(\left| z -z_0\right| >R\) the series diverges}}

Using the convention that \(\frac{1}{0}= \infty\) and \(\frac{1}{\infty}=0\), then \(R\) is given by Hadamard's formula:
 {{c2::\(\begin{align*}
        	\frac{1}{R}= \limsup \left| a_n \right|^{1 / n} .
        \end{align*}\)}}
	The number \(R\) is called the \textbf{radius of convergence} of the power series, and the region {{c1::\(\left| z-z_0 \right| <R\)}}  is the \textbf{disc of convergence}.
Tags: analysis complex_analysis power_series defn
<!--ID: 1624504053960-->
END
\end{anki}

\begin{exmp}[Trigonometric Functions]
	Consider the power series given by
	\begin{align*}
		e^{z} &:= \sum_{n=0}^{\infty} \frac{1}{n!}z^{n}\\
		\cos (z) &:= \sum_{n=0}^{\infty} a_n z^{n}\\
		\sin (z) &:= \sum_{n=0}^{\infty} b_n z^{n}
	\end{align*}
	where
	\begin{align*}
		a_n &= \begin{cases}
			\frac{(-1)^{n}}{(2n)!} & n \equiv 0 \pmod{2} \\
			0 & n \equiv 1 \pmod{2}
		\end{cases}\\
		b_n &= \begin{cases}
			0 & n \equiv 0 \pmod{2}\\
			\frac{(-1)^{n}}{(2n+1)!} & n \equiv 1 \pmod{2}
		\end{cases}.
	\end{align*}
	These power series are absolutely convergent in the whole complex plane. One can check that they agree with the usual exponential, cosine, and sine function of the real plane when \(z\) is real. Within the context of complex analysis, we instead choose to define the functions by the above series.
\end{exmp}

\begin{anki}
START
MathJaxCloze
Text: Consider the power series given by
	\begin{align*}
		e^{z} &:= {{c1::\sum_{n=0}^{\infty} \frac{1}{n!}z^{n}}} \\
		\cos (z) &:= \sum_{n=0}^{\infty} a_n z^{n}\\
		\sin (z) &:= \sum_{n=0}^{\infty} b_n z^{n}
	\end{align*}
	where
	\begin{align*}
		a_n &= {{c2::\begin{cases}
			\frac{(-1)^{n}}{(2n)!} & n \equiv 0 \pmod{2} \\
			0 & n \equiv 1 \pmod{2}
		\end{cases} }} \\
		b_n &= {{c3::\begin{cases}
			0 & n \equiv 0 \pmod{2}\\
			\frac{(-1)^{n}}{(2n+1)!} & n \equiv 1 \pmod{2}
		\end{cases} }} .
	\end{align*}
Extra: These power series are absolutely convergent in the whole complex plane. One can check that they agree with the usual exponential, cosine, and sine function of the real plane when \(z\) is real. Within the context of complex analysis, we instead choose to define the functions by the above series.
Tags: analysis complex_analysis power_series
<!--ID: 1624504053995-->
END
\end{anki}

\begin{hw}
	Show that \(e^{z}, \cos(z), \sin(z)\) converge for all \(z \in \C\). Then show that
	\begin{align*}
		\cos(z) = \frac{1}{2}\left( e^{iz} + e^{-iz} \right) \\
		\sin(z) = \frac{1}{2i} \left( e^{iz} - e^{-iz} \right) .
	\end{align*}
	We call the above formulas the \textbf{Euler formulas} for the cosine and sine functions.
\end{hw}

\begin{hw}
	Show that \(e^{z}\) is the only solution to
	\begin{align*}
		f'(z) = f(z)
	\end{align*}
	with \(f(0) = 1\). Use this formulation of \(e^{z}\) to show that
	\begin{align*}
		e^{a+b} = e^{a}e^{b}
	\end{align*}
	Many references choose to define \(e^{z}\) as the unique solution to the differential equation above. Proving this bridges the gap between the two definitions, and now either formulation can be used interchangably.
\end{hw}

\begin{prop}
	\begin{align*}
		e^{2 \pi i} = 1.
	\end{align*}
\end{prop}
\begin{proof}
	Observe that
	\begin{align*}
		e^{z} = (\cos(z),\sin(z))
	\end{align*}
	and hence
	\begin{align*}
		e^{2\pi i} = \left( \cos(2\pi i), \sin(2\pi i) \right) = \left( 1,0 \right) = 1.
	\end{align*}
\end{proof}

\begin{exmp}[Logarithm]
We define the \textbf{logarithm} to be the inverse function of the exponential:
\begin{align*}
	\log: \C\setminus\left\{ 0 \right\} \to \C
	\log(e^{z}) := z
\end{align*}
Hence by definition, the domain of \(\log\) is the range of \(e^{z}\), that is, \(\C\setminus \left\{ 0 \right\} \).\\

First, notice that the logarithm is not injective. To see this, write \(z = (x,y)\) and notice that
\begin{align*}
	e^{z} = e^{(x,y)} = e^{(x,0)}e^{(0,y)} = e^{(x,0)}e^{(0,2\pi k+ y}
\end{align*}
for \(k \in \Z\). Hence the real part is unique, but the imaginary part is only unique up to multiples of \(2\pi \). We refer to the real part of the logarithm as the \textbf{real logarithm}, and note that it is given by
\begin{align*}
	\log(e^{(x,0)}) = \left| z \right| .
\end{align*}
The imaginary part is referred to as the \textbf{argument of \(z\)} and is given by
\begin{align*}
	\log(e^{(0,y)}) = \sfrac{z}{\left| z \right| }.
\end{align*}
When taking the argument of a complex number, we first must choose a \textbf{branch}-- an interval of length \(2\pi \) in which the argument is to lie. If unstated, then we implicitly are choosing the canonical branch \(0\leq \textrm{arg}(z)<2\pi \).\\

Geometrically, we can view the argument of \(z\) as the angle. Hence, for all \(z \in \C\setminus\left\{ 0 \right\} \), we have
\begin{align*}
	\log(z) = (\log\left| z \right|, \textrm{arg}(z)).
\end{align*}
Let the canonical branch be chosen. This function is not holomorphic on \(\C\setminus \left\{ 0 \right\}\), but is holomorphic on \(\C\setminus \left\{ z\in \R \mid z \leq 0 \right\} \). This is because there is a discontinuity on the negative real line.
\end{exmp}

\begin{thm}
	The power series \(f(z) = \sum_{n=0}^{\infty} a_n (z-z_0)^n\) is a holomorphic function in its disc of convergence. The derivative of \(f\) is also a power series obtained by differentiating term by term the series for \(f\), that is,
	\begin{align*}
		f'(z) = \sum_{n=0}^{\infty} na_n(z-z_0)^{n-1}
	\end{align*}
	Moreover, \(f'\) has the same radius of convergence as \(f\).
\end{thm}
\begin{proof}

\end{proof}

\begin{anki}
START
MathJaxCloze
Text: The power series \(f(z) = \sum_{n=0}^{\infty} a_n (z-z_0)^n\) is a {{c1::holomorphic function}} in its disc of convergence. The derivative of \(f\) is also a {{c1::power series}} obtained by {{c1::differentiating term by term the series for \(f\)}}, that is,
 {{c1::\(\begin{align*}
        	f'(z) = \sum_{n=0}^{\infty} na_n(z-z_0)^{n-1}
        \end{align*}\)}}
	Moreover, \(f'\) has the {{c1::same radius of convergence}} as \(f\).
Extra: A power series is infinitely complex differentiable in its disc of convergence, and the higher derivatives are also power series obtained by termwise differentiation.
Tags: analysis complex_analysis power_series complex_analyticity
<!--ID: 1624504054031-->
END
\end{anki}

\begin{cor}
	A power series is infinitely complex differentiable in its disc of convergence, and the higher derivatives are also power series obtained by termwise differentiation.
\end{cor}
This is an incredibly powerful statement. Compare this to real analysis-- in real analysis, we cannot infer a function has higher derivatives from the existence of a first derivative. The strength of this tool is that now if we want to show a complex equation is holomorphic in a region, we simply show that it is equal to a power series within the region, then show the region is within the power series' region of convergence. Now we formalize this idea:

\begin{defn}[Analytic]
	A function \(f\) defined on an open set is said to be \textbf{analytic} at a point \(z_0\) if there exists a power series centered at \(z_0\) with positive radius of convergence such that
	\begin{align*}
		f(z) = \sum_{n=0}^{\infty} a_n(z-z_0)^{n}
	\end{align*}
	for all \(z\) in a neighborhood of \(z_0\).\\

	If \(f\) has a power series expansion at every point in the open set, it is \textbf{analytic} on the open set.
\end{defn}
It follows immediately that an analytic function on \(\Omega \) is holomorphic on \(\Omega \). We will later show the converse.

\begin{anki}
START
MathJaxCloze
Text: A function \(f\) defined on an open set is said to be **analytic** at a point \(z_0\) if {{c1::there exists a power series centered at \(z_0\)}} with {{c1::positive radius of convergence}} such that
{{c1::\(\begin{align*}
        	f(z) = \sum_{n=0}^{\infty} a_n(z-z_0)^{n}
        \end{align*}\)}}
for all \(z\) in a neighborhood of \(z_0\).

If \(f\) has {{c1::a power series expansion}} at every point in the open set, it is **analytic** on the open set.
Extra: An analytic function on \(\Omega\) is holomorphic on \(\Omega\) (the converse also holds)
Tags: analysis complex_analysis defn power_series complex_analyticity
<!--ID: 1624504054064-->
END
\end{anki}

\begin{prop}
	If \(f,g\) are power series which converge absolutely on \(D(z_0,R)\), then \(f+g\) and \(fg\) converge absolutely on \(D(z_0,R)\). Furthermore, if \(\alpha  \in \C\), then \(\alpha f\) converges absolutely on \(D(z_0,R)\). In fact, we have:
	\begin{align*}
		(f+g)(z-z_0) = f(z-z_0) + g(z-z_0)\\
		(fg)(z-z_0) = f(z-z_0)g(z-z_0)\\
		(\alpha f)(z-z_0) = \alpha f(z-z_0)
	\end{align*}
	for all \(z \in D(z_0,R)\).
\end{prop}

\begin{anki}
START
MathJaxCloze
Text: If \(f,g\) are power series which converge absolutely on \(D(z_0,R)\), then \(f+g\) and \(fg\) {{c1::converge absolutely on \(D(z_0,R)\)}}. Furthermore, if \(\alpha  \in \C\), then {{c1::\(\alpha f\)}} converges absolutely on \(D(z_0,R)\). In fact, we have:
 {{c1::\(\begin{align*}
         	(f+g)(z-z_0) = f(z-z_0) + g(z-z_0)\\
         	(fg)(z-z_0) = f(z-z_0)g(z-z_0)\\
         	(\alpha f)(z-z_0) = \alpha f(z-z_0)
         \end{align*}\)}}
for all \(z \in D(z_0,R)\).
Tags: analysis complex_analysis power_series
<!--ID: 1624845302985-->
END
\end{anki}

This leads to the following theorem:
\begin{thm}
	\begin{enumerate}[(a).]
		\item Let \(f(z) = \sum_{n=0}^{\infty} a_n z^{n}\) be a non-constant power series with non-zero radius of convergence. If \(f(0) = 0\), then there exists a disc of radius \(s>0\) such that
			\begin{align*}
				f(z)\neq 0
			\end{align*}
			for all \(z \in D(0,s)\setminus\left\{ 0 \right\} \).
		\item Suppose that \(f,g\) are convergent power series with
			\begin{align*}
				f(z) = \sum_{n=0}^{\infty} a_n z^n\\
				g(z) = \sum_{n=0}^{\infty} b_n z^{n}.
			\end{align*}
			If \(f(z)=g(z)\) in any infinite set \(A\) with \(0 \in \overline{A}\), then \(f(z)=g(z)\) everywhere-- i.e. \(a_n = b_n\) for all \(n\).
	\end{enumerate}
\end{thm}
\begin{proof}

\end{proof}
This theorem is extremely useful for proving the uniqueness of holomorphic functions, as well as distinguishing holomorphic functions.

\begin{anki}
START
MathJaxCloze
Text:
* Let \(f(z) = \sum_{n=0}^{\infty} a_n z^{n}\) be a non-constant power series with non-zero radius of convergence. If \(f(0) = 0\), then there exists a {{c1::disc of radius \(s>0\)}} such that
{{c1::\(\begin{align*}
        f(z)\neq 0
        \end{align*}\)}}
for all {{c1::\(z \in D(0,s)\setminus\left\{ 0 \right\} \)}}.
* Suppose that \(f,g\) are convergent power series with
\(\begin{align*}
  f(z) = \sum_{n=0}^{\infty} a_n z^n\\
  g(z) = \sum_{n=0}^{\infty} b_n z^{n}.
  \end{align*}\)
If \(f(z)=g(z)\) in {{c2::any infinite set \(A\) with \(0 \in \overline{A}\)}}, then {{c2::\(f(z)=g(z)\) everywhere}}-- i.e. {{c2::\(a_n = b_n\) for all \(n\)::coefficients}}.
Tags: analysis complex_analysis power_series
<!--ID: 1624845303027-->
END
\end{anki}

\begin{prop}[Composition of Power Series]
	Let
	\begin{align*}
		f(z) = \sum_{n=0}^{\infty} a_n z^{n}\\
		g(z) = \sum_{n=0}^{\infty} b_n z^{n}
	\end{align*}
	be convergent power series, and assume that \(b_0 = 0\). If \(f(z)\) is absolutely convergent for \(z \in D(0,R)\), \(R>0\), and there exists an integer \(s>0\) so that
	\begin{align*}
		\sum_{n=0}^{\infty} \left| b_n \right| s^{n} \leq R
	\end{align*}
	then
	\begin{align*}
		h(z) = \sum_{n=0}^{\infty} a_n \left( \sum_{m=0}^{\infty} b_m z^{m} \right)^{n}
	\end{align*}
	converges absolutely for \(z \in D(0,s)\), and within this disc satisfies
	\begin{align*}
		h = f\circ g.
	\end{align*}
\end{prop}

\begin{anki}
START
MathJaxCloze
Text: Let
\(\begin{align*}
  	f(z) = \sum_{n=0}^{\infty} a_n z^{n}\\
  	g(z) = \sum_{n=0}^{\infty} b_n z^{n}
  \end{align*}\)
be convergent power series, and assume that \(b_0 = 0\). If \(f(z)\) is {{c1::absolutely convergent}} for {{c1::\(z \in D(0,R)\)}}, \(R>0\), and there exists {{c1::an integer \(s>0\)}} so that
{{c1::\(\begin{align*}
        	\sum_{n=0}^{\infty} \left| b_n \right| s^{n} \leq R
        \end{align*}\)}}
then
\(\begin{align*}
  	h(z) = \sum_{n=0}^{\infty} a_n \left( \sum_{m=0}^{\infty} b_m z^{m} \right)^{n}
  \end{align*}\)
{{c1::converges absolutely}} for {{c1::\(z \in D(0,s)\)}}, and within this disc satisfies
{{c1::\(\begin{align*}
        	h = f\circ g.
        \end{align*}\)}}
Tags: analysis complex_analysis power_series
<!--ID: 1624845303068-->
END
\end{anki}

There is a slightly more general form of power series that will be useful when discussing holomorphic functions.

\begin{defn}[Laurent Series]
A \textbf{Laurent series} is an infinite sum of monomials
\begin{align*}
	f(z) = \sum_{n-\infty}^{\infty} a_n (z-z_0)^{n}
\end{align*}
where \(\left\{ a_n \right\},z_0  \in \C\) and \(z\) is a complex variable. We say that the Laurent series \textbf{converges absolutely} on \(\Omega \subset \C\) if
\begin{align*}
	f^{+}(z) = \sum_{n=0}^{\infty} a_n (z-z_0)^{n}\\
	f^{-}(z) = \sum_{n=-\infty}^{-1} a_n (z-z_0)^{n}
\end{align*}
converges absolutely on \(\Omega \). Notice that if this holds, then
\begin{align*}
	f = f^{+}+ f^{-}.
\end{align*}
\end{defn}

\begin{anki}
START
MathJaxCloze
Text: A **Laurent series** is an infinite sum of monomials
 {{c1::\(\begin{align*}
         	f(z) = \sum_{n-\infty}^{\infty} a_n (z-z_0)^{n}
         \end{align*}\)}}
where \(\left\{ a_n \right\},z_0  \in \C\) and \(z\) is a complex variable. We say that the Laurent series **converges absolutely** on \(\Omega \subset \C\) if
{{c1::\(\begin{align*}
         	f^{+}(z) = \sum_{n=0}^{\infty} a_n (z-z_0)^{n}\\
         	f^{-}(z) = \sum_{n=-\infty}^{-1} a_n (z-z_0)^{n}
         \end{align*}\)}}
converges absolutely on \(\Omega \). Notice that if this holds, then
 {{c1::\(\begin{align*}
        	f = f^{+}+ f^{-}.
        \end{align*}\)}}
Tags: analysis complex_analysis power_series defn
<!--ID: 1625522318703-->
END
\end{anki}

\subsection{Obtaining Convergence and Absolute Convergence}
\label{sub:obtaining_absolute_convergence}
We will briefly develop a few tools that will help us show a series is absolutely convergent. As discussed earlier, this is a vital step in obtaining holomorphicity of a function.

\begin{thm}[Weierstrass M test]
	Let \(\left\{ f_n \right\} \) be a sequence of real or complex-valued functions, and \(\left\{ A_n \right\} \) a sequence of non-negative real numbers so that
	\begin{align*}
		\left| f_n(z) \right| \leq A_n
	\end{align*}
	for all \(z\) in some region \(\Omega\). If the sum
	\begin{align*}
		\sum_{n=0}^{\infty} A_n
	\end{align*}
	converges, then
	\begin{align*}
		\sum_{n=0}^{\infty} f_n(z)
	\end{align*}
	converges absolutely and uniformly on \(\Omega\).\\

	In this case, we call \(A_n\) a \textbf{majorant} of the \textbf{minorant} \(\left\{ f_n \right\} \).
\end{thm}

\begin{anki}
START
MathJaxCloze
Text: **Weierstrass M-test**
	Let \(\left\{ f_n \right\} \) be a sequence of real or complex-valued functions, and \(\left\{ A_n \right\} \) a sequence of non-negative real numbers so that
	{{c1::\(\begin{align*}
	        	\left| f_n(z) \right| \leq A_n
	        \end{align*}\)}}
	for all \(z\) in some region \(\Omega\). If
	{{c1::\(\begin{align*}
	        	\sum_{n=0}^{\infty} A_n
	        \end{align*}\)}}
	converges, then
	{{c1::\(\begin{align*}
	        	\sum_{n=0}^{\infty} f_n(z)
	        \end{align*}\)}}
	converges absolutely and uniformly on \(\Omega\).

In this case, we call \(A_n\) a **majorant** of the **minorant** \(\left\{ f_n \right\} \).
Tags: analysis complex_analysis power_series
<!--ID: 1624504054101-->
END
\end{anki}

We have another useful tool:

\begin{thm}[Abel's Limit Theorem]
	Let \(G(z)\) be a power series given by
	\begin{align*}
		G(z) = \sum_{n=0}^{\infty} a_n z^{n}
	\end{align*}
	Suppose that the sum below converges:
	\begin{align*}
		\sum_{n=0}^{\infty} a_n = a
	\end{align*}
	for some \(a \in \C\). Then
	\begin{align*}
		\lim_{z \to 1} G(z) = \sum_{n=0}^{\infty} a_n
	\end{align*}
	provided that \(z\) remains within a \textbf{Stolz sector}, that is, satisfies
	\begin{align*}
		\frac{\left| 1-z \right| }{1-\left| z \right| } \leq M
	\end{align*}
	for some \(M \in \R\).
\end{thm}
This is most useful when the radius of convergence of a power series is \(1\), as it can be used to find the limit of the power series from within the disc of convergence. Hence, even if the power series does not have a limit on the radius of convergence, we might be able to obtain an "inner limit" that we can use for calculations.

\begin{anki}
START
MathJaxCloze
Text: **Abel's Limit Theorem**
	Let \(G(z)\) be a power series given by
	\(\begin{align*}
	  	G(z) = \sum_{n=0}^{\infty} a_n z^{n}
	  \end{align*}\)
	Suppose that the sum below converges:
	\(\begin{align*}
	  	\sum_{n=0}^{\infty} a_n = a
	  \end{align*}\)
	for some \(a \in \C\). Then
	{{c1::\(\begin{align*}
	        	\lim_{z \to 1} G(z) = \sum_{n=0}^{\infty} a_n
	        \end{align*}\)}}
	provided that \(z\) remains within a \textbf{Stolz sector}, that is, satisfies
	{{c1::\(\begin{align*}
	        	\frac{\left| 1-z \right| }{1-\left| z \right| } \leq M
	        \end{align*}\)}}
	for some \(M \in \R\).
Tags:  analysis complex_analysis power_series
<!--ID: 1624504054138-->
END
\end{anki}

One last tool that will be helpful is Stirling's formula.

\begin{prop}[Stirling's Formula]
	\begin{align*}
		\sqrt{2\pi n} (n^{n}e^{-n}) \leq n! \leq e\sqrt{n} (n^{n}e^{-n})
	\end{align*}
	for all \(n \in \N\). Furthermore, \(n!\) limits towards the lower bound-- that is,
	\begin{align*}
		\lim_{n \to \infty} \frac{n!}{\sqrt{2\pi n} (n^{n}e^{-n})} =1.
	\end{align*}
	Sometimes, the approximation is written by
	\begin{align*}
		\ln n! \approx n\ln n - n.
	\end{align*}
\end{prop}
This can be useful when comparing power series to show radius of convergence.

\begin{exmp}[Radius of Convergence of Various Series]
	Consider the power series given below by
	\begin{align}
		\sum_{n=0}^{\infty} n! z^{n}\\
		\sum_{n=0}^{\infty} \frac{1}{n!}z^{n}\\
		\sum_{n=0}^{\infty} \frac{n!}{n^{n}}z^{n}\\
	\end{align}
	The radius of convergence of the first power series is 0 because \(\frac{n^{n}}{e^{n}z^{n}}\) is unbounded as \(n\to \infty\). Likewise, \(\frac{z^{n}}{n^{n}e^{n}}\) approaches zero as \(n\to \infty\) and hence the second series has infinite radius of convergence. A similar trick can be used to show that the third series' radius of convergence is \(e\).\\

	In general the ratio test states that if
	\begin{align*}
		\lim_{n \to \infty} \frac{a_{n+1}}{a_n} = A\geq 0
	\end{align*}
	for positive numbers \(a_n\), then
	\begin{align*}
		\lim_{n \to \infty} a_n^{\sfrac{1}{n}}=A.
	\end{align*}
\end{exmp}

\begin{exmp}[Binomial Series]
	Let \(\alpha  \in \C\) be a non-zero complex number. The \textbf{binomial coefficients} are given by
	\begin{align*}
	{\alpha\choose{n}} := \frac{\alpha (\alpha-1)\ldots(\alpha -n+1)}{n!}\\
	{\alpha \choose{0}}=1
	\end{align*}
	and the \textbf{binomial series} by
	\begin{align*}
		B_\alpha (T) := \sum_{n=0}^{\infty} {\alpha \choose{n}}z^{n} = (1+z)^{\alpha }.
	\end{align*}
	One can check that the second equality indeed holds, and in fact the radius of convergence of the binomial series is \(1\) provided that \(\alpha \) is not an integer \(\geq 0\).
\end{exmp}
\begin{proof}
	Observe that
	\begin{align*}
		\left| \frac{ {\alpha \choose{n+1}}}{ {\alpha \choose{n}}} \right| = \left| \frac{\alpha -n}{n+1} \right|
	\end{align*}
	and hence limits to \(1\). By the ratio test, the binomial sum has the radius of convergence desired.
\end{proof}

\end{document}


\documentclass[13pt,onlymath]{beamer}
\usefonttheme{serif}
\usepackage{graphicx,amsmath,amssymb,tikz,psfrag,epstopdf,fancyvrb}
\usepackage[lighttt]{lmodern}
%\usepackage{graphicx,psfrag}

\input defs.tex

%% formatting

\mode<presentation>
{
\usetheme{default}
}
\setbeamertemplate{navigation symbols}{}
\usecolortheme[rgb={0.13,0.28,0.59}]{structure}
\setbeamertemplate{itemize subitem}{--}
\setbeamertemplate{frametitle} {
    \begin{center}
      {\large\bf \insertframetitle}
    \end{center}
}

\newcommand\footlineon{
  \setbeamertemplate{footline} {
    \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,leftskip=.8cm,rightskip=.6cm]{structure}
      \footnotesize \insertsection
      \hfill
      {\insertframenumber}
    \end{beamercolorbox}
    \vskip 0.45cm
  }
}
\footlineon

\AtBeginSection[]
{
    \begin{frame}<beamer>
        \frametitle{Outline}
        \tableofcontents[currentsection,currentsubsection]
    \end{frame}
}

%% begin presentation

\title{\large \bfseries Combinatorial Games}

\author{Jaehyun Park\\[3ex]
CS 97SI\\
Stanford University}

\date{\today}

\begin{document}

\frame{
\thispagestyle{empty}
\titlepage
}

\begin{frame}{Combinatorial Games}
\BIT
\item Turn-based competitive multi-player games
\item Can be a simple win-or-lose game, or can involve points
\item Everyone has perfect information
\item Each turn, the player changes the current ``state'' using a valid ``move''
\item At some states, there are no valid moves
\BIT
\item The current player immediately loses at these states
\EIT
\EIT
\end{frame}

\section{Simple Games}

\begin{frame}{Combinatorial Game Example}
\BIT
\item Settings: There are $n$ stones in a pile. Two players take turns and remove 1 or 3 stones at a time. The one who takes the last stone wins. Find out the winner if both players play perfectly
\item State space: Each state can be represented by the number of remaining stones in the pile
\item Valid moves from state $x$: $x \rightarrow (x-1)$ or $x \rightarrow (x-3)$, as long as the resulting number is nonnegative
\item State 0 is the losing state
\EIT
\end{frame}

\begin{frame}{Example (continued)}
\BIT
\item No cycles in the state transitions
\BIT
\item Can solve the problem bottom-up (DP)
\EIT
\item A player wins if there is a way to force the opponent to lose
\BIT
\item Conversely, we lose if there is no such a way
\EIT
\item State $x$ is a winning state (W) if
\BIT
\item $(x-1)$ is a losing state,
\item OR $(x-3)$ is a losing state
\EIT
\item Otherwise, state $x$ is a losing state (L)
\EIT
\end{frame}

\begin{frame}{Example (continued)}
\BIT
\item DP table for small values of $n$:

\begin{center}
\begin{tabular}{|c|cccccccc|}
\hline
$n$&0&1&2&3&4&5&6&7 \\ \hline
W/L&L&W&L&W&L&W&L&W \\
\hline
\end{tabular}
\end{center}
\vfill
\item See a pattern?
\vfill
\item Let's prove our conjecture
\EIT
\end{frame}

\begin{frame}{Example (continued)}
\BIT
\item Conjecture: If $n$ is odd, the first player wins. If $n$ is even, the second player wins.
\vfill
\item Holds true for the base case $n=0$
\item In general,
\BIT
\item If $n$ is odd, we can remove one stone and give the opponent an even number of stones
\item If $n$ is even, no matter what we choose, we have to give an odd number of stones to the opponent
\EIT
\EIT
\end{frame}

\section{Minimax Algorithm}

\begin{frame}{More Complex Games}
\BIT
\item Settings: a competitive zero-sum two-player game
\item Zero-sum: if the first player's score is $x$, then the other player gets $-x$
\item Each player tries to maximize his/her own score
\item Both players play perfectly
\vfill
\item Can be solved using a \emph{minimax} algorithm
\EIT
\end{frame}

\begin{frame}{Minimax Algorithm}
\BIT
\item Recursive algorithm that decides the best move for the current player at a given state
\item Define $f(S)$ as the optimal score of the current player who starts at state $S$
\item Let $T_1, T_2, \ldots, T_m$ be states can be reached from $S$ using a single move
\item Let $T$ be the state that minimizes $f(T_i)$
\item Then, $f(S) = -f(T)$
\BIT
\item Intuition: minimizing the opponent's score maximizes my score
\EIT
\EIT
\end{frame}

\begin{frame}{Memoization}
\BIT
\item (Not \emph{memorization} but \emph{memoization})
\item A technique used to avoid repeated calculations in recursive functions
\item High-level idea: take a note (memo) of the return value of a function call. When the function is called with the same argument again, return the stored result
\item Each subproblem is solved at most once
\BIT
\item Some may not be solved at all!
\EIT
\EIT
\end{frame}

\begin{frame}[fragile]{Recursive Function without Memoization}
\begin{Verbatim}[xleftmargin=25pt]
int fib(int n)
{
    if(n <= 1) return n;
    return fib(n - 1) + fib(n - 2);
}
\end{Verbatim}
\vfill
\BIT
\item How many times is \verb,fib(1), called?
\EIT
\end{frame}

\begin{frame}[fragile]{Memoization using \texttt{std::map}}
\begin{Verbatim}[xleftmargin=25pt]
map<int, int> memo;
int fib(int n)
{
    if(memo.count(n)) return memo[n];
    if(n <= 1) return n;
    return memo[n] = fib(n - 1) + fib(n - 2);
}
\end{Verbatim}
\vfill
\BIT
\item How many times is \verb,fib(1), called?
\EIT
\end{frame}

\begin{frame}{Minimax Algorithm Pseudocode}
\BIT
\item Given state $S$, want to compute $f(S)$
\vfill
\item If we know $f(S)$ already, return it
\item Set return value $x \leftarrow -\infty$
\item For each valid next state $T$:
\BIT
\item Update return value $x \leftarrow \max\{x, -f(T)\}$
\EIT
\item Write a memo $f(S) = x$ and return $x$
\EIT
\end{frame}

\begin{frame}{Possible Extensions}
\BIT
\item The game is not zero-sum
\BIT
\item Each player wants to maximize his own score
\item Each player wants to maximize the difference between his score and the opponent's
\EIT
\item There are more than two players
\vfill
\item All of above can be solved using a similar idea
\EIT
\end{frame}

\section{Nim Game}

\begin{frame}{Nim Game}
\BIT
\item Settings: There are $n$ piles of stones. Two players take turns. Each player chooses a pile, and removes any number of stones from the pile. The one who takes the last stone wins. Find out the winner if both players play perfectly
\vfill
\item Can't really use DP if there are many piles, because the state space is huge
\EIT
\end{frame}

\begin{frame}{Nim Game Example}
\BIT
\item Starts with heaps of 3, 4, 5 stones
\BIT
\item We will call them heap A, heap B, and heap C
\EIT
\vfill
\item Alice takes 2 stones from A: $(1, 4, 5)$
\item Bob takes 4 from C: $(1, 4, 1)$
\item Alice takes 4 from B: $(1, 0, 1)$
\item Bob takes 1 from A: $(0, 0, 1)$
\item Alice takes 1 from C and wins: $(0, 0, 0)$
\EIT
\end{frame}

\begin{frame}{Solution to Nim}
\BIT
\item Given heaps of size $n_1, n_2, \ldots, n_m$
\item The first player wins if and only if the \emph{nim-sum} $n_1 \oplus n_2 \oplus \cdots \oplus n_m$ is nonzero ($\oplus$ is bitwise XOR operator)
\vfill
\item Why?
\BIT
\item If the nim-sum is zero, then whatever the current player does, the nim-sum of the next state is nonzero
\item If the nim-sum is nonzero, it is possible to force it to become zero (not obvious, but true)
\EIT
\EIT
\end{frame}

\section{Grundy Numbers (Nimbers)}

\begin{frame}{Playing Multiple Games at Once}
\BIT
\item Suppose that multiple games are played at the same time. At each turn, the player chooses a game and make a move. You lose if there is no possible move. We want to determine the winner
\EIT
\begin{center}
\includegraphics[height=0.5\textheight]{figures/games}

Figure from \url{http://sps.nus.edu.sg/~limchuwe/cgt/}
\end{center}
\end{frame}

\begin{frame}{Grundy Numbers (Nimbers)}
\BIT
\item For each game, we compute its \emph{Grundy number}
\item The first player wins if and only if the XOR of all the Grundy numbers is nonzero
\BIT
\item For example, the Grundy number of a one-pile version of the nim game is equal to the number of stones in the pile (we will see this again later)
\EIT
\vfill
\item Let's see how to compute the Grundy numbers for general games
\EIT
\end{frame}

\begin{frame}{Grundy Numbers}
\BIT
\item Let $S$ be a state, and $T_1, T_2, \ldots, T_m$ be states can be reached from $S$ using a single move
\vfill
\item The Grundy number $g(S)$ of $S$ is the smallest nonnegative integer that doesn't appear in $\{g(T_1), g(T_2), \ldots, g(T_m)\}$
\BIT
\item Note: the Grundy number of a losing state is 0
\item Note: I made up the notation $g(\cdot)$. Don't use it in other places
\EIT
\EIT
\end{frame}

\begin{frame}{Grundy Numbers Example}
\BIT
\item Consider a one-pile nim game
\item $g(0) = 0$, because it is a losing state
\item State 0 is the only state reachable from state 1, so $g(1)$ is the smallest nonnegative integer not appearing in $\{g(0)\} = \{0\}$. Thus, $g(1) = 1$
\item Similarly, $g(2) = 2$, $g(3) = 3$, and so on
\item Grundy numbers for this game is then $g(n) = n$
\BIT
\item That's how we got the nim-sum solution
\EIT
\EIT
\end{frame}

\begin{frame}{Another Example}
\BIT
\item Let's consider a variant of the game we considered before; only 1 or 2 stones can be removed at each turn
\item Now we're going to play many copies of this game at the same time
\item Grundy number table:

\begin{center}
\begin{tabular}{|c|cccccccc|}
\hline
$n$&0&1&2&3&4&5&6&7 \\ \hline
$g(n)$&0&1&2&0&1&2&0&1 \\
\hline
\end{tabular}
\end{center}
\EIT
\end{frame}

\begin{frame}{Another Example (continued)}
\BIT
\item Grundy number table:

\begin{center}
\begin{tabular}{|c|cccccccc|}
\hline
$n$&0&1&2&3&4&5&6&7 \\ \hline
$g(n)$&0&1&2&0&1&2&0&1 \\
\hline
\end{tabular}
\end{center}
\vfill
\item Who wins if there are three piles of stones $(2, 4, 5)$?
\item What if we start with $(5, 11, 13, 16)$?
\item What if we start with $(10^{100}, 10^{200})$?
\EIT
\end{frame}

\begin{frame}{Tips for Solving Game Problems}
\BIT
\item If the state space is small, use memoization
\item If not, print out the result of the game for small test data and look for a pattern
\BIT
\item This actually works really well!
\EIT
\item Try to convert the game into some nim-variant
\item If multiple games are played at once, use Grundy numbers
\EIT
\end{frame}

\end{document}


\documentclass[11pt]{article}
%\usepackage[firstpage]{draftwatermark}
\usepackage{times}
\usepackage{pdfpages}
\usepackage{fullpage}
\usepackage{url}
\usepackage{hyperref}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{enumitem}
\usepackage{indentfirst}
\usepackage{subcaption}
\usepackage{units}
\usepackage{bm}

\usepackage{./math_bbing}

% Highlighting
\usepackage{color,soul}
\DeclareRobustCommand{\hlr}[1]{{\sethlcolor{red}\hl{#1}}}
\DeclareRobustCommand{\hlg}[1]{{\sethlcolor{green}\hl{#1}}}
\DeclareRobustCommand{\hlb}[1]{{\sethlcolor{blue}\hl{#1}}}
\DeclareRobustCommand{\hly}[1]{{\sethlcolor{yellow}\hl{#1}}}

\setcounter{secnumdepth}{4}
\graphicspath{{images/}}
\pagestyle{fancy}

% Conditional for notes
\newif\ifnotes
\notesfalse

\newcommand{\doctitle}{USV Plugins, Theory of Operation}

\newcommand{\docnumber}{\doctitle}

\addtolength{\headheight}{2em}
\addtolength{\headsep}{1.5em}
\lhead{\docnumber}
\rhead{}

\newcommand{\capt}[1]{\caption{\small \em #1}}

\cfoot{\small Brian Bingham \today \\ \thepage}
\renewcommand{\footrulewidth}{0.4pt}

\newenvironment{xitemize}{\begin{itemize}\addtolength{\itemsep}{-0.75em}}{\end{itemize}}
\newenvironment{tasklist}{\begin{enumerate}[label=\textbf{\thesubsubsection-\arabic*},ref=\thesubsubsection-\arabic*,leftmargin=*]}{\end{enumerate}}
\newcommand\todo[1]{{\bf TODO: #1}}
\setcounter{tocdepth}{2}
\setcounter{secnumdepth}{4}

\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother

%\renewcommand{\chaptername}{Volume}
%\renewcommand{\thesection}{\Roman{section}}
%\renewcommand{\thesubsection}{\Roman{section}-\Alph{subsection}}

\begin{document}
\input{./Commands}
\input{./defs}
\newpage
% Title Page
\setcounter{page}{1}
\begin{center}
{\huge \doctitle}
\end{center}

\section{Overview}
The rigid body dynamics implemented in Gazebo are augmented with environmental forces to simulate an unmanned surface vessel via a set of Gazebo plugins.  These plugins simulate the effects of
\begin{itemize}
\item Dynamics
  \begin{itemize}
  \item Maneuvering - added mass, drag, etc.
  \item Wave field - motion of the water surface
  \end{itemize}
\item Thrust - vehicle propulsion
\item Wind - windage.
  \end{itemize}

This document is a high-level description of the implementation, but not a full documentation of the models and techniques used.  The code itself is the ultimate documentation; comments have been included in the source to allow for users to adapt and extend these simple techniques for their own purposes.

\section{Maneuvering Model and Waves}
The influence of both maneuvering and wave forces on the motion of the USV is implemented as a single model plugin for Gazebo.  Currently there is only one implementation, but other implementations, with varying fidelity, could be developed in the future.

\subsection{usv gazebo dynamics plugin}

\subsubsection{Maneuvering Model}
The plugin implements a portion of the nonlinear maneuvering equations from \cite{fossen11handbook},
\beqn
\underbrace{\bm{M}_{RB}\dot{\bm{\nu}}+\bm{C}_{RB}(\bm{\nu})\bm{\nu}}_\text{rigid-body forces} +
\underbrace{\bm{M}_A\dot{\bm{\nu}}_r + \bm{C}_A(\bm{\nu}_r)\bm{\nu}_r +
\bm{D}(\bm{\nu}_r)\bm{\nu}_r}_\text{hydrodynamic forces}
= \bm{\tau}+\bm{\tau}_{wind}+\bm{\tau}_{waves}
\label{e:fossenmodel}
\eeqn
where the state vector $\bm{\nu}=[u,v,r]^T$ includes the velocities $u$, $v$ and $r$ are in the surge, sway and yaw directions respectively and  $\bm{\nu}_r$ is the velocity vector relative to an irrotational water current $\bm{\nu}_c$, i.e., $\bm{\nu}=\bm{\nu}_r+\bm{\nu}_c$.
The \emph{rigid-body forces} components are simulated via the Gazebo physics engine, while the \emph{hydrodynamic forces} are determined via the plugin.

The six DOF maneuvering model is specified by the following matrices. The added mass matrix expressed as
\beqn
\bm{M}_{A}= \left[
\begin{array}{cccccc}
-X_{\dot{u}} & 0 & 0 &0 &0 &0 \\
0 & -Y_{\dot{v}} & 0 &0 &0 &0 \\
0 & 0  &0.1 &0 &0 &0 \\
0 &0 &0 &0.1 &0 &0 \\
0 &0 &0 &0 &0.1 &0 \\
0 &0 &0 &0 & 0 & -N_{\dot{r}}
\end{array} \right].
\eeqn
The Coriolis-centripetal matrix for the added mass expressed as
\beqn
\bm{C}_{A}(\bm{\nu}_r)= \left[
\begin{array}{cccccc}
0 &0 &0 &0 & 0 & Y_{\dot{v}}v_r+Y_{\dot{r}}r \\
0 &0 &0 &0 & 0 & -X_{\dot{u}}u_r\\
0 &0 &0 &0 &0 &0 \\
0 &0 &0 &0 &0 &0 \\
0 &0 &0 &0 &0 &0 \\
0 &0 &0 & -Y_{\dot{v}}v_r - Y_{\dot{r}}r& X_{\dot{u}}u_r & 0
\end{array} \right].
\eeqn.
It is worth noting that $\bm{C}_A$ includes the nonlinear Munk moment (see \cite{fossen11handbook} p.121).  Following \cite{fossen11handbook} the SNAME notation for the hydrodynamic derivatives.  Currently these terms are neglected in the model for simplicity and because of the challenges in estimating and verifying the pertinent parameters.

The linear and quadratic drag terms
\beqn
\bm{D}(\bm{\nu}_r)= \left[
\begin{array}{cccccc}
X_u + X_{u|u|}|u| & 0 & 0 &0 &0 &0\\
0 & Y_v + Y_{v|v|}|v| &0  &0 &0 &0\\
0 &0 &Z_w  &0 &0 &0 \\
0 &0 &0 &K_p  &0 &0 \\
0 &0 &0 &0 &M_q &0 \\
0 &0 &0 &0 &0 & N_r+N_{r|r|}|r|
\end{array} \right].
\eeqn
which neglects coupleing between sway and yaw.

\subsubsection{Wave Forcing}

Gerstner waves with three components \cite{tessendorf99simulating}.  Each of the component waves is user-specified by an amplitude, period and direction.  Deep water dispersion is used in simulating the wave behaviors.

To determine the influence of the wave field on the vessel, the vessel footprint is decomposed into a simple grid, with points at each corner of the vessel.  The vertical displacement is calculated for each of these points.  Using the vessel's position and attitude, the buoyancy force at each location is determined and then applied at that grid point.

\section{Thrust}
The external force and torque from the vessel propulsion is implemented in a standalone plugin to allow for independent extension to higher-fidelity thrust configurations and models.

\subsection{usv gazebo thrust plugin}
The plugin subscribes the \verb+cmd_drive+ topic to receive messages of type UsvDrive (defined in the \verb+usv_msgs+ package).  These message specify left and right thrust commands where the commands are scaled from $\{-1.0-1.0\}$.

To emulate the thruster behavior, the commands are mapped to a thrust force applied to the model.  Two possible mappings are currently available.  Users select which mapping using the \verb+mappingType+ SDF tag.

The axial force is applied at a point vertically separated from the CG as specified by the \texttt{thrustOffsetZ} parameter.  This results in coupling between the forward thrust and the vehicle pitch.

\subsubsection{0: Linear thruster map}
The command values (-1.0 to 1.0) are scaled linearly to the \texttt{maxForceFwd} and \texttt{maxForceRev} SDF parameters.  A total forward thrust is caculated as the sum.  A total torque is calculated assuming the two thrust forces are applied at opposite ends of the \texttt{boatWidth} parameter.

\subsubsection{1: GLF thruster map}

In this mode two generalized logistic functions (GLFs) are used to convert commands to thrust force.  One set of GLF parameters are used for positive commands (0 to 1.0) and a second set of parameters are used for negative commands (-1 to 0).  The form of the GLF used is
\begin{equation}
  T = A + \frac{K-A}{\left(C+\exp(-B(x-M))\right)^{1/\nu}}
\end{equation}
where $T$ is the thrust force in Newtons, $x$ is the command and the remaining variables are the GLF parameters.  To identify the GLF parameters, the data from
\cite{sarda17station} was used---Figure\ref{f:sarda}.  The Python script for accomplishing this is include in the \verb+usv_gazebo_plugins+ repository in the \verb+thrust_curve_fit+ directory.

\begin{figure}[h]
  \centering
  \includegraphics[width=0.6\textwidth]{images/sarda_tcurve.png}
  \caption{Empirical thrust performance data from \cite{sarda17station}.}
  \label{f:sarda}
\end{figure}

The data was fit with two separate GLF functions using the \verb+scipy.optimize.fmin+ optimization routine to minimize the squared error.  The results are shown in Figure\ref{f:fit}.

\begin{figure}[h]
  \centering
  \includegraphics[width=0.6\textwidth]{images/wamv_glf_annote.png}
  \caption{GLF fit of empirical data.}
  \label{f:fit}
\end{figure}

\section{Wind}

The influence of wind on the motion of the USV is implemented as a standalone model plugin for Gazebo.  Currently there is only one implementation, but other implementations, with varying fidelity, could be developed in the future.

\subsection{usv gazebo wind plugin}

The wind forces (x and y) and moment (yaw) are predicted following the models presented by Fossen~\cite{fossen94guidance}.

The wind velocity on the vessel ($V_w$) is considered to be a constant velocity and direction.  If desired, this could be extended to include a parameterized wind spectrum the distribution of wind velocities over time, e.g., average wind velocity, gusts, etc.  For the current implementation the constant wind velocity is specified as a three element vector which specifies the wind speed the world-frame x, y and z coordinates with units of \unitfrac[]{m}{s}.  The z component is ignored.

The resulting forces and moments on the vessel are determined based on the user-specified force/moment coefficients and the relative wind velocity.  Within the plugin, the relative (or apparent) wind velocity vector $V_R$.  The forces/moment are calculated as
\begin{eqnarray}
  X_{wind} &=& (C_X) V_{R_x} |V_{R_x}| \\
  Y_{wind} &=& (C_Y) V_{R_y} |V_{R_y}| \\
  N_{wind} &=& -2.0 (C_N) V_{R_x} V_{R_y} \\
\end{eqnarray}
where $C_X$, $C_Y$ and $C_N$ are specified as the three element \verb+wind_coeff_vector+.  Approximate values for these coefficients are given in \cite{sarda17station} which can then be tuned to give reasonable response.

%\newpage
%\setcounter{page}{1}
\bibliographystyle{ieeetr}
\bibliography{refs}

\end{document}


\section{\hogwild}

Prior to 2011, parallel stochastic gradient methods had been introduced, but
most suffered from poor scaling due to the necessity of locks. A naive
implementation could look like:
\begin{breakablealgorithm}
  \caption{Very Naive Parallel Stochastic Gradient}
  \label{alg:naivePSG}
  \begin{algorithmic}[1]
    \Require Number of data points $N$, seperable loss function $f
    = \sum_{e \in E} f_e(x_e)$, Initial $x$.
    \For{epoch $= 1 \to$ MAX\_EPOCHS}
      \State \#pragma omp parallel for
      \For{$k = 1 \to N$}
        \State Choose $i$ uniformly from $\{1, \dots, |E|\}$.
        \State \#pragma omp critical
        \Indent
          \State Read current parameters $x$.
          \State Compute $\nabla f_i(x)$.
          \State $x \gets x - \eta \nabla f_i(x)$.
        \EndIndent
      \EndFor
    \EndFor
  \end{algorithmic}
\end{breakablealgorithm}
Note that the version presented above is one with a fixed number of iterations,
as the discussion of stopping criteria seems to be similar to that of the
stochastic gradient method, and for extremely large data sets, is often
heuristic. But it's clear here that such an algorithm would only effectively be
parallelizing the unform sample of $i$ in $\{1, \dots, |E|\}$, and it's overall
parallel efficiency would likely be poor. Technically, you can improve the above
by replacing the critical section with selective locks on components of $x$
based on the sparsity pattern of $\nabla f_i(x)$, but because the process of
acquiring locks is much more expensive than floating point arithmetic, this
helps little.

However, in 2011, the article "\hogwild: A Lock-Free Approach to Parallelizing
Stochastic Gradient Descent" by Niu et al. \cite{2011NRRW} proposed a very
simple solution to this problem. Remove the locks!%
\footnote{
  Apparently this was discovered by accident by Feng Niu, one of the original
  paper's authors, when he was debugging stochastic gradient method code. I wish
  my troubleshooting was nearly as effective... \cite{2014Recht}
} \clearpage
\begin{breakablealgorithm}
  \caption{\hogwild: Asynchronous Stochastic Gradient with replacement}
  \label{alg:hogwildwreplacement}
  \begin{algorithmic}[1]
    \Require Number of data points $N$, seperable loss function $f
    = \sum_{e \in E} f_e(x_e)$, Initial $x$.
    \For{epoch $= 1 \to$ MAX\_EPOCHS}
      \State \#pragma omp parallel for
      \For{$k = 1 \to N$}
        \State Choose $i$ uniformly from $\{1, \dots, |E|\}$.
        \State Read current parameters $x$.
        \State Compute $\nabla f_i(x)$.
        \State $x \gets x - \eta \nabla f_i(x)$. \Comment{Must be done
        atomically}
      \EndFor
    \EndFor
  \end{algorithmic}
\end{breakablealgorithm}
and should we want to sample without replacement the algorithm is easily
modified to:
\begin{breakablealgorithm}
  \caption{\hogwild: Asynchronous Stochastic Gradient without replacement}
  \label{alg:hogwildworeplacement}
  \begin{algorithmic}[1]
    \Require Number of data points $N$, seperable loss function $f
    = \sum_{e \in E} f_e(x_e)$, Initial $x$.
    \For{epoch $= 1 \to$ MAX\_EPOCHS}
      \State Let $P$ be a random permutation of $\{1, \dots, |E|\}$.
      \Comment{i.e. a Fisher-Yates Shuffle.}
      \State \#pragma omp parallel for
      \For{$k = 1 \to N$}
        \State $i \gets P[k]$.
        \State Read current parameters $x$.
        \State Compute $\nabla f_i(x)$.
        \State $x \gets x - \eta \nabla f_i(x)$. \Comment{Must be done
        atomically}
      \EndFor
    \EndFor
  \end{algorithmic}
\end{breakablealgorithm}

It should be noted that although the formal OMP locks have been removed, atomic
operations are still required in order to prevent mutual exclusion. However, no
guards have been placed to prevent a thread from overwriting another's
computation midway through, and it's not obvious as to why such a race condition
wouldn't destroy the performance of the Stochastic Gradient method. However,
with certain assumptions one can show that \hogwild\ behaves roughly like a noisy
stochastic gradient method, and thus shares its convergence properties.