\longsection{%
  \texorpdfstring{%
    Hierarchization on Spatially Adaptive Sparse Grids\\
    with the Unidirectional Principle%
  }{%
    Hierarchization on Spatially Adaptive Sparse Grids
    with the Unidirectional Principle%
  }%
}{%
  Hierarchization on Spatially Adaptive Sparse Grids
  with the Unidirectional Principle%
}{%
  Hierarchization with the Unidirectional Principle%
}
\label{sec:45spatAdaptiveUP}

\minitoc{90mm}{9}

\noindent
In this final section of the chapter,
we further decrease the computational complexity
for the application of the linear operator $\linop$
on spatially adaptive sparse grids
from quadratic to linear time with two algorithms based on the \up.

\subsection{%
  Iteratively Applying the Unidirectional Principle with Iterative Refinement%
}
\label{sec:451iterativeRefinement}

The first algorithm can be applied if two requirements are met:
\begin{itemize}
  \item
  The inverse $\linop^{-1}$ is known and can be efficiently applied.

  \item
  There is an operator $\linop'$
  that is ``sufficiently close'' to $\linop$ and can be efficiently applied.
\end{itemize}
For hierarchization with B-splines on sparse grids,
we choose $\linop$ to be the hierarchization
operator given in \cref{eq:hierarchizationSLE} and
$\linop'$ to be the \up directly applied on the
sparse grid.
Both of the assumptions are then satisfied,
as $\linop^{-1}$ is known
(interpolation matrix $\intpmat$ of basis function evaluations)
and $\linop^{-1}$ and $\linop'$ can be applied fast.
The \up $\linop'$ generally produces wrong
results for hierarchical B-splines due to missing coupling points.
However, especially for low B-spline degrees,
$\linop'$ does not deviate too much from the true operator $\linop$.
Below, we will specify a sufficient criterion for the ``closeness.''

\paragraph{Iterative refinement}

Under the two assumptions above, we can apply the procedure given in
\cref{alg:iterativeRefinement}.
The algorithm is equivalent to the well-known method of
\term{iterative refinement,} which has been developed to
stabilize the numerical solution of a linear system
influenced by rounding errors \cite{Higham02Accuracy}.
The operator $\linop'$ acts like a preconditioner,
which is why it is required to be close to $\linop$.
Note that the algorithm is similar to the repeated application
of the method of residual interpolation
(see \cref{sec:433residualInterpolation}) on the whole sparse grid.

\begin{algorithm}
  \begin{algorithmic}[1]
    \Function{$\vlinout = \texttt{iterativeRefinement}$}{%
      $\vlinin$, $\vlinout[(0)]$%
    }
      \State{$\*r^{(0)} \gets \vlinin - \linop^{-1}\vlinout[(0)]$}
      \Comment{initial residual}%
      \For{$m = 0, 1, 2, \dotsc$}
        \State{$\vlinout[(m+1)] \gets \vlinout[(m)] + \linop' \*r^{(m)}$}
        \Comment{update solution}%
        \State{$\*r^{(m+1)} \gets \*r^{(m)} - \linop^{-1} \linop' \*r^{(m)}$}
        \Comment{update residual}%
      \EndFor{}
      \vspace{-1mm}
      \State{$\vlinout \gets \text{last computed } \vlinout[(m)]$}
    \EndFunction{}
  \end{algorithmic}
  \caption[%
    Iterative refinement%
  ]{%
    Application of a tensor product operator $\linop$
    on spatially adaptive sparse grids with iterative refinement,
    where $\linop'$ is an approximation of $\linop$.
    Inputs are the vector $\vlinin = (\linin{\*l,\*i})_{(\*l,\*i) \in \liset}$
    of input data (function values $\fcnval{\*l,\*i}$ at the grid points) and
    an initial solution $\vlinout[(0)]$.
    The output is the vector
    $\vlinout = (\linout{\*l,\*i})_{(\*l,\*i) \in \liset}$
    of output data (hierarchical surpluses $\surplus{\*l,\*i}$).%
  }%
  \label{alg:iterativeRefinement}%
\end{algorithm}

The loop in \cref{alg:iterativeRefinement} has to be terminated
after some iterations.
The following simple lemma allows to use a stopping criterion based on the
size of the residual $\*r^{(m)}$ to the true solution,
which we denote with $\vlinout[\ast] \ceq \linop \vlinin$.

\begin{shortlemma}[equivalent convergence for iterative refinement]
  \label{lemma:iterativeRefinementEquivalent}
  In \cref{alg:iterativeRefinement}, we have
  $\vlinout[(m)] \to \vlinout[\ast] \iff \*r^{(m)} \to \*0$ for
  $m \to \infty$.
\end{shortlemma}

\vspace{-0.5em}

\begin{proof}
  It suffices to prove $\linop \*r^{(m)} = \vlinout[\ast] - \vlinout[(m)]$
  for $m \in \nat$ by induction.
  For $m = 0$, we have
  $\linop \*r^{(0)}
  = \linop \vlinin - \linop \linop^{-1} \vlinout[(0)]
  = \vlinout[\ast] - \vlinout[(0)]$.
  For $m \to m+1$, it holds
  $\linop \*r^{(m+1)}
  = \linop \*r^{(m)} - \linop \linop^{-1} \linop' \*r^{(m)}
  = (\vlinout[\ast] - \vlinout[(m)]) - \linop' \*r^{(m)}
  = \vlinout[\ast] - \vlinout[(m+1)]$.
\end{proof}

\vspace{0.5em}

\noindent
Next, we give a sufficient condition for the
convergence of \cref{alg:iterativeRefinement} to the true solution.

\vspace{0.5em}

\begin{proposition}[%
  sufficient condition for the convergence of
  {\hyperref[alg:iterativeRefinement]{Alg.\ \ref*{alg:iterativeRefinement}}}%
]
  \label{prop:iterativeRefinementSufficient}
  If we have $\limsup_{m \to \infty}
  \sqrt[m]{\norm{(\idop - \linop^{-1} \linop')^m}} < 1$
  with an arbitrary operator matrix norm $\norm{\cdot}$ and the
  identity operator $\idop$,
  then $\vlinout[(m)] \to \vlinout[\ast]$ for $m \to \infty$
  in \cref{alg:iterativeRefinement}
  for every initial solution $\vlinout[(0)]$.
\end{proposition}

\vspace{-0.5em}

\begin{proof}
  A short proof by induction shows that
  \begin{equation}
    \label{eq:proofPropIterativeRefinementSufficient}
    \vlinout[(m)]
    = \vlinout[(0)] + \linop'
    \sum_{m'=0}^{m-1} (\idop - \linop^{-1} \linop')^{m'} \*r^{(0)},
  \end{equation}
  where $(\idop - \linop^{-1} \linop')^{m'} \*r^{(0)} = \*r^{(m')}$.
  For $m \to \infty$ and with the assumption on
  $\norm{(\idop - \linop^{-1} \linop')^m}$,
  the sum converges to the Neumann series
  $\sum_{m'=0}^\infty (\idop - \linop^{-1} \linop')^{m'}
  = (\idop - (\idop - \linop^{-1} \linop'))^{-1} = (\linop')^{-1} \linop$
  (see, e.g., \cite{Werner11Funktionalanalysis}).
  In this case, we infer that the limit of $\vlinout[(m)]$ is given by
  \begin{equation}
    \vlinout[(0)] + \linop' (\linop')^{-1} \linop \*r^{(0)}
    = \vlinout[(0)] + \linop \vlinin - \linop \linop^{-1} \vlinout[(0)]
    = \linop \vlinin
    = \vlinout[\ast],
  \end{equation}
  as claimed.
\end{proof}

The sufficient condition given in \cref{prop:iterativeRefinementSufficient}
is quite strong, as it can be shown that $\limsup_{m \to \infty}
\sqrt[m]{\norm{(\idop - \linop^{-1} \linop')^m}} \le 1$ is necessary for
convergence.
Unfortunately, in the case of hierarchization with B-splines,
numerical experiments show that
this condition is only met for low dimensionalities $d$ and low
B-spline degrees $p$.
\Cref{alg:iterativeRefinement} generally diverges
for higher dimensionalities or higher degrees.

\subsection{Duality of the Unidirectional Principle}
\label{sec:452duality}

To motivate the second algorithm that we present in this section,
we study why we cannot directly apply the \up
(as introduced in \cref{alg:unidirectionalPrinciple})
on spatially adaptive sparse grids.
As before, we denote with $\liset$ the level-index set of
the spatially adaptive sparse grid (see \cref{sec:41problem}).

The \up\punctfix{,} as stated in
\cref{alg:unidirectionalPrinciple} for full grids,
subsequently applies one-dimensional operators
$\upopuv{t_j}{\lisetpole}\colon \real^{\setsize{\lisetpole}} \to
\real^{\setsize{\lisetpole}}$
on the poles $\lisetpole$ of the sparse grid at hand,
iterating over a permutation $t_1, \dotsc, t_d$
of the dimensions $1, \dotsc, d$.
We recall the pole equivalence relation $\samepole{t_j}$
from \cref{eq:poleEquivalenceRelation}:
Two points $\*k', \*k'' \in \liset$ are $\samepole{t_j}$-equivalent,
if $\*k'$ is contained in the pole through $\*k''$
with respect to the $t_j$-th dimension, i.e.,
\begin{equation}
  \*k' \samepole{t_j} \*k'' \iff \*k'_{-t_j} = \*k''_{-t_j},\quad
  \*k', \*k'' \in \liset.
\end{equation}

\paragraph{Operators for the unidirectional principle}

The combined application of all one-di\-men\-sional operators
$\upopuv{t_j}{\lisetpole}$
($\lisetpole \in \eqclasses{\liset}{\samepole{t_j}}$)
of the $j$-th iteration of \cref{alg:unidirectionalPrinciple}
is equivalent to a single application of the following operator
$\upop{t_j}\colon \real^{\setsize{\liset}} \to \real^{\setsize{\liset}}$:
\begin{equation}
  \label{eq:upopEntries}
  (\upop{t_j})_{\*k'',\*k'}
  \ceq
  \begin{cases}
    (\upopuv{t_j}{\lisetpole})_{k''_{t_j},k'_{t_j}},&
    \ex{\lisetpole \in \eqclasses{\liset}{\samepole{t_j}}}{
      \*k', \*k'' \in \lisetpole
    },\\
    0,&\*k' \not\samepole{t_j} \*k'',
  \end{cases}
\end{equation}
where $(\upop{t_j})_{\*k'',\*k'}$ denotes the entry of row $\*k''$
and column $\*k'$ of the matrix corresponding to $\upop{t_j}$
(similar for $(\upopuv{t_j}{\lisetpole})_{k''_{t_j},k'_{t_j}}$).
The reason for this equivalence is that
the poles $\lisetpole$ are pairwise disjoint equivalence classes.
Consequently, every point $\*k$ is only acted upon by a single
one-dimensional operator $\upopuv{t_j}{\lisetpole}$,
namely the one with $\lisetpole = \eqclass{\*k}{\samepole{t_j}}$.
This leads to the block-diagonal structure
of $\upop{t_j}$ given in \eqref{eq:upopEntries},
if the rows of the matrix of $\upop{t_j}$
are grouped by poles $\lisetpole$ and the columns are arranged accordingly.

\paragraph{Correctness and duality of the unidirectional principle}

For the remaining considerations, we assume that
the operators $\linop$ and $\upopuv{t_j}{\lisetpole}$ are invertible.
In this case, $\upop{t_j}$ is also invertible and
$\upopinv{t_j}$ is given by the block-diagonal matrix composed of
the inverses of the blocks $\upopuv{t_j}{\lisetpole}$ of $\upop{t_j}$.
This is satisfied by dehierarchization operators $\intpmat$ due to the
linear independence of the hierarchical basis functions.

We are now able to describe the whole \up of
\cref{alg:unidirectionalPrinciple} as the operator
$\upop{t_1,\dotsc,t_d}\colon \real^{\setsize{\liset}} \to
\real^{\setsize{\liset}}$ given by
\begin{equation}
  \label{eq:upopProduct}
  \upop{t_1,\dotsc,t_d}
  \ceq \upop{t_d} \dotsm \upop{t_1}.
\end{equation}
The right-most operator is $\upop{t_1}$, since it is applied first.
We say that the \up is \term{correct} for $\linop$ and
$(t_1, \dotsc, t_d)$, if
\begin{equation}
  \upop{t_1,\dotsc,t_d}
  \overset{?}{=} \linop.
\end{equation}
This relation is not satisfied in general,
especially for B-spline hierarchization with the operator
$\linop = \intpmatinv$.
However, for operators like these, whose inverse
$\linopinv = \intpmat$ can be described and applied much easier,
we can make use of the so-called \term{duality of the \up:}

\begin{lemma}[duality of the unidirectional principle]
  \label{lemma:dualityUnidirectionalPrinciple}
  Let the operators $\linop$ and $\upopuv{t_j}{\lisetpole}$ be invertible
  for all poles $\lisetpole$ in $\liset$.
  Then the \up is correct for $\linop$ and $(t_1, \dotsc, t_d)$
  if and only if the \up is correct for $\linopinv$ and $(t_d, \dotsc, t_1)$.
\end{lemma}

\begin{proof}
  The correctness of the \up for $\linop$ and $(t_1, \dotsc, t_d)$
  is by definition equivalent to
  \begin{equation}
    \upop{t_d} \dotsm \upop{t_1} = \linop.
  \end{equation}
  By inverting both sides, we obtain the definition of the
  correctness of the \up for $\linopinv$ and $(t_d, \dotsc, t_1)$.
\end{proof}

This duality means that in order to establish the correctness of $\linop$
for some arbitrary permutation $(t_1, \dotsc, t_d)$ of $1, \dotsc, d$,
it suffices to establish the \up's correctness for the
inverse operator $\linopinv$ and the reverse permutation $(t_d, \dotsc, t_1)$.
This is especially of interest for our main application,
the hierarchization operator $\linop = \intpmatinv$ for B-splines.

\subsection{Chains and Equivalent Correctness Conditions}
\label{sec:453chains}

We first define the notion of a chain between two grid points
$\*k'$ and $\*k''$.

\begin{definition}[chain]
  \label{def:chain}
  Let $\*k', \*k'' \in \liset$ and
  $(t_1, \dotsc, t_j)$ be a permutation of $j$ of the
  dimensions $1, \dotsc, d$.
  We define the \term{chain} from $\*k'$ to $\*k''$ with respect to
  $(t_1, \dotsc, t_j)$ as the sequence
  $(\chain{0}, \dotsc, \chain{j})$, where
  \begin{equation}
    \chain{j'}_{T_{j'}}
    \ceq \*k''_{T_{j'}},\quad
    \chain{j'}_{-T_{j'}}
    \ceq \*k'_{-T_{j'}},\quad
    T_{j'}
    \ceq (t_1, \dotsc, t_{j'}),\quad
    j' = 0, \dotsc, j,
    \hspace*{-10mm}
  \end{equation}
  if $\chain{j} = \*k''$ and
  $\chain{j'} \in \liset$ for all $j' = 0, \dotsc, j$.
\end{definition}

This definition is equivalent to
$\chain{j'-1} \samepole{t_{j'}} \chain{j'}$ for $j' = 1, \dotsc, j$.
\Cref{fig:chainDefinition} shows examples of chains in
two and three dimensions.
As it is shown in \cref{fig:chainDefinition2},
the order $(t_1, \dotsc, t_j)$ of the dimensions is important
for whether the grid contains the chain from $\*k'$ to $\*k''$.
The grid must contain all intermediate points, otherwise
it is not a chain.

\begin{figure}
  \subcaptionbox{%
    $d = 2$, $(t_1, t_2) = (2, 1)$%
  }[47mm]{%
    \includegraphics{chainDefinition_1}%
  }%
  \hfill%
  \subcaptionbox{%
    $d = 2$, $(t_1, t_2) = (1, 2)$%
    \label{fig:chainDefinition2}%
  }[47mm]{%
    \includegraphics{chainDefinition_2}%
  }%
  \hfill%
  \subcaptionbox{%
    $d = 3$, $(t_1, t_2, t_3) = (2, 3, 1)$%
  }[50mm]{%
    \includegraphics{chainDefinition_3}%
  }%
  \caption[%
    Examples for the definition of chains%
  ]{%
    Examples for chains in two and three dimensions.
    \emph{Left:} A chain from $\chain{0}$ to $\chain{2}$
    with respect to $(t_1, t_2) = (2, 1)$ in a two-dimensional sparse grid.
    \emph{Center:}
    With respect to the reverse permutation
    $(t_1, t_2) = (1, 2)$ of the dimensions,
    there is no chain from $\chain{0}$ to $\chain{2}$,
    because the corresponding chain point $\chain{1}$ is missing in the grid.
    \emph{Right:} A chain in three dimensions.%
  }%
  \label{fig:chainDefinition}%
\end{figure}

We now show two lemmas.
First, we prove that $(\upop{t_1,\dotsc,t_j})_{\*k'',\*k'} \not= 0$
is sufficient for the existence of a chain from $\*k'$ to $\*k''$:

\begin{restatable}[sufficient condition for chain existence]{%
  lemma%
}{%
  lemmaChainExistenceSufficient%
}
  \label{lemma:chainExistenceSufficient}
  If $(\upop{t_1,\dotsc,t_j})_{\*k'',\*k'} \not= 0$
  for some $j = 0, \dotsc, d$,
  then the grid $\liset$ contains the chain from $\*k'$ to $\*k''$
  with respect to $(t_1, \dotsc, t_j)$.
\end{restatable}

\vspace{-0.5em}

\begin{proof}
  See \cref{sec:a134proofCorrectnessUnidirectionalPrincipleSASG}.
\end{proof}

\vspace{0.5em}

Second, we show that the equality of
$(\upop{t_1,\dotsc,t_j})_{\chain{j},\*k'}$ and the product of
the one-dimensional operators is necessary for the
existence of a chain from $\*k'$ to $\*k''$:

\begin{restatable}[necessary condition for chain existence]{%
  lemma%
}{%
  lemmaChainExistenceNecessary%
}
  \label{lemma:chainExistenceNecessary}
  If the grid $\liset$ contains the chain $(\chain{0}, \dotsc, \chain{j})$
  from $\*k'$ to $\*k''$ with respect to $(t_1, \dotsc, t_j)$
  for some $j = 0, \dotsc, d$, then
  \begin{equation}
    \label{eq:lemmaChainExistenceNecessary}
    (\upop{t_1,\dotsc,t_j})_{\chain{j},\*k'}
    = (\upopuv{t_1}{\eqclass{\chain{1}}{\samepole{t_1}}})_{k''_{t_1},k'_{t_1}}
    \dotsm
    (\upopuv{t_j}{\eqclass{\chain{j}}{\samepole{t_j}}})_{k''_{t_j},k'_{t_j}}.
  \end{equation}
\end{restatable}

\vspace{-0.5em}

\begin{proof}
  See \cref{sec:a134proofCorrectnessUnidirectionalPrincipleSASG}.
\end{proof}

\vspace{0.5em}

These two lemmas can be used to prove the following characterization
of the correctness of the \up\punctfix{.}
Here, we need an additional assumption on the structure of the
operator $\linop$, which we call \term{tensor product structure:}

\begin{restatable}[characterization of the correctness of the UP]{%
  proposition%
}{%
  propCorrectnessUPCharacterization%
}
  \label{prop:correctnessUPCharacterization}
  Let $\linop$ have tensor product structure:
  For all $\*k', \*k'' \in \liset$ with the chain
  $(\chain{0}, \dotsc, \chain{d})$ from $\*k'$ to $\*k''$
  with respect to $(t_1, \dotsc, t_d)$,
  we assume that
  \begin{equation}
    \label{eq:tensorProductOperator}
    (\linop)_{\*k'',\*k'}
    = \prod_{j=1}^d
    (\upopuv{t_j}{\eqclass{\chain{j}}{\samepole{t_j}}})_{k''_{t_j},k'_{t_j}}.
  \end{equation}
  Then the \up is correct for $\linop$ and $(t_1, \dotsc, t_d)$
  if and only if the grid $\liset$ contains the chain from $\*k'$ to $\*k''$
  with respect to $(t_1, \dotsc, t_d)$ for all $\*k', \*k'' \in \liset$
  for which $(\linop)_{\*k'',\*k'} \not= 0$.
\end{restatable}

\vspace{-0.5em}

\begin{proof}
  See \cref{sec:a134proofCorrectnessUnidirectionalPrincipleSASG}.
\end{proof}

\vspace{0.5em}

When applied to the hierarchization operator,
the combination of \cref{prop:correctnessUPCharacterization} with
\thmref{lemma:dualityUnidirectionalPrinciple} can be summarized in
the following corollary:

\begin{corollary}[%
  equivalent statements for correctness of UP for hierarchization%
]
  \label{cor:equivalentCorrectnessUPHierarchization}
  The following statements are equivalent:
  \begin{itemize}
    \item
    The \up is correct for $\intpmatinv$ and $(t_1, \dotsc, t_d)$.

    \item
    The \up is correct for $\intpmat$ and $(t_d, \dotsc, t_1)$.

    \item
    The grid $\liset$ contains the chain from $\*k'$ to $\*k''$
    with respect to $(t_d, \dotsc, t_1)$ for all $\*k', \*k'' \in \liset$
    for which $\basis{\*k'}(\gp{\*k''}) \not= 0$.
  \end{itemize}
\end{corollary}

\begin{proof}
  The corollary is a direct consequence of
  \cref{lemma:dualityUnidirectionalPrinciple} and
  \cref{prop:correctnessUPCharacterization},
  applied to the dehierarchization operator $\linop = \intpmat$.

  The assumption of \cref{lemma:dualityUnidirectionalPrinciple}
  is satisfied:
  The operators $\upopuv{t_j}{\lisetpole}$ are invertible
  for all poles $\lisetpole$ in $\liset$
  due to the uniqueness of univariate interpolants
  (linear independence of the basis functions).
  Similarly, $\linop$ is invertible
  due to the uniqueness of multivariate interpolants.
  In addition, the assumption of \cref{prop:correctnessUPCharacterization}
  is satisfied, since
  \begin{equation}
    (\linop)_{\*k'',\*k'}
    = (\intpmat)_{\*k'',\*k'}
    = \prod_{j=1}^d \basis{k'_{t_j}}(\gp{k''_{t_j}})
    = \prod_{j=1}^d
    (\upopuv{t_j}{\eqclass{\chain{j}}{\samepole{t_j}}})_{k''_{t_j},k'_{t_j}}
  \end{equation}
  due to the tensor product basis functions.
\end{proof}

\paragraph{Inserting chain points}

This means that we can establish the correctness of the \up
for the hierarchization operator $\linop = \intpmatinv$,
if we insert all missing chain points that are specified by
\cref{prop:correctnessUPCharacterization} into the grid.

We take the case $p = 1$ of piecewise linear
standard B-splines $\bspl{\*l,\*i}{1}$ as an example.
We assume that we iteratively generated a spatially adaptive sparse grid
such that all grid points are reachable from the corners of $\clint{\*0, \*1}$
in the sense of \cref{eq:bfsAssumption2}.
If we want to ensure the correctness of the \up for all possible permutations
$(t_1, \dotsc, t_d)$ of the dimensions $(1, \dotsc, d)$,
then the existence of the necessary chains in
\cref{cor:equivalentCorrectnessUPHierarchization} is equivalent to the
requirement that the grid should contain
the hierarchical ancestors of every grid point in every direction:
\begin{subequations}
  \begin{alignat}{4}
    \fafa{(\*l',\*i') \in \liset}{\{t = 1, \dotsc, d \mid l'_t > 1\}}{
      (\*l,\*i) \in \liset
    },\quad
    &&&\*l \ceq \*l' - \stdbasis{t},\quad
    &&i_t \ceq 2 \floor{\tfrac{i'_t}{4}} + 1,\quad
    &&\*i_{-t} = \*i'_{-t},\\
    \fafa{(\*l',\*i') \in \liset}{\{t = 1, \dotsc, d \mid l'_t = 1\}}{
      (\*l,\*i) \in \liset
    },\quad
    &&&\*l \ceq \*l' - \stdbasis{t},\quad
    &&i_t \ceq 0,\quad
    &&\*i_{-t} = \*i'_{-t},
  \end{alignat}
\end{subequations}
where $\stdbasis{t}$ is the $t$-th standard basis vector.
This is a standard assumption on spatially adaptive sparse grids with
piecewise linear basis functions \cite{Pflueger10Spatially}.
However, we only have to satisfy the conditions of
\cref{cor:equivalentCorrectnessUPHierarchization} for a single permutation
$(t_1, \dotsc, t_d)$ of the dimensions
in order to hierarchize with the \up\punctfix{.}
\Cref{fig:chainInsertionBSpline} shows the necessary ancestor chain points
(colored points in \cref{fig:chainInsertionBSpline2})
for an example of a two-dimensional spatially adaptive sparse grid
(\cref{fig:chainInsertionBSpline1}).

\begin{figure}
  \subcaptionbox{%
    Original grid ($N = 85$)%
    \label{fig:chainInsertionBSpline1}%
  }[48mm]{%
    \includegraphics{chainInsertion_1}%
  }%
  \hfill%
  \subcaptionbox{%
    Chain points for $p = 1$\\
    \rlap{\hspace*{10.5mm}($N = 121$)}%
    \label{fig:chainInsertionBSpline2}%
  }[48mm]{%
    \includegraphics{chainInsertion_2}%
  }%
  \hfill%
  \subcaptionbox{%
    Chain points for $p = 3$\\
    \rlap{\hspace*{10.5mm}($N = 289 = 17 \times 17$)}%
    \label{fig:chainInsertionBSpline3}%
  }[48mm]{%
    \includegraphics{chainInsertion_3}%
  }%
  \caption[%
    Chain points for hierarchical B-splines on a sparse grid%
  ]{%
    Necessary chain points for the correctness of the unidirectional principle
    with respect to $(t_1, t_2) = (1, 2)$
    for hierarchical B-splines $\bspl{l,i}{p}$ on a
    two-dimensional spatially adaptive sparse grid.
    The colors indicate the recursion depth in which the
    chain points have been inserted.
    Black points are contained in the original grid
    (``zero-order points'').
    \textcolor{C0}{Blue points} are part of chains
    between original grid points (``first-order chain points'').
    \textcolor{C1}{Red points} are second-order chain points,
    i.e., they are part of chains
    from $\*k'$ to $\*k''$ where $\*k'$ and $\*k''$ are
    original grid points or first-order chain points
    and at least one of them is a first-order chain point.
    Analogously,
    \textcolor{C2}{brown points} are third-order chain points.
    $N$ is the number of points in the final grid.%
  }%
  \label{fig:chainInsertionBSpline}%
\end{figure}

Unfortunately, we have to insert these points recursively,
e.g., the inserted points may generate new chains,
for which other missing points have to be inserted and so on
(``higher-order chain points'' in \cref{fig:chainInsertionBSpline}).
Therefore, the number of points to be inserted may be large.
The worst case is that the final grid is a full grid, i.e.,
the Cartesian product of the union of the poles in the different dimensions:
\begin{equation}
  \paren*{\bigcup_{\*k \in \liset} \eqclass{\*k}{\samepole{1}}}
  \times \dotsb \times
  \paren*{\bigcup_{\*k \in \liset} \eqclass{\*k}{\samepole{d}}},
\end{equation}
i.e., we fully lose the advantage of sparse grids,
whose purpose is to ease the curse of dimensionality.
For the standard hierarchical B-spline basis $\bspl{l,i}{p}$,
this worst case often occurs as there are many non-zero entries
in the corresponding interpolation matrices $\intpmat$
(see \cref{sec:41problem} and \cref{fig:chainInsertionBSpline3}).

\subsection{Hierarchical Weakly Fundamental Splines}
\label{sec:454wfs}

\paragraph{Motivation}

In order to reduce the number of chain points to be inserted,
we have to use other spline bases such that
the resulting interpolation matrices $\intpmat$ have more zero entries.
The hierarchical fundamental splines
as introduced in \cref{sec:443fundamentalSplines} are one possibility.
However, they are globally supported, which implies a number
of disadvantages concerning the algorithms and the implementations.
The most significant disadvantage is that although
we can use \bfs for the univariate hierarchization operators,
the time complexity for the univariate hierarchization is still quadratic.
We search for a locally supported spline basis for which
the univariate hierarchization can be done in linear time.

To meet these goals, we have to relax the fundamental property
to a weaker version, which results in the so-called
\term{weakly fundamental property.}
A univariate hierarchical basis
$\wfundbasis{l',i'}\colon \clint{0, 1} \to \real$
is called \term{weakly fundamental,} if
\begin{equation}
  \label{eq:weaklyFundamentalProperty}
  \wfundbasis{l',i'}(\gp{l,i}) = 0,\quad
  l < l',\;\;
  i \in \hiset{l}.
\end{equation}
This is exactly the first condition \eqref{eq:fundamentalProperty1}
of the fundamental property \eqref{eq:fundamentalProperty}.
We drop the requirement that the basis functions
should vanish at the other grid points of the same level.
The relation \eqref{eq:fundamentalPropertyImplicationMV} from the
fundamental case becomes
\begin{equation}
  \label{eq:weaklyFundamentalPropertyImplicationMV}
  \wfundbasis{\*l',\*i'}(\gp{\*l,\*i})
  \not= 0
  \implies
  \*l' \le \*l,
\end{equation}
i.e., every basis function $\wfundbasis{\*l',\*i'}$
can only be non-zero at grid points $\gp{\*l,\*i}$ with
higher or equal level $\*l$.

\paragraph{Definition of hierarchical weakly fundamental splines}

We construct the \term{weakly fundamental spline parent function}
$\parentwfundspl{p}\colon \real \to \real$
by forming a linear combination of as few neighboring
uniform B-splines as possible such that $\parentwfundspl{p}$
satisfies the weakly fundamental property
\eqref{eq:weaklyFundamentalProperty}:
\begin{subequations}
  \begin{gather}
    \label{eq:weaklyFundamentalSplineParent}
    \parentwfundspl{p}(x)
    \ceq \largesum[(p-1)/2]{k=-(p-1)/2}
    \wfundsplcoeff{k}{p} \parentbspl{p}(x - k)
    \quad\text{such that}\\
    \wfundsplcoeff{0}{p} = 1,\quad
    \parentwfundspl{p}(k') = 0,\;\;
    k' = -p + 2,\; -p + 4,\; \dotsc,\; p - 2.
  \end{gather}
\end{subequations}
\usenotation{zzzzwfs}
\term{Hierarchical weakly fundamental splines}
$\bspl[\wfs]{l,i}{p}\colon \clint{0, 1} \to \real$
are now defined canonically via an affine parameter transformation:
\begin{equation}
  \bspl[\wfs]{l,i}{p}(x)
  \ceq \parentwfundspl{p}(\tfrac{x}{\ms{l}} - i),\quad
  l \ge 1.
\end{equation}
For $l = 0$, we define $\bspl[\wfs]{l,i}{p}$ to be the
linear Lagrange polynomial of level zero:%
\footnote{%
  This will simplify the description of the
  Hermite hierarchization algorithm in \cref{sec:455hermiteHierarchization}.%
}
\begin{equation}
  \bspl[\wfs]{0,i}{p}
  \ceq \lagrangepoly{0,i},\quad
  i = 0, 1.
\end{equation}
The hierarchical weakly fundamental spline basis is shown in
\cref{fig:hierarchicalWeaklyFundamentalSpline}.
Note that these basis functions are translation-invariant by construction
(starting with level $l \ge 1$).
As the weakly fundamental parent spline $\parentwfundspl{p}$
vanishes at all odd integers and as the
support of $\bspl[\wfs]{l,i}{p}$ is local
($\supp \bspl[\wfs]{l,i}{p}
= \clint{\gp{l,i-p}, \gp{l,i+p}} \cap \clint{0, 1}$),
this implies that the weakly fundamental property
\eqref{eq:weaklyFundamentalProperty} is fulfilled.

\begin{SCfigure}
  \includegraphics{hierarchicalBasis_17}%
  \caption[%
    Hierarchical weakly fundamental splines%
  ]{%
    Hierarchical cubic weakly
    \vspace{-0.1em}%
    fundamental splines
    $\bspl[\wfs]{l',i'}{p}$
    ($l' \le l$, $i' \in \hiset{l'}$, $p = 3$) and
    grid points $\gp{l',i'}$ \emph{(dots)} up to level $l = 3$.%
  }%
  \label{fig:hierarchicalWeaklyFundamentalSpline}%
\end{SCfigure}

\paragraph{Chain points for weakly fundamental splines}

The first advantage of the
weakly fundamental spline basis $\bspl[\wfs]{l,i}{p}$
over standard uniform B-splines $\bspl{l,i}{p}$ is that
the condition $\basis{\*k'}(\gp{\*k''}) \not= 0$ in
\cref{cor:equivalentCorrectnessUPHierarchization} is
satisfied for much fewer $\*k', \*k''$.
Consequently, fewer chain grid points have to be inserted to
ensure the correctness of the \up for hierarchization.
\Cref{fig:chainInsertionWeaklyFundamentalSpline} shows the inserted points
for the same grid as in \cref{fig:chainInsertionBSpline}.

\begin{SCfigure}
  \includegraphics{chainInsertion_4}%
  \caption[%
    Chain points for hierarchical weakly fundamental splines on a
    sparse grid%
  ]{%
    Necessary chain points for the correctness of the unidirectional principle
    with respect to $(t_1, t_2) = (1, 2)$
    for hierarchical cubic weakly fundamental splines
    $\bspl[\wfs]{l,i}{p}$ ($p = 3$)
    on the same two-dimensional spatially adaptive sparse grid
    as in \cref{fig:chainInsertionBSpline1}.
    The colors indicate the recursion depth in which the
    chain points have been inserted
    (see caption of \cref{fig:chainInsertionBSpline}).
    The number of points in the final grid is $N = 157$.%
  }%
  \label{fig:chainInsertionWeaklyFundamentalSpline}%
\end{SCfigure}

In the special case of regular sparse grids $\regsgset{n}{d}$,
we do not have to insert any grid points for the correctness of the
\up\punctfix{.}
We can verify this statement with
\thmref{cor:equivalentCorrectnessUPHierarchization}:
Let $(\*l',\*i')$ and $(\*l'',\*i'')$ with
$\normone{\*l'}, \normone{\*l''} \le n$ and
$\*i' \in \hiset{\*l'}$, $\*i'' \in \hiset{\*l''}$,
such that $\bspl[\wfs]{\*l',\*i'}{p}(\gp{\*l'',\*i''}) \not= 0$.
Furthermore, let $(\chain[\*l]{0}, \chain[\*i]{0}), \dotsc,
(\chain[\*l]{d}, \chain[\*i]{d})$ be the chain
from $\*k'$ to $\*k''$ with respect to $t_1, \dotsc, t_d$.
Note that $\chain[\*l]{j} \le \vecmax\{\*l', \*l''\}$ due to the
definition of chain points (\cref{def:chain}).
Therefore, we have for $j = 0, \dotsc, d$
by \eqref{eq:weaklyFundamentalPropertyImplicationMV}:
\begin{equation}
\*l' \le \*l''
\implies
\chain[\*l]{j} \le \vecmax\{\*l', \*l''\} \le \*l''
\implies
\normone{\chain[\*l]{j}} \le \normone{\*l''} \le n.
\end{equation}
Hence, $\regsgset{n}{d}$ contains the grid points corresponding to
$(\chain[\*l]{j}, \chain[\*i]{j})$ for all $j = 0, \dotsc, d$.
Consequently, the conditions of
\cref{cor:equivalentCorrectnessUPHierarchization} are satisfied without
inserting any additional chain points.
This statement is even valid for arbitrary
dimensionally adaptive sparse grids.

\subsection{Hermite Hierarchization}
\label{sec:455hermiteHierarchization}

\paragraph{Hermite interpolation}

The second advantage of the weakly fundamental spline basis
is that due to the reduced coupling,
the univariate hierarchization operators can be applied easier
than for standard uniform B-splines.
This results in the formulation of the so-called
\term{Hermite hierarchization} algorithm.
We first recall higher-order Hermite interpolation:

\begin{lemma}[higher-order Hermite interpolation]
  \label{lemma:hermiteInterpolation}
  Let $p \in \nat$ be odd and $a, b \in \real$ with $a < b$.
  Furthermore, let
  $\deriv[q]{x}{\objfun}(a) \in \real$ and
  $\deriv[q]{x}{\objfun}(b) \in \real$ be given data
  for $q = 0, \dotsc, \frac{p-1}{2}$.
  Then there is a unique polynomial $\spl \in \polyspace{p}$ such that
  \begin{equation}
    \deriv[q]{x}{\objfun}(a)
    = \deriv[q]{x}{\spl}(a),\quad
    \deriv[q]{x}{\objfun}(b)
    = \deriv[q]{x}{\spl}(b),\quad
    q = 0, \dotsc, \frac{p-1}{2}.
    \hspace*{-10mm}
  \end{equation}
\end{lemma}

\begin{proof}
  See \cite{Freund07Stoer}.
\end{proof}

\paragraph{Hermite hierarchization algorithm}

The interpolating polynomial $\spl$ and its derivatives can be
efficiently evaluated using Hermite basis functions
(generalized Lagrange polynomials \cite{Freund07Stoer}).
With Hermite interpolation, we formulate
\cref{alg:hermiteHierarchization}
for the hierarchization with hierarchical weakly fundamental splines.
While we formulate \cref{alg:hermiteHierarchization}
only for regular univariate grids and weakly fundamental splines,
a slightly reformulated version of the algorithm
also correctly operates on spatially adaptive univariate grids
(with the assumption that the grids contain the parents of their grid points)
and other weakly fundamental bases that are
piecewise polynomials of degree $\le p$.

\begin{algorithm}
  \begin{algorithmic}[1]
    \Function{$\vlinout = \texttt{hermiteHierarchization1D}$}{%
      $\vlinin$, $n$%
    }
      \For{$i = 0, 1$}
      \Comment{set values for level $0$}%
        \State{%
          $\linout{0,i} \gets \fcnval{0,i}$%
        }
        \label{line:algHermiteHierarchization1}
        \State{%
          $\deriv[q]{x}{\fgintp{0}}(\gp{0,i})
          \gets \kronecker{q}{0} \cdot \fcnval{0,i} +
          \kronecker{q}{1} \cdot (\fcnval{0,1} - \fcnval{0,0})$
          for all $q = 0, \dotsc, \frac{p-1}{2}$%
        }
        \label{line:algHermiteHierarchization3}
      \EndFor{}
      \For{$l = 1, \dotsc, n$}
        \For{$i \in \hiset{l}$}
          \State{%
            $\fgintp{l-1}(\gp{l,i}) \gets \text{Hermite interpolation of}$
            $\deriv[q]{x}{\fgintp{l-1}}(\gp{l,i\pm1})$
            ($q = 0, \dotsc, \frac{p-1}{2}$)%
          }
          \label{line:algHermiteHierarchization4}
          \State{%
            $r^{(l)}(\gp{l,i})
            \gets \fcnval{l,i} - \fgintp{l-1}(\gp{l,i})$%
          }
          \label{line:algHermiteHierarchization5}
          \Comment{residual to be interpolated}%
        \EndFor{}
        \State{%
          Let $r^{(l)}_l$ be of the form
          $\sum_{i' \in \hiset{l}} \linout{l,i'} \bspl[\wfs]{l,i'}{p}$%
        }
        \Comment{contribution of level $l$}%
        \label{line:algHermiteHierarchization6}
        \State{%
          Choose $(\linout{l,i'})_{i' \in \hiset{l}}$ such that
          $r^{(l)}_l(\gp{l,i}) = r^{(l)}(\gp{l,i})$ for all $i \in \hiset{l}$%
        }
        \label{line:algHermiteHierarchization7}
        \For{$i = 0, \dotsc, 2^l$}
        \Comment{for all points (current level and ancestors)}%
          \For{$q = 0, \dotsc, \frac{p-1}{2}$}
            \State{%
              $\deriv[q]{x}{\fgintp{l}}(\gp{l,i})
              \gets \deriv[q]{x}{\fgintp{l-1}}(\gp{l,i}) +
              \deriv[q]{x}{r^{(l)}_l}(\gp{l,i})$%
            }
            \Comment{update values}%
            \label{line:algHermiteHierarchization8}
          \EndFor{}
        \EndFor{}
      \EndFor{}
    \EndFunction{}
  \end{algorithmic}
  \caption[%
    Hermite hierarchization%
  ]{%
    Hermite hierarchization on one-dimensional regular grids.
    Inputs are
    the vector $\vlinin = (\linin{l,i})_{(l,i) \in \liset}$
    of input data (function values $\fcnval{l,i}$ at the grid points) and
    the level $n$ of the regular grid,
    where $\liset = \{(l, i) \mid l = 0, \dotsc, n,\; i \in \hiset{l}\}$.
    The output is the vector
    $\vlinout = (\linout{l,i})_{(l,i) \in \liset}$
    of output data (hierarchical surpluses $\surplus{l,i}$).%
  }%
  \label{alg:hermiteHierarchization}%
\end{algorithm}

\vspace*{\fill}

The idea of \cref{alg:hermiteHierarchization},
which is also illustrated in \cref{fig:hermiteHierarchization},
is to hierarchize the function value data level by level,
which is only possible because of the weakly fundamental property
\eqref{eq:weaklyFundamentalProperty}.
For each level $l$, we calculate surpluses
$\surplus{l,i} = \linout{l,i}$, while keeping track of
the values and derivatives
$\deriv[q]{x}{\fgintp{l}}(\gp{l,i})$ of the
``current'' interpolant $\fgintp{l}$ (up to level $l$).
Hermite interpolation is used to determine the ``delta''
to the interpolant of the next level.
Note that in \cref{line:algHermiteHierarchization8},
we have to evaluate the derivatives of
$\deriv[q]{x}{\fgintp{l-1}}(\gp{l,i})$ of the Hermite interpolant
determined in \cref{line:algHermiteHierarchization4}.
This is not an issue since in an implementation
one would typically simultaneously evaluate the
Hermite interpolant and its derivatives.

\vspace*{\fill}

\begin{SCfigure}
  \includegraphics{hermiteHierarchization_1}%
  \caption[%
    Hermite hierarchization%
  ]{%
    Hermite hierarchization on a regular grid in one dimension
    with cubic weakly fundamental splines $\bspl[\wfs]{l,i}{p}$ ($p = 3$).
    The interpolants $\fgintp{l}$ \emph{\textcolor{C1}{(red)}}
    of the objective function \emph{\textcolor{C0}{(blue)}}
    are computed level by level.
    For each level $l$,
    \vspace{-0.1em}%
    the values $\fgintp{l}(\gp{l,i})$ and the derivatives
    $\deriv{x}{\fgintp{l}}(\gp{l,i})$ of the
    current interpolant $\fgintp{l}$ at the
    grid points $\gp{l,i}$ ($i = 0, \dotsc, 2^l$) are saved
    \emph{(black dots and bars).}
    The values and derivatives are used for the Hermite interpolation
    of the residual $\objfun - \fgintp{l}$.
    The interpolated residual is then added to the current interpolant
    such that the sum vanishes in the grid points of the next level $l + 1$
    \emph{%
      (black dashed lines between \textcolor{C1}{red} and
      \textcolor{C0}{blue} dots).%
    }
    Due to the weakly fundamental property, the previously
    interpolated values of $\objfun$ remain unchanged.%
  }%
  \label{fig:hermiteHierarchization}%
\end{SCfigure}

For hierarchical weakly fundamental splines,
the complexity of the $l$-th iteration of \cref{alg:hermiteHierarchization}
is linear in the number of grid points of level $l$, i.e., $\landauO{2^l}$.
The reason for this is the bandedness (with bandwidth $\landauO{p}$) of the
system of linear equations corresponding to the interpolation problem of
\cref{line:algHermiteHierarchization6,line:algHermiteHierarchization7},
which means that the interpolation problem can be solved in
linear time and memory.
In total, the complexity of \cref{alg:hermiteHierarchization} is
given by $\landauO{\sum_{l=0}^n 2^l} = \landauO{2^n}$, i.e.,
the time and memory required by \cref{alg:hermiteHierarchization}
is only linear in the number of grid points.

\pagebreak

\paragraph{Correctness}

We prove the correctness of Hermite hierarchization
with the following invariant.

\begin{restatable}[invariant of Hermite hierarchization]{%
  proposition%
}{%
  propInvariantHermiteHierarchization%
}
  \label{prop:invariantHermiteHierarchization}
  In \cref{alg:hermiteHierarchization}, it holds
  for $l = 0, \dotsc, n$ and $i = 0, \dotsc, 2^l$
  \begin{equation}
    \label{eq:propInvariantHermiteHierarchization}
    \deriv[q]{x}{\fgintp{l}}(\gp{l,i})
    = \sum_{l'=0}^l \sum_{i' \in \hiset{l'}}
    \linout{l',i'} \deriv[q]{x}{\bspl[\wfs]{l',i'}{p}}(\gp{l,i}),\quad
    q = 0, \dotsc, \frac{p-1}{2}.
    \hspace*{-6mm}
  \end{equation}
\end{restatable}

\begin{proof}
  See \cref{sec:a135proofHermiteHierarchization}.
\end{proof}

\begin{restatable}[correctness of Hermite hierarchization]{%
  shortcorollary%
}{%
  corAlgHermiteHierarchizationCorrectness%
}
  \label{cor:algHermiteHierarchizationCorrectness}
  \Cref{alg:hermiteHierarchization} is correct.
\end{restatable}

\begin{proof}
  See \cref{sec:a135proofHermiteHierarchization}.
\end{proof}

\subsection{Hierarchical Weakly Fundamental Not-A-Knot Splines}
\label{sec:456wfsNotAKnot}

Finally, as for fundamental splines,
it is possible to combine the weakly fundamental basis
with the not-a-knot idea from \cref{sec:32notAKnot} to construct
hierarchical weakly fundamental not-a-knot spline functions
$\bspl[\wfs,\nak]{l',i'}{p}$.
The approach is similar to the fundamental not-a-knot splines
in \cref{sec:445fundamentalNotAKnotSplines}
(see \cref{eq:fundamentalNotAKnotSplines}):
Instead of combining uniform B-splines as in
\eqref{eq:weaklyFundamentalSplineParent},
we combine not-a-knot B-splines such that the
weakly fundamental property is satisfied.

However, the exact construction is somewhat complicated,
as one has to carefully consider which conditions to enforce
with which basis functions.
There are some special cases, if the index of the basis function
$\bspl[\wfs,\nak]{l',i'}{p}$ is near the boundary
(near $i' = 0$ or near $i' = 2^{l'}$).
Nevertheless, there are only finitely many special cases;
for higher levels $l'$, one can just scale the basis functions
of coarser levels.
In the scope of this thesis,
it suffices to show the resulting basis functions for
the cubic case ($p = 3$) in
\cref{fig:hierarchicalWeaklyFundamentalNotAKnotSpline},
instead of rigorously stating the technical formulas.

\begin{SCfigure}
  \includegraphics{hierarchicalBasis_18}%
  \caption[%
    Hierarchical weakly fundamental not-a-knot splines%
  ]{%
    Hierarchical cubic weakly fundamental not-a-knot splines
    $\bspl[\wfs,\nak]{l',i'}{p}$
    ($l' \le l$, $i' \in \hiset{l'}$, $p = 3$),
    grid points $\gp{l',i'}$ \emph{(dots),} and
    removed knots \emph{(crosses)} up to level $l = 3$.%
  }%
  \label{fig:hierarchicalWeaklyFundamentalNotAKnotSpline}%
\end{SCfigure}


%\documentclass[12pt]{article}
\documentclass[12pt,landscape]{article}

\usepackage[normalem]{ulem}
\include{preamble}

\newcommand{\instr}{\small Your answer will consist of a lowercase string (e.g. \texttt{aebgd}) where the order of the letters does not matter. \normalsize}

\title{Math 369 / 690 Fall \the\year{} \\ Final Examination}
\author{Professor Adam Kapelner}

\date{Thursday, December 16, \the\year{}}

\begin{document}
\maketitle

%\noindent Full Name \line(1,0){410}

\thispagestyle{empty}

\section*{Code of Academic Integrity}

\footnotesize
Since the college is an academic community, its fundamental purpose is the pursuit of knowledge. Essential to the success of this educational mission is a commitment to the principles of academic integrity. Every member of the college community is responsible for upholding the highest standards of honesty at all times. Students, as members of the community, are also responsible for adhering to the principles and spirit of the following Code of Academic Integrity.

Activities that have the effect or intention of interfering with education, pursuit of knowledge, or fair evaluation of a student's performance are prohibited. Examples of such activities include but are not limited to the following definitions:

\paragraph{Cheating} Using or attempting to use unauthorized assistance, material, or study aids in examinations or other academic work or preventing, or attempting to prevent, another from using authorized assistance, material, or study aids. Example: using an unauthorized cheat sheet in a quiz or exam, altering a graded exam and resubmitting it for a better grade, etc.
\\

\noindent By taking this exam, you acknowledge and agree to uphold this Code of Academic Integrity. \\

%\begin{center}
%\line(1,0){250} ~~~ \line(1,0){100}\\
%~~~~~~~~~~~~~~~~~~~~~signature~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date
%\end{center}

\normalsize
\vspace{-0.3cm}
\section*{Instructions}
This exam is 110 minutes (variable time per question) and closed-book. You are allowed \textbf{three} page (front and back) of a \qu{cheat sheet}, blank scrap paper and a graphing calculator. Please read the questions carefully. I recommend answering all questions that are easy first and then circling back to work on the harder ones. \ingray{Gray text} means the text is repeated verbatim from a previous problem. No food is allowed, only drinks. %If the question reads \qu{compute,} this means the solution will be a number otherwise you can leave the answer in \textit{any} widely accepted mathematical notation which could be resolved to an exact or approximate number with the use of a computer. I advise you to skip problems marked \qu{[Extra Credit]} until you have finished the other questions on the exam, then loop back and plug in all the holes. I also advise you to use pencil. The exam is 100 points total plus extra credit. Partial credit will be granted for incomplete answers on most of the questions. \fbox{Box} in your final answers. Good luck!

\pagebreak

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\problem\timedsection{13} \href{https://en.wikipedia.org/wiki/Benford\%27s_law}{Benford's law} discovered in 1938 a discrete parameterless probability distribution on the first digits of numbers. It is also called the \qu{first-digit law} and was discovered by examining real-world datasets. In real-world datasets, numbers beginning with a 1 are about twice as likely as numbers beginning with a 2. Numbers beginning with a 2 are about 50\% more likely that numbers beginning with a 3, etc. This is especially true in domains such as accounting and taxes. This distribution is used frequently to prove that a dataset is fraudulent i.e. if someone is trying to cheat on their taxes by randomly generating numeric values, their values will not follow Benford's law since most crooks aren't too careful about learning probability theory. Below is the Benford Law distribution's PMF and CDF. It's mean is 3.441.

\begin{table}[h]
\centering
\begin{tabular}{l|lllllllll}
$x$		&	1		& 	2		&	3		&	4		&	5		&	6		&	7		&		8	&	9 \\ \hline
$p(x)$	&	.301	&	.176	&	.125	&	.097	&	.079	&	.067	&	.058	& 		.051	&	.046 \\
$F(x)$  &   .301		&	.477	&	.602	&	.699	&	.778	&	.845	&	.903	& 		.954	&	1.000 \\
\end{tabular}
\end{table}
\FloatBarrier
\vspace{-0.2cm}
\noindent Consider a tax return with $n=45$ numbers. We examine the first digit of the numbers and sort the data. It turns out the first digit is exactly uniformly distributed across all digits i.e. $\x = <1,1,1,1,1,2,2,2,2,2, \ldots, 9,9,9,9,9>$.  This smells of fraud; we will investigate. To test cheating we can use ...

\vspace{-0.1cm}\benum\truefalsesubquestionwithpoints{13}
\begin{enumerate}[(a)]
\item ... the one sample asymptotic $z$ test for the mean
\item ... the one sample asymptotic $t$ test for the mean
\item ... the one sample Wald test for the mean
\item ... the score test for the mean
\item ... the likelihood ratio test for the mean
\item ... a generalized likelihood ratio test
\item ... Pearson's $\chi^2$ goodness of fit test
\item ... Kolmogorov-Smirnov's one-sample test
\item ... a bootstrap test where $\xbar$ is calculated for each bootstrap sample
\item ... the Welch-Satterthwaite $t$ test
\item ... Kolmogorov-Smirnov's two-sample test
\item ... Fisher's two-sample permutation test
\item ... the multivariate delta method
\end{enumerate}
\eenum\instr\pagebreak

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\problem\timedsection{14} \ingray{\small{\href{https://en.wikipedia.org/wiki/Benford\%27s_law}{Benford's law} discovered in 1938 a discrete parameterless probability distribution on the first digits of numbers. It is also called the \qu{first-digit law} and was discovered by examining real-world datasets. In real-world datasets, numbers beginning with a 1 are about twice as likely as numbers beginning with a 2. Numbers beginning with a 2 are about 50\% more likely that numbers beginning with a 3, etc. This is especially true in domains such as accounting and taxes. This distribution is used frequently to prove that a dataset is fraudulent i.e. if someone is trying to cheat on their taxes by randomly generating numeric values, their values will not follow Benford's law since most crooks aren't too careful about learning probability theory. Below is the distribution's PMF and CDF. It's mean is 3.441.} \normalsize

\vspace{-0.2cm}
\begin{table}[h]
\centering\ingray{
\begin{tabular}{l|lllllllll}

$x$		&	1		& 	2		&	3		&	4		&	5		&	6		&	7		&		8	&	9 \\ \hline
$p(x)$	&	.301	&	.176	&	.125	&	.097	&	.079	&	.067	&	.058	& 		.051	&	.046 \\
$F(x)$  &   .301		&	.477	&	.602	&	.699	&	.778	&	.845	&	.903	& 		.954	&	1.000 \\
\end{tabular}}
\end{table}
\FloatBarrier

\vspace{-0.3cm}
\noindent Consider a tax return with $n=45$ numbers. We examine the first digit of the numbers and sort the data. It turns out the first digit is exactly uniformly distributed across all digits i.e. $\x = <1,1,1,1,1,2,2,2,2,2, \ldots, 9,9,9,9,9>$. This smells of fraud; we will investigate.} To do so, we will employ Pearson's $\chi^2$ goodness of fit test at $\alpha = 5\%$. Critical values you may need to reference are: $F_{\chisq{7}}(14.1) = F_{\chisq{8}}(15.5) = F_{\chisq{9}}(16.9) = F_{\chisq{10}}(18.3) = .95$.

\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{12}
\begin{enumerate}[(a)]
\item $H_0: \theta = 3.441$ where $\theta$ denotes the mean of the DGP that generated $x_1, \ldots, x_{45}$
\item $H_0:$ the DGP that generated $x_1, \ldots, x_{45}$ is Benford's law
\item $H_0:$ the PMF of the DGP that generated $x_1, \ldots, x_{45}$ is the $p(x)$ given as $p(x)$ in the table above
%\item $H_0:$ the CDF of the DGP that generated $x_1, \ldots, x_{45}$ is the $p(x)$ given as $F(x)$ in the table above
\item Pearson's $\chi^2$ goodness of fit test statistic is a realization from an approximate $\chisq{7}$ distribution
\item Pearson's $\chi^2$ goodness of fit test statistic is a realization from an approximate $\chisq{9}$ distribution

\item Pearson's $\chi^2$ goodness of fit test statistic is 0
\item Pearson's $\chi^2$ goodness of fit test statistic is 18.05 rounded to the nearest two digits
\item Pearson's $\chi^2$ goodness of fit test statistic is 18.39 rounded to the nearest two digits
\item Pearson's $\chi^2$ goodness of fit test statistic is 213.01 rounded to the nearest two digits
%\item Pearson's $\chi^2$ goodness of fit test statistic is 4888.37 rounded to the nearest two digits
\item Pearson's $\chi^2$ goodness of fit test statistic cannot be computed given the information available

\item $H_0$ is rejected
\item There is sufficient evidence to conclude this person is cheating on their tax return
\end{enumerate}
\eenum\instr\pagebreak

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\problem\timedsection{13} \ingray{\footnotesize{\href{https://en.wikipedia.org/wiki/Benford\%27s_law}{Benford's law} discovered in 1938 a discrete parameterless probability distribution on the first digits of numbers. It is also called the \qu{first-digit law} and was discovered by examining real-world datasets. In real-world datasets, numbers beginning with a 1 are about twice as likely as numbers beginning with a 2. Numbers beginning with a 2 are about 50\% more likely that numbers beginning with a 3, etc. This is especially true in domains such as accounting and taxes. This distribution is used frequently to prove that a dataset is fraudulent i.e. if someone is trying to cheat on their taxes by randomly generating numeric values, their values will not follow Benford's law since most crooks aren't too careful about learning probability theory. Below is the distribution's PMF and CDF. It's mean is 3.441.} \normalsize

\vspace{-0.2cm}
\begin{table}[h]
\centering\ingray{
\begin{tabular}{l|lllllllll}

$x$		&	1		& 	2		&	3		&	4		&	5		&	6		&	7		&		8	&	9 \\ \hline
$p(x)$	&	.301	&	.176	&	.125	&	.097	&	.079	&	.067	&	.058	& 		.051	&	.046 \\
$F(x)$  &   .301		&	.477	&	.602	&	.699	&	.778	&	.845	&	.903	& 		.954	&	1.000 \\
\end{tabular}}
\end{table}
\FloatBarrier

\vspace{-0.2cm}
\noindent Consider a tax return with $n=45$ numbers. We examine the first digit of the numbers and sort the data. It turns out the first digit is exactly uniformly distributed across all digits i.e. $\x = <1,1,1,1,1,2,2,2,2,2, \ldots, 9,9,9,9,9>$. This smells of fraud; we will investigate.} To do so, we will employ the Kolmogorov-Smirnov (KS) test at $\alpha = 5\%$ (and assume it works for discrete rv's). The critical value you need for reference is: $F_{K}(1.36) = .95$ where $K$ denotes the Kolmogorov distribution.

\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{12}
\begin{enumerate}[(a)]
\item $H_0: \theta = 3.441$ where $\theta$ denotes the mean of the DGP that generated $x_1, \ldots, x_{45}$
\item $H_0:$ the DGP that generated $x_1, \ldots, x_{45}$ is Benford's law
%\item $H_0:$ the PMF of the DGP that generated $x_1, \ldots, x_{45}$ is the $p(x)$ given as $p(x)$ in the table above
%\item $H_0:$ the CDF of the DGP that generated $x_1, \ldots, x_{45}$ is the $p(x)$ given as $F(x)$ in the table above
\item The KS test is an approximate test

\item The $\doublehat{D}_n$ test statistic is 0
\item The $\doublehat{D}_n$ test statistic is 0.19 rounded to the nearest two digits
\item The $\doublehat{D}_n$ test statistic is 0.25 rounded to the nearest two digits
\item The $\doublehat{D}_n$ test statistic is 0.27 rounded to the nearest two digits
\item The $\doublehat{D}_n$ test statistic cannot be computed given the information available

\item If $\doublehat{D}_n < 1.36$, this means the null hypothesis is retained
\item There is sufficient evidence to conclude this person is cheating on their tax return
\item the KS test statistic should be approximately equal to Pearson's $\chi^2$ goodness of fit test statistic
\item Fisher's p-value in the KS test should be approximately equal to Fisher's p-value in Pearson's $\chi^2$ goodness of fit test
\end{enumerate}
\eenum\instr\pagebreak

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\problem\timedsection{14} \ingray{\footnotesize{\href{https://en.wikipedia.org/wiki/Benford\%27s_law}{Benford's law} discovered in 1938 a discrete parameterless probability distribution on the first digits of numbers. It is also called the \qu{first-digit law} and was discovered by examining real-world datasets. In real-world datasets, numbers beginning with a 1 are about twice as likely as numbers beginning with a 2. Numbers beginning with a 2 are about 50\% more likely that numbers beginning with a 3, etc. This is especially true in domains such as accounting and taxes. This distribution is used frequently to prove that a dataset is fraudulent i.e. if someone is trying to cheat on their taxes by randomly generating numeric values, their values will not follow Benford's law since most crooks aren't too careful about learning probability theory. Below is the distribution's PMF and CDF. It's mean is 3.441.

\vspace{-0.2cm}
\begin{table}[h]
\centering\ingray{
\begin{tabular}{l|lllllllll}

$x$		&	1		& 	2		&	3		&	4		&	5		&	6		&	7		&		8	&	9 \\ \hline
$p(x)$	&	.301	&	.176	&	.125	&	.097	&	.079	&	.067	&	.058	& 		.051	&	.046 \\
$F(x)$  &   .301		&	.477	&	.602	&	.699	&	.778	&	.845	&	.903	& 		.954	&	1.000 \\
\end{tabular}}
\end{table}
\FloatBarrier

\vspace{-0.2cm}
\noindent Consider a tax return with $n=45$ numbers. We examine the first digit of the numbers and sort the data. It turns out the first digit is exactly uniformly distributed across all digits i.e. $\x = <1,1,1,1,1,2,2,2,2,2, \ldots, 9,9,9,9,9>$. This smells of fraud; we will investigate.}} \normalsize To do so, we will employ the generalized likelihood ratio test at $\alpha = 5\%$. Critical values you may need to reference are: $F_{\chisq{7}}(14.1) = F_{\chisq{8}}(15.5) = F_{\chisq{9}}(16.9) = F_{\chisq{10}}(18.3) = .95$.

\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{13}
\begin{enumerate}[(a)]
\item $H_0: \theta = 3.441$ where $\theta$ denotes the mean of the DGP that generated $x_1, \ldots, x_{45}$
\item $H_0:$ the DGP that generated $x_1, \ldots, x_{45}$ is Benford's law

%\item The $\doublehat{\Lambda}$ test statistic is a realization from an approximate $\chisq{7}$ distribution
\item The $\doublehat{\Lambda}$  test statistic is a realization from an approximate $\chisq{9}$ distribution

\item The generalized likelihood ratio test is an approximate test
\item The numerator in the likelihood ratio is $1/9^{45}$
\item The denominator in the likelihood ratio is $1/9^{45}$
\item The likelihood that this data came from Benford's law is less than 1 in 1,000,000,000
\item The $\doublehat{\Lambda}$ test statistic is 0
\item The $\doublehat{\Lambda}$ test statistic is 2.12 $\times 10^{-47}$ rounded to the nearest two digits
\item The $\doublehat{\Lambda}$ test statistic is 8.59 rounded to the nearest two digits
\item The $\doublehat{\Lambda}$ test statistic cannot be computed given the information available

\item If the likelihood ratio is calculated to be a value strictly greater than 1, the null hypothesis is rejected
\item There is sufficient evidence to conclude this person is cheating on their tax return

\end{enumerate}
\eenum\instr\pagebreak

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\problem\timedsection{13} Below is the PMF and log PMF of Benford's law distribution:

\vspace{-0.2cm}
\begin{table}[h]
\centering
\begin{tabular}{l|lllllllll}

$x$		&	1		& 	2		&	3		&	4		&	5		&	6		&	7		&		8	&	9 \\ \hline
$p(x)$	&	.301	&	.176	&	.125	&	.097	&	.079	&	.067	&	.058	& 		.051	&	.046 \\
$\natlog{p(x)}$  &   -1.201 & -1.737 & -2.079 & -2.333 & -2.538 & -2.703 & -2.847 & -2.976 & -3.079 \\
\end{tabular}
\end{table}
\FloatBarrier

\vspace{-0.2cm}
\noindent \ingray{Consider a tax return with $n=45$ numbers. We examine the first digit of the numbers and sort the data. It turns out the first digit is exactly uniformly distributed across all digits i.e. $\x = <1,1,1,1,1,2,2,2,2,2, \ldots, 9,9,9,9,9>$. This smells of fraud; we will investigate.} \normalsize This time, we will use model selection even though this is not, strictly speaking, a form of hypothesis testing. Consider two models:

\begin{itemize}
\item[I] Uniform i.e. with likelihood $\tothepow{\oneover{9}}{5} \tothepow{\oneover{9}}{5} \cdot \ldots \cdot \tothepow{\oneover{9}}{5}$
\item[II] Benford i.e. with likelihood $\tothepow{0.301}{5} \tothepow{0.176}{5} \cdot \ldots \cdot \tothepow{0.046}{5}$
\end{itemize}

\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{16}
\begin{enumerate}[(a)]
\item The log-likelihood in the first model is -98.88 rounded to the nearest two digits
\item The log-likelihood in the second model is -107.47 rounded to the nearest two digits
\item Since the log-likelihood in the second model is absolutely larger than the first model, the second model is more likely to be true if you assume one of the two models is true

\item The AIC for Model I is 197.75 rounded to the nearest two digits
\item The AIC for Model I is 199.75 rounded to the nearest two digits

\item Since Model I has the lower AIC, model I is the selected model according to the AIC model selection procedure

\item Assuming one of these two models is the true model, the probability that model I is true is 50\%
\item Assuming one of these two models is the true model, the probability that model I is true is 99.98\% rounded to the nearest two digits

\item For Model II, the AIC and the AICC metrics will be equivalent
\end{enumerate}
\eenum\instr\pagebreak

%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{11} Consider running $m > 1$ hypothesis tests. Following the notation from the lectures, below is a table that tabulates the random variables that model the possible events (denoted by uppercase letters) and the fixed constants (denoted by lowercase letters) in the course of these tests:

\begin{table}[h]
\centering
\begin{tabular}{c|cc|c}
& Decision: Retain $H_0$ & Decision: Reject $H_0$ & total \\\hline
$H_0$ true & $U$ & $V$ & $m_0$ \\
$H_a$ true & $T$ & $S$ & $m - m_0$ \\ \hline
total & $F$ & $R$ & $m$
\end{tabular}
\end{table}
\FloatBarrier

Assume each of the $m$ tests are \textbf{independent from each other} and that the levels for each test are $\alpha$.

\vspace{-0.2cm}\benum\truefalsesubquestionwithpoints{13}

\begin{enumerate}[(a)]
\item $U \sim \binomial{m}{\alpha}$
\item $U \sim \binomial{m}{1 - \alpha}$
\item For any $m -m_0$ alternative distributions, $S$ can be modeled as a binomial
\item $T$ is the rv model which models the number of type II errors
\item If the FWER is properly controlled, $T$ goes to zero as $m \rightarrow \infty$
\item If the FWER is properly controlled, the rejected tests's results are of higher practical significance then the rejected tests's results without FWER control (but still may not be practically significant)
\item The familywise error rate (FWER) is equal to the probability that $R > 1$
\item Using the Dunn-Sidak correction, the threshold for significance of each test would be less than $\alpha$
\item The Simes procedure has a higher $\expe{R}$ than the Bonferroni procedure

\item If you set $\alpha = 5\% / m$ then FWER $=5\%$
\item If you set $\alpha = 5\% / m$ then FWER $> 5\%$

\item In order to compute the threshold of significance for Sime's FWER-controlling procedure, you need to first run all $m$ tests and compute their $m$ p-values
\item For $m_0$ of the $m$ tests, the p-values could be drawn as realizations from $\stduniform$
\end{enumerate}
\eenum\instr\pagebreak

%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{9} A not-so well-known test is a test for a DGP's \qu{kurtosis}. Kurtosis is generally speaking a measure of how fast the tails of the distribution approach zero. Pearson defined it to be $\kappa := \expe{(X - \mu)^4 / \sigma^4}$, the fourth standardized moment. A very interesting fact is that the normal distribution has $\kappa = 3$ regardless of its mean and variance. Thus, we define the \qu{excess kurtosis} as the amount in excess over 3, i.e. $\kappa_0 := \kappa - 3$. An excess kurtosis of different than 0 means the tails of the distribution are thinner/fatter than the normal's tails. This is really important to test sometimes.

\vspace{-0.1cm}
\benum\truefalsesubquestionwithpoints{8}
\begin{enumerate}[(a)]
\item To test this we can use a one sample Wald test if we were given the DGP and can derive the MLE for $\kappa_0$
\item To test $H_a: \kappa_0 \neq 0$ we can use Pearson's $\chi^2$ goodness of fit test
\item To test $H_a: \kappa_0 \neq 0$ we can use Kolmogorov-Smirnov's one-sample test
\item To test $H_a: \kappa_0 \neq 0$ we can use Fisher's two-sample permutation test
\item To test $H_a: \kappa_0 \neq 0$ we can use the multivariate delta method
\item We can always estimate $\kappa_0$ using MM for any DGP whose $\kappa_0$ is finite
\item To test $H_a: \kappa_0 \neq 0$ we can use a one sample Wald test if we can derive the standard error for the MM $\kappa_0$ estimator
\item To test $H_a: \kappa_0 \neq 0$ we can use a bootstrap test where the MM excess kurtosis estimate is calculated for each bootstrap sample
\end{enumerate}
\eenum\instr\pagebreak

%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{8} \ingray{A not-so well-known test is a test for a DGP's \qu{kurtosis}. Kurtosis is generally speaking a measure of how fast the tails of the distribution approach zero. Pearson defined it to be $\kappa := \expe{(X - \mu)^4 / \sigma^4}$, the fourth standardized moment. A very interesting fact is that the normal distribution has $\kappa = 3$ regardless of its mean and variance. Thus, we define the \qu{excess kurtosis} as the amount in excess over 3, i.e. $\kappa_0 := \kappa - 3$. An excess kurtosis of greater than 0 means the tails of the distribution are fatter than the normal's tails. This is really important to test sometimes.} Consider the following stock market data: centered daily percentage returns from the S\&P 500 in the past year. We wish to test if the tails of this distribution are fatter than the normal distribution's tails, i.e. $H_a: \kappa_0 \neq 0$ at $\alpha = 5\%$ and to do so we'll use a bootstrap test. Here is a histogram of $B=1,000,000$ MM estimates of $\kappa_0$. And $\doublehat{\kappa}^{MM}_0 = 0.748$

\begin{figure}[h]
\centering
\includegraphics[width=7in]{boot}
\end{figure}

\vspace{-0.9cm}
\benum\truefalsesubquestionwithpoints{9}
\begin{enumerate}[(a)]
\item We do not really need to use the bootstrap test as the sampling distribution of $\hat{\kappa}^{MM}_0$ can be derived analytically
\item A 95\% bootstrap confidence interval will be approximately between -1 and 3
\item A 95\% bootstrap confidence interval will be approximately between 0.2 and 1.4
\item The null hypothesis is rejected
\item The data seems to suggest the normal model is not a good model for daily percentage returns from the S\&P 500 in the past year
\item $B=1,000,000$ seems to be sufficient to construct CI's and run hypothesis tests
\item $\hat{\kappa}^{MM}_0$ may be biased
\item If $\hat{\kappa}^{MM}_0$ were to be biased, the test is still valid regardless of the bias
\item If $\hat{\kappa}^{MM}_0$ were to be biased, the bias could be fixed by increasing $n$
\end{enumerate}
\eenum\instr\pagebreak

%%%%%%%%%%%%%%%%%%%%%%%%

\problem\timedsection{15} Assume a DGP of $\Xoneton \iid \normnot{0}{\theta}$. We wish to test $H_a: \theta \neq 1$ for the dataset 1.41, 1.44, 4.19, 5.12, 0.09, 8.62, 0.6, -8.88, 0.63, -8.57 at $\alpha = 5\%$ using the score test.

\vspace{-0.1cm}
\benum\truefalsesubquestionwithpoints{14}
\begin{enumerate}[(a)]
\item The score test requires you to compute $\doublehat{\theta}^{MLE}$
\item $\mathcal{L}\parens{\theta; \Xoneton} = \displaystyle\prod_{i=1}^n \oneoversqrt{2\pi\theta} \exp{-\oneover{2\theta} X_i^2}$
\item $\ell\parens{\theta; \Xoneton} = \tothepow{2\pi\theta}{-n/2} \natlog{-\oneover{2\theta} X_i^2}$
\item $\ell'\parens{\theta; \Xoneton} = -\displaystyle\frac{n}{2\pi} -\displaystyle\frac{n}{2\theta} - \oneover{2\theta} \sum_{i=1}^nX_i^2$
\item $\ell'\parens{\theta; \Xoneton} =-\displaystyle\frac{n}{2\theta} + \oneover{2\theta^2} \sum_{i=1}^n X_i^2$
\item $\ell''\parens{\theta; \Xoneton} = \displaystyle\frac{n}{2\theta^2} - \oneover{\theta^3} \sum_{i=1}^n X_i^2$
\item $I(\theta) = \displaystyle\frac{n}{2\theta^2}$
\item $I(\theta) = -\displaystyle\frac{n}{2\theta^2}$
\item The score statistic is $\parens{-\displaystyle\frac{n}{2} + \half \sum_{i=1}^n X_i^2} \displaystyle\overn{\sqrt{2}}$
\item The score statistic is 0
\item The score statistic is 16.40 rounded to the two nearest digits
\item The score statistic is 89.98 rounded to the two nearest digits
\item The null hypothesis is rejected
\item The p-value of the score test will be similar to the p-values of the likelihood ratio test and the wald test but may not be exactly equal
\end{enumerate}
\eenum\instr\pagebreak

\end{document}


\chapter{Data Application} \label{chapter4:Data-Application}

To evaluate the performance of our method on real data, we use an atomic force microscopy (AFM) image of a solar cell. The image (see Figure~\ref{fig:film}) comes from a paper by Singh et al.~\cite{Singh2014}, who wanted to improve efficiency of converting light into electricity by optimizing the concentration of carbon nanotubes in solar cells coated with a particular compound called poly(3-hexylthiophene): phenyl-C61-butyric acid methyl ester (P3HT:PCBM). This compound is spread in a microscopically thin film over the cell.

\begin{figure}[htbp]
	\centering
	\includegraphics[width=0.65\textwidth]{film.png}
	\caption{Atomic force microscopy image of a thin film of the P3HT:PCBM compound on a solar cell. Dark clusters represent areas where the film is thinner, and lighter clusters are thicker areas.}
	\label{fig:film}
\end{figure}

Figure~\ref{fig:film} shows a P3HT:PCBM film doped with a 0.1\% concentration of carbon nanotubes. By treating the film thickness as observations from an unknown isotropic stationary Gaussian process, our goal was to train a covariance model on some of these observations and predict the others.

To prepare the data, we selected ten 25-by-25 pixel squares to use to estimate the covariance function. We treated the squares as 10 independent observations of a Gaussian process on the 25-by-25 grid. Once we obtained our estimate, we selected an out of sample 25-by-25 square, removed a 4-by-4 section of that square made predictions conditionally on the remainder as observations in the square. One of the training squares is shown in Figure~\ref{fig:training25}, and Figure~\ref{fig:pred25} shows the observation square, with the withheld prediction points highlighted in red.

\begin{figure}[htbp]
	\centering
	\includegraphics[width=0.95\textwidth]{col_image_5.pdf}
	\caption{One of the 10 25-by-25 sections of the film image used to fit the spline model.}
	\label{fig:training25}
\end{figure}

\begin{figure}[htbp]
	\centering
	\includegraphics[width=0.95\textwidth]{col_pred.pdf}
	\caption{This 25-by-25 section of the film image was held out from the training step. The 16 outlined pixels are used for prediction, and the others are treated as observations.}
	\label{fig:pred25}
\end{figure}

\begin{figure}[htbp]
	\centering
	\includegraphics[width=0.95\textwidth]{covariance_realdata.pdf}
	\caption{The estimated covariance function based on the 10 25-by-25 sections of the film image used to fit the spline model.}
	\label{fig:covariance-realdata}
\end{figure}

We fit the semiparametric model and a Mat\'ern model, and compare the prediction performance of each. The mean squared prediction error for the Mat\'ern model was $0.0008707$, while the mean squared prediction error for the semiparametric model was $0.0006414$. The semiparametric model performed $26.3\%$ better on the 16 prediction points, indicating that it is capturing the local behavior of the Gaussian process more effectively than the best-fit Mat\'ern model can. Figure~\ref{fig:covariance-realdata} shows the estimated covariance function from the semiparametric model. There is a significant hole effect that a Mat\'ern model is not capable of capturing.


% Created 2018-03-13 mar 13:26
\documentclass[a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\usepackage{khpreamble}
\newcommand*{\shift}{\operatorname{q}}
\author{Kjartan Halvorsen}
\date{Due 2018-03-07}
\title{Computerized control - homework 3}
\hypersetup{
  pdfkeywords={},
  pdfsubject={},
  pdfcreator={Emacs 24.5.1 (Org mode 8.2.10)}}
\begin{document}

\maketitle

\section*{The system}
\label{sec-1}
Consider the linearized model of the tank that we looked at in class

\begin{center}
\includegraphics[width=0.7\linewidth]{../../MR2012/figures/tank-with-hole}
\end{center}
Using the parameter values
\[ A = 1, \qquad a = 0.1, \qquad g = 9.8,\]
and the operating point given by
\[ h_0 = 1, \qquad z_0 = a\sqrt{2gh_0} \approx 0.44,\]
the linearized model of the tank is described by the first-order system
\[ G_1(s) = \frac{1}{s + 0.44}\]
from the deviation in flow $w(t)$ to the deviation in level $y(t)$.

A valve is used to control the flow. The valve is a so-called control valve, which means it includes an inner controller that works as a position servo. That is, it will make sure the opening of the valve follows the input signal to the valve. This signal is named $u(t)$. The response of the opening of the valve $\theta(t)$ to the input signal $u(t)$ is well-described by a second-order, critically damped system
\[ G_2(s) = \frac{1}{(0.5s + 1)(0.5s+1)} = \frac{4}{(s+2)(s+2)}. \]

The flow through the valve depends also on the square root of the pressure difference across the valve. In a linearized model, a change in pressure enters as an additive disturbance to the system. The complete model of the process is given in the block-diagram below.

  \begin{center}
  \begin{tikzpicture}[scale = 0.8, node distance=18mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]

  \node[coordinate] (input) {};
  \node[block, right of=input] (valve) {$G_2(s)$};
  \node[above of=valve, node distance=6mm] {valve};
  \node[sumnode, right of=valve, node distance=16mm] (sum) {\tiny $\sum$};
  \node[block, right of=sum, node distance=20mm] (tank) {$G_1(s)$};
  \node[above of=tank, node distance=6mm] {tank};
  \node[coordinate, right of=tank] (output) {};
  \node[coordinate, above of=sum, node distance=12mm] (disturbance) {};

  \draw[->] (input) -- node[above] {$u(t)$} (valve);
  \draw[->] (valve) -- node[above] {} (sum);
  \draw[->] (sum) -- node[above] {$w(t)$} (tank);
  \draw[->] (tank) -- node[above] {$y(t)$} (output);
  \draw[->] (disturbance) -- node[right, pos=0.2] {$v(t)$} (sum);

  \end{tikzpicture}
\end{center}

The level of the tank is measured, and is available for feedback control.
    \begin{center}
  \begin{tikzpicture}[scale = 0.8, node distance=20mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]

  \node[coordinate] (refinput) {};
  \node[sumnode, right of=refinput, node distance=20mm] (sumerr) {\tiny $\sum$};
  \node[block, right of=sumerr] (controller) {$F(s)$};
  \node[above of=controller, node distance=6mm] {controller};
  \node[block, right of=controller, node distance=24mm] (valve) {$G_2(s)$};
  \node[above of=valve, node distance=6mm] {valve};
  \node[sumnode, right of=valve, node distance=16mm] (sum) {\tiny $\sum$};
  \node[block, right of=sum, node distance=20mm] (tank) {$G_1(s)$};
  \node[above of=tank, node distance=6mm] {tank};
  \node[coordinate, right of=tank, node distance=20mm] (output) {};
  \node[coordinate, above of=sum, node distance=12mm] (disturbance) {};

  \draw[->] (refinput) -- node[above, pos=0.3] {$y_{ref}(t)=0$} (sumerr);
  \draw[->] (sumerr) -- node[above] {$e(t)$} (controller);
  \draw[->] (controller) -- node[above] {$u(t)$} (valve);
  \draw[->] (valve) -- node[above] {} (sum);
  \draw[->] (sum) -- node[above] {$w(t)$} (tank);
  \draw[->] (tank) -- node[coordinate] (measure) {} node[above, pos=0.8] {$y(t)$} (output);
  \draw[->] (disturbance) -- node[right, pos=0.2] {$v(t)$} (sum);
  \draw[->] (measure) -- ++(0,-14mm) -| node[right, pos=0.95] {$-$} (sumerr);
 \end{tikzpicture}
\end{center}

A simulation model (\texttt{simulink}) of the system is available on Blackboard under \texttt{Course Documents/Matlab and Simulink}

\section*{Exercises}
\label{sec-2}
\subsection*{Problem 1 - Tuning a PID}
\label{sec-2-1}

Perform a bumptest on the plant (valve+tank). This means to connect a step block (see \texttt{Sources} in the \texttt{Simulink Library Browser}) to the input of the valve. Determine the slope $R$, the apparent deadtime $L$, and the parameter $a=RL$ from the step response. See figure 8.13 in the text-book

\begin{center}
\includegraphics[width=0.7\linewidth]{../figures/fig8-13.png}
\end{center}

Include your simulated step-response in your report.

Determine a PID controller using table 8.2 in the book.

\begin{center}
\includegraphics[width=0.7\linewidth]{../figures/table8-2.png}
\end{center}

\subsection*{Problem 2 - Implement the PID in simulink}
\label{sec-2-2}

The controller is written
\[U(s) = K \left( U_c(s) - Y(s) + \frac{1}{sT_i}\big(U_c(s) - Y(s)\big) - \frac{sT_d}{1 + sT_d/N} Y(s)\right).\]

Set $N=10$ and implement the controller in simulink using the values for $K$, $T_i$ and $T_d$ that you determined in Problem 1.

Simulate the closed-loop system's response to step changes in both the set point, $u_c(t)$ and the disturbance, $v(t)$. Include the step-responses in your report and comment on the results.

\subsection*{Problem 3 - Discrete PID}
\label{sec-2-3}

The discretized controller is written
\[ R(\shift) u(kh) = T(\shift) u_c(kh) - S(\shift) y(kh), \]
where
\begin{align*}
 R(\shift) &= (\shift -1)(\shift - a_d)\\
 S(\shift) &= s_0\shift^2 + s_1\shift + s_2\\
T(\shift) &= t_0\shift^2 + t_1\shift + t_2
\end{align*}

Determine the discrete PID controller parameters $a_d$, $s_0$, $s_1$, $s_2$, $t_0$, $t_1$ and $t_2$ using table 8.1 in the textbook (given below). You can use whichever of the three discretization methods provided.

\begin{center}
\includegraphics[width=0.7\linewidth]{../figures/table8-1.png}
\end{center}

\section*{Solutions}
\label{sec-3}
\subsection*{Problem 1 - Tuning a PID}
\label{sec-3-1}

Below is the result from a bumptest on the plant (valve+tank).
\begin{center}
\includegraphics[width=0.7\linewidth]{./figures/hw3-bumptest.png}
\end{center}
The measurement points (\(t_1, y_1\)) and (\(t_2, y_2\)) were moved around in order to find two close points which gave the largest slope \(R = \frac{y_2-y_1}{t_2-t_1}\). The apparent deadtime $L$ is the intersection of the steepest tangent with the time axis. This can be found by noting that if we take the midpoint of $y_1$ and $y_2$ as the tangent point, then $R = \frac{y_2+y_1}{2L}$. We get
\begin{align*}
R &= \frac{y_2-y_1}{t_2-t_1} = 0.73\\
L &= \frac{y_1+y_2}{2R} = 2.85\\
a &= RL = 2.09
\end{align*}

From table 8.2 we obtain the parameters
\begin{align*}
K &= 1.2/a = 0.575\\
T_i &= 2L = 5.69\\
T_d &= 0.5L = 1.42
\end{align*}

\subsection*{Problem 2 - Implement the PID in simulink}
\label{sec-3-2}

The controller is written
\[U(s) = K \left( U_c(s) - Y(s) + \frac{1}{sT_i}\big(U_c(s) - Y(s)\big) - \frac{sT_d}{1 + sT_d/N} Y(s)\right).\]

In \texttt{simulink} the model should look like the following
\begin{center}
\includegraphics[width=0.9\linewidth]{./figures/hw3-pid-block.png}
\end{center}
Note that the derivative part acts only on the feedback signal $-y(t)$. The blocks are
\begin{description}
\item[{Derivative part}] num: [Td, 0], den: [Td/N, 1]
\item[{Integrating part}] num: [ 1 ], den: [Ti, 0]
\end{description}

A step response of the closed-loop system is given below. A step change in the set point occurs at time $t=10$ and then a step in the disturbance occurs at time $t=50$.
\begin{center}
\includegraphics[width=0.6\linewidth]{./figures/hw3-pid-step.png}
\end{center}

We can see that thanks to the integrating part of the controller, there is no steady-state error. It takes the system about 20 seconds to settle. There is some overshoot in the set-point response, but not too much. This should be acceptable.

\subsection*{Problem 3 - Discrete PID}
\label{sec-3-3}

The discretized controller is written
\[ R(\shift) u(kh) = T(\shift) u_c(kh) - S(\shift) y(kh), \]
where
\begin{align*}
 R(\shift) &= (\shift -1)(\shift - a_d)\\
 S(\shift) &= s_0\shift^2 + s_1\shift + s_2\\
T(\shift) &= t_0\shift^2 + t_1\shift + t_2
\end{align*}

Determine the discrete PID controller parameters $a_d$, $s_0$, $s_1$, $s_2$, $t_0$, $t_1$ and $t_2$ using table 8.1 in the textbook (given below).

Using the special discretization (and $b=1$) we get

\begin{align*}
  a_d &= \frac{T_d}{Nh + T_d} = \frac{1.42}{10h + 1.42}\\
  s_0 &= K(1 + b_d) = K(1 + Na_d) = 0.575(1 + \frac{14.2}{10h + 1.42})\\
  s_1 &= -K(1 + a_d + 2b_d - b_i) = -0.575( 1 + \frac{1.42 + 28.4}{10h + 1.42} - \frac{h}{5.69})\\
  s_2 &= K(a_d + b_d - b_ia_d) = 0.575\frac{1.42 + 14.2 - h/5.69}{10h + 1.42}\\
  t_0 &= Kb = 0.575\\
  t_1 &= -K(b(1+a_d) - b_i) = -0.575( \frac{10h + 1.42 + 1.42}{10h + 1.42} - \frac{h}{5.69})\\
  t_2 &= Ka_d(b-b_i) = 0.575 \frac{1.42(1-\frac{h}{5.69})}{10h + 1.42}
\end{align*}
% Emacs 24.5.1 (Org mode 8.2.10)
\end{document}