\documentclass[paper=a4, fontsize=11pt]{scrartcl} % A4 paper and 11pt font size
\usepackage{physics}
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\usepackage{fourier} % Use the Adobe Utopia font for the document - comment this line to return to the LaTeX default
\usepackage[english]{babel} % English language/hyphenation
\usepackage{amsmath,amsfonts,amsthm} % Math packages
\usepackage{braket}
\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{sectsty} % Allows customizing section commands
\allsectionsfont{\centering \normalfont\scshape} % Make all sections centered, the default font and small caps
\usepackage[mathscr]{euscript}
\usepackage{bm}
\newcommand{\uvec}[1]{\boldsymbol{\hat{\textbf{#1}}}}
\usepackage[thinlines]{easytable}
\usepackage{fancyhdr} % Custom headers and footers
\pagestyle{fancyplain} % Makes all pages in the document conform to the custom headers and footers
\fancyhead{} % No page header - if you want one, create it in the same way as the footers below

\usepackage{multicol}
\fancyfoot[L]{} % Empty left footer
\fancyfoot[C]{} % Empty center footer
\fancyfoot[R]{\thepage} % Page numbering for right footer
\renewcommand{\headrulewidth}{0pt} % Remove header underlines
\renewcommand{\footrulewidth}{0pt} % Remove footer underlines
\setlength{\headheight}{13.6pt} % Customize the height of the header
\usepackage{float}
\numberwithin{equation}{section} % Number equations within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)
\numberwithin{figure}{section} % Number figures within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)
\numberwithin{table}{section} % Number tables within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)

\setlength\parindent{0pt} % Removes all indentation from paragraphs - comment this line for an assignment with lots of text
\usepackage{pgfplots}

\pgfplotsset{
  compat=newest,
  xlabel near ticks,
  ylabel near ticks
}
%----------------------------------------------------------------------------------------
%	TITLE SECTION
%----------------------------------------------------------------------------------------

\newcommand{\horrule}[1]{\rule{\linewidth}{#1}} % Create horizontal rule command with 1 argument of height

\title{
\normalfont \normalsize
\textsc{California State University San Marcos \\ Dr. De Leone, Physics 323} \\ [25pt] % Your university, school and/or department name(s)
\horrule{0.5pt} \\[0.4cm] % Thin top horizontal rule
\huge H.W. 4 \\ % The assignment title
\horrule{2pt} \\[0.5cm] % Thick bottom horizontal rule
}

\author{Josh Lucas} % Your name

\date{\normalsize\today} % Today's date or a custom date

\begin{document}

\maketitle % Print the title

%----------------------------------------------------------------------------------------
%	PROBLEM 1
%----------------------------------------------------------------------------------------

\section*{Problem 1.6}
\textbf{A beam of spin-1/2 particles is prepared in the state}
$$ \ket{\psi} = \frac{2}{\sqrt{13}} \ket{+}_x + i \frac{3}{\sqrt{13}} \ket{-}_x$$
\textbf{a) What are the possible results of a measurement of the spin component $S_z$, and with what probabilities would they occur?}\\
We know that the relation for state vectors in the x direction is  $\ket{\pm}_x = \frac{1}{\sqrt{2}} \big [ \ket{+} \pm \ket{-} \big ]$ which we can substitute in our probability equation,
\begin{align*}
\mathscr{P_+} & = \bigg | \bra{+} \big \{ \tfrac{2}{\sqrt{13}} \big ( \tfrac{1}{\sqrt{2}} \big [ \ket{+} + \ket{-} \big ] \big ) +  \tfrac{3}{\sqrt{13}} \big ( \tfrac{1}{\sqrt{2}}   \big [ \ket{+} + \ket{-}  \big ]\big ) \big \} \bigg |^2 \\
& = \bigg |  \tfrac{2}{\sqrt{26}} \braket{+|+} + i\tfrac{3}{\sqrt{26}} \braket{+|+} \bigg |^2 \\
& = \bigg | \tfrac{2}{\sqrt{26}} + i\tfrac{3}{\sqrt{26}} \bigg |^2 \\
\mathscr{P_+} & = \tfrac{13}{26} = \tfrac{1}{2}
\end{align*}
\begin{align*}
\mathscr{P_-} & = \bigg | \bra{-} \big \{ \tfrac{2}{\sqrt{13}} \big ( \tfrac{1}{\sqrt{2}} \big [ \ket{+} - \ket{-} \big ] \big ) +  \tfrac{3}{\sqrt{13}} \big ( \tfrac{1}{\sqrt{2}}   \big [ \ket{+} - \ket{-}  \big ]\big ) \big \} \bigg |^2 \\
& = \bigg |  \tfrac{2}{\sqrt{26}} \braket{-|-} - i\tfrac{3}{\sqrt{26}} \braket{-|-} \bigg |^2 \\
& = \bigg | \tfrac{2}{\sqrt{26}} - i\tfrac{3}{\sqrt{26}} \bigg |^2 \\
\mathscr{P_-} & = \tfrac{13}{26} = \tfrac{1}{2}
\end{align*}
\textbf{b) What are the possible results of a measurement of the spin component $S_x$, and with what probabilities would they occur?}
 \begin{multicols}{2}
 \noindent
\begin{align*}
\mathscr{P_+} & = \bigg |  \braket{+_x|\psi} \bigg|^2 \\
& = \bigg | \bra{+} \bigg \{ \tfrac{2}{\sqrt{13}}\ket{+} + i\tfrac{3}{\sqrt{13}}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  \tfrac{2}{\sqrt{13}}\braket{+|+}  \bigg |^2 \\
  & = \bigg |  \tfrac{2}{\sqrt{13}} \bigg |^2 \\
  \mathscr{P_+} & = \frac{4}{13}
  \end{align*}
   \begin{align*}
\mathscr{P_-} & = \bigg |  \braket{+_x|\psi} \bigg|^2 \\
& = \bigg | \bra{-} \bigg \{ \tfrac{2}{\sqrt{13}}\ket{+} - i\tfrac{3}{\sqrt{13}}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  \tfrac{3i}{\sqrt{13}}\braket{-|-}  \bigg |^2 \\
  & = \bigg |  \tfrac{3i}{\sqrt{13}} \bigg |^2 \\
  \mathscr{P_-} & = \frac{9}{13}
  \end{align*}
  \end{multicols}

  \textbf{c) Plot histograms of the predicted measurement results from parts (a) and (b).} \\
  \\
   \begin{tikzpicture}
    \begin{axis}[
      ybar,
      bar width=15pt,
      xlabel={$S_z$},
      ylabel={Probability},
      ymin=0,
      ymax =100,
      ytick=\empty,
      xtick=data,
      axis x line=bottom,
      axis y line=left,
      enlarge x limits=0.2,
      symbolic x coords={ $ + \frac{\hbar}{2}$, $ - \frac{\hbar}{2}$ },
      xticklabel style={anchor=base,yshift=-\baselineskip},
      nodes near coords={\pgfmathprintnumber\pgfplotspointmeta\%}
    ]
      \addplot[fill=white] coordinates {
        ($ + \frac{\hbar}{2}$,50)
        ($ - \frac{\hbar}{2}$,50)
      };
    \end{axis}
  \end{tikzpicture}
     \begin{tikzpicture}
    \begin{axis}[
      ybar,
      bar width=15pt,
      xlabel={$S_x$},
      ylabel={Probability},
      ymin=0,
      ymax =100,
      ytick=\empty,
      xtick=data,
      axis x line=bottom,
      axis y line=left,
      enlarge x limits=0.2,
      symbolic x coords={ $ + \frac{\hbar}{2}$, $ - \frac{\hbar}{2}$ },
      xticklabel style={anchor=base,yshift=-\baselineskip},
      nodes near coords={\pgfmathprintnumber\pgfplotspointmeta\%}
    ]
      \addplot[fill=white] coordinates {
        ($ + \frac{\hbar}{2}$,30.77)
        ($ - \frac{\hbar}{2}$,69.23)
      };
    \end{axis}
  \end{tikzpicture}

\section*{Problem 1.10}
\textbf{Consider the three quantum states:}
\begin{align*}
\ket{\psi_1} & = \tfrac{4}{5} \ket{+} + i\tfrac{3}{5} \ket{-} \\
\ket{\psi_2} & = \tfrac{4}{5} \ket{+} - i\tfrac{3}{5} \ket{-} \\
\ket{\psi_1} & = - \tfrac{4}{5} \ket{+} + i\tfrac{3}{5} \ket{-}
\end{align*}
\textbf{a) For each of the $\ket{\psi}$ above, calculate the probabilities of spin component measurements
along the x-, y-, and z-axes.}\\
\\
%%%%%xxxxxxxxxxxx%%%%%%%%%%%%%%%%%%%%%%%
 \begin{multicols}{2}
 \noindent
\begin{align*}
\mathscr{P_+}_x & = \bigg | \braket{+_x|\psi_1} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}}\bra{+} + \bra{-} \bigg \{ \tfrac{4}{5}\ket{+} + i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  \tfrac{4}{5\sqrt{2}}\braket{+|+} + i\tfrac{3}{5\sqrt{2}} \braket{-|-}  \bigg |^2 \\
  & = \bigg |  \tfrac{4}{5\sqrt{2}} + i\tfrac{3}{5\sqrt{2}} \bigg |^2 \\
  \mathscr{P_+}_x & = \tfrac{25}{50} = \tfrac{1}{2}
  \end{align*}
   \begin{align*}
\mathscr{P_-} & = \bigg |  \braket{-_x|\psi_1} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}} \bra{+} -\bra{-} \bigg \{ \tfrac{4}{5}\ket{+} + i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  \tfrac{4}{5\sqrt{2}}\braket{+|+} - i\tfrac{3}{5\sqrt{2}} \braket{-|-}  \bigg |^2 \\
 & = \bigg |  \tfrac{4}{5\sqrt{2}} - i\tfrac{3}{5\sqrt{2}} \bigg |^2 \\
  \mathscr{P_-}_x & = \tfrac{25}{50} = \tfrac{1}{2}
  \end{align*}
  \end{multicols}
  %%%%%%%%%YYYYYYYYYYYYYYYYY%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   \begin{multicols}{2}
 \noindent
\begin{align*}
\mathscr{P_+}_y & = \bigg | \braket{+_y|\psi_1} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}}\bra{+} - i\bra{-} \bigg \{ \tfrac{4}{5}\ket{+} + i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  \tfrac{4}{5\sqrt{2}}\braket{+|+} - i^2\tfrac{3}{5\sqrt{2}} \braket{-|-}  \bigg |^2 \\
  & = \bigg |  \tfrac{4}{5\sqrt{2}} + \tfrac{3}{5\sqrt{2}} \bigg |^2 \\
  \mathscr{P_+}_y & = \tfrac{49}{50}
  \end{align*}
   \begin{align*}
\mathscr{P_-}_Y & = \bigg |  \braket{-_y|\psi_1} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}} \bra{+} + i \bra{-} \bigg \{ \tfrac{4}{5}\ket{+} + i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  \tfrac{4}{5\sqrt{2}}\braket{+|+} + i^2\tfrac{3}{5\sqrt{2}} \braket{-|-}  \bigg |^2 \\
 & = \bigg |  \tfrac{4}{5\sqrt{2}} - \tfrac{3}{5\sqrt{2}} \bigg |^2 \\
  \mathscr{P_-}_y & = \tfrac{1}{50}
  \end{align*}
  \end{multicols}
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Zzzzzzz%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   \begin{multicols}{2}
 \noindent
\begin{align*}
\mathscr{P_+}_z & = \bigg | \braket{+_z|\psi_1} \bigg|^2 \\
& = \bigg | \bra{+}  \bigg \{ \tfrac{4}{5}\ket{+} + i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  \tfrac{4}{5}\braket{+|+}  \bigg |^2 \\
  & = \bigg |  \tfrac{4}{5} \bigg |^2 \\
  \mathscr{P_+}_z & = \tfrac{16}{25}
  \end{align*}
   \begin{align*}
\mathscr{P_-}_z & = \bigg |  \braket{-_z|\psi_1} \bigg|^2 \\
& = \bigg |  \bra{-} \bigg \{ \tfrac{4}{5}\ket{+} + i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |    i\tfrac{3}{5} \braket{-|-}  \bigg |^2 \\
 & = \bigg |  i \tfrac{3}{5} \bigg |^2 \\
  \mathscr{P_-}_z & = \tfrac{9}{25}
  \end{align*}
  \end{multicols}\horrule{2pt}
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %%%%%%%%%%%%%%%%%%BBBB%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   \begin{multicols}{2}
 \noindent
\begin{align*}
\mathscr{P_+}_x & = \bigg | \braket{+_x|\psi_2} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}}\bra{+} + \bra{-} \bigg \{ \tfrac{4}{5}\ket{+} - i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  \tfrac{4}{5\sqrt{2}}\braket{+|+} - i\tfrac{3}{5\sqrt{2}} \braket{-|-}  \bigg |^2 \\
  & = \bigg |  \tfrac{4}{5\sqrt{2}} - i\tfrac{3}{5\sqrt{2}} \bigg |^2 \\
  \mathscr{P_+}_x & = \tfrac{25}{50} = \tfrac{1}{2}
  \end{align*}
   \begin{align*}
\mathscr{P_-} & = \bigg |  \braket{-_x|\psi_2} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}} \bra{+} -\bra{-} \bigg \{ \tfrac{4}{5}\ket{+} - i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  \tfrac{4}{5\sqrt{2}}\braket{+|+} + i\tfrac{3}{5\sqrt{2}} \braket{-|-}  \bigg |^2 \\
 & = \bigg |  \tfrac{4}{5\sqrt{2}} + i\tfrac{3}{5\sqrt{2}} \bigg |^2 \\
  \mathscr{P_-}_x & = \tfrac{25}{50} = \tfrac{1}{2}
  \end{align*}
  \end{multicols}
  %%%%%%%%%YYYYYYYYYYYYYYYYY%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{multicols}{2}
\noindent
	\begin{align*}
\mathscr{P_+}_y & = \bigg | \braket{+_y|\psi_2} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}}\bra{+} - i\bra{-} \bigg \{ \tfrac{4}{5}\ket{+} - i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  \tfrac{4}{5\sqrt{2}}\braket{+|+} + \tfrac{3i^2}{5\sqrt{2}} \braket{-|-}  \bigg |^2 \\
  & = \bigg |  \tfrac{4}{5\sqrt{2}} - \tfrac{3}{5\sqrt{2}} \bigg |^2 \\
  \mathscr{P_+}_y & = \tfrac{1}{50}
  \end{align*}
  \begin{align*}
\mathscr{P_-}_Y & = \bigg |  \braket{-_y|\psi_2} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}} \bra{+} + i \bra{-} \bigg \{ \tfrac{4}{5}\ket{+} - i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  \tfrac{4}{5\sqrt{2}}\braket{+|+} - \tfrac{3i^2}{5\sqrt{2}} \braket{-|-}  \bigg |^2 \\
 & = \bigg |  \tfrac{4}{5\sqrt{2}} + \tfrac{3}{5\sqrt{2}} \bigg |^2 \\
  \mathscr{P_-}_y & = \tfrac{49}{50}
  \end{align*}
\end{multicols}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Zzzzzzz%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{multicols}{2}
\noindent
	\begin{align*}
\mathscr{P_+}_z & = \bigg | \braket{+_z|\psi_2} \bigg|^2 \\
& = \bigg | \bra{+}  \bigg \{ \tfrac{4}{5}\ket{+} - i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  \tfrac{4}{5}\braket{+|+}  \bigg |^2 \\
  & = \bigg |  \tfrac{4}{5} \bigg |^2 \\
  \mathscr{P_+}_z & = \tfrac{16}{25}
	\end{align*}
	\begin{align*}
\mathscr{P_-}_z & = \bigg |  \braket{-_z|\psi_2} \bigg|^2 \\
& = \bigg |  \bra{-} \bigg \{ \tfrac{4}{5}\ket{+} - i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  -  i\tfrac{3}{5} \braket{-|-}  \bigg |^2 \\
 & = \bigg | - i \tfrac{3}{5} \bigg |^2 \\
  \mathscr{P_-}_z & = \tfrac{9}{25}
	\end{align*}
\end{multicols}
%%%%%%%%%%%%%%%%%%%%%%%33333
\horrule{2pt}
 \begin{multicols}{2}
 \noindent
\begin{align*}
\mathscr{P_+}_x & = \bigg | \braket{+_x|\psi_3} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}}\bra{+} + \bra{-} \bigg \{ -\tfrac{4}{5}\ket{+} + i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  -\tfrac{4}{5\sqrt{2}}\braket{+|+} + i\tfrac{3}{5\sqrt{2}} \braket{-|-}  \bigg |^2 \\
  & = \bigg | - \tfrac{4}{5\sqrt{2}} + i\tfrac{3}{5\sqrt{2}} \bigg |^2 \\
  \mathscr{P_+}_x & = \tfrac{25}{50} = \tfrac{1}{2}
  \end{align*}
   \begin{align*}
\mathscr{P_-} & = \bigg |  \braket{-_x|\psi_3} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}} \bra{+} -\bra{-} \bigg \{- \tfrac{4}{5}\ket{+} + i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  -\tfrac{4}{5\sqrt{2}}\braket{+|+} - i\tfrac{3}{5\sqrt{2}} \braket{-|-}  \bigg |^2 \\
 & = \bigg |  -\tfrac{4}{5\sqrt{2}} - i\tfrac{3}{5\sqrt{2}} \bigg |^2 \\
  \mathscr{P_-}_x & = \tfrac{25}{50} = \tfrac{1}{2}
  \end{align*}
  \end{multicols}
  %%%%%%%%%YYYYYYYYYYYYYYYYY%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   \begin{multicols}{2}
 \noindent
\begin{align*}
\mathscr{P_+}_y & = \bigg | \braket{+_y|\psi_3} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}}\bra{+} - i\bra{-} \bigg \{ -\tfrac{4}{5}\ket{+} + i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg | - \tfrac{4}{5\sqrt{2}}\braket{+|+} - i^2\tfrac{3}{5\sqrt{2}} \braket{-|-}  \bigg |^2 \\
  & = \bigg |  -\tfrac{4}{5\sqrt{2}} + \tfrac{3}{5\sqrt{2}} \bigg |^2 \\
  \mathscr{P_+}_y & = \tfrac{1}{50}
  \end{align*}
   \begin{align*}
\mathscr{P_-}_Y & = \bigg |  \braket{-_y|\psi_3} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}} \bra{+} + i \bra{-} \bigg \{ -\tfrac{4}{5}\ket{+} + i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  -\tfrac{4}{5\sqrt{2}}\braket{+|+} + i^2\tfrac{3}{5\sqrt{2}} \braket{-|-}  \bigg |^2 \\
 & = \bigg |  -\tfrac{4}{5\sqrt{2}} - \tfrac{3}{5\sqrt{2}} \bigg |^2 \\
  \mathscr{P_-}_y & = \tfrac{49}{50}
  \end{align*}
  \end{multicols}
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Zzzzzzz%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   \begin{multicols}{2}
 \noindent
\begin{align*}
\mathscr{P_+}_z & = \bigg | \braket{+_z|\psi_3} \bigg|^2 \\
& = \bigg | \bra{+}  \bigg \{ -\tfrac{4}{5}\ket{+} + i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |  -\tfrac{4}{5}\braket{+|+}  \bigg |^2 \\
  & = \bigg |  -\tfrac{4}{5} \bigg |^2 \\
  \mathscr{P_+}_z & = \tfrac{16}{25}
  \end{align*}
   \begin{align*}
\mathscr{P_-}_z & = \bigg |  \braket{-_z|\psi_3} \bigg|^2 \\
& = \bigg |  \bra{-} \bigg \{ -\tfrac{4}{5}\ket{+} + i\tfrac{3}{5}\ket{-} \bigg \} \bigg |^2 \\
& = \bigg |    i\tfrac{3}{5} \braket{-|-}  \bigg |^2 \\
 & = \bigg |  i \tfrac{3}{5} \bigg |^2 \\
  \mathscr{P_-}_z & = \tfrac{9}{25}
  \end{align*}
  \end{multicols}

\textbf{b) Use your results from (a) to comment on the importance of the overall phase and of the
relative phases of the quantum state vector.} \\
\\
Because the same results were observed from state vectors in different phases we can say that the phases are not observable in our measurements.
\section*{Problem 1.11}
\textbf{A beam of spin-1/2 particles is prepared in the state}\\
$$\ket{\psi} = \tfrac{3}{\sqrt{34}} \ket{+} + i\tfrac{5}{\sqrt{34}} \ket{-}$$
\\
\textbf{a) What are the possible results of a measurement of the spin component Sz, and with what
probabilities would they occur?} \\
\begin{multicols}{2}
\noindent
\begin{align*}
\mathscr{P}_+ & = \bigg | \bra{+} \big \{  \tfrac{3}{\sqrt{34}} \ket{+} + i\tfrac{5}{\sqrt{34}} \ket{-} \big \} \bigg|^2 \\
& = \bigg | \tfrac{3}{\sqrt{34}} \bigg|^2 \\
\mathscr{P}_+ & = \tfrac{9}{34}
\end{align*}
\begin{align*}
\mathscr{P}_- & = \bigg | \bra{-} \big \{  \tfrac{3}{\sqrt{34}} \ket{+} + i\tfrac{5}{\sqrt{34}} \ket{-} \big \} \bigg|^2 \\
& = \bigg | i\tfrac{5}{\sqrt{34}} \bigg|^2 \\
\mathscr{P}_- & = \tfrac{25}{34}
\end{align*}
\end{multicols}
\textbf{b) Suppose that the $S_z$ measurement yields the result Sz = -$\frac{\hbar}{2}$. Subsequent to that result a second measurement is performed to measure the spin component $S_x$. What are the
possible results of that measurement, and with what probabilities would they occur?}\\
\\
If the measurement show that the system is prepared in the z down state then we would expect an even distribution in spins for the x direction as,
\begin{multicols}{2}
\noindent
\begin{align*}
\mathscr{P}_+ & = \bigg | \tfrac{1}{\sqrt{2}}\bra{+}  \big \{  \  \ket{+} + \ket{-} \big \} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}} \bigg|^2 \\
\mathscr{P}_+ & = \tfrac{1}{2}
\end{align*}
\begin{align*}
\mathscr{P}_- & = \bigg | \tfrac{1}{\sqrt{2}}\bra{-} \big \{  \ket{+} + \ket{-} \big \} \bigg|^2 \\
& = \bigg | \tfrac{1}{\sqrt{2}} \bigg|^2 \\
\mathscr{P}_- & = \tfrac{1}{2}
\end{align*}
\end{multicols}
\textbf{c) Draw a schematic diagram depicting the successive measurements in parts (a) and (b).}\\
\\
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------

\end{document}

H.W. 4 Due Wednesday 9-12-2018/Quantum H.W. 4.tex


\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

% Main maths packages
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathrsfs}

% Required to use the underbracket
\usepackage{mathtools}

\begin{document}

\subsection*{Basic accents}

\[
	\vec{a} =
	\begin{pmatrix}
		1\\
		1
	\end{pmatrix}
\]

\[
\hat{a} = 90^\circ
\]

The other accents can be found in the symbols list in the \emph{Best Practices} part in the \LaTeX Compendium.

\subsection*{Stacking elements}

\[
	a \overset{?}{=} b
\]

\[
	a \underset{k = 0}{=} b
\]

\[
	\sum_{\substack{k=0 \\ i=0 \\ j=0}}^{n} i + j + k
\]

\subsection*{Arrows}

\[
	a \xrightarrow[down]{up} b
\]

\[
	a \xleftarrow[down]{up} b
\]

\subsection*{Complex decoration}

\[
	z = \overbrace{\underbracket{x}_{\text{real}} + \underbracket{iy}_{\text{imaginary}}}^{\text{complex number}}
\]

\end{document}


\documentclass{article}
%\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{color}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{mathrsfs}
\usepackage{enumerate}
\usepackage[margin=1in]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Final 06}
\rhead{Jon Allen}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}
\newcommand{\degree}{\ensuremath{^\circ}}

\begin{document}
\subsubsection*{PDE D.2}
\begin{align*}
  \text{PDE.}&&\frac{\partial u}{\partial t}&=\frac{\partial^2u}{\partial x^2}&&\text{for}&0&<x<\infty,&0&<t<\infty\\
  \text{BC.}&&u(0,t)&=f(t)&&\text{for}&&&0&<t<\infty\\
  \text{IC.}&&u(x,0)&=0&&\text{for}&0&<x<\infty
\end{align*}

Apply the Laplace transform with respect to $t$ to PDE D.2 to obtain the relation $U(x,s)=sF(s)W(x,s)$, where $U(x,s)$ is the Laplace transform of the solution $u(x,t), F(s)$ is the transform of $f(t)$ and $W(x,s)$ is the transform of problem 5. Show that the result leads to the formula

\[u(x,t)=f(0)\text{erfc}\left(\frac{x}{2\sqrt{t}}\right)+t\int_0^1{\text{erfc}\left(\frac{x}{2\sqrt{t}}(1-u)^{-1/2}\right)f'(tu)\mathrm{d}u}\]

\begin{align*}
  sU(x)-0&=\frac{\mathrm{d}^2U}{\mathrm{d}^2x}\\
  U(0)&=F(s)\\
  0&=\frac{\mathrm{d}^2U}{\mathrm{d}^2x}-sU(x)\\
  U(x)&=c_1e^{x\sqrt{s}}+c_2e^{-x\sqrt{s}}\\
  U(0)&=F(s)=c_1+c_2\\
  c_1=0&\quad c_2=F(s)\\
  U(x)&=F(s)e^{-x\sqrt{s}}=\frac{s}{s}F(s)e^{-x\sqrt{s}}\\
  W(s)&=\frac{1}{s}e^{-x\sqrt{s}}\\
  U(x)&=sF(s)W(x)
\end{align*}
And now we do the reverse transform
\begin{align*}
  U(x)&=(sF(s)-f(0)+f(0))W(x)\\
  &=(sF(s)-f(0))W(x)+f(0)W(x)\\
  u(x,t)&=f(0)\text{erfc}\left(\frac{x}{2\sqrt{t}}\right)+\int_0^t{f'(u)\,\text{erfc}\left(\frac{x}{2\sqrt{(t-u)}}\right)\,\mathrm{d}u}\\
  &=f(0)\text{erfc}\left(\frac{x}{2\sqrt{t}}\right)+t\int_0^1{f'(tu)\,\text{erfc}\left(\frac{x}{2\sqrt{(t-tu)}}\right)\,\mathrm{d}u}\\
  &=f(0)\text{erfc}\left(\frac{x}{2\sqrt{t}}\right)+t\int_0^1{f'(tu)\,\text{erfc}\left(\frac{x}{2\sqrt{t}\sqrt{1-u}}\right)\,\mathrm{d}u}\\
\end{align*}
\end{document}


\documentclass[12pt,letterpaper]{article}

%\usepackage{keystroke}
\usepackage{amsmath}
\usepackage{algpseudocode}

%if i don't put that trailing space, spaces after \svdimage wont show
%like this "SvdImageis cool beans"
%don't know why
\newcommand{\svdimage}{\texttt{SvdImage} }

\newcommand{\codeitem}[2]{\item[\texttt{\%> #1}] \hfill \\ #2}

\begin{document}

\title{SvdImage Manual}
\author{Tim Martin}
\date{Spring 2012}
\maketitle

\section{Description}
In an abstracted form, images are matrices of color values. Therefore, we can
perform linear algebra operations on images just as we do on general matrices.
Specifically, when we perform a Singular Value Decomposition (SVD) on an image,
we can represent it as the product of 3 matrices: the left-singular vectors,
a diagonal matrix of the decreasing singular values and the right-singular vectors.

\begin{equation}
A=USV^{T}
\end{equation}

Performing an SVD gets interesting for images when we truncate the factor
matrices. Truncation in this sense is the removal of a certain number of
trailing columns of $U$ and $V$ and trailing columns and rows of $S$. By
multiplying the matrix back into $A$ after truncating, we get back a similar
image to the original. Depending on the amount of truncation, we can keep a
``good'' representation of the image in less space!

\svdimage is a program and developer library that performs a truncated SVD. It
is written in the Ruby programming language and provides a command line
interface.

\section{Features}
\begin{itemize}
\item Command Line Interface
\item Grayscale, RGB, and CMYK channel processing
\item Level of truncation can be ``automatic'' or user-specified
\item Supports most image file formats
\item Codec provides targeted file format (.svd)
\item Ruby Gem distribution
\item Can be used a library
\end{itemize}

\section{Compression}
The main application of \svdimage is to compress images. However, this does not
come for free. We are indeed losing information about the original image. This
happens by reducing the rank our image to some value. For example, an image
\texttt{dog.jpg}may have 200 linearly independent rows and columns. If we run
\svdimage on this image with a k value of 150, the output will be an image that
looks similar to \texttt{dog.jpg}, but is acutally now comprised of 150 linearly
independent rows and columns. In other words, 50 rows and columns will be the
linear combination of the other 150 rows and columns.

Another caveat is that you may not always notice compression in file size. This
is dependent on a few factors (image content, colorspace, file format). Not each
file format stores truncated SVDs in a way optimal to this operation. I can't
imagine a file format that would be able to understand if some rows or columns
are linearly dependent.

However, this is not to say you will never see compression! Personally, most
times, I have.

\section{Sigma Ratio Threshold}
\svdimage comes with the option to use the \texttt{-a}/\texttt{--auto-k} flags.
These tell \svdimage that you would like to try to find a good truncation
automatically. This truncation is unique to to the image's singular values and
the sigma threshold. First, we set our sigma threshold equal to some value. By
default, \svdimage uses 0.2, but you may also specify this yourself by providing
an argument to the \texttt{-a}/\texttt{--auto-k} flags. Here is psuedocode for
the algorithm:

%algorithmic doesn't like \operatorname
\begin{algorithmic}
  \Require $0 \leq \operatorname{sigma\_threshold} < 1$
  \For{$k = 1 \to \operatorname{k\_max}$}
    \If{$ \operatorname{sigma\_threshold} \geq \frac{\sum_{i=k+1}^{t} \sqrt{\sigma_{i}^{2}}}{\sum_{i=1}^{t} \sqrt{\sigma_{i}^{2}}}$}
      \Return $k$
    \EndIf
  \EndFor
\end{algorithmic}

Intuitively, you may think of this as leaving out
$(\operatorname{sigma\_threshold})\%$ of the image's information.

\section{Question}
The project poses a question:
\begin{quote}
To get a good easily recognizable image, do you need to have $\sigma_{k+1}$ small
compares to 255, or just small compared to $\sigma_1$, or is there some other criterion of smallness
that is even more relevant?
Try this compression with portraits of faces. How small can you make k, and still
keep the portrait recognizable? In other words (roughly), what is the rank of a human
face?
\end{quote}

I believe I have answered this question with my explanation of the sigma ratio
threshold. A good $k$ is not dependent on 255 or just being small, but it is
instead dependent on the complexity of the image. $k$ must be chosen such that
you do not lose too much information from the image.

\section{Requirements}
\subsection{System}
\begin{itemize}
\item Ruby 1.9.2
\item GNU Scientific Library 1.15
\item ImageMagick 6.7.6-0
\item RubyGems 1.8.17
\end{itemize}
\subsection{Ruby Gems}
\begin{itemize}
\item bundler 1.0.21
\end{itemize}
Bundler will be used to easily download and install other gems.

\section{Installation}
Once all requirements have been met, you can install \svdimage. If you are
unable to get these requirements or perform the following installation, please
contact me!
\begin{description}
\codeitem{tar -xzvf svdimage-0.1.0.tar.gz}{Extract the archive contents.}
\codeitem{cd svdimage-0.1.0/}{Change into the \svdimage directory.}
\codeitem{bundle install}{Install all \svdimage dependency gems to your
system.}
\codeitem{rake install}{Install \svdimage to your system.}
\end{description}
And that's it! \svdimage should be in your \texttt{\$PATH} and you can start
using it anywhere

\section{Usage}
\footnotesize
\begin{verbatim}
Usage: svdimage INPUT_IMAGE OUTPUT_IMAGE [OPTIONS]
    -c, --colorspace COLORSPACE      Defines the colorspace of output-image.
                                       Must be "rgb", "gray", or "cmyk".
                                       Defaults to "rgb".
    -k RANK                          Truncates the SVD to rank RANK. May not be
                                       used with -a/--auto-k
    -a, --auto-k [SIGMA_THRESHOLD]   Truncates the SVD to a rank determined by
                                       the unique singular values of input-file.
                                       Compares the sum of the sqaure roots of
                                       the squares of the singular values to
                                       SIMGA_THRESHOLD, which may be provided as
                                       an argument or defaults to 0.2.
                                       May not be used with -k

    -h, --help                       Show this message
        --version                    Show version
\end{verbatim}
\normalsize

\section{Examples}
For the following examples, you must have
\begin{description}
\codeitem{svdimage in.jpg out.jpg -k 100}{Truncate \texttt{in.jpg} to have a rank of 100 and write it out as \texttt{out.jpg}. Ranks must be $1 \leq k < \min(\operatorname{image\_height}, \operatorname{image\_width})$.}
\codeitem{svdimage format1.png format2.gif -k 100}{Like previous, but notice how you can use file formats interchangeably.}
\codeitem{svdimage in.jpg out.jpg -a}{Truncate \texttt{in.jpg} to a ``reasonable'' rank. This algorithm attempts to remove unneeded ranks, but what ranks you consider unneeded may differ from me!}
\codeitem{svdimage in.jpg out.jpg -a 0.05}{Like previous, but with a specification of the sigma ratio. See the respective section for more information on how to use this.}
\codeitem{svdimage in.jpg out.svd -k 20}{Perform a truncation, but output to \texttt{.svd} format, a format designed to store SVDs.}
\codeitem{svdimage color.jpg bw.jpg -k 43 -c gray}{Decompose to grayscale. The default colorspace is rgb.}
\end{description}

\section{License}
Copyright (c) 2012 Tim Martin

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

\end{document}


\documentclass[12]{scrartcl}
\usepackage{amssymb,amsmath,gensymb,dsfont,calc,multicol,fullpage}
\makeatletter
\newcommand\Aboxed[1]{
   \@Aboxed#1\ENDDNE}
\def\@Aboxed#1&#2\ENDDNE{%
   &
   \settowidth\@tempdima{$\displaystyle#1{}$}
   \setlength\@tempdima{\@tempdima+\fboxsep+\fboxrule}
   \kern-\@tempdima
   \boxed{#1#2}
}
\makeatother

\begin{document}

\title{Homework 32, Section 6.3: 2, 4, 6, 8, 12}
\author{Alex Gordon}
\date{\today}
\maketitle
\section*{Homework}
\subsection*{2.}
$C(7,5) \cdot (\frac{1}{6})^5 \cdot (\frac{5}{6})^2 + C(7,6) \cdot (\frac{1}{6})^6 \cdot (\frac{5}{6})^1 + C(7,7) \cdot (\frac{1}{6})$
\subsection*{4.}
$\frac{1}{2}^{10} \cdot (C(10,8) + C(10,9) + 1)$
\subsection*{6.}
$ C(5,3) \cdot (\frac{1}{2})^3 \cdot (\frac{1}{2})^2 + C(5,4) \cdot (\frac{1}{2})^4 \cdot (\frac{1}{2})^1 + \frac{1}{2}^5$
\subsection*{8.}
$C(4,3) \cdot (\frac{1}{2})^3 \cdot (\frac{1}{2})^1 + \frac{1}{2}^4$
\subsection*{12. A)}
$\frac{3 \cdot 5 \cdot 4}{6^3}$
\subsection*{12. B)}
$\frac{3 \cdot 5 \cdot 4}{6^3}$
\subsection*{12. C)}
$\frac{3 \cdot 5 + 5}{6^3}$

\end{document}


% Copyright 2017 Markus J. Pflaum, licensed under CC BY-NC-ND 4.0
% main author:
%   Markus J. Pflaum
%
\section{Inner product spaces}
\label{sec:inner-product-spaces}
%
%
\para
Let us first remind the reader that as before $\fldK$ stands for the field
of real or of complex numbers. We will keep this notational agreement
throughout the whole chapter.
\begin{definition}
By a \emph{sesquilinear form} on a $\fldK$-vector space $\vectorspV$ one understands a map
$\langle \cdot , \cdot \rangle : \vectorspV \times \vectorspV \to \fldK$
with the following two properties:
\begin{enumerate}[label={\textup{({\sffamily SF\arabic*})}},leftmargin=*]
\item
\label{axiom:form-linearity-in-first-coordinate}
  The map $\langle \cdot , \cdot \rangle$ is \emph{linear} in its first coordinate which means that
  \[
    \langle v_1 + v_2, w \rangle = \langle v_1, w \rangle + \langle v_2, w \rangle
    \quad \text{and} \quad \langle r v, w \rangle = r \langle v, w \rangle
  \]
  for all  $v, w , v_1,v_2 \in \vectorspV$ and $r\in \fldK$.
\item
 \label{axiom:form-conjugate-linearity-in-second-coordinate}
  The map $\langle \cdot , \cdot \rangle$ is \emph{conjugate-linear} in its second coordinate which means that
  \[
    \langle v_1 + v_2, w \rangle = \langle v_1, w \rangle + \langle v_2, w \rangle
    \quad \text{and} \quad \langle  v, r w \rangle = \overline{r} \langle v, w \rangle
  \]
  for all  $v, w , v_1,v_2 \in \vectorspV$ and $r\in \fldK$.
\end{enumerate}
A \emph{hermitian form} is a sesquilinear form $\langle \cdot , \cdot \rangle$ on $\vectorspV$ with the following
additional property:
\begin{enumerate}[label={\textup{({\sffamily SF\arabic*})}},leftmargin=*,resume]
\item
\label{axiom:form-conjugate-symmetry}
  The map $\langle \cdot , \cdot \rangle$ is \emph{conjugate symmetric} which means that
  \[
    \langle v, w \rangle = \overline{\langle w, v \rangle} \quad \text{for all  } v, w \in \vectorspV \ .
  \]
\end{enumerate}
A sesquilinear form  $\langle \cdot , \cdot \rangle$ is  called
\emph{weakly-nondegenerate} if it satisfies axiom
\begin{enumerate}[label={\textup{({\sffamily SF\arabic*w)}}},leftmargin=*,resume]
\item
\label{axiom:form-weakly-nondegenerate}
  For every $v\in \vectorspV$, the map $\vectorspV \to \fldK$, $w \to \langle w,v \rangle$ is the zero
  map if and only if $v=0$.
\end{enumerate}
Finally, one calls a hermitian form  $\langle \cdot , \cdot \rangle$ on $\vectorspV$
\emph{positive semidefinite} if
\begin{enumerate}[label={\textup{({\sffamily SF\arabic*s})}},leftmargin=*,resume]
\item
\label{axiom:form-positive-semidefinite}
  $\langle v,v \rangle \geq 0$ for all $v\in \vectorspV$.
\end{enumerate}
\end{definition}

\begin{remark}
Recall that a map  $\langle \cdot , \cdot \rangle : \vectorspV \times \vectorspV \to \fldK$ is called \emph{bilinear},
if it satisfies \ref{axiom:form-linearity-in-first-coordinate} and
\begin{axiomlist}[BF]
\item
 \label{axiom:form-linearity-in-second-coordinate}
  The map $\langle \cdot , \cdot \rangle$ is \emph{linear} in its second coordinate which means that
  \[
    \langle v_1 + v_2, w \rangle =  \langle  v_1, w \rangle + \langle v_2, w \rangle
    \quad \text{and} \quad \langle  v, r w \rangle = r \langle v, w \rangle
  \]
  for all  $v, v_1,v_2, w \in \vectorspV$ and $r\in \fldK$.
\end{axiomlist}
If the underlying ground field $\fldK$ coincides with the field of real numbers,
a sesquilinear form is by definition the same as a bilinear form,
and a hermitian form the same as a symmetric bilinear form.
\end{remark}

\para \label{para:properties-seminorm-associated-positive-semidefinite-hermitian-form}
Given a positive semidefinite hermitian form $\langle \cdot , \cdot \rangle$ on a
$\fldK$-vector space $\vectorspV$, one calls two vectors $v,w \in \vectorspV$ \emph{orthogonal}
if $\langle v , w \rangle = 0$. Since the hermitian form
$\langle \cdot , \cdot \rangle$ is assumed to be positive semidefinite, the map
\[
 \| \cdot \| : \vectorspV \to \R_{\geq 0} , \: v \mapsto \|v \| = \sqrt{\langle v , v \rangle}
\]
is well-defined. We will later see that $\| \cdot \|$  is a seminorm on $\vectorspV$
and therefore call the map $\| \cdot \|$ the \emph{seminorm associated to}
$\langle \cdot , \cdot \rangle$. The following formulas are immediate consequences of the
properties defining a positive semidefinite hermitian form and the definition
of the associated seminorm:
\begin{align}
  \label{eq:norm-squared-sum}
  & \| v+w \|^2  = \| v\|^2 + 2\, \Re \, \langle  v ,  w \rangle + \| w\|^2 \quad \text{for all }
  v,w \in \vectorspV \ , \\
  \label{eq:pythagorean-theorem}
  & \| v+w \|^2  = \| v\|^2 + \| w\|^2 \quad \text{for all orthogonal } v,w \in \vectorspV \ ,  \\
  \label{eq:parallelogram-identity}
  & \| v+w \|^2  + \|v-w\|^2  = 2 \big( \| v\|^2 + \| w\|^2 \big) \quad \text{for all } v,w \in \vectorspV\ ,\\
  \label{eq:absolute-homogeneity}
  & \| rv \| = \sqrt{ |r|^2 \langle  v ,  v \rangle }  = |r| \| v \|
  \quad \text{for all } v,w \in \vectorspV \text{ and } r\in \fldK \ .
\end{align}
Formula \eqref{eq:pythagorean-theorem} is an abstract version of the \emph{pythagorean theorem},
\Cref{eq:parallelogram-identity} is called the \emph{parallelogram identity}.
The triangle inequality for the map $\| \cdot \|$  will turn out to be a consequence of the
following result.

\begin{proposition}[Cauchy--Schwarz inequality]
\label{thm:cauchy-schwartz-inequality-inner-product-spaces}
%
Given a positive semidefinite hermitian form $\langle \cdot , \cdot \rangle$ on a $\fldK$-vector space
$\vectorspV$ the following inequality holds true:
\begin{equation}
\label{eq:cauchy-schwarz-inequality}
  |\langle v, w \rangle| \leq \|v\|\|w\| \quad \text{for all $v,w \in \vectorspV$}.
\end{equation}
Equality holds if and only if $v$ and $w$ are linearly dependant.
\end{proposition}
\begin{proof}
If $v$ or $w$ is $0$, the proof is trivial, hence we can assume both to be nonzero. Put
\[
  c = - \frac{\langle v, w \rangle}{\|v\|^2}
\]
and compute
\begin{equation}
\label{eq:expanding-norm-of-sum-in-inner-product-space}
\begin{split}
   0 & \leq \|c v + w\|^2 = \langle c v + w, c v + w \rangle =
   |c|^2 \langle v, v \rangle + c \langle v, w \rangle +
   \overline{c}\langle w, v \rangle + \langle w, w \rangle = \\
   & =  |c|^2\|v\|^2 + 2 \, \Re \big( c\langle v, w \rangle \big) + \|w\|^2 =
   \frac{|\langle v, w \rangle|^2}{\|v\|^2} - 2\frac{|\langle v, w \rangle|^2}{\|v\|^2} + \|w\|^2 = \\
   & = \|w\|^2 - \frac{|\langle v, w \rangle|^2}{\|v\|^2} \ .
 \end{split}
\end{equation}
Hence
\[
   |\langle v, w \rangle|^2 \leq \|v\|^2\|w\|^2
\]
which entails the Cauchy--Schwarz inequality.

If $v,w$ are linearly dependant nonzero elements of $\vectorspV$, then there exists a nonzero scalar
$a\in \fldK$ such that $v = a w$. Hence
\[
  |\langle v , w \rangle| = |a| \, \| w \|^2
  = \| v \|  \| w \| \, .
\]
Vice versa, if equality holds, then \Cref{eq:expanding-norm-of-sum-in-inner-product-space}
entails that $c v +w  = 0$, which means that $v$ and $w$ are linearly dependant.
\end{proof}

\begin{lemma}
\label{thm:positive-definitess-equivalent-nondegeneracy}
  A positive semidefinite hermitian form $\langle \cdot , \cdot \rangle$ on a $\fldK$-vector space
  $\vectorspV$ is weakly-nondegenerate if and only if it is \emph{positive definite} that is if and only if
  \begin{enumerate}[label=\textup{({\sffamily SF\arabic*p)}},leftmargin=*]
  \setcounter{enumi}{4}
  \item
  \label{axiom:form-positive-definite}
  $\langle v,v \rangle > 0$ for all $v\in \vectorspV \setminus \{ 0 \}$.
  \end{enumerate}
\end{lemma}

\begin{proof}
  A positive definite real bilinear or complex  hermitian form $\langle \cdot , \cdot \rangle$ is
  non-degenerate since for every $v \in \vectorspV \setminus \{ 0 \}$ the  linear form
  $\langle - ,v \rangle : \vectorspV \to \fldK$ then is  nonzero  because  $\langle v,v \rangle > 0$.

  Conversely, if $\langle - ,v \rangle : \vectorspV \to \fldK$ is nonzero for all
  $v \in \vectorspV \setminus \{ 0 \}$, then  there exists an element $w \in \vectorspV$ such that
  $\langle w,v \rangle \neq 0$. The Cauchy--Schwarz inequality entails
  \[
    0 < |\langle w,v \rangle |^2 \leq \langle w,w \rangle \, \langle v,v \rangle \ ,
  \]
  which implies $\langle v,v \rangle > 0$. Hence $\langle \cdot , \cdot \rangle$ is positive definite.
\end{proof}

\begin{proposition}
 The map
 \[
  \| \cdot \| :V \to \R_{\geq 0} , \: v \mapsto \|v \| = \sqrt{\langle v , v \rangle}
 \]
 associated to a positive semidefinite hermitian form
 $\langle \cdot , \cdot \rangle$ on a $\fldK$-vector space $\vectorspV$ is a seminorm.
 If the hermitian form is positive definite, then $\| \cdot \|$ is even  a norm.
\end{proposition}
\begin{proof}
 Absolute homogeneity \ref{axiom:norm-absolute-homogeneity} is given by Eq.~\eqref{eq:absolute-homogeneity}.
 The triangle inequality is a consequence of the Cauchy--Schwarz inequality:
 \[
   \| v + w \|^2 =   \| v\|^2 + 2 \, \Re \, \langle  v ,  w \rangle + \| w\|^2 \leq
    \| v\|^2 + 2 \, \|  v \| \, \| w \| + \| w\|^2 = \big(\| v\|+\| w\| \big)^2 \ .
 \]
 Finally, if $\langle \cdot , \cdot \rangle$ is positive definite, then
 $\| v \| = \sqrt{\langle v , v \rangle} > 0 $ for all $v \in \vectorspV \setminus \{ 0 \}$,
 so $\| \cdot \|$ is  a norm.
\end{proof}

%%%%%%%%%%%%%%%%%%%
%% Hilbert space definition
%%%%%%%%%%%%%%%%%%%
\begin{definition}
\label{def:hilbert-space}
By an \emph{inner product} or a \emph{scalar product} on a $\fldK$-vector space $\hilbertH$ one
understands a positive definite hermitian form on $\hilbertH$. A $\fldK$-vector space $\hilbertH$
together with an inner product $\langle \cdot , \cdot \rangle : \hilbertH \times \hilbertH \to \fldK$ is
called an \emph{inner product space} or a \emph{pre-Hilbert space}.

A hermitian form on a  $\fldK$-vector space $\hilbertH$ which is only positive semidefinite is called a \emph{semi-inner product} or a \emph{semi-scalar product}.

A \emph{Hilbert space} is an inner product space  $(\hilbertH , \langle \cdot , \cdot \rangle)$  which is
complete as a normed vector space. In other words, a Hilbert space is Banach space where the
norm on the space is induced by an inner product.
\end{definition}

\begin{examples}
\label{ex:inner-product-spaces}
\begin{environmentlist}
\item The vector space $\R^n$ with the \emph{euclidean inner product}
      \[
        \langle \cdot , \cdot \rangle : \R^n \times \R^n \to \R, \:
        \big( (v_1,\ldots , v_n),(w_1,\ldots , w_n) \big) \mapsto
        \sum_{i=1}^n v_i w_i
      \]
      is a real Hilbert space. Obviously, $\langle \cdot , \cdot \rangle$ is linear in the first argument,
      symmetric, and positive definite, hence a real inner product. The associated norm is
      the \emph{euclidean norm}. We have seen before that $\R^n$ with the euclidean norm is complete.
\item The vector space $\C^n$ together with the hermitian form
      \[
        \langle \cdot , \cdot \rangle : \C^n \times \C^n \to \C, \:
        \big( (v_1,\ldots , v_n),(w_1,\ldots , w_n) \big) \mapsto
        \sum_{i=1}^n v_i\overline{w}_i
      \]
      is a complex Hilbert space. One immediately verifies that $\langle \cdot , \cdot \rangle$ is linear in the first argument,
      conjugate symmetric, and positive definite. Hence $\langle \cdot , \cdot \rangle$ is a complex inner product which we
      sometimes call the \emph{standard hermitian inner product} on $\C^n$.  Its associated norm is again the euclidean
      norm, so by completeness of $\C^n\cong \R^{2n}$ endowed with the euclidean norm one obtains the claim.
\item The set
      \[
        \ell^2 =
        \left\{(z_k)_{k\in \N} \in \C^\N \suchthat \sum_{k=0}^\infty |z_k|^2 < \infty \right\}
      \]
      of square summable sequences of complex numbers  is a complex Hilbert space
      with inner product
      \[
        \langle \cdot , \cdot \rangle :
        \ell^2 \times \ell^2 \to \C, \: \big((z_k)_{k\in \N},(w_k)_{k\in \N} \big)
        \mapsto \sum_{k=0}^\infty z_k \overline{w}_k \ .
      \]
      To prove this one needs to first verify that $\ell^2$ is a subvector space of $\C^\N$.
      For $z = (z_k)_{k\in \N} \in \C^\N$ denote by $\| z\|$ the \emph{extended norm}
      $\sqrt{\sum_{k=0}^\infty |z_k|^2} = \sup\limits_{K\in \N} \sqrt{\sum_{k=0}^K |z_k|^2} \in \closedint{0,\infty}$.
      Then $z\in \ell^2$ if and only if $\|z\| < \infty$. Now let $a \in \C$ and $z\in \ell^2$ and compute
      \[
         \| a z \| = \sqrt{\sum_{k=0}^\infty |a  z_k|^2} = |a| \, \sqrt{\sum_{k=0}^\infty |z_k|^2} = |a| \cdot \| z \| < \infty \ .
      \]
      Hence $az \in \ell^2$. If $z,w \in \ell^2$, denote for each $K\in \N$ by $z_{(K)}$ and $w_{(K)}$ the ``cut-off''
      vectors $(z_0, \ldots , z_K) \in \C^{K+1}$ and  $(w_0, \ldots , w_K) \in \C^{K+1}$, respectively.
      By the triangle inequality for the norm on the Hilbert space $\C^{K+1}$  one concludes
      \[
         \sqrt{\sum_{k=0}^K  | z_k + w_k |^2} =  \| z_{(K)} + w_{(K)} \| \leq
         \| z_{(K)} \| + \| w_{(K)} \| \leq \| z \| + \| w \| < \infty \ .
      \]
      Therefore, the sequence of partial sums $\sum_{k=0}^K  | z_k + w_k |^2$, $K\in \N$, is bounded,
      so convergent by the the monotone convergence theorem. One  obtains
       \[
          \| z + w \| = \lim_{K\to\infty} \sqrt{ \sum_{k=0}^K  | z_k + w_k |^2} \leq \| z \| + \| w \| < \infty \ .
      \]
      Hence  $z + w$ is square summable and $\ell^2$ a vector subspace of $\C^\N$ indeed.
      Note that our argument also shows that the restriction of the extended norm to $\ell^2$ is a norm.

      We need to show that $\langle \cdot , \cdot \rangle$ is well-defined.
      To this end it suffices to prove that for all $z,w \in\ell^2$ the family $\left( z_k \overline{w}_k\right)_{k\in \N}$
      is absolutely summable or in other words that $\sum_{k=0}^\infty \left| z_k \overline{w}_k \right| < \infty$.
      One concludes by the H\"older inequality for  sums
      \[
        \sum_{k=0}^K \left| z_k  \overline{w}_k \right| = \sum_{k=0}^K \left| z_k  w_k \right|
        % =  \left| \inprod{(|z_0|,\ldots,|z_N|),(|w_0|,\ldots,|w_N|)  } \right|
        \leq \| z_{(K)} \| \,  \| w_{(K)} \| \leq  \| z \| \,  \| w \| \ .
      \]
      So the left hand side has an upper bound uniform in $K$ which by the monotone convergence theorem entails
      convergence of the partial sums and the estimate
      \[
         \sum_{k=0}^\infty \left| z_k \overline{w}_k \right| \leq  \| z \| \,  \| w \| < \infty \ .
      \]
      By definition it is clear that $ \langle \cdot , \cdot \rangle $ is linear in the first argument,
      conjugate symmetric and positive definite, hence a complex inner product. Note that the norm
      associated to  $ \langle \cdot , \cdot \rangle $ coincides with the above defined map $\| \cdot \|$.

      It remains to be shown that $\ell^2$ is complete. Let $(z^n)_{n\in \N}$ with $z^n = {(z^n_k)}_{k\in \N}\in \ell^2$
      for all $n\in \N$ be a Cauchy sequence in $\ell^2$.
      For $\varepsilon >0$ choose $N_\varepsilon \in \N$ so that
      \[
        \| z^n - z^m   \|< \varepsilon \quad \text{for all } n,m \geq N_\varepsilon \ .
      \]
      For each fixed $k\in \N$ one therefore has
      \begin{equation}
        \label{eq:estimate-component-sequence-Cauchy-sequence-square-summable-sequences}
        | z^n_k - z^m_k | \leq \| z^n - z^m   \|< \varepsilon \quad \text{for all } n,m \geq N_\varepsilon \ .
      \end{equation}
      By completeness of $\C$ there exist $z_k \in \C$ such that $\lim_{n\to\infty} z^n_k = z_k$ for all $k\in \N$.
      We claim that $z = (z_k)_{k\in \N}$ is an element of $\ell^2$ and that $(z^n)_{n\in \N}$ converges to $z$.
      To verify this observe that for all $\varepsilon >0$, $K\in \N$ and $n\geq N_\varepsilon$
      \[
        \sum_{k=0}^K  | z_k - z^n_k |^2 = \lim_{m\to\infty}  \sum_{k=0}^K  | z^m_k - z^n_k |^2
        \leq \sup_{m \geq N_\varepsilon} \sum_{k=0}^K  | z^m_k - z^n_k |^2
        \leq \sup_{m \geq N_\varepsilon} \| z^m - z^n \|^2 \leq \varepsilon^2 \ .
      \]
      This implies by the triangle inequality and the fact that the Cauchy sequence $(z^n)_{n\in \N}$ is bounded in norm by some
      $C>0$ that for all $K\in \N$ and $N = N_1$
      \[
        \sqrt{\sum_{k=0}^K  | z_k|^2 } = \| z_{(K)} \| \leq  \| z_{(K)} - z^N_{(K)} \| + \| z^N_{(K)} \|
        \leq  \| z_{(K)} - z^N_{(K)} \| + \| z^N \|
        \leq 1 + C \ .
      \]
      Hence $ \| z \|= \sqrt{\sum_{k=0}^\infty | z_k|^2 } \leq 1 + C $  and $z \in \ell^2$. In addition one obtains
      \[
       \| z - z^n \| = \lim_{K\to\infty} \sqrt{\sum_{k=0}^K  | z_k - z^n_k |^2} \leq \varepsilon \quad \text{for all } n \geq N_\varepsilon \ .
      \]
      This means that $z$ is the limit of the sequence $(z^n)_{n\in \N}$ and $\ell^2$ is complete.
\item Let
      \[
        \mathscr{L}^2(\R^n) = \left\{ f : \R^n \to \C \suchthat f
        \text{ is Lebesgue measurable and }
        \int_{\R^n}|f|^2 d\lambda < \infty \right\}
      \]
      denote the space of Lebesgue square integrable functions on $\R^n$.
      Then the map
      \[
          \langle \cdot , \cdot \rangle : \mathscr{L}^2(\R^n) \times  \mathscr{L}^2(\R^n) \to \C, \:
         (f,g) \mapsto \int_{\R^n}f\overline{g}\, d\lambda
      \]
      is a positive semidefinite hermitian form on $\mathscr{L}^2(\R^n)$.
      Modding out $\mathscr{L}^2(\R^n)$ by the kernel
      \[
        \mathscr{N} := \Ker (\| \cdot \|) =
        \left\{ f \in \mathscr{L}^2(\R^n) \suchthat \int_{\R^n}|f|^2 d\lambda = 0 \right\}
      \]
      gives the Lebesgue space
      \[
          L^2 (\R^n) := \mathscr{L}^2(\R^n) / \mathscr{N} \ .
      \]

      The hermitian form $\langle \cdot , \cdot  \rangle $ vanishes on $\mathscr{N} \times  \mathscr{L}^2(\R^n)$ and
      $\mathscr{L}^2(\R^n) \times \mathscr{N}$ by the Cauchy--Schwarz inequality, hence descends to a hermitian form
      \[
        \langle \cdot , \cdot \rangle : L^2(\R^n) \times  L^2(\R^n) \to \C, \:
        (f + \mathscr{N} ,g+ \mathscr{N}) \mapsto \int_{\R^n}f\overline{g}\, d\lambda \ .
      \]
      That hermitian form is positive definite, since
      $\langle f + \mathscr{N}, f + \mathscr{N} \rangle = 0$ means
      $ \int_{\R^n}|f|^2 d\lambda =0$, hence $f\in \mathscr{N}$.
      So $L^2(\R^n)$ together with $\langle \cdot , \cdot \rangle $ is a
      Hilbert space which we call the
      \emph{Hilbert space of square-integrable functions} on $\R^n$.
      \add{provide details on well-definedness of hermitian form and show completeness}
\end{environmentlist}
\end{examples}

%%%%%%%%%%%%%%%%%%%
%% Theorem giving condition to relate inner product with norm
%%%%%%%%%%%%%%%%%%%

\begin{theorem}
\label{thm:parallegram-identity-guarantees-that-norm-comes-from-some-inner-product}
Let $\vectorspV$ be a normed $\fldK$-vector space. Then the norm $\|\cdot\| : \vectorspV \to \R_{\geq 0}$
is associated to an inner product $\langle \cdot , \cdot \rangle :  \vectorspV \times \vectorspV \to \fldK$
if and only if the \emph{parallelogram identity}
\[
  \| v + w \|^2 + \| v -  w\|^2 = 2\|v\|^2 + 2\|w\|^2
\]
holds true for all $v,w \in \vectorspV$. In this case, the inner product of two elements $v,w\in \vectorspV$
can be expressed by the \emph{polarization identity for} $\fldK = \R$
\begin{equation}
  \label{eq:real-polarization-identity}
  \langle v , w \rangle = \frac 14 \left( \| v + w \|^2  - \| v - w \|^2 \right)
  = \frac 12 \left( \| v + w \|^2  - \| v \|^2 - \| w \|^2 \right)
\end{equation}
respectively by the  \emph{polarization identity for} $\fldK = \C$
\begin{equation}
  \label{eq:complex-polarization-identity}
  \langle v , w \rangle = \frac 14 \sum_{k=1}^4 \cplxi^k \, \| v + \cplxi^k \, w \|^2  \ .
\end{equation}
\end{theorem}
\begin{proof}
The forward direction is a consequence of
\ref{para:properties-seminorm-associated-positive-semidefinite-hermitian-form}, Eq.~\ref{eq:parallelogram-identity}.
To show the backward direction we consider two cases $\fldK = \R$ and
$\fldK = \C$ separately.

\textit{1.~Case.} Given the norm $\|\cdot\|$ define $\langle \cdot , \cdot \rangle : \vectorspV \times \vectorspV \to \R$ by real polarization
\[
   \langle v , w \rangle = \frac 14 \left( \| v + w \|^2  - \| v - w \|^2 \right), \quad \text{where } v,w\in \vectorspV  \ .
\]
Note that the parallelogram identity entails
\[
  \frac 14 \left( \| v + w \|^2  - \| v - w \|^2 \right) =
  \frac 12 \left( \| v + w \|^2  - \| v \|^2 - \| w \|^2 \right) \ .
\]
Observe that by definition $\langle v , w \rangle = \langle w , v \rangle$ and $\| v \| = \sqrt{ \langle v , v \rangle}$.
Let us show additivity in the first variable. Let $v_1,v_2,w \in \vectorspV$ and compute using the parallelogram identity
\begin{equation*}
  \begin{split}
     \| v_1 + v_2 + w \|^2 & = 2 \| v_1 + w \|^2 + 2 \| v_2\|^2 -  \| v_1 + w - v_2\|^2 \ , \\
     \| v_1 + v_2 + w \|^2 & = 2 \| v_2 + w \|^2 + 2 \| v_1\|^2 -  \| v_2 + w - v_1\|^2 \ .
  \end{split}
\end{equation*}
Hence
\begin{equation*}
  \begin{split}
     \| v_1 + v_2 \pm w \|^2 & =
     \| v_1 \pm w \|^2 +  \| v_2 \pm w \|^2 +  \| v_1\|^2 + \| v_2\|^2 -  \| v_1 \pm w - v_2\|^2  -  \| v_2 \pm w - v_1\|^2 \ .
  \end{split}
\end{equation*}
Subtracting the $-$ version from the $+$ version of this equation entails
\begin{equation*}
  \begin{split}
    \langle v_1 + v_2 , w \rangle \, & = \frac 14 \left( \| v_1 + v_2 + w \|^2  - \| v_1 + v_2 - w \|^2 \right)= \\
    & = \frac 14 \left( \| v_1 + w \|^2 +  \| v_2 + w \|^2 -  \| v_1 - w \|^2 -  \| v_2 - w \|^2 \right) =
    \langle v_1  , w \rangle +  \langle v_2 , w \rangle \ ,
  \end{split}
\end{equation*}
so additivity in the first variable is proved. By induction  one derives from this that
for all natural $n$
\begin{equation}
\label{eq:natural-number-homogeneity}
  \langle nv , w \rangle = n \langle v , w \rangle \quad \text{for all } v,w \in \vectorspV  \ .
\end{equation}
Since then $\langle - nv , w \rangle - n \langle v , w \rangle = \langle -nv + nv , w \rangle = 0$ for all $n\in \N$,
Eq.~\eqref{eq:natural-number-homogeneity} also holds for $n\in \Z$.
Now let $p\in \Z$ and $q \in \gzN$. Then $ q\, \langle \frac pq v , w \rangle = \langle p v , w \rangle = p \, \langle  v , w \rangle$,
hence one has for rational $r$
\begin{equation}
\label{eq:rational-number-homogeneity}
 \langle rv , w \rangle = r \langle v , w \rangle \quad \text{for all } v,w \in \vectorspV  \ .
\end{equation}
Since addition, multiplication by scalars and the norm are continuous, the function
\[
   \R \to \R, \:r \mapsto  \langle rv , w \rangle - r \langle v , w \rangle = \frac 14 \left( \| r v + w \|^2 + r \|  v - w \|^2   - \| rv - w \|^2 -  r \|  v + w \|^2 \right)
\]
is continuous. Since  it vanishes over $\Q$, it has to coincide with the zero map. Therefore,
Eq.~\eqref{eq:rational-number-homogeneity} holds for all $r\in \R$. So $\langle \cdot , \cdot \rangle$ is linear in
the first coordinate. By symmetry, it is so too in the second coordinate. Hence $\langle \cdot , \cdot \rangle$ is a
symmetric bilinear form inducing $\| \cdot \|$.

\textit{2.~Case.} In the case $\fldK = \C$ use complex polarization and put
\[
   \langle v , w \rangle = \frac 14 \sum_{k=1}^4 \cplxi^k \, \| v + \cplxi^k \, w \|^2
   \quad \text{for all } v,w\in \vectorspV  \ .
\]
Then  $\langle \cdot , \cdot \rangle$ is conjugate symmetric, since
\[
   \overline{\langle v , w \rangle} = \frac 14 \sum_{k=1}^4 (- \cplxi)^k \, \| v + \cplxi^k \, w \|^2
   =   \frac 14 \sum_{k=1}^4 (-\cplxi)^k \, \| (-\cplxi)^k \, v +  w \|^2 =
   \langle w , v \rangle \ .
\]
Next compute
\[
  \Re \langle v , w \rangle =  \frac 14 \left( \| v + w \|^2  - \| v - w \|^2 \right)
\]
and
\[
  \Im \langle v , w \rangle =  \frac 14 \left( \| v + \cplxi w \|^2  - \| v - \cplxi w \|^2 \right) \ .
\]
By the first case one concludes that  $\Re \langle \cdot , \cdot \rangle$ and $\Im \langle \cdot , \cdot \rangle$
are both $\R$-linear in the first  and the second coordinate. Moreover,
\[
  \Re \langle \cplxi  v , w \rangle =  \frac 14 \left( \| \cplxi v + w \|^2  - \| \cplxi v - w \|^2 \right)
  = \frac 14 \left( \| v - \cplxi w \|^2  - \| v + \cplxi w \|^2 \right) =
  - \Im \langle v ,  w \rangle
\]
and
\[
  \Im \langle \cplxi \, v , w \rangle =
  \frac 14 \left( \| \cplxi v + \cplxi w \|^2  - \| \cplxi v - \cplxi w \|^2 \right) =
  \Re \langle  v , w \rangle \ ,
\]
hence $\langle \cdot , \cdot \rangle$ is complex linear in the first coordinate.
Finally,
\[
  \Re \langle v , v \rangle =  \| v  \|^2 \quad \text{and} \quad
  \Im \langle v , v \rangle =  \frac 14 \left( \| v + \cplxi v \|^2  - \| v - \cplxi v \|^2 \right) = 0 \ .
\]
This finishes the proof that $ \langle \cdot , \cdot \rangle$ is a complex inner product inducing the
norm $\| \cdot \|$.
\end{proof}

\para
Next we will turn Hilbert spaces into a category. To this end one needs to know what morphisms in this
category should be. There are two options each giving rise to a category of Hilbert spaces. These categories
just differ by their morphism classes. The first one is to
have as morphisms  linear maps $A:\hilbertH_1\to\hilbertH_2$ preserving the inner products which means that
they fulfill
\[
  \inprod{Av_1,Av_2} = \inprod{v_1,v_2}  \quad \text{for all } v_1,v_2 \in \hilbertH_1 \ .
\]
By \Cref{thm:parallegram-identity-guarantees-that-norm-comes-from-some-inner-product} this property is
equivalent to
\[
  \| Av \| = \| v \| \quad \text{for all } v \in \hilbertH_1 \ ,
\]
that is to $A$ being \emph{norm preserving} or \emph{isometric}. Obviously, the identity map between two
Hilbert spaces is isometric and the composition of two composable isometric linear maps between Hilbert
spaces is again isometric and linear. Hence Hilbert spaces together with norm preserving linear maps between
them form a  category which we denote by $\category{Hilb_\textup{np}}$. The isomorphisms in this category
are the surjective and inner product preserving linear maps between Hilbert spaces. Such maps
are called \emph{unitary}. The condition of a linear map being norm preserving is pretty restrictive, so
the category $\category{Hilb_\textup{np}}$ contains only few morphisms. This can be healed by allowing all
\emph{bounded} linear maps between Hilbert spaces to be morphisms that is of all
linear $A:\hilbertH_1\to\hilbertH_2$ for which there exists a $C\geq 0$ such that
\[
  \| Av \| \leq C \| v \| \quad \text{for all } v \in \hilbertH_1 \ .
\]
The smallest such $C$ is called the \emph{operator norm} of $A$ and is denoted $\| A\|$.
Equivalently, the operator norm is given by
\[
  \| A\| = \sup \big\{ \| Av \| \bigmid v\in \hilbertH_1, \, \| v \| \leq 1 \big\}
  = \sup \big\{ \| Av \| \bigmid v\in \hilbertH_1, \, \| v \| = 1 \big\} \ .
\]
Every norm preserving linear map is bounded with operator norm $1$.
In particular the identity map on a Hilbert space is bounded. Moreover, if
$A: \hilbertH_1\to\hilbertH_2$  and $B: \hilbertH_2\to\hilbertH_3$ are bounded linear operators
between Hilbert spaces, then the composition $BA :  \hilbertH_1\to\hilbertH_3$ is bounded
with operator norm $\leq \| B\|\, \| A\|$ since for all $v \in \hilbertH_1 $ with $\| v\|\leq 1$
\[
  \| BAv \| \leq \| B \| \, \|Av\| \leq \| B\|\, \| A\| \ .
\]
Hence Hilbert spaces as objects together with bounded linear maps as morphisms form a category which we
denote by $\category{Hilb}$ and call the \emph{category of Hilbert spaces}. Note that the morphisms
in this category appear to ``forget'' the inner product and just preserve the linear and the topological
structure. John Baez \cite[p.~133]{BaeHDAII2HS} has explained how to heal this apparent defect by showing that
$\category{Hilb}$ carries a so-called $*$-structure given by the adjoint map on bounded linear operators.
We will come back to this point later when we introduce adjoint operators.

\para
Last in this section we will introduce bounded bilinear and sesquilinear maps. We define them for normed
vector spaces. Their main application lies in the operator theory on Hilbert spaces, so we introduce
them here.

\begin{definition}
  Let $\vectorspV$ be a vector space over $\fldK$ with norm $\| \cdot \| : \vectorspV \to \R_{\geq 0}$.
  A bilinear or sesquilinear form $b : \vectorspV \times \vectorspV \to \fldK$ is called \emph{bounded} if
  there exists a $C >0$ such that
  \[
    | b(v,w)| \leq C \, \| v\| \, \| w \| \quad \text{for all } v,w \in \vectorspV \ .
  \]
  In this case,
  \[
    \| b \| := \sup \big\{ | b(v,w) | \bigmid v,w \in \vectorspV \: \& \: \| v\| = \| w \| = 1 \big\}
  \]
  exists and is called the \emph{norm} of the form $b$.
\end{definition}
\begin{example}
  The inner product on a (pre-) Hilbert space is bounded by the Cauchy--Schwarz inequality and has norm $1$.
\end{example}

\begin{proposition}
A bounded bilinear or sesquilinear form $b : \vectorspV \times \vectorspV \to \fldK$ on a normed vector space $\vectorspV$ over
$\fldK$ is continuous. Vice versa, if $\vectorspV$ is complete, then continuity of $b : \vectorspV \times \vectorspV \to \fldK$
implies boundedness.
 \end{proposition}
\begin{proof}
If $b$ is bounded, then
\begin{equation*}
  \begin{split}
  \big\vert b(v,w) - b(v',w') \big\vert \, &
  \leq   \big\vert b(v,w) - b(v',w) \big\vert + \big\vert b(v',w) - b(v',w') \big\vert \leq \\
  & \leq \| b \| \, \left( \|  w \| \, \| v-v'\| +  \|  v' \| \, \| w-w'\| \right)
  \end{split}
\end{equation*}
for all $v,v',w,w' \in \vectorspV$. Hence $b$ is locally Lipschitz continuous, so in particular continuous.

Now assume that $\vectorspV$ is a Banach space and that $b$ is continuous. Then one can find $\delta >0$ such that
for all $v,w \in  V$ of norm less than $\delta$ the relation $ |b(v,w)| < 1$ holds true. But that entails for all
non-zero $v,w$
\[
   |b(v,w)| = \frac{4 \, \|v\| \, \|w\|}{\delta^2} \cdot b\left( \delta \frac{v}{2 \|v\|}, \delta \frac{w}{2 \|w\|}\right)
   \leq  \frac{4}{ \delta^2} \|v\| \, \|w\| \ .
\]
Hence $b$ is bounded.
\end{proof}


\providecommand{\main}{../..}
\documentclass[\main/thesis.tex]{subfiles}
\begin{document}

\section{Num: a representation for positional numeral systems}\label{num}

\subsection{Definition}

Numerals of positional numeral systems are composed of sequences of digits.
Consequently the definition of {\lstinline|Numeral|} will be similar to that of
{\lstinline|List|},
except that a {\lstinline|Numeral|} must contain at least one digit while a list
may contain no elements at all.
The most significant digit is placed near {\lstinline|_∙|} while the least
significant digit is placed at the end of the sequence.

{\lstinline|Numeral|} has three indices, which corresponds to the three
generalizations we have introduced.

\begin{lstlisting}
infixr 5 _∷_

data Numeral : (b d o : ℕ) → Set where
    _∙  : ∀ {b d o} → Digit d → Numeral b d o
    _∷_ : ∀ {b d o} → Digit d → Numeral b d o → Numeral b d o
\end{lstlisting}

The decimal number ``2016'' for example can be represented as:

\begin{lstlisting}
MMXVI : Numeral 10 10 0
MMXVI = # 6 ∷ # 1 ∷ # 0 ∷ (# 2) ∙
\end{lstlisting}
%
where {\lstinline|#_ : ∀ m {n} {m<n : True (suc m ≤? n)} → Fin n|} converts from
{\lstinline|ℕ|} to {\lstinline|Fin n|} provided that the number is small enough.

\lstinline|lsd| extracts the least significant digit of a numeral.

\begin{lstlisting}
lsd : ∀ {b d o} → (xs : Numeral b d o) → Digit d
lsd (x ∙   ) = x
lsd (x ∷ xs) = x
\end{lstlisting}

\subsection{Converting to natural numbers}

Converting to natural numbers is fairly trivial.

\begin{lstlisting}
⟦_⟧ : ∀ {b d o} → (xs : Numeral b d o) → ℕ
⟦_⟧ {_} {_} {o} (x ∙)    = Digit-toℕ x o
⟦_⟧ {b} {_} {o} (x ∷ xs) = Digit-toℕ x o + ⟦ xs ⟧ * b
\end{lstlisting}

\section{Dissecting Numeral Systems with Views}\label{views}

There are many kinds of numeral systems inhabit in {\lstinline|Numeral|}.
These systems have different interesting properties that should be treated
differently, so we sort them into \textbf{four categories} accordingly.

\paragraph{Systems with no digits at all}

The number of digits of a system is determined by the index {\lstinline|d|}.
If {\lstinline|d|} happens to be $ 0 $, then there will be no digits in any of
these systems. Although they seem useless, these systems have plenty of properties.
Since there are not digits at all, any property that is related to digits would
hold vacuously.

\paragraph{Systems with base $0$}

If {\lstinline|b|}, the base of a system, happens to be $ 0 $,
then only the least significant digit would have effects on the evaluation,
because the rest of the digits would diminish into nothing.

\begin{lstlisting}
⟦ x ∙    ⟧ = Digit-toℕ x o
⟦ x ∷ xs ⟧ = Digit-toℕ x o + ⟦ xs ⟧ * 0
\end{lstlisting}

\paragraph{Systems with only zeros}

Consider when {\lstinline|d|} is set to $ 1 $ and {\lstinline|o|} set to $ 0 $.
There will be one digit. however, the only digit can only be assigned to $ 0 $.

\begin{lstlisting}
0, 00, 000, 0000, ...
\end{lstlisting}

As a result, every numeral would evaluate to $ 0 $ regardless of the base.

\paragraph{``Proper'' systems}

The rest of systems that does not fall into any of the categories above
are considered \textit{proper}.

\subsection{Categorizing Systems}

These ``categories'' are represented with a datatype called {\lstinline|NumView|}
that is indexed by the three indices: {\lstinline|b|}, {\lstinline|d|}, and {\lstinline|o|}.

\begin{lstlisting}
data NumView : (b d o : ℕ) → Set where
    NullBase    : ∀   d o → NumView 0       (suc d) o
    NoDigits    : ∀ b o   → NumView b       0       o
    AllZeros    : ∀ b     → NumView (suc b) 1       0
    Proper      : ∀ b d o → (proper : suc d + o ≥ 2)
                          → NumView (suc b) (suc d) o
\end{lstlisting}

By pattern matching on indices, different configurations of indices are sorted into
different {\lstinline|NumView|}s.

\begin{lstlisting}
numView : ∀ b d o → NumView b d o
numView b       zero          o       = NoDigits b o
numView zero    (suc d)       o       = NullBase d o
numView (suc b) (suc zero)    zero    = AllZeros b
numView (suc b) (suc zero)    (suc o) = Proper b zero (suc o) _
numView (suc b) (suc (suc d)) o       = Proper b (suc d) o _
\end{lstlisting}

Together with \textit{with-abstractions}, we can, for example, define a function
to determine whether a numeral system is interesting or not:

\begin{lstlisting}
interesting : ∀ b d o → Bool
interesting b d o with numView b d o
interesting _ _ _ | NullBase d o         = false
interesting _ _ _ | NoDigits b o         = false
interesting _ _ _ | AllZeros b           = false
interesting _ _ _ | Proper b d o proper  = true
\end{lstlisting}

As we can see, the function {\lstinline|numView|} does more than sorting indices
into different categories. It also reveals relevant information and properties
about these categories. For instance, if a system {\lstinline|Numeral b d o|}
is classified as \textit{Proper}, then we know that:

\begin{itemize}
    \item {\lstinline|b|} is greater than $ 0 $.
    \item {\lstinline|d|} is also greater than $ 0 $.
    \item {\lstinline|o|} can be any value as long as {\lstinline|d + o ≥ 2|};
        we name this requirement \textit{proper}.
\end{itemize}

\subsection{Views}

The sole purpose of {\lstinline|NumView|} is to sort out and expose some
interesting properties about its indices.
Such datatypes are called \textit{views}\cite{wadler1987views} as they present
different aspects of the same object.
Functions like {\lstinline|numView|} are called \textit{view functions} or
\textit{eliminators}\cite{mcbride2004views} because they provide different ways
of eliminating a datatype.

Views are \textbf{reusable} as they free us from having to pattern match on the
same indices or data again and again. On the other hand, they can be customized
to our needs since they are just \textit{ordinary functions}.
We will define more views and use them extensively in the coming sections.

\section{Properties of each Category}

\paragraph{NoDigits}

Although systems with no digits have no practical use,
they are pretty easy to deal with because all properties related to digits would
hold unconditionally for systems of {\lstinline|NoDigits|}.
This is proven by deploying \textit{the principle of explosion}.

\begin{lstlisting}
NoDigits-explode : ∀ {b o a} {Whatever : Set a}
    → (xs : Numeral b 0 o)
    → Whatever
NoDigits-explode (() ∙   )
NoDigits-explode (() ∷ xs)
\end{lstlisting}

\paragraph{NullBase}

The theorem below states that, evaluating a numeral of {\lstinline|NullBase|}
would results the same value as evaluating its least significant digit.

\begin{lstlisting}
toℕ-NullBase : ∀ {d o}
    → (x : Digit d)
    → (xs : Numeral 0 d o)
    → ⟦ x ∷ xs ⟧ ≡ Digit-toℕ x o
toℕ-NullBase {d} {o} x xs =
    begin
        Digit-toℕ x o + ⟦ xs ⟧ * 0
    ≡⟨ cong (λ w → Digit-toℕ x o + w) (*-right-zero ⟦ xs ⟧) ⟩
        Digit-toℕ x o + 0
    ≡⟨ +-right-identity (Digit-toℕ x o) ⟩
        Digit-toℕ x o
    ∎
\end{lstlisting}

\paragraph{AllZeros}

The theorem below states every numeral of {\lstinline|AllZeros|}
would evaluate to $ 0 $ regardless of the base.
We pattern match on the digit to eliminate other possible cases to exploit the
fact that there is only one digit in such numerals.

\begin{lstlisting}
toℕ-AllZeros : ∀ {b} → (xs : Numeral b 1 0) → ⟦ xs ⟧ ≡ 0
toℕ-AllZeros     (z    ∙   ) = refl
toℕ-AllZeros     (s () ∙   )
toℕ-AllZeros {b} (z    ∷ xs)
    = cong (λ w → w * b) (toℕ-AllZeros xs)
toℕ-AllZeros     (s () ∷ xs)
\end{lstlisting}

\end{document}