\section{Sequences, sequences and sequences}

Every Riordan array $\mathcal{R}$, as we've seen in
\autoref{sec:back:to:the:basics:sequences}, has a particular sequence
$\lbrace a_i\rbrace_{i\in\mathbb{N}}$,
called $A$-sequence, such that uniquely characterizes it (to be precise another sequence
$\lbrace z_i\rbrace_{i\in\mathbb{N}}$, called $Z$-sequence, is needed
to fulfill the very first column, together with root element $d_{00}$),
capturing the way every element $d_{n+1,k+1}$ can be written as a linear combination
of elements lying on the previous row, formally:
\begin{displaymath}
    d_{n+1,k+1} = a_{0}d_{n,k} +a_{1}d_{n,k+1} +a_{2}d_{n,k+2} +
        \ldots + a_{j}d_{n,k+j}
\end{displaymath}
where $k+j = n$. In this section we would like to offer a generalization
of this \emph{combinatorial device}, providing a machinery to build sequences
that combine coefficients, possibly lying on arbitrary rows, as desired.
Finally, a connection with $A$-matrix concept is explored, leaving an open
question.

What follows doesn't use the $h$-characterization concept directly,
we put it here because a \emph{column oriented}
approach, as used for derivation of $h$-characterizations, is used as well.
For the sake of simplicity,
however, we start from an array $\mathcal{R}(d(t),h(t))$ and its
$h$-characterization $\mathcal{R}_{h(t)}(g(h(t)), h(t))$, for some function $g$.

\subsection{Localizing $A$-sequences}

Consider the following question: there exists a sequence
$\lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}}$ of coefficients
such that the generic element $d_{n+1,k+1}\in\mathcal{R}$ can be written
as a linear combination of \emph{all} other elements $d_{n,j}$
lying on the previous row, namely for all $j\in\lbrace0,1,2,\ldots,n\rbrace$?
Later we ask a more general question, for now tackle the current one.

The previous statement can be written in a compact way, or \emph{column-wise}, as:
\begin{displaymath}
    g(h(t))h(t)^k = \sum_{i\geq0}{\gamma_i\,t\,g(h(t)) h(t)^i}\\
\end{displaymath}
To see why, recall a generic column
$k$ has generating function $g(h(t))h(t)^k$ and imagine that series written vertically,
with increasing degree of $t$ from top to bottom.
The required constraint on coefficient of $t^n$, namely $d_{nk}$,
to be a linear combination of elements lying on the previous row
can be satisfied if we \emph{shift downward} every column,
namely multiplying each one by $t$, and combining them using coefficients
$\lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}}$.
We have learnt this trick from \citeauthor{shapiro:1991}, in \cite{shapiro:1991}.

Simplification of $g(h(t))$ shows that using the factored representation or
the natural one doesn't make any difference, therefore:
\begin{displaymath}
    h(t)^k = t \sum_{i\geq 0}{\gamma_i\,h(t)^i} = t \Gamma(h(t))
\end{displaymath}
where function $\Gamma$ is a \ac{fps} over sequence
$\lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}}$, which we're searching for.
Doing a change of variable to abstract over $h(t)$, its possible to
\marginpar{$\hat{h}(y)^{\alpha}$ acts as a ruler which,
    if an element $d_{nk}$ is combined,
    scrolls to row $n-\alpha$}
structure the basic for a generic schema (or \emph{device} if you please):
\begin{equation}
    \left.\left[y^{k} = \hat{h}(y)\,\Gamma(y) \right| y = h(t) \right]
    \label{eq:localizing:A:sequence}
\end{equation}

Before going on, let the device consumes some known arrays. Take
array $\mathcal{C}$, so $\hat{h}_{\mathcal{C}}(y) = y-y^2$, hence:
\begin{displaymath}
    \left.\left[\frac{y^{k-1}}{1-y} =  \Gamma(y) \right| y = h(t) \right]\\
\end{displaymath}
so sequence $\lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}}$ satisfies:
\begin{displaymath}
    \lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}} =
        \left(\underbrace{\gamma_{0}=0,\ldots,\gamma_{k-2}=0}_{k-1 \text{ zeros}},
            \underbrace{\gamma_{k-1}=1, \ldots}_{\text{infinitely many ones}} \right)
\end{displaymath}
so $d_{nk}\in\mathcal{C}$ is the combination of \emph{all} coefficients
lying on previous row $n-1$ according to $\lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}}$,
therefore $d_{nk}=\sum_{i=k-1}^{n-1}{d_{n-1,i}}$.
\marginpar{exactly as $A_{\mathcal{C}}(t)=\frac{1}{1-t}$ requires}

Motzkin's turn,
$\hat{h}_{\mathcal{M}}(y) = \frac{y}{1+y+y^2}$, hence:
\begin{displaymath}
        \left.\left[y^{k-1}+y^{k}+y^{k+1}=\Gamma(y)\right| y = h(t) \right]
\end{displaymath}
so sequence $\lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}}$ satisfies:
\begin{displaymath}
    \lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}} =
        \left(\underbrace{\gamma_{0}=0,\ldots,\gamma_{k-2}=0}_{k-1 \text{ zeros}},
            1,1,1,
            \underbrace{\gamma_{k+2}=0, \ldots}_{\text{infinitely many zeros}} \right)
\end{displaymath}
\marginpar{exactly as $A_{\mathcal{M}}(t)=1+t+t^{2}$ requires}
so $d_{nk}\in\mathcal{M}$ is the combination of \emph{all} coefficients
lying on previous row $n-1$ according $\lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}}$,
therefore $d_{nk}=d_{n-1,k-1}+d_{n-1,k}+d_{n-1,k+1}$.
\\\\
\marginpar{getting $A$-sequence back}
What we've done is nothing more nor less than writing $A$-sequences
in a more generic format, putting evidence on the \emph{local} meaning
of the combination: it is explicitly written the dependency of
elements belonging to a column $k$. On the other hand, natural $A$-sequences
are stated with a fixed start index in mind, namely $k-1$ if combining
for elements in a column $k$.

\marginpar{$y^{\beta}$ acts as a second ruler too, which scrolls
    to column $\beta$ directly. Rulers $y^{k-1}$ and $\hat{h}(y)$
    scroll to column $k-1$ and to row $n-1$ respectively, after
    combination starts as $\Gamma$ says\ldots}
It is possible to get the natural $A$-sequence back by requiring that
combination of elements (denoted by coefficients of \ac{fps} $\Gamma$)
lying on the previous row (denoted by $\hat{h}(y)$)
starts at index $k-1$ (denoted by $y^{k-1}$), formally:
\begin{displaymath}
    \left[y^{k} = y^{k-1}\,\hat{h}(y)\,\Gamma(y) \big| y = h(t) \right] =
    \left[y = \hat{h}(y)\,\Gamma(y) \big| y = h(t) \right]
\end{displaymath}
since $h(t) = t\,A(h(t))$, then \ac{fps}
$\Gamma$ and $A$ are defined over the same sequence, the $A$-sequence, as desired.
\\\\
\marginpar{The following can be skipped on a first reading}
Here there are a couple of applications of concepts described in previous paragraphs.

What if we ask: find a sequence $\lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}}$
such that an element $d_{nk}\in\mathcal{C}$ combines elements lying on a
row $3$ lines above, starting from column index $2$,
namely $d_{n-3,k}$ for all $k\in\lbrace 2,\ldots,n-3\rbrace$.
Set the device:
\begin{displaymath}
    \left[y^{k} = y^{2}\,\hat{h}(y)^3\,\Gamma(y) \big| y = h(t) \right] =
        \left.\left[\frac{y^{k-5}}{(1-y)^3} = \Gamma(y) \right| y = h(t) \right]
\end{displaymath}

Checking what we've obtained, assume you want to find coefficient $d_{7,5}$,
 so expand function $\Gamma$ with $k=5$:
\begin{displaymath}
    \left.\left[\Gamma(y)=1 + 3y + 6y^2 + 10y^3 + 15y^4 + \mathcal{O}(y^5)
        \big| y = h(t) \right]\right|_{k=5}
\end{displaymath}
therefore $d_{7,5}=d_{4,2} + 3\,d_{4,3} + 6\,d_{4,4}$,
instantiating $27 = 9 + 3\cdot4 + 6\cdot1$, which holds.
Just another element, say $d_{9,7}$, so expand function $\Gamma$ with $k=7$:
\marginpar{varing $k$ shifts $\lbrace \gamma_{i}\rbrace_{i\in\mathbb{N}}$ only.
    In \autoref{par:generalized:A:sequence:Delannoy:example}
    we will get a new sequence for each $k$}
\begin{displaymath}
    \left.\left[\Gamma(y)=y^2 + 3y^3 + 6y^4 + 10y^5 +  \mathcal{O}(y^6)
        \big| y = h(t) \right]\right|_{k=7}
\end{displaymath}
therefore $d_{9,7}=d_{6,4} + 3\,d_{6,5} + 6\,d_{6,6}$,
instantiating $44 = 20 + 3\cdot6 + 6\cdot1$, which holds.
It's interesting to observe the following fact: while a natural $A$-sequence
says how to combine starting always from the previous column index. With
this generalization we got the same coefficients for combining as $A$-sequence
states, augmenting with the column index from where the combination should start.

The previous two checks shows exactly this aspect: for column index $k=5$
combination starts at column index $2$, while for column index $k=7$ combination
starts at column index $4$.
\\\\
One last application, before the interlude:
find a sequence $\lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}}$ such that
an element $d_{nk}\in\mathcal{M}$ combines \emph{all} elements lying on
the next row, namely $d_{n+1,k}$ for all $k\in\lbrace0,\ldots,n+1\rbrace$.
The first step is always setting the device:
\begin{displaymath}
    \left[y^{k} = \hat{h}(y)^{-1}\,\Gamma(y) \big| y = h(t) \right]=
        \left[ \frac{y^{k + 1}}{y^2 + y + 1} = \Gamma(y) \big| y = h(t) \right]
\end{displaymath}
in order to find $d_{6,3}$,  expand function $\Gamma$ with $k=3$:
\begin{displaymath}
    \left.\left[\Gamma(y)=y^4 -y^5 + y^7 -y^8 +y^{10} + \mathcal{O}(y^{11})
        \big| y = h(t) \right]\right|_{k=3}
\end{displaymath}
therefore $d_{6,3}=d_{7,4} - d_{7,5} + d_{7,7}$, instantiating $44 = 70 -27 +1$,
which holds. Just another element, say $d_{8,1}$, so expand function
$\Gamma$ with $k=1$:
\begin{displaymath}
    \left.\left[\Gamma(y)=y^2 -y^3 + y^5 -y^6 + y^8 -y^9 + y^{11} +
        \mathcal{O}(y^{12}) \big| y = h(t) \right]\right|_{k=1}
\end{displaymath}

\marginpar{what about $d_{n0}\in\mathcal{M}$?
    it should provide a combinatorial identity for the $n$th
    Motzkin number\ldots}
therefore $d_{8,1}=d_{9,2} - d_{9,3} + d_{9,5}- d_{9,6}+ d_{9,8}- d_{9,9}$,
instantiating $512 = 1422 -1140 +369 -147 +9 -1$, which holds.
\iffalse
\\\\
As a final remark, under the insights of two solved exercises, is that a
sequence found using this approach, knows which elements to combine and which
ones to discard, we're required to supply the set of available elements only.
\fi

\subsection{Interlude: let's generalize}
\label{subsec:sequences:interluce:generalization}

Previous applications shows a pattern that can be pointed out looking at
the generic device for a Riordan array $\mathcal{R}$ where
function $h$ is its second component and function $\hat{h}$
is its compositional inverse:
\begin{displaymath}
    \left[y^{k} = \hat{h}(y) \Gamma(y) \big| y = h(t) \right]
\end{displaymath}
there's \emph{an equation} on the left hand side of the variable substitution block,
where function $\Gamma$ is the unknown. In this format,
a constraint is stated: let $d_{nk}\in\mathcal{R}$ be a generic element,
then a \emph{localized} sequence
$\lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}}$ respect to column $k$ exists, which
combines all elements lying on the previous row $n-1$.

Since we're dealing with an equation, we can augment it as desired in order to
constrain over additional facts. For instance, consider the following question:
find a sequence $\lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}}$ such that
an element $d_{nk}\in\mathcal{R}$ combines \emph{all} elements lying on
\emph{some} row $n-\alpha$, with the additional property to add the combination of
elements, defined by a \emph{given} sequence $\lbrace \theta_{i} \rbrace_{i\in\mathbb{N}}$,
lying on \emph{some different} row $n-\beta$. Formally, $\alpha,\beta\in\mathbb{Z}$
and $\alpha \not=\beta$, we would like to express $d_{nk}$ as:
\begin{displaymath}
    d_{nk} = \sum_{i=0}^{n-\alpha}{\gamma_{i}\,d_{n-\alpha,i}} +
        \sum_{i=0}^{n-\beta}{\theta_{i}\,d_{n-\beta,i}}
\end{displaymath}
so set the device as usual:
\begin{displaymath}
    \left[y^{k} = \hat{h}(y)^{\alpha} \Gamma(y) + \hat{h}(y)^{\beta} \Theta(y) \big| y = h(t) \right]
\end{displaymath}
Nonetheless its generality, its not the best one: to be truly general,
we should introduce two new parameters $c_\mu$ and $c_\nu$, which allow
to fix the column index from where the combinations denoted by functions
$\Gamma$ and $\Theta$ start, respectively. Here is the most general device:
\marginpar{most general device}
\begin{displaymath}
    \left[y^{k} = y^{c_\mu}\hat{h}(y)^{\alpha} \Gamma(y) +
        y^{c_\nu}\hat{h}(y)^{\beta} \Theta(y) \big| y = h(t) \right]
\end{displaymath}
\\
\paragraph{An example about $\mathcal{D}$}{
    \label{par:generalized:A:sequence:Delannoy:example}
    \marginpar{an example about $\mathcal{D}$}
    Try to make the generalization at work:
    find a sequence $\lbrace \gamma_{i} \rbrace_{i\in\mathbb{N}}$ such that
    an element $d_{nk}\in\mathcal{D}$, in the Delannoy array,
    combines \emph{all} elements lying on
    the next row, namely $n+1$, in addition to the
    combination of elements lying two row above, namely $n-2$,
    defined as their sum, simply.

    In order to set the device, we need $\hat{h}_{\mathcal{D}}$:
    \begin{displaymath}
        \hat{h}_{\mathcal{D}}(y) = \frac{\sqrt{1+6y+y^2}-y-1}{2}
    \end{displaymath}
    and build function $\Theta$ from the additional requirement:
    \begin{displaymath}
        \Theta(y) = \frac{1}{1-y}
    \end{displaymath}
    now we're ready:
    \begin{lenghtydisplaymath}
    \begin{split}
        &\left.\left[y^{k} = \hat{h}_{\mathcal{D}}(y)^{-1} \Gamma(y) +
            \hat{h}_{\mathcal{D}}(y)^{2}\frac{1}{1-y} \right| y = h(t) \right]\\
        &=\left.\left[\frac{y^{3} + {\left(y^{2} - 1\right)} y^{k} + 6 \, y^{2} - {\left({\left(y - 1\right)} y^{k} + y^{2} + 3 \, y + 1\right)} \sqrt{y^{2} + 6 \, y + 1} + 6 \, y + 1}{2 \, {\left(1-y\right)}}=\Gamma(y) \right| y = h(t) \right]\\
    \end{split}
    \end{lenghtydisplaymath}
    in order to find $d_{8,1}$,  expand function $\Gamma$ with $k=1$:
    \begin{lenghtydisplaymath}
        \left.\left[\Gamma(y)=y^2 -3y^3 + 11y^4  -47y^5 + 211y^6 -987y^7 + 4747y^8
            -23335y^9 + \mathcal{O}(y^{10}) \big| y = h(t) \right]\right|_{k=1}
    \end{lenghtydisplaymath}
    therefore $d_{8,1}=d_{9,2} -3\,d_{9,3} +11\,d_{9,4}-47\,d_{9,5}
        +211\,d_{9,6} -987\,d_{9,7} +4747\,d_{9,8}-23335\,d_{9,9}+\epsilon$,
        where $\epsilon = d_{6,0}+d_{6,1}+d_{6,2}+d_{6,3}+d_{6,4}+d_{6,5}+d_{6,6} =
                2(d_{6,0}+d_{6,1}+d_{6,2})+d_{6,3} = 2(1 + 11 + 41) + 63 = 169$:
        instantiating $15 = 113 -3\cdot377 +11\cdot681 -47\cdot681 +211\cdot377
            -987\cdot113 +4747\cdot17 -23335 + \epsilon = -154 + 169$, which holds.

    It's interesting to observe that function $\Gamma$ above, an algebraic one,
    produces sequences that use different coefficients for different values of $k$,
    and we observe a curious pattern for increasing values of
    $k\in\lbrace 0,\ldots,10 \rbrace$:
    \begin{lenghtydisplaymath}
        \begin{split}
            &\left.\left[\Gamma(y)=
            y -2 y^{2} + 5 y^{3} + -17 y^{4} + 65 y^{5} -273 y^{6} + 1213 y^{7} -5617 y^{8} + \mathcal{O}\left(y^{9}\right)
                \big| y = h(t) \right]\right|_{k=0}\\
            &\left.\left[\Gamma(y)=
            y^{2} -3 y^{3} + 11 y^{4} -47 y^{5} + 211 y^{6} -987 y^{7} + 4747 y^{8} + \mathcal{O}\left(y^{9}\right)
                \big| y = h(t) \right]\right|_{k=1}\\
            &\left.\left[\Gamma(y)=
            3 y^{4} -19 y^{5} + 99 y^{6} -503 y^{7} + 2547 y^{8} -12971 y^{9} + \mathcal{O}\left(y^{10}\right)
                \big| y = h(t) \right]\right|_{k=2}\\
            &\left.\left[\Gamma(y)=
            - y^{3} + 6 y^{4} -27 y^{5} + 127 y^{6} -615 y^{7} + 3031 y^{8} -15171 y^{9} + \mathcal{O}\left(y^{10}\right)
                \big| y = h(t) \right]\right|_{k=3}\\
            &\left.\left[\Gamma(y)=
            - y^{3} + 5 y^{4} -24 y^{5} + 119 y^{6} -587 y^{7} + 2919 y^{8} -14687 y^{9} + \mathcal{O}\left(y^{10}\right)
                \big| y = h(t) \right]\right|_{k=4}\\
            &\left.\left[\Gamma(y)=
            - y^{3} + 5 y^{4} -25 y^{5} + 122 y^{6} -595 y^{7} + 2947 y^{8} -14799 y^{9} + \mathcal{O}\left(y^{10}\right)
                \big| y = h(t) \right]\right|_{k=5}\\
            &\left.\left[\Gamma(y)=
            - y^{3} + 5 y^{4} -25 y^{5} + 121 y^{6} -592 y^{7} + 2939 y^{8} -14771 y^{9} + \mathcal{O}\left(y^{10}\right)
                \big| y = h(t) \right]\right|_{k=6}\\
            &\left.\left[\Gamma(y)=
            - y^{3} + 5 y^{4} -25 y^{5} + 121 y^{6} -593 y^{7} + 2942 y^{8} -14779 y^{9} + \mathcal{O}\left(y^{10}\right)
                \big| y = h(t) \right]\right|_{k=7}\\
            &\left.\left[\Gamma(y)=
            - y^{3} + 5 y^{4} -25 y^{5} + 121 y^{6} -593 y^{7} + 2941 y^{8} -14776 y^{9} + \mathcal{O}\left(y^{10}\right)
                \big| y = h(t) \right]\right|_{k=8}\\
            &\left.\left[\Gamma(y)=
            - y^{3} + 5 y^{4} -25 y^{5} + 121 y^{6} -593 y^{7} + 2941 y^{8} -14777 y^{9} + \mathcal{O}\left(y^{10}\right)
                \big| y = h(t) \right]\right|_{k=9}\\
            &\left.\left[\Gamma(y)=
            - y^{3} + 5 y^{4} -25 y^{5} + 121 y^{6} -593 y^{7} + 2941 y^{8} -14777 y^{9} + \mathcal{O}\left(y^{10}\right)
                \big| y = h(t) \right]\right|_{k=10}\\
        \end{split}
    \end{lenghtydisplaymath}

    Starting from index $k=3$, it seems that one more coefficient stabilizes
    in the expansion, one increment of $k$ at a time, pretty nice.
    To finish this section involving Delannoy triangle, we report its natural
    $A$-sequence, computed with $\left.\left[y^{k} = y^{k-1}
    \hat{h}_{\mathcal{D}}(y)\,\Gamma(y) \right| y = h(t) \right]$:

    \marginpar{$\mathcal{D}$'s $A$-sequence which, of course, doesn't
        depend on $k$: it's unique\ldots}
    \begin{lenghtydisplaymath}
        \left[\Gamma(y)=
        1 + 2 y -2\,y^{2} + 6 y^{3} -22\,y^{4} + 90 y^{5} -394\,y^{6} + 1806 y^{7}  + \mathcal{O}\left(y^{8}\right)
            \big| y = h(t) \right]\\
    \end{lenghtydisplaymath}
}

\subsection{$A$-matrix connection}

Is the previous device the most general one? Really is it?
We lie. In this section we enhance the last version to
find an interesting connection with
the $A$-matrix concept of a Riordan array $\mathcal{R}$,
introduced in \autoref{sec:back:to:the:basics:sequences}.
\\\\
Let $\lbrace\Omega_{i}\rbrace_{i\in\mathbb{N}}$ be a collection of formal
power series and assume we would like to \emph{not} localize them (a-l\`a natural
$A$-sequence) in order to combine elements lying on the previous row, on the previous
but one and so on \ldots hence, respect to an element $d_{nk}\in\mathcal{R}$,
set the following device:

\marginpar{since columns are infinite, so is this device}
\begin{displaymath}
    \left.\left[
            \begin{split}
                y^{k} &= y^{k-1}\hat{h}(y) \Omega_{0}(y) \\
                &+ y^{k-1}\hat{h}(y)^{2} \Omega_{1}(y) \\
                &+ y^{k-1}\hat{h}(y)^{3} \Omega_{2}(y) \\
                &+ \ldots\\
                &+ y^{k-1}\hat{h}(y)^{i+1} \Omega_{i}(y)\\
                &+ \ldots
            \end{split}
        \right| y = h(t) \right]
\end{displaymath}
a simplification rewrites:
\begin{displaymath}
    \left.\left[
        y = \hat{h}(y) \Omega_{0}(y) +
        \hat{h}(y)^{2} \Omega_{1}(y) + \hat{h}(y)^{3} \Omega_{2}(y) +
        \ldots +
        \hat{h}(y)^{i+1} \Omega_{i}(y) + \ldots
        \right| y = h(t) \right]
\end{displaymath}
Here are our thoughts, each in a dedicated subsection.

\subsubsection{Increasing generality}
It can be seen as an additional generalization of device introduced in
\autoref{subsec:sequences:interluce:generalization},
where some new functions are thrown in: it allows to augment the
combination including sets of coefficients lying on more rows,
each of them combined according to a function $\Omega_{j}$.

\marginpar{one equation in one unknown}
If the combination is augmented using a fixed number $r$
of functions $\Omega_{0},\ldots,\Omega_{r-1}$
and $r-1$ of them $\Omega_{i_{0}},\ldots,\Omega_{i_{r-2}}$
are \emph{explicitly defined}, then it is possible to find
the remaining one $\Omega_{i_{r-1}}$, because it is the same to solve a system
with one equation in one unknown.

% the following should be an attempt to find two rows in the
% `A-matrix' but it merely fails
%\subsubsection{Two characterizing functions}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Assume we allow that combinations starts from column index $0$,
%%so the very general device in this case has the following form:
%\begin{displaymath}
    %\left.\left[
        %y^{k} = \hat{h}(y) \Omega_{0}(y) + \hat{h}(y)^{2} \Omega_{1}(y)
            %\right| y = h(t) \right]
%\end{displaymath}
%Even if we don't define one of functions $\Omega_{0}$ or $\Omega_{1}$
%to find the other, it's possible to find \emph{both of them} by solving the system
%obtained letting $k\in\lbrace0,1\rbrace$,
%formally functions $\Omega_{0}$ and $\Omega_{1}$ satisfy both:
%\begin{displaymath}
    %\left.\left[
        %1 = \hat{h}(y) \Omega_{0}(y) + \hat{h}(y)^{2} \Omega_{1}(y)
            %\right| y = h(t) \right]
%\end{displaymath}
%and:
%\begin{displaymath}
    %\left.\left[
        %y = \hat{h}(y) \Omega_{0}(y) + \hat{h}(y)^{2} \Omega_{1}(y)
            %\right| y = h(t) \right]
%\end{displaymath}

\subsubsection{$A$-sequence $\hat{h}$-representation}

It provides a ``representation'' of \ac{fps} $A$, over a corresponding
$A$-sequence $\lbrace a_{i}\rbrace_{i\in\mathbb{N}}$, ``in base'' $\hat{h}$,
the compositional inverse of function $h$.  Recognizing $h(t)=tA(h(t))$ yield:
\begin{displaymath}
    \left.\left[
        A(y) =  \Omega_{0}(y) +
        \hat{h}(y)\,\Omega_{1}(y) + \hat{h}(y)^{2}\,\Omega_{2}(y) + \ldots +
        \hat{h}(y)^{i}\,\Omega_{i}(y) + \ldots
        \right| y = h(t) \right]
\end{displaymath}

This is quite interesting from the theoretical point of
view but it can also have a practical application
when functions $A$ and $\hat{h}$ are polynomials. If this is the case,
can apply the \emph{division theorem} among polynomial and
proceed to factor polynomial $A$ dividing it by polynomial $\hat{h}$,
repeatedly. For the sake of clarity, consider the following cases:

\begin{itemize}

    % Pascal's $A$-sequence
    \item let $\mathcal{P}$ be the Pascal array $\mathcal{P}$ and recall
        the following facts:

        \marginpar{apply it to $A_{\mathcal{P}}$}
        \begin{displaymath}
            \hat{h}_{\mathcal{P}}(y)=\frac{y}{1+y} \quad\quad A_{\mathcal{P}}(y)=1+y
        \end{displaymath}
        therefore, by \emph{division theorem},
        there exist functions $\Omega_{0}$ and $\Delta_{0}$ such that:
        \begin{displaymath}
            \left.\left[
                (1+y)^2 =  (1+y)\Omega_{0}(y) + y\,\Delta_{0}(y) \right| y = h_{\mathcal{P}}(t) \right]
        \end{displaymath}
        dividing $(1+y)^2$ by $y$ yield $\Delta_{0}(y)=2+y$ and $(1+y)\Omega_{0}(y)=1$,
        which defines function $\Omega_{0}$. We need to
        keep applying \emph{division theorem}, so there exist the following
        sequences of functions such that:

        %\vskip+20pt plus.5fill
        \marginpar{$\triangleq$ is the \emph{unify} operator}
        \begin{lenghtydisplaymath}
            \begin{split}
                & \left.\left[
                    \frac{\Delta_{0}(y)}{\hat{h}_{\mathcal{P}}(y)} =
                        \left(y+3, 2\right)\triangleq
                        \left(\Delta_{1}(y), (1+y)\Omega_{1}(y) \right)
                     \right| y = h_{\mathcal{P}}(t) \right]\\
                & \left.\left[
                    \frac{\Delta_{1}(y)}{\hat{h}_{\mathcal{P}}(y)} =
                        \left(y+4, 3\right)\triangleq
                        \left(\Delta_{2}(y), (1+y)\Omega_{2}(y) \right)
                     \right| y = h_{\mathcal{P}}(t) \right]\\
                & \left.\left[
                    \frac{\Delta_{2}(y)}{\hat{h}_{\mathcal{P}}(y)} =
                        \left(y+5, 4\right)\triangleq
                        \left(\Delta_{3}(y), (1+y)\Omega_{3}(y) \right)
                     \right| y = h_{\mathcal{P}}(t) \right]\\
                & \left.\left[
                    \frac{\Delta_{3}(y)}{\hat{h}_{\mathcal{P}}(y)} =
                        \left(y+6, 5 \right)\triangleq
                        \left(\Delta_{4}(y), (1+y)\Omega_{4}(y) \right)
                     \right| y = h_{\mathcal{P}}(t) \right]\\
                &\vdots
            \end{split}
        \end{lenghtydisplaymath}
        A pattern seems to emerge and can be captured with the
        following rule in order to define function $\Omega_{i}$:
        \begin{displaymath}
                \left.\left[
                    \Delta_{i-1}(y) \triangleq
                        q_{i-1}(y)\,\hat{h}_{\mathcal{P}}(y) + r_{i-1}
                        \rightarrow (1+y)\,\Omega_{i}(y)=r_{i-1}
                    \right| y = h_{\mathcal{P}}(t) \right]
        \end{displaymath}
        where each polynomial $q_{j}$ satisfies $q_{j}(0)\not=0$ and
        each $r_{j}\in\mathbb{N}$ is a remainder, with boundary initial
        condition $\Delta_{-1}(y)=0\,\hat{h}_{\mathcal{P}}(y)+1$.
        Therefore it is possible to state
        a closed formula for function $\Omega_{i}$:
        \begin{displaymath}
            \Omega_{i}(y)=\frac{1+i}{1+y}
        \end{displaymath}

        Putting it all together, the factorization of polynomial
        $A_{\mathcal{P}}$ respect to polynomial $\hat{h}_{\mathcal{P}}$ is:
        \begin{displaymath}
                \left.\left[
                    A_{\mathcal{P}}(y) = \sum_{i \geq0}{\left(\frac{1+i}{1+y}\right)
                        \hat{h}_{\mathcal{P}}(y)^{i}} \right| y = h_{\mathcal{P}}(t) \right]
        \end{displaymath}

    % Catalan's $A$-sequence
    \item for Catalan array $\mathcal{C}$ things are quite interesting,
        first of all recall the following facts:

        \marginpar{apply it to $A_{\mathcal{C}}$}
        \begin{displaymath}
            \hat{h}_{\mathcal{C}}(y)=y-y^2 \quad\quad
                A_{\mathcal{C}}(y)=\frac{1}{1-y}
        \end{displaymath}
        therefore, by \emph{division theorem},
        there exist functions $\Omega_{0}$ and $\Delta_{0}$ such that:
        \begin{displaymath}
            \left.\left[
                1 = (1-y)\Omega_{0}(y) + y(1-y)^{2}\,\Delta_{0}(y)
                    \right| y = h_{\mathcal{C}}(t) \right]
        \end{displaymath}
        \marginpar{congecture: is Catalan array's $A$-matrix \emph{unique}?
            Moreover: $\Omega_{k}=0$ for $k>0$?}
        dividing $1$ by $y(1-y)^2$ yield $\Delta_{0}(y)=0$
        and $(1-y)\Omega_{0}(y)=1$, this defines function $\Omega_{0}$.
        This means that ``polynomial'' $A_{\mathcal{C}}$ is already
        the factorization of itself, which is the same to say that
        there exists a \emph{unique} $A$-matrix for $\mathcal{C}$, pretty curious;

        \item for Motzkin array $\mathcal{M}$ things are quite interesting,
            first of all recall the following facts:
            \marginpar{apply it to $A_{\mathcal{M}}$}
            \begin{displaymath}
                \hat{h}_{\mathcal{M}}(y)=\frac{y}{1+y+y^2} \quad\quad
                    A_{\mathcal{M}}(y)=1+y+y^2
            \end{displaymath}
            therefore, by \emph{division theorem},
            there exist functions $\Omega_{0}$ and $\Delta_{0}$ such that:
            \begin{displaymath}
                \left.\left[
                    (1+y+y^2)^2 = (1+y+y^2)\Omega_{0}(y) + y\,\Delta_{0}(y)
                        \right| y = h_{\mathcal{M}}(t) \right]
            \end{displaymath}
            dividing $(1+y+y^2)^2$ by $y$ yield $\Delta_{0}(y)=2+3y+2y^2+y^3$
            and $(1+y+y^2)\Omega_{0}(y)=1$, this defines function $\Omega_{0}$,
            which expanded as fps equals:
            \begin{displaymath}
                \left.\left[
                    \Omega_{0}(y) = 1 -y +y^{3} -y^{4} + y^{6}
                        -y^{7} + y^{9} -y^{10}
                        + y^{12} + \mathcal{O}\left(y^{13}\right)
                        \right| y = h_{\mathcal{M}}(t) \right]
            \end{displaymath}
            We need to keep applying \emph{division theorem}, so there exist
            the following sequences of functions such that:
            \begin{lenghtydisplaymath}
                \begin{split}
                    & \left.\left[
                        \frac{\Delta_{0}(y)}{\hat{h}_{\mathcal{M}}(y)} =
                            \left(y^4 + 3y^3 + 6y^2 + 7y + 5, 2\right)\triangleq
                            \left(\Delta_{1}(y), (1+y+y^2)\Omega_{1}(y) \right)
                         \right| y = h_{\mathcal{M}}(t) \right]\\
                    & \left.\left[
                        \frac{\Delta_{1}(y)}{\hat{h}_{\mathcal{M}}(y)} =
                            \left(y^5 + 4y^4+10y^3+16y^2 + 18y + 12, 5\right)\triangleq
                            \left(\Delta_{2}(y), (1+y+y^2)\Omega_{2}(y) \right)
                         \right| y = h_{\mathcal{M}}(t) \right]\\
                    & \left.\left[
                        \frac{\Delta_{2}(y)}{\hat{h}_{\mathcal{M}}(y)} =
                            \left(y^6 + 5y^5 + 15y^4 + 30y^3 + 44y^2+46y+30,
                                12\right)\triangleq
                            \left(\Delta_{3}(y), (1+y+y^2)\Omega_{3}(y) \right)
                         \right| y = h_{\mathcal{M}}(t) \right]\\
                    & \left.\left[
                        \frac{\Delta_{3}(y)}{\hat{h}_{\mathcal{M}}(y)} =
                            \left(y^7+6y^6+21y^5+50y^4+89y^3+120y^2+120y+76, 30
                                \right)\triangleq
                            \left(\Delta_{4}(y), (1+y+y^2)\Omega_{4}(y) \right)
                         \right| y = h_{\mathcal{M}}(t) \right]\\
                    &\vdots
                \end{split}
            \end{lenghtydisplaymath}
            A pattern seems to emerge and can be captured with the
            following rule in order to defines function $\Omega_{i}$:
            \begin{displaymath}
                    \left.\left[
                        \Delta_{i-1}(y) \triangleq q_{i-1}(y)\,\hat{h}_{\mathcal{M}}(y)
                        + r_{i-1} \rightarrow (1+y+y^2)\,\Omega_{i}(y)=r_{i-1}
                         \right| y = h_{\mathcal{M}}(t) \right]
            \end{displaymath}
            where each polynomial $q_{j}$ satisfies $q_{j}(0)\not=0$ and
            each $r_{j}\in\mathbb{N}$ is a remainder, with boundary initial
            condition $\Delta_{-1}(y)=1$.

            \marginpar{something similar already occurs within $\mathcal{P}$}
            It is quite interesting that, as the case for array $\mathcal{P}$,
            the sequence $\lbrace r_{j} \rbrace_{j\in\mathbb{N}}$ of remainders
            is exactly the sequence of coefficients of the function defining
            the second column of array $\mathcal{M}$ shifted by \emph{one}
            position, namely function $d_{\mathcal{M}}$ times function
            $h_{\mathcal{M}}$.

            Putting it all together, the factorization of polynomial
            $A_{\mathcal{M}}$ respect to polynomial $\hat{h}_{\mathcal{M}}$ is:
            \begin{displaymath}
                    \left.\left[
                        A_{\mathcal{M}}(y) = \sum_{i \geq0}{
                            \left(\frac{[t^{1+i}]d_{\mathcal{M}}(t)h_{\mathcal{M}}(t)}
                                {1+y+y^2}\right)
                            \hat{h}_{\mathcal{M}}(y)^{i}}
                            \right| y = h_{\mathcal{M}}(t) \right]
            \end{displaymath}

        \item if terms are not in a polynomial ring, we've difficulty to show a
        factorization: for example Delannoy array $\mathcal{D}$ is affected by this difficulty.

    \end{itemize}

\subsubsection{$A$-matrix from another point of view}

We observe that functions in the collection
$\lbrace\Omega_{i}\rbrace_{i\in\mathbb{N}}$ are exactly the same as those
functions in the collection $\lbrace P_{i}\rbrace_{i\in\mathbb{N}}$ introduced
by Merlini et al., therefore we've expressed the $A$-matrix concept from a
different point of view.

\marginpar{a system difficult to solve}
A problem is still open: what if we would like to find all such functions? A reply
to this question seems interesting but we've no idea how to satisfy it.
The major difficulty arises if the device is seen as a system:
there's \emph{one} equation in possibly $k$ unknowns, with $k$ as desired,
so we haven't any idea about the shape of the remaining $k-1$ equations.

Have a little check about Pascal array $\mathcal{P}$ again:
let $d_{nk}\in\mathcal{P}$, from the point above we've, firstly,
$\Omega_{0}(y)=\frac{1}{1+y}$, which says to sum coefficients
lying on row $n-1$ using alternating signs; then add the doubled sum of
coefficients lying on row $n-2$ using alternating signs;
then add the tripled sum of elements lying on row $n-3$
using alternating signs; and so on \ldots, all respect to column index $k$.

\marginpar{combining\\$d_{7,4}\in\mathcal{P}$}
Element $d_{7,4}$,  is the combination
    $(d_{6,3}-d_{6,4}+d_{6,5}-d_{6,6})+
    2(d_{5,3}-d_{5,4}+d_{5,5}) + 3(d_{4,3}-d_{4,4}) + 4d_{4,4}$,
    instantiating $35 = (20-15+6-1)+2(10-5+1)+3(4-1)+4\cdot1$
     which holds.
%\deleted[remark=boring and tedious the combination for $d_{8,1}$]{
    %Element $d_{8,1}$,  is the combination
    %$d_{7,0}-d_{7,1}+d_{7,2}-d_{7,3}+d_{7,4}-d_{7,5}+d_{7,6}-d_{7,7}
        %+2d_{7,0}+d_{7,1}$, instantiating
        %$8 = 1-7+21-35+35-21+7-1+2\cdot1+6$ which holds.}

\marginpar{combining $d_{6,2}\in\mathcal{M}$}
On the other hand, let $d_{6,2}\in\mathcal{M}$ be the
combination $(d_{5,1}-d_{5,2}+d_{5,4}-d_{5,5})
    +2(d_{4,1}-d_{4,2}+d_{4,4})
    +5(d_{3,1}-d_{3,2})
    +12(d_{2,1} -d_{2,2})
    +30\,d_{1,1}$, instantiating:
    $69=(30-25+5-1)
    +2(12-9+1)
    +5(5-3)
    +12(2 -1)
    +30\cdot1$, which holds.


\chapter{Non-parametric statistic models(NParmStat)}


\documentclass[a4paper]{article}

\input{temp}

\begin{document}

\title{Quantum Mechanics}

\maketitle

\newpage

\tableofcontents

\newpage

\section{Wave Functions and Operators}
We introduce some of the mathematical structure of quantum mechanics (QM) by considering a particle in one dimension.

\subsection{Wave Function and States}
A classical point particle in one dimension has a position $x$ at each time. In QM a particle has a \emph{state} at each time given by a complex \emph{wave function} $\psi\left(x\right)$.

\begin{post}
A measurement of position gives a result $x$ with probability density $|\psi\left(x\right)|^2$, i.e.
\begin{equation*}
\begin{aligned}
|\psi\left(x\right)|^2 \delta x
\end{aligned}
\end{equation*}
will be the probability that particle is found between $x$ and $x+\delta x$, or
\begin{equation*}
\begin{aligned}
\int_a^b |\psi\left(x\right)|^2 dx
\end{aligned}
\end{equation*}
is the probability that the particle is found in the interval $a\leq x \leq b$.
This obviously requires
\begin{equation*}
\begin{aligned}
\int_{-\infty}^\infty |\psi\left(x\right)|^2 dx = 1
\end{aligned}
\end{equation*}
We say $\psi$ is \emph{normalised} if it satisfies this condition.
\end{post}

\begin{eg} (Gaussian wave function) Let
\begin{equation*}
\begin{aligned}
\psi\left(x\right) = C e^{-\frac{\left(x-x_0\right)^2}{2\alpha}}
\end{aligned}
\end{equation*}
For some real $\alpha > 0$.\\
If $\alpha$ is small, $|\psi|^2$ will be sharply peaked around $x=x_0$.\\
If $\alpha$ is large, $|\psi|^2$ is more spread out.

Since $\psi$ needs to be normalised,
\begin{equation*}
\begin{aligned}
\int_{-\infty}^\infty |\psi\left(x\right)|^2 dx &= |C|^2 \int_{-\infty}^\infty e^{-\frac{\left(x-x_0\right)^2}{\alpha}}dx\\
&= |C|^2 \left(2\pi\right)^{1/2}\\
&= 1
\end{aligned}
\end{equation*}
So $\psi$ is normalised if
\begin{equation*}
\begin{aligned}
C=\left(\frac{1}{2\pi}\right)^{1/4}
\end{aligned}
\end{equation*}
\end{eg}

It is convenient to deal more generally with \emph{normalisable} wave functions that are \emph{not} identically zero, and satisfy
\begin{equation*}
\begin{aligned}
\int_{-\infty}^\infty |\psi\left(x\right)|^2 dx < \infty
\end{aligned}
\end{equation*}
In fact, $\psi\left(x\right)$ and $\phi\left(x\right) = \lambda \psi\left(x\right)$ contain the same physical information for any complex $\lambda \neq 0$.

If $\psi\left(x\right)$ is normalisable, we can choose $\lambda$ to ensure $\psi\left(x\right)$ is normalised. Note also $\psi\left(x\right)$ and $e^{i\alpha} \psi\left(x\right)$ are physically equivalent for any real $\alpha$, and when $\psi$ is normalised,
\begin{equation*}
\begin{aligned}
|\psi\left(x\right)|^2 = |e^{i\alpha} \psi\left(x\right)|^2
\end{aligned}
\end{equation*}
i.e. they have the same probability distribution.

In general we will consider normalisable wave functions $\psi,\phi,\chi,...$ that are \emph{smooth} (differentiable any number of times) except at isolated points (see examples below). Also, $\psi,\psi',... \to 0$ as $|x| \to \infty$.

Given states $\psi_1\left(x\right)$ and $\psi_2\left(x\right)$ can form new state
\begin{equation*}
\begin{aligned}
\psi\left(x\right) = \psi_1\left(x\right) + \psi_2\left(x\right)
\end{aligned}
\end{equation*}
which is called superposition.

\begin{eg}
Take
\begin{equation*}
\begin{aligned}
\psi\left(x\right) = B\left(e^{-\frac{x^2}{2\alpha}} + e^{-\frac{\left(x-x_0\right)^2}{2\alpha}}\right)
\end{aligned}
\end{equation*}
i.e. the superposition of Gaussian wave function and itself at different positions.

By drawing the image of $|\psi\left(x\right)|^2$ we can get the probability distribution for single particle, with appropriate choice of $B$.
\end{eg}

\subsection{Operators and Observables}
A quantum state contains information about other physical quantities \emph{observables}, for example, momentum and energy, in addition to position. In QM, each observable is represented by an \emph{operator} acting on wave functions:\\
Position:
\begin{equation*}
\begin{aligned}
\hat{x} = x\\
\left(\hat{x}\psi\right)\left(x\right) = x\psi\left(x\right)
\end{aligned}
\end{equation*}
Momentum:
\begin{equation*}
\begin{aligned}
\hat{p} = -i\hbar \frac{d}{dx}\\
\left(\hat{p}\psi\right)\left(x\right) = -i\hbar \frac{d\psi}{dx} = -i\hbar \psi'\left(x\right)
\end{aligned}
\end{equation*}
Energy, or \emph{Hamiltonian}, for a particle of mass $m$ moving at potential $V\left(x\right)$:
\begin{equation*}
\begin{aligned}
H &= \frac{\hat{p}^2}{2m} + V\left(\hat{x}\right)\\
&= -\frac{\hbar^2}{2m} \frac{d^2}{dx^2} + V\left(x\right)
\end{aligned}
\end{equation*}

If an observable $Q$ is measured when the system is in a state $\psi$, we would like to know:\\
(i) what results are possible;\\
(ii) what is the probability for each result.

\subsubsection{Expectation values}
For any normalisable $\psi\left(x\right)$ and $\phi\left(x\right)$, define
\begin{equation*}
\begin{aligned}
\left(\psi,\phi\right) = \int_{-\infty}^\infty \psi\left(x\right)^* \phi\left(x\right) dx
\end{aligned}
\end{equation*}

For normalised $\psi\left(x\right)$, define the \emph{expectation value} of $Q$ (some operator) in this state to be
\begin{equation*}
\begin{aligned}
\left<Q\right>_\psi = \left(\psi,Q\psi\right) = \int_{-\infty}^\infty \psi^* Q\psi dx
\end{aligned}
\end{equation*}

Note for $Q=\hat{x}$,
\begin{equation*}
\begin{aligned}
\left<\hat{x}\right>_\psi = \left(\psi,\hat{x}\psi\right)=\int_{-\infty}^\infty x|\psi\left(x\right)|^2 dx
\end{aligned}
\end{equation*}
standard expression for mean or expectation of $x$, and for $Q=\hat{p}$,
\begin{equation*}
\begin{aligned}
\left<\hat{p}\right>_\psi = \left(\psi,\hat{p}\psi\right) = \int_{-\infty}^\infty -i\hbar \psi^* \psi' dx
\end{aligned}
\end{equation*}

\begin{post}
For any observable, $\left<Q\right>_\psi$ is the mean result of measuring $Q$ when the system is in state $\psi$.
\end{post}

Now consider $\phi$ and $\psi$ (normalised) with
\begin{equation*}
\begin{aligned}
\phi\left(x\right) = \psi\left(x\right) e^{ikx}
\end{aligned}
\end{equation*}
for real $k$. Then $|\phi\left(x\right)|^2 = |\psi\left(x\right)|^2$. As a result, $\left<\hat{x}\right>_\phi = \left<\hat{x}\right>_\psi$, but
\begin{equation*}
\begin{aligned}
\left<\hat{p}\right>_\phi &= \int_{-\infty}^\infty -i\hbar \phi^*\phi' dx\\
&= \int_{-\infty}^\infty -i\hbar \psi^* \psi' + \int_{-\infty}^\infty \hbar
k \psi^* \psi\\
&= \left<\hat{p}\right>_\psi + \hbar k
\end{aligned}
\end{equation*}
So additional factor of $e^{ikx}$ changes momentum by $hk$.

\begin{eg}
Let
\begin{equation*}
\begin{aligned}
\psi = C e^{-\frac{x^2}{2\alpha}}
\end{aligned}
\end{equation*}
as in the last subsection but with $x_0=0$.\\
Then $\left<\hat{p}\right>_\psi = 0$,
\begin{equation*}
\begin{aligned}
\phi = C e^{-\frac{x^2}{2\alpha}} e^{ikx}
\end{aligned}
\end{equation*}
with $\left<\hat{p}\right>_\phi = \hbar k$.
\end{eg}

\subsubsection{Eigenvalues and Eigenstates}
Consider an operator corresponding to an observable, $Q$, with
\begin{equation*}
\begin{aligned}
Q \psi = q\psi
\end{aligned}
\end{equation*}
for some number $q$. Then $\psi\left(x\right)$ is called an \emph{eigenfunction}, or \emph{eigenstate} of $Q$ with eigenvalue $q$.

\begin{post}
If $Q$ is measured when the system is in an eigenstate $\psi$, then the result is the eigenvalue $q$ with probability 1.
\end{post}

\begin{eg}
$Q = \hat{x}$. This has no normalisable eigenfunctions, since if
\begin{equation*}
\begin{aligned}
\hat{x} \psi\left(x\right) = x\psi\left(x\right) = q\psi\left(x\right)
\end{aligned}
\end{equation*}
for some $q$, then $\psi\left(x\right) = 0$ for all $x\neq q$.
\end{eg}

\begin{eg}
Set $Q = \hat{p} = -ih\frac{d}{dx}$, and $q=p$. Then $\psi = C e^{ikx}$ is an eigenfunction with $p = \hbar k$. However, this is not normalisable on the real line (we'll return to this later).
\end{eg}

\begin{eg}
Set $Q=H$ with $V\left(x\right) = \frac{1}{2} kx^2$ with $k>0$, a harmonic oscillator, and $q = E$. Then the eigenvalue equation
\begin{equation*}
\begin{aligned}
H \psi &= -\frac{\hbar^2}{2m} \psi'' + \frac{1}{2} kx^2 \psi = E\psi
\end{aligned}
\end{equation*}
is satisfied by
\begin{equation*}
\begin{aligned}
\psi = Ce^{-x^2/2\alpha}
\end{aligned}
\end{equation*}
(where $C$ is chosen to normalise $\psi$) for $\alpha^2 = \hbar^2/km$ and $E = \frac{\hbar}{2} \sqrt{\frac{k}{m}}$.
\end{eg}

In general, the energy eigenvalue equation
\begin{equation*}
\begin{aligned}
H_\psi = E_\psi
\end{aligned}
\end{equation*}
or
\begin{equation*}
\begin{aligned}
-\frac{\hbar}{2m} \frac{d^2 \psi}{dx^2} +V\left(x\right) \psi = E\psi\left(x\right)
\end{aligned}
\end{equation*}
for particle in potential $V\left(x\right)$ is called the \emph{time-independent} \emph{Schr\"{o}dinger Equation}(SE). Solving this determines all states of definite energy.

\subsubsection{Additional comments}
\begin{rem}
If $\psi$ is any normalised state, then $\left<\hat{p}\right>_\psi$ and $\left<H\right>_\psi$ are real. This follows from definitions using integration by parts, e.g.
\begin{equation*}
\begin{aligned}
\left<\hat{p}\right>^* &= \left(\int_{-\infty}^\infty -i\hbar \psi^* \psi' dx\right)^* \\
&= \left(\int_{-\infty}^\infty i\hbar \psi\left(\psi^*\right)' dx\right)\\
&= i\hbar \left[\psi \psi^*\right]_{\infty}^\infty (=0) - i\hbar \int_{-\infty}^\infty \psi'\psi^* dx\\
&= \left<\hat{p}\right>_\psi
\end{aligned}
\end{equation*}
Similarly we can check
\begin{equation*}
\begin{aligned}
\left<H\right>_\psi = \int_{-\infty}^\infty \left(-\frac{\hbar^2}{2m} \psi^* \psi'' + \psi^* V \psi\right) dx
\end{aligned}
\end{equation*}
is real, integrate first term by parts twice after taking complex conjugate (assume V real).
\end{rem}

\begin{rem}
Postulate 3 is consistent with Postulate 2 since
\begin{equation*}
\begin{aligned}
&H\psi = E\psi\\
\implies & \left<H\right>_\psi = \int_{-\infty}^\infty \psi^* H \psi dx = \int_{-\infty}^\infty E \psi^* \psi dx = E
\end{aligned}
\end{equation*}
for $\psi$ normalised.
\end{rem}

\begin{rem}
From the previous two remarks, the energy eigenvalue for a normalised eigenstate $\psi$ is always real.
\end{rem}

\subsection{Infinite well or particle in a box}

Let
\begin{equation*}
\begin{aligned}
V\left(x\right) = \left\{
\begin{array}{ll}
0 & |x| \leq a\\
\infty & |x| > a
\end{array}
\right.
\end{aligned}
\end{equation*}
assume $\psi\left(\pm a\right) = 0$ and justify at end and $\psi\left(x\right) = 0$ for $|x|>a$.

Consider SE for $-a\leq x \leq a$
\begin{equation*}
\begin{aligned}
-\frac{\hbar^2}{2m} \psi'' = E\psi
\end{aligned}
\end{equation*}
for $E>0$, set $E = \frac{\hbar^2 k^2}{2m}$ where $k>0$ so that SE becomes
\begin{equation*}
\begin{aligned}
\psi'' + k^2 \psi = 0
\end{aligned}
\end{equation*}
So
\begin{equation*}
\begin{aligned}
\psi = A \cos kx + B \sin kx
\end{aligned}
\end{equation*}
But $A\cos ka \pm B \sin ka = 0$ from boundary condition. That implies either
\begin{equation*}
\begin{aligned}
B=0,\ ka = \frac{n\pi}{2} \ n=1,3,...
\end{aligned}
\end{equation*}
or
\begin{equation*}
\begin{aligned}
A=0,\ ka = \frac{n\pi}{2} \ n=2,4,...
\end{aligned}
\end{equation*}

Solutions:
\begin{equation*}
\begin{aligned}
\psi_n\left(x\right) = \left(\frac{1}{a}\right)^{1/2} \left\{
\begin{array}{ll}
\cos \\
\sin
\end{array}
\right\} \frac{n\pi}{2a}x \text{ for } n>0 \left\{
\begin{array}{ll}
\text{odd} \\
\text{even}
\end{array}
\right\}
\end{aligned}
\end{equation*}
energy eigenfunctions and discrete set of energy eigenvalues
\begin{equation*}
\begin{aligned}
E_n = \frac{\hbar^2 \pi^2 n^2}{8ma^2}
\end{aligned}
\end{equation*}

For $E<0$, set
\begin{equation*}
\begin{aligned}
E= -\frac{\hbar^2 k^2}{2m}
\end{aligned}
\end{equation*}
with $k>0$ so that SE becomes\begin{equation*}
\begin{aligned}
\psi'' - k^2 \psi = 0
\end{aligned}
\end{equation*}
Solutions are
\begin{equation*}
\begin{aligned}
\psi = A e^{kx} + B e^{-kx}
\end{aligned}
\end{equation*}
and cannot satisfy boundary conditions, except by $A=B=0$.

To justify boundary conditions, consider potential with $V\left(x\right) = U \gg E$ for $|x|>a$. Setting
\begin{equation*}
\begin{aligned}
U-E = \frac{\hbar^2 k^2}{2m}
\end{aligned}
\end{equation*}
and SE is
\begin{equation*}
\begin{aligned}
\psi'' - k^2 \psi = 0
\end{aligned}
\end{equation*}
for $|x|>a$. So for normalisable solutions, we need
\begin{equation*}
\begin{aligned}
\psi = \left\{
\begin{array}{ll}
Ae^{-kx} & x>a\\
Be^{+kx} & x<-a
\end{array}
\right.
\end{aligned}
\end{equation*}
Taking $U \to \infty$ with $E$ fixed, $k \to \infty$, and $\psi \to 0$ for $|x| > a$.

\newpage

\section{The Schr\"{o}dinger Equation}
To continue our development of QM (in one dimension), we need to consider how things evolve in time.

Classical dynamics of a particle can be specified by the potential $V\left(x\right)$ (Force $f\left(x\right) = -V'\left(x\right)$). Quantum dynamics is also specified by Hamiltonian
\begin{equation*}
\begin{aligned}
H = \frac{\hat{p}^2}{2m} + V\left(\hat{x}\right)
\end{aligned}
\end{equation*}
also determined by potential.

Evolution of a quantum state in time is described by a $t$-dependent wave function $\Psi\left(x,t\right)$ which satisfies
\begin{equation}\label{1}
\begin{aligned}
i\hbar \frac{\partial}{\partial t} \Psi = H \Psi
\end{aligned}
\end{equation}
the \emph{time-dependent Schr\"{o}dinger Equation}.

The operators $\hat{x}$ and $\hat{p}$ do not change in time, and \eqref{1} is
\begin{equation*}
\begin{aligned}
i\hbar \frac{\partial \Psi}{\partial t} = -\frac{\hbar^2}{2m} \frac{\partial^2 \Psi}{\partial x^2} + V\left(x\right) \psi
\end{aligned}
\end{equation*}
a PDE linear in $\Psi$ and first order in $t$, so specify $\Psi\left(x,0\right)$ and $\Psi\left(x,t\right)$ can be determined uniquely.

\subsection{Stationary states}
Consider a wave function of definite frequency:
\begin{equation*}
\begin{aligned}
\Psi\left(x,t\right) = \psi\left(x\right) e^{-i\omega t}
\end{aligned}
\end{equation*}
Substituting in \eqref{1} gives
\begin{equation*}
\begin{aligned}
\psi \hbar \omega e^{-i\omega t} = \left(H\psi\right) e^{-i\omega t}
\end{aligned}
\end{equation*}
This holds if and only if
\begin{equation*}
\begin{aligned}
H \psi = E\psi
\end{aligned}
\end{equation*}
with $E = \hbar \omega$.

Alternatively, look for a separable solution
\begin{equation*}
\begin{aligned}
\Psi\left(x,t\right) = f\left(t\right)\psi\left(x\right)
\end{aligned}
\end{equation*}
and find
\begin{equation*}
\begin{aligned}
\frac{1}{\psi} H \psi = \frac{i\hbar}{f}\dot{f} = E
\end{aligned}
\end{equation*}
which is a separation constant. This implies $H\psi = E\psi$ and $f\left(t\right) = f\left(0\right) e^{-iEt/\hbar}$.

A solution of this special form is called a \emph{stationary state}. Special properties of stationary states:\\
(i)
\begin{equation*}
\begin{aligned}
\left|\Psi \left(x,t\right)\right|^2 = \left|\psi\left(x\right)\right|^2
\end{aligned}
\end{equation*}
So probability density does not change with time;\\
(ii)
\begin{equation*}
\begin{aligned}
\Psi\left(x,t\right) = \psi\left(x\right) e^{-iEt/\hbar}
\end{aligned}
\end{equation*}
is the unique solution with $\Psi\left(x,0\right) = \psi\left(x\right)$ and $H\psi = E\psi$. Then $H\Psi = E\Psi$ implies that the measurement of energy gives result $E$ with certainty (probability 1) for all $t$.

\begin{eg}
Consider particle in a box in chapter 1.3: found energy eigenstates $\psi_n\left(s\right)$ $\left(\begin{array}{ll}\sin \\ \cos\end{array}\right)$ with
\begin{equation*}
\begin{aligned}
E_n = \frac{\hbar^2 \pi^2}{8ma^2} n^2
\end{aligned}
\end{equation*}
for $n=1,2,...$.\\
Stationary state solutions of time dependent SE:
\begin{equation*}
\begin{aligned}
\Psi_n\left(x,t\right) = \psi_n\left(x\right) e^{-iE_n t/\hbar}
\end{aligned}
\end{equation*}
Note however $\psi_1+\psi_2$ is \emph{not} an energy eigenstate:
\begin{equation*}
\begin{aligned}
H\left(\psi_1+\psi_2\right) = E_1\psi_1 E_2 \psi_2 \not\propto \psi_1+\psi_2
\end{aligned}
\end{equation*}
\end{eg}

\subsection{Conservation of Probability}
The probability density
\begin{equation*}
\begin{aligned}
P\left(x,t\right) = \left|\Psi\left(x,t\right)\right|^2
\end{aligned}
\end{equation*}
obeys a conservation equation
\begin{equation*}
\begin{aligned}
\frac{\partial P}{\partial t} = -\frac{\partial J}{\partial x}
\end{aligned}
\end{equation*}
where
\begin{equation*}
\begin{aligned}
J\left(x,t\right) = -\frac{i\hbar}{2m} \left(\Psi^* \Psi' - \left.\Psi'\right.^* \Psi\right)
\end{aligned}
\end{equation*}
which is real (here $' = \frac{\partial}{\partial x}$), and is called the \emph{probability current}.

This follows from time dependent SE
\begin{equation*}
\begin{aligned}
i\hbar \frac{\partial\Psi}{\partial t} = -\frac{\hbar^2}{2m} \Psi'' + V\Psi
\end{aligned}
\end{equation*}
and its conjugate
\begin{equation*}
\begin{aligned}
-i\hbar \frac{\partial\Psi^*}{\partial t} = -\frac{\hbar^2}{2m} \left.\Psi^*\right.'' + V\Psi^*
\end{aligned}
\end{equation*}
So
\begin{equation*}
\begin{aligned}
\frac{\partial P}{\partial t} &= \Psi^* \frac{\partial \Psi}{\partial t} + \frac{\partial \Psi^*}{\partial t} \Psi \\
&= \Psi^* \frac{i\hbar}{2m} \Psi'' - \frac{i\hbar}{2m} \left.\Psi^*\right.'' \Psi
\end{aligned}
\end{equation*}
Since the potential terms ($V$) cancel each other. That is equal to
\begin{equation*}
\begin{aligned}
-\frac{\partial J}{\partial x}
\end{aligned}
\end{equation*}
as claimed.

The conservation equation implies
\begin{equation*}
\begin{aligned}
\frac{d}{dt}\int_a^b P\left(x,t\right)dx &= \int_a^b + \frac{\partial P}{\partial t}\left(x,t\right)dx\\
&=\int_a^b -\frac{\partial J}{\partial x} \left(x,t\right) dx\\
&= -J\left(b,t\right) + J\left(a,t\right)
\end{aligned}
\end{equation*}

Then boundary conditions $\Psi, J \to 0$ as $x \to \pm \infty$ (for fixed $t$) gives
\begin{equation*}
\begin{aligned}
\int_{-\infty}^\infty \left|\Psi\left(x,t\right)\right|^2 dx
\end{aligned}
\end{equation*}
which is independent of time.

Hence $\Psi\left(x,0\right)$ normalised $\implies$ $\Psi\left(x,t\right)$ normalised for all $t\geq 0$.

\subsection{Wave packets and particles}
Any wave function that represents a particle localised in space (about some point, on some scale) is called a \emph{wave packet}.

For example, consider Gaussian
\begin{equation*}
\begin{aligned}
\psi\left(x\right) = A \frac{1}{\alpha^{1/2}} e^{-x^2/2\alpha}
\end{aligned}
\end{equation*}
where $A = \left(\alpha/\pi\right)^{1/4}$.\\
Wave packet localised around $x=0$ on length scale $\sqrt{\alpha}$.

So the solution of time dependent SE with $V=0$ (free particle) and $\Psi\left(x,0\right) = \psi\left(x\right)$. Then
\begin{equation*}
\begin{aligned}
\Psi\left(x,t\right) = A\frac{1}{\gamma\left(t\right)^{1/2}} e^{-x^2/2\gamma\left(t\right)}
\end{aligned}
\end{equation*}
with
\begin{equation*}
\begin{aligned}
\gamma\left(t\right) = \alpha + \frac{i\hbar t}{m}
\end{aligned}
\end{equation*}
(see example sheet 1).

Then the probability density is
\begin{equation*}
\begin{aligned}
P_\Psi\left(x,t\right) &= \left|\Psi\left(x,t\right)\right|^2 \\
&= \frac{|a|^2}{|\gamma\left(t\right)|} e^{-\alpha x^2/|\gamma\left(t\right)|^2}
\end{aligned}
\end{equation*}
localised around $x=0$ but the length scale $|\gamma\left(t\right)/\sqrt{\alpha}$ spreads with $t$.

However it's easy to check
\begin{equation*}
\begin{aligned}
\left<\hat{x}\right>_\Psi = \left<\hat{p}\right>_\Psi = 0
\end{aligned}
\end{equation*}
for all $t$.

Previously noted $\phi\left(x\right) = \psi\left(x\right) e^{ikx}$ has expectation value $\hbar k$ for momentum. Solution to SE with $\Phi\left(x,0\right) = \phi \left(x\right)$ is
\begin{equation*}
\begin{aligned}
\Phi\left(x,t\right) = \Psi\left(x-ut,t\right)e^{ikx}e^{-i\left(\hbar k^2/2m\right)t}
\end{aligned}
\end{equation*}
with $mu = \hbar k$ (can be checked directly). We can also check
\begin{equation*}
\begin{aligned}
\left<\hat{x}\right>_\Phi = ut
\end{aligned}
\end{equation*}
and
\begin{equation*}
\begin{aligned}
\left<\hat{p}\right>_\Phi = \hbar k
\end{aligned}
\end{equation*}

Moreover,
\begin{equation*}
\begin{aligned}
P_\Phi = \left|\Phi\left(x,t\right)\right|^2  = \left|\Psi\left(x-ut,t\right)\right|^2 = P_\Psi\left(x-ut,t\right)
\end{aligned}
\end{equation*}

So $\Phi$ corresponds to the moving particle with $mu = \hbar k$ momentum.

Gaussian wave function spreads out on time-scale $\tau \sim \frac{m\alpha}{\hbar}$.

For example, consider an electron $m=m_e$ and $\sqrt{\alpha} = 10^{-12}$ meter. Then $ \tau \sim 10^{-20}$ sec.

Now take $m=10^{-6}$ kg and $\alpha = 10^{-6}$ meter. Then $\tau \sim 10^{16}$ sec.

\newpage

\section{Bound States in One Dimension}

A bound state for a particle of mass $m$ in a potential $V\left(x\right)$ is a normalisable energy eigenstate (or stationary state)
\begin{equation*}
\begin{aligned}
H\psi = -\frac{\hbar^2}{2m} \psi'' + V\left(x\right) \psi = E\psi
\end{aligned}
\end{equation*}
(time-independent SE). This corresponds to a bounded classical orbit.

If $V\left(x\right) \to 0$ as $|x| \to \infty$, need $E < 0$ (see section 3.2 below).

\subsection{Potential Well}
Consider a potential well
\begin{equation*}
\begin{aligned}
V\left(x\right) = \left\{ \begin{array}{ll}
-U & |x|<a \\
0 & |x| \geq a
\end{array}
\right.
\end{aligned}
\end{equation*}
Seek solutions of time-independent SE with $-U<E<0$:
\begin{equation*}
\begin{aligned}
-\frac{\hbar^2}{2m}\psi'' = \left(E+U\right)\psi & &|x|<a\\
-\frac{\hbar^2}{2m}\psi'' = E\psi & &|x|>n
\end{aligned}
\end{equation*}

Set $U+E = \frac{\hbar^2 k^2}{2m}$ and $E=-\frac{\hbar^2\kappa^2}{2m}$ for $k,\kappa \in \R^+$. Then
\begin{equation*}
\begin{aligned}
k^2 + \kappa^2 = \frac{2mU}{\hbar^2}
\end{aligned}
\end{equation*}
Then SE becomes
\begin{equation*}
\begin{aligned}
\psi'' + k^2 \psi = 0 & & |x|<a\\
\psi'' - \kappa^2 \psi = 0 & & |x|>a
\end{aligned}
\end{equation*}
Need $\psi,\psi'$ continuous but $\psi''$ discontinuous at $x = \pm a$.

Consider \emph{even parity} solutions with $\psi\left(-x\right) = \psi\left(x\right)$:\begin{equation*}
\begin{aligned}
\psi = \left\{\begin{array}{ll}
A\cos kx & |x|<a\\
Be^{-\kappa x} & |x|>a
\end{array}
\right.
\end{aligned}
\end{equation*}
Matching $\psi$ and $\psi'$ at $x=a$ ($x=-a$ automatic for $\psi$ even):
\begin{equation*}
\begin{aligned}
A\cos ka = Be^{-\kappa a}\\
-Ak\sin ka = -B \kappa e^{-\kappa a}
\end{aligned}
\end{equation*}

These give the same result for $A/B$ if and only if
\begin{equation*}
\begin{aligned}
k\tan ka = \kappa
\end{aligned}
\end{equation*}
To see when solutions exists, convenient to set
\begin{equation*}
\begin{aligned}
\xi = ak, \eta = a\kappa
\end{aligned}
\end{equation*}
which are dimensionless (and positive), and consider
\begin{equation*}
\begin{aligned}
\eta = \xi \tan \xi,\\
\xi^2 + \eta^2 = \frac{2ma^2}{\hbar^2} U
\end{aligned}
\end{equation*}

For each point of intersection, we get one solution for $\xi,\eta$ or $k,\kappa$ and corresponding value of $E$.\\
Hence there is exactly one solution for $\frac{2ma^2}{\hbar^2}U < \pi^2$.

In general, there are $n$ solutions for $\left(n-1\right)^2 \pi^2 < \frac{2ma^2U}{h\hbar^2} < n^2\pi^2$.

There are finite number of allowed energy eigenstates.

\begin{tikzpicture}
\draw (0,0) -- (1,0);
\draw (1,0) -- (0,1);
\draw (0.5,1) -- (0.25,-0.25);
\draw (0,0) .. controls (1,0) and (0.5,1) .. (1,1);
\draw (2,2) .. controls (1.65,-0.95) and (-0.3,3.4) .. (1,0);
\end{tikzpicture}

Note that now we have non-zero probability density $|\psi\left(x\right)|^2$ of measuring particle \emph{outside} classically allowed region $|x|<a$ (for $E<0$).

We can consider \emph{odd parity} solutions $\psi\left(-x\right) = -\psi\left(x\right)$ similarly (see example sheet 1).

\subsection{General Properties}

\subsubsection{Bound state energies}
Consider time-independent SE with $V\left(x\right) \to 0$ as $x \to \pm \infty$. For 2nd order ODE, there are 2 complex constants in general solution.\\
But this is linear in $\psi$, so one complex constants corresponds to $\psi \to \lambda \psi$.

Now
\begin{equation*}
\begin{aligned}
-\frac{\hbar^2}{2m}\psi'' \sim E\psi
\end{aligned}
\end{equation*}
as $x \to \pm \infty$. So
\begin{equation*}
\begin{aligned}
\psi \sim A_\pm e^{ikx} + B_\pm e^{-ikx} & & E=\frac{\hbar^2 k^2}{2m} > 0\\
\psi \sim A_\pm e^{\kappa x} + B_\pm e^{-\kappa x} & & E=-\frac{\hbar^2\kappa^2}{2m} < 0
\end{aligned}
\end{equation*}
For $E>0$ there is no normalisable solution.

For $E<0$ we have normalisable solution if
\begin{equation*}
\begin{aligned}
\psi \sim \left\{ \begin{array}{ll}
B_+ e^{-\kappa x} & x\to +\infty \  \left(A_+ = 0\right)\\
A_- e^{\kappa x} & x \to -\infty \  \left(B_- = 0\right)
\end{array}
\right.
\end{aligned}
\end{equation*}

Only one complex constant left to choose, so specifying behaviour at both boundaries $\implies$ over-determined system, solutions exist for \emph{particular} values of $E$ $\implies$ bound state energies quantised.

We may have several bound states:

\begin{tikzpicture}
\draw (-2,0) -- (2,0);
\draw (0,-2) -- (0,2);
\draw (-2,-0.1) .. controls (-1.0,-0.15) and (-0.5,-1.0) .. (0,-1);
\draw (2,-0.1) .. controls (1.0,-0.15) and (0.5,-1.0) .. (0,-1);
\end{tikzpicture}

or none:

\begin{tikzpicture}
\draw (-2,0) -- (2,0);
\draw (0,-2) -- (0,2);
\draw (-2,0.1) .. controls (-1.0,0.15) and (-0.5,1.0) .. (0,1);
\draw (2,0.1) .. controls (1.0,0.15) and (0.5,1.0) .. (0,1);
\end{tikzpicture}

Furthermore, if $V\left(x\right) \geq V_0$ (constant), then for $\psi$ normalisable,
\begin{equation*}
\begin{aligned}
H\psi = E\psi \implies E &= \left<H\right>_\psi\\
&=\int_{-\infty}^\infty \left(-\frac{\hbar^2}{2m} \psi^* \psi'' + V\left(x\right) |\psi\left(x\right)|^2\right) dx\\
&= \int_{-\infty}^\infty \left(\frac{\hbar^2}{2m}|\psi'|^2 + V\left(x\right) |\psi|^2\right) dx\\
&\geq 0+V_0
\end{aligned}
\end{equation*}
(integration by parts). So $0>E>V_0$ for any bounded state.

\newpage

\section{Expectation and Uncertainty}
\subsection{Hermitian Operators}
Recall earlier definition
\begin{equation*}
\begin{aligned}
\left(\phi,\psi\right) = \int_{-\infty}^\infty \phi\left(x\right)^* \psi\left(x\right) dx
\end{aligned}
\end{equation*}
with properties
\begin{equation*}
\begin{aligned}
\left(\psi,\alpha\psi\right)=\alpha\left(\phi,\psi\right) = \left(\alpha^*\phi,\psi\right)
\end{aligned}
\end{equation*}
and similarly
\begin{equation*}
\begin{aligned}
\left(\phi,\psi\right)^* = \left(\psi,\phi\right)
\end{aligned}
\end{equation*}

Regarding this as an inner product on wave functions, define the \emph{norm} of $psi$, denoted $||\psi||$, by
\begin{equation*}
\begin{aligned}
||\psi||^2 = \left(\psi,\psi\right) = \int_{-\infty}^\infty |\psi\left(x\right)|^2 dx
\end{aligned}
\end{equation*}
which is real and positive, and $||\psi|| = 1$ is $\psi$ is normalised.

An operator $Q$ is \emph{hermitian} if
\begin{equation*}
\begin{aligned}
\left(\phi,Q\psi\right) = \left(Q\phi,\psi\right)
\end{aligned}
\end{equation*}
for all normalisable $\psi,\phi$. This implies
\begin{equation*}
\begin{aligned}
\left(\psi,Q\psi\right) = \left(Q\psi,\psi\right) = \left(\psi,Q\psi\right)^*\\
\implies \left<Q\right>_\psi = \left<Q\right>_\psi^*
\end{aligned}
\end{equation*}

The operators $\hat{x},\hat{p}$, and $H=\frac{\hat{p}^2}{2m} + V\left(\hat{x}\right)$ are hermitian (for $V$ real).

Check:
\begin{equation*}
\begin{aligned}
&\left(\phi,\hat{x}\psi\right) = \left(\hat{x}\phi,\psi\right)\\
\iff & \int_{-\infty}^\infty \phi\left(x\right)^* \left(x\psi\left(x\right)\right)dx = \int_{-\infty}^\infty \left(x\phi\left(x\right)\right)^* \psi\left(x\right) dx
\end{aligned}
\end{equation*}
which is true ($x$ is real).

\begin{equation*}
\begin{aligned}
&\left(\phi,\hat{p}\psi\right) = \left(\hat{p}\phi,\psi\right)\\
&\iff \int_{-\infty}^\infty \phi^* \left(-i\hbar \psi'\right) dx = \int_{-\infty}^\infty \left(-ih\phi'\right)^* \psi dx
\end{aligned}
\end{equation*}
by parts and $\left[\phi^*\psi\right]_{-\infty}^\infty = 0$.

To show $\left(\phi,H\psi\right) = \left(H\phi,\psi\right)$, check KE and PE terms separately:\\
KE: $\left(\phi,\psi''\right) = -\left(\phi',\psi'\right) = \left(\phi'',\psi\right)$;\\
PE: $\left(\phi,V\left(x\right)\psi\right) = \left(V\left(x\right)\phi,\psi\right)$ for $V$ real.

(Later in chapter 6 we'll prove other general properties of hermitian operators, e.g. eigenvalues are real, eigenstates with distinct eigenvalues are orthogonal with respect to inner product.)

\subsection{Ehrenfest's Theorem}

Consider normalised $\Psi\left(x,t\right)$ satisfying SE
\begin{equation*}
\begin{aligned}
i\hbar\dot{\Psi} = H\Psi = \left(\frac{\hat{p}^2}{2m} + V\left(\hat{x}\right)\right)\Psi = -\frac{\hbar^2}{2m}\Psi'' + V\left(x\right) \Psi
\end{aligned}
\end{equation*}
The expectation values
\begin{equation*}
\begin{aligned}
\left<\hat{x}\right>_\Psi = \left(\Psi,\hat{x}\Psi\right)
\end{aligned}
\end{equation*}
and
\begin{equation*}
\begin{aligned}
\left<\hat{p}\right>_\Psi = \left(\Psi,\hat{p}\Psi\right)
\end{aligned}
\end{equation*}
depend on $t$ through $\Psi$. Ehrenfest's Theorem states
\begin{equation*}
\begin{aligned}
\frac{d}{dt}\left<\hat{x}\right>_\Psi = \frac{1}{m} \left<\hat{p}\right>_\Psi
\end{aligned}
\end{equation*}
and
\begin{equation*}
\begin{aligned}
\frac{d}{dt}\left<\hat{p}\right>_\Psi = -\left<V'\left(\hat{x}\right)\right>_\Psi
\end{aligned}
\end{equation*}
which is the quantum counterparts to classical equations of motion (in first order form).
\begin{proof}
\begin{equation*}
\begin{aligned}
\frac{d}{dt}\left<\hat{x}\right>_\Psi &= \left(\dot{\Psi},\hat{x}\Psi\right) + \left(\Psi,\hat{x}\dot{\Psi}\right)\\
&= \left(\frac{1}{i\hbar} H \Psi, \hat{x}\Psi\right) + \left(\Psi,\hat{x}\frac{1}{i\hbar}H\Psi\right)
\end{aligned}
\end{equation*}

Since $H$ is hermitian,
\begin{equation*}
\begin{aligned}
&-\frac{1}{i\hbar}\left(H\Psi,\hat{x}\Psi\right) + \frac{1}{i\hbar}\left(\Psi,\hat{x}H\Psi\right)\\
&= -\frac{1}{i\hbar}\left(\Psi,H\hat{x}\Psi\right)+\frac{1}{i\hbar}\left(\Psi,\hat{x}H\Psi\right)\\
&= \frac{1}{i\hbar}\left(\Psi,\left(\hat{x}H-H\hat{x}\right)\Psi\right)
\end{aligned}
\end{equation*}
But
\begin{equation*}
\begin{aligned}
\left(\hat{x}H-H\hat{x}\right)\Psi &= \frac{-\hbar^2}{2m}\left(x\Psi'' - \left(x\Psi\right)''\right) + \left(xV-Vx\right)\Psi\\
&= +\frac{\hbar^2}{2m}2\Psi'\\
&= \frac{i\hbar}{m}\hat{p}\Psi
\end{aligned}
\end{equation*}
as required.

Similarly,
\begin{equation*}
\begin{aligned}
\frac{d}{dt}\left<\hat{p}\right>_\Psi &= \left(\dot{\Psi},\hat{p}\Psi\right)+\left(\Psi,\hat{p}\dot{\Psi}\right)\\
&= \left(\frac{1}{i\hbar}H\Psi,\hat{p}\Psi\right) + \left(\Psi,\hat{p}\frac{1}{i\hbar}H\Psi\right)\\
&= \frac{1}{i\hbar}\left(\Psi,\left(\hat{p}H-H\hat{p}\right)\Psi\right)
\end{aligned}
\end{equation*}
But
\begin{equation*}
\begin{aligned}
\left(\hat{p}H-H\hat{p}\right)\Psi &= -i\hbar \left(-\frac{\hbar^2}{2m}\right)\left(\left(\Psi''\right)'-\left(\Psi'\right)''\right) (=0) - i\hbar\left(\left(V\Psi\right)'-V\Psi'\right)\\
&= -i\hbar V'\left(x\right)\Psi
\end{aligned}
\end{equation*}
as required.

\subsection{The Uncertainty Principle}
If $\psi$ is any normalised state (at fixed time) define the \emph{uncertainty} in position $\left(\Delta x\right)_\psi$ and momentum $\left(\Delta p\right)_\psi$ by
\begin{equation*}
\begin{aligned}
\left(\Delta x\right)_\psi^2 = \left<\left(\hat{x}-\left<\hat{x}\right>-\psi\right)^2\right>_\psi \neq = \left<\hat{x}^2\right>_\psi - \left<\hat{x}\right>_\psi^2
\end{aligned}
\end{equation*}
and the same formula for $\left(\Delta p\right)_\psi$.

These quantify 'spread' of possible results of measurements.

Heisenberg's Uncertainty Principle states
\begin{equation*}
\begin{aligned}
\left(\Delta x\right)_\psi \left(\Delta p\right)_\psi \geq \frac{\hbar}{2}
\end{aligned}
\end{equation*}
Interpretation: we can never reduce combined uncertainty in measurements of position and momentum below this threshold.

Note: $X=\hat{x}-\alpha$ and $P=\hat{p}-\beta$ are both hermitian for any real $\alpha,\beta$.

\begin{equation*}
\begin{aligned}
\left(\psi,X^2\psi\right) = \left(X\psi,X\psi\right) = ||X\psi||^2 \geq 0,\
\left(\psi,P^2\psi\right) = \left(P\psi,P\psi\right) = ||P\psi||^2 \geq 0
\end{aligned}
\end{equation*}
Choosing $\alpha = \left<\hat{x}\right>_\psi$ and $\beta = \left<\hat{p}\right>_\psi$, we deduce $\left(\Delta x\right)_\psi^2$ and $\left(\Delta p\right)_\psi^2$ are indeed real and positive, as required in our definition.

\begin{eg}
For Gaussian
\begin{equation*}
\begin{aligned}
\psi\left(x\right) = \left(\frac{1}{\alpha\pi}\right)^\frac{1}{4} e^{-x^2/2\alpha}
\end{aligned}
\end{equation*}
find
\begin{equation*}
\begin{aligned}
\left<\hat{x}\right>_\psi = \left<\hat{p}\right>_\psi = 0
\end{aligned}
\end{equation*}
and
\begin{equation*}
\begin{aligned}
\left(\Delta x\right)_\psi^2 = \alpha/2,\left(\Delta p\right)_\psi^2 = \hbar^2 / 2\alpha
\end{aligned}
\end{equation*}
So
\begin{equation*}
\begin{aligned}
\left(\Delta x\right)_\psi \left(\Delta p\right)_\psi = \frac{\hbar}{2}
\end{aligned}
\end{equation*}
\end{eg}

\end{proof}

\end{document}


\chapter{Transmission Derivation}

This is an expanded version of the analysis performed for Fig.~\ref{fig:energydistrib}

\begin{equation}
T = T(\omega, x_o) = \frac{(\exp(-\frac{L}{\xi}))^2}{
(\omega-\omega _o)^2 + (\exp(-\frac{L}{\xi})\frac{1}{2}\exp(\frac{\mid L-2 x_o \mid}{\xi}))^2 }
\label{fig:appendixtransmission}
\end{equation}
Where we have appoximated cosh() as $\frac{1}{2}\exp()$.

From the behavior of transmission in media with defects and centers of localizaiton, we see two cases when on a resonant frequency:  either the defect is in the first half of the sample.%, (\ref{fig:cononicaldefectpositions}, plot 1).

\begin{equation}
{\cal E}(x) = \left\{
\begin{array}{l l}
  A \exp\left(\frac{2 (x-x_o)}{\xi}\right) & \quad 0 < x < x_o \\
  B \exp\left(-\frac{2 (x-x_o)}{\xi}\right) & \quad x_o < x < L\\
\end{array} \right.
\label{fig:left}
\end{equation}

or it is in the second half of the sample.%, (\ref{fig:cononicaldefectpositions}, plot 2).
\begin{equation}
{\cal E}(x) = \left\{
\begin{array}{l l}
 A \exp\left(-\frac{2 x}{\xi}\right) & \quad 0 < x < L-2 x_o \\
 B \exp\left(\frac{2 (x-x_o)}{\xi}\right) & \quad L-2 x_o < x < x_o \\
 C \exp\left(-\frac{2 (x-x_o)}{\xi}\right) & \quad x_o < x < L \\
\end{array} \right.
\label{fig:right}
\end{equation}

With either case, we see three distinct regions when the frequency is not on resonance but prior to the pure exponential decay regimes. %(\ref{fig:cononicaldefectpositions}, plot 3):
\begin{equation}
{\cal E}(x) = \left\{
\begin{array}{l l}
y_1 = A \exp\left(-\frac{2 x}{\xi}\right)   & \quad 0 < x < x_1  \\
y_2 = B \exp\left(\frac{2 (x-x_o)}{\xi}\right) & \quad x_1 < x < x_o  \\
y_3 = C \exp\left(-\frac{2 (x-x_o)}{\xi}\right) & \quad  x_o < x < L \\
\end{array} \right.
\label{fig:startingequations}
\end{equation}
Where $x_1$ is the turning point.

\begin{comment}
%% pictures were removed, causes a problem during compile (?)
\begin{figure}
\vskip -0.5cm
\centerline{
\scalebox{0.5}{\includegraphics{pictures/transmission_derivation_14_LR}}
\scalebox{0.5}{\includegraphics{pictures/transmission_derivation_34_LR}}
\scalebox{0.5}{\includegraphics{pictures/transmission_derivation_off_res_LR}}
}
\vskip -0.5cm
\caption{Log of energy versus position sketches for a center of localization in the first half (left), Eq.~\ref{fig:left}; and second half (center), Eq.~\ref{fig:right}. The turning point in the center plot is $L-2 x_o$. The right sketch is off-resonance but prior to pure exponential decay, which applies to any center of localization position, as described by Eq.~\ref{fig:startingequations}. The turning point in the right plot from the initial exponential decay to growth varies depending how far off resonance one is. We call this $x_1$}
\label{fig:cononicaldefectpositions}
\end{figure}
\end{comment}

From the off-resonance Eq.~\ref{fig:startingequations}, we apply boundry conditions to determine the coefficients in passive systems. We take gain into account and make corrections later.

At $x=0$ then $y_1=4$, giving $A=4$. Thus
\begin{equation}
\boxed{y_1 = 4 \exp\left(-\frac{2 x}{\xi}\right)}   \quad \quad \quad 0 < x < L-2 x_o
\end{equation}

At $x=L$, $y_3=T$. Solve for C,
\begin{equation}
C=T \exp\left(\frac{2(L-x_o)}{\xi}\right)
\end{equation}
plug back in,
\begin{equation}
y_3 = T \exp\left(\frac{2(L-x_o)}{\xi}) \exp(-\frac{2 (x-x_o)}{\xi}\right)  \quad \quad \quad  x_o < x < L
\end{equation}
simplify to get
\begin{equation}
\boxed{y_3 = T \exp\left(-\frac{2(x-L)}{\xi}\right)}  \quad \quad \quad  x_o < x < L
\end{equation}
at $x_o$, $y_2 = y_3$
\begin{equation}
B \exp\left(\frac{2 (x_o-x_o)}{\xi}\right) = B = T \exp\left(-\frac{2(x_o-L)}{\xi}\right)
\end{equation}
plug in to $y_2$
\begin{equation}
y_2 = T \exp\left(-\frac{2(x_o-L)}{\xi}\right) \exp\left(\frac{2 (x-x_o)}{\xi}\right) \quad \quad \quad L-2 x_o < x < x_o
\end{equation}
simplify to get
\begin{equation}
\boxed{y_2 = T \exp\left(\frac{2(x+L-2 x_o)}{\xi}\right)} \quad \quad \quad L-2 x_o < x < x_o
\end{equation}

The turning point $x_1$ varies as a function of frequency. Boundry conditions on $x_1$ are that it should remain less than $x_o$ and that it be non-negative. To solve for $x_1$, see where $y_1=y_2$
\begin{equation}
4 \exp\left(-\frac{2 x_1}{\xi}\right) = T \exp\left(\frac{2(x_1+L-2 x_o)}{\xi}\right)
\end{equation}

\begin{equation}
\boxed{x_1(\omega) = -\frac{\xi}{4} \log(\frac{1}{4} T) - \frac{1}{2}L + x_o}
\end{equation}

Knowing $y_1,y_2$, and $y_3$ we can integrate to find the energy ${\cal E}$:
\begin{equation}
\begin{gathered}
{\cal E}(x,\omega) = \int _0 ^{x_1} 4 \exp\left(-\frac{2 x}{\xi}\right) dx +
    \int _{x_1} ^{x_o} T \exp\left(\frac{2(x+L-2 x_o)}{\xi}\right) dx + \\
    \int _{x_o} ^{L} T \exp\left(-\frac{2(x-L)}{\xi}\right)
\label{fig:Eintegral}
\end{gathered}
\end{equation}

Solve, reduce to get the energy as a function of x, frequency, and transmission:
\begin{equation}
\begin{gathered}
{\cal E}(x,\omega) = \frac{\xi}{2} \left( T \left( \exp\left(\frac{2(L-x_o)}{\xi}\right) - \exp\left(\frac{2(L-2 x_o+x_1)}{\xi}\right)+\right. \right.\\
\left.\left.\exp\left(\frac{2(L-x_o))}{\xi}\right) -1 \right) + 4 \left(1-\exp\left(-\frac{2 x_1}{\xi}\right)\right) \right)
\label{fig:appendixenergy}
\end{gathered}
\end{equation}


\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{chngcntr}
\usepackage[table,xcrdaw]{xcolor}
\lhead{Evan Kohilas - z5114986}
\rhead{COMP3821 - Assignment 2}
\pagestyle{fancy}
\title{A17S1N1}
\counterwithin*{equation}{section}
\begin{document}
\begin{center}
    \begin{LARGE}
        COMP3121\\
        Assignment 2\\
        A17S1N2\\
        \hrulefill\\
        Evangelos Kohilas\\
        z5114986\\
        \hrulefill
    \end{LARGE}

    \begin{large}
        By submitting this document you are confirming that all the answers are your work and are not take from any other sources unless clearly mentioned.
    \end{large}

\end{center}

\section*{Question 1}
\begin{enumerate}[label=\alph*)]
    \item
        \begin{gather}
            \text{let } A^n
            = \begin{pmatrix} F(n+1) & F(n) \\ F(n) & F(n-1)  \end{pmatrix}
        \end{gather}
        When $n = 1$
        \begin{gather}
            A^1 = \begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix}
        \end{gather}
        Assume $n = k$
        \begin{gather}
            A^k = \begin{pmatrix} F(k+1) & F(k) \\ F(k) & F(k-1)  \end{pmatrix}
        \end{gather}
        let $n = k + 1$
        \begin{align}
            A^{k+1} &= AA^k \\
            &= \begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix}\begin{pmatrix} F(k+1) & F(k) \\ F(k) & F(k-1)\end{pmatrix} \\
            &= \begin{pmatrix} F(k+1) + F(k) & F(k) + F(k-1) \\ F(k+1) & F(k)  \end{pmatrix} \\
            &= \begin{pmatrix} F(k+2) & F(k+1) \\ F(k+1) & F(k)  \end{pmatrix}
        \end{align}
        Therefore the formula is true by induction for all $n > 0$.
    \item
        $F(n)$ can be found in $\log n$ matrix multiplications using a recursive algorithm
        \begin{verbatim}
matrix = ((1, 1), (1,0))
func(n):
    if n == 1:
        return matrix
    if n is even:
        return func(n/2)^2
    if n is odd:
        return func(n-1) * matrix
        \end{verbatim}
\end{enumerate}

\section*{Question 2}
\begin{enumerate}[label=\alph*)]
    \item
        First we calculate the Karastuba trick.
        \setcounter{equation}{0}
        \begin{gather}
            (a + b)(c + d) = ac + ad + bd + bc \\
            ad + bd = (a + b)(c + d) - ac - bc
        \end{gather}
        Then we substitute $(2)$ into $(4)$
        \begin{align}
            (a + ib)(c + id) &= ac + adi + bdi + bc \\
            &= ac + i(ad + bd) + bc \\
            &= ac + i((a + b)(c + d) - ac - bc) + bc
        \end{align}
        Thus only requiring 3 real number multiplications.
    \item
        \setcounter{equation}{0}
        First we calculate
        \begin{gather}
            a^2 - b^2 = (a + b)(a - b)
        \end{gather}
        Then we substitute $(1)$ into $(2)$
        \begin{align}
            (a + ib)^2 &= a^2 - b^2 + 2abi\\
            &= (a + b)(a - b) + 2abi
        \end{align}
        Thus only requiring 2 real number multiplications
    \item
        \setcounter{equation}{0}
        By re-arranging by the laws of exponents:
        \begin{gather*}
            (a+ib)^2(c+id)^2 = ((a+ib)(c+id))^2
        \end{gather*}
        Thus from above, we then calculate the middle multiplication using
        3 real number multiplications, and then we find the square as above
        using 2 more real number multiplications.
\end{enumerate}

\section*{Question 3}
Expand $P(x)$ and $Q(x)$ as follows.
\begin{align*}
    & P(x) = a_0 + x^{17}(a_{17} + a_{19}x^{2} + a_{21}x^4 + a_{23}x^6)\\
    & Q(x) = b_0 + x^{17}(b_{17} + b_{19}x^{2} + b_{21}x^4 + b_{23}x^6)
\end{align*}
let $y = x^2$ so that
\begin{align*}
    & R_a(y) = a_{17} + a_{19}y + a_{21}y^2 + a_{23}y^3\\
    & R_b(y) = b_{17} + b_{19}y + b_{21}y^2 + b_{23}y^3
\end{align*}
then
\begin{align*}
    & P(x)Q(x) = a_0b_0 + x^{17}(a_0R_b(x^2) + b_0R_a(x^2)) + x^{34}R_a(x^2)R_b(x^2)
\end{align*}
through brute force, we then calculate
\begin{align*}
    & a_0b_0 \text{ to require 1 multiplication}\\
    & a_0R_b(x^2) \text{ and } b_0R_a(x^2) \text{ to require 4 multiplications each}
\end{align*}
then to multiply $R_a(x^2)R_b(x^2)$ (of degree 3), we require $2(3)+1 = 7$ multiplications using the generalised Karatsuba method.\\
and so we get $1 + 4 + 4 + 7 = 16$ multiplications of large numbers.

\section*{Question 4}
As $P(x)$ has all 15 roots of unity, and $x^{15} - 1$ and $P(x)$ are both of the same degree and are both monic then it follows that
\begin{gather*}
P(x) = x^{15} -1
\end{gather*}

\section*{Question 5}
For any input $(a_0, a_1, a_2, ..., a_{2^n-1})$, we can describe $a_i$'s new position by converting $i$ to $n$ binary places and finding the reversed sequence.
e.g. $6 \rightarrow 110 \rightarrow 011 \rightarrow 3$

\section*{Question 6}
let
\begin{align}
    f_m &= \sum_{i+j=m} (j+1)q_jq_i \\
    p_j &= (j+1)q_j
\end{align}
then substitute $(2)$ into $(1)$
\begin{align}
    & \sum_{i+j=m} p_jq_i = \vec{p} \ast \vec{q}
\end{align}
as $(3)$ is a linear convolution, $f_m$ can be computed in $O(n\log n )$ time by transforming $\vec{p}$ and $\vec{q}$ to a point value representation using FFT, calculating the linear multiplication, and then transforming back to coefficient form using inverse FFT.

\pagebreak
\section*{Question 7}
\begin{enumerate}[label=\alph*)]
    \item Starting at $(0,0)$ any spiral arrangement such as the one below would require $n^2$ queries to find the middle element as the local minimum.
        \begin{center}
\texttt{%
\begin{tabular}{|c|c|c|c|c|}
\hline
\rowcolor[HTML]{E6E6E6}
16                        & 15                        & 14                        & 13 & 12                         \\ \hline
17                        & 18                        & 19                        & 20 & \cellcolor[HTML]{E6E6E6}11 \\ \hline
\cellcolor[HTML]{E6E6E6}2 & \cellcolor[HTML]{E6E6E6}1 & \cellcolor[HTML]{E6E6E6}0 & 21 & \cellcolor[HTML]{E6E6E6}10 \\ \hline
\cellcolor[HTML]{E6E6E6}3 & 24                        & 23                        & 22 & \cellcolor[HTML]{E6E6E6}9  \\ \hline
\rowcolor[HTML]{E6E6E6}
4                         & 5                         & 6                         & 7  & 8                          \\ \hline
\end{tabular}
}
        \end{center}
    \item Using the fact that a surface attains its minimal height either along its edges or in the interior, we can develop a divide-and-conquer algorithm by first finding the minimal height along a grid's boundary rows \& columns, and center rows \& columns as follows for an odd and even $n$.
\begin{center}
\texttt{%
\begin{tabular}{|
>{\columncolor[HTML]{E6E6E6}}c |c|c|c|
>{\columncolor[HTML]{E6E6E6}}c |c|c|c|
>{\columncolor[HTML]{E6E6E6}}c |}
\hline
\rowcolor[HTML]{E6E6E6}
25 & 75 & 63 & 34 & 9 & 45 & 49 & 57 & 77 \\ \hline
3  & 58 & 6 & 51 & 4 & 27 & 39 & 18 & 76 \\ \hline
62 & 33 & 46 & 59 & 36                        & 11 & 50 & 5  & 42 \\ \hline
10 & 0  & 15 & 60 & 55                        & 35 & 74 & 28 & 14 \\ \hline
\rowcolor[HTML]{E6E6E6}
30 & 68 & 78 & 21 & 31                        & 29 & 54 & 73 & 65 \\ \hline
40 & 48 & 80 & 43 & 44                        & 38 & 37 & 23 & 72 \\ \hline
19 & 7  & 22 & 32 & \cellcolor[HTML]{CCCCCC}2 & 1  & 67 & 70 & 71 \\ \hline
64 & 61 & 56 & 8  & 79                        & 16 & 52 & 17 & 69 \\ \hline
\rowcolor[HTML]{E6E6E6}
13 & 47 & 12 & 20 & 66                        & 41 & 26 & 24 & 53 \\ \hline
\end{tabular}
\quad
\begin{tabular}{|
>{\columncolor[HTML]{E6E6E6}}c |c|c|
>{\columncolor[HTML]{E6E6E6}}c |
>{\columncolor[HTML]{E6E6E6}}c |c|c|
>{\columncolor[HTML]{E6E6E6}}c |}
\hline
\rowcolor[HTML]{E6E6E6}
16 & 8  & 25 & 24 & 22 & 38 & 37 & 53 \\ \hline
54 & 3  & 27 & 17 & 57 & 10 & 35 & 62 \\ \hline
4  & 28 & 5  & 52 & 34 & 56 & 42 & 18 \\ \hline
\rowcolor[HTML]{E6E6E6}
20 & 12 & 6  & 11 & 21 & 49 & 26 & 61 \\ \hline
\rowcolor[HTML]{E6E6E6}
46 & 33 & 2  & 60 & 40 & 41 & 58 & 14 \\ \hline
48 & 47 & 51 & 9  & 43 & 13 & 23 & 19 \\ \hline
45 & 7  & 30 & 63 & 36 & 50 & 0  & 29 \\ \hline
\rowcolor[HTML]{E6E6E6}
39 & 44 & 15 & 59 & 55 & 31 & \cellcolor[HTML]{CCCCCC}1  & 32 \\ \hline
\end{tabular}
}
\end{center}
We then check to see if the minimal height is a local minimum.\\
If it is, we return it, otherwise we recurse into the quadrant of its smallest neighbour, including our original boundary, since there must be a minimum in that direction as we would be following the slope of the curve. We do this as follows.
\begin{center}
\texttt{%
\begin{tabular}{|
>{\columncolor[HTML]{E6E6E6}}c |c|c|c|
>{\columncolor[HTML]{CCCCCC}}c |c|c|c|
>{\columncolor[HTML]{CCCCCC}}c |}
\hline
25 & \cellcolor[HTML]{E6E6E6}75 & \cellcolor[HTML]{E6E6E6}63 & \cellcolor[HTML]{E6E6E6}34 & \cellcolor[HTML]{E6E6E6}9  & \cellcolor[HTML]{E6E6E6}45 & \cellcolor[HTML]{E6E6E6}49 & \cellcolor[HTML]{E6E6E6}57 & \cellcolor[HTML]{E6E6E6}77 \\ \hline
3  & 58                         & 6                          & 51                         & \cellcolor[HTML]{E6E6E6}4  & 27                         & 39                         & 18                         & \cellcolor[HTML]{E6E6E6}76 \\ \hline
62 & 33                         & 46                         & 59                         & \cellcolor[HTML]{E6E6E6}36 & 11                         & 50                         & 5                          & \cellcolor[HTML]{E6E6E6}42 \\ \hline
10 & 0                          & 15                         & 60                         & \cellcolor[HTML]{E6E6E6}55 & 35                         & 74                         & 28                         & \cellcolor[HTML]{E6E6E6}14 \\ \hline
30 & \cellcolor[HTML]{E6E6E6}68 & \cellcolor[HTML]{E6E6E6}78 & \cellcolor[HTML]{E6E6E6}21 & 31                         & \cellcolor[HTML]{CCCCCC}29 & \cellcolor[HTML]{CCCCCC}54 & \cellcolor[HTML]{CCCCCC}73 & 65                         \\ \hline
40 & 48                         & 80                         & 43                         & 44                         & 38                         & \cellcolor[HTML]{CCCCCC}37 & 23                         & 72                         \\ \hline
19 & 7                          & 22                         & 32                         & 2                          & \cellcolor[HTML]{B3B3B3}1  & \cellcolor[HTML]{CCCCCC}67 & \cellcolor[HTML]{CCCCCC}70 & 71                         \\ \hline
64 & 61                         & 56                         & 8                          & 79                         & 16                         & \cellcolor[HTML]{CCCCCC}52 & 17                         & 69                         \\ \hline
13 & \cellcolor[HTML]{E6E6E6}47 & \cellcolor[HTML]{E6E6E6}12 & \cellcolor[HTML]{E6E6E6}20 & 66                         & \cellcolor[HTML]{CCCCCC}41 & \cellcolor[HTML]{CCCCCC}26 & \cellcolor[HTML]{CCCCCC}24 & 53                         \\ \hline
\end{tabular}
\quad
\begin{tabular}{|
>{\columncolor[HTML]{E6E6E6}}c |c|c|
>{\columncolor[HTML]{E6E6E6}}c |
>{\columncolor[HTML]{E6E6E6}}c |c|c|
>{\columncolor[HTML]{E6E6E6}}c |}
\hline
16 & \cellcolor[HTML]{E6E6E6}8  & \cellcolor[HTML]{E6E6E6}25 & 24 & 22                         & \cellcolor[HTML]{E6E6E6}38 & \cellcolor[HTML]{E6E6E6}37 & 53                         \\ \hline
54 & 3                          & 27                         & 17 & 57                         & 10                         & 35                         & 62                         \\ \hline
4  & 28                         & 5                          & 52 & 34                         & 56                         & 42                         & 18                         \\ \hline
20 & \cellcolor[HTML]{E6E6E6}12 & \cellcolor[HTML]{E6E6E6}6  & 11 & 21                         & \cellcolor[HTML]{E6E6E6}49 & \cellcolor[HTML]{E6E6E6}26 & 61                         \\ \hline
46 & \cellcolor[HTML]{E6E6E6}33 & \cellcolor[HTML]{E6E6E6}2  & 60 & \cellcolor[HTML]{CCCCCC}40 & \cellcolor[HTML]{CCCCCC}41 & \cellcolor[HTML]{CCCCCC}58 & \cellcolor[HTML]{CCCCCC}14 \\ \hline
48 & 47                         & 51                         & 9  & \cellcolor[HTML]{CCCCCC}43 & \cellcolor[HTML]{CCCCCC}13 & \cellcolor[HTML]{CCCCCC}23 & \cellcolor[HTML]{CCCCCC}19 \\ \hline
45 & 7                          & 30                         & 63 & \cellcolor[HTML]{CCCCCC}36 & \cellcolor[HTML]{CCCCCC}50 & \cellcolor[HTML]{B3B3B3}0  & \cellcolor[HTML]{CCCCCC}29 \\ \hline
39 & \cellcolor[HTML]{E6E6E6}44 & \cellcolor[HTML]{E6E6E6}15 & 59 & \cellcolor[HTML]{CCCCCC}55 & \cellcolor[HTML]{CCCCCC}31 & \cellcolor[HTML]{CCCCCC}1  & \cellcolor[HTML]{CCCCCC}32 \\ \hline
\end{tabular}
}
\end{center}
Using the master theorem, we can reduce the $n \times n$ matrix to a $\sim\frac{n}{2} \times \frac{n}{2}$ matrix with $O(n)$ queries.
\begin{align*}
    T(n) &= T(n/2) + cn\\
    T(n) &= T(n/4) + c\frac{n}{2} + cn\\
    T(n) &= T(n/8) + c\frac{n}{4} + c\frac{n}{2} + cn\\
    &\quad\quad\quad\quad\vdots\\
    T(n) &= T(1) + cn(1 + \frac{1}{2} + \frac{1}{4} + \ldots)\\
    T(n) &= T(1) + 2cn
\end{align*}
Thus, our algorithm is of $\Theta(n)$ time.
\end{enumerate}

\section*{Question 8}
\begin{align*}
    \text{let } &A(k) = k^{th} \text{smallest element of } A\\
    \text{let } &B(k) = k^{th} \text{smallest element of } B\\
    \text{let } &i \text{ be the current iteration (starting from 1)}\\
    \text{let } &s_f(i) = \lfloor\frac{n}{2^i}\rfloor, s_c(i) = \lceil\frac{n}{2^i}\rceil\\
    \text{let } &a = s_f(1), b = s_c(1)\\
    \text{let } &m_a = A(a + 1), m_b = B(b + 1)\\
    \text{let } &N \text{ be the set of } n \text{ elements such that } \forall x \in N \cap A, x < m_a \text{ and } \forall x \in N \cap B, x < m_b
\end{align*}
When all elements in $N$ are smaller than $m_a$ and $m_b$, the median will be the smallest of both $m_a$ and $m_b$.\\

\noindent
So we iterate.

\noindent
if $B(b) > m_a$ then there exist elements in $N$ that are not smaller than $m_a$:\\
    \indent Therefore, we change $m_a$ and $m_b$ and increment $i$.\\
    \indent We increase $a$ by $s_c(i)$ to consider elements that may be smaller than the median.\\
    \indent We decrease $b$ by $s_f(i)$ to ignore elements that may be larger than the median.\\
else if $A(a) > m_b$ then there exist elements in $N$ that are not smaller than $m_b$:\\
    \indent Therefore, we change $m_a$ and $m_b$ and increment $i$.\\
    \indent We decrease $a$ by $s_f(i)$ to ignore elements that may be larger than the median.\\
    \indent We increase $b$ by $s_c(i)$ to consider elements that may be smaller than the median.\\
else:\\
    \indent We stop iterating, as all elements of $N$ are smaller than both $m_a$ and $m_b$, and we take the median to be smaller of the two\\

\noindent This algorithm will take at most $O(\log n)$ queries, as every iteration we jump by a factor of 2, similar to that of a binary search.\\

\noindent
Note: if $a + 1 > n$ assume $m_b$ to be the median.

\end{document}


\documentclass{amsart}

\title{LocalGraph Abstract Data Type}
\author{Todd D. Vance}
\date{\today}

\begin{document}
\maketitle{}

\section{Local Graph}

A local graph (modeling a directed graph, loops and multiple edges allowed, from which only a node and its immediate neighborhood are visible at any one time) is actually a system of ADTs.  It consists of a single Cursor, and a finite number of Nodes and outgoing Edges indexed by Directions from a node.  In addition, there is a concept of Items. An Item belongs to something, either a Node, another Item, the Cursor, or it belongs to nothing (the Nil object). The motivation for Items is Zork-like text adventure games, in which a Node is a room, the Cursor is the player, and Directions are connections to other rooms.  Items can then be in a room, on the player, in or on another item, or nowhere (for a period of time).

The axioms are as folows:

\begin{enumerate}
\item There exists a unique Cursor object $c$.
\item There exists a unique Nil object $\epsilon$.
\item There exists a unique Node object $n$ such that $c\in{n}$.
\item For each Direction $d$ and Node object $n$, either $n.d=\epsilon$ or there exists a unique Node object $m$ such that $n.d=m$.
\item For each Item object $i$, exactly one of the following hold:
\begin{enumerate}
\item $i\in\epsilon$.
\item $i\in{c}$.
\item There exists a unique Node object $n$ such that $i\in{n}$
\item There exists a unique Item object $j$ such that $i\in{j}$
\end{enumerate}
\item There are no circular inclusions among items; that is for no sequence of Item objects $i_1, i_2, \dots, i_n$ does it happen that $i_1\in i_2 \in \cdots\in i_n\in i_1$.
\end{enumerate}

For practical purposes, some query operations are permitted:

\begin{enumerate}
\item If $n$ is a Node object, then $\mathrm{dir}(n)$ is a set containing all directions  $d$ such that $n.d\ne\epsilon$.
\item $\mathrm{loc}(c)$ is the unique Node object $n$ such that $n\in{c}$.
\item $\mathrm{loc}(i)=o$ is equal to the object $o$ which must be exactly one of the following:
\begin{enumerate}
\item $o=\epsilon$ if $i\in\epsilon$.
\item $o=n$ if $n$ is a Node object and $i\in{n}$.
\item $o=j$ if  $j$ is an Item object and $i\in{j}$.
\item $o=c$ if $i\in{c}$.
\end{enumerate}
\end{enumerate}

Optional operations provide more functionality:
\begin{enumerate}
\item If $n$ is a Node object, then $itm(n)$ is the set of all Item objects $i$ such that $i\in{n}$.
\item If $i$ is an Item object, then $itm(i)$ is the set of all Item objects $j$ such that $j\in{i}$
\item $itm(c)$ is the set of Item objects $i$ such that $i\in{c}$.
\item $itm(\epsilon)$ is the set of Item objects $i$ such that $i\in\epsilon$.
\item $itm()$ is the set of all Item objects.
\item $nod()$ is the set of all Node objects.
\end{enumerate}
\end{document}


\section{Observation model}
\label{sec:observationModel}
Figure \ref{fig:observModel} gives an overview of the Observation Model as implemented in the current version of PharmML, which covers only continuous data models. A future release will cover discrete data models, such as categorical, count and time-to-event (greyed out in the figure).
\begin{figure}[h!]
\centering
 \includegraphics[height=75mm]{observationalModel}
\caption{Observation Model}
\label{fig:observModel}
\end{figure}
An essential component of the Observation Model is the Residual Error Model, which applies only to continuous data models.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Residual error model}
\label{sec:residualErrorModel}
\label{maths:error_model}
\label{maths:combined-err-model}
In this section we consider different forms of the residual error, i.e. this section is about $g$ in the term
\begin{align*}
g(x_{ij}, \psi_{i}, \xi) \epsilon_{ij}
\end{align*}
of eq.\ref{eq:nlmeModel} with $\epsilon_{ij} \sim N(0, 1)$, i.e. a standard normally distributed random variable. We distinguish between
\begin{itemize}\addtolength{\itemsep}{-.95\baselineskip}
\item
models for \textbf{untransformed} data
\begin{align*}
 \underbrace{ y_{ij}}_{\text{\parbox{2cm}{\centering Experimental \\[-4pt]  data}}} =
 \underbrace{ f(x_{ij}, \psi_{i})}_{\text{\parbox{2.5cm}{\centering Model \\[-4pt]  prediction}}} +
 \underbrace{ g(x_{ij}, \psi_{i}, \xi_i) \; \epsilon_{ij}}_{\text{\parbox{3cm}{\centering Residual \\[-4pt] error}}}
 \end{align*}
 \item
\textbf{transform-both-sides} models
\begin{eqnarray}
 \underbrace{ u(y_{ij})}_{\text{\parbox{2cm}{\centering Transformed \\[-4pt] experimental \\[-4pt]  data}}} =
 \underbrace{ u\big(f(x_{ij}, \psi_{i})\big)}_{\text{\parbox{2.5cm}{\centering Transformed \\[-4pt]  model \\[-4pt]  prediction}}} +
 \underbrace{ g(x_{ij}, \psi_{i}, \xi_i) \; \epsilon_{ij}}_{\text{\parbox{3cm}{\centering Residual \\[-4pt] error}}} \nonumber
 \end{eqnarray}
 \item
and \textbf{implicit} models
\begin{eqnarray}
 \underbrace{ u(y_{ij})}_{\text{\parbox{2.5cm}{\centering Transformed \\[-4pt] experimental  data}}} =
 \underbrace{ U\big(f(x_{ij}, \psi_{i}),\xi_i, \epsilon_{1,ij}, \epsilon_{2,ij}, \dots\big)}_{\text{\parbox{2.5cm}{\centering Transformed \\[-4pt]  model prediction}}}
 \end{eqnarray}
\end{itemize}
The \textit{untransformed} form is a special case of the \textit{transform-both-sides} form with $u \equiv Id$, i.e. the identity transformation.
Then for models of both types with $\epsilon_{ij}$ being normally distributed with mean 0 and variance 1, $u(y_{ij})$ is also normally distributed
with mean $u(f(x_{ij}, \psi_{i}))$ and the standard deviation $g(x_{ij}, \psi_{i}, \xi_i)$. \\
Possible extensions to the basic models are
\begin{itemize}
\item
when more than one random variable is applied, i.e. multiple $\epsilon$'s,
\item
when more than one type of measurement or observation is defined, or
\item
when variability, as discussed in section \ref{sec:variabilityModel}, is applied to parameters of the residual error model (see section \ref{subsec:varModelResidualError} for details).
\end{itemize}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Incorporating variability on the residual error model parameters}
\label{subsec:varModelResidualError}
In analogy to the nested hierarchical structure for the variability on the individual parameters,
variability on residual error model parameters can be defined using the same structure.
By doing so, no new structure is necessary to account for any inter-individual and/or inter-occasion variability of the residual error model parameters.

This allows \pharmml to cover the so-called 'ETA-on-EPS' approach -- e.g. IIV on the residual error model parameters or in other words varying residual
error magnitude between individuals, see Figure \ref{fig:IOV0_residualError}.
\begin{figure}[htb!]
\centering
  \includegraphics[width=125mm]{pics/IOV0_residualError}
 \caption{Inter-individual variability of the residual error parameter $a$. The nested hierarchical structure is identical to that of structural model parameters.}
 \label{fig:IOV0_residualError}
\end{figure}
For example, if an additive residual error model and a log-normal distribution for $a$ is assumed, then the parameter model reads
\begin{align*}
	& \log(a_i) = \log(a_{pop}) + \eta_a, \quad  \eta_a \sim \mathcal{N}(0,\omega_a^2)
\end{align*}
and the observation model reads
\begin{align*}
	& y_{ij} \sim \mathcal{N}(f_{ij},a_i^2): \quad y_{ij} = f_{ij} + a_i \epsilon_{ij}, \quad \epsilon_{ij} \sim \mathcal{N}(0,1).
\end{align*}
%See also section \ref{modelKK_RM1} for three IIV and IOV examples with NMTRAN and MLXTRAN code.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Residual error model examples}
\label{subsec:modelExamples}
Currently, there is no library of residual error models but this might change in the future. All of the following residual error model examples and their different versions can be implemented in the present version of PharmML:
\begin{itemize}
\item
Constant/additive:
\begin{align*}
& y_{ij} = f_{ij} + a \; \epsilon_{ij}; \quad \epsilon_{ij} \sim N(0,1)  \\
\text{or} \quad & y_{ij} = f_{ij} + \epsilon_{ij}; \quad \epsilon_{ij} \sim N(0,\sigma^2)
\end{align*}
\item
Proportional or constant CV (CCV):
\begin{align*}
&y_{ij} =  f_{ij} + bf_{ij} \; \epsilon_{ij}; \quad \epsilon_{ij} \sim N(0,1)  \\
\text{or} \quad & y_{ij} =  f_{ij}(1+\epsilon_{ij}); \quad \epsilon_{ij} \sim N(0,\sigma^2)
\end{align*}
\item
Combined additive and proportional 1:
\begin{align*}
& y_{ij} =  f_{ij} + (a + bf_{ij}) \; \epsilon_{ij}; \quad \epsilon_{ij} \sim N(0,1)
\end{align*}
\item
Combined additive and proportional 2:
\begin{align*}
& y_{ij} =  f_{ij} + \sqrt{a^2 + b^2f_{ij}^2} \; \epsilon_{ij}; \quad \epsilon_{ij} \sim N(0,1)  \\
\text{or}  \quad & y_{ij} =  f_{ij} +  a\, \epsilon_{1,ij} + b f_{ij}\, \epsilon_{2,ij}; \quad \epsilon_{1,ij} \sim N(0,1); \quad \epsilon_{2,ij} \sim N(0,1);   \\
\text{or}  \quad & y_{ij} =  f_{ij} (1 + \epsilon_{1,ij}) + \epsilon_{2,ij}; \quad \epsilon_{1,ij} \sim N(0,\sigma_1^2); \quad \epsilon_{2,ij} \sim N(0,\sigma_2^2);
\end{align*}
\item
Power error model:
\begin{align*}
& y_{ij} = f_{ij} + b\,f_{ij}^c \; \epsilon_{ij}; \quad \epsilon_{ij} \sim N(0,1)
\end{align*}
\item
Combined additive and power error model 1:
\begin{align*}
& y_{ij} =  f_{ij} + (a + b f_{ij}^c) \; \epsilon_{ij}; \quad \epsilon_{ij} \sim N(0,1)
\end{align*}
\item
Combined additive and power error model 2:
\begin{align*}
& y_{ij} = f_{ij} + a\epsilon_{1,ij} + b f_{ij}^c \epsilon_{2,ij}; \quad \epsilon_{1,ij} \sim N(0,1); \quad \epsilon_{2,ij} \sim N(0,1)
\end{align*}
\item
Two (or more) types of measurements error model:
\begin{align*}
& y_{ij} = f_{ij} + \text{ASY}_j\epsilon_{1,ij} + (1-\text{ASY}_j) \epsilon_{2,ij}; \quad \epsilon_{1,ij} \sim N(0,\sigma_1^2); \quad \epsilon_{2,ij} \sim N(0,\sigma_2^2)
\end{align*}
\item
Two (or more) types of observations error model:
\begin{align*}
& y_{ij} = \text{TYP}_{ij} f_{1,ij} + (1-\text{TYP}_{ij}) f_{2,ij} + \text{TYP}_{ij}\epsilon_{1,ij} + (1-\text{TYP}_{ij}) \epsilon_{2,ij};  \\
&  \epsilon_{1,ij} \sim N(0,\sigma_1^2); \quad \epsilon_{2,ij} \sim N(0,\sigma_2^2)
\end{align*}
%\item
%Extended error model:
%
%y_{ij} = \left\{ \begin{array}{rcl}  f_{ij} + \epsilon_{1,ij}  & \mbox{for} & \text{TIME == 1 \&\& ID == 1} \\
%f_{ij} + \epsilon_{2,ij}  & \mbox{for} & \text{TIME == 2 \&\& ID == 1} \\
%\cdots \end{array}\right\} \quad \text{with} \quad
%\epsilon_{1,ij} \sim N(0,\sigma_1^2),\, \epsilon_{2,ij} \sim N(0,\sigma_2^2), \cdots
%
\end{itemize}
Main sources: \cite{NONMEM:2006aa} and \cite{POPIX:2013}.

\subparagraph{Note 1}
In the list above models are pulled together which have the same variance function.
\subparagraph{Note 2}
Models listed above are the most popular ones in use but the present PharmML structure allows for implementation of virtually any user-defined model. See section ref:XYZ for more examples and PharmML implementation.

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\subsection{PharmML implementation}
%Some of the above listed residual error model types have two or three equivalent forms, by which we mean they have the same variance, although they use one or more residual errors, $\epsilon_{ij}$. Other types contain two or more predictions from the structural model, \var{f_{ij}}. From a
%computational point of view it makes a lot of sense to reflect such differences in the language structure.
%This was the motivation to allow for the implementation of two types of observation models
%\begin{itemize}
%\item
%\xelem{Standard} -- any observation model of the form
%\begin{align*}
%	u(y_{ij}) = u(f_{ij}) + g\times\epsilon_{ij}
%\end{align*}
%which can be defined using exactly one of the following items
%\begin{itemize}
%\item
%a transformation, $u$, e.g. \var{log} or \var{logit}
%\item
%one structural model prediction, \var{f_{ij}}
%\item
%one standard deviation function, \var{g}
%\item
%one random variable, $\epsilon_{ij}$
%\end{itemize}
%\item
%\xelem{General} -- using any number of the items listed above and arbitrary functional relationship between them.
%\end{itemize}
%Chapter \ref{chap:worked-egs} contains a number of examples illustrating these constructs.

%\begin{itemize}
%\item
%standard -- defined in the spec as \xelem{Standard} with following child elements
%\begin{itemize}
%\item
%\item
%\item
%\end{itemize}
%\item
%general -- defined in the spec as \xelem{General}.
%\end{itemize}

%The residual errors are part of the \textit{Observations Model}, see section \ref{sec:eg1-obs-model} for detailed discussion.
%The following table contains some of the models which can be implemented in \pharmml:
%
%\begin{table}[htdp]
%\begin{center}
%\begin{tabular}{l c c}
%Model name & $g$ & $\xi$ \\
%\hline \hline
%Constant error model & $a$ & $a$ \\
%Proportional error model & $bf$ & $b$ \\
%Combined error model & $a + bf$ & $a,b$ \\
%Alternative combined error model 1& $\sqrt{a^2 + b^2f^2}$ & $a,b$ \\
%Alternative combined error model 2 & $a + bf^c$ & $a, b, c$
%\end{tabular}
%\end{center}
%\caption{Examples of residual error models which can be implemented in \pharmml.}
%\label{tab:residualModels}
%\end{table}%