\chapter{Fake rate of pulse detection}
\label{ch:rate}

In \autoref{ch:snr} we measured the signal to noise ratio after filtering. The
point of using the SNR is expressing the signal height relative to the width of
the noise distribution, because the threshold required to reject noise with a
given probability is proportional to that scale. So it is convenient to express
the threshold relative to the same scale. When setting a threshold on the
filtered amplitude, as done in data acquisition to reduce the noise rate, an
SNR well above such a rescaled threshold will ensure that a good efficiency for
signal is retained.

This chapter deals with the calculation of the noise rate resulting from random
fluctuations of the noise above the threshold.

Even assuming the noise to be Gaussian, the probability that a random
fluctuation gets above the threshold is not given simply by computing the
survival function (i.e., the integral to $+\infty$) of the Gaussian
distribution at the threshold.

More precisely, the probability that any given sample is above the threshold is
given by such integral. What we need, however, is the \emph{rate} of threshold
\emph{crossings}. The noise is not white, but even if it was, after applying
the filter, which combines linearly many input samples for each output sample,
the waveform is autocorrelated at least up to the length of the filter.
Intuitively, if a smooth function crosses a threshold, it takes some time to go
down before it can cross the threshold again.

We will present the method used to compute the threshold crossing rate of the
noise, or fake rate, for a running average filter, and check that the
calculated rates are consistent with the results obtained in data.

The choice of the running average filter is due to the fact that this was the
filter implemented as part of the first prototype firmware for the FPGA of the
digitizer board. This constitutes the first processing stage in the DarkSide
DAQ chain, and the reduction of the noise is a key goal of that processing.
However, the method we present can be applied to any linear filter of choice,
and allows to extrapolate efficiently to very low rates.

\section{Model}

We expect the noise to be Gaussian. Even if it were not prior to any
processing, when filtering many samples are linearly combined, and the sum of
random variables tends to have a Gaussian distribution independently of the
initial one. So Gaussianity is a reasonable assumption in our study.

\subsection{From the continuous case}

We have a discrete sequence of samples. The continuous equivalent is a Gaussian
process. We can expect the discrete case to be equivalent to the continuous
case if the autocorrelation time is larger enough than the sampling step, which
should hold from the consideration above.

Also, even though the values are initially discrete too, after filtering the
possible non integer values between two consecutive integers are at least the
length of the filter (think about an average). So we take the formula for the
continuous case and adapt it.

The mean number of threshold upcrossings $r$ in the interval $(0,1)$ by a
zero-mean stationary and appropriately smooth Gaussian process is given by
\cite[81]{rasmussen2006}
%
\begin{align}
    r &= \sqrt{-\frac{k''(0)}{2\pi}} \operatorname{gauss}(u;0,\sigma) = \\
      &= \frac 1 {2\pi} \frac {\sqrt{-k''(0)}} \sigma
         \exp \left( -\frac12 (u/\sigma)^2 \right),
\end{align}
%
where $u$ is the threshold, $\sigma$ the noise standard deviation (the RMS),
$\operatorname{gauss}(x;\mu,\sigma)$ a Gaussian probability density on $x$ with
mean $\mu$ and standard deviation $\sigma$, and $k$ the autocovariance
function, i.e., $k(x) = \operatorname{Cov}[f(t), f(t+x)]$ for any $t$ (for
example, $k(0) = \sigma^2$), where $f(t)$ is the continuous waveform.

We have to map the second derivative of the autocovariance function to a
discrete equivalent. We first do a manipulation in the continuous realm. Since
the covariance operator is an integral, it commutes with derivation:
%
\begin{align}
    k''(x)
    &= \frac{\partial^2}{\partial x^2} \operatorname{Cov}[f(t), f(t+x)] = \\
    &= \operatorname{Cov}[f(t), f''(t+x)],
\end{align}
%
thus $k''(0) = \operatorname{Cov}[f(t), f''(t)]$. We estimate the second
derivative with a finite difference:
%
\begin{align}
    f(t \pm \Delta t)
    &= f(t) \pm f'(t) \Delta t + \frac12 f''(t) \Delta t^2 + O(\Delta t^3)
    \rightarrow \\
    \rightarrow f''(t) \Delta t^2 &=
    f(t + \Delta t) + f(t - \Delta t) - 2 f(t) + O(\Delta t^3).
\end{align}
%
Choosing $\Delta t = 1/f_s$, where $f_s$ is the sampling frequency, and calling
$y_i = f(t_0 + i\Delta t)$ the samples, we have:
\begin{align}
    k''(0) &\mapsto f_s^2 k_2, \\
    k_2 &\equiv \operatorname{Cov}[y_i, y_{i+1}+y_{i-1}-2y_i], \label{eq:k2} \\
    r &= f_s \frac 1 {2\pi} \frac {\sqrt{-k_2}} \sigma
         \exp \left( -\frac12 (u/\sigma)^2 \right).
    \label{eq:rcont}
\end{align}
%
Discretizing directly $k''(0)$ yields the same result.

The covariance in \autoref{eq:k2} can be estimated with the sample
covariance on a filtered waveform array~$\mathbf y$.

\subsection{Direct discrete derivation}

Since the formula we derived is approximate, as a cross check we derive another
approximate one following a different path.

A threshold crossing happens when a sample is below the threshold and the next
one is above: $y_i \leq u$, $y_{i+1} > u$. Fix $i=0$ and let $p(y_0,y_1)$ be the
joint distribution of the two samples. The probability of crossing at any given
point then is
%
\begin{equation}
    P =
    \int_{-\infty}^u \mathrm d y_0\,
    \int_u^\infty \mathrm d y_1\,
    p(y_0, y_1).
    \label{eq:crossingprob}
\end{equation}

In general we can not obtain the crossing rate just by multiplying $P$ by the
sampling frequency because of correlations. However in practice we are
interested in low crossing rates, less than~\SI{10}{cps}, to be compared to the
filter length $\SI{2}{\micro s} = 1/(\SI{500}{kHz})$. If the typical time
between crossings is much longer than the autocorrelation time, then we can
ignore correlations. Thus the crossing rate is $r = f_s P$.

The integrand in \autoref{eq:crossingprob} is a bivariate Gaussian
distribution, which explicitly is
%
\begin{equation}
    p(y_0,y_1) =
    \frac 1 {2\pi \sqrt{\sigma^4 - c^2}}
    \exp \left(
    \frac 1 2
    \begin{pmatrix}
        y_0 & y_1
    \end{pmatrix}
    \begin{pmatrix}
        \sigma^2 & c \\
        c & \sigma^2
    \end{pmatrix}^{-1}
    \begin{pmatrix}
        y_0 \\ y_1
    \end{pmatrix}
    \right),
\end{equation}
%
where $c = \operatorname{Cov}[y_0, y_1]$.

We do not know how to the integral analytically, so we break down the joint
distribution as $p(y_0,y_1) = p(y_1|y_0) p(y_0)$ and discretize the integral
over~$y_0$:
%
\begin{align}
    p(y_0) &= \operatorname{gauss}(y_0; 0, \sigma), \\
    p(y_1|y_0) &= \frac {p(y_0, y_1)} {p(y_0)}
    = \operatorname{gauss} \left(
        y_1; \frac c {\sigma^2} y_0, \sqrt{\sigma^2 - \frac {c^2} {\sigma^2}}
    \right), \\
    P &\approx
    \sum_{k=0}^{N-1} \Delta u\, p(y_0(k,u,\Delta u))
    \int_u^\infty \mathrm d y_1\, p(y_1|y_0(k,u,\Delta u)), \label{eq:rdisc} \\
    y_0(k,u,\Delta u) &\equiv u - k \Delta u.
\end{align}

The integral on $y_1$ can be computed using the error function. $\Delta u$
should be chosen small compared to $\sigma$, while $N$ large relative to
$\sigma / \Delta u$.

In \autoref{fig:crossingprob} we compare formula~\eqref{eq:rcont} (with $f_s
= 1$) with $P$ and with the Gaussian survival function. To make the comparison
we have to use a $k_2$ that matches $c$:
%
\begin{align}
    k_2 &= \operatorname{Cov}[y_i, y_{i+1}+y_{i-1}-2y_i] = \notag \\
    &= \operatorname{Cov}[y_i,y_{i+1}]
    + \operatorname{Cov}[y_i,y_{i-1}]
    - 2 \operatorname{Cov}[y_i,y_i] = \notag \\
    &= 2 (c - \sigma^2). \label{eq:c2k2}
\end{align}
%
We use $\sigma=1$, $c = \SI{99}\%$, $\Delta u = 1/100$, $N=500$ (we decreased
$\Delta u$ until convergence). We see that our derivation and the formula
for Gaussian processes agree very well, while differing visibly from the
survival function. We will henceforth use the continuous formula for its
simplicity.

\begin{figure}

    \widecenter{\includempl{figcrossingprob}}

    \figcaption{crossingprob}{The threshold upcrossing rate expressed as
    per-sample crossing probability (i.e., the rate if the sampling frequency
    is~1) for an autocorrelated Gaussian waveform, estimated using three
    formulae: 1) the probability for a single sample to be higher than the
    threshold, 2) a formula for continuous processes (\autoref{eq:rcont}),
    3) an approximation of the discrete case (\autoref{eq:rdisc}).}

\end{figure}

\subsection{Dead time}

One part of the data acquisition system (DAQ) for which the study of threshold
crossings is particularly relevant are the digitizers. Due to limited logic
resources in the installed FPGAs, a digitizer can not do complicated
processing. Instead, a simple filter is applied, and the filtered waveform is
compared to the threshold. Whenever the threshold is crossed, a fixed slice of
waveform is sent to the front end processing (FEP) for further analysis
(identify multiple signals, locate them precisely, use a better filter, etc.).
A threshold crossing that happens too close in time to a previous crossing will
be ignored.

This means that we have a dead time $T$. We model it as a non-restartable dead
time, i.e., a crossing that happens within $T$ of a previous one is ignored
only if the latter has not been ignored itself.

Assuming that the crossings are a Poisson process, the formula to correct a
rate $R$ for the effect of the dead time is \cite[120]{knoll2010}:
%
\begin{equation}
    R \mapsto \frac R {1 + RT}. \label{eq:deadrate}
\end{equation}

We note that the crossings of a Gaussian process are not in general a Poisson
process. We just need one counterexample to show this. Consider the process
with autocovariance function $k(x)=\cos(x)$. This is positive definite because
it is a linear combination of external products: $\cos(x-y) = \cos x \cos y +
\sin x \sin y$. Since $\cos$ is orthogonal to $\sin$, they are the
eigenfunctions, so a realization of the process is a random linear combination
of harmonic functions, which means that it is a shifted cosine, so the
crossings are exactly periodic.

However, in practice we expect that there will just be a ``repulsion'' or
``attraction'' of crossings within the scale of the autocorrelation time, so
for low crossing rate the formula should work.

\section{Application to real electrical noise data}

We want to test formula~\eqref{eq:rcont} on actual electrical noise.

\subsection{Data}

We will use the Proto0 run 886, collected when operating the SiPMs below their
breakdown voltage, see \autoref{sec:dataproto0}. Tiles 53, 57 and 59 (used in
Proto0) will be also studied with LNGS data, while for Tile~15 just LNGS data
are available. The LNGS data files are:
%
\begin{verbatim}
FBK/NUV/MB2-LF-3x/NUV-LF_3x_53/nuvhd_lf_3x_tile53_77K_64V_6VoV_1.wav
FBK/NUV/MB2-LF-3x/NUV-LF_3x_53/nuvhd_lf_3x_tile53_77K_66V_7VoV_1.wav
FBK/NUV/MB2-LF-3x/NUV-LF_3x_57/nuvhd_lf_3x_tile57_77K_64V_6VoV_1.wav
FBK/NUV/MB2-LF-3x/NUV-LF_3x_59/nuvhd_lf_3x_tile59_77K_64V_6VoV_1.wav
LFOUNDRY/pre-production-test/TILE_15/LF_TILE15_77K_55V_0VoV_1.wav
LFOUNDRY/pre-production-test/TILE_15/LF_TILE15_77K_59V_2VoV_1.wav
LFOUNDRY/pre-production-test/TILE_15/LF_TILE15_77K_63V_4VoV_1.wav
LFOUNDRY/pre-production-test/TILE_15/LF_TILE15_77K_67V_6VoV_1.wav
LFOUNDRY/pre-production-test/TILE_15/LF_TILE15_77K_71V_8VoV_1.wav
LFOUNDRY/pre-production-test/TILE_15/LF_TILE15_77K_73V_9VoV_1.wav
\end{verbatim}

The Proto0 data consists purely of noise, so no preprocessing is required. For
the LNGS data we take the pre-trigger part of the events, and ignore events
where any pre-trigger sample is less than~750 (860 for Tile~15).

We plot the time-value histogram of the data for Tile 53 in Proto0 and LNGS
(\autoref{fig:hist2dtile53}), for Tile 15 at maximum overvoltage, and for
Tiles 57 and 59 (\autoref{fig:hist2dtile155759}).

\subsection{Filter}

We filter using a \SI1{\micro s} moving average with \SI1{\micro s} of baseline
and \SI1{\micro s} of dead time, without delay between the baseline and the
signal averages. In \autoref{fig:sqfilt} we show an example filtered
waveform and the filter shape.

\begin{figure}

    \widecenter{\includempl{figsqfilt}}

    \figcaption{sqfilt}{A filtered waveform. The computation is split into a
    moving average $m$ (dotted line) and its finite difference $y$ (solid black
    line). The right plot shows the overall filter shape. (We use an event with
    a signal just to see how the filter behaves, the analysis is done on noise
    only.)}

\end{figure}

Although we know from \autoref{ch:snr} and~\ref{ch:timeres} that this is
not the optimal filter by SNR neither by temporal resolution, this is a simple
filter that would be suitable for implementation in the digitizer's FPGA.

Since on LNGS data the events are short compared to the filter length
(\SI9{\micro s} vs.\ \SI2{\micro s}), we need to take into account boundary
effects. The output length of the filtered waveform is $(\text{initial length})
- \SI2{\micro s} + \SI1{sample}$; to compute the rate we have to divide by this
quantity instead of the initial waveform length.

The dead time does not play nicely with borders, because a hypothetical unseen
crossing within \SI1{\micro s} before the event start could kill a crossing in
the event. Moreover, at low thresholds, the first crossing will happen
almost immediately, and again immediately after the dead time ends, thus the
number of crossings per event is quantized.

A complete solution to these problems would be to avoid counting the crossings
which happen within \SI1{\micro s} after the event start (although they are
detected and do project a dead time on the following ones), and in the
remaining region further select a subregion which is \SI1{\micro s} shorter but
has a uniformly random starting position.

However we are mostly interested in the low-rate regime, in which the dead time
boundary effects are negligible, so we keep the whole filtered region.

\subsection{Algorithm}

The simplest way to count the threshold crossings as a function of the
threshold is to repeat the calculation varying the threshold. The computational
complexity is $O(nN)$ where $n$ is the number of thresholds and $N$ the number
of samples.

To produce a smooth curve (large $n$) we use instead a reverse histogram. We
choose an evenly spaced range of thresholds. For each pair of consecutive
samples, if the second sample is higher than the first, we determine the
subrange of thresholds that falls between the samples, and increment their
counts. To apply the dead time, we keep a per-threshold last occurence time.

Since the range of thresholds is evenly spaced, the subrange can be found
arithmetically, so the complexity is just $O(N)$, i.e., it does not depend on
the number of thresholds.

\subsection{Results}
\label{sec:rateconcl}

In \autoref{fig:fakerate1} we compare the measured threshold crossings with
the continuous-derived formula~\eqref{eq:rcont} for a single Tile over the
entire threshold range. The coefficients $\sigma$ and $k_2$ for the formula are
computed on each filtered event and then averaged. Finally, the dead time is
accounted for with~\eqref{eq:deadrate}. For the data, the conversion from count
to rate is done dividing by the length of the filtered waveform (so \SI2{\micro
s} less than the initial length per event).

A discrete agreement can be observed at low and high rates, less so in the
intermediate region. The agreement at high rate is probably improved by
saturation due to dead time, since the maximum rate allowed by dead time is
$1/(\SI1{\micro s}) = \SI1{Mcps}$. Although it cannot be fully appreciated from
\autoref{fig:fakerate1} due to the logarithmic scale, even where the theory and
data lines are closer they still differ by a factor~1.3, while the Poisson
error is approx.~\SI3\% since the count is~1000.

\begin{figure}

    \widecenter{\includempl{figfakerate1}}

    \figcaption{fakerate1}{Measured and predicted (with \autoref{eq:rcont})
    fake rate for Tile~31 in Proto0 with a noise-only acquisition. The right
    scale shows the actual count of threshold crossings for the data, with a
    gray band marking one crossing.}

\end{figure}

In \autoref{fig:fakerate} we show the same comparison together for all
datasets, divided in three groups (Tile~15 LNGS data, LNGS other Tiles, Proto0
data). The parameters for the formula, and the rates at threshold~$4\,\sigma$,
are listed in \autoref{tab:fakerate}.

For comparison, in \autoref{fig:fakerate} we also show the rate predicted by
\cite[98]{savarese2018}, which provides the following formula:
%
\begin{align}
    r &= \frac{R_0}2 \exp\left(-\frac12 (u/\sigma)^2\right), \\
    R_0 &= \frac 2{\sqrt 3} f_u, \quad f_u = \SI{40}{MHz}.
\end{align}
%
We see that it overestimates the true rate about by a factor of~5-10. Note,
however, that the formula was derived without taking into account filtering, so
the overestimation is expected.

In the second group above some threshold the measured rate stops decreasing and
remains constant at approximately 10 counts. This is probably due to real
pulses which our very simple preprocessing can not filter away, most likely
\SI1{PE} dark noise or random pulses from light leaks.

In \autoref{fig:fakerate} we highlight the measured rates for Tile~53 because
they are evident outliers. The rate remains higher than the theory predicts and
than the other Tiles as the threshold increases. This is visible in Proto0, and
in LNGS at \SI6{VoV}, but not at \SI7{VoV}. Analogously, from
\autoref{tab:fakerate} we see that the quantity $f_s \sqrt{-k_2}/(2\pi\sigma)$
that multiplies the exponential in~\eqref{eq:rcont} is different from the
others for Tile~53, in the same cases as the data, but with the opposite trend.
This variation seems to depend only on an increase in $\sigma$ and not on $k_2$.

Comparing the 2D histograms for Tile~53 (\autoref{fig:hist2dtile53}) to the
others (\autoref{fig:hist2dtile155759}) there is no apparent difference. Three
possible explanations come to mind: 1)~a violation of Gaussianity, 2)~stray
pulses, 3)~low frequency electrical noise.

\marginpar{Looking at the spectrum it is evident that there's a very low
frequency component ($<\SI{10}{kHZ} = 1/(\SI{100}{\micro s})$) absent in other
Tiles. Maybe they are sudden changes of baseline? I should look at events where
crossings with high threshold happen. Try to do the spectrum with windowing to
see if it's a boundary problem.}

Regarding Gaussianity, we checked the distribution of the samples before
filtering and it agrees very well with a Gaussian. If they are stray pulses,
they do not have the same height, otherwise they would show up as a flat rate
curve. It could be oscillating noise with a frequency of
approx.~$1/(\SI2{\micro s}) = \SI{500}{kHz}$, since our filter would be very
good at picking that up, or sudden variations of the baseline.

We note that this behavior arises for the same Tile in different setups,
showing up both as an increased noise RMS and an higher threshold crossing
rate. We also note that the Proto0 data were collected after the LNGS data. As
for the absence of this behavior in the LNGS data collected at \SI{7}{VoV}, we
cannot formulate hypotheses as we do not know in what order the LNGS data at
\SI{6}{VoV} and \SI{7}{VoV} were collected, i.e., whether the tile was damaged
during the testing procedure.

We did not investigate further the discrepancy for Tile~53, since for all
the other Tiles the agreement between our model and data is consistent and
satisfactory.

We now want to estimate the minimum amount of data required for the procedure.
From \autoref{tab:fakerate} we see that the relative error on $k_2$ times the
square root of the time, $C \equiv
\operatorname{Std}[\bar{k_2}]\sqrt{T}/|k_2|$, is approximately \SI8{ns^{1/2}}
in all cases. The error should be proportional to $T^{-1/2}$, so to have an
\SI1\% error we need $T_{\SI1\%} = (100 C)^2 = \SI{0.7}{ms}$.

We conclude this chapter by summarizing all the steps we took to compute the
fake rate:
%
\begin{enumerate}

    \item Acquire at least \SI1{ms} of noise data.

    \item Filter the data (including baseline subtraction) producing a
    filtered waveform $\mathbf y$.

    \item Compute the standard deviation $\sigma$ and $k_2 =
    \operatorname{Cov}[y_i, y_{i+1} + y_{i-1} - 2y_i]$.

    \item Compute the fake rate for threshold $u$ using $r =
    f_s\sqrt{-k_2/(2\pi)}\operatorname{gauss}(u;0,\sigma)$ where $f_s$ is the
    sampling frequency.

\end{enumerate}
%
Alternatively, if one has a noise spectrum available but not the noise
waveform, it is possible to obtain the autocovariance by computing the discrete
Fourier transform of the power spectrum \cite[84]{ferrante2015} and then
normalizing it to be $\sigma^2$ in 0. Then $k_2$ is obtained by the covariance
at lag 1 $c$ with \eqref{eq:c2k2}. If the spectrum was obtained from the
discrete Fourier transform of a noise waveform, $c$ is the first coefficient
after the central one in the autocovariance.

The model was satisfactory in 24 of the 25 Tiles we considered. The uncertainty
in the low rate regime is \SI{\pm50}\% and the result is an overestimate with
probability \SI{90}\%. These statements are educated guesses based on
\autoref{tab:fakerate}.

\begin{table}

    \widecenter{%
    \begin{tabular}{
        c
        S[table-format=2]
        S[table-format=>1]
        S[table-format=3]
        S[table-format=2.1]
        S[table-format=+1.4]
        S[table-format=2.3]
        S[table-format=1.1]
        *2S[table-format=1.2]
    }
        \toprule
        \multicolumn3c{Data}
        &
        &
        &
        &
        &
        & \multicolumn2c{Rate @ $4\,\sigma$} \\
        \cmidrule(r){1-3} \cmidrule(l){9-10}

        Setup
        & {Tile}
        & {Overvoltage}
        & {$T$}
        & {$\sigma$}
        & {$k_2$}
        & {$\operatorname{Std}[\bar{k_2}]\sqrt T$}
        & {$f_s \sqrt{-k_2}/(2\pi\sigma)$}
        & {Theory}
        & {Data} \\

        &
        & {[\si{V}]}
        & {[\si{ms}]}
        & {[\si{u}]}
        & {[\si{u^2}]}
        & {[\si{u^2 ns^{1/2}}]}
        & {[\si{Mcps}]}
        & {[\si{kcps}]}
        & {[\si{kcps}]} \\
        \midrule

  LNGS & 15 &  0 & 138 &  1.6 & -0.0017 & 0.012 & 4.2 &  1.4 &  1.1 \\
  LNGS & 15 &  2 & 138 &  1.5 & -0.0017 & 0.012 & 4.3 &  1.4 &  1.2 \\
  LNGS & 15 &  4 & 138 &  1.5 & -0.0017 & 0.012 & 4.3 &  1.4 &  1.3 \\
  LNGS & 15 &  6 & 138 &  1.5 & -0.0017 & 0.012 & 4.4 &  1.5 &  1.1 \\
  LNGS & 15 &  8 & 138 &  1.5 & -0.0017 & 0.012 & 4.5 &  1.5 &  1.4 \\
  LNGS & 15 &  9 & 138 &  1.4 & -0.0017 & 0.012 & 4.6 &  1.5 &  1.3 \\  \midrule
  LNGS & 53 &  6 &  69 &  3.8 & -0.0044 & 0.030 & 2.7 & 0.92 &  2.6 \\
  LNGS & 53 &  7 &  69 &  2.1 & -0.0043 & 0.029 & 5.0 &  1.7 &  1.0 \\
  LNGS & 57 &  6 &  68 &  2.2 & -0.0043 & 0.031 & 4.8 &  1.6 &  1.2 \\
  LNGS & 59 &  6 &  69 &  2.2 & -0.0040 & 0.028 & 4.6 &  1.5 &  1.0 \\  \midrule
Proto0 & 29 & <0 & 499 &  8.3 &   -0.86 &   10. & 2.2 & 0.74 & 0.77 \\
Proto0 & 30 & <0 & 499 &  6.9 &   -0.75 &   6.0 & 2.5 & 0.84 & 0.67 \\
Proto0 & 31 & <0 & 499 &  7.7 &   -0.82 &   7.0 & 2.3 & 0.78 & 0.60 \\
Proto0 & 32 & <0 & 499 &  7.0 &   -0.76 &   6.6 & 2.5 & 0.83 & 0.67 \\
Proto0 & 34 & <0 & 499 &  6.5 &   -0.78 &   6.2 & 2.7 & 0.90 & 0.62 \\
Proto0 & 36 & <0 & 499 &  7.7 &   -0.84 &   7.1 & 2.4 & 0.79 & 0.63 \\
Proto0 & 37 & <0 & 499 &  6.5 &   -0.69 &   5.4 & 2.5 & 0.85 & 0.67 \\
Proto0 & 38 & <0 & 499 &  7.7 &   -0.84 &   7.1 & 2.4 & 0.80 & 0.59 \\
Proto0 & 39 & <0 & 499 &  7.6 &   -0.91 &   7.5 & 2.5 & 0.84 & 0.68 \\
Proto0 & 41 & <0 & 499 &  7.5 &   -0.87 &   7.1 & 2.5 & 0.83 & 0.71 \\
Proto0 & 42 & <0 & 499 &  7.0 &   -0.82 &   6.8 & 2.6 & 0.87 & 0.63 \\
Proto0 & 52 & <0 & 499 &  7.8 &   -0.82 &   6.5 & 2.3 & 0.77 & 0.61 \\
Proto0 & 53 & <0 & 499 & 10.1 &   -0.90 &   8.0 & 1.9 & 0.63 &  2.3 \\
Proto0 & 54 & <0 & 499 &  8.0 &   -0.89 &   7.4 & 2.4 & 0.79 & 0.59 \\
Proto0 & 55 & <0 & 499 &  8.0 &   -0.85 &   7.1 & 2.3 & 0.77 & 0.63 \\
Proto0 & 57 & <0 & 499 &  7.8 &   -0.88 &   7.4 & 2.4 & 0.80 & 0.69 \\
Proto0 & 58 & <0 & 499 &  7.6 &   -0.82 &   6.4 & 2.4 & 0.79 & 0.65 \\
Proto0 & 59 & <0 & 499 &  7.6 &   -0.79 &   6.6 & 2.3 & 0.77 & 0.55 \\
Proto0 & 60 & <0 & 499 &  7.5 &   -0.77 &   6.3 & 2.3 & 0.78 & 0.61 \\
Proto0 & 61 & <0 & 499 &  8.0 &   -0.89 &   7.4 & 2.4 & 0.79 & 0.60 \\
Proto0 & 62 & <0 & 499 &  7.6 &   -0.80 &   6.6 & 2.3 & 0.78 & 0.62 \\
Proto0 & 63 & <0 & 499 &  8.1 &   -0.86 &   7.1 & 2.3 & 0.76 & 0.61 \\
Proto0 & 64 & <0 & 499 &  7.9 &   -0.81 &   6.9 & 2.3 & 0.76 & 0.66 \\
Proto0 & 65 & <0 & 499 &  7.5 &   -0.80 &   6.4 & 2.4 & 0.80 & 0.62 \\
Proto0 & 66 & <0 & 499 &  8.2 &   -0.91 &   7.5 & 2.3 & 0.77 & 0.61 \\

        \bottomrule
    \end{tabular}}

    \tabcaption{fakerate}{The coefficients measured on the filtered waveforms
    needed to evaluate the formula for the threshold upcrossing rate. $T$ is
    the total duration, $\sigma$ the standard deviation, $k_2$ the covariance
    of the waveform with its second derivative (\autoref{eq:k2}),
    $\operatorname{Std}[\bar{k_2}]$ the uncertainty on the value of $k_2$
    determined as the standard deviation of the sample mean of $k_2$ values
    across events. The unit ``\si{u}'' is the ADC digit.}

\end{table}

\begin{figure}

    \widecenter{\includempl{figfakerate}}

    \figcaption{fakerate}{The threshold upcrossing rate both counting directly
    the crossings on data and computing it with formula~\eqref{eq:rcont}. The
    gray band marks the rate corresponding to a single crossing counted in the
    data. The thick gray curve is the rate predicted by
    \cite[98]{savarese2018}.}

\end{figure}

\begin{figure}

    \widecenter{\includempl{fighist2dtile53-0}}

    \widecenter{\includempl{fighist2dtile53-1}}

    \widecenter{\includempl{fighist2dtile53-2}}

    \figcaption{hist2dtile53}{Time-value histograms of Tile 53 noise in Proto0
    with a baseline acquisition, and in LNGS pre-trigger at overvoltage \SI6V
    and \SI7V.}

\end{figure}

\begin{figure}

    \widecenter{\includempl{fighist2dtile155759-0}}

    \widecenter{\includempl{fighist2dtile155759-1}}

    \widecenter{\includempl{fighist2dtile155759-2}}

    \figcaption{hist2dtile155759}{Time-value histograms of Tiles 15, 57 and 59
    noise in LNGS data.}

\end{figure}


% This is part of the TFTB Reference Manual.
% Copyright (C) 1996 CNRS (France) and Rice University (US).
% See the file refguide.tex for copying conditions.

\markright{tfrri}
\section*{\hspace*{-1.6cm} tfrri}

\vspace*{-.4cm}
\hspace*{-1.6cm}\rule[0in]{16.5cm}{.02cm}
\vspace*{.2cm}

{\bf \large \sf Purpose}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
Rihaczek time-frequency distribution.
\end{minipage}
\vspace*{.3cm}

{\bf \large \sf Synopsis}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
\begin{verbatim}
[tfr,t,f] = tfrri(x)
[tfr,t,f] = tfrri(x,t)
[tfr,t,f] = tfrri(x,t,N)
[tfr,t,f] = tfrri(x,t,N,trace)
\end{verbatim}
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf Description}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
        {\ty tfrri} computes the Rihaczek distribution of a discrete-time
        signal {\ty x}, or the cross Rihaczek representation between two
        signals. Its expression is
\[R_x(t,\nu)=x(t)\ X^*(\nu)\ e^{-j2\pi \nu t}.\]

\hspace*{-.5cm}\begin{tabular*}{14cm}{p{1.5cm} p{8cm} c}
Name & Description & Default value\\
\hline
        {\ty x}     & signal if auto-Ri, or {\ty [x1,x2]} if cross-Ri ({\ty
			Nx=length(x)}) \\
        {\ty t}     & time instant(s)           & {\ty (1:Nx)}\\
        {\ty N}     & number of frequency bins  & {\ty Nx}\\
        {\ty trace} & if nonzero, the progression of the algorithm is shown
                                          & {\ty 0}\\
     \hline {\ty tfr}   & time-frequency representation\\
        {\ty f}     & vector of normalized frequencies\\

\hline
\end{tabular*}
\vspace*{.2cm}

When called without output arguments, {\ty tfrri} applies {\ty tfrqview} on
 the real part of the distribution, which is equal to the Margenau-Hill
 distribution.
\end{minipage}
\vspace*{1cm}

{\bf \large \sf Example}
\begin{verbatim}
         sig=fmlin(128,0.1,0.4); tfrri(sig);
\end{verbatim}
\vspace*{.5cm}

{\bf \large \sf See Also}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
all the {\ty tfr*} functions.
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf Reference}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
[1] A. Rihaczek ``Signal Energy Distribution in Time and Frequency'', IEEE
Tans. on Info. Theory, Vol. 14, No. 3, pp. 369-374, 1968.
\end{minipage}


\documentclass[11pt]{article}

\newcommand{\REDUCE}{REDUCE}
\newcommand{\RLISP}{RLISP}
% \usepackage{reduce}

\title{\texttt{TRIGSIMP} \\
A \REDUCE{} Package for the Simplification and Factorization of
Trigonometric and Hyperbolic Expressions}

\author{Wolfram Koepf \\
	Andreas Bernig \\
	Herbert Melenk \\
	ZIB Berlin \\
	~ \\
	Revised by Francis Wright \\
	QMW London \\
	E-mail: \texttt{F.J.Wright@Maths.QMW.ac.uk}}

\date{17 January 1999}

\begin{document}
\maketitle

\section{Introduction}

The \REDUCE{} package TRIGSIMP is a useful tool for all kinds of
problems related to trigonometric and hyperbolic simplification and
factorization.  There are three operators included in TRIGSIMP:
trigsimp, trigfactorize and triggcd.  The first is for simplifying
trigonometric or hyperbolic expressions and has many options, the
second is for factorizing them and the third is for finding the
greatest common divisor of two trigonometric or hyperbolic
polynomials.  This package is automatically loaded when one of these
operators is used.

\section{Simplifying trigonometric expressions}

As there is no normal form for trigonometric and hyperbolic
expressions, the same function can convert in many different
directions, e.g.\ $\sin(2x) \leftrightarrow 2\sin(x)\cos(x)$.  The
user has the possibility to give several parameters to the operator
\texttt{trigsimp} in order to influence the transformations.  It is
possible to decide whether or not a rational expression involving
trigonometric and hyperbolic functions vanishes.

To simplify an expression \texttt{f}, one uses
\texttt{trigsimp(f[,options])}.  For example:
\begin{verbatim}
trigsimp(sin(x)^2+cos(x)^2);

1
\end{verbatim}
The possible options (where $^*$ denotes the default) are:
\begin{enumerate}
\item \texttt{sin}$^*$ or \texttt{cos};
\item \texttt{sinh}$^*$ or \texttt{cosh};
\item \texttt{expand}$^*$, \texttt{combine} or \texttt{compact};
\item \texttt{hyp}, \texttt{trig} or \texttt{expon};
\item \texttt{keepalltrig};
\item \texttt{tan} and/or \texttt{tanh};
\item target arguments of the form \textit{variable} /
\textit{positive integer}.
\end{enumerate}
From each of the first four groups one can use at most one option,
otherwise an error message will occur.  Options can be given in any
order.

The first group fixes the preference used while transforming a
trigonometric expression:
\begin{verbatim}
trigsimp(sin(x)^2);

      2
sin(x)

trigsimp(sin(x)^2, cos);

         2
 - cos(x)  + 1
\end{verbatim}
The second group is the equivalent for the hyperbolic functions.

The third group determines the type of transformation.  With the
default, \texttt{expand}, an expression is transformed to use only
simple variables as arguments:
\begin{verbatim}
trigsimp(sin(2x+y));

                                 2
2*cos(x)*cos(y)*sin(x) - 2*sin(x) *sin(y) + sin(y)
\end{verbatim}
With \texttt{combine}, products of trigonometric functions are
transformed to trig\-onometric functions involving sums of variables:
\begin{verbatim}
trigsimp(sin(x)*cos(y), combine);

 sin(x - y) + sin(x + y)
-------------------------
            2
\end{verbatim}
With \texttt{compact}, the \REDUCE{} operator \texttt{compact}
\cite{hearns} is applied to \texttt{f}.  This often leads to a simple
form, but in contrast to \texttt{expand} one does not get a normal
form. For example:
\begin{verbatim}
trigsimp((1-sin(x)^2)^20*(1-cos(x)^2)^20, compact);

      40       40
cos(x)  *sin(x)
\end{verbatim}

With an option from the fourth group, the input expression is
transformed to trigonometric, hyperbolic or exponential form
respectively:
\begin{verbatim}
trigsimp(sin(x), hyp);

 - sinh(i*x)*i

trigsimp(sinh(x), expon);

  2*x
 e    - 1
----------
      x
   2*e

trigsimp(e^x, trig);

cos(i*x) - sin(i*x)*i
\end{verbatim}

Usually, \texttt{tan}, \texttt{cot}, \texttt{sec}, \texttt{csc} are
expressed in terms of \texttt{sin} and \texttt{cos}.  It can sometimes
be useful to avoid this, which is handled by the option
\texttt{keepalltrig}:
\begin{verbatim}
trigsimp(tan(x+y), keepalltrig);

  - (tan(x) + tan(y))
----------------------
  tan(x)*tan(y) - 1
\end{verbatim}
Alternatively, the options \texttt{tan} and/or \texttt{tanh} can be
given to convert the output to the specified form as far as possible:
\begin{verbatim}
trigsimp(tan(x+y), tan);

  - (tan(x) + tan(y))
----------------------
  tan(x)*tan(y) - 1
\end{verbatim}
By default, the other functions used will be \texttt{cos} and/or
\texttt{cosh}, unless the other desired functions are also specified
in which case this choice will be respected.

The final possibility is to specify additional target arguments for
the trigonometric or hyperbolic functions, each of which should have
the form of a variable divided by a positive integer.  These
additional arguments are treated as if they had occurred within the
expression to be simplified, and their denominators are used in
determining the overall denominator to use for each variable in the
simplified form:
\begin{verbatim}
trigsimp(csc x - cot x + csc y - cot y, x/2, y/2, tan);

     x          y
tan(---) + tan(---)
     2          2
\end{verbatim}

It is possible to use the options of different groups simultaneously:
\begin{verbatim}
trigsimp(sin(x)^4, cos, combine);

 cos(4*x) - 4*cos(2*x) + 3
---------------------------
             8
\end{verbatim}

Sometimes, it is necessary to handle an expression in separate steps:
\begin{verbatim}
trigsimp((sinh(x)+cosh(x))^n+(cosh(x)-sinh(x))^n, expon);

  1   n    n*x
(----)  + e
   x
  e

trigsimp(ws, hyp);

2*cosh(n*x)

trigsimp((cosh(a*n)*sinh(a)*sinh(p)+cosh(a)*sinh(a*n)*sinh(p)+
    sinh(a - p)*sinh(a*n))/sinh(a));

cosh(a*n)*sinh(p) + cosh(p)*sinh(a*n)

trigsimp(ws, combine);

sinh(a*n + p)
\end{verbatim}

The \texttt{trigsimp} operator can be applied to equations, lists and
matrices (and compositions thereof) as well as scalar expressions, and
automatically maps itself recursively over such non-scalar data
structures:
\begin{verbatim}
trigsimp( { sin(2x) = cos(2x) } );

                            2
{2*cos(x)*sin(x)= - 2*sin(x)  + 1}
\end{verbatim}

\section{Factorizing trigonometric expressions}

With \texttt{trigfactorize(p,x)} one can factorize the trigonometric
or hyperbolic polynomial \texttt{p} in terms of trigonometric
functions of the argument \texttt{x}.  The output has the same format
as that from the standard \REDUCE{} operator \texttt{factorize}.  For
example:
\begin{verbatim}
trigfactorize(sin(x), x/2);

             x            x
{{2,1},{sin(---),1},{cos(---),1}}
             2            2
\end{verbatim}
If the polynomial is not coordinated or balanced \cite{art}, the
output will equal the input.  In this case, changing the value for
\texttt{x} can help to find a factorization, e.g.
\begin{verbatim}
trigfactorize(1+cos(x), x);

{{cos(x) + 1,1}}

trigfactorize(1+cos(x), x/2);

             x
{{2,1},{cos(---),2}}
             2
\end{verbatim}
The polynomial can consist of both trigonometric and hyperbolic functions:
\begin{verbatim}
trigfactorize(sin(2x)*sinh(2x), x);

{{4,1}, {sinh(x),1}, {cosh(x),1}, {sin(x),1}, {cos(x),1}}
\end{verbatim}

The \texttt{trigfactorize} operator respects the standard \REDUCE{}
\texttt{factorize} switch \texttt{nopowers} -- see the \REDUCE{}
manual for details.  Turning it on gives the behaviour that was
standard before \REDUCE~3.7:
\begin{verbatim}
on nopowers;

trigfactorize(1+cos(x), x/2);

        x        x
{2,cos(---),cos(---)}
        2        2
\end{verbatim}

\section{GCDs of trigonometric expressions}

The operator \texttt{triggcd} is essentially an application of the
algorithm behind \texttt{trigfactorize}.  With its help the user can
find the greatest common divisor of two trigonometric or hyperbolic
polynomials.  It uses the method described in \cite{art}.  The syntax
is \texttt{triggcd(p,q,x)}, where \texttt{p} and \texttt{q} are the
trigonometric polynomials and \texttt{x} is the argument to use.  For
example:
\begin{verbatim}
triggcd(sin(x), 1+cos(x), x/2);

     x
cos(---)
     2

triggcd(sin(x), 1+cos(x), x);

1
\end{verbatim}
The polynomials $p$ and $q$ can consist of both trigonometric and
hyperbolic functions:
\begin{verbatim}
triggcd(sin(2x)*sinh(2x), (1-cos(2x))*(1+cosh(2x)), x);

cosh(x)*sin(x)
\end{verbatim}

\section{Further Examples}

With the help of this package the user can create identities:
\begin{verbatim}
trigsimp(tan(x)*tan(y));

 sin(x)*sin(y)
---------------
 cos(x)*cos(y)

trigsimp(ws, combine);
\end{verbatim}

{\samepage\begin{verbatim}
 cos(x - y) - cos(x + y)
-------------------------
 cos(x - y) + cos(x + y)
\end{verbatim}}

\begin{verbatim}
trigsimp((sin(x-a)+sin(x+a))/(cos(x-a)+cos(x+a)));

 sin(x)
--------
 cos(x)

trigsimp(cosh(n*acosh(x))-cos(n*acos(x)), trig);

0

trigsimp(sec(a-b), keepalltrig);

  csc(a)*csc(b)*sec(a)*sec(b)
-------------------------------
 csc(a)*csc(b) + sec(a)*sec(b)

trigsimp(tan(a+b), keepalltrig);

  - (tan(a) + tan(b))
----------------------
  tan(a)*tan(b) - 1

trigsimp(ws, keepalltrig, combine);

tan(a + b)
\end{verbatim}

Some difficult expressions can be simplified:
\begin{verbatim}
df(sqrt(1+cos(x)), x, 4);

            5           4            3       2            3
( - 4*cos(x)  - 4*cos(x)  - 20*cos(x) *sin(x)  + 12*cos(x)

             2       2            2                   4
  - 24*cos(x) *sin(x)  + 20*cos(x)  - 15*cos(x)*sin(x)

                    2                       4            2
  + 12*cos(x)*sin(x)  + 8*cos(x) - 15*sin(x)  + 16*sin(x) )/

(16*sqrt(cos(x) + 1)

         4           3           2
 *(cos(x)  + 4*cos(x)  + 6*cos(x)  + 4*cos(x) + 1))

on rationalize;
trigsimp(ws);

 sqrt(cos(x) + 1)
------------------
        16

off rationalize;
load_package taylor;

taylor(sin(x+a)*cos(x+b), x, 0, 4);

cos(b)*sin(a) + (cos(a)*cos(b) - sin(a)*sin(b))*x

                                    2
 - (cos(a)*sin(b) + cos(b)*sin(a))*x

    2*( - cos(a)*cos(b) + sin(a)*sin(b))   3
 + --------------------------------------*x
                     3

    cos(a)*sin(b) + cos(b)*sin(a)   4      5
 + -------------------------------*x  + O(x )
                  3

trigsimp(ws, combine);

 sin(a - b) + sin(a + b)                               2
------------------------- + cos(a + b)*x - sin(a + b)*x
            2

    2*cos(a + b)   3    sin(a + b)   4      5
 - --------------*x  + ------------*x  + O(x )
         3                  3
\end{verbatim}

Certain integrals whose evaluation was not possible in \REDUCE{}
(without preprocessing) are now computable:
\begin{verbatim}
int(trigsimp(sin(x+y)*cos(x-y)*tan(x)), x);

       2
(cos(x) *x - cos(x)*sin(x) - 2*cos(y)*log(cos(x))*sin(y)

          2
  + sin(x) *x)/2

int(trigsimp(sin(x+y)*cos(x-y)/tan(x)), x);

                                   x  2
(cos(x)*sin(x) - 2*cos(y)*log(tan(---)  + 1)*sin(y)
                                   2

                      x
  + 2*cos(y)*log(tan(---))*sin(y) + x)/2
                      2
\end{verbatim}
Without the package, the integration fails, and in the second case one
does not receive an answer for many hours.

\begin{verbatim}
trigfactorize(sin(2x)*cos(y)^2, y/2);

{{2*cos(x)*sin(x),1},

       y          y
 {cos(---) - sin(---),2},
       2          2

       y          y
 {cos(---) + sin(---),2}}
       2          2
\end{verbatim}
\begin{verbatim}
trigfactorize(sin(y)^4-x^2, y);

        2               2
{{sin(y)  + x,1},{sin(y)  - x,1}}

trigfactorize(sin(x)*sinh(x), x/2);

{{4,1},

        x
 {sinh(---),1},
        2

        x
 {cosh(---),1},
        2

       x
 {sin(---),1},
       2

       x
 {cos(---),1}}
       2

triggcd(-5+cos(2x)-6sin(x), -7+cos(2x)-8sin(x), x/2);

       x        x
2*cos(---)*sin(---) + 1
       2        2

triggcd(1-2cosh(x)+cosh(2x), 1+2cosh(x)+cosh(2x), x/2);

        x  2
2*sinh(---)  + 1
        2
\end{verbatim}

\begin{thebibliography}{99}

\bibitem{art}
Roach, Kelly: Difficulties with Trigonometrics. Notes of a talk.

\bibitem{hearns}
Hearn, A.C.: COMPACT User Manual.

\end{thebibliography}
\end{document}


\section{Multigrid Methods } %Jonathan / b-j8522 / Jul 20

\subsection{Dual spaces}
{\bf Definition:} Given a vector space $V$, the dual space
$$V^\prime = \{\varphi: V \to \mathbb{R}: \varphi\textrm{ is a linear map}\}$$
Here $V^\prime$ itself is  also a vector space. It's easy to verify $(\varphi_1+\varphi_2): V\to \mathbb{R}$. (Because $(\varphi_1+\varphi_2)(v)=\varphi_1(v)+\varphi_2(v)$).

Let $v_1,\ldots,v_n \in V$ be a basis, define functions $\varphi_i: V\to\mathbb{R}$ by
\begin{equation}
\varphi_i (v_j) = \delta_{ij} := \left\{
	\begin{array}{cc}
	1, & i=j \\
	0, & i\ne j
	\end{array} \right.
\end{equation}

Exercise: show that $\varphi_1, \ldots, \varphi_n$ is a basis of $V^\prime$.

Let's give some properties of the dual space here.
Suppose $f: V \to W$ is a linear map. Let $W^\prime$ be the dual space of $W$, defined by
\begin{equation}
W^\prime = \{ \psi: W\to \mathbb{R},\ \textrm{s.t.}\ W\ \textrm{is linear} \}.
\end{equation}
So $\psi \circ f: V\to \mathbb{R}$ is linear, which means $\psi \circ f \in V^\prime$.
Composition with $f$ gives a map from $W^\prime$ to $V^\prime$. %, called $f^\top$

Furthermore, suppose $W\subset V$ is a subspace, a $\varphi \in V^\prime$ is a function from $V$ to $\mathbb{R}$, and is also a function from $W$ to $\mathbb{R}$.

\subsection{Multigrid methods}
Consider to solving a linear system as follows
\begin{equation}\label{eq:linearsys}
A u = \varphi
\end{equation}
where $\varphi\in V^{\prime}$, we are looking for $u\in V$, and  $A: V\to V^{\prime}$ is a linear map. Here $V^{\prime}$ is the dual space of $V$.

Now, we consider a method to solving the linear system \eqref{eq:linearsys}. Notice that $V$ is a very high dimensional, so the system is very difficult to solve. So we consider if we can approximate this equation by some lower dimensional system.

Consider a subspace $W\subset V$, then we can consider the system
\begin{equation}\label{eq:sublinearsys}
Aw = \psi
\end{equation}
where $w\in W$ and $\psi$ equals to $\varphi$ restricted to $W$. Basically, there is a restriction/projection operation $V^\prime \to W^\prime$.%Usually the restriction is natural, so we use same notation here.
Now, we can choose some subspace $W$, and solve system \eqref{eq:sublinearsys} to get the approximation of the solution.

\subsubsection{Abstract Algorithm}
Consider a sequence of subspaces $W_1, W_2, \ldots, W_n \subset V$.
\begin{itemize}
\item Pick $v_0\in V$, consider residual equation
\begin{equation}
Av = r_0 = \varphi - A v_0
\end{equation}
\item Restrict $Av=r_0 $ to $W_1$.
\item Solve it on $W_1$ and add the solution to $v_0$ to get $v_1$.
\end{itemize}

\subsubsection{Example}
We give an 1-d example here. Consider a 1-D problem.
\begin{equation}
\begin{split}
 -\frac{\textrm{d}^2}{\textrm{d} x^2} u &= f  \label{eq:1dProb}\\
 u(0)&=u(1)=0
\end{split}
\end{equation}
Here we try to find a function defined on $[0,1]$. The function values of endpoints are $0$, and the second derivative is given.

The First thing we need to do is to formulate $A: V\to V^\prime$.
Choose a smooth function $g(x)$.
Integrate both sides of \eqref{eq:1dProb} against $g$ (view both sides in dual space).
\begin{equation}\label{eq:1dProbInt}
\begin{split}
   &\int_0^1 \left( -\frac{\textrm{d}^2}{\textrm{d} x^2} u(x) \right) \cdot g(x) \textrm{d}x = \int_0^1 f(x)  g(x) \textrm{d}x
 \end{split}
\end{equation}
Using integration by part, the left hand side of \eqref{eq:1dProbInt} equals
\begin{equation}
\begin{split}
 \int_0^1 \left( \frac{\textrm{d}}{\textrm{d} x} u \right) \left( \frac{\textrm{d}}{\textrm{d} x} g \right) \textrm{d}x
\end{split}
\end{equation}
It gives
\begin{equation}
 \int_0^1 \left( \frac{\textrm{d}}{\textrm{d} x} u \right) \left( \frac{\textrm{d}}{\textrm{d} x} g \right) \textrm{d}x = \int_0^1 f g \textrm{d}x  \quad \forall g
\end{equation}
But the above still can not be solve, because it is infinite dimensional.
So we apply the restriction mentioned before from it to a finite dimensional subspace.

\subsubsection{Restrict to a finite dimensional subspace}

Divide $[0,1]$ to $n$ pieces, $0=x_0<x_1<\ldots<x_n=1$.
Let $$V = \left\{\ \textrm{Piecewise linear functions which are linear on}\ (x_i,x_{i+1}]\ \right\}.$$ And this is the simplest finite element space.
We need to restrict $u$ and $g$ to space $V$.

Now we need bases of vector spaces $V$ and $V^\prime$ which are dual. Let's talk first about the basis in $V^\prime$. A good choice of the basis for the dual space $V^\prime$, functions from $V$ to real numbers. Consider functions in $V$. We have $n+1$ different grid points, and the function is uniquely determined by its values at all these grid points. Take a particular point $x_i$, and evaluating in $x_i$.
\begin{equation}
\begin{split}
\varphi_{i} (v) = v(x_i)\quad \textrm{and}\quad
\varphi_{i} \in V^\prime
\end{split}
\end{equation}
So evaluation at one of these grid points is a dual vector. And particular because the function is uniquely determined by values on these grid points, this actually is the dual basis.d
Now we obtain the dual basis. That $\{ \varphi_1, \varphi_2, \ldots, \varphi_n\}$ is a basis of $V^\prime$.
Then consider functions in $V$ with the property that $v\in V$ such that
\begin{equation}
\varphi_i (v_j) = \left\{
	\begin{array}{cc}
	1, & i=j \\
	0, & i\ne j
	\end{array} \right.
\end{equation}
So we get the `hat' function $v_i$ that is a piecewise linear function. and $v_i$ equals one on the grid $x_i$ and zero on the others. Then we have $\{ v_1, v_2, \ldots, v_n \}$ is the dual basis of $V$.
In order to turn \eqref{eq:1dProbInt} into an equation like \eqref{eq:1dProb}. We want to represent $u$ and $g$as a simple linear combination of $\{ v_1, v_2, \ldots, v_n \}$:
\begin{equation}
u = \sum_{i=1}^n a_i v_i
\end{equation}
And the right hand side of \eqref{eq:1dProbInt} should be a dual vector and equal to
\begin{equation}
\sum_{i=1}^n b_i \varphi_i,
\end{equation}
that is
\begin{equation}
b_i = \int_0^1 f v_i {\rm d}x.
\end{equation}
And we also need to figure out what $\int_0^1 \left( \frac{\textrm{d}}{\textrm{d} x} v_i \right) \left( \frac{\textrm{d}}{\textrm{d} x} v_j \right) \textrm{d}x$ is. Notice that $v_i$ is the `hat' function. Then, it gives
\begin{equation}
\left(
	\begin{array}{ccccc}
	\frac{2}{h} & -\frac{1}{h} & 0 &\cdots &0\\
	-\frac{1}{h} & \frac{2}{h} & 0 &\cdots &0 \\
	\vdots & \ddots  & \ddots & \ddots &\vdots \\
	0 & 0 & \cdots &-\frac{1}{h} & \frac{2}{h}
	\end{array} \right)
\left(
	\begin{array}{c}
	a_1\\ a_2 \\
	\vdots \\ a_n
	\end{array} \right)
=
\left(
	\begin{array}{c}
	b_1\\ b_2 \\
	\vdots \\ b_n
	\end{array} \right)
\end{equation}
where $h = \frac{1}{n}$ is the length of each segmentation.
So far, we take the integral equation \eqref{eq:1dProbInt} in the infinite dimensional vector space, and restrict it to a finite dimensional vector space. This is what people do to solve differential equations.

Now consider the multigrid method. We start with the equation in the finite dimensional subspace $V$, then we restrict it to a coarse space (a smaller subspace of $V$).

In this particular problem, let $W\subset V$ be the subspace of functions which are linear in $[x_{2n}, x_{2n+2}]$. Notice that we get coarse grids $0=w_0 <w_1< \ldots <w_{\frac{n}{2}}$. As before, we can construct two bases, like $\{\varphi_i\}$ and $\{v_i\}$. A basis of $W^\prime$
\begin{equation}
\{ \psi_1^\prime, \psi_2^\prime, \ldots, \psi_{\frac{n}{2}}^\prime\}
\end{equation}
and and the dual basis of $W$
\begin{equation}
\{ w_1^\prime, w_2^\prime, \ldots, w_{\frac{n}{2}}^\prime\}.
\end{equation}
And $w_i$ is also a `hat' function which is piecewise linear and equal to one at grid $x_{2i}$ and zero at the others $x_{2j}$ with $j=0,1,\ldots,i-1,i+1,\ldots, \frac{n}{2}$.
Now, we want to do the same restriction, as we done before, from $V$ to $W$.
Consider the right hand side
\begin{equation}
\sum_{i=1}^{n} b_i \varphi_i \in V^\prime
\end{equation}
So
\begin{equation}
\sum_{i=1}^{n} b_i \varphi_i (w_j) = \frac{1}{2} b_{2j-1} + b_{2j} +\frac{1}{2} b_{2j+1}
\end{equation}
Then we get
\begin{equation}
\left(
	\begin{array}{c}
	b_1\\ b_2 \\ b_3 \\b_4 \\
	\vdots \\ b_{n-1} \\b_n
	\end{array} \right)
\to
\left(
	\begin{array}{c}
	- \\
	b^\prime_1\\
	- \\
	 b_2^\prime \\
	\vdots \\- \\ b^\prime_n
	\end{array} \right)
\end{equation}
And the value of $b_i^\prime = \frac{1}{2} b_{2i-1} + b_{2i} + \frac{1}{2} b_{2i+1}$. That how we get the right hand side of a small system from a large system. Notice this can be regard as the convolution with stride two. And the other thing is please to figure out, given a linear combination of the basis $\{w_1,\ldots, w_{\frac{n}{2}}\}$, how to get the coefficients of this linear combination w.r.t. the basis $\{v_1,\ldots, v_{\frac{n}{2}}\}$. That is the map from the small subspace $W$ to the large space $V$.


%%==============================================
%% Section 3.01: Analytic Extension to the Strip
%%==============================================

\documentclass[../dissertation.tex]{subfiles}

\begin{document}
\section{Analytic Extension to the Strip}\label{sec3:Analyticity}

%%
%% The following was taken directly (with a modification of the notation)
%% from from Prof. Perry's section of the kpw1.tex file
%%
% We wish to show that $M_1^+$ is the lower boundary value of a function analytic in the
% strip $\{ z \in \CC ~:~ 0 < \im z < 2\}$ which satisfies the spectral problem
% \eqref{eq0:SpecProb}. For the moment we fix $\lambda$ and supress the $\lambda$ dependence of
% $M_1$ and $G_L$ for brevity. As a candidate for the analytic continuation we consider the
% function ($z=x+iy$)
% \begin{equation}
% 	\label{eq2:ILW.M.ac}
% 	M_1(z) = 1 + \int_{-\infty}^\infty G_L(x-x'+iy) u(x') M_1(x') \, \mathrm{d}x'.
% \end{equation}
% for $0<y<2$.
A natural candidate for the analytic extension of $G_\star$ to the open strip
$\mathcal S_1 = \{ z \in \mathbb C ~:~ 0 < \im z < 2\}$ is
\begin{equation}
	\label{eq3:ILW.GFz}
	G_\star(x+iy)
		:= \frac{1}{2\pi}
			\int_{\Gamma_\star} e^{ix\xi}
				\frac{e^{-y\xi}}{\xi - \zeta\left(1-e^{-2\xi}\right)}
			\, \mathrm{d}\xi,
		\qquad (\star = L \text{, or } R)
\end{equation}
which is a convergent integral for $0<y<2$ owing to the new factor $e^{-y\xi}$.
A straightforward argument with the dominated convergence theorem shows that
$G_\star(z)$ is continuous on the open strip $\mathcal S_1$. It then follows from
Morera's theorem and \eqref{eq3:ILW.GFz} that $G_\star(z)$ is analytic in $z$.

Next we consider convolution of $G_\star(\dotarg+iy)$ with $L^1$ functions. Since the integral
\eqref{eq3:ILW.GFz} is absolutely convergent for $y$ in compact subintervals of $(0,2)$, it
follows that for any $f \in L^1(\RR)$, $G_\star(\dotarg+iy)* f$  obeys the uniform
in $\lambda$ bound
\[
	\left\|G_\star(\dotarg+iy; \lambda)* f\right\|_{\inn{\dotarg}L^\infty}
		\lesssim_{\, y} \left\|f\right\|_{L^1}
\]
where the implied constant has the same uniformity. Another application of Morera's
theorem shows that, for any $f \in C_0^\infty(\RR)$, the convolution $G_\star(\dotarg+iy)*f$
defines an analytic function of $z$ in $\mathcal S_1$. Finally let
$f \in L^1(\mathbb R) \cap L^p(\mathbb R)$ for some
$p \in (1,2]$, and let $\{ f_n \}_{n \in \NN}$ be a sequence from $C_0^\infty(\mathbb R)$
converging to $f$ in $L^1 \cap L^p$. Then $\left(G_\star(\dotarg+iy)*f_n\right)(x)$ converges
uniformly to $\left(G_\star(\dotarg+iy)*f\right)(x)$ on compact subsets of $\mathcal S_1$,
so $G_\star(\dotarg+iy)*f$ is also analytic in $\mathcal S_1$.
% This shows that $M(z)$ as defined by \eqref{eq2:ILW.M.ac} defines an
% analytic function on $S$.

It remains to show that $G_\star$ as a convolution operator has an upper boundary
value $G_\star^-$ and to obtain an effective formula for $G_\star^-$. Using the
``boxcar'' contour in Figure \ref{fig1:GammaContour} again we can compute
\begin{subequations}
	\label{eq3:ILW.GFz.rep}
	\begin{align}
		\label{eq3:ILW.GLz.rep}
		G_L(x+ iy; \lambda)
			&=
				K(x+iy; \lambda)
				+ i \big[
						\alpha(\lambda) + \beta(\lambda) e^{i\lambda x}e^{-\lambda y}
					\big] \chi_L(x) \\
			&=
				K(x+iy; \lambda) + \mathpzc R_L(x+iy; \lambda)
				\nonumber \\
		G_R(x+ iy; \lambda)
			&=
				K(x+iy; \lambda)
				- i \big[
						\alpha(\lambda) + \beta(\lambda) e^{i\lambda x}e^{-\lambda y}
					\big] \chi_R(x) \\
			&=
				K(x+iy; \lambda) - \mathpzc R_R(x+iy; \lambda)
				\nonumber
	% G_L(x+iy; \lambda) =
	% 	\begin{cases}
	% 		-K(x+iy; \lambda),
	% 			&	x<0 \\
	% 		i \left(
	% 			\alpha(\lambda) + \beta(\lambda) e^{i\lam x}e^{-y\lam}
	% 		\right)
	% 		- K(x+iy; \lambda),
	% 			& x>0	\\
	% 	\end{cases}
\end{align}
\end{subequations}
Here
\begin{equation}
	\label{eq3:ILW.K.z}
	K(x + iy; \lambda)
				:= \frac{e^{-\pi|x|} \exp\big(- i \pi y \sign(x)  \big)}{2\pi}
					\int_{\mathbb R} e^{i x \xi}
						\frac{e^{-y\xi}}{p(\xi; \lambda) + i \pi \sign(x)}
					\, \mathrm{d}\xi
\end{equation}
is defined by a convergent integral for $y \in (0,2)$, so that $K(x+iy)$ is actually
a bounded continuous function. We can now study boundary values for the convolution of
$G_L(\dotarg+iy)$ with a function on the line as $y \nearrow 2$.  Note that
\[
	K(x + iy; \lambda)
		= \frac{1}{2 \pi} \int\limits_{\Sigma_{\sign(x)}} \frac{e^{i(x + iy) \xi}}{p(\xi)} \, \mathrm{d}\xi,
\]
where $\Sigma_{\sign(x)}$ is the contour defined at the beginning of Subsection \ref{sec1:AsympK},
as
\[
	i(x + iy)\big(\xi + i \pi \sign(x) \big)
		= \big( i x \xi - y \xi\big)
			+ \big( -\pi x \sign(x) - i \pi y \sign(x) \big).
\]

%%
%% End verbatum stealing from Prof. Perry's notes.
%% Begin partial thievery of Prof. Perry's notes.
In our analysis of this limit, we first claim that for any $f \in L^1 \cap L^p$
($1 < p \leq 2$), we can rewrite the convolutions $G_\star*f$ as
\begin{subequations}
	\label{eq3:ILW.(GFz*f)}
	\begin{align}
		\label{eq3:ILW.(GLz*f)}
		\big(G_L(\dotarg + iy)*f\big)(x)
			&= i\alpha(\lambda) \int_{-\infty}^x f(x') \, \mathrm{d}x' \\
		    &\quad + i\beta(\lambda) \, e^{i\lam x}e^{-\lam y}
		    		\int_{-\infty}^x e^{-i\lam x'} f(x')\, \mathrm{d}x'
		    	\nonumber \\
		    &\quad +\int_{\mathbb R} \mathfrak C(x-x',y) f(x') \, \mathrm{d}x'
				\nonumber \\
			&\quad + \frac{e^{-i \pi y}}{2 \pi i}
				\int_{-\infty}^x e^{-\pi|x-x'|} \frac{1}{(x-x') - i(2-y)} f(x') \, \mathrm{d}x'
				\nonumber  \\
			&\quad + \frac{e^{i \pi y}}{2 \pi i}
				\int_x^{\infty} e^{-\pi|x-x'|} \frac{1}{(x-x') - i(2-y)} f(x') \, \mathrm{d}x'
				\nonumber \\[0.5\baselineskip]
		\label{eq3:ILW.(GLz*f)}
		\big(G_R(\dotarg + iy)*f\big)(x)
			&= i\alpha(\lambda) \int_{-\infty}^x f(x') \, \mathrm{d}x' \\
		    &\quad + i\beta(\lambda) \, e^{i\lam x}e^{-\lam y}
		    		\int_{-\infty}^x e^{-i\lam x'} f(x')\, \mathrm{d}x'
		    	\nonumber \\
		    &\quad +\int_{\mathbb R} \mathfrak C(x-x',y) f(x') \, \mathrm{d}x'
				\nonumber \\
			&\quad + \frac{e^{-i \pi y}}{2 \pi i}
				\int_{-\infty}^x e^{-\pi|x-x'|} \frac{1}{(x-x') - i(2-y)} f(x') \, \mathrm{d}x'
				\nonumber  \\
			&\quad + \frac{e^{i \pi y}}{2 \pi i}
				\int_x^{\infty} e^{-\pi|x-x'|} \frac{1}{(x-x') - i(2-y)} f(x') \, \mathrm{d}x'
				\nonumber
	\end{align}
\end{subequations}
where $\mathfrak C$ is as defined in equations \eqref{eq3:GFcont} and \eqref{eq0:smallR} above.
Indeed, one can see directly from \eqref{eq3:ILW.GFz.rep}
\begin{align*}
	\big(G_L(\dotarg + iy)*f\big)(x)
		&= \big(K(\dotarg + iy) * f\big)(x) + \mathpzc R_L(\dotarg + iy) * f \\
	\big(G_R(\dotarg + iy)*f\big)(x)
		&= \big(K(\dotarg + iy) * f\big)(x) + \mathpzc R_R(\dotarg + iy) * f.
\end{align*}
Further, since
\begin{align*}
	\big(K(\dotarg + iy) * f\big)(x)
		&=
			\frac{e^{-i \pi y}}{2 \pi i}
				\int_{-\infty}^x
					\left(
						e^{-\pi |x - x'|}
						\int_{\mathbb R}
							e^{ix\xi} \frac{e^{-y\xi}}{p(\xi;\lambda) + i\pi}
						\, \mathrm{d}\xi
					\right)
				f(x')
				\, \mathrm{d}x' \\
		&\quad+
			\frac{e^{i \pi y}}{2 \pi i}
				\int_x^{\infty}
					\left(
						e^{-\pi |x - x'|}
						\int_{\mathbb R}
							e^{ix\xi} \frac{e^{-y\xi}}{p(\xi;\lambda) - i\pi}
						\, \mathrm{d}\xi
					\right)
				f(x')
				\, \mathrm{d}x' \\
\end{align*}
the identity
\begin{align}\label{eq3:RanId}
	\frac{e^{-y \xi}}{p(\xi , \lambda) \pm i \pi}
		= \frac{1}{\zeta(\lambda)} e^{(2-y)\xi} \chi_{\mathbb R^-}(\xi)
			+ \rho \big(\xi, y, \pm 1; \lambda\big),
\end{align}
where $\chi_{\mathbb R^-}$ denotes the characteristic function of $(-\infty, 0)$, along with the
Fourier identity
\[
	\int_{\mathbb R}
		e^{i x \xi} \frac{1}{\zeta(\lambda)} e^{(2-y)\xi} \chi_{\mathbb R^-}(\xi)
	\, \mathrm{d}\xi
	=
		\frac{1}{ix + (2-y)}
\]
imply equations \eqref{eq3:ILW.(GFz*f)} hold.

To verify identity \eqref{eq3:RanId} note that
\begin{align*}
	\zeta
		&= \big(-\zeta + \zeta \, e^{-2\xi} + \zeta) e^{2\xi} \\
		&=
			\big[
				\xi - \zeta\big(1-e^{-2\xi}\big)
				\pm i \pi - \xi \mp i \pi
			\big]
			e^{2\xi},
\end{align*}
which implies
\begin{align*}
	&\frac{1}{\zeta} e^{(2-y)\xi}
			+ \frac{1}{\zeta}
				\frac{
					\big(\zeta - \xi \mp i\pi\big)e^{(2-y)\xi}
				}
				{\xi-\zeta(1-e^{2\xi}) \pm i \pi}  \\
	&\qquad=
		\frac{1}{\zeta}
		\Big\{
			\big[
				\xi - \zeta\big(1-e^{-2\xi}\big)
				\pm i \pi - \xi \mp i \pi
			\big]
			e^{2\xi}
		\Big\}
		\frac{e^{-y\xi}}{p(\xi; \lambda) \pm i \pi} \\
	&\qquad= \frac{e^{-y\xi}}{p(\xi; \lambda) \pm i \pi},
\end{align*}
as claimed.

By introducing the notation\label{sym:almostExpCauchy}
\begin{align*}
	\left( \mathcal E_\varepsilon f \right)(x)
		&:=  \frac{e^{-i \pi (2-\varepsilon)}}{2 \pi i}
			\int_{-\infty}^x
				\frac{e^{-\pi|x-x'|}}{(x-x') - i\varepsilon} f(x')
			\, \mathrm{d}x' \\
		&\quad + \frac{e^{i \pi (2-\varepsilon)}}{2 \pi i}
			\int_x^{\infty}
				\frac{e^{-\pi|x-x'|} }{(x-x') - i\varepsilon} f(x')
			\, \mathrm{d}x',
\end{align*}
equation \eqref{eq3:ILW.(GFz*f)} can be rewritten more simply as
\begin{subequations}
	\label{eq3:ILW.(Gz*f).simp}
	\begin{align}
		\label{eq3:ILW.(GLz*f).simp}
		\big(G_L(\dotarg + iy)*f\big)(x)
			&= \big[\mathfrak C(\dotarg, y) + \mathpzc R_L(\dotarg+iy)\big] * f(x)
				+ \mathcal E_{(2-y)} f(x)
			\\
		\label{eq3:ILW.(GRz*f).simp}
		\big(G_R(\dotarg + iy)*f\big)(x)
			&= \big[\mathfrak C(\dotarg, y) - \mathpzc R_R(\dotarg+iy) \big] * f(x)
				+ \mathcal E_{(2-y)} f(x)
	\end{align}
\end{subequations}
Since the integrands of the residue terms
\begin{align*}
	\mathpzc R_L(\dotarg+iy)*f(x)
		&= i\alpha \int_{-\infty}^x f(x') \, \mathrm{d}x'
		       + i\beta(\lambda) \, e^{\lambda(ix - y)}
		    		\int_{-\infty}^x e^{-i\lam x'} f(x')\, \mathrm{d}x' \\
	\mathpzc R_R(\dotarg+iy)*f(x)
		&=  i\alpha \int_{-\infty}^x f(x') \, \mathrm{d}x'
		       + i\beta(\lambda) \, e^{\lambda(ix - y)}
		    		\int_x^{\infty} e^{-i\lam x'} f(x')\, \mathrm{d}x'
\end{align*}
in \eqref{eq3:ILW.(Gz*f).simp} do not involve $y$, they are certainly well behaved
under the limit $y \nearrow 2$. Further, the purpose of decomposing the convolution
operator $G_L$ as shown in \eqref{eq3:ILW.(Gz*f).simp} is to isolate the singularity that
results under the limit $y \nearrow 2$. Indeed, a cursory inspection of the
convolution operator $\mathfrak C$ leads one to believe that it is well behaved under
this limit, which
is something we discuss further in Section \ref{sec3:ContPart}.

The $\mathcal E_{(2-y)} f(x)$ terms in \eqref{eq3:ILW.(Gz*f).simp} captures the singular
portion of $K$ under the $y\nearrow 2$ limit. Understanding the behavior of these terms
under this limit involves much more delicate analysis and is the subject of Sections
\ref{sec3:CauchyTrans} and \ref{sec3:BndE}.

\begin{rmk}
	That $\mathpzc R_\star$ grows linearly for $\lambda = 0$ is the single reason
	why we can only guarantee the limit \eqref{eq3:lim} converges as an $L^p$ limit
	for functions with sufficient decay (\textit{i.e.} $L^{p,1}$) and not for all
	$L^p$ functions when $\lambda = 0$.
\end{rmk}

\end{document}


\documentclass[12pt]{cdblatex}
\usepackage{exercises}
\usepackage{fancyhdr}
\usepackage{footer}

\begin{document}

% --------------------------------------------------------------------------------------------
\section*{Exercise 3.2 Riemann tensor from commutation of $\nabla$}

\begin{cadabra}
   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u#}::Indices(position=independent).

   \nabla{#}::Derivative.
   \partial{#}::PartialDerivative.

   \Gamma^{a}_{b c}::TableauSymmetry(shape={2}, indices={1,2});

   # rules for the first two covariant derivs of V^a

   deriv1 := \nabla_{a}{V^{b}} -> \partial_{a}{V^{b}}
                                + \Gamma^{b}_{d a} V^{d}.          # cdb (ex-0302.101,deriv1)

   deriv2 := \nabla_{a}{\nabla_{b}{V^{c}}} -> \partial_{a}{\nabla_{b}{V^{c}}}
                                            + \Gamma^{c}_{d a} \nabla_{b}{V^{d}}
                                            - \Gamma^{d}_{b a} \nabla_{d}{V^{c}}.
                                                                   # cdb (ex-0302.102,deriv2)

   Vabc :=   \nabla_{c}{\nabla_{b}{V^{a}}}
           - \nabla_{b}{\nabla_{c}{V^{a}}}.                        # cdb (ex-0302.103, Vabc)

   substitute (Vabc,deriv2)                                        # cdb (ex-0302.104, Vabc)
   substitute (Vabc,deriv1)                                        # cdb (ex-0302.105, Vabc)

   distribute     (Vabc)                                           # cdb (ex-0302.106, Vabc)
   product_rule   (Vabc)                                           # cdb (ex-0302.107, Vabc)

   sort_product   (Vabc)                                           # cdb (ex-0302.108, Vabc)
   rename_dummies (Vabc)                                           # cdb (ex-0302.109, Vabc)
   canonicalise   (Vabc)                                           # cdb (ex-0302.110, Vabc)
   factor_out     (Vabc,$V^{a?}$)                                  # cdb (ex-0302.111, Vabc)
\end{cadabra}

\begin{dgroup*}[spread={3pt}]
   \Dmath*{\cdb{ex-0302.103} = \Cdb*[\hskip2.0cm\hfill]{ex-0302.104}
                             = \Cdb*[\hskip2.0cm\hfill]{ex-0302.105}
                             = \Cdb*[\hskip2.0cm\hfill]{ex-0302.106}
                             = \Cdb*[\hskip2.0cm\hfill]{ex-0302.107}
                             = \Cdb*[\hskip2.0cm\hfill]{ex-0302.108}
                             = \Cdb*[\hskip2.0cm\hfill]{ex-0302.109}
                             = \Cdb*{ex-0302.110}
                             = \Cdb*{ex-0302.111}
                             = - R^{a}{}_{dbc} V^d}
\end{dgroup*}

This result agrees with Misner, Thorne and Wheeler. pg. 266.
\end{document}


\subsection{Loops, multiple edges and simple graphs}

\subsubsection{Loops}

A loop is an edge where both the vertices are the same.

\subsubsection{Multiple edges}

If there are two edges with the same pair of indices, there are multiple edges.

\subsubsection{Simple graphs}

No loops or multiple edges.


\section{Bonus lectures}
We have $n$ bins $1,2,\ldots,n$ and $n$ indistinguishable balls.
For every ball, we pick a bin uniformly randomly and place it independently of other balls.
Let $X_i$ be the number of balls in bin $i$.
Define the maximum load to be $M_n=\max_{i\le n}X_i$.
Now for every $i$, $X_i\sim\operatorname{Bin}(n,1/n)$.
We first want to find heuristically the value of $\mathbb P(M_n\ge x)$.
Note that we have $\mathbb P(M_n\ge x)\le n\mathbb P(X_1\ge x)$.
This is quite strict but works in this case.
Now for large $n$, we approximate $X_1$ by $\operatorname{Pois}(1)$, so we can estimate (by something proved in example sheet) by $\mathbb P(\operatorname{Pois}(\lambda)\ge x)\le\exp(-x\log(x/\lambda)-\lambda+x)$, so
$$\mathbb P(M_n\ge x)\le n\mathbb P(X_1\ge x)\approx n\mathbb P(\operatorname{Pois}(1)\ge x)\le \exp(-x\log(x)-1+x)$$
So for $\mathbb P(M_n\ge x)\to 0$, we need $x=(1+\epsilon)\log n/\log\log n$.
\begin{theorem}
    We have
    $$\frac{M_n}{\log n/\log\log n}\xrightarrow{\mathbb P}1$$
    as $n\to\infty$.
\end{theorem}
Let $N\sim\operatorname{Pois}(\lambda)$ and let $X=\sum_{k=1}^N\xi_k$ where $\xi_k\sim\operatorname{Bern}(p)$, then $X\sim\operatorname{Pois}(\lambda p)$ and $N-X\sim\operatorname{Pois}(\lambda(1-p))$ and $X,N-X$ are independent, so
$$\mathbb P(X=x,N-X=y)=e^{-\lambda}\frac{\lambda^{x+y}}{(x+y)!}\binom{x+y}{x}p^x(1-p)^y$$
We cast a method called Poissonization.
\begin{proof}
    Suppose we throw $\operatorname{Pois}(n(1+\epsilon))$ balls instead and let $Y_i$ be the load of bin $i$, then $Y_i\sim\operatorname{Pois}(1+\epsilon)$ are i.i.d..
    Set $\tilde{M}_n=\max_{i\le n}Y_i$, then
    \begin{align*}
        \mathbb P(M_n\ge x)&\le\mathbb P(\tilde{M}_n\ge x,\operatorname{Pois}(n(1+\epsilon))\ge n)+\mathbb P(\operatorname{Pois}(n(1+\epsilon))<n)\\
        &\le\mathbb P(\tilde{M}_n\ge x)+\mathbb P(\operatorname{Pois}(n(1+\epsilon))<n)\\
        &\le\mathbb P(\tilde{M}_n\ge x)+\exp(n\log (1+\epsilon)-\epsilon n)\\
        &\le\mathbb P(\tilde{M}_n\ge x)+\exp\left( -\frac{n\epsilon^2}{10} \right)
    \end{align*}
    for $\epsilon\in(0,1)$.
    Hence
    $$\mathbb P\left(M_n\ge(1+\epsilon)\frac{\log n}{\log\log n}\right)\le\mathbb P\left(\tilde{M}_n\ge(1+\epsilon)\frac{\log n}{\log\log n}\right)+\exp\left( -\frac{n\epsilon^2}{10} \right)$$
    Note that $\exp(-n\epsilon^2/10)\to 0$ as $n\to\infty$.
    Now
    $$P\left(\tilde{M}_n\ge(1+\epsilon)\frac{\log n}{\log\log n}\right)\le n\mathbb P\left( Y_1\ge (1+\epsilon)\frac{\log n}{\log\log n} \right)$$
    which is bounded by
    $$n\exp\left( -(1+\epsilon)\frac{\log n}{\log\log n}\log\left( \frac{\log n}{\log\log n} \right)-(1+\epsilon)+(1+\epsilon)\frac{\log n}{\log\log n} \right)$$
    which is at most
    $$n\exp\left( -(1+\epsilon)\log n+10\frac{\log n\log\log\log n}{\log\log n} \right)\to 0$$
    as $n\to\infty$, hence
    $$\lim_{n\to\infty}\mathbb P\left(M_n\ge(1+\epsilon)\frac{\log n}{\log\log n}\right)\to 0$$
    which establishes the upper bound.\\
    For the lower bound, we need to show that for all $\epsilon\in(0,1)$, we have
    $$\lim_{n\to\infty}\mathbb P\left( M_n\le(1-\epsilon)\frac{\log n}{\log\log n} \right)\to 0$$
    Note first that $\mathbb P(\operatorname{Pois}(n(1-\epsilon))>n)\le e^{-n\epsilon^2/10}$, so
    $$\mathbb P\left( M_n\le(1-\epsilon)\frac{\log n}{\log\log n} \right)\le e^{-n\epsilon^2/10}+\mathbb P\left( \tilde{M}_n\le(1-\epsilon)\frac{\log n}{\log\log n} \right)$$
    where $\tilde{M}_n=\max_{i\le n}\tilde{Y}_i$ with $\tilde{Y}_i$ are i.i.d. $\operatorname{Pois}(1-\epsilon)$.
    So
    $$P\left( \tilde{M}_n\le(1-\epsilon)\frac{\log n}{\log\log n}\right)=P\left( \tilde{Y}_1\le(1-\epsilon)\frac{\log n}{\log\log n} \right)^n$$
    Now we have
    $$P\left( \tilde{Y}_1\ge(1-\epsilon)\frac{\log n}{\log\log n}\right)\ge e^{-(1-\epsilon)}\frac{(1-\epsilon)^M}{M!},M=(1-\epsilon)\frac{\log n}{\log\log n}$$
    Hence
    \begin{align*}
        \mathbb P(\tilde{M}_n<M)\le\left( 1-e^{-(1-\epsilon)}\frac{(1-\epsilon)^M}{M!} \right)^n\\
        \le\exp\left(-ne^{-(1-\epsilon)}\frac{(1-\epsilon)^M}{M!}\right)
    \end{align*}
    Now $M!\le M(M/e)^M$ for large enough $M$, so we (finally!) get $\mathbb P(\tilde{M}_n<M)=o(1)$, whcih establishes the result.
\end{proof}
Throw $n$ balls into $n$ bins.
Every time, we pick $d\ge 2$ bins at random and place the ball in the least loaded bin.
\begin{theorem}
    After all balls have been placed, the maximum load is
    $$\frac{\log\log n}{\log d}+O(1)$$
    with probability $1-o(1)$.
\end{theorem}
We will use the Chernoff inequality for binomials, i.e.
$$\mathbb P(\operatorname{Bin}(n,p)\ge 2np)\le e^{-np/3}$$
The height of the ball is the number of balls already placed in the bin it is placed $+1$.
Let $\nu_i$ be the number of bins with load $\ge i$ and $\mu_i$ is the number of bins with height $\ge i$, then $\nu_i\le \mu_i$.
The idea is that we want to define a sequence $\beta_i$ such that $\nu_i\le\beta_i$ with high probability for all $i\le i^\star$ where $i^\star$ is to be determined and we will show that $i^\star=\log\log n/\log d$.
Then at this time, $\beta_{i^\star}$ will have order $n$ and we can finish the proof easily from there.
Suppose we condition on $\nu_i\le\beta_i$, then the probability that a ball has height at least $i+1$ is bounded by $(\beta_i/n)^d$ since all of the $d$ choices have to come from bins with load $\ge i$, so
$$\mathbb P(\nu_{i+1}>k)\le\mathbb P(\operatorname{Bin}(n,(\beta_i/n)^d))$$
\begin{lemma}
    Let $X_1,\ldots$ be a sequence of random variables and let $Y_i$ be a function of $X_1,\ldots,X_i$ that takes values in $\{0,1\}$.
    If $\mathbb P(Y_i=1|X_1,\ldots,X_{i-1})\le p$, then
    $$\mathbb P\left( \sum_{i=1}^nY_i>k \right)\le\mathbb P(\operatorname{Bin}(n,p)>k)$$
\end{lemma}
\begin{proof}
    Each $Y_i$ is upper bounded by $\operatorname{Bern}(p)$.
    And for the sum we use induction.
\end{proof}
\begin{proof}[Proof of the Theorem]
    Let $\nu_i(t)$ be the number of bins with load $\ge i$ at time $t$ (after the $t^{th}$ ball is placed).
    Let $\mu_i(t)$ be the number of balls with height $\ge i$ at time $t$.
    Write $\nu_i(n)=\nu_i$ and $\mu_i(n)=\mu_i$, so $\nu_i(t)\le\mu_i(t)$ for any $i,t$.
    Now we want to find a sequence $\beta_i$ with $\nu_i\le\beta_i$ for $i< i^\star$ with high probability.
    Let $\beta_4=n/4$ and $\beta_{i+1}=2n(\beta_i/n)^d$.
    Define $E_i=\{\nu_i\le\beta_i\}$, so $\mathbb P(E_4)=1$.
    Now we want to show that for all $4\le i<i^\star$ where $i^\star$ is to be determined, we have $\mathbb P(E_{i=1}^c)\le\mathbb P(E_i^c)+1/n^2$.
    Define a sequence of binomial variables $Y_t=1_{h(t)\ge i+1,\nu_{i-1}\le\beta_i}$.
    Let $\omega_j$ be bins selected by the $j^{th}$ ball.
    Now
    $$\mathbb P(Y_t=1|\omega_1,\ldots,\omega_{t-1})\le\left( \frac{\beta_i}{n} \right)^d=p_i$$
    So by the preceding lemma, for any $k$,
    $$\mathbb P\left( \sum_{t=1}^nY_t>k \right)\le\mathbb P(\operatorname{Bin}(n,p)>k)$$
    So
    $$\mathbb P(E_{i+1}^c|E_i)=\mathbb P(\nu_{i+1}\ge\beta_{i+1}|E_i)\le\mathbb P(\mu_{i+1}>\beta_{i+1}|E_i)$$
    Conditioned on $E_i$, $Y_t=1_{h(t)\ge i+1}$, so $\sum_{t=1}^nY_t=\mu_{i+1}$, so
    \begin{align*}
        \mathbb P(\mu_{i+1}>\beta_{i+1}|E_i)&=\mathbb P\left( \sum_{t=1}^nY_t>\beta_{i+1}\middle|E_i \right)\\
        &=\frac{1}{\mathbb P(E_i)}\mathbb P\left( \sum_{t=1}^nY_t>\beta_{i+1},E_i \right)\\
        &\le\frac{1}{\mathbb P(E_i)}\mathbb P\left( \sum_{t=1}^nY_t>\beta_{i+1}\right)\\
        &\le\frac{1}{\mathbb P(E_i)}\mathbb P(\operatorname{Bin}(n,p_i)>\beta_{i+1})\\
        &\le\frac{e^{-np_i/3}}{\mathbb P(E_i)}
    \end{align*}
    Note that for any $i$ with $np_i\ge 6\log n$ we have
    $$\mathbb P(E_{i+1}^c|E_i)\le\frac{1}{n^2\mathbb P(E_i)}\implies\mathbb P(E_{i+1}^c)\le\frac{1}{n^2}+\mathbb P(E_i^c)$$
    Let $i^\star$ be the first $i$ such that $np_i<6\log n$.
    Now we claim that
    $$i^\star=\log\log n/\log d+O(1)$$
    It suffices to show by induction that
    $$\beta_{i+4}=\frac{n}{2^{2d^i}-\sum_{j=0}^{i-1}d^j}$$
    Once we know that, we get $\beta_{i+4}\le n/2^{d^i}$, so $\mathbb P(E_{i^\star}^c)\le i^\star/n^2$, so $\beta_{i^\star+i}=2np_{i^\star}\le 2n(6\log n/n)=12\log n$
    Now

    \begin{align*}
        \mathbb P(\nu_{i^\star+1}>18\log n|E_{i^\star})&\le\mathbb P(\nu_{i^\star+1}>18\log n|E_{i^\star})\\
        &\le\frac{\mathbb P(\operatorname{Bin}(n,6\log n/n^2)>18\log n)}{\mathbb P(E_{i^\star})}\\
        &\le e^{-2\log n}/\mathbb P(E_{i^\star})\\
        &=\frac{1}{n^2\mathbb P(E_{i^\star})}
    \end{align*}
    So
    $$\mathbb P(\nu_{i^\star+1}\ge 18\log n)\le\frac{1}{n^2}+\mathbb P(E_{i^\star}^c)\le\frac{i^\star+1}{n^2}$$
    Now $\{\nu_{i^\star+1}\ge 1\}\subset\{\mu_{i^\star+1}\ge 1\}\subset\{\mu_{i^\star+2}\ge 2\}$.
    \begin{align*}
        \mathbb P(\mu_{i^\star+1}\ge 2|\nu_{i^\star+1}<18\log n)&\le\mathbb P(\operatorname{Bin}(n,(8\log n/n)^d)\ge 2)/\mathbb P(\nu_{i^\star+1}<18\log n)\\
        &\le\binom{n}{2}\left( \frac{18\log n}{n} \right)^{2d}+\frac{i^\star+1}{n^2}\\
        &\le\frac{n^2}{n^{2d}}(18\log n)^{2d}+\frac{i^\star+1}{n^2}\\
        &=o(1/n)
    \end{align*}
    and this shows what we wanted.
\end{proof}


\subsection{Variation of Parameters}
\noindent
Although the method of undetermined coefficients is useful and relatively quick because it is algebra-based, it cannot solve many equations, even simple-looking second order equations, like
\begin{equation*}
	y'' + y = \csc{x}
\end{equation*}
The method also requires guessing, meaning for very complicated forms of $b(x)$, things can get very messy.\\

\noindent
Instead, we'll look at a more rigorous, calculus-based, approach developed by Lagrange called "variation of parameters". We'll first see how to apply the method to 2nd order linear ODEs with constant coefficients, like forced vibrations, and then we'll extend with method to order $n$.

\input{./higherOrder/nonHomeg/variationParameters_secondOrder.tex}
\input{./higherOrder/nonHomeg/variationParameters_higherOrder.tex}


\chapter{Product of funcoids over a filter}

The following definition is inspired by the usual definition of Tychonoff
product of topological spaces.

\begin{defn}
  Let $f$ be an indexed family of funcoids. Let $\mathcal{F}$ be a filter on
  $\dom f$.
  \[ a \mathrel{\left[ \prod^{[\mathcal{F}]} f \right]} b \Leftrightarrow
     \exists N \in \mathcal{F} \forall i \in N : \Pr^{\mathsf{RLD}}_i a
     \suprel{f_i} \Pr^{\mathsf{RLD}}_i b \]
  for atomic reloids $a$ and $b$.
\end{defn}

\begin{rem}
  We are especially interested in the special case when $\mathcal{F}$ is the
  cofinite filter. In this case $a \mathrel{\left[ \prod^{[\mathcal{F}]} f
  \right]} b$ is defined by the condition that $\Pr^{\mathsf{RLD}}_i a
  \suprel{f_i} \Pr^{\mathsf{RLD}}_i $ for an infinite number of
  indexes $i$.
\end{rem}

\begin{obvious}
$a \mathrel{\left[ \prod^{\suprel{ \top^{\mathscr{F} (\dom f)} }} f
\right]} b \Leftrightarrow a \mathrel{\left[ \prod^{(A)} f \right]} b$.
\end{obvious}

\begin{prop}
  $\neg \left( \mathcal{X} \suprel{f} \mathcal{Y} \right)$ implies $\neg
  \left( X \suprel{f} Y \right)$ for some $X \in \up \mathcal{X}$, $Y
  \in \up \mathcal{Y}$.
\end{prop}

\begin{proof}
  Suppose $\neg \left( \mathcal{X} \suprel{f} \mathcal{Y} \right)$. Then
  $\mathcal{Y} \asymp \supfun{f} \mathcal{X}$. Thus by separability of
  core for filters $Y \asymp \supfun{f} \mathcal{X}$ for some $Y \in
  \up \mathcal{Y}$, that is $\neg \left( \mathcal{X} \suprel{f} Y
  \right)$. Apply this result twice.
\end{proof}

\begin{lem}
  ~
  \[ \forall X \in \prod_{i \in D} \up a_i, Y \in \prod_{i \in D}
     \up b_i \exists x \in \prod_{i \in D} \mathrm{atoms} \uparrow X_i,
     y \in \prod_{i \in D} \mathrm{atoms} \uparrow Y_i \exists N \in
     \mathcal{F} \forall j \in N : x_j \mathrel{[f_j]} y_j \]
  implies $\exists N \in \mathcal{F} \forall i \in N : a_i \suprel{f_i}
  b_i$.
\end{lem}

\begin{proof}
  Suppose for the contrary $\neg \left( a_i \suprel{f_i} b_i \right)$ for
  all $i \in N$ where $N \in \mathcal{F}$ (i.e. for an infinite number of
  indexes if $\mathcal{F}$ is the cofinite filter). Then (lemma above) there
  are $X_i \in \up a_i$ and $Y_i \in \up b_i$ such that $\neg
  \left( X_i \mathrel{[f_j]^{\ast}} Y_i \right)$ for $i \in N$. Thus $\neg
  \left( x_i \suprel{f_i} y_i \right)$ for $i \in N$, contrary to the
  condition.
\end{proof}

\begin{prop}
  The funcoid $\prod^{[\mathcal{F}]} f$ exists.
\end{prop}

\begin{proof}
  We need to prove that
  \[ \forall X \in \up a, Y \in \up b \exists x \in \atoms
     \uparrow^{\mathsf{RLD}} X, y \in \atoms
     \uparrow^{\mathsf{RLD}} Y : x \mathrel{\left[ \prod^{(A 2)} f
     \right]} y \]
  implies $a \mathrel{\left[ \prod^{[\mathcal{F}]} f \right]} b$.

  Equivalently transforming it: \fxwarning{More detailed proof.}

  $\forall X \in \up a, Y \in \up b \exists x \in \atoms
  \uparrow^{\mathsf{RLD}} X, y \in \atoms
  \uparrow^{\mathsf{RLD}} Y \\
  \exists N \in \mathcal{F} \forall i \in N : \Pr^{\mathsf{RLD}}_i x
  \suprel{f_i} \Pr^{\mathsf{RLD}}_i y$; \\
  $\forall X \in \up a, Y \in \up b \exists x \in \prod_{i \in
  \dom f} \atoms \uparrow^{\mathsf{RLD}} X_i, y \in
  \prod_{i \in \dom f} \atoms \uparrow^{\mathsf{RLD}} Y_i \\
  \exists N \in \mathcal{F} \forall i \in N : x_i \suprel{f_i} y_i$;

  \[ \forall X \in \prod_{i \in D} \up a_i, Y \in \prod_{i \in D}
     \up b_i \exists x \in \prod_{i \in D} \mathrm{atoms} \uparrow X_i,
     y \in \prod_{i \in D} \mathrm{atoms} \uparrow Y_i \exists N \in
     \mathcal{F} \forall j \in N : x_j \mathrel{[f_j]} y_j \]
  where $D = \dom f$.

  Thus by the lemma $\exists N \in \mathcal{F} \forall i \in N : a_i
  \suprel{f_i} b_i$, that is $a \suprel{\prod^{[\mathcal{F}]} f} b$.
\end{proof}

\fxnote{TODO: when $\Pr_j \prod^{[\mathcal{F}]}_{i\in D} a_i = a_j$?}

\section{More on product of reloids}

\fxwarning{Move this to a more appropriate place.}

\begin{defn}
  $\prod^{(Y)}_{i \in \dom f} f = \prod^{(A)}_{i \in \dom f}
  \tofcd f$ for an indexed family~$f$ of reloids.
\end{defn}

\begin{prop}
  \[ a \mathrel{\left[ \prod^{(Y)}_{i \in \dom f} f \right]} b
  \Leftrightarrow \forall i \in \dom f : f_i \nasymp
  \Pr^{\mathsf{RLD}}_i a \times^{\mathsf{RLD}}
  \Pr^{\mathsf{RLD}}_i b. \]
\end{prop}

\begin{proof}
  $f_i \nasymp \Pr^{\mathsf{RLD}}_i a \times^{\mathsf{FCD}} \Pr^{\mathsf{RLD}}_i b
  \Leftrightarrow \tofcd f_i \sqsupseteq
  \Pr^{\mathsf{RLD}}_i a \times^{\mathsf{FCD}} \Pr^{\mathsf{RLD}}_i b \Leftrightarrow
  a \mathrel{[\tofcd f_i]} b$.
\end{proof}

\begin{example}
  The funcoid $p$ described by the formula (for atomic reloids $a$ and $b$)
  \[ a \mathrel{\mathrel{p}} b \Leftrightarrow \forall i \in \dom f : f_i
     \sqsupseteq \Pr^{\mathsf{RLD}}_i a \times^{\mathsf{RLD}}
     \Pr^{\mathsf{RLD}}_i b \]
  does not exist (in general), even if we restrict to $2$-indexed families
  only.
\end{example}

\begin{proof}
  For the case if $f = \llbracket v , w \rrbracket$ is a $2$-indexed family of
  reloids, the formula which we need to disprove takes the form:
  \[ a \mathrel{\mathrel{p}} b \Leftrightarrow v \sqsupseteq \dom a
     \times^{\mathsf{RLD}} \dom b \wedge w \sqsupseteq \im
     a \times^{\mathsf{RLD}} \im b. \]
  Take $v = w = 1^{\mathbf{Rel}}$ on an infinite set. Suppose for the
  contrary $p$ exists and is a funcoid. Then
  \[ \forall X \in \up a, Y \in \up b \exists x \in \atoms
     \uparrow X, y \in \atoms \uparrow Y : x \mathrel{\mathrel{p}} y \Rightarrow
     a \mathrel{\mathrel{p}} b. \]
  For a counter-example take $a = b$ to be a nontrivial ultrafilter. Then for
  every $X \in \up a$, $Y \in \up b$ take $x = y$ to be singletons
  on $X \cap Y$. We have $x \mathrel{\mathrel{p}} y$, but not $a \mathrel{\mathrel{p}} b$.
\end{proof}


%----------------------------------------------------------------------------------------
% Quantum Mechanic's Toolbox
%----------------------------------------------------------------------------------------

\chapter*{Quantum Mechanic's Toolbox}
This is a collection of the tools in our toolbox.

%tool1
\ref{tool:decom} This tool is used to write a state vector in terms of a set of orthonormal basis vectors.
\[
\ket{A} = \sum_j \alpha_j \ket{j},
\]
where $\alpha_j$ are complex numbers.

%tool2
\ref{tool:orthog} This tool is used to collapse a sum using the inner product of two orthonormal state vectors.
\[
\avg{k|A} = \bra{k} \left( \sum_j \alpha_j \ket{j} \right)= \alpha_k.
\]

%tool3
\ref{tool:span} This tool is used to insert a complete set of basis vectors and project a state vector onto that basis.
\[
\sum_j \ket{j}\bra{j} = \onehat \qquad \int_{-\infty}^{\infty} \ket{\lambda}\bra{\lambda} = \onehat.
\]

%tool4
\ref{tool:prob} This tool is used to calculate the probability of measuring a particular outcome of a quantum state.
\[
P(\rmt{measuring } \ket{\lambda}) = \abs{\avg{\lambda|\Psi}}^2 = P(a,b) = \int\displaylimits_a^b\psi^{*}(x)\psi^{}(x)dx.
\]

%tool5
\ref{tool:avg} This tool is used to find the average measurement value of an operator for an input state.
\[
\avg{\hat{L}} = \bra{\Psi_\rmt{in}}\hat{L}\ket{\Psi_\rmt{in}} =  \sum_j P(\lambda_j)\lambda_j = \Tr \oprod{\Psi}{\Psi}\hat{L}.
\]

%tool6
\ref{tool:eigen} This tool is used to evaluate the operation of a linear operator on one of its eigenvectors. It returns the eigenvalue and the eigenvector.
\[
\hat{L}\ket{\lambda} = \lambda\ket{\lambda}.
\]

%tool7
\ref{tool:sch} This tool is used to find the time evolution of a quantum state.
\[
\I \hbar \frac {d}{dt}\ket{\Psi} = \hat{H}\ket{\Psi}
\]
%tool8
\ref{tool:commutator} This tool is used to find the commutation relationship between two operators.
\[
\com{\hat{A},\hat{B}}=\hat{A}\hat{B} - \hat{B}\hat{A}
\]

%tool9
\ref{tool:meunc} This tool is used to find the uncertainty in the measurement associated with an operator.
\[
\Delta L= \left[\avg{\hat{L}^2} - \avg{\hat{L}}^2\right]^{1/2}.
\]

%tool10
\ref{tool:genuncert} This tool is used to find the uncertainty relationship between two operators.
\[
\Delta A \Delta B \geq \frac{1}{2} \abs{\bra{\Psi}\com{\hat{A},\hat{B}}\ket{\Psi}}.
\]

%tool11
\ref{tool:wavefunction} This tool is used to determine the continuous wavefunction in a particular basis.
\[
\psi(\lambda) = \avg{\lambda|\Psi}\quad \psi(x) = \avg{x|\Psi}\quad \phi(p_x) = \avg{p_x|\Psi} \quad \psi(\vec{r}) \equiv \avg{\vec{r}|\Psi} \quad \phi(\vec{p}) \equiv \avg{\vec{p}|\Psi}.
\]

%tool12 - Fourier Transforms
\ref{tool:FTtool} This tool is used to transform a wavefunction back and forth from the position to the momentum bases.
\[
\begin{split}
\phi(p_x)= &  \frac{1}{\sqrt{2\pi\hbar}}\int\displaylimits_{-\infty}^{\infty}\E{-\I \frac{p_x}{\hbar} x} \psi(x) dx\\
\psi(x) = &  \frac{1}{\sqrt{2\pi\hbar}}\int\displaylimits_{-\infty}^{\infty}\E{\I \frac{p_x}{\hbar} x} \phi(p_x) dp_x.
\end{split}
\begin{split}
\displaystyle \phi(\vec{p})& = \frac{1}{(2\pi\hbar)^{3/2}}\int \psi(\vec{r})\E{-\I\vec{p}\cdot \vec{r}/\hbar}d^{3}r.\\
\displaystyle \psi(\vec{r}) &= \frac{1}{(2\pi\hbar)^{3/2}}\int \phi(\vec{p})\E{\I\vec{p}\cdot \vec{r}/\hbar}d^{3}p.
\end{split}
\]

%tool13 - TDSWE

\ref{tool:TDSWE} This tool is used to find the time evolution of a quantum wavefunction in the position basis in a position-dependent potential.
\[
\I\hbar \frac{\partial \psi(\vec{r},t)}{\partial t} =-\frac{\hbar^2}{2m}\vec{\nabla}^2\psi(\vec{r},t) + V(\vec{r}) \psi(\vec{r},t).
\]

%tool14 - TISWE
\ref{tool:TISWE} This tool is used to find the energy eigenvalues for a the time-independent Schr\"{o}dinger equation in the position basis.
\[
-\frac{\hbar^2}{2m}\vec{\nabla}^2\psi_E(\vec{r}) + V(\vec{r}) \psi_E(\vec{r})= E \psi_E(\vec{r})
\]

Path Integral
\[
C_{1,2} =\int\displaylimits_{-\infty}^{\infty}\bra{x_2} \E{-\I \frac{\hat{H}}{\hbar} \Delta t/2}\ket{x}\bra{x}\E{-\I \frac{\hat{H}}{\hbar} \Delta t/2}\ket{x_1}dx.
\]

First-order time-independent perturbation model
\[
E_n^1 = \bra{\psi_n^0}\hat{H}'\ket{\psi_n^0}
\]

Time-dependent perturbation model
\[
\begin{split}
\dot{c}_a =& -\frac{\I}{\hbar} c_b H'_{ab} \E{-\I\omega_0 t} \\
\dot{c}_b =&  -\frac{\I}{\hbar} c_a H'_{ba} \E{\I\omega_0 t}
\end{split}
\]

Number Operators
\[
\begin{split}
\Ap = & \left(\sqrt{\frac{m \omega_0}{2\hbar}}\hat{X}+ \frac{\hat{P}_x }{\I\sqrt{2m\hbar\omega_0}}\right)\\
\Am = & \left(\sqrt{\frac{m \omega_0}{2\hbar}}\hat{X}- \frac{\hat{P}_x }{\I\sqrt{2m\hbar\omega_0}}\right)\\
\Ap\ket{n} = & \sqrt{n+1}\ket{n+1}\\
\Am\ket{n} = & \sqrt{n}\ket{n-1}\\
\hat{N}\ket{n} = & \Ap\Am\ket{n} = n\ket{n},\; n=0,1,2,\ldots
\end{split}
\]

Angular Momentum Operator
\[
\vec{L} = \vec{r}\times\vec{p} \rightarrow \begin{aligned}
L_x = & yp_z - zp_y\\
L_y = & zp_x - xp_z\\
L_z = & xp_y - yp_x\\
\end{aligned}
\]

Generalized Angular Momentum
\[
\begin{split}
\com{\Jh_1,\Jh_2} =& \I\hbar\Jh_3\\
\com{\Jh_2,\Jh_3} =& \I\hbar\Jh_1\\
\com{\Jh_3,\Jh_1} =& \I\hbar\Jh_2\\
\Jh^2 = &\Jh_1^2 + \Jh_2^2 +\Jh_3^2\\
\com{\Jh^2,\Jh_1} = & \com{\Jh^2,\Jh_2} = \com{\Jh^2,\Jh_3} = 0
\end{split}
\]

\[
\begin{split}
\Jh^2\ket{jm_j} = & j(j+1)\hbar^2\ket{jm_j}\\
\Jh_3\ket{jm_j} = & m_j\hbar \ket{jm_j} \\
j =& 0,\frac{1}{2},1,\frac{3}{2},\ldots \\
m_j =& -j,-j+1,-j+2,\ldots,j-2,j-1,j\; \rmt{ and}\\
\Jpm\ket{jm_j} = &\hbar \sqrt{j(j+1) - m_j(m_j\pm1)} \ket{j(m_j\pm1)}.
\end{split}
\]

Spherical Harmonics in Position Basis
\[
\Ylm(\theta,\phi)=\sqrt{\frac{(2l+1)(l-m_l)!}{4\pi(l+m_l)!}} P_l^{m_l}(\cos\theta) \E{\I m_l\phi}
\]

Normalized Radial Coulomb Wavefunction
\[
R_{nl}(r) = \sqrt{\left(\frac{2}{n a_0}\right)^3\frac{(n-l-1)!}{2n\left[(n+l)!\right]^3}}\E{-\frac{r}{na_0}}\left(\frac{2r}{na_0}\right)^l L_{n-l-1}^{2l+1}\left(\frac{2r}{na_0}\right).
\]

%---------------------------------
% Useful items
%---------------------------------
\subsection{Matrix Representations}
This is a table of the matrix representations for common states and operators.
\bas
\ket{u},\ket{V} \Meq & \vket{1}{0} & \ket{d},\ket{H} \Meq & \vket{0}{1} \nonumber\\
\ket{r},\ket{D_R} \Meq & \frac{1}{\stwo}\vket{1}{1} & \ket{\ell},\ket{D_L} \Meq & \frac{1}{\stwo}\vket{1}{-1} \nonumber\\
\ket{i},\ket{C_R} \Meq & \frac{1}{\stwo}\vket{1}{\I} & \ket{o},\ket{C_L} \Meq & \frac{1}{\stwo}\vket{1}{-\I} \nonumber\\
\hat{\sigma}_1 \Meq &\sxmatrix  & \hat{S}_x \Meq& \frac{\hbar}{2}\sxmatrix \nonumber\\
\hat{\sigma}_2 \Meq &\symatrix  & \hat{S}_y \Meq& \frac{\hbar}{2}\symatrix \nonumber\\
\hat{\sigma}_3 \Meq &\szmatrix  & \hat{S}_z \Meq& \frac{\hbar}{2}\szmatrix \nonumber
\eas

%sagemathcloud={"latex_command":""}