\documentclass[12pt,fleqn]{article}

\usepackage[paper]{ets-papers}
\setcounter{page}{1}

\input m-defs
\def\TN{450052}
\input colordvi

\title{
  An EMTP Theory Book Correction
}
\author{
  \vbox{\hsize=5.0in \baselineskip=12pt
    E.~T.~Scharlemann
  }
\\Lawrence Livermore National Laboratory
\\Livermore, California 94550
}

\begin{document}

%\topmargin-1in
%\oddsidemargin-1in
%\evensidemargin-1in
%\textheight792pt
%
%\includegraphics[0,0][612,792]{DC-EMTP.ps}
%\thispagestyle{empty}
%
%%\newpage
%%\thispagestyle{empty}

%\topmargin30pt
%\oddsidemargin0in
%\evensidemargin0in

\showllnl
\maketitle
\setcounter{page}{1}

In Carsons' 1926 article ~\cite{Carson} on wave propagation on a wire above the ground, the impedance of an overhead wire or pair of wires with ground return is derived, and expressed in terms of the integral
\[
   J(p, q) = P + i Q = \int_0^\infty \left( \sqrt{\mu^2 + i} - \mu \right) e^{-p\mu} \cos q\mu \; d\mu
\]
with
\[
   r = a = \sqrt{p^2 + q^2}  \ ,
\]
\[
   \theta = \phi = \tan^{-1}(q/p)  \ .
\]

The EMTP Theory Book~\cite{EMTP}, pp.~4-7  to 4-9, presents the equations stated to be used by the Alternative Transients Program ATP (or Electromagnetic Transients Program EMTP) for this impedance. The impedance expressions in~\cite{EMTP} are not the same as the expressions in~\cite{Carson}, although they are supposed to be. The main correction required to bring~\cite{EMTP} into agreement with~\cite{Carson} is to replace
\[
   \sgn = (-1)^{\left[\frac{n - 1}{4} \bmod 2\right]} = 1,1, -1, -1, -1, -1, 1, 1\ldots \text{   for   } n = 3, 4, 5, 6, 7, 8, 9, 10 \ldots
\]
as described just below Eq.~(4.12) of~\cite{EMTP}, with
\[
   \sgn = (-1)^{\left[\frac{n + 1}{2} \bmod 2\right]} = 1,1, -1, -1, 1, 1, -1, -1\ldots \text{   for   } n = 3, 4, 5, 6, 7, 8, 9, 10 \ldots  \ ;
\]
i.e., the sign of the terms in the series for $b$ alternates every two terms rather than every four terms.

The expressions in~\cite{EMTP} should be:
\[
   b_1 = \frac{\sqrt{2}}{6}
\]
\[
   b_2 = \frac{1}{16}
\]
\[
   b_n = \frac{\sgn}{n(n + 2)} b_{n - 2}
\]
\[
   c_2 = 1.3659315 = \ln \frac{2}{\gamma} + 1 + \frac{1}{2} - \frac{1}{4}
\]
($\gamma$ is defined in~\cite{Carson} as 1.7811 and is Euler's constant [$\gamma_E = 0.57722$] exponentiated: $\gamma = e^{\gamma_E}$)
\[
   c_n = c_{n-2} + \frac{1}{n} + \frac{1}{n + 2}
\]
\[
   d_n = \frac{\pi}{4} b_n
\]
\[
   \sgn = (-1)^{\left[\frac{n + 1}{2} \bmod 2\right]} = 1,1, -1, -1, 1, 1, -1, -1\ldots \text{   for   } n = 3, 4, 5, 6, 7, 8, 9, 10 \ldots \ .
\]

Other corrections are simple typographic errors, and have been caught in other references~\cite{Wang} to Carson's formula. With corrections in red, the  expressions for Carson's $P$ and $Q$ in~\cite{EMTP} should be
\begin{align*}
   P = & \frac{\pi}{8} - b_1 a \cos\phi \\
    & + b_2 \left[ (c_2 - \ln a) a^2 \cos 2\phi + \Red{\phi}\; a^2 \sin 2\phi \right] + b_3 a^3 \cos 3\phi  - d_4 a^4 \cos 4\phi - b_5 a^5 \cos 5\phi \\
    & + b_6 \left[ (c_6 - \ln a) a^6 \cos 6\phi + \phi\; a^6 \sin 6\phi \right] + b_7 a^7 \cos 7\phi  - d_8 a^8 \cos 8\phi - b_9 a^9 \cos 9\phi \\
    & + b_{10} \left[ (c_{10} - \ln a) a^{10} \cos 10\phi + \phi\; a^{10} \sin 10\phi \right] + b_{11} a^{11} \cos 11\phi  \\
    & \text{\hskip20mm} - d_{12} a^{12} \cos 12\phi - b_{13} a^{13} \cos 13\phi \ldots
\end{align*}
repeating in groups of four.
\begin{align*}
   Q = & \frac{1}{2}(0.6159315 - \ln a) + b_{\Red{1}} a \cos\phi - d_2 a^2 \cos 2\phi + b_3 a^3 \cos 3\phi \\
    & - b_4 \left[ (c_4 - \ln a) a^4 \cos 4\phi + \phi a^4 \sin 4\phi \right] + b_5 a^5 \cos 5\phi  - d_6 a^6 \cos 6\phi + b_7 a^7 \cos 7\phi \\
    & - b_8 \left[ (c_8 - \ln a) a^8 \cos 8\phi + \phi a^8 \sin 8\phi \right] + b_9 a^9 \cos 9\phi  - d_{10} a^{10} \cos 10\phi + b_{11} a^{11} \cos 11\phi \\
    & - b_{12} \left[ (c_{12} - \ln a) a^{12} \cos 12\phi + \phi a^{12} \sin 12\phi \right] + b_{13} a^{13} \cos 13\phi  \\
    & \text{\hskip20mm} - d_{14} a^{14} \cos 14\phi + b_{15} a^{15} \cos 15\phi \ldots
\end{align*}
also repeating in groups of four. The term 0.6159315 is $1/2 + \log(2/\gamma)$, and the $P$ and $Q$ are the terms inside the curly brackets of Eq.~(4.11) of~\cite{EMTP}. The typographical errors above were corrected in~\cite{Wang} but not the ordering of signs in the $b$ series.

For reference, Carson's equations~\cite{Carson} are (with $r = a$ and $\theta = \phi$):
\[
   s_2 = \frac{1}{1!2!} \left(\frac{r}{2}\right)^2 \cos 2\theta
    -\frac{1}{3!4!} \left(\frac{r}{2}\right)^6 \cos 6\theta
    +\frac{1}{5!6!} \left(\frac{r}{2}\right)^{10} \cos 10\theta \ldots
\]
\[
   s_2^\prime = \frac{1}{1!2!} \left(\frac{r}{2}\right)^2 \sin 2\theta
    -\frac{1}{3!4!} \left(\frac{r}{2}\right)^6 \sin 6\theta
    +\frac{1}{5!6!} \left(\frac{r}{2}\right)^{10} \sin 10\theta \ldots
\]
\[
   s_4 = \frac{1}{2!3!} \left(\frac{r}{2}\right)^4 \cos 4\theta
    -\frac{1}{4!5!} \left(\frac{r}{2}\right)^8 \cos 8\theta
    +\frac{1}{6!7!} \left(\frac{r}{2}\right)^{12} \cos 12\theta \ldots
\]
\[
   s_4^\prime = \frac{1}{2!3!} \left(\frac{r}{2}\right)^4 \sin 4\theta
    -\frac{1}{4!5!} \left(\frac{r}{2}\right)^8 \sin 8\theta
    +\frac{1}{6!7!} \left(\frac{r}{2}\right)^{12} \sin 12\theta \ldots
\]
\[
   \sigma_1 = \frac{r \cos\theta}{3} - \frac{r^5 \cos 5\theta}{3^2 5^2 7} + \frac{r^9 \cos 9\theta}{3^2 5^2 7^2 9^2 11} \ldots
\]
\[
   \sigma_3 = \frac{r^3 \cos 3\theta}{3^2 5} - \frac{r^7 \cos 7\theta}{3^2 5^2 7^2 9} + \frac{r^{11} \cos 11\theta}{3^2 5^2 7^2 9^2 11^2 13} \ldots
\]
\begin{align*}
   \sigma_2 = & \left( 1 + \frac{1}{2} - \frac{1}{4}\right) \frac{1}{1! 2!} \left(\frac{r}{2}\right)^2 \cos 2\theta \\
   & - \left( 1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} - \frac{1}{8}\right) \frac{1}{3! 4!} \left(\frac{r}{2}\right)^6 \cos 6\theta \\
   & + \left( 1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \frac{1}{5} + \frac{1}{6} - \frac{1}{12}\right) \frac{1}{5! 6!} \left(\frac{r}{2}\right)^{10} \cos 10\theta \ldots
\end{align*}
\begin{align*}
   \sigma_4 = & \left( 1 + \frac{1}{2} + \frac{1}{3} - \frac{1}{6}\right) \frac{1}{2! 3!} \left(\frac{r}{2}\right)^4 \cos 4\theta \\
   & - \left( 1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \frac{1}{5} - \frac{1}{10}\right) \frac{1}{4! 5!} \left(\frac{r}{2}\right)^8 \cos 8\theta \\
   & + \left( 1 + \frac{1}{2} + \frac{1}{3} + \frac{1}{4} + \frac{1}{5} + \frac{1}{6} + \frac{1}{7} - \frac{1}{14}\right) \frac{1}{6! 7!} \left(\frac{r}{2}\right)^{12} \cos 12\theta \ldots
\end{align*}
\[
   P = \frac{\pi}{8}\left(1 - s_4\right) + \frac{1}{2} \left(\ln\frac{2}{\gamma} - \ln r\right)s_2 + \frac{\theta}{2} s_2^\prime - \frac{1}{\sqrt{2}}\sigma_1 + \frac{1}{2}\sigma_2 + \frac{1}{\sqrt{2}}\sigma_3  \ ,
\]
\[
   Q = \frac{1}{4} + \frac{1}{2} \left(\ln\frac{2}{\gamma} - \ln r\right)\left(1 - s_4\right) - \frac{\theta}{2} s_4^\prime - \frac{\pi}{8} s_2 + \frac{1}{\sqrt{2}}\sigma_1 + \frac{1}{\sqrt{2}}\sigma_3 - \frac{1}{2}\sigma_4  \ .
\]

Fig.~\ref{fig:l} compares the numerical results for $0 < r <= 10$ at  $\theta = 2\pi/3$ for the series in~\cite{Carson} with the corrected series from~\cite{EMTP}.
\begin{figure}[H]
  \hbox{
     \includegraphics[width=3in]{carson.ps}
     \includegraphics[width=3in]{emtp.ps}
  }
  \caption{Comparison of results for Carson's series at $\theta = 2\pi/3$ (left) and the corrected EMTP Theory Book series at the same value for $\phi$ (right). Terms up to and including $r^{23}$ (or $a^{23}$) were retained in the series to get valid results to $a = r = 10$.}
  \label{fig:l}
\end{figure}

Python programs (and typeset \LaTeX) to calculate (and display) both Carson's series and the corrected EMTP Theory Book series are available from the author.

Comparison of the corrected EMTP Theory Book series and Carson's series with the results of ATP for the impedance of a single wire above
the ground plane suggests that ATP in fact uses the correct expressions, and \emph{not} what is described in the EMTP Theory Book. Regrettably, we have been unable to obtain the source code for ATP to verify this inference.

\section*{Acknowledgments}

I am happy to acknowledge useful conversations with Barry Kirkendall and Nils Stenvig.

This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under Contract DE-AC52-07NA27344.

\vskip5mm
\baselineskip=12pt
\begin{thebibliography}{9}

\bibitem{Carson} J.~R.~Carson, ``Wave Propagation in Overhead Wires with Ground Return'', \emph{Bell System Technical Journal}, {\bf 5}, 539-554 (1926).

\bibitem{EMTP} H.~W.~Dommel, ``Electromagnetic Transients Program (EMTP) Theory Book'', Bonneville Power Administration, Portland, OR (1981 or 1986 or 1994 or ?).

\bibitem{Wang} Y.-J.~Wang and S.-J.~Liu, ``A Review of Methods for Calculation of Frequency-dependent Impedance of Overhead Power Transmission Lines,'' \emph{Proc.~Natl.~Sci.~Counc.~ROC(A)}, {\bf 25}, No.~6, pp.~329-338 (2001).

\end{thebibliography}

\vskip5mm
\hrule
\vskip5mm
\parindent=0pt

%\ets

\end{document}


\subsection{Isoquants}

Isoquants are indifference curves for firms.

We have a production function: \(Q=f(X)\).

An isoquant is defined for each \(c\) \(f(X)=c\), where \(X\) is a vector.

\subsection{Marginal rate of technical substitution}

This is the marginal rate of substitution, adapted for firms.

\(MRTS=\)

\subsection{Marginal and average costs}

\subsection{Average total cost}

\subsection{Long-run average incremental cost}


\section{Method}
\label{sec:method}

\subsection{The data}
\label{sec:the_data}

We used the publicly available \kepler-\gaia\ DR2 crossmatched
catalog\footnote{Available at gaia-kepler.fun} to combine the \mct\ catalog of
stellar rotation periods, measured from \kepler\ light curves, with the \gaia\
DR2 catalog of parallaxes, proper motions and apparent magnitudes.
Reddening and extinction from dust was calculated for each star using the
Bayestar dust map implemented in the {\tt dustmaps} {\it Python} package
\citep{green2018}, and {\tt astropy} \citep{astropy2013, astropy2018}.

For this work, we used the precise \textit{Gaia} DR2 photometric color,
$G_{\rm BP} - G_{\rm RP}$, to estimate \teff\ for the Kepler rotators.
To calibrate this relation, Curtis \etal\ (2020, in prep) combined effective
temperature measurements for nearby, unreddened field stars in benchmark
samples, including FGK stars characterized with high-resolution optical
spectroscopy \citep{brewer2016}, M dwarfs characterized with low-resolution
optical and near-infrared spectroscopy \citep{mann2015}, and K and M dwarfs
characterized with interferometry and bolometric flux analyses
\citep{boyajian2012}.
This empirical color--temperature relation is valid over the color range $0.55
< (G_{\rm BP} - G_{\rm RP})_0 < 3.20$, corresponding to $6470 < T_{\rm eff} <
3070$~K.
The dispersion about the relation implies a high precision of 50~K.
These benchmark data enable us to accurately estimate \teff\ for cool dwarfs
\citep[\eg][]{rabus2019}, and allows us to correct for interstellar reddening
at all temperatures\footnote{The color--temperature relation is described in
detail in the Appendix of, and the formula is provided in Table 4 of, Curtis
\etal\ (2020, in prep).}.
The equation we used to calculate photometric temperatures from Gaia \gcolor\
color is a seventh-order polynomial with coefficients given in table
\ref{tab:coeffs}.
\begin{table}[h!]
  \begin{center}
      \caption{
          Coefficient values for the 7th-order polynomial used to estimate
      \teff\ from \Gaia\ \gcolor\ color, calibrated in Curtis \etal\ (2020, in
      prep).}
    \label{tab:coeffs}
    \begin{tabular}{l|c} % <-- Alignments: 1st column left and 2nd middle, with vertical lines in between
        (\gcolor\ ) exponent & Coefficient  \\
      \hline
      $0$ & -416.585 \\
      $1$ & 39780.0  \\
      $2$ & -84190.5 \\
      $3$ & 85203.9  \\
      $4$ & -48225.9 \\
      $5$ & 15598.5  \\
      $6$ & -2694.76 \\
      $7$ & 192.865  \\
    \end{tabular}
  \end{center}
\end{table}

Photometric binaries and subgiants were removed from the \mct\ sample by
applying cuts to the color-magnitude diagram (CMD), shown in figure
\ref{fig:age_gradient}.
A 6th-order polynomial was fit to the main sequence and raised by 0.27 dex to
approximate the division between single stars and photometric binaries (shown
as the curved dashed line in figure \ref{fig:age_gradient}).
All stars above this line were removed from the sample.
Potential subgiants were also removed by eliminating stars brighter than 4th
absolute magnitude in \gaia\ G-band.
This cut also removed a number of main sequence F stars from our sample,
however these hot stars are not the focus of our gyrochronology study since
their small convective zones inhibit the generation of a strong magnetic
field.
The removal of photometric binaries and evolved/hot stars reduced the total
sample of around 34,000 stars by almost 10,000.

The rotation periods of the dwarf stars in the \mct\ sample are shown on a
\gaia\ color-magnitude diagram (CMD) in the top panel of figure
\ref{fig:age_gradient}.
In the bottom panel, the stars are colored by their gyrochronal age,
calculated using the \citet{angus2019} gyrochronology relation.
The stars with old gyrochronal ages, plotted in purple hues, predominantly lie
along the upper edge of the MS, where stellar evolution models predict old
stars to be, however the majority of these `old' stars are bluer than \gcolor\
$\sim$ 1.5 dex.
The lack of gyrochronologically old M dwarfs suggests that either old M dwarfs
are missing from the \mct\ catalog, or the \citet{angus2019} gyrochronology
relation under-predicts the ages of low-mass stars.
Given that lower-mass stars stay active for longer than higher-mass stars
\citep[\eg][]{west2008, newton2017, kiman2019}, and are therefore more likely
to have measurable rotation periods at old ages, the latter scenario seems
likely.
However, it is also possible that the rotation periods of the oldest early M
dwarfs are so long that they are not measurable with Kepler data.
Ground-based rotation period measurements of mid and late M dwarfs indicate
that there is an upper limit to the rotation periods of {\it late} M dwarfs of
around 140 days \citep{newton2016, newton2018}, which is much
longer than the longest rotation periods measured in the \mct\ sample (around
70 days).
The apparent lack of old gyro-ages for M dwarfs in figure
\ref{fig:age_gradient} may be caused by a combination of ages being
underestimated by a poorly calibrated model, and rotation period detection
bias.
The \citet{angus2019} gyrochronology relation is a simple polynomial model,
fit to the period-color relation of Praesepe.
Inaccuracies at low masses are a typical feature of empirically calibrated
gyrochronology models since there are no (or at least very few) old M dwarfs
with rotation periods and the models are poorly calibrated for these stars.
\begin{figure}
  \caption{
      Top: de-reddened MS \kepler\ stars with \mct\ rotation periods, plotted
    on a \gaia\ CMD.
    We removed photometric binaries and subgiants from the sample by excluding
    stars above the dashed lines.
    Bottom: a zoom-in of the top panel, with stars colored by their
    gyrochronal age \citep{angus2019}, instead of their rotation period.
    A general age gradient is visible across the main sequence.
    Since the \citet{angus2019} relation predicts that the oldest stars in
    the \mct\ sample are late-G and early-K dwarfs, it is probably
    under-predicting the ages of late-K and early-M dwarfs.
}
  \centering
    \includegraphics[width=1\textwidth]{CMD_cuts_double}
\label{fig:age_gradient}
\end{figure}

The {\tt Pyia} \citep{price-whelan_2018} and {\tt astropy} \citep{astropy2013,
astropy2018} {\it Python} packages were used to calculate velocities for the
\mct\ sample.
{\tt Pyia} calculates velocity samples from the full \gaia\ uncertainty
covariance matrix via Monte Carlo sampling, thereby accounting for the
covariances between \gaia\ positions, parallaxes and proper motions.
Stars with negative parallaxes or parallax signal-to-noise ratios less than 10
(around 3,000 stars), stars fainter than 16th magnitude (200 stars), stars
with absolute \vb\ uncertainties greater than 1 \kms\ (1000 stars), and stars
with galactic latitudes greater than 15\degrees\ (5500 stars, justification
provided in the appendix) were removed from the sample.
Finally, we removed almost 2000 stars with rotation periods shorter than the
main population of periods, since this area of the period-\teff\ diagram is
sparsely populated.
We removed these rapid rotators by cutting out stars with gyrochronal ages
less than 0.5 Gyr \citep[based on the][gyro-model]{angus2019}, because a 0.5
Gyr gyrochrone\footnote{A gyrochrone is a gyrochronological isochrone, or a
line of constant age in period-\teff, or period-color space.} traces the
bottom edge of the main population of rotation periods.
After these cuts, around 13,000 stars out of the original $\sim$34,000 were
included in the sample.


\chapter{Assignment: Image Analytics}
\label{ch:arheo_image_analytics}

\newthought{Archaeologists often analyze images of artefacts}, from sketches of items to photographs of sites and findings. \marginnote{Images are available at \url{http://file.biolab.si/datasets/amphorae.zip}}We retrieved 164 digital sketches of amphorae belonging to 3 different types - Dressel, Gauloise, and Keay. Consider we have an archive of such images and we wish to automatically label new sketches with their corresponding amphora type.

\begin{wrapfigure}{o}{0.75\textwidth}
    \vspace{-0.5cm}
    \includegraphics[scale=0.6]{intermediate-workflow.png}
\end{wrapfigure}

First, we load images with \widget{Import Images} from the Image Analytics add-on. Our images are organized, each type of amphora being in it own folder. Folders will be treated as categories upon loading. This means each image will get a special label with the name of the folder - the target variable.

Second, we have metadata belonging to each subtype of amphora (Dressel 6b, Gauloise 13, etc.). Load this with \widget{File} and join the two tables with \widget{Merge Data}. The widget should automatically recognize the attribute to merge by, but it case it doesn't, set both to \textit{image name}. Finally, we will use \widget{Select Columns} to put all the metadata to metas. Remember, our aim is to classify amphorae based on their image, not their description.

\begin{figure*}[h]
    \centering
    \includegraphics[width=\textwidth]{embeddings.png}
    \caption{$\;$} % empty caption for proper page setting
\end{figure*}

But machine learning works with numbers and images are not numbers, but complex objects. We need a way to transform images to a numeric description. We will use \widget{Image Embedding}, a widget that uses pre-trained deep models to infer image profiles. A common embedder is Google's Inception v3, which we will use for this exercise. Finally, we have our numbers! Specifically, a 2048-dimensional vector for each image.

Now, we can train a few classifiers. Common models for image classification are \widget{kNN}, \widget{Logistic Regression}, and \widget{SVM}, so let's use these. It looks like SVM has the highest AUC score, but Logistic Regression performs the best in other metrics.

\begin{figure}[h]
    \centering
    \includegraphics[scale=0.5]{test-and-score.png}
    \caption{$\;$} % empty caption for proper page setting
\end{figure}

\subsection{Assignment}

\begin{itemize}
    \item Observe \widget{Confusion Matrix} and determine which model is better to use in practice and why.
    \item Which type of amphorae is the most difficult to predict? How could we improve the performance? Select different misclassifications in Confusion Matrix and explore them in Image Viewer.
    \item There are three new images to predict. Use amphorae-predict and load it with Import Images. Pass it to Image Embedding, then use Predictions and the chosen model to predict image type. How accurate is the model? Would you use it in practice? Why (not)?
\end{itemize}

\begin{figure*}[h]
    \centering
    \includegraphics[width=\textwidth]{final-workflow.png}
    \caption{$\;$} % empty caption for proper page setting
\end{figure*}


\section{Summary of findings}

\begin{figure}
\img{PR-and-latency--0_7}
\captionn{Performance comparison of the best SWR detectors}{Legend as in \cref{fig:BPF-performance}. ``Proposed online BPF'' is the best representative of the current generation of SWR detectors (band-pass filters on a pyramidal cell layer channel; see \cref{ch:BPF}). ``GEVec'' and ``Recurrent neural network'' (RNN) are the newly investigated, data-driven algorithms. Using the GEVec algorithm with about ten delay samples (corresponding to 10 ms at $f_s = 1000$ Hz) yielded optimal performance (see \cref{ch:GEVec}). Both a version of the GEVec algorithm using multiple, spatially distributed input channels (``all ch.''), and a version using the same, single input channel as the band-pass filter (``pyr ch.'') are presented here. The RNN here used all input channels. \newline
The GEVec-based detectors and the band-pass filter have very similar performance. The GEVec-based detectors have very slightly lower latency (Difference in medians of relative latency is $\pm$ 6 percentage-points. Difference in medians of absolute latency is 2 milliseconds). In the high recall regime (at $R > 93\%$), the band-pass filter is slightly more precise (less false positive detections). The single-channel and the multichannel GEVec-based detectors show near identical performance.}
\label{fig:PR-and-latency-conclusion}
\end{figure}

We compared different existing online ripple detection filters from the literature. We found important differences between these filters (see \cref{sec:recommend}). We proposed a band-pass filter (labelled ``Proposed online BPF'' in \cref{fig:PR-and-latency-conclusion}) that is at least as good as the filters from the literature, and used this as a baseline for comparison. Additionally, we defined a framework to quantify the performance of online SWR detection algorithms.

We then investigated, for the first time, two data-driven, multichannel algorithms for SWR detection. The first, based on the generalized eigenvector (GEVec) decomposition, achieves performance roughly on par with the best online band-pass filter (BPF); see \cref{fig:PR-and-latency-conclusion}). Additionally, its output envelope is very similar to those of online band-pass filters, suggesting that the GEVec-based algorithm finds filters similar to those of the explicitly designed online band-pass filters.

The GEVec-based algorithm uses multiple past input samples of the LFP to calculate the current output sample. We found that using about ten such delayed samples (corresponding to 10 ms at $f_s = 1000$ Hz) yielded optimal performance.

The GEVec-based algorithm has a very slightly lower detection delay than the proposed online BPF, while the online BPF yields a slightly lower amount of false positives in the high recall regime. These differences might not hold up when analyzing data from multiple recordings, animals, and electrode setups, however.

To investigate the use of multiple input channels, we also applied the GEVec-based algorithm to a single channel of input data. This yielded an online SWR detector with near identical performance and output envelopes as the multichannel GEVec-based detector. This suggests that, at least for this algorithm and under the constraints discussed in \cref{sec:limits}, using multiple, spatially distributed input channels is not advantageous for online SWR detection.

The second algorithm investigated, a type of recurrent neural network (RNN), showed worse detection performance than the band-pass and GEVec-based filters, under the used evaluation scheme (see \cref{fig:PR-and-latency-conclusion}). Analyzing its output envelopes however (see \cref{fig:RNN-envelopes,fig:RNN-profile}) reveals an interesting finding. Although the RNN was only trained on segments with strong ripple-oscillations, its output also yields high-confidence detections whenever the low-frequency spatiotemporal signature of an SWR is present (as described in \cref{ch:SWR} on SWR anatomy and physiology), but without necessarily any strong ripple oscillation present.

% - We can only marginally improve sota
%   (2 ms d median; ~6% percentage points; while high-recall PR performance is slightly worse).
% - Real (first?) quantification and comparison of band-pass filters
% - 10 delays / ms best for gevec
% - Take care with BPF: possible to introduce unnecessary (group) delay.
% - Using more than one electrode for detection (such as a stratum radiatum electrode in addition to the stratum pyramidale electrode, or multiple stratum pyramidale electrodes) does not significantly improve accuracy nor latency.


\begin{intro}
  We can embed finite element methods for the Darcy problem, also for
  the Maxwell problem, into a common framework based on the de Rham
  complex. If we wanted to do this in its full mathematical beauty, we
  would have to spend some time introducing the concept and notation
  of differential forms. As an alternative, we can use the concrete
  vector spaces $\Hdiv(\domain)$ and $\Hcurl(\domain)$. The drawback
  is, that we have to prove several particular cases, where the
  abstract theory only knows one common case. Nevertheless, it is
  worthwhile to begin this way, such that the reader has an easier
  task reading the full theory
  in~\cite{ArnoldFalkWinther06acta,ArnoldFalkWinther10}. As a byproduct,
  we will prove in generality some of the properties of polynomial
  spaces in Chapter~\ref{cha:darcy}.
\end{intro}

\subsection{Excursion to differential forms}

\input{alt}

\subsection{Well-posedness of the Maxwell problem}

\begin{Definition}{hlambda}
  The space $H\Lambda^k(\domain)$ is the closure of $\Lambda^k(\domain)$
  under the norm corresponding to the inner product
  \begin{gather}
    \scal(u,v)_{H\Lambda^k}
    = \scal(u,v)_{L^2\Lambda^k}
    + \scal(d u, d v)_{L^2\Lambda^{k+1}}.
  \end{gather}
  The space $H\Lambda^k_0(\domain)$ is the closure of
  $C^{\infty}_{00}\Lambda^k(\domain)$ with respect to the same norm.

  Both spaces are Hilbert spaces and we have
  \begin{gather}
    \gamma\omega(v_1,\dots,v_k) = 0 \qquad
    \forall \omega\in H\Lambda^k_0(\domain),
  \end{gather}
  and tangential vector fields $v_1,\dots,v_k$.
\end{Definition}

\begin{Notation}{hlambda}
  We can summarize the results of the previous section by the notation
  of the \define{Hilbert cochain complex}\index{cochain complex} of
  differential forms and the corresponding cochain complex for proxy
  fields
  \begin{gather}\minCDarrowwidth20pt
    \label{eq:derham:9}
    \begin{CD}
      \R
      @>{d}>> H\Lambda^0(\domain)
      @>{d}>> H\Lambda^1(\domain)
      @>{d}>> H\Lambda^2(\domain)
      @>{d}>> H\Lambda^3(\domain)
      @>>> 0
      \\
      @.
      @V{\cong}VV
      @V{\cong}VV
      @V{\cong}VV
      @V{\cong}VV
      \\
      \R
      @>{\subset}>> H^1(\domain)
      @>{\nabla}>> \Hcurl(\domain)
      @>{\curl}>> \Hdiv(\domain)
      @>{\div}>> L^2(\domain)
      @>>> 0,
    \end{CD}
  \end{gather}
  such that $d=d_k\colon H\Lambda^k(\domain) \to H\Lambda^{k+1}(\domain)$ and
  \begin{gather}
    d^2 = d\circ d = d_{k+1} \circ d_k = 0.
  \end{gather}
\end{Notation}

\begin{remark}
  The spaces $H\Lambda^k(\domain)$ are Hilbert spaces with values in
  the spaces of alternating $k$-forms on $\R^d$. From linear algebra,
  we know that all alternating $k$-forms are zero if $k$ exceeds the
  dimension of the vector space.  Therefore, the sequence above is
  only valid in three dimensions, and it must be shorter by one member
  in two dimensions. Changing our view back to differential operators,
  we realize that there are two relevant sequences in two
  dimensions. In the following diagram, the sequence on top can be
  used to formulate Maxwell problems in $\Hcurl$ in two dimensions,
  while the sequence on the bottom relates to the mixed form of the
  Laplacian.

  We introduce the sequences in two dimensions and afterwards will
  focus our arguments on the more general case of three dimensions
  again. Specialization to two dimensions are straight forward.
\end{remark}

\begin{Notation}{hlambda-2d}
  In two dimensions, we consider the de Rham sequences
  \begin{gather}\minCDarrowwidth20pt
    \label{eq:derham:8}
    {\small
    \begin{CD}
      \R
      @>{\subset}>> H^1(\domain)
      @>{\nabla}>> \Hcurl(\domain)
      @>{\curl}>> L^2(\domain)
      @>>> 0
      \\
      @.
      @A{\cong}AA
      @A{\cong}AA
      @A{\cong}AA
      \\
      \R
      @>{d}>> H\Lambda^0(\domain)
      @>{d}>> H\Lambda^1(\domain)
      @>{d}>> H\Lambda^2(\domain)
      @>>> 0
      \\
      @.
      @V{\cong}VV
      @V{\cong}VV
      @V{\cong}VV
      \\
      \R
      @>{\subset}>> H^1(\domain)
      @>{\curl}>> \Hdiv(\domain)
      @>{\div}>> L^2(\domain)
      @>>> 0,
    \end{CD}
    }
  \end{gather}
\end{Notation}

The value of this notation lies in the following theorem by de Rham,
which describes the relation between the elements of the sequence. It
is cited here without proof.

\begin{Definition}{cohomology-space}
  The \define{cohomology group} in $\Lambda^k(\domain)$ is defined in
  differential geometry as
  \begin{gather}
    \mathcal H_k(\domain) = \nicefrac{\ker{d_k}}{\range{d_{k-1}}}.
  \end{gather}
  Since we have a Hilbert space structure, we can much more
  conveniently choose a representative in $\ker{d_k} \subset H\Lambda^k(\domain)$
  \begin{gather}
    \mathcal H_k(\domain) = \bigl\{ \omega\in \ker{d_k}
    \;\big|\;
    \form(\omega,d\eta) = 0 \quad\forall \eta\in H\Lambda^{k-1}(\domain)
    \bigr\}.
  \end{gather}
  For spaces $H\Lambda^k_0(\domain)$ defined below, $\mathcal H_k$ is
  defined in an analogous way.
\end{Definition}

\begin{Theorem*}{de-rham-1}{de Rham}
  The dimension of the cohomology groups is equal to the Betti
  numbers, which in turn depend only on the topology of the
  domain. These depend on the number of ``holes of dimension
  $k$''. For a Lipschitz domain, they are finite. For a simply
  connected domain, they are all zero.
\end{Theorem*}

\begin{Theorem*}{de-rham}{de Rham for Hilbert complexes}
  Assume the domain $\domain$ is Lipschitz.  If $\domain$ is simply
  connected, the sequences in equations~\eqref{eq:derham:9}
  and~\eqref{eq:derham:8} are exact, that is, there holds
  \begin{gather}
    \label{eq:derham:7}
    \ker {d_{k+1}} = \range{d_k}.
  \end{gather}
  If it is not simply connected, the codimension of $\range{d_k}$ in
  $\ker{d_{k+1}}$ is finite and only determined by the topology of
  $\domain$. In particular, $\range{d_k}$ is closed in
  $H\Lambda^{k+1}(\domain)$.
\end{Theorem*}

\begin{Corollary}{de-rham-1}
  Let
  \begin{gather}
    V_0 = \bigl\{ \omega\in H\Lambda^k(\domain)
    \; \big| \;
    \form(\omega, d\eta)_{L^2\Lambda^k(\domain)} = 0
    \quad\forall\eta\in H\Lambda^{k-1}(\domain)\bigr\}.
  \end{gather}
  The problem: find $\omega\in V_0$ such that
  \begin{gather}
    \form(d \omega, d\mu) = \form(f,\mu)
    \qquad\forall \mu\in V_0,
  \end{gather}
  has a unique solution on a simply connected domain.
\end{Corollary}

\begin{Example}{de-rham-1}
  Consider the case $H\Lambda^0(\domain) = H^1(\domain)$. Then, $V_0$
  is the space of functions orthogonal to constants, and we seek a
  solution $p\in  V_0$ such that
  \begin{gather}
    \form(\nabla p, \nabla q) = (f,q) \qquad\forall q\in V_0.
  \end{gather}
\end{Example}

\begin{Corollary}{de-rham-2}
  Let
  \begin{gather}
    V_0 = \left\{ \omega\in H\Lambda^k(\domain)
        \; \middle| \;
        \arraycolsep1pt
        \begin{array}{rcll}
          \form(\omega, d\eta)
          &=&0
          &\;\forall\eta\in H\Lambda^{k-1}(\domain)\\
          \form(\omega,\tau)
          &=&0
          &\;\forall \tau\in \mathcal H_k(\domain)
        \end{array}
  \right\}.
  \end{gather}
  The problem: find $\omega\in V_0$ such that
  \begin{gather}
    \form(d \omega, d\mu) = \form(f,\mu)
    \qquad\forall \mu\in V_0,
  \end{gather}
  has a unique solution.
\end{Corollary}

So far, we have not considered boundary conditions. The next lemma,
which is again stated without proof, indicates that the properties of
the de Rham complex are inherited, if the appropriate boundary
conditions are applied to each space, namely, function values in
$H^1$, tangential traces in $\Hcurl$, and normal traces in
$\Hdiv$. The last restriction from $L^2$ to $L^2_0$ is not a boundary
condition, but it is the compatibility condition implied by the Gauss
theorem on $\Hdiv$.

\begin{Lemma}{hlambda-0}
  The Hilbert cochain complex with boundary values
  \begin{gather}\minCDarrowwidth20pt
    {\small
    \begin{CD}
      0
      @>{d}>> H\Lambda^0_0(\domain)
      @>{d}>> H\Lambda^1_0(\domain)
      @>{d}>> H\Lambda^2_0(\domain)
      @>{d}>> H\Lambda^3_0(\domain)
      @>>> 0
      \\
      @.
      @V{\cong}VV
      @V{\cong}VV
      @V{\cong}VV
      @V{\cong}VV
      \\
      0
      @>>> H^1_0(\domain)
      @>{\nabla}>> \Hcurl_0(\domain)
      @>{\curl}>> \Hdiv_0(\domain)
      @>{\div}>> L^2_0(\domain)
      @>>> 0,
    \end{CD}
    }
  \end{gather}
  has the same properties as stated for the Hilbert complex without
  boundary conditions.
\end{Lemma}

% \begin{Example}{not-simply-connected}

% \end{Example}

\begin{remark}
  The complex does not start with $\R$ on the left, but with zero,
  since the constant functions are not members of $H^1_0(\domain)$.

  On the other hand, we could have replaced the right end of the
  complex by
  \begin{gather}
    L^2(\domain) \xrightarrow{\frac1{\abs{\domain}}\int} \R,
  \end{gather}
  where the arrow is the mean value operator.
\end{remark}

\begin{Lemma}{de-rham-3}
  The problem: find
  \begin{gather}
    (\omega,\eta,\theta)
    \in H\Lambda^1_0(\domain)
    \times H\Lambda^{0}_0(\domain)
    \times \mathcal H_1(\domain)
  \end{gather}
   such that
  \begin{gather}
    \arraycolsep1pt
    \begin{array}{cccccclll}
      \form(d \omega, d\mu) &+& \form(\mu,d\eta) &+& \form(\theta,\mu)
      &=& \form(f,\mu)
      & \qquad & \forall \mu\in H\Lambda^1_0(\domain)
      \\
      \form(\omega,d\zeta) && && &=&0
      & \qquad & \forall \zeta\in H\Lambda^{0}_0(\domain)
      \\
      \form(\omega,\tau) && && &=& 0
      & \qquad & \forall \tau\in \mathcal H_1(\domain).
    \end{array}
  \end{gather}
  is well-posed.
\end{Lemma}

\begin{Theorem}{div-curl-well-posed}
  Let $\domain$ be simply connected. Then, the Maxwell problem in
  \slideref{Definition}{Maxwell-mixed-0} is well posed.
\end{Theorem}

\begin{proof}
  We have to show the inf-sup condition and the ellipticity of the
  curl-curl bilinear form. Let us introduce
  \begin{gather}
    a(u,v) = \form(\curl u, \curl v),
    \qquad
    b(v,q) = \form(v,\nabla q).
  \end{gather}
  From the fact that the de Rham complex starts with zero, we obtain
  that the kernel of the gradient is zero. Thus, for any $q\in
  H^1_0(\domain)\setminus\{0\}$, we have $v = \nabla q \neq 0$ and
  $\norm{v}_{\Hcurl} = \norm{v}_{L^2} \le \norm{q}_{H^1}$. Thus, the
  inf-sup condition holds.

  We show now that $a(.,.)$ is elliptic on $\ker B$. From the
  definition of $b(.,.)$, we deduce that
  $\ker B \perp \nabla H^1_0(\domain) = \ker A$. Thus, $A$ is an
  isomorphism between $\ker B$ and its dual, and consequently
  elliptic.
\end{proof}

\begin{Problem}{darcy-derham}
  Prove well-posedness for the Darcy problem using the de Rham complex
  for proving \slideref{Lemma}{darcy-reduced-wellposed} and
  \slideref{Lemma}{darcy-infsup}.
\begin{solution}
From the last step
 \begin{gather}\minCDarrowwidth20pt
    \begin{CD}
      \Hdiv_0(\domain)
      @>{\div}>> L^2_0(\domain)
      @>>> 0,
    \end{CD}
  \end{gather}
we deduce $L_0^2(\Omega)=\range{\nabla\cdot}$. In particular, this means
that for all $q\in L_0^2(\Omega)$ there exists $v\in H_0^{\text{div}}$ such that
$\nabla \cdot v=q$ and $\norm{v}_{H^{\text{div}}}\leq C \norm{q}_0$.
Hence, it holds the estimate
\begin{align}
\inf_{q\in Q}\sup_{v\in V}\frac{(\nabla \cdot v, q)}{\norm{q}_Q\norm{v}_V}
  \geq \inf_{q\in Q} \frac{\norm{q}_0}{\norm{v}_{H^{\text{div}}}}\geq C.
\end{align}
where $q = \nabla \cdot v$. Ellipticity of the bilinear form is obvious
\begin{align}
  \norm{u}_{H^{\text{div}}}=\norm{u}_0 \quad \forall u\in \ker B.
\end{align}
\end{solution}
\end{Problem}

\section{Polynomial complexes for simplicial meshes}

\begin{intro}
  We have already seen that adding $\vx\P_r$ to the space $\P_r^\sdim$, we
  obtain a surjective divergence operator from the Raviart-Thomas
  element to the pressure space $\P_k$. In this section, we see that
  there is a general principle behind this concept and it can be
  extended to the curl and gradient operators.
\end{intro}

\begin{Notation}{pk-complex}
  The polynomial complex $\P_r\Lambda^k$ consists of $k$-forms with
  coefficients in the polynomial space $\P_r$.

  The homogeneous polynomial spaces $\breve\P_k$ and their proxy
  fields form the cochain complex
  \begin{gather}\minCDarrowwidth15pt
    \begin{CD}
      0
      @>{d}>> \breve\P_r\Lambda^0
      @>{d}>> \breve\P_{r-1}\Lambda^1
      @>{d}>> \breve\P_{r-2}\Lambda^2
      @>{d}>> \breve\P_{r-3}\Lambda^3
      @>{d}>> 0
      \\
      @.
      @V{\cong}VV
      @V{\cong}VV
      @V{\cong}VV
      @V{\cong}VV
      \\
      0
      @>{\subset}>> \breve\P_r
      @>{\nabla}>> \breve\P_{r-1}^3
      @>{\curl}>> \breve\P_{r-2}^3
      @>{\div}>> \breve\P_{r-3}
      @>>> 0,
    \end{CD}
  \end{gather}
  and $d_{k+1}\circ d_k = 0$.

  Note the special cases $r=0$ and $r=3$, namely
  \begin{gather}\minCDarrowwidth15pt
    \begin{CD}
      0
      @>{\subset}>> \R
      @>{\cong}>> \breve\P_0
      @>{\nabla}>> 0\\
      0
      @>{\subset}>> \breve\P_3
      @>{\nabla}>> \breve\P_{2}^3
      @>{\curl}>> \breve\P_{1}^3
      @>{\div}>> \breve\P_{0}
      @>{\cong}>> \R
      @>>> 0,
    \end{CD}
  \end{gather}
\end{Notation}

\begin{remark}
  Since the polynomial space $\P_r$ is the direct sum
  \begin{gather}
    \P_r = \bigoplus_{s=0}^r \breve\P_s,
  \end{gather}
  the homogeneous polynomial complex above can be extended to a
  general polynomial complex in a straightforward way.
\end{remark}

\subsection{The Koszul complex}

\begin{Definition}{koszul-differential}
  We define the \define{Koszul differential} as a map
  \begin{gather}
    \kappa\colon \Lambda^k(\R^\sdim) \to \Lambda^{k-1}(\R^\sdim),
  \end{gather}
  such that
  \begin{gather}
    \kappa\omega(\vx) (v_1,\dots,v_{k-1})
    = \omega(\vx) (\vx,v_1,\dots,v_{k-1}).
  \end{gather}
  As with the exterior differentail, we write $\kappa_k$ if we want to
  specify the degree of $\Lambda^k$.  Application to proxy fields yields
  \begin{gather}
    \label{eq:derham:13}
    \begin{aligned}
      \kappa\omega_1 &\leftrightarrow \vx\cdot\vu,\\
      \kappa\omega_2 &\leftrightarrow -\vx\times\vu,\\
      \kappa\omega_3 &\leftrightarrow \vx p.
    \end{aligned}
  \end{gather}
\end{Definition}

\begin{Lemma}{koszul-differential}
  There holds
  \begin{gather}
    \label{eq:derham:14}
    \kappa\circ\kappa = \kappa_k\circ\kappa_{k+1} = 0.
  \end{gather}
  Furthermore, we have the Leibniz rule for $\omega\in \Lambda^k$ and
  $\eta\in\Lambda^\ell$
  \begin{gather}
    \kappa(\omega\wedge\eta) = \kappa\omega\wedge\eta
    + (-1)^k \omega\wedge\kappa\eta.
  \end{gather}
  If
  $\omega(\vx) = a_\sigma(\vx)
  \dx_{\sigma_1}\wedge\dots\wedge\dx_{\sigma_k}$, then we have
  \begin{gather}
    \kappa\omega(\vx) = \sum_{i=1}^k (-1)^{i+1} a_\sigma(\vx)x_{\sigma_i}
    \dx_{\sigma_1}\wedge\dots\wedge\widehat{\dx_{\sigma_i}}
    \wedge\dots\wedge\dx_{\sigma_k}.
  \end{gather}
  Finally, the Koszul differential commutes with the pullback.
\end{Lemma}

\begin{Definition}{Koszul-complex}
  The homogeneous \define{Koszul complex} is a polynomial complex of
  the form
  \begin{gather}\minCDarrowwidth15pt
    \label{eq:derham:12}
    \begin{CD}
      0
      @<<< \breve \P_r\Lambda^0
      @<{\kappa_1}<< \breve \P_{r-1}\Lambda^1
      @<{\kappa_2}<< \breve \P_{r-2}\Lambda^2
      @<{\kappa_3}<< \breve \P_{r-3}\Lambda^3
      @<<< \R
    \end{CD}.
  \end{gather}
  For $r\le 3$ we have
  \begin{gather}\minCDarrowwidth15pt
    \label{eq:derham:12a}
    \begin{CD}
      0
      @<<< \breve \P_3\Lambda^{-r}
      @<{\kappa_1}<< \breve \P_{2}\Lambda^{1-r}
      @<{\kappa_2}<< \breve \P_{1}\Lambda^{2-r}
      @<{\kappa_3}<< \breve \P_{0}\Lambda^{3-r}
      @<<< \R
    \end{CD},
  \end{gather}
  where forms with negative index evaluate to zero.
\end{Definition}

Note that the ``Koszul differential'' increases the polynomial order
and lowers the order of the form, thus acts in the opposite way of the
usual exterior derivative $d$.

\begin{Lemma}{kd-plus-dk}
  For $\omega\in \breve \P_r\Lambda^k$ there holds
  \begin{gather}
    \label{eq:derham:15}
    \bigl(d\kappa+\kappa d\bigr)\omega = (r+k) \omega.
  \end{gather}
\end{Lemma}

\begin{proof}
  We prove this here
  for each $k$ directly. The proof for forms is in the video and can be found in ~\cite{ArnoldFalkWinther06acta}. For $k=0$, we have $\kappa\omega = 0$, thus
  we have to show
  \begin{gather}
    \kappa d\omega = r\omega.
  \end{gather}
  Due to linearity of $\kappa$ and $d$, it suffices to prove the
  result for $\omega = p=x_1^ax_2^bx_3^c$. We note that $dp/d_{x_1} =
  a/x_1 p$ and $d(x_1 p)/d_{x_1} = (a+1) p$ and analogue for the other
  coordinates.
  \begin{gather}
    \kappa_1 d_0\omega = x\cdot \nabla p = x\cdot
    \begin{pmatrix}
      a/x_1\\b/x_2\\c/x_3
    \end{pmatrix}p
    = (a+b+c)p.
  \end{gather}
  The second easy case is $k=3$ such that $d\omega = 0$. Let again
  $\omega = p$ to obtain
  \begin{gather}
    d_2\kappa_3 \omega = \div(xp) = \div
    \begin{pmatrix}
      x_1 p \\x_2 p \\x_3 p
    \end{pmatrix}
    = (a+1+b+1+c+1) p = (r+3) \omega.
  \end{gather}
  For the two vector valued cases, we note that it suffices to prove
  the result for $\omega = (p,0,0)^\transpose$ and to note that the results for
  nonzero second and third component follow suite. Thus, for $k=1$
  \begin{multline}
    \nabla (x\cdot \omega) - x\times \curl \omega
    = \nabla(x_1 p) - x\times
    \begin{pmatrix}
      0\\c/x_3 \\ -b/x_2
    \end{pmatrix}p
    \\
    =
    \begin{pmatrix}
      a+1 \\ bx_1/x_2\\ cx_1/x_3
    \end{pmatrix}p
    +
    \begin{pmatrix}
      b+c \\ -bx_1/x_2\\cx_1/x_3
    \end{pmatrix}p
    =
    \begin{pmatrix}
      a+b+c+1 \\0\\0
    \end{pmatrix}p
    = (r+1)\omega.
  \end{multline}
  Finally, for $k=2$
  \begin{multline}
    \curl(-x\times \omega) + x \div \omega
    = \curl
    \begin{pmatrix}
      0 \\ -x_3 \\ x_2
    \end{pmatrix}p
    +
    \begin{pmatrix}
      x_1 a/x_1\\x_2 a/x_1\\x_3 a/x_1\\
    \end{pmatrix}p
    \\=
    \begin{pmatrix}
      b+1+c+1\\-ax_2/x_1 \\ -a x_3/x_1
    \end{pmatrix}p
    +
    \begin{pmatrix}
      a\\ax_2/x_1\\ax_3/x_1
    \end{pmatrix}p
    =
    \begin{pmatrix}
      a+b+c+2\\0\\0
    \end{pmatrix}p
    = (r+2)\omega.
  \end{multline}
\end{proof}

\begin{Lemma}{d-kappa-injective}
  The restriction of operator $d$ to $\range \kappa$ is injective and
  vice versa, or equivalently for any polynomial form
  $\omega\in \breve \P_r\Lambda^k$ there holds
  \begin{gather}
    \label{eq:derham:16}
    \begin{aligned}
      d\kappa\omega &= 0 &\Longrightarrow&& \kappa\omega &= 0,\\
      \kappa d\omega &= 0 &\Longrightarrow&& d\omega &= 0.
    \end{aligned}
  \end{gather}
\end{Lemma}

\begin{proof}
  If $r=k=0$, then $\kappa\omega = d\omega = 0$, such that the lemma
  holds trivially. For $r+k\neq 0$, we apply $\kappa$ to
  equation~\eqref{eq:derham:15} to obtain
  \begin{gather}
    \kappa\omega = \frac1{r+k}
    \bigl(\kappa d\kappa\omega + \kappa^2d\omega\bigr)
    = \frac1{r+k}\kappa d\kappa\omega.
  \end{gather}
  Thus, we have proven $d\kappa\omega=0$ implies $\kappa\omega=0$. The
  second implication is proven by applying $d$ to~\eqref{eq:derham:15}.
\end{proof}

\begin{Theorem}{polynomial-exact}
  The polynomial de Rham complex and the Koszul complex are exact for
  $r\ge 1$. Furthermore, for $k,r\ge 0$ and $k+r>0$, there holds
  \begin{gather}
    \label{eq:derham:17}
    \breve \P_r\Lambda^k = \kappa \breve\P_{r-1}\Lambda^{k+1}
    \oplus d\breve\P_{r+1}\Lambda^{k-1}.
  \end{gather}
\end{Theorem}

\begin{proof}
  We already know $\range{\kappa_{k-1}} \subset \ker{\kappa_k}$. Thus,
  it remains to show the opposite inclusion. Let therefore $\omega\in
  \breve \P_r\Lambda^k$ such that $\kappa\omega=0$. Then,
  \begin{gather}
    \omega = \frac1{r+k} (d\kappa\omega+\kappa d\omega)
    = \frac1{r+k} \kappa d\omega =: \kappa\eta
  \end{gather}
  with $\eta \in \breve\P_{r-1}\Lambda^{k+1}$. Thus,
  $\omega\in \range{\kappa_{k-1}}$. Again, the proof for the de Rham
  complex is obtained by replacing $\kappa$ by $d$.

  In order to see that $\breve \P_r\Lambda^k$ is the sum of the two
  spaces, we let for arbitrary $\omega\in \breve \P_r\Lambda^k$
  \begin{gather}
    \eta = \frac1{r+k} d\omega \in \breve\P_{r-1}\Lambda^{k+1},
    \qquad
    \mu = \frac1{r+k} \kappa\omega \in \breve\P_{k+1}\Lambda^{k-1}.
  \end{gather}
  By equation~\eqref{eq:derham:15}, we have
  $\omega = \kappa\eta + d\mu$. It remains to show that the
  intersection of the spaces is zero. Therefore, let $\omega$ be
  chosen from the intersection. Then, $\omega = \kappa\eta = d \mu$
  and
  \begin{gather}
    (r+k)\omega = d\kappa \omega + \kappa d \omega
    = d \kappa^2 \eta + \kappa d^2 \mu = 0.
  \end{gather}
\end{proof}

\begin{Corollary}{pk-complexes}
  \slideref{Theorem}{polynomial-exact} holds as well for the
  polynomial complexes
  \begin{gather}\minCDarrowwidth15pt
    \begin{CD}
      0
      @>>> \P_r\Lambda^0
      @>{d}>> \P_{r-1}\Lambda^1
      @>{d}>> \P_{r-2}\Lambda^2
      @>{d}>> \P_{r-3}\Lambda^3
      @>>> 0
    \end{CD},
  \end{gather}
  and
  \begin{gather}\minCDarrowwidth15pt
    \begin{CD}
      \R
      @<<< \P_r\Lambda^0
      @<{\kappa}<< \P_{r-1}\Lambda^1
      @<{\kappa}<< \P_{r-2}\Lambda^2
      @<{\kappa}<< \P_{r-3}\Lambda^3
      @<<< 0
    \end{CD}.
  \end{gather}
\end{Corollary}

\begin{proof}
  This is due to the fact that the polynomial spaces $\P_r$ are the
  direct sums of homogeneous polynomial space $\breve\P_s$.
\end{proof}

\begin{Definition}{pk-plus}
  \index{prpl@$\P_r+\Lambda^k$}
  The polynomial space of $k$-forms $\P_r^+\Lambda^k$ is defined as
  \begin{gather}
    \P_r^+\Lambda^k = \P_r\Lambda^k \oplus \kappa \breve\P_r\Lambda^{k+1}.
  \end{gather}
  \index{prml@$\P_r-\Lambda^k$}
  It is also referred to as $\P_{r+1}^-\Lambda^k$. Furthermore,
  \begin{gather}
    \P_r^+\Lambda^0 = \P_{r+1}\Lambda^0,
    \qquad
    \P_r^+\Lambda^\sdim = \P_r\Lambda^\sdim.
  \end{gather}
\end{Definition}

\begin{remark}
  We have used the construction principle
  \begin{gather}
    \P_r\Lambda^k = \P_{r-1}\Lambda^k \oplus \breve \P_r\Lambda^k.
  \end{gather}
  Using its decomposition, we obtain
  \begin{gather}
    \P_r\Lambda^k =
    \bigoplus_{s=1}^{r-1}\kappa \breve\P_{s-1}\Lambda^{k+1}
    \bigoplus_{s=1}^{r-1} d\breve\P_{s+1}\Lambda^{k-1}
    \oplus \kappa \breve\P_{r-1}\Lambda^{k+1}
    \oplus d\breve\P_{r+1}\Lambda^{k-1}.
  \end{gather}
  If we leave out the last factor, we get the new space
  $\P_{r-1}^+\Lambda^k$.
\end{remark}

\begin{Lemma}{pk-plus-d}
  If $\omega\in \P_r^+\Lambda^k$ and $d\omega=0$, then
  $\omega\in\P_r\Lambda^k$.
\end{Lemma}

\begin{proof}
  Let $\omega = \omega_1 + \kappa\eta$ with $\omega_1\in\P_r\Lambda^k$
  and $\eta\in \breve\P_r\Lambda^{k+1}$. Then,
  $d\omega_1\in\P_{r-1}\Lambda^{k+1}$ and
  $d\kappa\eta\in \breve\P_r\Lambda^{k+1}$. Therefore,
  $d\omega_1 = d\kappa\eta = 0$. By
  \slideref{Lemma}{d-kappa-injective}, $\kappa\eta=0$, such that
  $\omega=\omega_1$.
\end{proof}

\begin{Problem}{rt-bdm-forms}
  \begin{enumerate}
  \item   Identify the spaces $\P_r \Lambda^{\sdim-1}$ and
    $\P_r^+ \Lambda^{\sdim-1}$ with finite element spaces for
    $\Hdiv$.
  \item Where have we stated a special case of
    \slideref{Lemma}{pk-plus-d} before?
  \item Suggest polynomial spaces for $\Hcurl$ corresponding to
    $\P_r \Lambda^{1}$ and $\P_r^+ \Lambda^{1}$
  \end{enumerate}
\end{Problem}

% AFW 2006 Lemma 3.8
\begin{Lemma}{pr-pr-plus}
  For $r\ge 1$ and $0\le k < n$ there holds
  \begin{gather}
    d\P_{r}^+\Lambda^k \subset d\P_{r+1}\Lambda^k
    \subset \P_r\Lambda^{k+1}
    \subset \P_r^+\Lambda^{k+1}.
  \end{gather}
  The following four mappings $d$ have the same kernel:
  \begin{gather}
    \begin{aligned}
      d\colon \P_{r+1}\Lambda^k &\to \P_{r}\Lambda^{k+1}
      &
      d\colon \P_r^+\Lambda^k &\to \P_{r}\Lambda^{k+1}
      \\
      d\colon \P_{r+1}\Lambda^k &\to \P_{r}^+\Lambda^{k+1}
      &
      d\colon \P_r^+\Lambda^k &\to \P_{r}^+\Lambda^{k+1}
    \end{aligned}
  \end{gather}
  The following four mappings $d$ have the same range:
  \begin{gather}
    \begin{aligned}
      d\colon \P_{r+1}\Lambda^k &\to \P_{r}\Lambda^{k+1}
      &
      d\colon \P_{r}^+\Lambda^k &\to \P_{r}\Lambda^{k+1}
      \\
      d\colon \P_{r+1}\Lambda^k &\to \P_{r}^+\Lambda^{k+1}
      &
      d\colon \P_{r}^+\Lambda^k &\to \P_{r}^+\Lambda^{k+1}
    \end{aligned}
  \end{gather}
\end{Lemma}

\begin{Corollary}{pr-sequences}
  For polynomial forms in $\R^3$,
  all four sequences in this diagram are exact:
  {\small
  \begin{tikzcd}
    \R \arrow[r,hook]
    & \P_{r+3}\Lambda^0 \arrow[r,"\diffd"]
    & \P_{r+2}\Lambda^1 \arrow[rd,"\diffd"]\\
    \R \arrow[r,hook]
    & \P_{r+2}\Lambda^0 \arrow[r,"\diffd"]
    & \P_{r+1}^+\Lambda^1 \arrow[r,"\diffd"]
    & \P_{r+1}\Lambda^2 \arrow[rdd,"\diffd"]\\
    \R \arrow[r,hook]
    & \P_{r+2}\Lambda^0 \arrow[r,"\diffd"]
    & \P_{r+1}\Lambda^1 \arrow[rd,"\diffd"]\\
    \R \arrow[r,hook]
    & \P_{r+1}\Lambda^0 \arrow[r,"\diffd"]
    & \P_{r}^+\Lambda^1 \arrow[r,"\diffd"]
    & \P_{r}^+\Lambda^2 \arrow[r,"\diffd"]
    & \P_{r}\Lambda^3 \arrow[r,"\diffd"]
    & 0
  \end{tikzcd}
  }
\end{Corollary}

\begin{proof}
  The first statement follows from the inclusions of $\P_r$ and
  $\P_r^+$. The horizontal equality of the second statement follows
  from \slideref{Lemma}{pk-plus-d}. The vertical identities from the
  decomposition~\eqref{eq:derham:17}. For the last set of identities,
  we observe that by construction
  \begin{gather}
    \P_r\Lambda^k = \P_{r-1}^+\Lambda^k \oplus d \P_{r+1}\Lambda^{k-1}.
  \end{gather}
  Thus, $d\P_r\Lambda^k = d\P_{r-1}^+\Lambda^k\subset \P_{r-1}\Lambda^{k+1}$.
\end{proof}

\begin{Theorem}{dimension-pr-lambda}
  Let $r\ge 0$ and $1\le k \le \sdim$. Then,
  \begin{gather}
    \begin{split}
      \dim \kappa \breve P_r\Lambda^k(\R^\sdim)
      & = \dim d \breve P_{r+1}\Lambda^{k-1}(\R^\sdim)
      \\
      &= \binom{\sdim+r}{\sdim-k}\binom{r+k-1}{k-1}.
    \end{split}
  \end{gather}
\end{Theorem}

\begin{proof}
  First, we prove the equality of the two dimensions by applying $\kappa$
  to equation~\eqref{eq:derham:17}, yielding
  \begin{gather}
    \kappa \breve P_r\Lambda^k(\R^d)
    = \kappa \ediff \breve P_{r+1}\Lambda^{k-1}(\R^\sdim).
  \end{gather}
  By \slideref{Lemma}{d-kappa-injective}, the two spaces are
  isomorphic and the equality holds.

  The dimension formula is proven first for $r=0$ and $k\ge 1$. The
  Koszul operator is injective on $\P_0\Lambda^K(\R^\sdim)$ since the
  first factor in equation~\eqref{eq:derham:17} vanishes. It is
  also injective on $\breve P_r\Lambda^\sdim(\R^\sdim)$ for $r\ge 0$.

  For all other combinations of $r$ and $k$ it is proven by induction
  over $k$. For $k=\sdim$,
  \begin{gather}
    \dim \breve\P_r\Lambda^\sdim(\R^\sdim) = \dim\breve\P_r(\R^\sdim)
    = \binom{\sdim+r-1}{\sdim-1}.
  \end{gather}
  For $k<\sdim$, we assume the formula proven for $k+1$. We have
% Move this to an earlier point or an appendix
  \begin{gather}
    \breve P_r\Lambda^k(\R^d) = \binom{\sdim+r-1}{\sdim-1}\binom{\sdim}{k}.
  \end{gather}
  Now, the dimension formula
  \begin{gather}
    \dim \range \phi = \dim V - \dim \ker \phi,
  \end{gather}
  yields
  \begin{gather}
    \dim\kappa\breve \P_r\Lambda^k(\R^\sdim) =
    \dim\breve \P_r\Lambda^k(\R^\sdim)
    - \dim\kappa\breve \P_{r-1}\Lambda^{k+1}(\R^\sdim),
  \end{gather}
  where we have used the exactness of the Koszul complex.
  Using the induction hypothesis yields by the binomial identity
% Olkhovskiy
  \begin{align}
    \dim\kappa\breve \P_r\Lambda^k(\R^\sdim)
    &= \binom{\sdim+r-1}{\sdim-1}\binom{\sdim}{k} - \binom{\sdim+r-1}{\sdim-k-1}\binom{r+k-1}{k}
    \\
    &= \frac{(\sdim+r-1)!{\color{green}\sdim!}}{{\color{green}(\sdim-1)!}{\color{purple}r!}k!{\color{blue}(\sdim-k)!}}
      - \frac{(\sdim+r-1)!{\color{red}(r+k-1)!}}{{\color{blue}(\sdim-k-1)!}
      {\color{red}(r+k)!}k!{\color{purple}(r-1)!}}
    \\
    &=
      \frac{(\sdim+r-1)!{\color{green}\sdim}{\color{red}(r+k)}-{\color{blue}(\sdim-k)}(\sdim+r-1)!{\color{purple}r}}
      {{\color{purple}r!}k!{\color{blue}(\sdim-k)!}{\color{red}(r+k)}}
    \\
    &= \frac{(\sdim+r-1)!\bigl(\sdim(r+k)-(\sdim-k)r\bigr)}{r!k!(\sdim-k)!(r+k)}
    \\
    &= \frac{(\sdim+r)!}{r!(k-1)!(\sdim-k)!(r+k)}
    \\
    &= \binom{\sdim+r}{\sdim-k}\binom{r+k-1}{k-1}.
  \end{align}
\end{proof}

\subsection{Degrees of freedom and bases for simplicial meshes}

\begin{intro}
  After having studied the properties of the de Rham complex and the
  Koszul complex of polynomial spaces, we continue like with standard
  finite elements and define a basis of shape functions and sets of
  degrees of freedom dual to this basis. Note that the following
  definition subsumes the definitions of conforming finite elements
  for $H^1$, $\Hcurl$ and $\Hdiv$ in a single statement.
\end{intro}

\begin{Definition}{mesh-pk}
  Given a space of polynomial forms
  $\P_r\Lambda^k=\P_r\Lambda^k(\R^\sdim)$, we define the space of finite
  element polynomial forms on a mesh $\mesh_h$ covering the domain
  $\domain\subset\R^\sdim$ as
  \begin{gather}
    \P_r\Lambda^k(\mesh) = \bigl\{
    \omega \in H\Lambda^k \big|
    \;\forall \cell\in\T\colon \omega_{|\cell} \in \P_r\Lambda^k
    \bigr\}.
  \end{gather}
  Furthermore, we define $\Delta_m(\T_h)$ as the set of all
  $m$-dimensional subsimplices of the whole mesh, where shared
  subsimplices of several cells are identified.
\end{Definition}

\begin{intro}
  The degrees of freedom have to be designed such that they guarantee
  the necessary continuity between cells. To this end, we have to
  study the traces of polynomial forms on the boundaries (called
  subsimplices below) of the simplex $\cell$. Then, we can start
  decomposing degrees of freedom and node values such that they can be
  allocated to these subsimplices.
\end{intro}

\begin{Theorem}{hlambda-continuity}
  Let $\omega\in L^2\Lambda^k(\domain)$ be polynomial on each mesh
  cell $\cell$ of a mesh $\mesh_h$ covering $\domain$. Then, the
  following statements are equivalent:
  \begin{enumerate}
  \item $\omega\in H\Lambda^k(\domain)$
  \item $\gamma_f\omega$ is single-valued for all $f\in\Delta_{\sdim-1}(\T_h)$
  \item $\gamma_f\omega$ is single-valued for all $f\in\Delta_{m}(\T_h)$ for
    $k\le m \le n-1$.
  \end{enumerate}
\end{Theorem}

\begin{proof}
  By the Stokes theorem, every smooth $k$-form on a mesh cell $\cell$
  has a well-defined trace $\gamma_f\omega$ on
  $f\in\Delta_{n-1}(\cell)$. Thus, $\omega\in H\Lambda^k(\domain)$ if
  and only if these traces coincide from both cells sharing this face.

  Once this is established, it is also clear that the two traces can
  only be the same if their traces to the boundary of $f$ coincide as
  well.
\end{proof}

\subsubsection{Geometric decomposition of $\P_r(\cell)$}

For the geometric decomposition of simplices and the consequences on barycentric coordinates, see \cref{sec:barycentric}

\begin{remark}
  When we introduced barycentric coordinates in order to define
  standard shape functions on simplices, we generated a basis for
  $\P_r(\R^\sdim)$ by selecting polynomials of the $\lambda_i$. Closer
  inspection reveals that these polynomials were
  homogeneous. Therefore, we defined an isomorphism
  \begin{gather}
    \breve \P_k(\R^{\sdim+1}) \cong \P_k(\R^\sdim),
  \end{gather}
  which reads: for every $p\in \P_k(\R^\sdim)$ there is
  $q\in\breve\P_k(\R^{\sdim+1})$ such that
  \begin{gather}
    p(x_1,\dots,x_\sdim) = q(\lambda_0,\dots,\lambda_\sdim).
  \end{gather}
% Argue why isomorphism: count?
\end{remark}

\begin{Definition}{pr-f}
  For each $k$-dimensional subsimplex $f_\sigma$ of $\cell$ with
  $\sigma = \sigma_0,\dots,\sigma_k$, the space
  $\P_r(f_\sigma) \cong \breve\P_r(\R^{k+1})$ is defined as
  \begin{gather}
    \P_r(f_\sigma) = \bigl\{
    q(\lambda_{\sigma_0},\dots,\lambda_{\sigma_k})
    \;\big\vert\;
    q\in\breve \P_r(\R^{k+1})\bigr\}.
  \end{gather}

  By $\overset{\circ}{\P}_r(f_\sigma)$ we denote the space of
  polynomials in $\P_r(f_\sigma)$ which vanish on the boundary $\d f_\sigma$.

  The \putindex{bubble function} associated with $f_\sigma$ is
  \begin{gather}
    b_{f\sigma} = \lambda_{\sigma_0}\cdots\lambda_{\sigma_k}
    \in \overset{\circ}{\P}_{k+1}(f_\sigma).
  \end{gather}
\end{Definition}

\begin{Lemma}{p0-bubble}
  Let $f$ be a $k$-simplex. Then,
  \begin{gather}
    \overset{\circ}{\P}_r(f) =
    \begin{cases}
      b_f \P_{r-k-1}(f) &\text{if } r\ge k+1\\
      \{0\} &\text{if } r \le k.
    \end{cases}
  \end{gather}
\end{Lemma}

\begin{Definition}{pr-f-extension}
  The \define{extension operator} $E_{f_\sigma\to\cell}$ is defined as
  \begin{gather}
    \begin{split}
      E_{f_\sigma\to\cell}\colon \P_r(f_\sigma) &\to \P_r(\R^\sdim),\\
      p(\lambda_0,\dots,\lambda_\sdim) &= q(\lambda_{\sigma_0},\dots,\lambda_{\sigma_k}),
    \end{split}
  \end{gather}
  where $q$ is chosen as in the definition of $\P_r(f_\sigma)$.
\end{Definition}

\begin{Lemma}{subsimplex-polynomials}
  Every function in $\P_r(f)$ vanishes on every subsimplex
  $g\in\Delta(\cell)$ which is disjoint from $f$.

  The bubble function $b_f$ vanishes on every subsimplex in
  $\Delta(\cell)$ not containing $f$.
\end{Lemma}

\begin{Problem}{subsimplex-polynomials}
  Show: $\P_r(f_\sigma)$ is isomorphic to $\P_r(\R^k)$. Prove
  \slideref{Lemma}{subsimplex-polynomials}.
\begin{solution}
  Since $\P_r(f_\sigma)$ is isomorphic to $\breve\P_r(\R^{k+1})$ and
  $\P_r(f_\sigma)$ is a vector space
  all we have to do is to show that the dimensions are equal.
  In fact, $\dim \P_r(\R^k) = \binom{r+k}{k}$
  (show by distributiung separators) and
  $\dim \breve\P_r(\R^k) = \binom{r+k-1}{k-1}$.
  Thus, $\dim \breve\P_r(\R^{k+1}) = \binom{r+k}{k} = \dim \P_r(\R^k)$
  and the two spaces are isomorphic.

  Let $g$ be a subsimplex that is disjoint from $f$.
  \begin{align}
      f_\sigma &= \bigl\{x\in\cell \big\vert
      \lambda_j=0 \text{ for } j\not\in\sigma\bigr\}.
      \\
      &= \biggl\{ x = \sum_{i\in\sigma}\lambda_i\bigg\vert
    \lambda_i \ge 0,\quad\sum_{i\in\sigma}\lambda_i = 1\biggr\}.
  \end{align}
  Then $\sigma_f$ and $\sigma_g$ are disjoint and in particular
  $\lambda_i = 0$ for all $i\in \sigma_f$ in the decomposition
  $g \ni x = \sum_i \lambda_i(x)$. Thus, $p\in \P_r(f)$
  is identified by $q(\lambda_{\sigma_0},\dots,\lambda_{\sigma_k})$
  which vanishes for all $x \in g$.

  Let $g$ be a subsimplex not containing $f$. Then, $\sigma_f\setminus \sigma_g$ is non-empty.
  In the decomposition $g\ni x = \sum_i\lambda_i$ such that $\lambda_i \ge 0,\quad\sum_i\lambda_i = 1$ at most
  the $\lambda_i$ ($i\in\sigma_f$) for $i\in\sigma_f\cap\sigma_g$ are non-zero. Due to to our assumption
  $\sigma_f\cap\sigma_g$ is a proper subset of $\sigma_f$ and hence there exist for each $x \in f\cap g$
  a $i \in \sigma_f$ such that $\lambda_i=0$. This implies $b_{f_\sigma}\equiv 0$ on $g$.
\end{solution}
\end{Problem}

\begin{Example}{h1-moment-dofs}
  \begin{center}
    \includegraphics[width=.3\textwidth]{fig/p1-p}
    \includegraphics[width=.3\textwidth]{fig/p2-p}
    \includegraphics[width=.3\textwidth]{fig/p3-p}
  \end{center}
  Unisolvent interpolation conditions for $\P_r(\cell)$
  \begin{xalignat*}3
    u(f) &= 0 &&& \dim f &= 0\\
    \form(u,q)_f &= 0 & q&\in \P_{r-2}(f) & \dim f &= 1 \\
    \form(u,q)_f &= 0 & q&\in \P_{r-3}(f) & \dim f &= 2 \\
    &\vdots && \vdots && \vdots
  \end{xalignat*}
\end{Example}

We are now generalizing and formalizing this example in order to
derive a geometric decomposition of $\P_r(\cell)$ and its dual.

\begin{Definition}{v-of-f}
  For every $f\in\Delta(\cell)$%
  %with $\sigma=\{\sigma_0,\dots,\sigma_k\}$
  , we define
  $V(f) \subset \P_r(\cell)$  for $\dim f>0$ as
  \begin{gather}
    V(f) = \bigl\{ p = E_{f\to\cell} b_f q
    \;\big\vert\;
    q \in \P_{r-\dim f -1}(f) \bigr\},
  \end{gather}
  and for $\dim f=0$
  \begin{gather}
    V(f) = \bigl\{ \lambda_i^r
    \;\big\vert\;
    f = \{x_i\}\bigr\}.
  \end{gather}
  For $r\le \dim f$ holds
  \begin{gather}
    V(f) = \{0\}.
  \end{gather}
\end{Definition}

\begin{Definition}{w-of-f}
  For every $f\in\Delta(\cell)$, we define
  $W(f) \subset \P_r(\cell)^*$ for $\dim f>0$ as
  \begin{gather}
    W(f) = \bigl\{\phi(p) = \form(p,q)_f\big\vert
    \;q\in\P_{r-\dim f-1}(f) \bigr\},
  \end{gather}
  and for $\dim f=0$
  \begin{gather}
    W(f) = \bigl\{\phi(p)= p(x_i) \big|
    \;f=\{x_i\}
    \bigr\}.
  \end{gather}
  For $r \le \dim f$ there holds
  \begin{gather}
    W(f) = \{0\}.
  \end{gather}
\end{Definition}

\begin{Lemma}{pr-geometric}
  There holds
  \begin{gather}
    \P_r(\cell) = \bigoplus_{f\in\Delta(\cell)}V(f),
    \qquad
    \P_r(\cell)^* = \bigoplus_{f\in\Delta(\cell)}W(f).
  \end{gather}
\end{Lemma}

\begin{proof}
  We begin to show that
  \begin{gather}
    \P_r(\cell) = \bigoplus_{f\in\Delta(\cell)}V(f).
  \end{gather}
  First, we note that for any $f\in\Delta(\cell)$ every function in $V(f)$
  is also in $\P_r(\cell)$.  For $\dim f=0$, that is, $f=\{x_i\}$ for some
  vertex $x_i$, the only homogeneous polynomial of order $r$ is $\lambda_i^r$.

  For $\dim f > 0$ we have by the first statement of
  \slideref{Lemma}{subsimplex-polynomials}, that the spaces $V(f)$
  where $f$ is a vertex are disjoint. By the second statement of the
  same lemma, the spaces $V(f)$ for all $f$ with equal dimension are
  disjoint. Therefore, the sum
  \begin{gather}
    V_\sdim(\cell) = \sum_{k=0}^{\sdim-1} \sum_{f\in \Delta_k(\cell)} V(f),
  \end{gather}
  is direct. But, $V(\cell) \cap V_\sdim(\cell) = \{0\}$, since all elements in
  $V(\cell)$ contain a bubble function factor. Therefore,
  \begin{gather}
    \bigoplus_{f\in\Delta(\cell)}V(f) \subset \P_r(\cell).
  \end{gather}
  We conclude by showing that dimensions on both sides are equal.
  On the right, we use
  \begin{gather}
    \dim \P_r(\R^\sdim) = \binom{r+\sdim}{r} = \frac{(r+\sdim)!}{\sdim!r!}
  \end{gather}
  On the left, we have
  \begin{multline}
    \dim \bigoplus_{f\in\Delta(\cell)}V(f) =
    \sum_{k=0}^{\sdim} \binom{\sdim+1}{k+1} \binom{r+k}{k}
    \\
    = \frac{(d+1)!}{r!}
    \sum_{k=0}^{\sdim} \frac{1}{(k+1)!(d-k)!} \frac{(r+k)!}{k!}.
  \end{multline}

% Finish this!

  It remains to show the decomposition for $\P_r(\cell)^*$. To this
  end, we first notice that for any $f\in\Delta(\cell)$ there holds
  $\dim W(f) = \dim V(f)$ by their definition. Furthermore, for
  $p\in V(f)$ there holds
  \begin{gather}
    \Bigl(\phi(p) = 0 \quad\forall \phi\in W(f)\Bigr)
    \quad\Rightarrow\quad
    p=0.
  \end{gather}
  Thus, for $p\in \P_r(\cell)$ there holds
  \begin{gather}
    \Bigl(\phi(p) = 0 \quad\forall \phi\in \sum W(f)\Bigr)
    \quad\Rightarrow\quad
    p=0.
  \end{gather}
  Consequently,
  \begin{gather}
    \P_r(\cell)^* = \sum W(f).
  \end{gather}
  since we have already proven that
  \begin{gather}
    \dim \P_r(\cell)^* = \sum \dim W(f),
  \end{gather}
  the sum on the right must be direct.
\end{proof}

\subsubsection{Results for $\P_r\Lambda^k$ and proxy fields}

\begin{Lemma}{pr-lambda-dimension-decomposition}
  There holds
  \begin{align}
    \dim \P_r\Lambda^k(\cell)
    &= \sum_{f\in\Delta(\cell)}
      \dim \P_{r+k-\dim f-1}^+\Lambda^{\dim f-k}(f) \\
    \dim \P_r^+\Lambda^k(\cell)
    &= \sum_{f\in\Delta(\cell)}
      \dim \P_{r+k-\dim f}\Lambda^{\dim f-k}(f)
  \end{align}
\end{Lemma}

% \begin{Notation}{volume-form}
%   The \define{volume form} of a $k$-dimensional subsimplex
%   $f\in\Delta(\cell)$ is defined by the relation
%   \begin{gather}
%     \abs{f} = \int_f \vol_f.
%   \end{gather}
%   Using the fact that $n! \abs{T} = \vol_T(t_1,\dots,t_n)$ we see
%   \begin{gather}
%     \dlambda_{\sigma_1}\wedge\dots\wedge\dlambda_{\sigma_k}
%     = \pm \frac1{k! \abs{f}} \vol_f.
%   \end{gather}
% \end{Notation}

\begin{Lemma}{afw06-4-7}
  Let $\omega \in \overset{\circ}{\P}_r \Lambda^k(\cell)$ and assume
  \begin{gather}
    \int_\cell\omega\wedge\eta = 0,
    \qquad\forall \eta\in\P_{r-n+k-1}^+\Lambda^{n-k}(\cell).
  \end{gather}
  Then, $\omega = 0$.
\end{Lemma}

\begin{proof}
  The proof consists of Lemmas 4.5 to 4.7 in
  \cite{ArnoldFalkWinther06acta}. It skilfully exploits representations of
  polynomial forms with zero traces by barycentric coordinates, but is
  rather technical.
\end{proof}

\begin{Theorem}{pr-lambda-unisolvent}
  Let $r\ge 1$ and $0\le k \le n$. For $f\in \Delta(\cell)$, define
  subspaces of $W(f) \subset \P_r\Lambda^k(\cell)^*$ by
  \begin{gather}
    W(f) = \left\{
      \nodal_{f,_\eta}(\omega) = \int_f \gamma_f \omega\wedge\eta,
      \;\middle\vert\;
       \eta \in \P_{r+k-\dim f-1}^+\Lambda^{\dim f-k}(f)
      \right\}.
  \end{gather}
  Then, if $\omega \in \P_r\Lambda^k(\cell)$ satisfies
  \begin{gather}
    \nodal_{f,\eta}(\omega) = 0
    \qquad \forall f\in \Delta(\cell)
    \quad\forall \nodal_{f,\eta} \in W(f),
  \end{gather}
  then $\omega = 0$. Thus, the space $\P_r\Lambda^k(\cell)$ together
  with the node functionals $\nodal_{f,\eta}$ forms a unisolvent
  finite element.  Furthermore, $\gamma_f\omega$ for any subsimplex
  $f\in\Delta(\cell)$ is uniquely determined by the degrees of freedom
  in $\bigoplus_g W(g)$ where $g\in\Delta(f)$.
\end{Theorem}

\begin{proof}
  First we note, that by
  \slideref{Lemma}{pr-lambda-dimension-decomposition} the dimensions
  of the spaces $W(f)$ add up to the dimension of
  $\P_r\Lambda^k(\cell)$. Thus, if we can show the first statement, we
  have shown that the sum of the spaces $W(f)$ is a direct sum, and
  thus unisolvence is obtained by the usual argument.

  Let now $f\in\Delta_k(\cell)$. Then, $\gamma\omega$ vanishes on
  $\d f$ as a $k$-form on a simplex of dimension $k-1$. Thus, we have
  $\gamma_f\omega\in \overset{\circ}{\P}_r\Lambda^k(f)$. Since
  furthermore by the assumption
  \begin{gather}
    \int_f \gamma_f\omega\wedge \eta = 0,
    \qquad \forall \eta \in \P_{r-1}^+\Lambda^0(f),
  \end{gather}
  \slideref{Lemma}{afw06-4-7} yields $\gamma_f\omega = 0$, which holds
  for all $f\in\Delta_k(\cell)$.

  Let now $f\in \Delta_{k+1}(\cell)$. Then, by the result of the
  previous argument,
  $\gamma_f\omega\in \overset{\circ}{\P}_r\Lambda^k(f)$, and by the
  argument itself $\gamma_f \omega = 0$. In particular,
  $\gamma_f\omega$ is uniquely determined at this point of the
  construction process, which proves the last statement of the theorem.

  We can now do induction by the dimension of $f$ until we reach
  $\Delta_n(\cell) = \{\cell\}$ to obtain the result.
\end{proof}

\begin{remark}
  Note that the space $\P_s^+\Lambda^k$ vanishes if $s<0$ or
  $k<0$. Therefore, the spaces $W(f)$ are nontrivial only if
  \begin{gather}
    k \le \dim f \le r+k-1.
  \end{gather}
  Comparing this to \slideref{Example}{h1-moment-dofs} for
  $H^1 = H\Lambda^0$, we see that one-dimensional subsimplices carry
  degrees of freedom for $r\ge 2$ and two-dimensional for $r\ge 3$.
\end{remark}

\begin{Theorem}{decomp-pr}
  Let $k,r\ge 1$. Then, $\P_r(\cell)$ admits a geometric decomposition
  \begin{gather}
    \P_r\Lambda^k(\cell) = \bigoplus_{f\in\Delta(\cell)} V(f),
  \end{gather}
  where
  \begin{gather}
    V(f) \cong W(f) \cong
    \begin{cases}
      0 & \dim f < k\\
      \P_{r+k-\dim f-1}^+ \Lambda^{\dim f-k}(f) &\text{else}\\
      0 & \dim f \le r+k.
    \end{cases}
  \end{gather}
\end{Theorem}

\begin{Example}{bdm-complex-decomp}
  \begin{gather}
    \begin{array}{c|cc|cc}
      \dim f
      & \P_r\Lambda^1 & N^{2e}_r
      & \P_r\Lambda^2 & BDM_r \\\hline
      3 & \P_{r-3}^+\Lambda^2 & RT_{r-2} & \P_{r-1}^+\Lambda^1 & N^{1e}_{r-1} \\
      2 & \P_{r-2}^+\Lambda^1 & RT_{r-1} & \P_{r}^+\Lambda^0 & \P_r \\
      1 & \P_{r-1}^+\Lambda^0 & \P_r & --& --
%      0 & \R & \R & -- & --
    \end{array}
  \end{gather}
  The spaces $\P_r\Lambda^k$ and their proxy fields and the spaces
  $W(f)$ of degrees of freedom.

  \begin{itemize}
  \item [$N^{2e}$] ($\Hcurl$) Nedelec 2nd family edge element
  \item [$BDM$] ($\Hdiv$) Brezzi-Douglas-Marini (also Nedelec 2nd face in 3D)
  \item [$N^{1e}$] ($\Hcurl$) Nedelec 1st family edge element
  \end{itemize}
\end{Example}

\subsubsection{Results for $\P_r^+\Lambda^k$ and proxy fields}

\begin{Theorem}{decomp-pr-plus}
  Let $k,r\ge 1$. Then, $\P_r^+(\cell)$ admits a geometric decomposition
  \begin{gather}
    \P_r^+\Lambda^k(\cell) = \bigoplus_{f\in\Delta(\cell)} V(f),
    \qquad
    \P_r^+\Lambda^k(\cell)^* = \bigoplus_{f\in\Delta(\cell)} W(f),
  \end{gather}
  where
  \begin{align}
    V(f) \cong
    \begin{cases}
      0 & \dim f < k\\
      \P_{r+k-\dim f} \Lambda^{\dim f-k}(f) &\text{else}\\
      0 & \dim f > r+k.
    \end{cases}
    \\
    W(f) \cong
    \begin{cases}
      0 & \dim f < k\\
      \P_{r+k-\dim f} \Lambda^{\dim f-k}(f) &\text{else}\\
      0 & \dim f > r+k.
    \end{cases}
  \end{align}
\end{Theorem}

\begin{Example}{rt-complex-decomp}
  \begin{gather}
    \begin{array}{c|cccccc}
      \dim f
      & \P_r^+\Lambda^0 & \P_{r+1}
      & \P_r^+\Lambda^1 & N^{1e}_r
      & \P_r^+\Lambda^2 & RT_r \\\hline
      3 & \P_{r-3}\Lambda^3 & \P_{r-3} & \P_{r-2}\Lambda^2 & BDM_{r-2} & \P_{r-1}\Lambda^1 & N^{2e}_{r-1} \\
      2 & \P_{r-2}\Lambda^2 & \P_{r-2} & \P_{r-1}\Lambda^1 & BDM_{r-1} & \P_{r}\Lambda^0 & \P_r\\
      1 & \P_{r-1}\Lambda^1 & \P_{r-1} & \P_{r}\Lambda^0   & \P_r  & -- & -- \\
      0 & \R & \R & -- & -- & --& --
    \end{array}
  \end{gather}
  Geometric decomposition of $\P_r^+\Lambda^k$ and their spaces of degrees of freedom.
  \begin{itemize}
  \item [$N^{1e}$] ($\Hcurl$) Nedelec 1st family edge element
  \item [$RT$] ($\Hdiv$) Raviart-Thomas (also Nedelec 1st face in 3D)
  \item [$N^{2e}$] ($\Hcurl$) Nedelec 2nd family edge element
  \end{itemize}
\end{Example}

\begin{Definition}{k-form-interpolation}
  By choosing a basis for each of the spaces $W(f)$ with
  $f\in\Delta(\cell)$, we obtain a finite number of node functionals
  $\nodal_{f,i}$ which in turn induces bases $\{\omega_{f,i}\}$ for $V(f)$ by
  duality.
  The \define{canonical interpolation} operators
  \begin{gather}
    \Pi_k\colon C\Lambda^k(\cell) \to \P_r\Lambda^k(\cell),
    \qquad
    \Pi_k^+\colon C\Lambda^k(\cell) \to \P_r^+\Lambda^k(\cell),
  \end{gather}
  are defined such that for all $\omega\in C\Lambda^k(\cell)$
  \begin{gather}
    \Pi_k \omega, \Pi_k^+\omega = \sum_{f\in\Delta(\cell)}
  \sum_{i=1}^{\dim W(f)} \nodal_{f,i}(\omega) \omega_{f,i},
\end{gather}
where the inner sum is determined by the spaces in \slideref{Theorem}{pr-lambda-unisolvent} and \slideref{Theorem}{decomp-pr-plus}, respectively.
\end{Definition}

\begin{Theorem}{canonical-commute}
  The diagram
  \begin{center}
    \begin{tikzcd}
      \Lambda^k(\cell)
      \arrow[r,"\diffd"]
      \arrow[d,"\Pi"]
      & \Lambda^{k+1}(\cell)
      \arrow[d,"\Pi"]
      \\
      \P\Lambda^k(\cell) \arrow[r,"\diffd"]
      &\P\Lambda^{k+1}(\cell)
    \end{tikzcd}
  \end{center}
  commutes for all combinations of the spaces
  $\P\Lambda^k \in \{\P_{r+1}\Lambda^k,\P_r^+\Lambda^k\}$ and
  $\P\Lambda^{k+1}\in \{\P_r\Lambda^{k+1}, \P_r^+\Lambda^{k+1}\}$.
  Namely, the canonical interpolation operators commute with the
  exterior derivative,
  \begin{gather}
    \Pi(d\omega) = d(\Pi\omega).
  \end{gather}
\end{Theorem}

\section{The complex of tensor product polynomial forms}

\begin{todo}
  Tensor products of algebraic forms first
\end{todo}

\begin{intro}
  The other multilinear map we know is the tensor product, which we
  used to define finite elements on squares and cubes. This section is
  now concerned with the interplay of alternating and differential
  forms and tensor products. In particular, we are looking into the
  construction of $k$-forms on $\R^\sdim$ as tensor products of
  one-dimensional forms.

  We will avoid the functional analysis of tensor products of Hilbert
  spaces and refer the readers
  to~\cite{ReedSimon80,Hackbusch14,Hackbusch19}.

  We focus instead on the finite dimensional construction of
  polynomial $k$-forms on $\R^\sdim$ by tensor products of
  one-dimensional forms.
\end{intro}

\begin{Definition}{pr-complex-1d}
  The one-dimensional de Rham complex on the interval $I = [0,1]$ and
  its polynomial subcomplex are
  \begin{gather}
    \begin{CD}
    \R
    @>{\subset}>>
    H^1(I) = H\Lambda^0(I)
    @>{\tfrac{\diffd}{\dx}}>>
    L^2(I) = H\Lambda^1(I)
    @>>> 0
    \\
    @.
    @A{\subset}AA
    @A{\subset}AA
    \\
    \R
    @>{\subset}>>
    \P_{r+1} = \P_{r+1}\Lambda^0
    @>{\tfrac{\diffd}{\dx}}>>
    \P_r = \P_r\Lambda^1
    @>>> 0
    \end{CD}
  \end{gather}
  We also use the simplified notation $\P\Lambda^k$, indicating that
  the polynomial degrees are chosen such that $r+k$ is constant.
\end{Definition}

\begin{remark}
  The polynomials sequence is exact due to \slideref{Theorem}{polynomial-exact}.
\end{remark}

\begin{Definition}{pr-1d-basis}
  The node functionals for $\P_{r+1}\Lambda^0$ are
  \begin{gather}
    \begin{matrix}
      \nodal_{0,0}^0(p) = p(1) - p(0),\\
      \nodal_{0,1}^0(p) = p(1) + p(0),
    \end{matrix}\qquad
    \nodal_{1.q}^0(p) = \int_{I} p' q \dx,\quad\forall q\in\nicefrac{\P_{r}}{\R}.
  \end{gather}
  The degrees of freedom for $\P_{r}\Lambda^1$ are
  \begin{gather}
    \nodal_{1,q}^1(p) = \int_{I} p q \dx,\quad\forall q\in\P_{r}.
  \end{gather}
  Bases for the shape function spaces are defined by duality.
\end{Definition}

\begin{remark}
  The degrees of freedom for $\P_{r+1}\Lambda^0$ are chosen such that
  the finite element function on a subdivision of $I$ is continuous,
  thus in $H^1$. This is true, even if the function values at the end
  points only appear in linear combinations.

  For $\P_{r}\Lambda^1$, we do not require continuity
  and thus only need interior degrees of freedom.
\end{remark}

\begin{Lemma}{commute-nodal}
  Let finite element $k$-forms $\P\Lambda^k$ on the cell $\cell\subset\R^\sdim$ be
  defined by node values $\nodal_i^k$ for $i=1,\dots,m_k$. Let the
  basis for the shape function spaces $\{\phi^k_i\}$ and
  $\{\phi^{k+1}_i\}$, respectively defined by duality.  Assume for $\rho=\dim\range d$
  \begin{gather}
    \label{eq:commute-basis}
      \begin{aligned}
          d\phi^k_i &= \phi^{k+1}_i & \qquad i&=1,\dots,\rho,\\
          d\phi^k_i &= 0 & i&=\rho+1,\dots,\dim\P\Lambda^{k}(\cell).
      \end{aligned}
  \end{gather}
Moreover, assume for any $\omega\in \Lambda^k(\cell)$
  \begin{gather}
    \label{eq:commute-nodal}
      \begin{aligned}
      \nodal^{k+1}_i(d \omega) &= \nodal^k_i(\omega)& \qquad i&=1,\dots,\rho,\\
      \nodal^{k+1}_i(d \omega) &= 0 & i&=\rho+1,\dots,\dim\P\Lambda^{k+1}.
      \end{aligned}
  \end{gather}
  Then, the \putindex{canonical interpolation} operators $\Pi$ commute
  with the exterior derivative, namely, there holds:
  \begin{gather}
    d_k \Pi_k \omega = \Pi_{k+1} d_k \omega.
  \end{gather}
\end{Lemma}

\begin{proof}
  By linearity, we have
  \begin{gather}
      d\Pi_k \omega = d\left(\sum_{i=1}^{\dim\P\Lambda^k}\nodal^k_i(\omega) \phi^k_i\right)
      = \sum_{i=1}^{\rho}\nodal^k_i(\omega) d \phi^k_i
      = \sum_{i=1}^{\rho}\nodal^k_i(\omega) \phi^{k+1}_i.
  \end{gather}
  On the other hand,
  \begin{gather}
    \Pi_{k+1} d \omega = \sum_{i=1}^{\dim\P\Lambda^{k+1}}\nodal^{k+1}_i(d \omega) \phi^{k+1}_i.
     = \sum_{i=1}^{\rho}\nodal^{k+1}_i(d \omega) \phi^{k+1}_i.
  \end{gather}
  Employing~\eqref{eq:commute-nodal} concludes the proof.
\end{proof}

\begin{Lemma}{pr-1d-commute}
  Let
  \begin{gather}
    \begin{split}
      \Pi^0_{r+1}\colon \Lambda^0(I) &\to \P_{r+1}\Lambda^0(I)\\
      \Pi^1_{r}\colon \Lambda^1(I) &\to \P_{r}\Lambda^1(I).
    \end{split}
  \end{gather}
 Then, the diagram
  \begin{center}
    \begin{tikzcd}
      \Lambda^0(I)
      \arrow[r,"\diffd"]
      \arrow[d,"\Pi"]
      & \Lambda^{1}(I)
      \arrow[d,"\Pi"]
      \\
      \P\Lambda^0(I) \arrow[r,"\diffd"]
      &\P\Lambda^{1}(I)
    \end{tikzcd}
  \end{center}
  commutes.
\end{Lemma}

\begin{proof}
  We prove that the assumptions of \slideref{Lemma}{commute-nodal} are
  fulfilled. To this end, we have to choose a particular basis for the
  node functional spaces. Let this be the \putindex{Legendre
    polynomials} of degrees zero to $r$ for $\nodal_{1,q}^1$. For
  $\nodal_{1,q}^0$, we choose
  \begin{gather}
    q_i = \plegendre_i,\qquad i=1,\dots, r
  \end{gather}

  We note that for Legendre polynomials on $[0,1]$ there holds
  \begin{gather}
    2(2m+1) \int_0^x \plegendre_m(t)\dt = \plegendre_{m+1}(x) - \plegendre_{m-1}(x).
  \end{gather}
  The basis functions for $\P_r\Lambda^0$ are
  \begin{gather}
    \begin{split}
      \phi_{0,0}^0 &= x-\tfrac12,\\
      \phi_{1,q_i} &= \tfrac{1}{2(2i+1)}(\plegendre_{i+1} - \plegendre_{i-1}),
      \qquad i=1,\dots,r,\\
      \phi_{0,1}^0 &= \tfrac12.
    \end{split}
  \end{gather}
  Clearly, the basis functions for $\P_r\Lambda^1$ are the Legendre polynomials themselves.
  Then, we have for $i=1,\dots,r$
  \begin{gather}
    d \phi_{1,q_i}^0(x) = \frac{\diffd}{\diffd x} \phi_{1,q_i}(x)
    = \plegendre_i(x)
    = \phi_{1,i}(x).
  \end{gather}
  Furthermore, $d\phi_{0,1}^0(x)=0$ and
  $d\phi_{0,0}^0(x)=1 = \phi_{1,0}^1(x)$. It thus remains to verify
  that the node functionals commute, which is obvious for
  $\nodal_{1,q_i}^0$ for $i=1,\dots,r$. For the remaining one, this
  is due to the fundamantal theorem of calculus.
\end{proof}

\begin{Definition}{k-form-tensor-product}
  Let $\omega\in \Lambda^k$ and $\eta\in\Lambda^\ell$, then their
  tensor product $\omega\otimes\eta\in\Lambda^{k+\ell}$ is defined through
  their basis representations
  \begin{gather}
    \omega = \sum_{\sigma\in\Sigma(k,n)} a_\sigma \dx_\sigma,
    \qquad
    \eta = \sum_{\tau\in\Sigma(\ell,n)} b_\tau \dx_\tau,
  \end{gather}
  as
  \begin{gather}
    \omega\otimes\eta = \sum_{\sigma\in\Sigma(k,n)}\sum_{\tau\in\Sigma(\ell,n)}
    (a_\sigma\otimes b_\tau) \dx_\sigma \wedge \dx_\tau.
  \end{gather}
  The space of $n$-fold tensor product polynomial $k$-forms is
  \begin{gather}
    \Q_r^+\Lambda^k \equiv
    \left(\P\Lambda^{\otimes n}\right)^k
    = \bigoplus_{\sigma_\in\Sigma(k,n)}
    \P_r^+\Lambda^{\chi_1} \otimes \dots \otimes \P_r^+\Lambda^{\chi_n},
  \end{gather}
  where $\chi= \chi_\sigma$ is the \putindex{characteristic vector} of $\sigma$.
\end{Definition}

From the study of the one-dimensional complex, we know that
$\P_{r+1}\Lambda^0$ and $\P_r\Lambda^1$ form an exact sequence. Thus,
in more detail, we have
  \begin{align}
    \left(\P\Lambda^{\otimes n}\right)^k
    &= \bigoplus_{\sigma_\in\Sigma(k,n)}
      \P_{r+1-\chi_1}\Lambda^{\chi_1} \otimes \dots \otimes \P_{r+1-\chi_n}\Lambda^{\chi_n}
    &= \bigoplus_{\sigma_\in\Sigma(k,n)}
      \P_r^+ \Lambda^{\chi_1}\otimes \dots \otimes \P_r^+\Lambda^{\chi_n},
  \end{align}
  where the second line hides the change of polynomial degree in the
  `$+$' superscript. This is also the idea behind the notation
  $\Q_r^+\Lambda^k$, which leads to the known continuous $\Q_{r+1}$
  element for 0-forms.

  Theoretically, $r$ could be different in each factor, as long as the
  relation between $\Lambda^0$ and $\Lambda^1$ is maintained.

  The tensor product of functions $p_i$ is
  \begin{gather}
    p_1\otimes \dots\otimes p_n(\vx) = p_1(x_1) p_2(x_2)\dots p_n(x_n).
  \end{gather}

\begin{todo}
  Use the form
  \begin{gather}
    \omega(v_1,\dots,v_k), \qquad \eta(w_1,\dots,w_\ell)\\
    \omega\otimes \eta(v_1,\dots,v_k,w_1,\dots,w_\ell).
  \end{gather}
\end{todo}

\begin{Lemma}{tensor-product-exterior-derivative}
  The \putindex{exterior derviative} of a tensor product $k$-form
  $\omega\otimes\eta$ with $\omega\in\Lambda^i$,
  $\eta\in\Lambda^j$, and $i+j=k$ is the $(k+1)$-form obtained by the
  \putindex{Leibniz rule}
  \begin{gather}
    d_k(\omega\otimes\eta) = d_i\omega \otimes \eta +  (-1)^i \omega \otimes d_j\eta.
  \end{gather}
\end{Lemma}

\begin{example}
  Let $\omega_1^0 = p_1 = p_1(x_1)$ and $\omega_2 = p_2(x_2)$.
  The two-dimensional tensor product $0$-form $q=p_1\otimes p_2$ on $[0,1]^2$ is
  \begin{gather}
    q(\vx) = \omega_1^0\otimes \omega_2^0(\vx) = p_1(x_1)p_2(x_2).
  \end{gather}
  Its exterior derivative is
  \begin{gather}
    d q(\vx) = d\omega_1^0 \otimes \omega_2^0 - \omega_1^0 \otimes d\omega_2^0
    = p_1'(x_1) p_2(x_2) \dx_1 + p_1(x_1) p_2'(x_2) \dx_2.
  \end{gather}
  Note that $d^2 = 0$ since $\dx_i\wedge \dx_i=0$.

  Let $\omega_1^1 = p_1(x_1)\dx_1$ and $\omega_2^1 = p_2(x_2)\dx_2$. Then, the
  possible tensor product 1-forms on $[0,1]^2$ are
  \begin{align}
    \omega_1^1 \otimes \omega_2^0 (\vx) &= p_1(x_1)p_2(x_2) \dx_1 \\
    \omega_1^0 \otimes \omega_2^1 (\vx) &= p_1(x_1)p_2(x_2) \dx_2,
  \end{align}
  Since forms of index 1 are one polynomial degree lower, we see that
  the tensor product function coefficient in front of $\dx_i$ is one
  degree lower in $x_i$ than in $x_j$ for $j\neq i$.

  Finally, we obtain the 2-form
  \begin{gather}
    \omega_1^1 \otimes \omega_2^1 (\vx) = p_1(x_1)p_2(x_2) \dx_1\wedge\dx_2.
  \end{gather}
\end{example}

\begin{Definition}{tensor-product-complex}
  Let there be two complexes $V^k = \Lambda^k(\R^n)$ and $W^\ell = \Lambda^\ell(\R^m)$,
  \begin{gather}
    \begin{matrix}
      \R&\xrightarrow{\subset}&V^0&\xrightarrow{d}&\cdots&
      \xrightarrow{d}&V^n&\xrightarrow{}& 0\\
      \R&\xrightarrow{\subset}&W^0&\xrightarrow{d}&\cdots&
      \xrightarrow{d}&W^m&\xrightarrow{}& 0
    \end{matrix}
  \end{gather}
  Then, the tensor product of the two complexes is
  \begin{gather}
    \R\xrightarrow{\subset}(V\otimes W)^0
    %\xrightarrow{d}(V\otimes W)^1
    \xrightarrow{d}\cdots\xrightarrow{d}(V\otimes W)^{m+n},
  \end{gather}
  where
  \begin{gather}
    (V\otimes W)^k = \bigoplus_{i+j=k} (V^i\otimes W^j).
  \end{gather}
\end{Definition}

\begin{Lemma}{tensor-product-exact}
  If the two complexes $\{V^k\}$ and $\{W^k\}$ are exact, then their tensor product is.
\end{Lemma}

\begin{todo}
  Make the representation of kernel and range part of the lemma?
\end{todo}

\begin{Corollary}{tensor-power-complex-exact}
  The tensor product complex
  \begin{gather}
    \R
    \overset{\subset}{\longrightarrow}
    \left(\P_r\Lambda^{\otimes n}\right)^0
    \overset{d}{\longrightarrow}
    \left(\P_r\Lambda^{\otimes n}\right)^1
    \overset{d}{\longrightarrow}
    \dots
    \overset{d}{\longrightarrow}
    \left(\P_r\Lambda^{\otimes n}\right)^n
    \longrightarrow 0
  \end{gather}
  is exact.
\end{Corollary}

\begin{Lemma}{qr-complex}
  The coefficient functions for $(\P_r^{\otimes 3})^k$ and thus the
  polynomial proxy fields are from the spaces
  \begin{gather}
    \R
    \overset{\subset}{\longrightarrow} \Q_{r+1}
    \overset{\nabla}{\longrightarrow}
    \begin{pmatrix}
      \Q_{r,r+1,r+1}\\\Q_{r+1,r,r+1}\\\Q_{r+1,r+1,r}
    \end{pmatrix}
    \overset{\curl}{\longrightarrow}
    \begin{pmatrix}
      \Q_{r+1,r,r}\\\Q_{r,r+1,r}\\\Q_{r,r,r+1}
    \end{pmatrix}
    \overset{\div}{\longrightarrow}
    \Q_r
    \longrightarrow 0,
  \end{gather}
\end{Lemma}

\begin{Theorem}{tensor-product-node-values}
  Let there be two polynomial tensor complexes $\{V^k=\P\Lambda^k\}$
  and $\{W^k=\P\Lambda^k\}$ with node functionals $\nodal_{V,i}^k$ and
  $\nodal_{W,j}^k$, respectively. Let the node functionals be
  unisolvent for the spaces $V^{k_1}$ and $W^{k_2}$,
  respectively. Then, a unisolvent set of node functionals on
  $V^{k_1}\otimes W^{k_2}$ is defined on the tensor product by
  \begin{gather}
    \nodal_{V,i}^{k_1}\otimes\nodal_{W,j}^{k_2}(\omega\otimes\eta)
    = \nodal_{V,i}^{k_1}(\omega)\nodal_{W,j}^{k_2}(\eta),
    \qquad \omega\in V^{k_1}, \eta\in W^{k_2}
  \end{gather}
\end{Theorem}

\begin{Definition}{cube-facets}
  Let $\cell$ be the hypercube $[0,1]^\sdim$ in $\R^\sdim$. Then,
  every combination $\sigma\in\Sigma(j,\sdim)$ together with a tuple
  $\{b_1,\dots,b_{\sdim-j}\}$ defines a $j$-dimensional \define{facet} of $\cell$ denoted by
  \begin{gather}
    f_{\sigma,b_1,\dots,b_{n-j}} =
    \left\{
      \vx\in\R^\sdim \;\middle\vert\;
      \arraycolsep1pt
      \begin{array}{rlcrl}
        x_i &\in [0,1] &\text{ for }& i&\in\sigma\\
        x_{\overline\sigma_i} &= b_i&\text{ for }& i&\not\in\sigma.
      \end{array}
    \right\},
  \end{gather}
  where $\overline\sigma\in\Sigma(n-j,n)$ is the complement of $\sigma$.

  The set of all facets of $\cell$ is denoted by $\Delta(\cell)$, the
  set of all facets of dimension $j$ is $\Delta_j(\cell)$.
\end{Definition}

\begin{Lemma}{cube-facets}
  The number of $j$-dimensional facets of a $\sdim$-dimensional hypercube is
  \begin{gather}
    \#\Delta_j(\cell) = 2^{\sdim-j}\binom{\sdim}{j}.
  \end{gather}
\end{Lemma}

\begin{Lemma}{facets-k-forms}
  The space of tangential traces
  $\gamma_f \left(\P_r\Lambda^{\otimes n}\right)^k$ on a facet of $\cell$ of
  dimension $j$ is isomorphic to
  $\left(\P_r\Lambda^{\otimes {j}}\right)^k$. In particular, it is zero if $j<k$.
\end{Lemma}

\begin{todo}
  Connectupper index of node functionals and spaces
\end{todo}
\begin{Notation}{dual-pr-1d}
  We denote by $W_r^i$ the dual space of $\P_r\Lambda^i(I)$ for
  $i=0,1$, respectively. We obtain a basis by a transformation and
  translating~\slideref{Definition}{pr-1d-basis} into the language of
  differential forms:
  \begin{xalignat}3
    \widetilde\nodal_{0,b}^0(\omega) &= \int_b \omega
    & \forall b&\in\{0,1\},
    & \forall \omega&\in \P_{r+1}\Lambda^0,
    \\
    \widetilde\nodal_{1,q}^0(\omega) &= \int_I \diffd\omega \wedge q
    & \forall q&\in \nicefrac{\P_r\Lambda^0}{\R},
    & \forall \omega&\in \P_{r+1}\Lambda^0,
    \\
    \widetilde\nodal_{1,q}^1(\omega) &= \int_I \omega \wedge q
    & \forall q&\in \P_r\Lambda^0,
    & \forall \omega&\in \P_{r}\Lambda^1,
  \end{xalignat}
  The upper index of $\widetilde\nodal_{x,y}^i$ corresponds to the space $W_r^i$.

  Due to \slideref{Theorem}{tensor-product-node-values},
  we can write
  \begin{gather}
    \left(\left(\P\Lambda^{\otimes n}\right)^k\right)^*
    = \bigoplus_{\sigma\in\Sigma(k,n)} W_r^{\chi_1}\otimes\dots\otimes W_r^{\chi_n}.
  \end{gather}
\end{Notation}

\begin{Definition}{facet-nodal}
  Let $f_{\sigma,b_1,\dots,b_{n-j}}$ be a $j$-dimensional facet of the
  hypercube $T = [0,1]^\sdim$. Using \slideref{Notation}{dual-pr-1d},
  we define the space
  \begin{gather}
    W^k(f_{\sigma,b_1,\dots,b_{n-j}}) = \bigoplus_{\tau\in\Sigma(k,n)} W_\tau,
  \end{gather}
  where
  \begin{gather}
    W_\tau = W_{\tau,1}\otimes \dots \otimes W_{\tau,n},
    \qquad W_{\tau,i} =
    \begin{cases}
      W_r^1 & \text{if } i \in \sigma \cap \tau\\
      W_r^0 & \text{if } i \in \sigma \cap \overline\tau\\
      \operatorname{span} \nodal_{0,b_i}^0 & \text{if } i \in \overline\sigma \cap \overline\tau\\
      \{0\} & \text{if } i \in \overline\sigma \cap \tau
    \end{cases}
  \end{gather}
  We call these the node values on the facet $f_{\sigma,b_1,\dots,b_{n-j}}$.
\end{Definition}

\begin{Theorem}{qr-unisolvence}
  Let $f\in\Delta(\cell)$. Let
  $\omega\in \left(\P\Lambda^{\otimes n}(I)\right)^k$. Then,
  $\gamma_f\omega$ is uniquely determined by the node functionals
  spanning $W^k(f)$. In particular, the finite element $k$-form with
  its node functionals is unisolvent.
\end{Theorem}

\section{Commuting quasi-interpolation operators}

\begin{intro}
  Quasi-interpolation operators for
  $H\Lambda^0(\domain) = H^1(\domain)$ are obtained by replacing point
  values by volume (Clément, Schöberl) or line (Scott/Zhang)
  averages. We have already seen, that in $\Hdiv(\domain)$, we also
  must replace face integrals by volume averages. Here, we are faced
  with the commutation property, such that the averages cannot be
  defined for each facet separately. Instead, we turn the procedure
  around and use interpolation on whole families of cells and the
  average over these families.

  The original version of the quasi-interpolation operators presented
  here is due to J.~Schöberl. The tensor product construction
  presented here is from current work of myself and F.~Bonizzoni.
\end{intro}

\begin{Lemma}{perturbed-interpolation-1d}
  Let $I_{a,b} = [a,b]$ Let the node functionals for
  $\P_r^+\Lambda^i(I_{a,b})$ with $i=0,1$ be defined for
  $\omega^0\in\Lambda^0$ and $\omega^1\in\Lambda^1$, respectively, by
  \begin{align}
    \nodal_{0,a,b}^0(\omega^0) &= \omega^0(b) - \omega^0(a),\\
    \nodal_{i,a,b}^0(\omega^0) &= \int_a^b \mu_i\diffd\omega^0 ,
                                 \quad i=1,\dots,r,
    \\
    \nodal_{r+1,a,b}^0(\omega^0) &= \omega^0(b) + \omega^0(a),\\
    \nodal_{i,a,b}^1(\omega^1) &= \int_a^b \mu_i\omega^1 ,\quad i=0,\dots,r,
  \end{align}
  where $\mu_i\in \P_i\Lambda^0$ are from the sequence of orthogonal
  polynomials on $I_{a,b}$. Then, there holds for $\omega\in\Lambda^0$
  \begin{gather}
    \nodal_{i,a,b}^0(\omega) = \nodal_{i,a,b}^1(\diffd\omega), \qquad i=0,\dots,r.
  \end{gather}
\end{Lemma}

\begin{proof}
  The proof is trivial for $i=1,\dots,r$ and elementary for $i=0$.
\end{proof}

\begin{Definition*}{cutoff}{Cutoff functions}
  A $C^k$-\define{cutoff function} $\eta_{x,\rho}$ for the interval $B_\rho(x)$ of radius
  $\rho$ around $x$ is a function fulfilling the following conditions:
  \begin{gather}
    \eta_{x,\rho} \in C^k\left(\R^\sdim\right),\qquad
    \operatorname{supp} \eta_{x,\rho}  \subseteq \overline{B_\rho(x)},\qquad
    \int \eta_{x,\rho} \dx = 1.
  \end{gather}
  An example for a $C^\infty$-cutoff function is
  \begin{gather}
    \eta_{x,\rho}(y) = \frac1{\rho\int\tilde\eta} \tilde\eta\left(\tfrac{y-x}{\rho}\right),
    \qquad
    \tilde\eta(t) =
    \begin{cases}
      \exp\left(\tfrac1{t^2-1}\right) & t\le 1\\
      0 & t>1.
    \end{cases}
  \end{gather}
\end{Definition*}

\begin{Definition}{quasi-interpolation-1d}
  Let $\rho\le \nicefrac13$. Let $\eta_{0,\rho}$, and $\eta_{1,\rho}$ be cutoff
  functions. Then, we define quasi-interpolation operators
  \begin{align}
    I^k_\rho\colon \Lambda^k(I_{-\rho,1+\rho}) &\to \P_r^+\Lambda^k(I_{0,1}),
                                     \qquad k=0,1,\\
    \omega^k & \mapsto \sum_i \overline{\nodal_i^k}(\omega^k) \phi_i^k,
  \end{align}
  using the node functionals
  \begin{gather}
    \overline{\nodal_i^k}(\omega^k)
    = \int_{-\rho}^\rho\int_{-\rho}^\rho \nodal_{i,a,b}^k(\omega^k)
    \eta_{0,\rho}(a)\eta_{1,\rho}(b) \,\diffd a\,\diffd b,
  \end{gather}
  and the shape functions $\phi_i^k$ according to \slideref{Definition}{pr-1d-basis}.
\end{Definition}

\begin{Lemma}{quasi-interpolation-1d}
  The quasi-interpolation operators $I_\rho^k$ can be extended to
  bounded operators on $L^2\Lambda^k(I_{-\rho,1+\rho})$, and thus on
  $H\Lambda^k(I_{-\rho,1+\rho})$. Furthermore, they commute with the
  exterior derivative.
\end{Lemma}

\begin{Definition}{quasi-interpolation-tensor}
  The tensor product quasi-interpolation operator
  $I^k_{\rho,\otimes n}$ is defined formally as
  \begin{gather}
    I^k_{\rho,\otimes n}\colon L^2\left(\Lambda^{\otimes n}\right)^k
    \to \Q_r^+\Lambda^k,
    \qquad
    I^k_{\rho,\otimes n} = \sum_{\sigma\in\Sigma(k,n)}
    I^{\chi_1}_\rho \otimes \dots \otimes I^{\chi_n}_\rho.
  \end{gather}
  Applied to a rank one tensor $\omega_1\otimes \dots \otimes \omega_\sdim$ with
  $\omega_i \in L^2\Lambda^{\chi_i}$, there holds
  \begin{gather}
    I^k_{\rho,\otimes n}(\omega_1\otimes \dots \otimes \omega_\sdim)
    = I^{\chi_1}_\rho (\omega_1)\otimes \cdots\otimes I^{\chi_n}_\rho(\omega_n).
  \end{gather}
\end{Definition}

\begin{Theorem}{quasi-interpolation-tensor}
  Let node functionals for $\Q_r^+\Lambda^k(\cell)$, where
  $\cell = [0,1]^\sdim$ be defined as tensor products of the node
  functionals in \slideref{Definition}{quasi-interpolation-1d}. Then,
  the resulting quasi-interpolation operators $I_{\rho,\otimes n}^k$ commute with
  the exterior derivative. Furthermore, they are bounded operators on
  $L^2\Lambda^k(\overline\cell$), where $\overline \cell = [-\rho,1+\rho]^\sdim$.
\end{Theorem}

\begin{Definition}{tensor-form-shape-functions}
  Let $\mesh_h$ be a finite element mesh on $\domain$ consisting of
  mesh cells $\cell$ which are obtained from a reference cell
  $\refcell = [0,1]^\sdim$ by the mapping $\Phi_\cell$. We define the
  \define{shape function space} $V_\cell^k$ on each cell $\cell$ by
  pullback from the reference cell such that
  \begin{gather}
    V_\cell^k = \bigl\{ \omega^k\in \Lambda^k(\cell) \;\big\vert\;
    \Phi^* \omega^k \in \Q_r^+\Lambda^k(\refcell) \bigr\}.
  \end{gather}
  The \define{finite element space} on the mesh $\mesh_h$ is
  \begin{gather}
    V_h^k = \bigl\{\omega_h^k \in H\Lambda^k(\domain)\;\big\vert\;
    \omega_h^k \in V_\cell^k \bigr\}.
  \end{gather}
\end{Definition}

\begin{Definition}{form-quasi-interpolation-mesh}
  A quasi-interpolation operator $I_{h,\rho}^k$ on the mesh $\mesh$ is defined by
  choosing the averaged node functionals consistently between mesh
  cells with averaging length $\rho = \nicefrac13 h$.
\end{Definition}

\begin{Corollary}{form-quasi-interpolation-mesh}
  The quasi-interpolation operators $I_{h,\rho}^k$ are bounded operators
  \begin{gather}
    I_{h,\rho}^k \colon H\Lambda^k(\domain) \to V_h^k,
  \end{gather}
  such that
  \begin{gather}
    d_k \circ I_{h,\rho}^k = I_{h,\rho}^{k+1} \circ d_k.
  \end{gather}
\end{Corollary}

\begin{Lemma}{form-quasi-interpolation-convergence}
  The restriction of $I_{h,\rho}^k$ to $V_h^k$ is a continuous function
  in $\rho$, and its limit for $\rho\to0$ is the identity.

  For sufficiently small $\rho$ the operator $I_{h,\rho|V_h^k}^k$ is
  invertible.
\end{Lemma}

\begin{Definition}{schoeberl-interpolation}
  The \define{Schöberl interpolation} operator $S_h^k$ is defined for
  sufficiently small $\rho$ as
  \begin{gather}
    S_h^k = \left(I_{h,\rho|V_h^k}^k\right)^{-1} \circ I_{h,\rho}^k.
  \end{gather}
  $S_h$ is a bounded operator on $H\Lambda^k$ which commutes with the
  exterior derivative and there holds
  \begin{gather}
    \left(S_h^k\right)^2 = S_h^k.
  \end{gather}
\end{Definition}

\begin{Theorem}{fem-cochain}
  The finite element cochain complex with spaces $V_h^k$ provides
  inf-sup stable discretizations for mixed problems of the form: find
  $\omega^{k}\in V_h^k$ for $k=0,\dots,\sdim$, such that
  \begin{gather}
    \arraycolsep1pt
    \begin{matrix}
      \form(\diffd\omega^k,\diffd \mu^k)
      &+& \form(\diffd \omega^{k-1},\mu^k)
      &=& \form(f,\mu^k)\\
      \form(\diffd\mu^{k-1},\omega^k) &&&=&0
    \end{matrix}
    \qquad\forall \mu^k\in V_h^k, \quad k=0,\dots,\sdim.
  \end{gather}
\end{Theorem}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "main"
%%% End:


\chapter{Results}
\label{chapter:results}

% \input{figs/ascending_descending}

% The relation between the pressure and resistance was non-linear as we expected.

% \input{figs/velostat_layers.tex}

% The pressure mat frames are mapped with color scheme Jet and Gaussian interpolation is used to get the final output. Since there was huge difficulties for a proper and careful calibration in the overall pressure mat we could not get highly satisfactory results. But the mat detected areas corresponding to high pressure approximately. More statisfactory image was obtained for feet when standing on the mattress. \input{figs/mat_frames.tex}

% Several 1.2kg discs were used to check parts of the mattress.

% When an pressure image is sent to the server end point and the posture is detected. Then there are particular ulceration points that are active for that posture. Providing the pressure image and these ulceration point names as the input bounding box parameters can be obtained.
% \input{figs/ml_result}
% All five postures classified correctly and bounding boxes are marked appropriately as in the figures.

% When ulceration points are located the pressure of these points can be found. We simulated temporal behavour and repositioning using the dataset by University of Dallas.

% Repositioning considerably shifts the pressure distribution.

% \input{figs/simulation}

The relationship between resistance and pressure is non-linear (as expected for Velostat).\input{figs/ascending_descending} Comparing the curves under ascending and descending forces it can be seen that hysteresis effects are tolerable. Comparing two layers of Velostat against one layer it was revealed that although the sensitivity improved the time for a stable result higher in the case of two layers. Therefore one layer of Velostat is appropriate for the pressure mats. \input{figs/velostat_layers.tex}

\section{Frames of Pressure Mat Readings}
The frames from pressure mat are mapped with color scheme Jet and Gaussian interpolation is used to get the final output. Since there was huge difficulties for a proper and careful calibration in the overall pressure mat we could not get highly satisfactory results. But the mat detected areas corresponding to high pressure approximately. More satisfactory image was obtained for feet when standing on the mattress. Several 1.2kg discs were used to calibrate parts of the mattress. \input{figs/mat_frames.tex}

\section{Neural Network results}
When a pressure image is sent to the server end point the posture is detected by the posture detection model. Then there are particular ulceration points that are active for that posture. Providing the pressure image and these ulceration point names as the input, bounding box parameters can be obtained.
All five postures classified correctly and bounding boxes are marked appropriately as in the figures.\input{figs/ml_result}

\section{Simulation of pressure-time behaviour on ulceration points}

When ulceration points are located the pressure of these points can be found. We simulated temporal behaviour and repositioning using the dataset by University of Dallas.Repositioning considerably shifts the pressure distribution and the pressure values are almost stable in a particular posture.

\input{figs/simulation}

\section{Implementation}

\begin{description}
    \item[The information system]   \url{http://prevelcer.herokuapp.com}
    \item[App] React native based app
    \item[API documentation] \url{https://documenter.getpostman.com/view/13647586/TVmHDeox}
    \item[Neural Network Models] \url{http://prevelcernn.herokuapp.com}
\end{description}