\chapter{Discussion}\label{chap:discussion}

In Chapter~\ref{chap:implementation} we present our formalisation of
infinitary term rewriting and in the current chapter we discuss some
aspects of it. First, the representation we use for rewrite sequences
is motivated and the resulting definitions are related to the notion
of convergence. We then comment on some technicalities in the
implementation. Finally, we conclude with an evaluation of our
formalisation.

\section{Representing Rewrite Sequences}

% TODO: leave out ', with the appropriate conditions...' ?
In Definition~\ref{def:seq}, transfinite rewrite sequences are
introduced as partial functions from ordinals to rewrite steps, with
the appropriate conditions on source and target terms of subsequent
rewrite steps. Could we not translate this directly to \Coq?

% TODO: one problem, and other problem?
A problem with partial functions from ordinals to rewrite steps is that we
would need a decidable order on the ordinals. Consider a non-trivial rewrite
sequence of length $\alpha$. The partial function representing this
rewrite sequence must compare its input value (an ordinal) to all possible
input values (ordinals up to $\alpha$) in order to decide what rewrite step to
produce, in finite time.

The order on our tree ordinals is not decidable (consider comparing the upper
bounds of two infinite sequences). This could be
remedied by using a different representation for the ordinals, for
example axiomatically, as Cantor normal forms, or as sets. We feel
that the inductively defined tree ordinals are a more natural
representation in the constructive type theory of \Coq.

Comparison of ordinals up to some given upper bound may be decidable,
so another remedy for this problem would be to only consider rewrite
sequences of limited length. Motivated by the Compression Lemma, we
could go even further and restrict our representation to rewrite
sequences of length $\le \omega$. This would severely cripple our
formalisation, since much of the theory of infinitary rewriting could
not be developed with this representation (e.g. the Compression Lemma
itself). % and many compressed rewrite sequences are unnatural

Another argument in favour of our representation based on tree
ordinals is that it seems natural for a \Coq formalisation. As a
comparison, lists of finite length are usually defined by induction in
\Coq, not as partial functions from the natural numbers. Our
representation can be seen as a generalisation of inductively defined
finite lists to lists of transfinite length.

\section{Convergence of Rewrite Sequences}\label{sec:convergence}

The inductively defined rewrite sequences from Section~\ref{sec:seq}
are not necessarily (weakly) convergent. A rewrite sequence of limit
length satisfies the condition that the target terms of the
\coqref{Rewriting.Lim}{\coqdocconstructor{Lim}} branches converge but
this is too weak to establish convergence of the rewrite
sequence itself.

The depths of the rewrite steps are not considered at all in our
formalisation and therefore it obviously does not implement strong
convergence. Furthermore, the discussion in this section also applies
to the notions of continuity.

We consider an example of a rewrite sequence that satisfies our
inductive definition from Section~\ref{sec:seq} but is not weakly
convergent. Let $A$ be a constant and $B, C, D$ unary function symbols. We use
the following three rewrite rules:
\begin{align*}
  \rho_1 \, : \, A \to B(A) \qquad \qquad
  \rho_2 \, : \, C(x) \to D(x) \qquad \qquad
  \rho_3 \, : \, D(x) \to C(x)
\end{align*}
The term $C(A)$ rewrites in $\omega$ many $\rho_1$-steps to
$C(B^\omega)$.
\begin{center}
{\footnotesize\begin{tikzpicture}[node distance=50pt]
\tikzstyle{level}=[level distance=20pt,sibling distance=22pt]
\node (a) {$C$} child { node {$A$} };
\node (b) [right of=a] {$C$} child { node {$B$} child { node {$A$} } };
\node (c) [right of=b] {$C$} child { node {$B$} child { node {$B$}
    child { node {$A$} } } };
\node (d) [right of=c,node distance=80pt] {$C$} child { node {$B$}
  child { node {$B$} child { node {$B$} child { node[below=-6pt]
        {\scriptsize$\vdots$} } } } };
\path (a) -- (b) node[midway,below=-1pt] {$\rightarrow_{\rho_1}$};
\path (b) -- (c) node[midway,below=-1pt] {$\rightarrow_{\rho_1}$};
\path (c) -- (d) node[midway,below=-1pt] {$\rightarrow_{\rho_1} \quad \cdots$};
\end{tikzpicture}}
\end{center}\vspace{-0.8\baselineskip}
We modify this rewrite sequence such that in between every two
$\rho_1$-steps, the root symbol $C$ is changed to $D$ and back to
$C$. The resulting rewrite sequence does not have a limit and is not
weakly convergent.
\begin{center}
{\footnotesize\begin{tikzpicture}[node distance=40pt]
\tikzstyle{level}=[level distance=20pt,sibling distance=22pt]
\node (a) {$C$} child { node {$A$} };
\node (a') [right of=a] {$C$} child { node {$B$} child { node {$A$} } };
\node (a'') [right of=a'] {$D$} child { node {$B$} child { node {$A$} } };
\node (b) [right of=a''] {$C$} child { node {$B$} child { node {$A$} } };
\node (b') [right of=b] {$C$} child { node {$B$} child { node {$B$}
    child { node {$A$} } } };
\node (b'') [right of=b'] {$D$} child { node {$B$} child { node {$B$}
    child { node {$A$} } } };
\node (c) [right of=b''] {$C$} child { node {$B$} child { node {$B$}
    child { node {$A$} } } };
\node (d) [right of=c] {};
\path (a) -- (a') node[midway,below=-1pt] {$\rightarrow_{\rho_1}$};
\path (a') -- (a'') node[midway,below=-1pt] {$\rightarrow_{\rho_2}$};
\path (a'') -- (b) node[midway,below=-1pt] {$\rightarrow_{\rho_3}$};
\path (b) -- (b') node[midway,below=-1pt] {$\rightarrow_{\rho_1}$};
\path (b') -- (b'') node[midway,below=-1pt] {$\rightarrow_{\rho_2}$};
\path (b'') -- (c) node[midway,below=-1pt] {$\rightarrow_{\rho_3}$};
\path (c) -- (d) node[pos=.8,below=-1pt] {$\rightarrow_{\rho_1} \quad \cdots$};
\end{tikzpicture}}
\end{center}\vspace{-0.8\baselineskip}
We can define this rewrite sequence as the limit of
$(\varphi_n)_{n \in \mathbb{N}}$, where $\concat$ denotes
concatenation of rewrite sequences:
\begin{align*}
  \varphi_0 \, &: \, C(A) \to^0 C(A)\\ % or \mbox{\emph{empty}}
  \varphi_{n + 1} \, &: \, \varphi_n \concat C(B^n(A)) \to_{\rho_1}
  C(B^{n + 1}(A)) \to_{\rho_2} D(B^{n + 1}(A)) \to_{\rho_3} C(B^{n +
    1}(A))
\end{align*}
The target terms $C(B^{n + 1}(A))$ converge to $C(B^\omega)$ and this
construction can thus be used with our inductive definition of rewrite
sequences, where we take $\varphi_n$ to be the $n$\textsuperscript{th}
branch of the \coqref{Rewriting.Lim}{\coqdocconstructor{Lim}}
constructor.

% $\varphi_n$ is the prefix of length $3n$.

% 'stuttering convergence'
% convergence with hiccups
% the difference between t_n and the limit t is oscillating

It is not clear to us whether there is some natural translation of the
convergence conditions to our formalisation.
%Without such a translation, we feel our definitions are not
%satisfactory.
For completeness we include a (not so natural) translation of
convergence, but we were not able to use it in our development. Even
proving the simplest convergent rewrite sequences to satisfy these
definitions seems too involved.
% TODO: try with the really simplest example and explain better why it doesn't
% work for us
\begin{singlespace}
\begin{coqdoccode}
\coqdocnoindent
\coqdockw{Fixpoint}
\coqdef{Rewriting.weaklyconvergent}{weakly\_convergent}{\coqdocdefinition{weakly\_convergent}}
\coqdocvar{s} \coqdocvar{t} (\coqdocvar{$\varphi$} : \coqdocvar{s}
\coqref{Rewriting.sequence}{$\rewrites_\mathcal{R}$} \coqdocvar{t}) :
\coqdockw{Prop}
:=\coqdoceol
\coqdocindent{1.00em}
\coqdockw{match} \coqdocvariable{$\varphi$} \coqdockw{with}\coqdoceol
\coqdocindent{1.00em}
\ensuremath{|} \coqref{Rewriting.Nil}{\coqdocconstructor{Nil}}
\coqdocvar{\_}          \ensuremath{\Rightarrow}
\coqexternalref{http://coq.inria.fr/stdlib/Coq.Init.Logic}{True}{\coqdocinductive{True}}\coqdoceol
\coqdocindent{1.00em}
\ensuremath{|} \coqref{Rewriting.Cons}{\coqdocconstructor{Cons}}
\coqdocvar{\_} \coqdocvar{\_} \coqdocvar{$\psi$} \coqdocvar{\_}
\coqdocvar{\_} \ensuremath{\Rightarrow}
\coqref{Rewriting.weaklyconvergent}{\coqdocdefinition{weakly\_convergent}}
\coqdocvariable{$\psi$}\coqdoceol
\coqdocindent{1.00em}
\ensuremath{|} \coqref{Rewriting.Lim}{\coqdocconstructor{Lim}}
\coqdocvar{\_} \coqdocvar{\_} \coqdocvar{f} \coqdocvar{t}
\coqdocvar{\_}  \ensuremath{\Rightarrow}
(\ensuremath{\forall} \coqdocvar{n},
\coqref{Rewriting.weaklyconvergent}{\coqdocdefinition{weakly\_convergent}}
(\coqdocvariable{f} \coqdocvariable{n})) \ensuremath{\land}
\ensuremath{\forall} \coqdocvar{d}, \ensuremath{\exists}
\coqdocvar{$\iota$}, \ensuremath{\forall} \coqdocvar{$\kappa$},\coqdoceol
\coqdocindent{10.00em}
\coqdocvariable{$\varphi$}[\coqdocvariable{$\iota$}]$^\textsc{seq}$ \coqref{Rewriting.embed}{$\sqsubseteq$}
\coqdocvariable{$\varphi$}[\coqdocvariable{$\kappa$}]$^\textsc{seq}$
\ensuremath{\rightarrow}
\coqdocvariable{$\varphi$}[\coqdocvariable{$\kappa$}]$^\textsc{l}$
\coqref{TermEquality.termequpto}{\equpto{\coqdocvariable{d}}}
\coqdocvariable{t}\coqdoceol
\coqdocindent{1.00em}
\coqdockw{end}.\coqdoceol
\coqdocemptyline
\coqdocnoindent
\coqdockw{Fixpoint}
\coqdef{Rewriting.stronglyconvergent}{strongly\_convergent}{\coqdocdefinition{strongly\_convergent}}
\coqdocvar{s} \coqdocvar{t} (\coqdocvar{$\varphi$} : \coqdocvar{s} \coqref{Rewriting.sequence}{$\rewrites_\mathcal{R}$} \coqdocvar{t}) : \coqdockw{Prop}
:=\coqdoceol
\coqdocindent{1.00em}
\coqdockw{match} \coqdocvariable{$\varphi$} \coqdockw{with}\coqdoceol
\coqdocindent{1.00em}
\ensuremath{|} \coqref{Rewriting.Nil}{\coqdocconstructor{Nil}}
\coqdocvar{\_}          \ensuremath{\Rightarrow}
\coqexternalref{http://coq.inria.fr/stdlib/Coq.Init.Logic}{True}{\coqdocinductive{True}}\coqdoceol
\coqdocindent{1.00em}
\ensuremath{|} \coqref{Rewriting.Cons}{\coqdocconstructor{Cons}}
\coqdocvar{\_} \coqdocvar{\_} \coqdocvar{$\psi$} \coqdocvar{\_}
\coqdocvar{\_} \ensuremath{\Rightarrow}
\coqref{Rewriting.stronglyconvergent}{\coqdocdefinition{strongly\_convergent}}
\coqdocvariable{$\psi$}\coqdoceol
\coqdocindent{1.00em}
\ensuremath{|} \coqref{Rewriting.Lim}{\coqdocconstructor{Lim}}
\coqdocvar{\_} \coqdocvar{\_} \coqdocvar{f} \coqdocvar{t}
\coqdocvar{\_}  \ensuremath{\Rightarrow}
(\ensuremath{\forall} \coqdocvar{n},
\coqref{Rewriting.stronglyconvergent}{\coqdocdefinition{strongly\_convergent}}
(\coqdocvariable{f} \coqdocvariable{n})) \ensuremath{\land}\coqdoceol
\coqdocindent{2.00em}
\ensuremath{\forall} \coqdocvar{d}, \ensuremath{\exists}
\coqdocvar{$\iota$}, \ensuremath{\forall} \coqdocvar{$\kappa$},\coqdoceol
\coqdocindent{3.00em}
\coqdocvariable{$\varphi$}[\coqdocvariable{$\iota$}]$^\textsc{seq}$
\coqref{Rewriting.embed}{$\sqsubseteq$}
\coqdocvariable{$\varphi$}[\coqdocvariable{$\kappa$}]$^\textsc{seq}$
\ensuremath{\rightarrow}
\coqdocvariable{d} $\le$
\coqdocdefinition{depth}
\coqdocvariable{$\varphi$}[\coqdocvariable{$\kappa$}]$^\textsc{stp}$\coqdoceol
\coqdocindent{1.00em}
\coqdockw{end}.\coqdoceol
\end{coqdoccode}
\end{singlespace}

%Here it should be possible to prove that
%\coqref{Rewriting.stronglyconvergent}{\coqdocdefinition{strongly\_convergent}}
%implies
%\coqref{Rewriting.weaklyconvergent}{\coqdocdefinition{weakly\_convergent}}.

\section{Design Decisions}\label{sec:design}

We describe a number of design decisions that we had to make during
implementation.

%Why \Coq?

\subsection{Coinductive Terms}

We define the type of infinite terms by coinduction. Another often
used definition of $\TerI$ is by partial functions from positions to
symbols. This definition is troublesome to translate to \Coq, which
admits no partial functions. It might be possible to circumvent this
restriction using option types, or by some other means, but we suspect
that the resulting notion of terms would not be elegant. Coinduction
is a native concept in \Coq and we use it as such. The consequence is that, in
defining infinite terms, we are restricted to definitions in guarded form, see
Section~\ref{sec:guardedness}.

\subsection{Positions}

The set of positions of a given term is a restricted list of natural
numbers. This could probably be translated to \Coq by encoding the
restriction in the type of positions. It would result in quite
complicated definitions, however, and therefore we choose for
\coqref{Term.subterm}{\coqdocdefinition{subterm}} and
\coqref{Context.dig}{\coqdocdefinition{dig}} to take any list of
natural numbers and return option types to distinguish between
existing and non-existing positions. This comes at the cost of having
to handle the option types with every call of
\coqref{Term.subterm}{\coqdocdefinition{subterm}} or
\coqref{Context.dig}{\coqdocdefinition{dig}}.

\subsection{Bisimilarity in Rewrite Steps}\label{sub:bissteps}

In the definition of rewrite steps (Section~\ref{sec:seq}), we include
bisimilarity conditions on the source and target terms. The reason is
that we cannot rely on \Coq's small standard equality. For consider two
rewrite steps $s_1 \to s_2$ and $t_1 \to t_2$, where $s_2 \bis
t_1$. We should be able to construct the rewrite sequence consisting
of these two steps, but the fact that the target term of the first
and the source term of the second can be identified must be encoded
somewhere. There are two places to do this: in the
\coqref{Rewriting.Cons}{\coqdocconstructor{Cons}} constructor
for rewrite sequences, or in the definition of rewrite steps. We
choose the latter because it turns out to be technically more
elegant.

\subsection{One-Hole Contexts}\label{sub:contexts}

We know of two obvious ways to represent multi-hole contexts:
by the coinductive term datatype augmented with a constructor for
holes or by a function whose arguments represent holes.
Both are unsatisfactory. The first representation requires a dynamic
check on the number of holes and it admits contexts with infinitely
many holes. The second representation cannot guarantee
that each hole occurs exactly once and its type, encoding the number of
holes, cannot be generalised. \citet{lindley-08} presents a quite
involved solution based on a type-level difference encoding of natural
numbers. We bypass the problem by only considering one-hole contexts.

\section{Conclusions}

Our representation of transfinite rewrite sequences based on tree
ordinals is original work. While the representation is natural to
implement in \Coq, we are disappointed by not being able to come up
with a natural translation of convergence for this
representation. Without such a translation, we feel our definitions
are not satisfactory and we hope that future work can remedy this.

%For example, it is quite conceivable that other means of indexing our
%rewrite sequences can be defined. Alternatives to our embedding
%relation might also be possible.

In an alternative representation as partial functions from
ordinals to rewrite steps, convergence can be expresssed directly, but it has
other problems. However, it seems
worthwhile to also investigate this representation further, for example
using the ordinals in Cantor normal form by
\citet{casteran-06}. Jeroen Ketema showed by personal communication
that, assuming some decidable properties on the ordinal representation,
constructive formalisation of some of the infinitary rewriting theory is
possible.

Working with \Coq has been an overall pleasant experience. During this
development, our main disturbance was with the guardedness condition
on corecursive definitions. Sometimes unguarded but natural
definitions are easily seen to be productive yet not accepted by
\Coq. One could hope for future additions to \Coq in this area, for
example in the form of user-supplied productivity proofs for
corecursive definitions to be admitted.

Still, the amount of work that is required for a formalisation like
this is disproportionally large. Especially the implementation of the
counterexample to UN$^\infty$ in weakly orthogonal systems from
Chapter~\ref{chap:unwo} takes only a page to formulate on paper, while
it took us some 2,000 lines of \Coq code to formalise.

%Original goal was compression.

%Formalising transfinite objects is hard.

The complete formalisation consists of some 6,500 physical source
lines of code (LOC), roughly distributed as follows:
\begin{center}\begin{singlespace}
{\renewcommand{\arraystretch}{1.4}
\renewcommand{\tabcolsep}{10pt}
\begin{tabular}{p{140pt} r}
\textsc{logical module} & \textsc{LOC}\\
\hline
coinductive terms & 1,250\\
tree ordinals & 900\\
transfinite rewriting & 1,500\\
UN$^\infty$ and weak orthogonality & 2,000\\
total & $\approx$ 6,500
\end{tabular}}
\end{singlespace}\end{center}

%\begin1,250 for terms
%\item 900 for ordinals
%\item 1,500 for rewriting
%\item 3,000 for UN$^\infty$ and weak orthogonality\\[1em]
%\end{compactitem}


%%% File encoding is UTF8
%%% You can use special characters just like ä,ü and ñ

\chapter{Capítulo Apéndice}

\section{Sección del apéndice}

\begin{neuralnetwork}[height=4]
\centering
	\newcommand{\nodetextclear}[2]{}
	\newcommand{\nodetextx}[2]{$x_#2$}
	\newcommand{\nodetexty}[2]{$y_#2$}
	\inputlayer[count=4, bias=false, title=Input\\layer, text=\nodetextx]
	\hiddenlayer[count=5, bias=false, title=Hidden\\layer, text=\nodetextclear] \linklayers
	\outputlayer[count=3, title=Output\\layer, text=\nodetexty] \linklayers
\end{neuralnetwork}

\begin{figure}[htb]
	\centering
	\begin{tikzpicture}
	\begin{axis}[axis lines = middle
	, enlargelimits = true
	, xlabel = {$x$}
	, ylabel = {$y$}
	, trig format plots = rad
	, width = 0.9\textwidth
	, height= 80mm
	, cycle list name=Dark2
	, title style={font=\bfseries,align=center,text width=0.7\textwidth}
	, title = {Example Diagram with a Line Break in the Title (using the \texttt{text width} option in the \texttt{title style})},
	]
	\addplot[myColorMainA,domain=0:9, line width=1pt, smooth]
	{0.2*x^2};
	\addplot[myColorMainB,domain=0:9, line width=1pt, smooth]
	{5*sin(x)};
	\end{axis}
	\end{tikzpicture}
	\captionsource{A scientific diagram using the \texttt{pgfplots} package by \textsc{Christian Feuersaenger} using the same colors which are also used for the layout}{\fuentePropia}
	\label{fig:ScientificDiagram}
\end{figure}

\subsection{Subseccion del apéndice}

Como se ve en el \alg{alg:ex1}

\begin{algorithm}[H]
	\caption{\textsc{Escribiendo algoritmos usando \LaTeX2e}}
	\label{alg:ex1}
	\SetAlgoLined
	\KwIn{Esto es la entrada del algoritmo}
	\KwOut{Esto es la salida del algoritmo}
	%\KwData{Esto son los datos con que trabaja el algoritmo}
	%\KwResult{Esto es el resultado del algoritmo}
\Begin{
	$V \longleftarrow U$\;
	$S \longleftarrow \emptyset$\;

	\While{not at end of this document}{
		read current\;
		\eIf{understand}{
			go to next section\;
			current section becomes this one\;
		}{
			go back to the beginning of current section\;
		}
	}
}
\end{algorithm}


\documentclass[11pt]{amsart}
\usepackage{amsmath,amsfonts,amsthm,amssymb, amsaddr, verbatimbox}

\title{Schr\"{o}dinger equation in 3-D}

\author{Joe Bentley}

\date{\today}

\begin{document}

\maketitle

\newpage

\section{Introduction}

In this we will look at how use the Schr\"{o}dinger equation in three dimensions, as well as seeing how it relates to the one dimensional Schr\"{o}dinger equation. This should be quite simple and does use some of the vector calculus stuff from the mathematics module, but mainly this should be simple to follow for the most part.

\section{Momentum in 3-D and the Schr\"{o}dinger Equation}

Before our concept of momentum was limited to one dimension, which meant we could represent the momentum operator using a single differential operator of the form $\hat{p} = -i\hbar\frac{\partial}{\partial x}$. However now, our momentum has three perpendicular components in the $x$, $y$, and $z$ directions, which are all independent of each other. We can therefore write that we have three momentum operators, one for each momentum eigenvalue corresponding to a given direction,

\begin{align*}
  \hat{p_x} = -i\hbar\frac{\partial}{\partial x} \qquad \hat{p_y} = -i\hbar\frac{\partial}{\partial y} \qquad \hat{p_z} = -i\hbar\frac{\partial}{\partial z}
\end{align*}

We can write this concisely using vector notation as $\hat{p} = (\hat{p_x}, \hat{p_y}, \hat{p_z})$. Substituting each one of these in,

\begin{align*}
  \hat{p}=-i\hbar
  \begin{pmatrix}
    \frac{\partial}{\partial x} \\[4pt]
    \frac{\partial}{\partial y} \\[4pt]
    \frac{\partial}{\partial z}
  \end{pmatrix}
\end{align*}

From vector calculus, the vector here is just the gradient operator, so this can be very concisely written as,

\begin{align*}
  \hat{p}=-i\hbar\nabla
\end{align*}

Similarly, for the kinetic energy operator,

\begin{align*}
  \hat{T}=\frac{{\hat{p}}^2}{2m}=-\frac{\hbar^2}{2m}\nabla^2
\end{align*}

Here the operator $\nabla^2$ is just the Laplacian. We can therefore see that the Schr\"{o}dinger equation, when expanded out of operator form, can be expressed as,

\begin{align*}
  -\frac{\hbar^2}{2m}\nabla^2\Psi+V\Psi=i\hbar\frac{\partial}{\partial t}\Psi
\end{align*}

where $\Psi = \Psi(\mathbf{r}, t)$, and $V = V(\mathbf{r}, t)$; both are a function of three dimensional space ($\mathbf{r} = (x, y, z)$) and time.

If the potential $V$ is only spatially varying, and is constant in time, we can write the time independent Schr\"{o}dinger equation as,

\begin{align*}
  -\frac{\hbar^2}{2m}\nabla^2\psi(\mathbf{r})+V(\mathbf{r})\psi(\mathbf{r})=E\psi(\mathbf{r})
\end{align*}

where, just as before, we say that the full time dependent wavefunction is the product of a spatial and temporal part $\Psi(\mathbf{r},t)=\psi(\mathbf{r})e^{-\frac{iEt}{\hbar}}$.

For a travelling wave in three-dimensions we can extend our one dimensional form by considering the wavefunction as a product of three spatial parts,

\begin{align*}
  \psi(\mathbf{r})&=e^{ik_xx}e^{ik_yy}e^{ik_zz} \\
                  &=e^{i(k_xx+k_yy+k_zz)} \\
                  &=e^{i(\mathbf{k}\cdot\mathbf{r})}
\end{align*}

where the vector $\mathbf{k}=(k_x,k_y,k_z)$ is called the wavevector, and is the vector analogue of the wavenumber.

As before, the wavefunction $\psi(\mathbf{r})$ is an eigenfunction of $\hat{p}$ with an eigenvalue of the three-dimensional momentum,

\begin{align*}
  \hat{p}e^{i\mathbf{k}\cdot\mathbf{r}}&=-i\hbar\nabla e^{i\mathbf{k}\cdot\mathbf{r}}\\
                                       &=\hbar\mathbf{k} e^{i\mathbf{k}\cdot\mathbf{r}}\\
                                       &=\mathbf{p}e^{i\mathbf{k}\cdot\mathbf{r}}\\
\end{align*}

We can write uncertainty relations for each orthogonal direction just as we could before, for example in the $y$-direction we can write $[\hat{y},\hat{p_y}]=i\hbar$ such that we can write our usual relation for the Heisenberg uncertainty principle, $\Delta y\Delta p_y \geq \hbar/2$. This is exactly the same in the $x$ and $y$ directions. However, note that if the observables are perpendicular to each other, such as the $x$-position and the $y$-momentum, there exists no uncertainty relation, as $[\hat{x},\hat{p_y}]=0$ which can be shown easily. This means that we can know both the momentum in one direction and the position in an orthogonal direction precisely and simultaneously.

\section{Solving the Schr\"{o}dinger Equation in 3-D: Infinite Potential Box}

Consider a particle confined to a cuboid potential, with sides length $a$, $b$, $c$, such that,

\begin{align*}
  V(\mathbf{r})=
  \begin{cases}
    0 & 0\leq x\leq a \\
    \dots & 0\leq y\leq b \\
    \dots & 0\leq z\leq c \\
    \infty & \text{elsewhere}
  \end{cases}
\end{align*}

This is perfectly analogous to the one dimensional infinite square well, just extended again into three independent directions. Outside the box the potential is infinite so there is no chance the particle will be there, and thus the wavefunction outside will be zero. Inside however the potential is zero, so the total energy will just be equal to the kinetic energy. Therefore by applying the kinetic energy operator $\hat{T}$,

\begin{align*}
  -\frac{\hbar^2}{2m}\nabla^2\psi(\mathbf{r}) &= -\frac{\hbar^2}{2m}\left(\frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2} + \frac{\partial^2}{\partial z^2}\right)\psi(\mathbf{r}) \\
                                              &= E\psi(\mathbf{r})
\end{align*}

There are no cross-dimensional terms as the energy is independent in each orthogonal direction, so we can separate the wavefunction in to a part for each direction,

\begin{align*}
  \psi(\mathbf{r})=X(x)Y(y)Z(z)
\end{align*}

and therefore we have three equations to solve of the form

\begin{align*}
  -\frac{\hbar^2}{2m} \frac{d^2 X(x)}{dx^2} = E_x X(x) \qquad 0\leq x\leq a
\end{align*}

The other two equation are the same but with the $y$ and $z$ coordinates instead. The total energy is written as $E=E_x+E_y+E_z$.

We already know the solutions as they are the same as an infinite square well in one dimension for each direction,

\begin{align*}
  X(x) = A_x\sin{\left(n_x\frac{\pi x}{a}\right)} \qquad n_x\in\mathbb{N}
\end{align*}

and similarly for the $y$ and $z$ directions. Note that the quantum number, $n_x$, can be different for each direction. There is no limitation that requires the quantum number to be the same in every direction! Note that this time we only have sine solutions, and we don't have solutions that switch between sine and cosine. This is because this our potential isn't symmetric about the origin, as one corner of the box is at the origin.

The full solution is then given by,

\begin{align*}
  \psi(\mathbf{r}) = A\sin{\left(\frac{n_x \pi}{a} x\right)}\sin{\left(\frac{n_y \pi}{b} y\right)}\sin{\left(\frac{n_z \pi}{c} z\right)}
\end{align*}

The coefficient of the coordinate in each sine is then just the wavenumber, for example $k_x = \frac{n_x \pi}{a}$. We can find the energy eigenvalues by applying the kinetic energy operator (the potential is zero inside the well) finding,

\begin{align*}
  E=E_x+E_y+E_z=\frac{\pi^2\hbar^2}{2m}\left(\frac{n_x^2}{a^2}+\frac{n_y^2}{b^2}+\frac{n_z^2}{c^2}\right)
\end{align*}

where each of the quantum numbers $n_x, n_y, n_z$ can vary independently.

\section{Solving the Schr\"{o}dinger Equation in 3-D: Infinite Potential Cube}

Consider the special case where the sides are all the same lengths, such that $a = b = c$, and we therefore have a symmetric potential box. Note how now, different combinations of $n_x$, $n_y$, $n_z$ will give us the same energy eigenvalues. This is called degeneracy. We will explore how this degeneracy occurs for each excited state,

\addvbuffer[12pt 8pt]{\begin{tabular}{l c c c}
  State & $(n_x, n_y, n_z)$ & $E$ & Degeneracy value \\[6pt]
  Ground state & $(1, 1, 1)$ & $\frac{3\pi^2\hbar^2}{2ma^2}$ & $1$ \\[6pt]
  First excited state & $(2, 1, 1)$ & $\frac{6\pi^2\hbar^2}{2ma^2}$ & $3$ \\
  & $(1, 2, 1)$ & \\
  & $(1, 1, 2)$ & \\[6pt]
  Second excited state & $(2, 2, 1)$ & $\frac{9\pi^2\hbar^2}{2ma^2}$ & $6$ \\
  & $(2, 1, 2)$ & \\
  & $(1, 2, 2)$ & \\
  & $(1, 1, 3)$ & \\
  & $(1, 3, 1)$ & \\
  & $(3, 1, 1)$ & \\[6pt]
  Third excited state & $(2, 2, 2)$ & $\frac{12\pi^2\hbar^2}{2ma^2}$ & $1$
\end{tabular}}

Note that the number of eigenstates with the same energy is called the degeneracy value, and that this degeneracy is due to the symmetry of the potential.

\section{Angular Momentum}

We have not come across angular momentum before as it is a phenomenon which only appears in three dimensions, so we will not have seen it in one-dimension. Classically we define the angular momentum as the cross product of the lever arm distance with the linear momentum,

\begin{align*}
  \mathbf{L} = \mathbf{r}\times\mathbf{p}
\end{align*}

or written in determinant form,

\begin{align*}
  \mathbf{L} =
  \begin{vmatrix}
    i & j & k \\
    x & y & z \\
    p_x & p_y & p_z
  \end{vmatrix}
\end{align*}

Therefore the components of the angular momentum in each Cartesian direction are given by,

\begin{align*}
  L_x &= yp_z - zp_y \\
  L_y &= zp_x - xp_z \\
  L_z &= xp_y - yp_x
\end{align*}

This can be written in operator form using the momentum operator $\hat{p_x} = -i\hbar\frac{\partial}{\partial x}$,

\begin{align*}
  \hat{L_x} &= -i\hbar\left(y\frac{\partial}{\partial z}-z\frac{\partial}{\partial y}\right) \\
  \hat{L_y} &= -i\hbar\left(z\frac{\partial}{\partial x}-x\frac{\partial}{\partial z}\right) \\
  \hat{L_z} &= -i\hbar\left(x\frac{\partial}{\partial y}-y\frac{\partial}{\partial x}\right)
\end{align*}

Now that we know what form our angular momentum operators take, the next equation is, how well can we measure each component simultaneously? To know this we find the commutator,

\begin{align*}
  [\hat{L_x}, \hat{L_y}] &= \hat{L_x}\hat{L_y} - \hat{L_y}\hat{L_x} \\
                         &= -\hbar^2\left\{\left(y\frac{\partial}{\partial z}-z\frac{\partial}{\partial y}\right)\left(z\frac{\partial}{\partial x}-x\frac{\partial}{\partial z}\right)-\left(z\frac{\partial}{\partial x}-x\frac{\partial}{\partial z}\right)\left(y\frac{\partial}{\partial z}-z\frac{\partial}{\partial y}\right)\right\} \\
                         &= -\hbar^2\left\{y\frac{\partial}{\partial x}-x\frac{\partial}{\partial y}\right\} \\
                         &= i\hbar\hat{L_z}
\end{align*}

Similarly, for the other components,

\begin{align*}
  [\hat{L_y}, \hat{L_z}] &= i\hbar\hat{L_x} \\
  [\hat{L_z}, \hat{L_x}] &= i\hbar\hat{L_y}
\end{align*}

Therefore, we see that no two components of the angular momentum commute. This shows us that we can only know one component exactly, and therefore we cannot know $\mathbf{L} = (L_x, L_y, L_z)$ precisely, and cannot know which direction $\mathbf{L}$ points in.

What about the magnitude, $\hat{L^2} = \hat{L_x^2} + \hat{L_y^2} + \hat{L_z^2}$? This time we need to work out the commutator given by,

\begin{align*}
  [\hat{L^2}, \hat{L_z}] &= [\hat{L_x^2} + \hat{L_y^2} + \hat{L_z^2}, \hat{L_z}] \\
                         &= [\hat{L_x^2}, \hat{L_z}] + [\hat{L_y^2}, \hat{L_z}] + [\hat{L_z^2}, \hat{L_z}]
\end{align*}

We know that the last term is zero, as the commutator of an operator with itself is clearly guaranteed to be zero.

To find the rest we need a couple of useful commutator relations,

\begin{align*}
  [\hat{A}\hat{B}, \hat{C}] &= \hat{A}\hat{B}\hat{C}-\hat{C}\hat{A}\hat{B} \\
                            &= \hat{A}\hat{B}\hat{C}-\hat{A}\hat{C}\hat{B}+\hat{A}\hat{C}\hat{B}-\hat{C}\hat{A}\hat{B} \\
                            &= \hat{A}[\hat{B},\hat{C}]+[\hat{A},\hat{C}]\hat{B}
\end{align*}

and,

\begin{align*}
  [\hat{A},\hat{B}]=-[\hat{B},\hat{A}]
\end{align*}

Now we can calculate our first term, using these relations,

\begin{align*}
  [\hat{L_x^2}, \hat{L_z}] &= [\hat{L_x}\hat{L_x}, \hat{L_z}] \\
                           &= \hat{L_x}[\hat{L_x}, \hat{L_z}] + [\hat{L_x}, \hat{L_z}]\hat{L_x} \\
                           &= \hat{L_x}(-i\hbar\hat{L_y}) + (-i\hbar\hat{L_y})\hat{L_x} \\
                           &= -i\hbar(\hat{L_x}\hat{L_y} + \hat{L_y}\hat{L_x}) \neq 0
\end{align*}

And the second term, similarly,

\begin{align*}
  [\hat{L_y^2}, \hat{L_z}] &= [\hat{L_y}\hat{L_y}, \hat{L_z}] \\
                           &= \hat{L_y}[\hat{L_y}, \hat{L_z}] + [\hat{L_y}, \hat{L_z}]\hat{L_y} \\
                           &= \hat{L_y}(-i\hbar\hat{L_x}) + (-i\hbar\hat{L_x})\hat{L_y} \\
                           &= i\hbar(\hat{L_y}\hat{L_x} + \hat{L_x}\hat{L_y}) = -[\hat{L_x^2}, \hat{L_z}]
\end{align*}

We therefore find by adding each term together the commutator for the magnitude of the angular momentum and the $z$-component,

\begin{align*}
  [\hat{L^2}, \hat{L_z^2}] &= -i\hbar(\hat{L_x}\hat{L_y}+\hat{L_y}\hat{L_x}) + i\hbar(\hat{L_x}\hat{L_y}+\hat{L_y}\hat{L_x}) + 0 \\
                           &= 0
\end{align*}

Therefore we can know both the magnitude of the angular momentum and the $z$-component simultaneously and precisely. Similarly this is true for the $x$ and $y$-components as well which can be shown by calculating their commutators. Therefore we see that since $\hat{L^2}$ commutes with each of $\hat{L_x}$, $\hat{L_y}$, and $\hat{L_z}$, then $\hat{L^2}$ shares a set of simultaneous eigenfunctions with $\hat{L_x}$, $\hat{L_y}$, and $\hat{L_z}$. However there is a different set of eigenfunctions for each component as $\hat{L_x}$, $\hat{L_y}$, and $\hat{L_z}$ do not commute with each other in any order. Therefore we can know precisely the value of $L^2$ but can only know a single component of $\mathbf{L}$. For simplicity we choose the $L_z$ component as that single component as it has the simplest form in spherical polar coordinates.

\section{Central Potentials}

A central potential is defined such that the potential energy is only dependent on the radial distance from the origin. This is the same as a Coulomb potential due to point-like electric charge. This is much simpler to work out in spherical polar coordinates, so we will transform our potential into spherical polars. Since our potential is just a function of the radial distance, it is just a function of the spherical polar coordinate $r$.

The Cartesian coordinates can be written in terms of the spherical polar coordinates using the following relations,

\begin{align*}
  x &= r\sin{\theta}\cos{\phi} \\
  y &= r\sin{\theta}\sin{\phi} \\
  z &= r\cos{\theta}
\end{align*}

We call $\theta$ the polar angle, and $\phi$ the azimuthal angle.

The $z$-component of the angular momentum can be written in the form (which will be proven),

\begin{align*}
  \hat{L_z} &= -i\hbar\left(x\frac{\partial}{\partial y}-y\frac{\partial}{\partial x}\right) \\
            &= -i\hbar\frac{\partial}{\partial\phi}
\end{align*}

This is because rotation about the axis is not dependent on the polar angle $\theta$.

We can show that this is true by finding $\frac{\partial}{\partial\phi}$ in terms of $\frac{\partial}{\partial x}$, $\frac{\partial}{\partial y}$, $\frac{\partial}{\partial z}$. By using the chain rule we see that,

\begin{align*}
  \frac{\partial}{\partial\phi}=\frac{\partial}{\partial x}\frac{\partial x}{\partial\phi}+\frac{\partial}{\partial y}\frac{\partial y}{\partial\phi}+\frac{\partial}{\partial z}\frac{\partial z}{\partial\phi}
\end{align*}

The last term is clearly zero as the $z$-component has no dependence on the azimuthal angle $\phi$. We now need to calculate each of the partial derivatives,

\begin{alignat*}{2}
  \frac{\partial x}{\partial\phi} &= -r\sin{\theta}\sin{\phi} &&= -y \\
  \frac{\partial y}{\partial\phi} &= r\sin{\theta}\cos{\phi}  &&= x \\
\end{alignat*}

Therefore we see that $\frac{\partial}{\partial\phi}$ is indeed such that,

\begin{align*}
  \hat{L_z}=-i\hbar\left(x\frac{\partial}{\partial y}-y\frac{\partial}{\partial x}\right)=-i\hbar\frac{\partial}{\partial\phi}
\end{align*}

$\hat{L_z}$ has the simplest form in spherical polar coordinates, which is why we chose it earlier when talking about the commutator. For reference here I will also write $\hat{L_x}$ and $\hat{L_y}$ in spherical polar coordinates, but I will not derive them,

\begin{align*}
  \hat{L_x} &= i\hbar\left(\sin{\phi}\frac{\partial}{\partial\theta}+\cot{\theta}\cos{\phi}\frac{\partial}{\partial\phi}\right) \\
  \hat{L_y} &= i\hbar\left(-\cos{\phi}\frac{\partial}{\partial\theta}+\cot{\theta}\sin{\phi}\frac{\partial}{\partial\phi}\right) \\
\end{align*}

and the magnitude is given by,

\begin{align*}
  \hat{L^2} = -\hbar^2\left(\frac{1}{\sin{\theta}}\frac{\partial}{\partial\theta}\left(\sin{\theta}\frac{\partial}{\partial\theta}\right)+\frac{1}{\sin^2{\theta}}\frac{\partial^2}{\partial\phi^2}\right)
\end{align*}

Note that all of them are dependent on both the polar and azimuthal angle except for the $z$-component of the angular momentum which is only dependent on the azimuthal angle. \textit{We are not expected to memorise these formulae.}

\section{Single Electron Atom}

In this section will we will solve the time independent Schr\"{o}dinger equation for an electron in a central Coulomb potential given by,

\begin{align*}
  V(r) = \frac{q_1 q_2}{4\pi\epsilon_0 r}
\end{align*}

The charge $q_1 = Ze$ is the charge of the nucleus with atomic (proton) number $Z$. The charge $q_2 = -e$ is the charge of a single electron. Since there is only one electron this is a hydrogen-like atom.

Classically the electron and nucleus will rotate about a common centre-of-mass, such that the electron and nucleus are seperated by a distance $r$. However it is easier to assume that the mass of the nucleus goes to infinity. To keep the distance equal to $r$ we then have to decrease the mass of the electron to a reduced mass to shift the centre of mass back to where it was. This new mass is given by,

\begin{align*}
  \mu = \left(\frac{M}{M+m}\right) M
\end{align*}

where $m$ is the mass of the electron, and $M$ is the mass of the nucleus. The problem is now reduced to one particle moving in a Coulomb potential, and thus the time independent Schr\"{o}dinger equation becomes,

\begin{align*}
  \left(-\frac{\hbar^2}{2\mu}\nabla^2+V(r)\right)\psi(r,\theta,\phi)=E\psi(r,\theta,\phi)
\end{align*}

The Laplacian in spherical polar coordinates is given by,

\begin{align*}
  \nabla^2=\frac{1}{r^2}\frac{\partial}{\partial r}\left(r^2\frac{\partial}{\partial r}\right)+\frac{1}{r^2\sin{\theta}}\frac{\partial}{\partial\theta}\left(\sin{\theta}\frac{\partial}{\partial\theta}\right)+\frac{1}{r^2\sin^2{\theta}}\frac{\partial^2}{\partial\phi^2}
\end{align*}

For our solution we use seperation of variables again, but for each polar coordinate instead of each Cartesian coordinate,

\begin{align*}
  \psi(r, \theta, \phi) = R(r)\Theta(\theta)\Phi(\phi)
\end{align*}

This allows us to isolate each variable in turn so that instead of having one partial differential equation, which is extremely hard to solve, we have three ordinary differential equations to solve which is much easier. In this section we will not go through the entire procedure of solving these, we will only provide an outline. The full procedures can be found in Eisberg and Resnick chapter 7.

First we need to solve the azimuthal differential equation given by,

\begin{align*}
  \frac{d^2\Phi}{d\phi^2} = m^2\Phi
\end{align*}

Solutions therefore have the form $\Phi = Ae^{im\phi}$. We need to normalize this to find the constant. Our normalization will range over the entire range of the azimuthal angle, from $0$ to $2\pi$,

\begin{align*}
  \int_0^{2\pi}\Phi^*\Phi d\phi = 1 \to A = \frac{1}{\sqrt{2\pi}}
\end{align*}

We can show that $\Phi(\phi)$ is an eigenfunction of the angular momentum $z$-component,

\begin{align*}
  \hat{L_z}\Phi &= -i\hbar\frac{\partial}{\partial\phi}\frac{1}{\sqrt{2\pi}}e^{im\phi} \\
                &= m\hbar\Phi
\end{align*}

The eigenvalues of the angular momentum component $L_z$ are thus given by $m\hbar$.

Also, we know that the wavefunction $\Phi(\phi)$ must be periodic and is therefore single valued. This means that we can determine different allowed values of $m$ based on our boundary conditions. First we know that the boundaries must be equal for equal $m$, that is $\Phi_m(0)=\Phi_m(2\pi)$ because of periodicity. By plugging these values into our wavefunction we get,

\begin{align*}
  1 &= e^{im 2\pi} \\
  1 &= \cos(2\pi m) + i\sin(2\pi m)
\end{align*}

For this to be true, $m$ must be any integer. The rotation about the $z$-axis is therefore quantized. We can't just have any continuous rotation, it is discrete in nature.

Next we need to solve the polar equaiton, given by,

\begin{align*}
-\frac{1}{\sin{\theta}}\frac{d}{d\theta}\left(\sin{\theta}\frac{d}{d\theta}\Theta\right) + \frac{m^2\Theta}{\sin^2{\theta}} = l(l+1)\Theta
\end{align*}

Note that this is much more complicated to solve, which we won't do here. The solutions have the form,

\begin{align*}
  \Theta(\theta) = \sin^{|m|}F_{l|m|}(\cos{\theta})
\end{align*}

where $F_{l|m|}(\cos{\theta})$ are polynomials in $\cos{\theta}$.

Since $\hat{L^2}$ and $\hat{L_z}$ commute, they share a simultaneous set of eigenfunctions known as the spherical harmonics,

\begin{align*}
  \Upsilon_{lm}(\theta,\phi)=\Theta(\theta)\Phi(\phi)
\end{align*}

When we apply the $\hat{L^2}$ operator to this we get,

\begin{align*}
  \hat{L^2}\Upsilon_{lm} = l(l+1)\hbar^2\Upsilon_{lm}
\end{align*}

for $l = 0, 1, 2\dots$.

When we apply the $\hat{L_z}$ operator,

\begin{align*}
  \hat{L_z}\Upsilon_{lm} = m\hbar\Upsilon_{lm}
\end{align*}

for all integer $m$. Note that this is the same result as just acting on $\Phi(\phi)$ alone, this is because $\hat{L_z}$ is only dependent on the azimuthal angle.

We see from applying $\hat{L^2}$ to $\Upsilon_{lm}$ that $l(l+1)\hbar^2$ are eigenvalues of the square of the angular momentum magnitude. A relation can be found between the quantum numbers $l$ and $m$ by applying physical ideas.

\begin{align*}
  L_z^2 \leq L^2
\end{align*}

This must be true, as if there is any $L_x$ or $L_y$ component then the component $L_z$ must be smaller than the magnitude of $L$. If there is no $L_x$ or $L_y$ component, then the component $L_z$ must be \textit{equal} to the magnitude. By subsituting in the eigenvalues for $L_z$ and $L^2$,

\begin{align*}
  m^2\hbar^2 \leq l(l+1)\hbar^2
\end{align*}

Since both $m$ and $l$ are integers we can write,

\begin{align*}
  |m| \leq l
\end{align*}

We can check that this is true by checking two different values. First if $m = l$, then it implies that $l^2 \leq l^2 + l$, which is definitely true for all $l \geq 0$. What about if $m = l + 1$ breaking our equality by one? This would imply that $m^2 > l(l + 1)$ which is not physically possible as it would imply that $L_z > L$. Therefore we can be justified in saying $|m| \leq l$. This implies that,

\begin{align*}
  L_z^2 < L^2
\end{align*}

except for the special case where $l = 0$ and then $L_z^2 = L^2 = 0$. We therefore come to the conclusion that the angular momentum $\mathbf{L}$ cannot be aligned purely along the $z$-axis, that is, unless it is zero it must have an $x$ or $y$ component. This means we can never know the direction of $\mathbf{L}$ precisely.

Consider a specific quantum number $l = 2$. The magnitude squared of the angular momentum is thus given by $L^2 = 2(2+1)\hbar^2 = 6\hbar^2$. The magnitude of the angular momentum is therefore $|L| = \sqrt{6}\hbar$. The quantum numbers of $m$ can only be, due to our relation, $m = -2, -1, 0, 1, 2$, and therefore the $z$-component of the angular momentum can only take the values $L_z = 0, \pm\hbar, \pm 2\hbar$. See diagrams on Canvas for more detail.

Finally consider the solution to the radial equation. The radial differential equation is given by,

\begin{align*}
  \frac{1}{r^2}\frac{d}{dr}\left(r^2\frac{dR}{dr}\right)+\frac{2\mu}{\hbar^2}\left[E-V(r)\right]R=l(l+1)\frac{R}{r^2}
\end{align*}

where $\mu$ is the reduced mass from earlier and $R$ is our solution to the differential equation.

What we find is that we only have solutions when the energy $E$ is quantized, which takes the form,

\begin{align*}
  E_n = -\frac{\mu Z^2e^4}{{(4\pi\epsilon_0)}^2 2\hbar^2 n^2} = -\frac{13.6}{n^2} Z^2 eV
\end{align*}

In the second step all of the constants were calculated to the value of $13.6$. In the case of hydrogen there is only one proton so $Z = 1$. See Canvas for a diagram on the energy levels in the hydrogen atom.

The radial solutoins have the form,

\begin{align*}
  R_{nl}(r)=e^{-\frac{Zr}{na_0}}{\left(\frac{Zr}{a_0}\right)}^l G_{nl}\left(\frac{Zr}{a_0}\right)
\end{align*}

where $G_{nl}$ is a polynomial in $\left(\frac{Zr}{a_0}\right)$ of order $n - (l + 1)$. The constant $a_0 = \frac{4\pi\epsilon_0\hbar^2}{\mu e^2} = 0.529\times10^{-10} m$, which is known as the Bohr radius.

The first few unnormalized eigenfunctions are given by,

\begin{align*}
  R_{10} &\propto e^{-\frac{Zr}{a_0}} \\
  R_{20} &\propto \left(1-\frac{Zr}{2a_0}\right) e^{-\frac{Zr}{a_0}} \\
  R_{21} &\propto \frac{Zr}{a_0} e^{-\frac{Zr}{a_0}}
\end{align*}

We can use these eigenfunctions to find the radial probability density, as given by the square of the wavefunction as normal,

\begin{align*}
  P(r)dr = {|R_{nl}(r)|}^2 4\pi r^2 dr
\end{align*}

The wavefunction squared gives us the probability \textit{volume} density so we have to multiply by a value element as shown so we can get the probability density as a function of radius and not volume. See Canvas for plots of the probability density. There are a few things to note from these plots.

\begin{enumerate}
  \item $\langle r \rangle$ gets larger for higher values of $n$
  \item The ground states peaks at $r = a_0$ (Bohr radius) and for the state where $n > 1$ with $l = n - 1$ (maximum $l$) is peaks at $r = n^2a_0$
  \item There is an exponential tail which dominates as $r \to \infty$
\end{enumerate}

\section{Atomic Quantum Numbers}

To summarise we have three quantum numbers.

First we have $n$, the principle quantum number (also known as the radial or shell quantum number), this determines the energy $E$ of the electron. It is an integer.

Second we have $l$, the angular momentum quantum number. The values are restricted such that $0 \leq l < n$, where $l$ is an integer. The magnitude of the angular momentum can be calculated from $l$ by $|\mathbf{L}| = \sqrt{l(l+1)}\hbar$.

Finally we have $m$, the magnetic quantum number. This is constrained such that $|m| \leq l$, and is an integer. Multiplied by $\hbar$ it is the $z$-component of the angular momentum, $L_z = m\hbar$.

\section{Magnetic Moment}

An effect of a moving electronic charge is that a magnetic field appears. This is relevant since an orbiting charge is equivalent to a current loop, which induces a magnetic field as we know from electromagnetism. We define the magnetic dipole moment as the current multiplied by the area of the loop,

\begin{align*}
  \mu &= I \pi r^2 \\
      &= \left(-\frac{eV}{2\pi r}\right) \times \pi r^2 \\
      &= -\frac{eVr}{2}
\end{align*}

Since we know that the angular momentum $L = r m_e v$ since $r$ is perpendicular to $v$, by rearranging for $v$ we can rewrite the magnetic dipole moment as,

\begin{align*}
  \mu = -\frac{eL}{2m_e}
\end{align*}

We will write this in the form,

\begin{align*}
  \mu_l = -\frac{g_l \mu_B}{\hbar} L
\end{align*}

where $\mu_B$, called the Bohr magneton, is defined as $\mu_B = \frac{e\hbar}{2m_e}$. In this case the symbol $g_L = 1$, and is called the orbital g factor.

We saw in the last section that we can write the angular momentum in terms of the angular momentum quantum number, $L = \sqrt{l(l+1)} \hbar$, so we can write the magnetic monopole moment as $\mu_l = -g_l \mu_B \sqrt{l(l+1)}$.

Since we know we can know both $|L|$ and $L_z$ simultaneously as seen in the earlier sections, we can see that we can also know $|u_l|$ and ${(u_l)}_z$. To measure the $z$ component we need a non-uniform magnetic field, for more information on this see the Stern Gerlach experiment, as well as the notes on Canvas. If we have a uniform $B$-field a torque is produced, but in a non-uniform $B$-field we also have a net linear force (up or down) following $F \propto m_l \frac{\partial B_z}{z}$.

\section{Ground State Hydrogen}

We will now consider the simplest case of the electronic configuration of a ground state hydrogen atom. Remember our restrictions for the quantum numbers. In this case we have $n = 1$ and thus $l = 0$ and $m_l = 0$. Therefore we have an angular momentum of zero $L = L_z = 0$. This means that we have no magnetic moment and thus no deflection. However experimentally we still find that there are two spots on the detector which can \textit{only} be explained by there being some kind of angular momentum present as deflection is occuring, but we have just shown that there is no angular momentum as predicted by Schr\"{o}dingers wavefunction view. There can only be one reasonable conclusion, and it is an important one: \textit{the electron has an instrinsic angular momentum}, that is, it always has some kind of internal angular momentum which we call spin, and behaves similarly to the orbital angular momentum which we expected to be required for the deflection.

The spin is defined by the spin quantum number $s$ in the same way that the orbital angular momentum is defined,

\begin{align*}
  |\mathbf{s}| &= \sqrt{s(s+1)}\hbar \\
  s_z &= m_s \hbar \\
  |m_s| &\leq s \\
  {(\mu_s)}_z &= -g_s \mu_b m_s
\end{align*}

We have defined a set of equations that are analogous (in fact pretty much the same) as our equations for the angular momentum $L$, but for the spin instead. If we have a spin quantum number $s = \frac{1}{2}$, we have a $z$-component $s_z = \pm \frac{1}{2}\hbar$ which refers to the spin having an up and down component simultaneously. The $g$ factor would therefore be $g_s = 2$.

We have that electrons are fermions, meaning that they have spins as integer multiples of $\frac{1}{2}\hbar$, this means that the Pauli exclusion principle applies, meaning that no two identical fermions (in this case electrons) can occupy the same quantum state. Quantum state means a single selection of quantum numbers, so no two electrons can have all quantum numbers the same. Since in our case $m_s = \pm \frac{1}{2}$, two electrons can occupy each magnetic substate.

Now the information is available, using the restriction on quantum numbers, to construct a table of the energy states in an atom. We can do this by placing our constraints on the quantum numbers, and them figuring out how many different combinations of $n$, $l$, $m_l$, and $m_s$ we can have. For example in the first one, we can have $n = 1$, $l = 0$, $m_l = 0$, but $m_s = \pm \frac{1}{2}$, so the only quantum number that can differ is that we can have two different values of $m_s$ so we can have two electrons in the $n = 1$ shell. All of the other combinations are found this way for the higher values of $n$.

\addvbuffer[12pt 8pt]{\begin{tabular}{l l l l l}
    Elements & $n$ & $l<n$ & $|m_l|\leq l$ & $m_s = \pm\frac{1}{2}$ \\[6pt]
    H, He & $1$ & $0$ & $0$ & 2 electrons fit \\

    Li thru Ne & $2$ & $0$ & $0$ & 8 electrons fit \\
           & & $1$ & $0, \pm 1$ \\[6pt]

    Na thru Ar & $3$ & $0$ & $0$ & 18 electrons fit \\
               & & $1$ & $0, \pm 1$ \\
               & & $2$ & $0, \pm 1, \pm 2$ \\[6pt]
\end{tabular}}

In spectroscopic notation we write the shells in the form,

\addvbuffer[12pt 8pt]{\begin{tabular}{l l l l l}
    $n = 1$ & $l = 0$ & 1s \\
    $n = 2$ & $l = 0$ & 2s \\
            & $l = 1$ & 2p \\
    $n = 3$ & $l = 0$ & 3s \\
            & $l = 1$ & 3p \\
            & $l = 2$ & 3d
\end{tabular}}

For each value of $n$ we see that there are $n$ values of $l$ possible, and $2l + 1$ values of $m_l$ possible.

\section{Total Angular Momentum}

The angular momentum $\mathbf{L}$ and spin $\mathbf{s}$ can be combined to give us the \textit{total} angular momentum $\mathbf{J}$ by summing them,

\begin{align*}
  \mathbf{J} &= \mathbf{L} + \mathbf{S} \\
  |\mathbf{J}| &= \sqrt{j(j+1)}\hbar \\
  j &\geq 0 \\
  J_z &= m_j \hbar \\
  |m_j| &\leq j \\
\end{align*}

$J_z$ is a scalar quantity defined by $J_z = L_z + S_z$, and $m_j = m_l + m_s$. In this case we have two possible values of $j$. Either $s = \frac{1}{2}$ and thus $j = l + s = l + \frac{1}{2}$ signifying that the angular momentum $\mathbf{L}$ is parallel and in the same direction as the spin $\mathbf{s}$. Or $s = -\frac{1}{2}$ and $j = l - \frac{1}{2}$ and $\mathbf{L}$ is parallel and in the \textit{opposite} direction to the spin $\mathbf{s}$.

\end{document}


\problemname{Train Tickets}
The Stockholm public transport system offers $12$ kinds of tickets for purchase.
The $i$'th kind of ticket is valid for exactly $i$ consecutive months.
However, they also change the price of every kind of ticket every year.

Katriel has access to the pricing data for the last $N$ years, and is currently studying the complexity of purchasing your tickets in order to minimize costs.
More precisely he wants to determine, given an interval of years $a, a + 1, \dots, b$, what the cost is to purchase tickets starting from January in year $a$ that are valid every month to December in year $b$.
Can you write a program to determine this?

\section*{Input}
The first line of input contains the integer $1 \le N \le 30\,000$, the number of years Katriel has pricing data for.
The next $N$ lines contain the pricing data for years $1, 2, \dots, N$, in order.
The pricing data for a given year is given as $12$ integers: the prices of the tickets valid for $1, 2, \dots, 12$ months, respectively.
All prices are between $0$ and $10\,000$.

The next line contains the integer $1 \le Q \le 3\,000$, the number of intervals of years Katriel wishes to compute the price for.
The next $Q$ lines contains each of these intervals, given as two integers $1 \le a \le b \le N$ representing the interval $a, a + 1, \dots, b$.

In a given year, a ticket valid for a longer period of time is never cheaper than a ticket valid for a shorter period of time.

\section*{Output}
For each query $a, b$, output a single line containing the minimum cost to purchase tickets valid during the entire interval, given that the first ticket is bought in January in year $a$.