\section{Autoregressive Moving Average models}


\documentclass{article}
\usepackage[margin = 1in]{geometry}
\usepackage{amsmath, amssymb, graphicx}
% change equation numbering to section.eq_num + set paragraph indent to 0
\numberwithin{equation}{section}
\setlength\parindent{0pt}
% makes clickable links to sections
\usepackage{hyperref}
% make the link colors blue, as well as cite colors
\hypersetup{
    colorlinks, linkcolor = blue, citecolor = blue, urlcolor = magenta
}
% set up figure caption format (can get rid of this later)
\usepackage{caption}
\captionsetup{font = small}

\title{Revisiting Black's model\thanks{
    Draft version. Plots have not yet been created.
}}
\author{Derek Huang}
\date{January 13, 2021\thanks{
    Previous version dated August 7, 2019. Notation has been cleaned up and the
    post-derivation analysis has been reworked.
}}

\begin{document}

\maketitle

\begin{abstract}
    Solving the Black-Scholes PDE by means of transformation to the heat
    equation\footnotemark\footnotetext{
        Derivation of the Black-Scholes formula using this method can be found
        in Wilmott, Howison, and Dewynne's \textit{The Mathematics of Financial
        Derivatives: A Student Introduction}. This book was the author's first
        exposure to quantitative finance.
    }
    proffers little financial intuition on the form of the pricing formula. An
    alternate approach using the risk-neutral pricing method allows for a
    simpler, more direct derivation of the formula, and allows one to re-express
    the formula in terms of risk-neutral conditional probabilities that shed a
    probabilistic light on the replication argument. We then examine the
    dynamics of the at-the-money European call under Black's model with regards
    to strike and maturity using both simple mathematics and computer-generated
    graphs.
\end{abstract}

\section{Derivation}

\subsection{Risk-neutral pricing}

The futures price process $ \{F_t\}_{t \in \mathbb{R}_+} $ under the
risk-neutral measure $ \mathbb{Q} $ in Black's model satisfies
\begin{equation} \label{black_dgbm}
    dF_t = \sigma F_t\,dW_t
\end{equation}

Here $ W_t $ is a Wiener process under $ \mathbb{Q} $, and we know that
$ W_t \sim \mathcal{N}(0, t) $. By the risk-neutral pricing formula, we can
write the time $ t $ value $ C_{t, T}^F $ of a European call option on $ F $ as
the conditional expectation
\begin{equation*}
    C_{t, T}^F = \mathbb{E}[D_{t, T}\max\{F_T - K, 0\} \mid \mathcal{F}_t]
\end{equation*}

Here $ F_t $ is the current futures price, $ T $ is the time of option
expiration, and $ K $ is the fixed option strike. $ D_{t, T} $ is a discount
factor, which Black specifies as the deterministic $ e^{-r(T - t)} $, with
$ r $ being a known, constant riskless discount rate. $ \mathcal{F}_t $ is the
time-$ t $ sub $ \sigma $-algebra from the natural filtration generated by the
process $ \{F_t\}_{t \in \mathbb{R}_+} $. Since Black's $ D_{t, T} $ is
deterministic, we can write the risk-neutral conditional expectation as
\begin{equation*}
    C_{t, T}^F = D_{t, T}\int_\mathbb{R}\max\{f - K, 0\}
    \varphi_{F_T, \tau \mid \mathcal{F}_t}(f)\,df =
    D_{t, T}\int_K^\infty(f - K)\varphi_{F_T, \tau \mid \mathcal{F}_t}(f)\,df
\end{equation*}

Here $ \varphi_{F_T, \tau \mid \mathcal{F}_t} $ is the risk-neutral probability
density for $ F_T $ conditional on $ \mathcal{F}_t $, where $ \tau \ge T \ge t $
is a delivery date. For brevity, we drop the explicit dependence on
$ \mathcal{F}_t $, $ T $ and use the simpler notation
$ \widetilde{\varphi}_\tau $ instead. Dividing by $ D_{t, T} $ and expanding the
remaining integral, we have
\begin{equation} \label{black_udE}
    \begin{split}
        \frac{C_{t, T}^F}{D_{t, T}} & = \int_K^\infty(f - K)
        \widetilde{\varphi}_\tau(f)\,df =
        \int_K^\infty f\widetilde{\varphi}_\tau(f)\,df -
        K\int_K^\infty\widetilde{\varphi}_\tau(f)\,df \\ & =
        \int_K^\infty f\widetilde{\varphi}_\tau(f)\,df -
        K\mathbb{Q}\{F_T \ge K \mid \mathcal{F}_t\}
    \end{split}
\end{equation}

We see that the expectation can be written as the difference between a partial
expectation of $ F_T $ conditional on $ \mathcal{F}_T $ and $ K $ times a
risk-neutral probability of a $ \mathcal{F}_t $-measurable event. To simplify
our computation of the partial expectation, we recall that the solution to
(\ref{black_dgbm}) is given by the equation
\begin{equation*}
    F_t = F_0e^{-\frac{1}{2}\sigma^2t + \sigma W_t}
\end{equation*}

Now we want to find an analytical expression for $ F_T $ conditioned on
$ \mathcal{F}_t $. By the properties of the Wiener process, we write
$ W_T \mid \mathcal{F}_t $ as $ \sqrt{T - t}Z $, where
$ Z \sim \mathcal{N}(0, 1) $ under $ \mathbb{Q} $. We then have
\begin{equation} \label{black_FT_tad}
    F_T \mid \mathcal{F}_t = F_te^{-\frac{1}{2}\sigma^2(T - t) +
    \sigma\sqrt{T - t}Z}
\end{equation}

For notational simplicity, set $ \theta \triangleq T - t $. To simplify the
partial expectation, we make note that $ F_T \mid \mathcal{F}_t $ is a function
of a standard normal random variable $ Z $. Therefore, using
(\ref{black_FT_tad}), we can rewrite the partial expectation in terms of the
standard normal density function $ \phi $ instead to get
\begin{equation} \label{black_pe_1}
    \int_K^\infty f\widetilde{\varphi}_\tau(f)\,df =
    F_t\int_\zeta^\infty e^{-\frac{1}{2}\sigma^2\theta +
    \sigma\sqrt{\theta}z}\phi(z)\,dz =
    F_t\int_\zeta^\infty\frac{1}{\sqrt{2\pi}}e^{-\frac{1}{2}\sigma^2\theta +
    \sigma\sqrt{\theta}z - \frac{1}{2}z^2}\,dz
\end{equation}

The last step follows from the definition of the standard normal density
$ \phi $, where of course
\begin{equation*}
    \phi(z) \triangleq \frac{1}{\sqrt{2\pi}}e^{-\frac{1}{2}z^2}
\end{equation*}

Since the partial expectation is taken over $ Z $ instead of
$ F_T \mid \mathcal{F}_t $, a function of $ Z $, the threshold $ K $ changes to
a different quantity $ \zeta $. We find $ \zeta $ by solving the equation
\begin{equation*}
    K = F_te^{-\frac{1}{2}\sigma^2\theta + \sigma\sqrt{\theta}\zeta}
\end{equation*}

This relates $ \zeta $ to $ K $ through the relation between
$ F_T \mid \mathcal{F}_t $ and $ Z $ given by (\ref{black_FT_tad}), so we see
that
\begin{equation} \label{black_zeta}
    \zeta = \frac{
        \log(K / F_t) + \frac{1}{2}\sigma^2\theta
    }{\sigma\sqrt{\theta}}
\end{equation}

Here $ \log $ is the natural logarithm. Since the exponentiated quadratic in
(\ref{black_pe_1}) is a perfect square, then
\begin{equation*}
    \int_K^\infty f\widetilde{\varphi}_\tau(f)\,df =
    F_t\int_\zeta^\infty\frac{1}{\sqrt{2\pi}}
    e^{-\frac{1}{2}(z - \sigma\sqrt{\theta})^2}dz =
    F_t\mathbb{Q}\{X \ge \zeta\}
\end{equation*}

Here $ X \sim \mathcal{N}(\sigma\sqrt{\theta}, 1) $, as we see that the function
being integrated above is a normal density. Since we can write
$ X = Z + \sigma\sqrt{\theta} $, if we rewrite $ \mathbb{Q}\{X \ge \zeta\} $
in terms of $ Z $ and substitute for $ \zeta $ the result in (\ref{black_zeta}),
we have
\begin{equation} \label{black_p1}
    \begin{split}
        \mathbb{Q}\{X \ge \zeta\} & =
        \mathbb{Q}\left\{Z + \sigma\sqrt{\theta} \ge \frac{\log(K / F_t) +
        \frac{1}{2}\sigma^2\theta}{\sigma\sqrt{\theta}}\right\} =
        \mathbb{Q}\left\{Z \ge \frac{
            \log(K / F_t) - \frac{1}{2}\sigma^2\theta
        }{\sigma\sqrt{\theta}}\right\} \\ & =
        \mathbb{Q}\left\{Z \le \frac{
            \log(F_t / K) + \frac{1}{2}\sigma^2\theta
        }{\sigma\sqrt{\theta}}\right\} =
        \Phi\left(\frac{
            \log(F_t / K) + \frac{1}{2}\sigma^2\theta
        }{\sigma\sqrt{\theta}}\right)
    \end{split}
\end{equation}

Here $ \Phi $ is the standard normal cdf and the second to last equality follows
from the symmetry of $ Z $ around $ 0 $. Using our result from (\ref{black_p1})
and replacing $ \theta $ with $ T - t $, we have
\begin{equation} \label{black_partial_E}
    \int_K^\infty f\widetilde{\varphi}_\tau(f)\,df =
    F_t\Phi\left(\frac{
        \log(F_t / K) + \frac{1}{2}\sigma^2(T - t)
    }{\sigma\sqrt{T - t}}\right)
\end{equation}

This is the first normal cdf term in Black's formula. Moving on to the
risk-neutral conditional probability
$ \mathbb{Q}\{F_T \ge K \mid \mathcal{F}_t\} $ we defined in (\ref{black_udE}),
we again use our expression for $ F_T \mid \mathcal{F}_t $ in
(\ref{black_FT_tad}). Substituting $ \theta $ for $ T - t $ as before, we can
rewrite $ \mathbb{Q}\{F_T \ge K \mid \mathcal{F}_t\} $ in terms of $ Z $ and
find that
\begin{equation} \label{black_p2}
    \begin{split}
        \mathbb{Q}\{F_T \ge K \mid \mathcal{F}_t\} & =
        \mathbb{Q}\left\{F_te^{
            -\frac{1}{2}\sigma^2\theta + \sigma\sqrt{\theta}Z
        } \ge K\right\} =
        \mathbb{Q}\left\{Z \ge \frac{
            \log(K / F_t) + \frac{1}{2}\sigma^2\theta
        }{\sigma\sqrt{\theta}}\right\} \\ & =
        \mathbb{Q}\left\{Z \le \frac{
            \log(F_t / K) - \frac{1}{2}\sigma^2\theta
        }{\sigma\sqrt{\theta}}\right\} =
        \Phi\left(\frac{
            \log(F_t / K) - \frac{1}{2}\sigma^2(T - t)
        }{\sigma\sqrt{T - t}}\right)
    \end{split}
\end{equation}

Our derivation has now been completed. Substituting our results from
(\ref{black_partial_E}) and (\ref{black_p2}) back into (\ref{black_udE}) and
multiplying by $ D_{t, T} = e^{-r(T - t)}$, we get exactly Black's formula
\begin{equation} \label{black_call}
    C_{t, T}^F = D_{t, T}\left[F_t\Phi\left(\frac{\log(F_t / K) +
    \frac{1}{2}\sigma^2(T - t)}{\sigma\sqrt{T - t}}\right) -
    K\Phi\left(\frac{
        \log(F_t / K) - \frac{1}{2}\sigma^2(T - t)
    }{\sigma\sqrt{T - t}}\right)\right]
\end{equation}

\subsection{$ \mathcal{F}_t $-conditional replication}

By deriving Black's formula from the risk-neutral pricing formula, we can
re-express the normal cdf terms as risk-neutral conditional probabilities in
terms of $ F_T $, which is the inverse of what was done when deriving the
formula. Since (\ref{black_p2}) already shows how the second normal cdf term is
written as a $ \mathcal{F}_t$-conditional $ \mathbb{Q} $ probability involving
$ F_T $, we work on the first normal cdf term. From (\ref{black_FT_tad}), we
have
\begin{equation} \label{Z_FT}
    Z = \left.\frac{
        \log(F_T / F_t) + \frac{1}{2}\sigma^2(T - t)
    }{\sigma\sqrt{T - t}} \ \middle\vert \ \mathcal{F}_t\right.
\end{equation}

Writing $ \theta = T - t $ as before, we can re-express the first normal cdf
term in (\ref{black_call}) using (\ref{Z_FT}) as
\begin{equation} \label{black_q1}
    \begin{split}
        \Phi\left(\frac{
            \log(F_t / K) + \frac{1}{2}\sigma^2(T - t)
        }{\sigma\sqrt{T - t}}\right) & =
        \mathbb{Q}\left\{Z \le \frac{
            \log(F_t / K) + \frac{1}{2}\sigma^2\theta
        }{\sigma\sqrt{\theta}}\right\} =
        \mathbb{Q}\left\{Z \ge \frac{
            \log(K / F_t) - \frac{1}{2}\sigma^2\theta
        }{\sigma\sqrt{\theta}}\right\} \\ & =
        \mathbb{Q}\left\{\frac{
            \log(F_T / F_t) + \frac{1}{2}\sigma^2\theta
        }{\sigma\sqrt{\theta}} \ge \frac{
            \log(K / F_t) - \frac{1}{2}\sigma^2\theta
        }{\sigma\sqrt{\theta}} \ \middle\vert \ \mathcal{F}_t\right\} \\ & =
        \mathbb{Q}\left\{F_T \ge Ke^{-\sigma^2(T - t)} \ \middle\vert \
        \mathcal{F}_t\right\}
    \end{split}
\end{equation}

Substituting our results from (\ref{black_p2}) and (\ref{black_q1}) into Black's
formula given in (\ref{black_call}), we have
\begin{equation} \label{black_qcall}
    C_{t, T}^F = D_{t, T}\left[F_t\mathbb{Q}\left\{F_T \ge Ke^{-\sigma^2(T - t)}
    \ \middle\vert \ \mathcal{F}_t\right\} -
    K\mathbb{Q}\{F_T \ge K \mid \mathcal{F}_t\}\right]
\end{equation}

A European call option can be replicated using the underlying and a risk-free
asset, in this case $ D_{t, T} $, which is essentially a
risk-free zero-coupon bond. Expressing Black's formula with (\ref{black_qcall})
helps show how the quantity of the underlying to long and quantity of the
risk-free asset to short are dependent on $ \mathcal{F}_t $-conditional
$ \mathbb{Q} $ probabilities of $ F_T $ exceeding a quantity involving the
strike $ K $. The first $ \mathbb{Q} $ probability can be seen from inspection
to be greater than or equal to the second, strictly so when
$ \sigma^2(T - t) > 0 $. Both $ \mathbb{Q} $ probabilities can also be
interpreted as $ \mathcal{F}_t $-conditional risk-neutral exercise
probabilities.

\section{Properties}

\subsection{Limiting behavior}

From (\ref{black_call}) we can easily verify well-known limiting behavior of
the European call. For example\footnotemark\footnotetext{
    We used the \textit{undiscounted} value $ C_{t, T}^F / D_{t, T} $ when
    taking the $ T \rightarrow \infty $ limit, as
    $ \lim_{T \rightarrow \infty}D_{t, T} = 0 $. In comparison, under the
    Black-Scholes model, for an underlying $ S $ that pays no dividends, the
    value $ C_{t, T}^S $ of the European call as $ T \rightarrow \infty $
    converges to $ S_t $, the current price of the underlying. Other limits
    that involved the undiscounted value $ C_{t, T}^F / D_{t, T} $ serve to
    remove the discount factor from the right-hand side of the limit equality.
},
\begin{equation} \label{black_limits}
    \begin{split}
        \lim_{t \rightarrow T_-}C_{t, T}^F & =
        \mathbb{I}\{F_t \ge K\}(F_t - K) \\
        \lim_{T \rightarrow \infty}\frac{C_{t, T}^F}{D_{t, T}} & = F_t \\
        \lim_{\sigma \rightarrow \infty}\frac{C_{t, T}^F}{D_{t, T}} & = F_t \\
        \lim_{F_t / K \rightarrow \infty}\frac{C_{t, T}^F}{D_{t, T}} & =
        F_t - K \\
        \lim_{F_t / K \rightarrow 0_+}C_{t, T}^F & = 0
    \end{split}
\end{equation}

Here $ \mathbb{I} $ is the indicator function. None of the limits shown in
(\ref{black_limits}) should be too surprising as they express well-known facts
about how European options should behave in general, although the fact that the
undiscounted European call value $ C_{t, T}^F / D_{t, T} $ converges to $ F_t $
as $ \sigma \rightarrow \infty $ is interesting but not very useful.

\subsection{At-the-money dynamics}

We can also see that under the Black model, the at-the-money European call,
whose value we will denote by $ \hat{C}_{t, T}^F $, has relatively simple
dynamics in terms of strike and maturity. From (\ref{black_call}), we can write
\begin{equation} \label{black_atm_call}
    \hat{C}_{t, T}^F = D_{t, T}K\xi(\sigma, T - t)
\end{equation}

As expected, the function $ \xi : [0, \infty)^2 \rightarrow [0, 1] $ is defined
such that
\begin{equation} \label{black_xi}
    \xi(\sigma, \theta) = \Phi\left(\frac{1}{2}\sigma\sqrt{\theta}\right) -
    \Phi\left(-\frac{1}{2}\sigma\sqrt{\theta}\right)
\end{equation}

From inspection, we see that under the Black model, the price of the
at-the-money European call is linear in the strike $ K $. Also, we see that
$ \forall K' \in [0, \infty) $,
$ \partial \hat{C}_{t, T}^F / \partial K \vert_{K = K'} \in [0, D_{t, T}] $, as
$ \forall (u, v) \in [0, \infty)^2, \xi(u, v) \in [0, 1] $. The dynamics of the
at-the-money European call with respect to maturity $ T $ are not immediately
obvious from inspection, however, so we compute
$ \partial \hat{C}_{t, T}^F / \partial T $, where from (\ref{black_atm_call}),
(\ref{black_xi}) we see that
\begin{equation*}
    \begin{split}
        \frac{\partial \hat{C}_{t, T}^F}{\partial T} & =
        -rD_{t, T}K\xi(\sigma, T - t) + D_{t, T}K\left[
            \phi\left(
                \frac{1}{2}\sigma\sqrt{T - t}
            \right)\frac{\sigma}{4\sqrt{T - t}} +
            \phi\left(
                -\frac{1}{2}\sigma\sqrt{T - t}
            \right)\frac{\sigma}{4\sqrt{T - t}}
        \right] \\ & =
        D_{t, T}K\left[
            -r\xi(\sigma, T - t) + \frac{1}{2}\sigma(T - t)^{-1 / 2}\phi\left(
                \frac{1}{2}\sigma\sqrt{T - t}
            \right)
        \right]
    \end{split}
\end{equation*}

Here we used the fact that $ D_{t, T} \triangleq e^{-r(T - t)} $, so
$ \partial D_{t, T} / \partial T = -re^{-r(T - t)} = -rD_{t, T} $, and the fact
that the standard normal density $ \phi $ is symmetric around the origin, i.e.
$ \forall z \in \mathbb{R} $, $ \phi(z) = \phi(-z) $. We see that
\begin{equation} \label{black_atm_call_partial_T_limits}
    \begin{array}{cc}
        \displaystyle \lim_{T \rightarrow \infty}
        \frac{\partial\hat{C}_{t, T}^F}{\partial T} = 0 \quad & \quad
        \displaystyle \lim_{T - t \rightarrow 0_+}
        \frac{\partial\hat{C}_{t, T}^F}{\partial T} = \infty
    \end{array}
\end{equation}

To compute the above limits, we used the fact that the limit of the product of
continuous functions exists when the individual limits of the continous
functions exist and is equal to the product of the individual limits. The
individual limits used in the calculations are shown below.
\begin{equation*}
    \begin{split}
        \lim_{T \rightarrow \infty}D_{t, T} & = 0 \\
        \lim_{T \rightarrow \infty}\xi(\sigma, T - t) & =
        \mathbb{I}\{\sigma > 0\} \\
        \lim_{T \rightarrow \infty}(T - t)^{-1 / 2} & = 0 \\
        \lim_{T \rightarrow \infty}\phi\left(
            \frac{1}{2}\sigma\sqrt{T - t}
        \right) & = \frac{1}{\sqrt{2\pi}}\mathbb{I}\{\sigma = 0\}
    \end{split}
    \quad \quad
    \begin{split}
        \lim_{T - t \rightarrow 0_+}D_{t, T} & = 1 \\
        \lim_{T - t \rightarrow 0_+}\xi(\sigma, T - t) & = 0 \\
        \lim_{T - t \rightarrow 0_+}(T - t)^{-1 / 2} & = \infty \\
        \lim_{T - t \rightarrow 0_+}\phi\left(
            \frac{1}{2}\sigma\sqrt{T - t}
        \right) & = \frac{1}{\sqrt{2\pi}}
    \end{split}
\end{equation*}

The limits for $ \partial \hat{C}_{t, T}^F / \partial T $ shown in
(\ref{black_atm_call_partial_T_limits}) do make intuitive sense. One would
expect that an at-the-money European call is worthless at maturity, i.e. when
$ T - t = 0 $, as $ \hat{C}_{t, T}^F $ should converge to its payoff. On the
other hand, as the maturity of a European call increases, the marginal value of
increasing the time to maturity should decrease. If the option never matures,
then there is no additional time value to add.

\medskip

We can visualize the strike and maturity dynamics of the at-the-money European
call in Black's model with line plots\footnotemark\footnotetext{
    Not yet included. Will be done in Python using \href{
        https://matplotlib.org/
    }{\texttt{matplotlib}}.
}. To show how the curves may vary based on the magnitude of the diffusion
parameter $ \sigma $, on each graph we draw four different curves, each
corresponding to a value of $ \sigma $ in $ \{0.25, 0.5, 0.75, 1\} $.

% The intuition here is that under the Black model, the value of a European call
% option is the discounted difference between the current value of the underlying,
% here the futures price $ F_t $, and the strike $ K $, each weighted by a
% risk-neutral probability. Interestingly, we may also write (\ref{black_call}) as
% as\footnotemark\footnotetext{
%     We use the obvious fact that
%     \begin{equation*}
%         \mathbb{Q}\left\{F_T \ge Ke^{-\sigma^2(T - t)} \ \middle\vert \
%         \mathcal{F}_t\right\} =
%         \mathbb{Q}\{F_T \ge K \mid \mathcal{F}_t\} +
%         \mathbb{Q}\left\{F_T \in \big[Ke^{-\sigma^2(T - t)}, K\big] \
%         \middle\vert \ \mathcal{F}_t\right\}
%     \end{equation*}
% }
% \begin{equation} \label{black_qcall_p}
%     C_{t, T}^F = D_{t, T}\left[
%         (F_t - K)\mathbb{Q}\{F_T \ge K \mid \mathcal{F}_t\} +
%         F_t\mathbb{Q}\left\{
%             F_T \in \big[Ke^{-\sigma^2(T - t)}, K\big] \ \middle\vert \
%             \mathcal{F}_t
%         \right\}
%     \right]
% \end{equation}
% (\ref{black_qcall_p}) shows that under the Black model, the value of a European
% call is equal to the the sum of two quantities. The first is the risk-neutral
% present value of a long forward contract\footnotemark\footnotetext{
%     The present value of a long forward contract on $ F $ with
%     forward (delivery) price $ K $ and delivery date $ T $ under $ \mathbb{Q} $
%     simply is, by the risk-neutral pricing formula,
%     $ \mathbb{E}[D_{t, T}(F_T - K)] = D_{t, T}(F_t - K) $. This is because
%     $ \{F_t\}_{t \in \mathbb{R}_+} $ is a martingale.
% } on the underlying futures with delivery
% date $ T $ and forward price $ K $ times the option's conditional exercise
% probability $ \mathbb{Q}\{F_T \ge K \mid \mathcal{F}_t\}$. The second is the
% discounted expectation of the terminal price $ F_T $ times the
% $ \mathcal{F}_t $-conditional probability that $ F_T $ falls within the interval
% $ \big[Ke^{-\sigma^2(T - t)}, K\big] $. For an underlying with higher
% volatility, this interval is wider, although it is clear that as the option
% approaches maturity, the interval converges to $ K $. We can rewrite this

% The first exercise probability
% $ \mathbb{Q}\big\{F_T \ge Ke^{-\sigma^2(T - t)}\big\} $ has the strike weighted
% by the quantity $ e^{-\sigma^2(T - t)} $ such that \textit{ceteris paribus}, if
% $ \sigma $ increases, $ C_{t, T}^F $ increases. This corroborates the intuition
% that \textit{ceteris paribus}, if an asset has high volatility, an option on
% that asset will be worth more.

% \textit{ceteris paribus}, as volatility increases, the value of an option
% increases. We can quantify this by separating out the volatility
% premium\footnotemark\footnotetext{
%     Here volatility is used to refer to the \textit{total volatility}, i.e. the
%     instantaneous diffusion coefficient $ \sigma $ multiplied by
%     $ \sqrt{T - t} $, the square root of the time to maturity. The option time
%     premium is implicitly included in this quantity.
% }, as
% \begin{equation*}
%     \begin{split}
%         \mathbb{Q}\left\{F_T \ge Ke^{-\sigma^2(T - t)} \ \middle\vert \
%         \mathcal{F}_t\right\} & =
%         \Phi\left(\frac{
%             \log(F_t / K) + \frac{1}{2}\sigma^2\theta
%         }{\sigma\sqrt{\theta}}\right) =
%         \mathbb{Q}\left\{Z \le - \zeta + \sigma\sqrt{\theta}\right\} =
%         \int_{-\infty}^{-\zeta + \sigma\sqrt{\theta}}\phi(z)\,dz \\
%         \mathbb{Q}\{F_T \ge K \mid \mathcal{F}_t\} & =
%         \Phi\left(\frac{
%             \log(F_t / K) - \frac{1}{2}\sigma^2\theta
%         }{\sigma\sqrt{\theta}}\right) = \mathbb{Q}\{Z \le -\zeta\} =
%         \int_{-\infty}^{-\zeta}\phi(z)\,dz
%     \end{split}
% \end{equation*}

% Here we have $ \zeta $ as defined in (\ref{black_zeta}), $ \theta = T - t $ as
% before, and $ \phi $ the normal pdf. We can thus see that
% \begin{equation*}
%     \mathbb{Q}\left\{F_T \ge Ke^{-\sigma^2(T - t)} \ \middle\vert \
%     \mathcal{F}_t\right\} =
%     \mathbb{Q}\{F_T \ge K \mid \mathcal{F}_t\} +
%     \int_{-\zeta}^{-\zeta + \sigma\sqrt{\theta}}\phi(z)\,dz
% \end{equation*}

% Therefore, we can write

% We can therefore define a function of the current futures price $ F_t $ and
% current time $ t $ parametrized by $ \sigma $,
% $ \lambda_\sigma : [0, \infty)^2 \rightarrow [0, \infty) $, where
% \begin{equation} \label{black_vol_prem}
%     \lambda_\sigma(F_t, \theta) =
%     \int_{-\zeta}^{-\zeta + \sigma\sqrt{\theta}}\phi(z)\,dz, \quad
%     \text{where} -\zeta =
%     \frac{\log(F_t / K) - \frac{1}{2}\sigma^2\theta}{\sigma\sqrt{\theta}}
% \end{equation}

% Here we emphasize the time-related parameters only, as all other parameters are
% constants. We know that $ \lambda_\sigma \ge 0 $ as by definition of a density function, $ \phi(z) \ge 0 $, and because $ \sigma > 0 $ and  $ \theta \ge 0 $. Using our new results in (\ref{black_vol_prem}), we can now rewrite (\ref{black_qcall}) with only $ \mathbb{Q}\{F_T \ge K \mid \mathcal{F}_t) $ while incorporating $ \lambda_\sigma $ to arrive at
% \begin{equation} \label{black_vpcall}
%     C_{t, T}^F = D_{t, T}\left[\mathbb{Q}\{F_T \ge K \mid \mathcal{F}_t)(F - K) + F\int_{-\zeta}^{-\zeta + \sigma\sqrt{T - t}}\phi(z)dz\right]
% \end{equation}
% We have now expressed $ C_{t, T}^F $ as a sum of the difference $ F - K $ between the underlying and the strike weighted by the risk-neutral exercise probability $ \mathbb{Q}\{F_T \ge K) $ and the volatility premium weighted by $ F $.

% \section{Analyzing the vol premium}

% From our result in (\ref{black_vpcall}), it is implied that the value of European call options struck at the money is the discounted volatility premium weighted by $ F = K $. We make this explicit below by writing
% \begin{equation*}
%     C(K, t) = D_{t, T}K\int_{-\zeta'}^{-\zeta' + \sigma\sqrt{T - t}}\phi(z)dz = D_{t, T}K\int_{-\zeta'}^{\zeta'}\phi(z)dz, \text{where} -\zeta' = -\frac{1}{2}\sigma\sqrt{T - t}
% \end{equation*}
% However, since the greatest difference between the price of a European call option under the Black model and its intrinsic value is greatest at the money, one might be interested in how $ \lambda_\sigma $ changes as we vary the time $ t $ futures price $ F $. Because we already showed that the value of at the money Black call is completely determined by $ F $ and $ \lambda_\sigma $, our intuition tells us that a plot of $ \lambda_\sigma $ against $ F $ is most likely concave, with one maximum at $ F = K $. Taking the partial derivative $ \partial \lambda_\sigma / \partial F $, we thus have
% \begin{equation*}
%     \frac{\partial\lambda_\sigma}{\partial F} = \frac{\partial}{\partial F}\int_{-\zeta}^{-\zeta + \sigma\sqrt{\theta}}\phi(z)dz = \frac{\partial}{\partial F}\left[\Phi\left(-\zeta + \sigma\sqrt{\theta}\right) - \Phi(-\zeta)\right] = \phi\left(-\zeta + \sigma\sqrt{\theta}\right)\frac{1}{F\sigma\sqrt{\theta}} - \phi(-\zeta)\frac{1}{F\sigma\sqrt{\theta}}
% \end{equation*}
% Factoring the expression above and rearranging terms, we simply have
% \begin{equation} \label{black_vp_delta}
%     \frac{\partial\lambda_\sigma}{\partial F} = \frac{1}{F\sigma\sqrt{\theta}}\left[\phi\left(-\zeta + \sigma\sqrt{\theta}\right) - \phi(-\zeta)\right]
% \end{equation}
% We consider the cases $ F < K $, $ F = K $, and $ F > K $ to roughly understand how $ \lambda_\sigma $ changes as $ F $ changes.

% \medskip

% $ F < K $: In this case, assuming $ \sigma\sqrt{\theta} > 0 $, $ \phi\left(-\zeta + \sigma\sqrt{\theta}\right) > \phi(-\zeta) $. We can thus conclude that
% \begin{equation*}
%     \left.\frac{\partial\lambda_\sigma}{\partial F} \middle|_{F < K}\right. > 0
% \end{equation*}
% $ F = K $: In this case, we see that $ -\zeta = -\zeta' = -\frac{1}{2}\sigma\sqrt{\theta}$, so $ -\zeta' + \sigma\sqrt{\theta} = \zeta' $. Due to the symmetry of $ \phi(z) $ around 0, we have that $ \phi(\zeta') - \phi(-\zeta') = 0 $, so we conclude that
% \begin{equation*}
%     \left.\frac{\partial\lambda_\sigma}{\partial F} \middle\vert_{F = K}\right. = 0
% \end{equation*}
% $ F > K $: In this case, assuming $ \sigma\sqrt{\theta} > 0 $, $ \phi\left(-\zeta + \sigma\sqrt{\theta}\right) < \phi(-\zeta) $. We can thus conclude that
% \begin{equation*}
%     \left.\frac{\partial\lambda_\sigma}{\partial F} \middle\vert_{F > K}\right. < 0
% \end{equation*}
% This confirms our intuition that $ \lambda_\sigma $ is greatest when $ F = K $. Plots of $ \lambda_\sigma $ over $ F $ and $ \partial \lambda_\sigma / \partial F $ over $ F $ in Figures \ref{vol_prem} and \ref{vol_prem_delta} show more complex dynamics, but still confirm our results. Interestingly, because of the lognormal dynamics assumed in the Black model, the plots of $ \lambda_\sigma $ and $ \partial\lambda_\sigma / \partial F $ over $ F $ are positively skewed.

% \section{Conclusion}

% In this article, we derived the Black formula by means of conditional expectation, which allowed us to re-express the formula in terms of risk-neutral exercise probabilities and isolate the volatility premium embedded in an option's price. We were able to avoid constructing the risk-free portfolio and solving the resulting PDE as outlined in the original Black-Scholes (1973) and Black (1976) papers. The probabilistic approach may be preferred for its financial intuition over the PDE approach, which requires a change of variable into dimensionless groups, thus temporarily causing the equation to lose all financial meaning.

% \pagebreak

% \section{Figures}

% All figures were plotted in R.

% \begin{figure}[h!]
%     \centering
%     \includegraphics[scale = 0.6]{images/black_vol_prem_crop.png}
%     \caption{Plot of $ \lambda_\sigma $ over $ F $ with arbitrary parameters $ \sigma = 0.2 $, $ K = 50 $, $ T - t = 1 $.}
%     \label{vol_prem}
% \end{figure}
% \begin{figure}[h!]
%     \centering
%     \includegraphics[scale = 0.6]{images/black_vol_prem_delta_crop.png}
%     \caption{Plot of $ \partial\lambda_\sigma / \partial F $ over $ F $ with arbitrary parameters $ \sigma = 0.2 $, $ K = 50 $, $ T - t = 1 $.}
%     \label{vol_prem_delta}
% \end{figure}

\end{document}


\subsection{Block}
I consider the \blk{} to be an abstract notion of memory. It provides an interface between the library and  physical memory.  Although there is only one block class internally blocks need to account for details of how the data is accessed given the particular block create process. For \cvl{} the three blocks are simple{}, \ttbf{derived} blocks and interface blocks.  We cover these below.
\\[6pt]
Data are stored in block objects as scalar values in contiguous order. Where and how the block object stores the data in the physical machine is not defined. The block/machine interface is an implementation detail left to the library implementor.  One of the primary purposes of defining the \cvl{} specification was software portability. Whenever the user directly accesses any machine dependent resource the probability of producing non-portable code is increased. Defining the block object as an abstract notion of memory allows the VSIPL API to not be dependent on whatever machine you happen to be on.
\\[6pt]
Blocks store scalars.  The scalar is not necessarily just a float value or an integer value.  The idea includes complex scalars, matrix or tensor indices, or any sort of value which is acted upon in an atomic fashion. Necessary information to create a block is the number and description of the scalar values the block will store.
\\[6pt]
For \cvl{} we define scalars using the naming convention defined in the specification. We have a  \ttbf{depth} parameter and a \ttbf{precision} parameter where depths are real, complex, matrix index and tensor index. Given the nature of C the depth and precision is set by the particular function call. For \pyjv{} I have decided to stay with the naming convention but I set the depth and precision with a string parameter with obvious connections to the \cvl{} function names. For instance to get a block of depth real and precision float in \cvl{} you do something like
vsip\_block\_f *aBlock = vsip\_blockcreate\_f(aLength, aHint)
and in \pyjv{} you do
aBlock=Block('block\_f',aLength)
\\[6pt]
A way we might look at depth is how many individual pieces can you break a scalar into. For instance with real there is only one piece but with complex you have the real piece and the imaginary piece and with matrix index you have the column piece and the row piece. There are three pieces to a tensor index.
\subsubsection{Derived Block}
So this brings us to the need for a derived block.  This is a little out of order because I talk about views below but most of you should be able to follow this.
\\[6pt]
In \cvl{} we want to be able to have views of the real or imaginary portion of a complex view.  This means we need to attach the view to a real block and precision the same as the complex view.  We do this with something called a derived block.  A derived block accesses the same data space as the parent block but does not own the data space. The data can be modified or read but the parent block is responsible for freeing the underlying data storage memory when the block is no longer being used.
\\[6pt]
In \cvl{} we only have derived blocks for complex but in a general sense anytime you want to define a block for a particular scalar and you need functionality to allow division of the scalar into component parts at the level of a \vw{} you will need to support derived blocks for that if you need in-place functionality.
\paragraph{comment}
You can define functionality to create a new \Blk{} object of the proper type and do a copy of the particular portion of the parent to the new object. For instance in \cvl{} we need a derived block for
\begin{minted}{c}
vsip_vview_d* vsip_vrealview_d(const vsip_cvview_d*)
\end{minted}
but for
\begin{minted}{c}
void vsip_vreal_d(const vsip_cvview_d*, const vsip_vview_d*)
\end{minted}
no derived block is required.
\paragraph{Discussion}
The only way to create a derived block in \cvl{} is with a \vw{} function such as \ttbf{vsip\_\emph{s}realview\_\emph{p}}. There probably should also be a block function to do this since the derived block is at the scope of the entire \blk{}, not just the scope of the \vw{}, but currently this is not the case.
\subsubsection{Interface block}
The user may want to create a block with a special relationship to physical machine memory for the purpose of efficient input and output of data between the library and the user program. In \cvl{} these type blocks look and act the same as any other type block but they have special functionality (block bind, rebind, admit and release) associated with them to allow control of the memory they are associated with, and who owns the right to use the memory at any particular time. For this article I will call these an interface blocks.  In \cvl{} these blocks are created with the \ttbf{vsip\_\emph{d}block\_bind\_\emph{p}} function. We talk more about interface blocks in the data interface section below.  Currently \pyjv{} has no counterpart for the interface block.
\paragraph{Comment} In \cvl{} we have interface \blk{}s but we don't call them that.  This is a new term I started using for this document.
\paragraph*{Comments and Questions VSIPL++}
So in \cvl{} we have a \Blk{} class and the object created, depending upon the method used, may support an interface to user memory and it may support derived \blk{}s.  I know (from reading source code so I don't know for sure) that in VSIPL++ there is a \blk{} associated with direct data access and dense \blk{}s seem to be talked about. There may be other \Blk{} classes. How do these fit into the VSIPL++ data model and how do they compare with the way \cvl{} does it?
%


%%% Template originaly created by Karol Kozioł (mail@karol-koziol.net) and modified for ShareLaTeX use

\documentclass[a4paper,11pt]{article}

\usepackage{amsmath}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage[usenames,dvipsnames]{xcolor}

\usepackage{sansmath}
\renewcommand\familydefault{\sfdefault}
\usepackage{tgheros}

\usepackage{amsmath,amssymb,amsthm,textcomp}
\usepackage{enumerate}
\usepackage{multicol}
\usepackage{tikz}
\usetikzlibrary{shapes, positioning}

\usepackage[super]{nth}
\usepackage{wrapfig}

\usepackage{geometry}
\geometry{total={210mm,297mm},
left=25mm,right=25mm,%
bindingoffset=0mm, top=20mm,bottom=20mm}

\linespread{1.3}

\newcommand{\linia}{\rule{\linewidth}{0.5pt}}

% custom theorems if needed
\newtheoremstyle{mytheor}
    {1ex}{1ex}{\normalfont}{0pt}{\scshape}{.}{1ex}
    {{\thmname{#1 }}{\thmnumber{#2}}{\thmnote{ (#3)}}}

\theoremstyle{mytheor}
\newtheorem{defi}{Definition}

% my own titles
\makeatletter
\renewcommand{\maketitle}{
\begin{center}
\vspace{2ex}
{\huge \textsc{\@title}}
\vspace{1ex}
\\
\linia\\
\@author \hfill \@date
\vspace{4ex}
\end{center}
}
\makeatother
%%%

% custom footers and headers
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{}
\lfoot{Automatic~Verification Assignment \#4}
\cfoot{}
\rfoot{Page \thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
%

% all section titles centered and bolded
\usepackage{sectsty}
\allsectionsfont{\bfseries\large}
%
% add section label
\renewcommand\thesection{Problem~\arabic{section}:}
\renewcommand\thesubsection{(\alph{subsection})}
%

%%%----------%%%----------%%%----------%%%----------%%%

\begin{document}

\title{Homework Assignment~\#4}

\author{R02943142 Hsieh, Chiao}

\maketitle

\section{$\mu$-Calculus}
Consider an extended Kripke structure $M$ as shown below:

\begin{center}
\begin{tikzpicture}[
  scale=2,
  state/.style = {draw, circle, minimum width=8mm, minimum height=8mm},
  every edge/.style = {draw, ->, >=latex, thick},
  trans/.style = {edge label = $a$}
]
  \node (i) at (-0.5, 0){};
  \node[state][label={below:$\{q\}$}]
    (0) at (0, 0) {$0$};
  \node[state][label={below:$\{p\}$}]
    (1) at (1, 0) {$1$};
  \node[state][label={below:$\{p\}$}]
    (2) at (2, 0) {$2$};
  \node[state][label={below:$\{p\}$}]
    (3) at (3, 0) {$3$};
  \node[state][label={below:$\{p,q\}$}]
    (4) at (4, 0) {$4$};

  \path
    (i) edge (0)
    (0) edge[trans] (1)
    (1) edge[trans] (2)
    (2) edge[trans] (3)
    (3) edge[trans] (4)

    (3) edge[trans,bend right=90] (1)
    (4) edge[trans,loop above] (4)
  ;
\end{tikzpicture}
\end{center}
Show the iterative valuations and the final result for the following fixpoints in $\mu$-calculus:

\newcommand{\Eval}{\texttt{Eval}}
\newcommand{\Evalp}{\{1,2,3,4\}}
\newcommand{\Evalq}{\{0,4\}}

\subsection{$\mu Q.(q \vee (p \wedge \langle a \rangle Q))$}
Answer.
\smallskip \\
To compute the fixpoint, we follow the \texttt{Eval} procedure and find $\Eval(\mu Q.(q \vee (p \wedge \langle a \rangle Q)), e)$. Here we present the result of each iteration of fixpoint computation in bottom-up manner.

\noindent \textbf{Atomic Propositions:}
\[
\begin{array}{ll}
  \Eval(q, e) = \Evalq &\qquad \Eval(p, e) = \Evalp \\
\end{array}
\]
\textbf{\nth{0} Iteration:}
\(Q_{old} \gets \bot,\quad e'\gets e[Q \gets Q_{old}]\)
\[
\arraycolsep=1.4pt
\begin{array}{ll}
  \Eval(Q, e')
    &= e[Q \gets Q_{old}](Q) = Q_{old} = \bot \\
  \Eval(\langle a \rangle Q, e')
    &= \{s \mid \exists t. s \xrightarrow{a} t \wedge t \in \Eval(Q, e')\} \\
    &= \{s \mid \exists t. s \xrightarrow{a} t \wedge t \in \bot\} = \bot\\
  Q_{val}
    &= \Eval((q \vee (p \wedge \langle a \rangle Q)), e')\\
    &= \Eval(q, e') \cup (\Eval(p,e') \cap \Eval(\langle a \rangle Q,e')) \\
    &= \Evalq \cup (\Evalp \cap \bot)=\{0,4\} \\
    &\neq Q_{old}
\end{array}
\]
\textbf{\nth{1} Iteration:}
\(Q_{old} \gets \{0,4\},\quad e'\gets e[Q \gets Q_{old}]\)
\[
\arraycolsep=1.4pt
\begin{array}{ll}
  \Eval(Q, e')
    &= \{0,4\} \\
  \Eval(\langle a \rangle Q, e')
    &= \{s \mid \exists t. s \xrightarrow{a} t \wedge t \in \{0,4\}\} \\
    &= \{3,4\} \\
  Q_{val}
    &= \Evalq \cup (\Evalp \cap \{3,4\})=\{0,3,4\} \\
    &\neq Q_{old}
\end{array}
\]
\textbf{\nth{2} Iteration:}
\(Q_{old} \gets \{0,3,4\},\quad e'\gets e[Q \gets Q_{old}]\)
\[
\arraycolsep=1.4pt
\begin{array}{ll}
  \Eval(Q, e')
    &= \{0,3,4\} \\
  \Eval(\langle a \rangle Q, e')
    &= \{s \mid \exists t. s \xrightarrow{a} t \wedge t \in \{0,3,4\}\} \\
    &= \{2,3,4\} \\
  Q_{val}
    &= \Evalq \cup (\Evalp \cap \{2,3,4\}) =\{0,2,3,4\} \\
    &\neq Q_{old}
\end{array}
\]
\textbf{\nth{3} Iteration:}
\(Q_{old} \gets \{0,2,3,4\},\quad e'\gets e[Q \gets Q_{old}]\)
\[
\arraycolsep=1.4pt
\begin{array}{ll}
  \Eval(Q, e')
    &= \{0,2,3,4\} \\
  \Eval(\langle a \rangle Q, e')
    &= \{s \mid \exists t. s \xrightarrow{a} t \wedge t \in \{0,2,3,4\}\} \\
    &= \{1,2,3,4\} \\
  Q_{val}
    &= \Evalq \cup (\Evalp \cap \{1,2,3,4\}) =\{0,1,2,3,4\} \\
    &\neq Q_{old}
\end{array}
\]
\textbf{\nth{4} Iteration:}
\(Q_{old} \gets \{0,1,2,3,4\},\quad e'\gets e[Q \gets Q_{old}]\)
\[
\arraycolsep=1.4pt
\begin{array}{ll}
  \Eval(Q, e')
    &= \{0,1,2,3,4\} \\
  \Eval(\langle a \rangle Q, e')
    &= \{s \mid \exists t. s \xrightarrow{a} t \wedge t \in \{0,1,2,3,4\}\} \\
    &= \{0,1,2,3,4\} \\
  Q_{val}
    &= \Evalq \cup (\Evalp \cap \{0,1,2,3,4\}) =\{0,1,2,3,4\} \\
    &= Q_{old}
\end{array}
\]
Hence, the least fixpoint is \(\{0,1,2,3,4\}\).

\subsection{$\mu Q_1.(\nu Q_2.(p \wedge \langle a \rangle Q_2) \vee (q \wedge \langle a \rangle Q_1))$}
Answer.
\smallskip \\
\textbf{Iteration 00:}
\(
  Q_1^0 \gets \bot,\quad Q_2^{00} \gets \top,\quad
  e' \gets e[Q_1 \gets Q_1^0; Q_2 \gets Q_2^{00}]
\)
\[
\arraycolsep=1.4pt
\begin{array}{ll}
  \Eval&(\langle a \rangle Q_1, e') = \bot
    \qquad \Eval(\langle a \rangle Q_2, e') = \top \\
  Q_2^{01}
    &= (\Evalp \cap \top) \cup (\Evalq \cap \bot)\\
    &= \{1,2,3,4\} \\
    &\neq Q_2^{00}
\end{array}
\]
\textbf{Iteration 01:}
\(
  Q_1^0 \gets \bot,\quad Q_2^{01} \gets \{1,2,3,4\},\quad
  e' \gets e[Q_1 \gets Q_1^0; Q_2 \gets Q_2^{01}]
\)
\[
\arraycolsep=1.4pt
\begin{array}{ll}
  \Eval&(\langle a \rangle Q_1, e') = \bot
    \qquad \Eval(\langle a \rangle Q_2, e') = \top \\
  Q_2^{02}
    &= (\Evalp \cap \top) \cup (\Evalq \cap \bot)\\
    &= \{1,2,3,4\} \\
    &= Q_2^{01} \qquad\text{Found fixpoint for } Q_2\\
  Q_1^1
    &= \Eval(\nu Q_2.(p \wedge \langle a \rangle Q_2) \vee (q \wedge \langle a \rangle Q_1), e') = Q_2^{01} \\
    &= \{1,2,3,4\} \\
    &\neq Q_1^0
\end{array}
\]
\textbf{Iteration 10:}
\(
  Q_1^1 \gets \{1,2,3,4\},\quad Q_2^{10} \gets \top,\quad
  e' \gets e[Q_1 \gets Q_1^1; Q_2 \gets Q_2^{10}]
\)
\[
\arraycolsep=1.4pt
\begin{array}{ll}
  \Eval&(\langle a \rangle Q_1, e') = \top
    \qquad \Eval(\langle a \rangle Q_2, e') = \top \\
  Q_2^{11}
    &= (\Evalp \cap \top) \cup (\Evalq \cap \top)\\
    &= \{0,1,2,3,4\} = \top\\
    &= Q_2^{10} \qquad\text{ Found fixpoint for } Q_2\\
  Q_1^2
    &= Q_2^{10} = \top \\
    &\neq Q_1^1
\end{array}
\]
\textbf{Iteration 20:}
\(
  Q_1^2 \gets \top,\quad Q_2^{20} \gets \top,\quad
  e' \gets e[Q_1 \gets Q_1^2; Q_2 \gets Q_2^{20}]
\)
\[
\arraycolsep=1.4pt
\begin{array}{ll}
  \Eval&(\langle a \rangle Q_1, e') = \top
    \qquad \Eval(\langle a \rangle Q_2, e') = \top \\
  Q_2^{21}
    &= (\Evalp \cap \top) \cup (\Evalq \cap \top)\\
    &= \{0,1,2,3,4\} = \top\\
    &= Q_2^{20} \qquad\text{ Found fixpoint for } Q_2\\
  Q_1^3
    &= Q_2^{20} = \top \\
    &= Q_1^2 \qquad\text{ Found fixpoint for } Q_1\\
\end{array}
\]
Hence, the least fixpoint is \(\{0,1,2,3,4\}\).

\section{NuSMV}
The following is a NuSMV model for two asynchronous processes
that use a semaphore to achieve mutual exclusion.
\begin{verbatim}
MODULE main
VAR
  semaphore : boolean;
  proc1 : process user(semaphore);
  proc2 : process user(semaphore);
ASSIGN
  init(semaphore) := 0;

MODULE user(semaphore)
VAR
  state : {idle, entering, critical, exiting};
ASSIGN
  init(state) := idle;
  next(state) :=
  case
    state = idle : {idle, entering};
    state = entering & !semaphore : critical;
    state = critical : {critical, exiting};
    state = exiting : idle;
    1 : state;
  esac;
next(semaphore) :=
  case
    state = entering : 1;
    state = exiting : 0;
    1 : semaphore;
  esac;
\end{verbatim}

\subsection{Write all the necessary boolean formulae that
specify the main module as a Kripke structure; you may define
shorter substitute names for the variables to save space.}
Answer.
\smallskip \\
For simple representation with boolean formulae, we use $sem$ to denote \texttt{semaphore} and also encode \texttt{state} using two boolean variables $s_0,s_1$ with following mapping on each value of \texttt{state}.
\[
\begin{array}{lcl}
  \texttt{state}=\texttt{idle} & \Leftrightarrow & (s_0,s_1)=(0,0) \text{ or } \neg{s_0}\neg{s_1} \text{ for short}\\
  \texttt{state}=\texttt{entering} & \Leftrightarrow & \neg{s_0}s_1 \\
  \texttt{state}=\texttt{critical} & \Leftrightarrow & s_0s_1 \\
  \texttt{state}=\texttt{exiting} & \Leftrightarrow & s_0\neg{s_1} \\
 &&
\end{array}
\]
Also we use superscript to distinguish the scope of the
variables. For example, $s_1^{1}$ means this variable is for process \texttt{proc1}. If there is no superscript on the variable, it is a global variable.
With these notations, the construction for one process is
straight forward. Following is the construction for \texttt{proc1}. Model for \texttt{proc2} can be constructed in the same way only with different superscript.
\[
\arraycolsep=1.4pt
\begin{array}{lcll}
  \multicolumn{3}{c}{M^\texttt{proc1} = (S^1,I^1,R^1,L^1)}  \\
  I^1 &=& \neg{s_0^1}\neg{s_1^1} &\texttt{\% idle} \\
  R^1 &=&\neg{s_0^1}\neg{s_1^1}(\neg{s_0^1}'\neg{s_1^1}' + \neg{s_0^1}'{s_1^1}')
         &\texttt{\% idle :\ \{idle, entering\}} \\
      &+& \neg{s_0^1}{s_1^1}(\neg{sem}){s_0^1}'{s_1^1}'
         &\texttt{\% entering \& !semaphore :\ critical} \\
      &+& {s_0^1}{s_1^1}({s_0^1}'{s_1^1}'+{s_0^1}'\neg{s_1^1}')
         &\texttt{\% critical :\ \{critical, exiting\}} \\
      &+& {s_0^1}\neg{s_1^1}{\neg{s_0^1}'\neg{s_1^1}'
         &\texttt{\% exiting :\ idle} \\
      &+& (s_0^1 \equiv {s_0^1}')(s_1^1 \equiv {s_1^1}')
         &\texttt{\% 1 :\ state} \\
      &+& \neg{s_0^1}{s_1^1}(sem') &\texttt{\% entering :\ 1} \\
      &+& {s_0^1}\neg{s_1^1}(\neg{sem'})
         &\texttt{\% exiting :\ 0} \\
      &+& (sem \equiv sem') &\texttt{\% 1 :\ semaphore} \\
\end{array}
\]
To compute the Kripke structure for the main module, we have to compose \texttt{proc1} and \texttt{proc2} with interleaving. Formally,
\[
\begin{array}{ll}
  \multicolumn{2}{c}{M^\texttt{main} = (S,I,R,L)}\\
  I &= \neg{sem} \cdot I^1 \cdot I^2 = (\neg{sem})\neg{s_0^1}\neg{s_1^1}\neg{s_0^2}\neg{s_1^2} \\
  R &= R^1 \cdot R^2 \\
\end{array}
\]

\subsection{Please draw BDD diagrams (as small as possible) for
the formulae in 2a.}
Answer. The variable order for both BDDs is
$(s_0^1, s_1^1, {s_0^1}', {s_1^1}',s_0^2, s_1^2, {s_0^2}', {s_1^2}', sem, sem')$.

\begin{wrapfigure}{l}{\textwidth}
\centering
\begin{tikzpicture}[
  scale=1,
  every node/.style = {minimum width=8mm, minimum height=8mm},
  state/.style = {draw, circle},
  const/.style = {draw, rectangle},
  every edge/.style = {draw, ->, >=latex, thick},
  edge1/.style = {},
  edge0/.style = {dotted}
]
  \node (v1) at (0, 5) {$s_0^1$};
  \node (v2) at (0, 4) {$s_1^1$};
  \node (v3) at (0, 3) {$s_0^2$};
  \node (v4) at (0, 2) {$s_1^2$};
  \node (v0) at (0, 1) {$sem$};

  \node[state] (n0) at (5, 5) {};
  \node[state] (n1) at (4, 4) {};
  \node[state] (n2) at (3, 3) {};
  \node[state] (n3) at (2, 2) {};
  \node[state] (n4) at (1, 1) {};

  \node[const] (1)  at (2, 0) {$1$};
  \node[const] (0)  at (5, 0) {$0$};

  \path
    (n0) edge[edge0] (n1)
         edge[edge1] (0)
    (n1) edge[edge0] (n2)
         edge[edge1] (0)
    (n2) edge[edge0] (n3)
         edge[edge1] (0)
    (n3) edge[edge0] (n4)
         edge[edge1] (0)
    (n4) edge[edge0] (1)
         edge[edge1] (0)
  ;
\end{tikzpicture}
\caption{BDD for Initial States $I$}
\label{fig:BDD_I}
\end{wrapfigure}

\begin{wrapfigure}{l}{\textwidth}
\centering
\includegraphics[width=\textwidth]{HW4_bdd}
\caption{BDD for Transition Relation $R$}
\label{fig:BDD_R}
\end{wrapfigure}

\end{document}


% !TEX root = ./Basilisk-avsLibrary20170812.tex

\section{Library Functions}

The AVS astrodynamics support library is developed to facility writing C-code that must perform the associated mathematical functions.  It is not a Basilisk module, but included with the main Basilisk distribution as a support library.  The library goals are

\begin{itemize}
	\item \textbf{C-Code implementation}: All function calls only use C-code.
	\item \textbf{Linear Algebra}: Basic matrix math function that are common in Matlab and Python environment quickly become tedious when programming in C.  To avoid this, a custom written C library is developed to perform specialized 2, 3, 4, and 6 dimensional matrix math, but some linear algebra math on matrices of general size.
	\item \textbf{Rigid Body Kinematics}: Provides a comprehensive C-based software library to convert between a broad range of rigid body attitude coordinates, as well as add and subtract orientations.  This library can also compute the differential kinematic equations of select coordinate types. The textbook  Reference~\citenum{schaub} contains a complete listing of all the attitude library function in Appendix E.
	\item \textbf{Orbital Motion Library}:  Provides a comprehensive C-based software library to convert between orbit anomaly angles, as well as orbit elements and Cartesian coordinates.  This library also contains some simple space environment modeling functions.

\end{itemize}

\section{Library Assumptions and Limitations}

\subsection{Assumptions}
\subsubsection{Linear Algebra Library}
The vector dimension can be declared either explicitly through
\begin{verbatim}
     double vec[3]
\end{verbatim}
or implicitly through
\begin{verbatim}
     double *vec
\end{verbatim}
and allocating the required memory dynamically.   However, with the specialized matrix dimensions the matrices are assumed to be defined through commands like
\begin{verbatim}
     double m33[3][3]
\end{verbatim}
 for a $3\times 3$ matrix.

\subsubsection{Rigid Body Kinematics}
These attitude kinematic relationships are general enough that no assumptions are made on the mathematics.  However, when the $3\times 3$ DCM are defined, they must be of type
\begin{verbatim}
     double BN[3][3]
\end{verbatim}

\subsubsection{Orbital Motion}
This orbital motion library accepts the inertial position and velocity vectors as pointers to a 3-dimensional array.  As with the linear algebra library, these can be declared explicitly or implicitly.

\subsection{Limitations}
\subsubsection{Linear Algebra Library}
There are no limitations on the provided linear algebra routines.  They are written in a general manner.

\subsubsection{Rigid Body Kinematics}
There are no limitations on the provided linear algebra routines.  They are written in a general manner.

\subsubsection{Orbital Motion}
The orbital motion support library has the following limitations.
\begin{itemize}
	\item While the {\tt elem2rv()} support rectilinear cases, the inverse mapping in {\tt rv2elem()} does not.
	\item The gravitational zonal harmonics for $J_{3}$-$J_{6}$ are only implemented for Earth, and not other celestial objects.
	\item The atmospheric density and drag, as well as the Debye length models are only implemented for Earth orbiting scenarios.
\end{itemize}


%
% API Documentation for Peach - Computational Intelligence for Python
% Module peach.fuzzy.norms
%
% Generated by epydoc 3.0beta1
% [Mon Dec 21 08:51:36 2009]
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                          Module Description                           %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}!peach.fuzzy.norms \textit{(module)}|(}
\section{Module peach.fuzzy.norms}

    \label{peach:fuzzy:norms}

This package implements operations of fuzzy logic.

Basic operations are \texttt{and ({\&})}, \texttt{or (|)} and \texttt{not ({\textasciitilde})}. Those are
implemented as functions of, respectively, two, two and one values. The \texttt{and}
is the t-norm of the fuzzy logic, and it is a function that takes two values and
returns the result of the \texttt{and} operation. The \texttt{or} is a function that takes
two values and returns the result of the \texttt{or} operation. the \texttt{not} is a
function that takes one value and returns the result of the \texttt{not} operation.
To implement your own operations there is no need to subclass -{}- just create the
functions and use them where appropriate.

Also, implication and aglutination functions are defined here. Implication is
the result of the generalized modus ponens used in fuzzy inference systems.
Aglutination is the generalization from two different conclusions used in fuzzy
inference systems. Both are implemented as functions that take two values and
return the result of the operation. As above, to implement your own operations,
there is no need to subclass -{}- just create the functions and use them where
appropriate.

The functions here are provided as convenience.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                               Functions                               %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  \subsection{Functions}

    \label{peach:fuzzy:norms:ZadehAnd}
    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}!peach.fuzzy.norms \textit{(module)}!peach.fuzzy.norms.ZadehAnd \textit{(function)}}

    \vspace{0.5ex}

    \begin{boxedminipage}{\textwidth}

    \raggedright \textbf{ZadehAnd}(\textit{x}, \textit{y})

    \vspace{-1.5ex}

    \rule{\textwidth}{0.5\fboxrule}

And operation as defined by Lofti Zadeh.

And operation is the minimum of the two values.
    \vspace{1ex}

      \textbf{Return Value}
      \begin{quote}

The result of the and operation.
      \end{quote}

    \vspace{1ex}

    \end{boxedminipage}

    \label{peach:fuzzy:norms:ZadehOr}
    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}!peach.fuzzy.norms \textit{(module)}!peach.fuzzy.norms.ZadehOr \textit{(function)}}

    \vspace{0.5ex}

    \begin{boxedminipage}{\textwidth}

    \raggedright \textbf{ZadehOr}(\textit{x}, \textit{y})

    \vspace{-1.5ex}

    \rule{\textwidth}{0.5\fboxrule}

Or operation as defined by Lofti Zadeh.

Or operation is the maximum of the two values.
    \vspace{1ex}

      \textbf{Return Value}
      \begin{quote}

The result of the or operation.
      \end{quote}

    \vspace{1ex}

    \end{boxedminipage}

    \label{peach:fuzzy:norms:ZadehNot}
    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}!peach.fuzzy.norms \textit{(module)}!peach.fuzzy.norms.ZadehNot \textit{(function)}}

    \vspace{0.5ex}

    \begin{boxedminipage}{\textwidth}

    \raggedright \textbf{ZadehNot}(\textit{x})

    \vspace{-1.5ex}

    \rule{\textwidth}{0.5\fboxrule}

Not operation as defined by Lofti Zadeh.

Not operation is the complement to 1 of the given value, that is, \texttt{1 - x}.
    \vspace{1ex}

      \textbf{Return Value}
      \begin{quote}

The result of the not operation.
      \end{quote}

    \vspace{1ex}

    \end{boxedminipage}

    \label{peach:fuzzy:norms:MamdaniImplication}
    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}!peach.fuzzy.norms \textit{(module)}!peach.fuzzy.norms.MamdaniImplication \textit{(function)}}

    \vspace{0.5ex}

    \begin{boxedminipage}{\textwidth}

    \raggedright \textbf{MamdaniImplication}(\textit{x}, \textit{y})

    \vspace{-1.5ex}

    \rule{\textwidth}{0.5\fboxrule}

Implication operation as defined by Mamdani.

Implication is the minimum of the two values.
    \vspace{1ex}

      \textbf{Return Value}
      \begin{quote}

The result of the implication.
      \end{quote}

    \vspace{1ex}

    \end{boxedminipage}

    \label{peach:fuzzy:norms:MamdaniAglutination}
    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}!peach.fuzzy.norms \textit{(module)}!peach.fuzzy.norms.MamdaniAglutination \textit{(function)}}

    \vspace{0.5ex}

    \begin{boxedminipage}{\textwidth}

    \raggedright \textbf{MamdaniAglutination}(\textit{x}, \textit{y})

    \vspace{-1.5ex}

    \rule{\textwidth}{0.5\fboxrule}

Aglutination as defined by Mamdani.

Aglutination is the maximum of the two values.
    \vspace{1ex}

      \textbf{Return Value}
      \begin{quote}

The result of the aglutination.
      \end{quote}

    \vspace{1ex}

    \end{boxedminipage}

    \label{peach:fuzzy:norms:ProbabilisticAnd}
    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}!peach.fuzzy.norms \textit{(module)}!peach.fuzzy.norms.ProbabilisticAnd \textit{(function)}}

    \vspace{0.5ex}

    \begin{boxedminipage}{\textwidth}

    \raggedright \textbf{ProbabilisticAnd}(\textit{x}, \textit{y})

    \vspace{-1.5ex}

    \rule{\textwidth}{0.5\fboxrule}

And operation as a probabilistic operation.

And operation is the product of the two values.
    \vspace{1ex}

      \textbf{Return Value}
      \begin{quote}

The result of the and operation.
      \end{quote}

    \vspace{1ex}

    \end{boxedminipage}

    \label{peach:fuzzy:norms:ProbabilisticOr}
    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}!peach.fuzzy.norms \textit{(module)}!peach.fuzzy.norms.ProbabilisticOr \textit{(function)}}

    \vspace{0.5ex}

    \begin{boxedminipage}{\textwidth}

    \raggedright \textbf{ProbabilisticOr}(\textit{x}, \textit{y})

    \vspace{-1.5ex}

    \rule{\textwidth}{0.5\fboxrule}

Or operation as a probabilistic operation.

Or operation is given as the probability of the intersection of two events,
that is, x + y - xy.
    \vspace{1ex}

      \textbf{Return Value}
      \begin{quote}

The result of the or operation.
      \end{quote}

    \vspace{1ex}

    \end{boxedminipage}

    \label{peach:fuzzy:norms:ProbabilisticNot}
    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}!peach.fuzzy.norms \textit{(module)}!peach.fuzzy.norms.ProbabilisticNot \textit{(function)}}

    \vspace{0.5ex}

    \begin{boxedminipage}{\textwidth}

    \raggedright \textbf{ProbabilisticNot}(\textit{x})

    \vspace{-1.5ex}

    \rule{\textwidth}{0.5\fboxrule}

Not operation as a probabilistic operation.

Not operation is the complement to 1 of the given value, that is, \texttt{1 - x}.
    \vspace{1ex}

      \textbf{Return Value}
      \begin{quote}

The result of the not operation.
      \end{quote}

    \vspace{1ex}

    \end{boxedminipage}

    \label{peach:fuzzy:norms:ProbabilisticImplication}
    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}!peach.fuzzy.norms \textit{(module)}!peach.fuzzy.norms.ProbabilisticImplication \textit{(function)}}

    \vspace{0.5ex}

    \begin{boxedminipage}{\textwidth}

    \raggedright \textbf{ProbabilisticImplication}(\textit{x}, \textit{y})

    \vspace{-1.5ex}

    \rule{\textwidth}{0.5\fboxrule}

Implication as a probabilistic operation.

Implication is the product of the two values.
    \vspace{1ex}

      \textbf{Return Value}
      \begin{quote}

The result of the and implication.
      \end{quote}

    \vspace{1ex}

    \end{boxedminipage}

    \label{peach:fuzzy:norms:ProbabilisticAglutination}
    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}!peach.fuzzy.norms \textit{(module)}!peach.fuzzy.norms.ProbabilisticAglutination \textit{(function)}}

    \vspace{0.5ex}

    \begin{boxedminipage}{\textwidth}

    \raggedright \textbf{ProbabilisticAglutination}(\textit{x}, \textit{y})

    \vspace{-1.5ex}

    \rule{\textwidth}{0.5\fboxrule}

Implication as a probabilistic operation.

Implication is given as the probability of the intersection of two events,
that is, x + y - xy.
    \vspace{1ex}

      \textbf{Return Value}
      \begin{quote}

The result of the and implication.
      \end{quote}

    \vspace{1ex}

    \end{boxedminipage}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                               Variables                               %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

  \subsection{Variables}

\begin{longtable}{|p{.30\textwidth}|p{.62\textwidth}|l}
\cline{1-2}
\cline{1-2} \centering \textbf{Name} & \centering \textbf{Description}& \\
\cline{1-2}
\endhead\cline{1-2}\multicolumn{3}{r}{\small\textit{continued on next page}}\\\endfoot\cline{1-2}
\endlastfoot\raggedright \_\-\_\-d\-o\-c\-\_\-\_\- & \raggedright \textbf{Value:}
{\tt \texttt{...}}&\\
\cline{1-2}
\raggedright Z\-A\-D\-E\-H\-\_\-N\-O\-R\-M\-S\- & \raggedright Tuple containing, in order, Zadeh and, or and not operations

\textbf{Value:}
{\tt ZadehAnd, ZadehOr, ZadehNot}&\\
\cline{1-2}
\raggedright M\-A\-M\-D\-A\-N\-I\-\_\-I\-N\-F\-E\-R\-E\-N\-C\-E\- & \raggedright Tuple containing, in order, Mamdani implication and algutination

\textbf{Value:}
{\tt MamdaniImplication, MamdaniAglutination}&\\
\cline{1-2}
\raggedright P\-R\-O\-B\-\_\-N\-O\-R\-M\-S\- & \raggedright Tuple containing, in order, probabilistic and, or and not operations

\textbf{Value:}
{\tt ProbabilisticAnd, ProbabilisticOr, ProbabilisticNot}&\\
\cline{1-2}
\raggedright P\-R\-O\-B\-\_\-I\-N\-F\-E\-R\-E\-N\-C\-E\- & \raggedright Tuple containing, in order, probabilistic implication and algutination

\textbf{Value:}
{\tt ProbabilisticImplication, ProbabilisticAglutination}&\\
\cline{1-2}
\end{longtable}

    \index{peach \textit{(package)}!peach.fuzzy \textit{(package)}!peach.fuzzy.norms \textit{(module)}|)}


\documentclass[10pt]{article}
\usepackage[publish]{dlmath}
\usepackage{tablefootnote}
\usepackage{marvosym}
\usepackage[hyphens]{url}
\usepackage[colorlinks=true, linkcolor=blue]{hyperref}
\usepackage{makeidx}
\newcommand{\dom}[1]{\ensuremath{\hbox{Dom}(#1)}}
%\newcommand{\code}[1]{\texttt{#1}}

%{\theoremstyle{definition} \newtheorem{note}{Note}}
%\newtheorem{defn}{Definition}
%opening
\title{Piecewise Linear with Decay}
\author{Bill Adams}
\date{Sept 2020}
\makeindex

\begin{document}
\maketitle

%\tableofcontents
\begin{abstract}
	Piecewise defined linear functions can be very useful in certain situations.  Having those
	functions decay smoothly to asymptotic values can be even more useful.  In this paper we
	describe a way to achieve that.
\end{abstract}

\tableofcontents

\section{Introduction}
A piecewise defined function is a function whose formula varies on different
regions of the domain. Typically those regions are continuous intervals, i.e.
sets of the form
$$[a,b] \defeq \{x | a \leq x \leq b\}$$
or
$$(a,b) \defeq \{x | a < x < b\}$$
or some mixture of half-closed and half-opened intervals.

The best way to get a feel for piecewise defined functions is to see an
example and the corresponding graph of the function.
Consider the following piecewise defined function examples:
\begin{note}
In the graphs below we use the red dots to indicate the beginning
and end points of the domains of definition of the function.
\end{note}
\begin{example}
\label{ex:1}
$$
f(x) =
\begin{cases}
x^2 & \hbox{ if } x\in [0,2] \\
-x+6 & \hbox{ if } x \in [2, 5]
\end{cases}
$$
\begin{center}
\includegraphics[width=2.5in]{graph1}
\end{center}
The function $f(x)$ is only defined on the closed interval $[0, 5]$, that is
we can only calculate $f(x)$ for values of $x$ between 0 and 5.  The function
is continuous, that is we can draw the graph without picking up our pencil.
Also the domain of the function, namely $x \in [0,5]$ is connected.
\end{example}
\begin{example}
\label{ex:2}
$$
f(x) =
\begin{cases}
x^3 & \hbox{ if } x\in [0,2] \\
x-2 & \hbox{ if } x \in (2, 5]
\end{cases}
$$
\begin{center}
\includegraphics[width=2.5in]{graph2}
\end{center}
This is an example of a discontinuous piecewise defined function because the
graph has a break over $x=2$.  Note that the first definition covers the
closed interval $[0,2]$ whereas the second definition only covers the
half-opened interval $(2,5]$.  However this function has a domain of
$x \in [0, 5]$ which is a connected domain (there are no gaps in it).
\end{example}

\begin{example}
\label{ex:3}
$$
f(x) =
\begin{cases}
x^3 & \hbox{ if } x\in [0,2] \\
x-2 & \hbox{ if } x \in [5, 8]
\end{cases}
$$
\begin{center}
\includegraphics[width=2.5in]{graph3}
\end{center}
This is an example of a discontinuous piecewise defined function because the
graph has a break from $x=2$ to $x=5$.  Also this function has a domain of
$x \in [0, 2] \cup [5,8]$ which is a disconnected domain, i.e.
there is a gap in the domain from $2$ to $5$.
\end{example}

\begin{note}[Warning!]
For the purposes of this paper we only consider piecewise defined functions
that are continuous and have a connected domain.  In other words we only
consider the case of Example \ref{ex:1}.  We do not consider discontinuous
piecewise defined functions like Example \ref{ex:2}.  Neither do we consider
piecewise defined functions whose domain is disconnects, as in Example
\ref{ex:3}.
\end{note}

\section{Piecewise linear functions}
A piecewise linear function is simply a piecewise defined function whose
every piece is a linear function.  There are several ways we could formally
define this.  The following is a more abstract definition.
\begin{definition}
A function $f(x)$ is a \ul{piecewise linear, continuous function, with
finite connected domain} iff:
\begin{enumerate}
\item $f(x)$ is continuous
\item The domain of $f(x)$, which we write as \dom{f}, is a finite connected
interval.  In other words, it does not go to infinity on either side.
\item For every point $x_0 \in \dom{f}$ there is an interval $[a,b]$ so that
$x \in [a,b]$ and $f(x)$ restricted to $[a,b]$ is a linear function.
\end{enumerate}
\end{definition}
\begin{note}
We only consider piecewise linear, continuous functions with connected domain.
Thus we shorten that long phrase to \ul{piewewise linear function}.
\end{note}
A more concrete definition of a piecewise linear function is the following.
\begin{definition}[Concrete definition of piecewise linear]
\label{def:concrete}
A function $f(x)$ is a \ul{piecewise linear function} iff it can be written as
$$f(x) =
\begin{cases}
m_1 x + b_1 & \hbox{ if } x \in [a_1, a_2] \\
m_2 x + b_2 & \hbox{ if } x \in [a_2, a_3] \\
\vdots & \vdots \\
m_{n-1} x + b_{n-1} & \hbox{ if } x \in [a_{n-1}, a_n]
\end{cases}
$$
where $a_1 < a_2 < \ldots < a_n$.
\end{definition}
\begin{note}
These two definitions are equivalent.  The second definition is much more
useful for computational purposes, the first would be more useful for the
purposes of proving things.
\end{note}
\begin{note}
\label{note:mb}
In Definition \ref{def:concrete}, the slope $m_i$ and y intercept $b_i$ in
the function definition on the interval $[a_i, a_{i+1}]$ can be calculated by
knowing $y_i = f(a_i)$ and $y_{i+1}=f(a_{i+1})$.  We can show the formula by
noting that the function is linear from the point $(a_i, y_i)$ to the point
$(a_{i+1}, y_{i+1})$.  Then the slope $m_i$ is:
$$m_i = \frac{y_{i+1}-y_i}{a_{i+1}-a_i}$$
and $b_i$ can be found by plugging either point into the equation of the line
$y=m_ix+b$ and solving for $b$.  If we use $(a_i, y_i)$ we get:
$$b_i=y_i-m_ia_i$$
\end{note}
Based Note \ref{note:mb} we see that a piecewise linear function can be defined
by giving a list of $a_i$'s and $y_i$'s.  Therefore we have a simple computational
definition of a piecewise linear function.
\begin{definition}[Computational]
\label{def:computational}
A piecewise linear function is defined by $\vec{a}=(a_1,a_2,\ldots,a_n)$ and
$\vec{y}=(y_1, y_2, \ldots y_n)$, where $a_1<a_2<\ldots <a_n$.  The formula
for the piecewise linear function defined by $\vec{a}$ and $\vec{y}$ is given by
$$
f_{\vec{a},\vec{y}}(x) \defeq
\begin{cases}
m_1 x + b_1 & \hbox{ if } x \in [a_1, a_2] \\
m_2 x + b_2 & \hbox{ if } x \in [a_2, a_3] \\
\vdots & \vdots \\
m_{n-1} x + b_{n-1} & \hbox{ if } x \in [a_{n-1}, a_n]
\end{cases}
$$
where:
\begin{eqnarray*}
m_i &=& \frac{y_{i+1}-y_i}{a_{i+1}-a_i} \\
b_i &=& y_i - m_i x_i
\end{eqnarray*}
\end{definition}
\section{Piecewise linear with decay}
Given a piecewise linear function (that is continuous with connected finite
domain), is there a natural way to extend it to positive and negative infinity
given asymptotes on both sides?  For example consider the graph shown below:

\includegraphics[width=2.5in]{pw_nodecay}

The red dotted line on top represents the asymptote on the right and the green
dotted line on the bottom represents the asymptote to the left.  Can we extend
our function continuously so that the graph approaches the given asymptotes?
There are many ways we can, consider:

\includegraphics[width=2.5in]{pw_decay1a}

This graph extends the previous one with the desired asymptotic behavior.
However there are many other choices as well.  Looking at the graph above
we notice that the slope of the graph where the left hand decay begins does
not match the slope of the piecewise linear piece beside it.  If we want
the slope of the decay function to match the slope of the linear piece the
decay connects with, this limits our choices more.  In fact if we:
\begin{enumerate}
\item specify the decay function to use (e.g. linear, exponential, etc), and
\item specify the resulting function must be continuous, and
\item specify that the slopes of the decays must match the slope of the piecewise linear
function on the edges of the domain \ldots
\end{enumerate}
then we uniquely determine the formula for the decay function to use.  Let's
collect that idea in Definition \ref{def:pwdecay}.  However first we need to
define the formulas for our decay functions.
\begin{definition}[Decay functions]
We define the exponential decay function as:
$$\mathfrak{e}_{A,B,C}(x) \defeq Ae^{Bx}+C$$
and we define the power decay function of degree $k$ as:
$$\mathfrak{p}_{k,A,B,C}(x) \defeq \frac{A}{(x-B)^k}+C$$
\end{definition}
\begin{note}
The parameter $C$ in both decay functions represents the limiting value
the function is decaying towards.
\end{note}
\begin{definition}
\label{def:pwdecay}
Given $f(x)$ a piecewise linear function (continuous on a finite connected domain $[a,b]$) and
\begin{enumerate}
\item a left hand asymptotic value $y_{-\infty}$
\item a right hand asymptotic value $y_{\infty}$
\item a decay function type (either exponential, or power for fixed degree $k$)
\end{enumerate}
an \ul{extension with decay} of $f(x)$ with decay is a function $\overline{f}(x)$ that:
\begin{enumerate}
\item the extension $\overline{f}$ agrees with $f$ on the domain $[a,b]$
\item the extension restricted to $(-\infty, a]$ matches the decay function type
\item the extension restricted to $[b, \infty)$ matches the decay function type
\item the extension is continuous
\item the slope of the extension at the points $x=a$ and $x=b$ are well defined.
\end{enumerate}
\end{definition}

We now have our main result:
\begin{theorem}
\label{thm:main}
Given a piecewise linear function (continuous on a finite connected domain $[a,b]$) such
that the slope at $x=a$ is not zero, and similarly for $x=b$, and
\begin{enumerate}
\item a left hand asymptotic value $y_{-\infty}$
\item a right hand asymptotic value $y_{\infty}$
\item a decay function type (either exponential for fixed $B$, or power for fixed $B$ and $k$)
\end{enumerate}
then there exists a unique extension with decay $\overline{f}$ of $f$.
\end{theorem}
We prove this theorem by proving the two cases separately
\begin{proof}
Proven in 2 cases, Theorem \ref{thm:power} and \ref{thm:exponential}.
\end{proof}

\begin{theorem}[Power Decay Version of Theorem \ref{thm:main}]
\label{thm:power}
Theorem \ref{thm:main} is true when the decay function is a power function, i.e.
$\mathfrak{p}_{k,A,B,C}(x)$.  Furthermore the parameters for the decay function on the left hand
side decay function are given by:
\begin{eqnarray*}
C&=& \hbox{LHS asymptotic value} \\
B&=&a_1 + \frac{k}{m_1}(y_1-C)\\
A&=&(y_1-C)(a_1-B)^k
\end{eqnarray*}
and the parameters for the right hand side decay function are given by:
\begin{eqnarray*}
C&=& \hbox{RHS asymptotic value} \\
B&=&a_n + \frac{k}{m_{n-1}}(y_n-C)\\
A&=&(y_n-C)(a_n-B)^k
\end{eqnarray*}
Where $\vec{a}=(a_1, \ldots, a_n)$, $\vec{y}=(y_1,\ldots,y_n)$ and $m_i$ are
as Definition \ref{def:computational}.
\end{theorem}
\begin{proof}
We need only derive the formula for $B$ and $A$ given that we know the value
of the decay function at point $x_0$ and the value of its derivative
at $x_0$ and the limiting value, which is $C$.  So given our decay function:
\begin{eqnarray}
\label{eqn:1}
\mathfrak{p}_{k,A,B,C}(x)&=&\frac{A}{(x-B)^k} + C
\end{eqnarray}
and assume we know:
\begin{eqnarray}
\label{eqn:2}\mathfrak{p}_{k,A,B,C}(x_0)&=&y_0 \\
\label{eqn:3}\mathfrak{p}'_{k,A,B,C}(x_0)&=&m_0 \\
C&=&\hbox{ the limiting value}
\end{eqnarray}
we want to use those equations to solve for $A, B$. Notice that:
\begin{eqnarray}
\label{eqn:4}\mathfrak{p}'_{k,A,B,C}(x) &=& \frac{-kA}{(x-B)^{k+1}}
\end{eqnarray}
Using Equation \ref{eqn:2} and the definition in Equation \ref{eqn:1} we get:
\begin{eqnarray}
\mathfrak{p}_{k,A,B,C}(x_0)&=&y_0 \\
\frac{A}{(x_0-B)^k} +C &=& y_0 \\ \label{eqn:k}
\frac{A}{(x_0-B)^k} &=& y_0 - C
\end{eqnarray}
Using Equation \ref{eqn:3} and the definition of the slope in Equation
\ref{eqn:4} we see:
\begin{eqnarray}
\mathfrak{p}'_{k,A,B,C}(x_0)&=&m_0 \\
\frac{-kA}{(x_0-B)^{k+1}}&=&m_0 \\
\left(\frac{A}{(x_0-B)^{k}}\right) \left( \frac{-k}{x_0-B} \right) &=&m_0 \\
\hbox{plug Equation \ref{eqn:k} in} \\
\left(y_0-C\right)\left( \frac{-k}{x_0-B} \right) &=& m_0 \\
y_0-C &=& -(x_0-B)\frac{m_0}{k} \\
(y_0-C)\frac{k}{m_0}&=&-x_0+B \\
\label{eqn:Bsolve}(y_0-C)\frac{k}{m_0}+x_0&=&B
\end{eqnarray}
With this we have solved for $B$, now we need to solve for $A$.  We can use
Equation \ref{eqn:k} to do this.
\begin{eqnarray}
\frac{A}{(x_0-B)^k} &=& y_0 - C \\
\label{eqn:Asolve} A &=& (x_0-B)^k(y_0-C)
\end{eqnarray}
Using Equations \ref{eqn:Bsolve} and \ref{eqn:Asolve} for $x_0=a_1, y_0=y_1, m_0=m_1$ we
get the left side decay formula for $A$ and $B$.  Similarly using those equations for
$a_n, y_n, m_{n-1}$ we get the right side decay formula for $A$ and and $B$.
\end{proof}

\begin{theorem}[Exponential Decay Version of Theorem \ref{thm:main}]
\label{thm:exponential}
Theorem \ref{thm:main} is true when the decay function is an exponential function, i.e.
$\mathfrak{e}_{A,B,C}(x)$.  Furthermore the parameters for the decay function on the left hand
side decay function is given by:
\begin{eqnarray*}
C&=&\hbox{LHS asymptotic value} \\
B &=& \frac{m_1}{y_1-C} \\
A&=&(y_1-C)e^{-Ba_1}
\end{eqnarray*}
and the parameters for the right hand side decay function are given by:
\begin{eqnarray*}
C&=&\hbox{RHS asymptotic value}\\
B &=& \frac{m_{n-1}}{y_n-C} \\
A&=&(y_n-C)e^{-Ba_n}
\end{eqnarray*}
Where $\vec{a}=(a_1, \ldots, a_n)$, $\vec{y}=(y_1,\ldots,y_n)$ and $m_i$ are
as Definition \ref{def:computational}.
\end{theorem}
\begin{proof}
As with the proof of Theorem \ref{thm:power} we simply need to prove the
formulas for $A$ and $C$ when we have the conditions
\begin{eqnarray}
\mathfrak{e}_{A,B,C}(x_0) &=& y_0 \label{eqn:e1}\\
\mathfrak{e}'_{B}(x_0) &=& m_0 \label{eqn:e2}
\end{eqnarray}
Notice that the exponential decay function and its derivative are given by:
\begin{eqnarray}
\mathfrak{e}_{A,B,C}(x) = Ae^{Bx}+C \label{eqn:e3}\\
\mathfrak{e}'_{B}(x) = ABe^{Bx} \label{eqn:e4}
\end{eqnarray}
We can use the formula in Equation \ref{eqn:e3} and plug into Equation \ref{eqn:e1}
and get:
\begin{eqnarray}
\mathfrak{e}_{A,B,C}(x_0) &=& y_0 \\
Ae^{Bx_0} + C &=& y_0 \\
Ae^{Bx_0} &=& y_0 - C \label{eqn:ePlugin}\\
A&=&(y_0-C)e^{-Bx_0} \label{eqn:eAsolve}
\end{eqnarray}

Using the formula from Equation \ref{eqn:e4} with Equation \ref{eqn:e2} and
solving for $A$ we get:
\begin{eqnarray}
\mathfrak{e}'_{B}(x_0) &=& m_0 \\
ABe^{Bx_0} &=& m_0 \\
B \left(Ae^{Bx_0} \right)&=& m_0 \\
B(y_0-C) &=&m_0 \hbox{ (plugin Equation \ref{eqn:ePlugin})} \\
B &=& \frac{m_0}{y_0-C} \label{eqn:eBsolve}
\end{eqnarray}

We can use Equations \ref{eqn:eAsolve} and \ref{eqn:eBsolve} when $x_0=a_1$,
$y_0=y_1$ and $m_0=m_1$ to get the formulas for the left hand side decay formulas
for $A$ and $C$:
\begin{eqnarray*}
A&=&(y_1-C)e^{-Ba_1}\\
B &=& \frac{m_1}{y_1-C}
\end{eqnarray*}
And similarly we get the equations for the right hand side decay formula.
\end{proof}
\section{What happens with only one point?}
With only a single point $(x_1, y_1)$ there is no piecewise linear function to do,
only the decays.  However, we do not have two points to calculate $m_1$ and $m_{n-1}$
from the formulas.  When this happens, we simply define $m_1$ and $m_{n-1}$ to be 1, if
the LHS asymptote is less than or equal to the RHS asymptote and we set them to -1 otherwise.

For instance if we have a piecewise linear function with decays
through the point $(10,0.5)$ with LHS limit 0 and RHS limit 1, the decay slopes
$m_1$ and $m_{n-1}$ would both be 1.  The graph is shown below.
\textbf{Note:} the red line is the line of slope one through the point $(10,0.5)$.
That line is the tangent to our graph, by construction.
\begin{center}
	\includegraphics[width=3.5in]{graph4}
\end{center}

Whereas if we have the same setup except the LHS and RHS asymptotes are switched, the
slopes $m_1$ and $m_{n-1}$ would both be $-1$.  The graph is shown below.
\textbf{Note:} the red line is the line of slope -1 through the point $(10,0.5)$.
That line is the tangent to our graph, by construction.

\begin{center}
	\includegraphics[width=3.5in]{graph5}
\end{center}
%\bibliography{programming}
%\bibliographystyle{plain}
\end{document}


\subsection{Redesigning the Database Model}\label{databaseModelRedesignNF}
We will now detail how we created relations describing the new models for the database.
Other groups of the \knox{} pipeline requested that entities representing articles have a unique Id field, regardless of what is considered good database design.
Similarly, they wanted a field denoting the total words appearing in the article.

We started by creating an ER-model of the domain, and then described the entity and relationship sets using the relational model, using the method described in section \ref{relational_databases}.

\begin{figure}[H]
    \centering
    \includegraphics[scale=0.35]{Images/FinalERDiagram.png}
    \caption{ER diagram depicting the new model of the database. Notice that the relationship set \textit{Publishes} and entity set \textit{publisher} has not changed.}
    \label{fig:newdatabaseRedesignER}
\end{figure}

Equation \ref{eq:newDatabaseRelationalModel} shows relations representing the new database structures from figure \ref{fig:newdatabaseRedesignER}.
Notice that the existing $publisher$ relation in the database has exactly the same attributes as the new one.

\begin{equation}\label{eq:newDatabaseRelationalModel}
    \begin{split}
        article(\underline{article\_id: \mathbb{Z^+}}, title:text,\\ total\_words:\mathbb{Z^+}, publisher\_name \rightarrow publisher, file\_path:text), \\
        word(\underline{text:text}),\\
        publisher(\underline{publisher\_name:text}),\\
        occursIn(\underline{text \rightarrow word}, \underline{article\_id \rightarrow article}, count:\mathbb{Z^+})\\
    \end{split}
\end{equation}

We had to ensure that the WordRatio view, described in section \ref{WordRatioCrud} and appendix \ref{Appendix_WordRatioOld}, still contained the same information as before.
Since the view is an abstraction over a \texttt{SELECT} query, we describe it using relational algebra.
The query of the view can be seen in equation \ref{create_new_view_rel_alg}.
The resulting relation structure is seen in equation \ref{create_new_view_rel_alg_structure}.

\begin{equation}\label{create_new_view_rel_alg}
    \begin{split}
        \sigma_{article\_id, text, count,title, file\_path, total\_words, publisher\_name, percent} \\
        ((article \Join_{article.article\_id = occursIn.article\_id} occursIn) \\
        \Join_{article.publisher\_name = publisher.publisher\_name} publisher\\
        \Join \gamma_{article, occursIn;percent(count, total\_words)})
    \end{split}
\end{equation}

\begin{equation}\label{create_new_view_rel_alg_structure}
    \begin{split}
        wordRatio(article\_id:\mathbb{Z^+}, text:text, count:\mathbb{Z^+},title:text, file\_path:text,\\ total\_words:\mathbb{Z^+}, publisher\_name:text, percent:\mathbb{R^+})
    \end{split}
\end{equation}

sections/Chapter 8 Sprint 6/CreatingNewModels.tex


\section{Displaying and Changing the State of a Specification}

\subsection{Displaying the State of a Specification}
\label{Displaying}

\begin{command}[\comName{moduleName}]
displays the name of the current specification.
\end{command}

\begin{command}[\comName{orderName}]
displays the name of the order specification associated with
the current specification.
\end{command}

The state of a specification consists of the current signature, the set of equations
and rules and of the current definitions for the termination ordering. There are
several commands to print out this information.\bigskip

\begin{command}[\comName{sig}]
prints out the signature of the current specification:
\end{command}

If you are writing an order-sorted specifications there exist
additional, automatically generated operators which result from the
translation into a many-sorted specification:
For every subsort relation s $<$ s' there will be an injective operator
with domain s und codomain s', called \verb|$inj-|s'\verb|-|s. If the domain can be
determined from the context, \verb|$inj-|s'\verb|-|s is abbreviated by s'.
These additional operators are also shown by the \comRef{sig}-command.\bigskip

\begin{command}[\comName{show}]
shows the sets of equations, rules and nonoperational equations of the
current specification in order-sorted form.
(Usually there exists more than one many-sorted representation of
an order-sorted axiom.)

Rules \condRule{C}{\rewRule{l}{r}} which are marked by an asterix
\kw{*} have an associated auxiliary rule of form
\condRule{C}{\rewRule{l+X}{r+X}}
where $+$ is the AC-operator on top of $l$ and $X$ is a new
variable of appropriate sort.
Auxiliary rules are automatically generated when needed during
completion modulo AC.
\end{command}

\begin{command}[\comName{showms}]
shows the sets of equations, rules and nonoperational equations of the
current specification in many-sorted form.
\end{command}

\subsection{Inspecting the Termination Ordering}
\label{InspecTermination}

\begin{command}[\comName{order}]
indicates the current termination ordering and asks the user whether he wants to
change it.
\end{command}

\begin{command}[\comName{operators}]
displays all precedences and stati in \kw{kns} or \kw{neqkns} or
all polynomial interpretations in \kw{poly}\nt{N} respectively.
\end{command}

\begin{command}[\comName{interpretation}]
displays all operator interpretations, provided \kw{poly}\nt{N} is the chosen termination
ordering and asks the user if he wants to change any. {\em If so all rules will be turned
back into equations.}
\end{command}

\subsection{Checking Preregularity and Regularity}

To ensure that the set of order-sorted equations of the specification and
the set of rewrite rules produced by CEC describe the same equational
theory, the signature must be {\em preregular} (\refArrow \cite{SNGM87}).
If in addition the signature is {\em regular} the term algebra is an
initial algebra in the semantics of \cite{GM87} (and \cite{SNGM87}).

\noindent
There are commands which check preregularity and regularity:\medskip

\begin{command}[\comName{preregular}]
succeeds if the current (order-sorted) signature is preregular,
and fails otherwise.\\
The preregularity condition is the regularity of
\cite{SNGM87}:
A signature is preregular, iff for every function symbol
$f$ and every string $w$ of sorts the set
$$   \{ t \mid \mbox{\ there is a declaration\ } f : w' \rightarrow t
\mbox{\ such that\ } w \leq w' \}
$$
is either empty or has a minimal element.
\end{command}

\begin{command}[\comName{regular}]
succeeds if the current (order-sorted) signature is regular,
and fails otherwise.
The regularity condition is the one of \cite{GM87}:
A signature is regular, iff for every function symbol
$f$ and every string $w$ of sorts the set
$$
   \{ (w',t) \mid \mbox{\ there is a declaration\ } f : w' \rightarrow t
      \mbox{\ such that\ } w \leq w' \}
$$
is either empty or has a minimal element.
\end{command}

\subsection{The UNDO Mechanism}

\begin{command}[\comName{undo}]
can be entered at the system's top level to reset the system to the state
before the last command that has caused a state change, if there was
any. \comRef{undo} can be used repeatedly to undo several steps of state changes.
It also undoes \comRef{undoUndo}-calls. At the moment, there is no way to backtrack
from single decisions that have been taken while running the completion
process.
\end{command}

\begin{command}[\comName{undoUndo}]
allows to undo the last \comRef{undo}-command at the system's top level. Repeated use of
this command undoes sequences of \comRef{undo}-commands. Chains of undo-calls begin at
the last user interaction different from an \comRef{undo} or \comRef{undoUndo}.
\end{command}


\section{Conclusion}\label{sec:conclusion}

\Figure[b!](topskip=0pt, botskip=0pt, midskip=0pt){figures/python/comp_lowerror.pdf}{
  The decoding rate $d$ for the low-error regime of phenomenological noise for the MWPM, UFPG and bvUF decoders. The UFPG decoding rates are improved from the UF variants and are very similar to MWPM. All $d$ are obtained by Monte Carlo simulations with a minimum of $100.000$ samples. The x-axis scales linearly with $N = L^3$.\label{comp_lowerror}}

\Figure[b!](topskip=0pt, botskip=0pt, midskip=0pt){figures/python/comp_lowerror_time.pdf}{
  The mean computation time of the UFPG, bvUF, and MWPM decoders in the low error regime for phenomenological noise for $p_X = \{0.5\%, 1.2\%, 2\%\}$ of the same simulation as in \Cref{comp_lowerror}. In this regime, the UFPG computation times are very comparable to the bvUF decoder. The x-axis scales linearly with $N = L^3$. \label{comp_lowerror_time}}

\Figure[t](topskip=0pt, botskip=0pt, midskip=0pt){figures/python/threshold_comparison.pdf}{
  Direct comparison of the performance of various decoders covered in this paper. The data of the original Union-Find (UF) decoder is taken from its publication \cite{delfosse2017almost}. Using the same range of lattice sizes and error rates, we simulate and plot the performance of \emph{(1)} our implementation of the Union-Find decoder with Weighted Growth applied via bucket sort and acyclic vertex-trees maintained during growth, the bvUF decoder, \emph{(2)} the Union-Find Partitioned-Growth decoder (UFPG), and  \emph{(3)} the Minimum-Weight Perfect Matching (MWPM) decoder. The UFPG decoder improves upon the Union-Find decoder and is very similar to the performance of the MWPM decoder. \label{thres_comp}}

In this paper, we have introduced a modification of the Union-Find (UF) decoder \cite{delfosse2017almost} that selectively grows regions of clusters based on the concept of a potential matching weight. The modified decoder, dubbed the Union-Find Partitioned-Growth (UFPG) decoder, relies on an additional data structure to facilitate the calculation of the potential matching weight. We have proved analytically that the UFPG decoder has a worst-case time complexity of $\m{O}(n\log{n})$.

The Union-Find Partitioned-Growth decoder proposed here, similarly to the original Union-Find, applies to any surface code of any genus, with or without boundary, and to color codes \cite{delfosse2017almost}. For simplicity, we have focused on the standard implementation of the surface code without boundary and leave additional numerical evaluation for future work.

Through Monte Carlo simulations on various decoder types, we have found that the UFPG decoder improves upon the performance of the UF decoder for all tested physical error rates and system sizes. Unfortunately, there is no fixed error threshold due to the Parity Inversion effect, which affects the performance at larger lattice sizes. Nevertheless, the UFPG decoder manages to occupy a region in $(p_X, d)$ space previously reserved to the Minimum Weight Perfect Matching (MWPM) decoder. For the low-error regime, the UFPG combines the advantages of the MWPM decoder's high decoding rates and the UF decoder's low computation time. Future work should focus on finding a way around the Parity Inversion effect and testing the decoder for other error types, such as erasure errors.

Recent work that includes the Union-Find decoder focuses on bringing the decoder algorithm to the hardware level. Most notably, a scalable decoder micro-architecture has been proposed with a fully pipelined hardware implementation \cite{das2020scalable}. Related work has shown that a reduction in bandwidth is possible provided qubits with a low physical error rate \cite{delfosse2020hierarchical}. Furthermore, another variant of the decoder, dubbed the \emph{Weighted Union-Find} decoder, not to be confused with \emph{Weighted Growth}, promises to increase the code threshold under circuit-level noise \cite{huang2020fault}. This application relies on adopting the decoder to a \emph{weighted} graph. Every edge $e\in\m{E}$ may now have a different length value, and edges are not limited to the growth of half-edges per growth iteration. We believe that the Union-Find Partitioned-Growth decoder and the Weighted Union-Find decoder are compatible. In the combined decoder, boundary edges in every node are grown with respect to their weights in the weighted graph.

The Union-Find decoder manages to decode fast and scale almost-linearly with the input system size. However, these speed-ups come at the cost of a decreased decoding performance. With the Union-Find Partitioned-Growth decoder, we manage to find a middle ground between the two objectives; high decoding performance that runs in worst-case quasi-linear time. For these reasons, it may be a great candidate for physical applications in the near future.


\section{Introduction}

Today's discussion is about Spline-based CNN.

\section{Literature}

	\begin{itemize}
		\item ~\cite{SplineCNN}
		\item ~\cite{GeometricDL}
	\end{itemize}

\section{Questions}

\begin{itemize}
\item What is $\mathcal{V}$ for graphs and discrete manifolds
    \item What is $\mathcal{E}$ for graphs and discrete manifolds
    \item What is $\mathcal{U}$ for graphs and discrete manifolds
    \item What is local support property for splines?
    \item How spline-based convolution operator is related to the traditional convolutional layer?
\end{itemize}


\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{geometry}
\usepackage{enumerate}
\usepackage{natbib}
\usepackage{float}%稳定图片位置
\usepackage{graphicx}%画图
\usepackage[english]{babel}
\usepackage{a4wide}
\usepackage{indentfirst}%缩进
\usepackage{enumerate}%加序号
\usepackage{multirow}%合并行
\title{\large UM-SJTU JOINT INSTITUTE\\DISCRETE MATHEMATICS\\(VE203)\\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\ \\\
ASSIGNMENT 7\\\ \\\ \\\ \\\ \\\ \\\ }
\author{Name: Pan Chongdan\\ID: 516370910121}
\date{Date: \today}

\begin{document}
\maketitle
\newpage
\section{Q1}
Assume A only contains finite $n$ prime numbers such as $p(1)=3,p(2)=7\cdots p(n)$. Then assume $Q=4\cdot p(1)\cdot p(2)\cdots p(n)+3\in A$. It's clear that $Q$ is odd and its divisor can be $4k+1$ because $(4k_1+1)\cdot(4k_2+1)=4(4k_1k_2+k_1+k_2)+1\notin A$ So the only divisor of $Q$ is 1 and itself, which means $Q$ is another prime, so A contains infinity primes.
\section{Q2}
Assume $g=gcd(c,m),m=xg,c=yg\Rightarrow\frac{m}{g}=x$
\\$ac\equiv bc\mod m\Rightarrow ayg=byg+kxg\Rightarrow a\equiv b+\frac{k}{y}x$
\\$a-b\in\mathbb{Z}\Rightarrow\frac{kx}{y}\in\mathbb{Z}$
\\If $\frac{k}{y}\in\mathbb{Z}\Rightarrow a\equiv b\mod x$, else $\frac{x}{y}\in\mathbb{Z}\Rightarrow g\neq gcd(c,m)$
\\$\therefore a\equiv b\mod\frac{m}{gcd(c,m)}$
\section{Q3}
We can solve the equation by solve
$$75=36x+1309y$$
$$1309=36\cdot36+13$$
$$36=2\cdot13+10$$
$$13=10+3$$
$$10=3\cdot3+1$$
$$1=-11\cdot1309+400\cdot36$$
$$75=-825\cdot139+30000\cdot36$$
$$\therefore x=30000$$
\section{Q4}
$$2x\equiv4\mod5\Rightarrow6x\equiv12\mod15$$
$$3x\equiv5\mod7\Rightarrow6x\equiv10\mod14$$
$$\therefore6x\equiv192\mod210\Rightarrow 7x\equiv224\mod245$$
$$\because 7x\equiv2\mod13\Rightarrow 7x\equiv1939\mod3185$$
$$\therefore x\equiv 277\mod455$$
\section{Q5}
$$x\equiv5\mod6\wedge x\equiv8\mod15\Rightarrow x\equiv23\mod30$$
$$\because x\equiv3\mod10\Rightarrow x\equiv23\mod30$$
$$\therefore x=23\mod30$$
\section{Q6}
$$x\equiv5\mod 5\wedge x\equiv3\mod7\Rightarrow x\equiv10\mod35$$
$$x\equiv8\mod 11\wedge x\equiv2\mod17\Rightarrow x\equiv19\mod187$$
$$x\equiv1515\mod 6545$$
\section{Q7}
Assume $f=n\log_2(n),g=\log_2(n),f$ is $O(g)\Rightarrow |n\log_2(n)|\leq C|\log_2(n)|$
\\if $n\neq 1\Rightarrow |n|\leq C\Rightarrow C$ doesn't exist since $n$ can be any number.
\section{Q8}
They're all order $\log_2{n}$, it's clear that $|\log_2{n}|\leq|\log_2{n}|$
$$|\log_{10}{n}|=|\frac{\log_2{n}}{\log_{2}{10}}|\leq|\log_2{n}|$$
$$|\log_2n|=|\frac{\log_{10}n}{\log_{10}2}|\leq4|\log_{10}n|$$
\\$\therefore \log_{10}n$ is order $\log_2n$, similarly:
$$|\ln{n}|=|\frac{\log_2{n}}{\log_2{e}}|\leq|\log_2{n}|$$
$$|\log_2n|=|\frac{\ln n}{\ln2}|\leq2|\ln n|$$
\\$\therefore$ they have the same order $\log_2{n}$
\section{Q9}
\begin{enumerate}[(i)]
\item
$$\frac{1}{n}=\int_{n-1}^n\frac{1}{n}\mathrm{d}x\Rightarrow\frac{1}{n}<\int_{n-1}^n\frac{1}{x}\mathrm{d}x\Rightarrow\sum_{j=2}^n\frac{1}{j}<\int_{2-1}^2\frac{1}{x}\mathrm{d}x+\cdots\int_{n-1}^n\frac{1}{x}\mathrm{d}x=\int_1^n\frac{1}{x}\mathrm{d}x$$
\item
$$H(n)=\frac{1}{n}+\frac{1}{n-1}\cdots+\frac{1}{1}=1+\sum_{j=2}^n\frac{1}{j}<1+\int_1^n\frac{1}{x}\mathrm{d}x=1+\ln(n)$$
$$\therefore\lim_{n\to\infty}|\frac{H(n)}{\ln(n)}|<\lim_{n\to\infty}|\frac{1}{\ln(n)}+1|=1$$
$$\frac{1}{n}=\int_n^{n+1}\frac{1}{n}\mathrm{d}x\Rightarrow\frac{1}{n}>\int_n^{n+1}\frac{1}{x}\mathrm{d}x\Rightarrow H(n)>\int_1^n\frac{1}{x}\mathrm{d}x=\ln(n)\Rightarrow\lim_{n\to\infty}|\frac{H(n)}{\ln(n)}|>1$$
$$\therefore\lim_{n\to\infty}|\frac{H(n)}{\ln(n)}|=1$$
$\therefore H(n)$ is $O(\ln(n))$
\end{enumerate}
\section{Q10}
$$\lfloor x^3-4\rfloor=x^3-y-4(0\leq y<1)$$
$$\lim_{x\to\infty}\frac{\lfloor x^3-4\rfloor}{|x^3|}=\lim_{x\to\infty}1+|\frac{y+4}{x^3}|=1(0\leq y+4<5)$$
$\therefore\lfloor x^3-4\rfloor$ is $O(x^3)$
$$\lim_{x\to\infty}\frac{|x^3|}{\lfloor x^3-4\rfloor}=\lim_{x\to\infty}=|\frac{x^3}{x^3-y-4}|=|1+\frac{y+4}{x^3-y-4}|=|1|$$
$\therefore\lfloor x^3-4\rfloor$ is order $x^3$
\section{Q11}
$$\lim_{n\to\infty}\frac{|n^{n-k}|}{|n^n|}=\lim_{n\to\infty}\frac{1}{|n^k|}=0$$
$\therefore n^{n-k}$ is $O(n^n),$ if $n^n$ is $O(n^{n-k})$ then there exists $C$ such that $\forall n,|n^n|\leq C|n^{n-k}|$
$$\therefore \forall n\in\mathrm{dom},k>1,C\geq|n^k|$$
$\therefore$ if the two functions' domain has both upper bound $a$ and lower bound $b$ than $C\geq\max(|a^k|,|b^k|)$, otherwise, such as the domain is $\mathbb{R}$ or $\mathbb{N}$ they don't have the same order.
\end{document}