% !TEX root = lectures.tex
\section{Oscillations}
\bigskip

\subsection{Harmonic Oscillator}

The harmonic oscillator is omnipresent in physics. Although students think of this as being related to springs, it, or an equivalent mathematical representation, appears in just about any problem where a mode is sitting near its potential energy minimum. At that point, $\partial_x V(x)=0$, and the first non-zero term (aside from a constant) in the potential energy is that of a harmonic oscillator. In a solid, sound modes (phonons) are built on a picture of coupled harmonic oscillators, and in relativistic field theory the fundamental interactions are also built on coupled oscillators positioned infinitesimally close to one another in space. The phenomena of a resonance of an oscillator driven at a fixed frequency plays out repeatedly in atomic, nuclear and high-energy physics, when quantum mechanically the evolution of a state oscillates according to $e^{-iEt}$ and exciting discrete quantum states has very similar mathematics as exciting discrete states of an oscillator.

The potential energy for a single particle as a function of its position $x$ can be written as a Taylor expansion about some point $x_0$
\begin{equation}
V(x)=V(x_0)+(x-x_0)\left.\partial_xV(x)\right|_{x_0}+\frac{1}{2}(x-x_0)^2\left.\partial_x^2V(x)\right|_{x_0}
+\frac{1}{3!}\left.\partial_x^3V(x)\right|_{x_0}+\cdots
\end{equation}
If the position $x_0$ is at the minimum of the resonance, the first two non-zero terms of the potential are
\begin{eqnarray}
V(x)&\approx& V(x_0)+\frac{1}{2}(x-x_0)^2\left.\partial_x^2V(x)\right|_{x_0},\\
\nonumber
&=&V(x_0)+\frac{1}{2}k(x-x_0)^2,~~~~k\equiv \left.\partial_x^2V(x)\right|_{x_0},\\
\nonumber
F&=&-\partial_xV(x)=-k(x-x_0).
\end{eqnarray}

Put into Newton's 2nd law (assuming $x_0=0$),
\begin{eqnarray}
m\ddot{x}&=&-kx,\\
x&=&A\cos(\omega_0 t-\phi),~~~\omega_0=\sqrt{k/m}.
\end{eqnarray}
Here $A$ and $\phi$ are arbitrary. Equivalently, one could have written this as $A\cos(\omega_0 t)+B\sin(\omega_0 t)$, or as the real part of $Ae^{i\omega_0 t}$. In this last case $A$ could be an arbitrary complex constant. Thus, there are 2 arbitrary constants (either $A$ and $B$ or $A$ and $\phi$, or the real and imaginary part of one complex constant. This is the expectation for a second order differential equation, and also agrees with the physical expectation that if you know a particle's initial velocity and position you should be able to define its future motion, and that those two arbitrary conditions should translate to two arbitrary constants.

A key feature of harmonic motion is that the system repeats itself after a time $T=1/f$, where $f$ is the frequency, and $\omega=2\pi f$ is the angular frequency. The period of the motion is independent of the amplitude. However, this independence is only exact when one can neglect higher terms of the potential, $x^3, x^4\cdots$. Once can neglect these terms for sufficiently small amplitudes, and for larger amplitudes the motion is no longer purely sinusoidal, and even though the motion repeats itself, the time for repeating the motion is no longer independent of the amplitude.

One can also calculate the velocity and the kinetic energy as a function of time,
\begin{eqnarray}
\dot{x}&=&-\omega_0A\sin(\omega_0 t-\phi),\\
\nonumber
T&=&\frac{1}{2}m\dot{x}^2=\frac{m\omega_0^2A^2}{2}\sin^2(\omega_0t-\phi),\\
\nonumber
&=&\frac{k}{2}A^2\sin^2(\omega_0t-\phi).
\end{eqnarray}
The total energy is then
\begin{equation}
E=T+U=\frac{1}{2}m\dot{x}^2+\frac{1}{2}kx^2=\frac{1}{2}kA^2.
\end{equation}
The total energy then goes as the square of the amplitude.

\example
A pendulum is an example of a harmonic oscillator. By expanding the kinetic and potential energies for small angles find the frequency for a pendulum of length $L$ with all the mass $m$ centered at the end by writing the eq.s of motion in the form of a harmonic oscillator.

{\bf Solution:} The potential energy and kinetic energies are (for $x$ being the displacement)
\begin{eqnarray*}
U&=&mgL(1-\cos\theta)\approx mgL\frac{x^2}{2L^2},\\
T&=&\frac{1}{2}mL^2\dot{\theta}^2\approx \frac{m}{2}\dot{x}^2.
\end{eqnarray*}
For small $x$ Newton's 2nd law becomes
\[
m\ddot{x}=-\frac{mg}{L}x,
\]
and the spring constant would appear to be $k=mg/L$, which makes the frequency equal to $\omega_0=\sqrt{g/L}$. Note that the frequency is independent of the mass.

\exampleend

\subsection{Damped Oscillators}

In this chapter we consider only the case where the damping force is proportional to the velocity. This is counter to dragging friction, where the force is proportional in strength to the normal force and independent of velocity, and is also inconsistent with wind resistance, where the magnitude of the drag force is proportional the square of the velocity. Rolling resistance does seem to be mainly proportional to the velocity. However, the main motivation for considering damping forces proportional to the velocity is that the math is more friendly. This is because the differential equation is linear, i.e. each term is of order $x$, $\dot{x}$, $\ddot{x}\cdots$, or even terms with no mention of $x$, and there are no terms such as $x^2$ or $x\ddot{x}$. The equations of motion for a spring with damping force $-b\dot{x}$ are
\begin{equation}
m\ddot{x}+b\dot{x}+kx=0.
\end{equation}
Just to make the solution a bit less messy, we rewrite this equation as
\begin{equation}
\label{eq:dampeddiffyq}
\ddot{x}+2\beta\dot{x}+\omega_0^2x=0,~~~~\beta\equiv b/2m,~\omega_0\equiv\sqrt{k/m}.
\end{equation}
Both $\beta$ and $\omega$ have dimensions of inverse time. To find solutions (see appendix C in the text) you must make an educated guess at the form of the solution. To do this, first realize that the solution will need an arbitrary normalization $A$ because the equation is linear. Secondly, realize that if the form is
\begin{equation}
x=Ae^{rt}
\end{equation}
that each derivative simply brings out an extra power of $r$. This means that the $Ae^{rt}$ factors out and one can simply solve for an equation for $r$. Plugging this form into Eq. (\ref{eq:dampeddiffyq}),
\begin{equation}
r^2+2\beta r+\omega_0^2=0.
\end{equation}
Because this is a quadratic equation there will be two solutions,
\begin{equation}
r=-\beta\pm\sqrt{\beta^2-\omega_0^2}.
\end{equation}
We refer to the two solutions as $r_1$ and $r_2$ corresponding to the $+$ and $-$ roots. As expected, there should be two arbitrary constants involved in the solution,
\begin{equation}
x=A_1e^{r_1t}+A_2e^{r_2t},
\end{equation}
where the coefficients $A_1$ and $A_2$ are determined by initial conditions.

The roots listed above, $\sqrt{\omega_0^2-\beta_0^2}$, will be imaginary if the damping  is small and $\beta<\omega_0$. In that case, $r$ is complex and the factor $e{rt}$ will have some oscillatory behavior. If the roots are real, there will only be exponentially decaying solutions. There are three cases:
\begin{enumerate}\itemsep 0pt
\item Underdamped: $\beta<\omega_0$
\begin{eqnarray}
x&=&A_1e^{-\beta t}e^{i\omega't}+A_2e^{-\beta t}e^{-i\omega't},~~\omega'\equiv\sqrt{\omega_0^2-\beta^2}\\
\nonumber
&=&(A_1+A_2)e^{-\beta t}\cos\omega't+i(A_1-A_2)e^{-\beta t}\sin\omega't.
\end{eqnarray}
Here we have made use of the identity $e^{i\omega't}=\cos\omega't+i\sin\omega't$. Because the constants are arbitrary, and because the real and imaginary parts are both solutions individually, we can simply consider the real part of the solution alone:
\begin{eqnarray}
\label{eq:homogsolution}
x&=&B_1e^{-\beta t}\cos\omega't+B_2e^{-\beta t}\sin\omega't,\\
\nonumber
\omega'&\equiv&\sqrt{\omega_0^2-\beta^2}.
\end{eqnarray}

\item Critical dampling: $\beta=\omega_0$\\
In this case the two terms involving $r_1$ and $r_2$ are identical because $\omega'=0$. Because we need to arbitrary constants, there needs to be another solution. This is found by simply guessing, or by taking the limit of $\omega'\rightarrow 0$ from the underdamped solution. The solution is then
\begin{equation}
\label{eq:criticallydamped}
x=Ae^{-\beta t}+Bte^{-\beta t}.
\end{equation}
The critically damped solution is interesting because the solution approaches zero quickly, but does not oscillate. For a problem with zero initial velocity, the solution never crosses zero. This is a good choice for designing shock absorbers or swinging doors.
\item Overdamped: $\beta>\omega_0$
\begin{eqnarray}
x&=&A_1e^{-(\beta+\sqrt{\beta^2-\omega_0^2})t}+A_2e^{-(\beta-\sqrt{\beta^2-\omega_0^2})t}
\end{eqnarray}
This solution will also never pass the origin more than once, and then only if the initial velocity is strong and initially toward zero.
\end{enumerate}

\example
Given $b$, $m$ and $\omega_0$, find $x(t)$ for a particle whose initial position is $x=0$ and has initial velocity $v_0$ (assuming an underdamped solution).

{\bf Solution:} The solution is of the form,
\begin{eqnarray*}
x&=&e^{-\beta t}\left[A_1\cos(\omega' t)+A_2\sin\omega't\right],\\
\dot{x}&=&-\beta x+\omega'e^{-\beta t}\left[-A_1\sin\omega't+A_2\cos\omega't\right].\\
\omega'&\equiv&\sqrt{\omega_0^2-\beta^2},~~~\beta\equiv b/2m.
\end{eqnarray*}
From the initial conditions, $A_1=0$ because $x(0)=0$ and $\omega'A_2=v_0$. So
\[
x=\frac{v_0}{\omega'}e^{-\beta t}\sin\omega't.
\]
\exampleend

\subsection{Sinusoidally Driven Oscillators}

Here, we consider the force
\begin{equation}
F=-kx-b\dot{x}+F_0\cos\omega t,
\end{equation}
which leads to the differential equation
\begin{equation}
\label{eq:drivenosc}
\ddot{x}+2\beta\dot{x}+\omega_0^2x=(F_0/m)\cos\omega t.
\end{equation}
Consider a single solution with no arbitrary constants, which we will call a {\it particular solution}, $x_p(t)$. It should be emphasized that this is {\bf A} particular solution, because there exists an infinite number of such solutions because the general solution should have two arbitrary constants. Now consider solutions to the same equation without the driving term, which include two arbitrary constants. These are called either {\it homogenous solutions} or {\it complementary solutions}, and were given in the previous section, e.g. Eq. (\ref{eq:homogsolution}) for the underdamped case. The homogenous solution already incorporates the two arbitrary constants, so any sum of a homogenous solution and a particular solution will represent the {\it general solution} of the equation. The general solution incorporates the two arbitrary constants $A$ and $B$ to accommodate the two initial conditions. One could have picked a different particular solution, i.e. the original particular solution plus any homogenous solution with the arbitrary constants $A_p$ and $B_p$ chosen at will. When one adds in the homogenous solution, which has adjustable constants with arbitrary constants $A'$ and $B'$, to the new particular solution, one can get the same general solution by simply adjusting the new constants such that $A'+A_p=A$ and $B'+B_p=B$. Thus, the choice of $A_p$ and $B_p$ are irrelevant, and when choosing the particular solution it is best to make the simplest choice possible.

To find a particular solution, one first guesses at the form,
\begin{equation}
\label{eq:partform}
x_p(t)=D\cos(\omega t-\delta),
\end{equation}
and rewrite the differential equation as
\begin{equation}
D\left\{-\omega^2\cos(\omega t-\delta)-2\beta\omega\sin(\omega t-\delta)+\omega_0^2\cos(\omega t-\delta)\right\}=\frac{F_0}{m}\cos(\omega t).
\end{equation}
One can now use angle addition formulas to get
\begin{eqnarray}
D\left\{(-\omega^2\cos\delta+2\beta\omega\sin\delta+\omega_0^2\cos\delta)\cos(\omega t)\right.\hspace*{36pt}&&\\
\nonumber
\left.+(-\omega^2\sin\delta-2\beta\omega\cos\delta+\omega_0^2\sin\delta)\sin(\omega t)\right\}
&=&\frac{F_0}{m}\cos(\omega t).
\end{eqnarray}
Both the $\cos$ and $\sin$ terms need to equate if the expression is to hold at all times. Thus, this becomes two equations
\begin{eqnarray}
D\left\{-\omega^2\cos\delta+2\beta\omega\sin\delta+\omega_0^2\cos\delta\right\}&=&\frac{F_0}{m}\\
\nonumber
-\omega^2\sin\delta-2\beta\omega\cos\delta+\omega_0^2\sin\delta&=&0.
\end{eqnarray}
After dividing by $\cos\delta$, the lower expression leads to
\begin{equation}
\tan\delta=\frac{2\beta\omega}{\omega_0^2-\omega^2}.
\end{equation}
Using the identities $\tan^2+1=\csc^2$ and $\sin^2+\cos\^2=1$, one can also express $\sin\delta$ and $\cos\delta$,
\begin{eqnarray}
\sin\delta&=&\frac{2\beta\omega}{\sqrt{(\omega_0^2-\omega^2)^2+4\omega^2\beta^2}},\\
\nonumber
\cos\delta&=&\frac{(\omega_0^2-\omega^2)}{\sqrt{(\omega_0^2-\omega^2)^2+4\omega^2\beta^2}}
\end{eqnarray}
Inserting the expressions for $\cos\delta$ and $\sin\delta$ into the expression for $D$,
\begin{equation}
\label{eq:Ddrive}
D=\frac{F_0/m}{\sqrt{(\omega_0^2-\omega^2)^2+4\omega^2\beta^2}}.
\end{equation}

For a given initial condition, e.g. initial displacement and velocity, one must add the homogenous solution then solve for the two arbitrary constants. However, because the homogenous solutions decay with time as $e^{-\beta t}$, the particular solution is all that remains at large times, and is therefore the steady state solution. Because the arbitrary constants are all in the homogenous solution, all memory of the initial conditions are lost at large times, $t>>1/\beta$.

The amplitude of the motion, $D$, is linearly proportional to the driving force ($F_0/m$), but also depends on the driving frequency $\omega$. For small $\beta$ the maximum will occur at $\omega=\omega_0$. This is referred to as a resonance. In the limit $\beta\rightarrow 0$ the amplitude at resonance approaches infinity.

\subsection{Alternative Derivation for Driven Oscillators}

Here, we derive the same expressions as in Eq.s (\ref{eq:partform}-\ref{eq:Ddrive}) but express the driving forces as
\begin{eqnarray}
F(t)&=&F_0e^{i\omega t},
\end{eqnarray}
rather than as $F_0\cos\omega t$. The real part of $F$ is the same as before. For the differential equation,
\begin{eqnarray}
\label{eq:compdrive}
\ddot{x}+2\beta\dot{x}+\omega_0^2x&=&\frac{F_0}{m}e^{i\omega t},
\end{eqnarray}
one can treat $x(t)$ as an imaginary function. Because the operations $d^2/dt^2$ and $d/dt$ are real and thus do not mix the real and imaginary parts of $x(t)$, Eq. (\ref{eq:compdrive}) is effectively 2 equations. Because $e^{\omega t}=\cos\omega t+i\sin\omega t$, the real part of the solution for $x(t)$ gives the solution for a driving force $F_0\cos\omega t$, and the imaginary part of $x$ corresponds to the case where the driving force is $F_0\sin\omega t$. It is rather easy to solve for the complex $x$ in this case, and by taking the real part of the solution, one finds the answer for the $\cos\omega t$ driving force.

We assume a simple form for the particular solution
\begin{equation}
x_p=De^{i\omega t},
\end{equation}
where $D$ is a complex constant.

From Eq. (\ref{eq:compdrive}) one inserts the form for $x_p$ above to get
\begin{eqnarray}
D\left\{-\omega^2+2i\beta\omega+\omega_0^2\right\}e^{i\omega t}=(F_0/m)e^{i\omega t},\\
\nonumber
D=\frac{F_0/m}{(\omega_0^2-\omega^2)+2i\beta\omega}.
\end{eqnarray}
The norm and phase for $D=|D|e^{-i\delta}$ can be read by inspection,
\begin{equation}
|D|=\frac{F_0/m}{\sqrt{(\omega_0^2-\omega^2)^2+4\beta^2\omega^2}},~~~~\tan\delta=\frac{2\beta\omega}{\omega_0^2-\omega^2}.
\end{equation}
This is the same expression for $\delta$ as before. One then finds $x_p(t)$,
\begin{eqnarray}
\label{eq:fastdriven1}
x_p(t)&=&\Re\frac{(F_0/m)e^{i\omega t-i\delta}}{\sqrt{(\omega_0^2-\omega^2)^2+4\beta^2\omega^2}}\\
\nonumber
&=&\frac{(F_0/m)\cos(\omega t-\delta)}{\sqrt{(\omega_0^2-\omega^2)^2+4\beta^2\omega^2}}.
\end{eqnarray}
This is the same answer as before.
If one wished to solve for the case where $F(t)= F_0\sin\omega t$, the imaginary part of the solution would work
\begin{eqnarray}
\label{eq:fastdriven2}
x_p(t)&=&\Im\frac{(F_0/m)e^{i\omega t-i\delta}}{\sqrt{(\omega_0^2-\omega^2)^2+4\beta^2\omega^2}}\\
\nonumber
&=&\frac{(F_0/m)\sin(\omega t-\delta)}{\sqrt{(\omega_0^2-\omega^2)^2+4\beta^2\omega^2}}.
\end{eqnarray}

\example
Consider the damped and driven harmonic oscillator worked out above. Given $F_0, m,\beta$ and $\omega_0$, solve for the complete solution $x(t)$ for the case where $F=F_0\sin\omega t$ with initial conditions $x(t=0)=0$ and $v(t=0)=0$. Assume the underdamped case.

{\bf Solution:}
The general solution including the arbitrary constants includes both the homogenous and particular solutions,
\begin{eqnarray*}
x(t)&=&\frac{F_0}{m}\frac{\sin(\omega t-\delta)}{\sqrt{(\omega_0^2-\omega^2)^2+4\beta^2\omega^2}}
+A\cos\omega't e^{-\beta t}+B\sin\omega't e^{-\beta t}.
\end{eqnarray*}
The quantities $\delta$ and $\omega'$ are given earlier in the section, $\omega'=\sqrt{\omega_0^2-\beta^2}, \delta=\tan^{-1}(2\beta\omega/(\omega_0^2-\omega^2)$. Here, solving the problem means finding the arbitrary constants $A$ and $B$. Satisfying the initial conditions for the initial position and velocity:
\begin{eqnarray*}
x(t=0)=0&=&-\eta\sin\delta+A,\\
v(t=0)=0&=&\omega\eta\cos\delta-\beta A+\omega'B,\\
\eta&\equiv&\frac{F_0}{m}\frac{1}{\sqrt{(\omega_0^2-\omega^2)^2+4\beta^2\omega^2}}.
\end{eqnarray*}
The problem is now reduced to 2 equations and 2 unknowns, $A$ and $B$. The solution is
\begin{eqnarray}
A&=& \eta\sin\delta ,~~~B=\frac{-\omega\eta\cos\delta+\beta\eta\sin\delta}{\omega'}.
\end{eqnarray}

\exampleend

\subsection{Resonance Widths; the $Q$ factor}

From the previous two sections, the particular solution for a driving force, $F=F_0\cos\omega t$, is
\begin{eqnarray}
x_p(t)&=&\frac{F_0/m}{\sqrt{(\omega_0^2-\omega^2)^2+4\omega^2\beta^2}}\cos(\omega_t-\delta),\\
\nonumber
\delta&=&\tan^{-1}\left(\frac{2\beta\omega}{\omega_0^2-\omega^2}\right).
\end{eqnarray}
If one fixes the driving frequency $\omega$ and adjusts the fundamental frequency $\omega_0=\sqrt{k/m}$, the maximum amplitude occurs when $\omega_0=\omega$ because that is when the term from the denominator $(\omega_0^2-\omega^2)^2+4\omega^2\beta^2$ is at a minimum. This is akin to dialing into a radio station. However, if one fixes $\omega_0$ and adjusts the driving frequency one minimize with respect to $\omega$, e.g. set
\begin{equation}
\frac{d}{d\omega}\left[(\omega_0^2-\omega^2)^2+4\omega^2\beta^2\right]=0,
\end{equation}
and one finds that the maximum amplitude occurs when $\omega=\sqrt{\omega_0^2-2\beta^2}$. If $\beta$ is small relative to $\omega_0$, one can simply state that the maximum amplitude is
\begin{equation}
x_{\rm max}\approx\frac{F_0}{2m\beta \omega_0}.
\end{equation}
\begin{figure}
\centerline{\includegraphics[width=0.32\textwidth]{figs/qfactor}}
\caption{\label{fig:qfactor}
The maximum amplitude squared of the steady-state motion of a sinusoidally driven harmonic oscillator is shown as a function of the driving frequency $\omega$. This peaks near the fundamental frequency $\omega_0$ and the full-width-half-maximum, $FWHM$, is given by the damping, $2\beta$.}
\end{figure}
Figure \ref{fig:qfactor} displays the maximum amplitude squared as a function of $\omega$, and  one can see the peak at $\omega\approx\omega_0$. The squared amplitude is usually more the quantity of interest than the amplitude because the power being absorbed by the oscillator is proportional to the square of the amplitude, not the amplitude. The width of the peak is quantified by the full-width-half-maximum, sometimes called $FWHM$ and can be found by finding the frequency difference, $\omega-\omega_0$, such that the maximum response falls by a factor of two,
\begin{eqnarray}
\frac{4\omega^2\beta^2}{(\omega_0^2-\omega^2)^2+4\omega^2\beta^2}=\frac{1}{2}.
\end{eqnarray}
For small damping this occurs when $\omega=\omega_0\pm \beta$, so the $FWHM\approx 2\beta$. For the purposes of tuning to a specific frequency, one wants the width to be as small as possible. The ratio of $\omega_0$ to $FWHM$ is known as the {\it quality} factor, or $Q$ factor,
\begin{equation}
Q\equiv \frac{\omega_0}{2\beta}.
\end{equation}

\subsection{Principal of Superposition and Periodic Forces (Fourier Transforms)}

If one has several driving forces, $F(t)=\sum_n F_n(t)$, one can find the particular solution to each $F_n$, $x_{pn}(t)$, and the particular solution for the entire driving force is
\begin{equation}
x_p(t)=\sum_nx_{pn}(t).
\end{equation}
This is known as the principal of superposition. It only applies when the homogenous equation is linear. If there were an anharmonic term such as $x^3$ in the homogenous equation, then when one summed various solutions, $x=(\sum_n x_n)^2$, one would get cross terms. Superposition is especially useful when $F(t)$ can be written as a sum of sinusoidal terms, because the solutions for each sinusoidal term is analytic, and are given in the previous two subsections.

Driving forces are often periodic, even when they are not sinusoidal. Periodicity implies that for some time $\tau$
\begin{eqnarray}
F(t+\tau)=F(t).
\end{eqnarray}
One example of a non-sinusoidal periodic force is a square wave. Many components in electric circuits are non-linear, e.g. diodes, which makes many wave forms non-sinusoidal even when the circuits are being driven by purely sinusoidal sources.

For the sinusoidal example studied in the previous subsections the period is $\tau=2\pi/\omega$. However, higher harmonics can also satisfy the periodicity requirement. In general, any force that satisfies the periodicity requirement can be expressed as a sum over harmonics,
\begin{equation}
F(t)=\frac{f_0}{2}+\sum_{n>0} f_n\cos(2n\pi t/\tau)+g_n\sin(2n\pi t/\tau).
\end{equation}
From the previous subsection, one can write down the answer for $x_{pn}(t)$, by substituting $f_n/m$ or $g_n/m$ for $F_0/m$ into Eq.s (\ref{eq:fastdriven1}) or (\ref{eq:fastdriven2}) respectively. By writing each factor $2n\pi t/\tau$ as $n\omega t$, with $\omega\equiv 2\pi/\tau$,
\begin{equation}
\label{eq:fourierdef1}
F(t)=\frac{f_0}{2}+\sum_{n>0}f_n\cos(n\omega t)+g_n\sin(n\omega t).
\end{equation}
The solutions for $x(t)$ then come from replacing $\omega$ with $n\omega$ for each term in the particular solution in Eq.s (\ref{eq:partform}-\ref{eq:Ddrive}),
\begin{eqnarray}
x_p(t)&=&\frac{f_0}{2k}+\sum_{n>0} \alpha_n\cos(n\omega t-\delta_n)+\beta_n\sin(n\omega t-\delta_n),\\
\nonumber
\alpha_n&=&\frac{f_n/m}{\sqrt{((n\omega)^2-\omega_0^2)+4\beta^2n^2\omega^2}},\\
\nonumber
\beta_n&=&\frac{g_n/m}{\sqrt{((n\omega)^2-\omega_0^2)+4\beta^2n^2\omega^2}},\\
\nonumber
\delta_n&=&\tan^{-1}\left(\frac{2\beta n\omega}{\omega_0^2-n^2\omega^2}\right).
\end{eqnarray}
Because the forces have been applied for a long time, any non-zero damping eliminates the homogenous parts of the solution, so one need only consider the particular solution for each $n$.

The problem will considered solved if one can find expressions for the coefficients $f_n$ and $g_n$, even though the solutions are expressed as an infinite sum. The coefficients can be extracted from the function $F(t)$ by
\begin{eqnarray}
\label{eq:fourierdef2}
f_n&=&\frac{2}{\tau}\int_{-\tau/2}^{\tau/2} dt~F(t)\cos(2n\pi t/\tau),\\
\nonumber
g_n&=&\frac{2}{\tau}\int_{-\tau/2}^{\tau/2} dt~F(t)\sin(2n\pi t/\tau).
\end{eqnarray}

To check the consistency of these expressions and to verify Eq. (\ref{eq:fourierdef2}), one can insert the expansion of $F(t)$ in Eq. (\ref{eq:fourierdef1}) into the expression for the coefficients in Eq. (\ref{eq:fourierdef2}) and see whether
\begin{eqnarray}
f_n&=?&\frac{2}{\tau}\int_{-\tau/2}^{\tau/2} dt~\left\{
\frac{f_0}{2}+\sum_{m>0}f_m\cos(m\omega t)+g_m\sin(m\omega t)
\right\}\cos(n\omega t).
\end{eqnarray}
Immediately, one can throw away all the terms with $g_m$ because they convolute an even and an odd function. The term with $f_0/2$ disappears because $\cos(n\omega t)$ is equally positive and negative over the interval and will integrate to zero. For all the terms $f_m\cos(m\omega t)$ appearing in the sum, one can use angle addition formulas to see that $\cos(m\omega t)\cos(n\omega t)=(1/2)(\cos[(m+n)\omega t]+\cos[(m-n)\omega t]$. This will integrate to zero unless $m=n$. In that case the $m=n$ term gives
\begin{equation}
\int_{-\tau/2}^{\tau/2}dt~\cos^2(m\omega t)=\frac{\tau}{2},
\end{equation}
and
\begin{eqnarray}
f_n&=?&\frac{2}{\tau}\int_{-\tau/2}^{\tau/2} dt~f_n/2\\
\nonumber
&=&f_n~\checkmark.
\end{eqnarray}
The same method can be used to check for the consistency of $g_n$.

\example
Consider the driving force:
\begin{equation}
F(t)=At/\tau,~~-\tau/2<t<\tau/2,~~~F(t+\tau)=F(t).
\end{equation}
Find the Fourier coefficients $f_n$ and $g_n$ for all $n$ using Eq. (\ref{eq:fourierdef2}).

{\bf Solution:} Only the odd coefficients enter by symmetry, i.e. $f_n=0$. One can find $g_n$ integrating by parts,
\begin{eqnarray}
\label{eq:fouriersolution}
g_n&=&\frac{2}{\tau}\int_{-\tau/2}^{\tau/2}dt~\sin(n\omega t) \frac{At}{\tau}\\
\nonumber
u&=&t,~dv=\sin(n\omega t)dt,~v=-\cos(n\omega t)/(n\omega),\\
\nonumber
g_n&=&\frac{-2A}{n\omega \tau^2}\int_{-\tau/2}^{\tau/2}dt~\cos(n\omega t)
+\left.2A\frac{-t\cos(n\omega t)}{n\omega\tau^2}\right|_{-\tau/2}^{\tau/2}.
\end{eqnarray}
The first term is zero because $\cos(n\omega t)$ will be equally positive and negative over the interval. Using the fact that $\omega\tau=2\pi$,
\begin{eqnarray}
g_n&=&-\frac{2A}{2n\pi}\cos(n\omega\tau/2)\\
\nonumber
&=&-\frac{A}{n\pi}\cos(n\pi)\\
\nonumber
&=&\frac{A}{n\pi}(-1)^{n+1}.
\end{eqnarray}
The true function is compared to the expansion in Fig. \ref{fig:triangle} where the sum is cut off at finite $n$.
\begin{figure}
\centerline{\includegraphics[width=0.6\textwidth]{figs/triangle}}
\caption{\label{fig:triangle}
The periodic function $F(t)=t/\tau, |t|<\tau/2$ (black) is compared to the Fourier expansion described in Eq. (\ref{eq:fouriersolution}) with 10 terms (red) or 100 terms (green).}
\end{figure}

\exampleend

\subsection{Response to Transient Force}

Consider a particle at rest in the bottom of an underdamped harmonic oscillator, that then feels a sudden impulse, or change in momentum, $I=F\Delta t$ at $t=0$. This increases the velocity immediately by an amount $v_0=I/m$ while not changing the position. One can then solve the trajectory by solving Eq. (\ref{eq:homogsolution}) with initial conditions $v_0=I/m$ and $x_0=0$. This gives
\begin{equation}
x(t)=\frac{I}{m\omega'}e^{-\beta t}\sin\omega't, ~~t>0.
\end{equation}
Here, $\omega'=\sqrt{\omega_0^2-\beta^2}$. For an impulse $I_i$ that occurs at time $t_i$ the trajectory would be
\begin{equation}
x(t)=\frac{I_i}{m\omega'}e^{-\beta (t-t_i)}\sin[\omega'(t-t_i)] \Theta(t-t_i),
\end{equation}
where $\Theta(t-t_i)$ is a step function, i.e. $\Theta(x)$ is zero for $x<0$ and unity for $x>0$. If there were several impulses linear superposition tells us that we can sum over each contribution,
\begin{equation}
x(t)=\sum_i\frac{I_i}{m\omega'}e^{-\beta(t-t_i)}\sin[\omega'(t-t_i)]\Theta(t-t_i)
\end{equation}

Now one can consider a series of impulses at times separated by $\Delta t$, where each impulse is given by $F_i\Delta t$. The sum above now becomes an integral,
\begin{eqnarray}\label{eq:Greeny}
x(t)&=&\int_{-\infty}^\infty dt'~F(t')\frac{e^{-\beta(t-t')}\sin[\omega'(t-t')]}{m\omega'}\Theta(t-t')\\
\nonumber
&=&\int_{-\infty}^\infty dt'~F(t')G(t-t'),\\
\nonumber
G(\Delta t)&=&\frac{e^{-\beta\Delta t}\sin[\omega' \Delta t]}{m\omega'}\Theta(\Delta t)
\end{eqnarray}
The quantity $e^{-\beta(t-t')}\sin[\omega'(t-t')]/m\omega'\Theta(t-t')$ is called a Green's function, $G(t-t')$. It describes the response at $t$ due to a force applied at a time $t'$, and is a function of $t-t'$. The step function ensures that the response does not occur before the force is applied. One should remember that the form for $G$ would change if the oscillator were either critically- or over-damped.

When performing the integral in Eq. (\ref{eq:Greeny}) one can use angle addition formulas to factor out the part with the $t'$ dependence in the integrand,
\begin{eqnarray}
\label{eq:Greeny2}
x(t)&=&\frac{1}{m\omega'}e^{-\beta t}\left[I_c(t)\sin(\omega't)-I_s(t)\cos(\omega't)\right],\\
\nonumber
I_c(t)&\equiv&\int_{-\infty}^t dt'~F(t')e^{\beta t'}\cos(\omega't'),\\
\nonumber
I_s(t)&\equiv&\int_{-\infty}^t dt'~F(t')e^{\beta t'}\sin(\omega't').
\end{eqnarray}
If the time $t$ is beyond any time at which the force acts, $F(t'>t)=0$, the coefficients $I_c$ and $I_s$ become independent of $t$.

\example
Consider an undamped oscillator ($\beta\rightarrow 0$), with characteristic frequency $\omega_0$ and mass $m$, that is at rest until it feels a force described by a Gaussian form,
\begin{eqnarray*}
F(t)&=&F_0 \exp\left\{\frac{-t^2}{2\tau^2}\right\}.
\end{eqnarray*}
For large times ($t>>\tau$), where the force has died off, find $x(t)$.\\
{\bf Solution:} Solve for the coefficients $I_c$ and $I_s$ in Eq. (\ref{eq:Greeny2}). Because the Gaussian is an even function, $I_s=0$, and one need only solve for $I_c$,
\begin{eqnarray*}
I_c&=&F_0\int_{-\infty}^\infty dt'~e^{-t^{\prime 2}/(2\tau^2)}\cos(\omega_0 t')\\
&=&\Re F_0 \int_{-\infty}^\infty dt'~e^{-t^{\prime 2}/(2\tau^2)}e^{i\omega_0 t'}\\
&=&\Re F_0 \int_{-\infty}^\infty dt'~e^{-(t'-i\omega_0\tau^2)^2/(2\tau^2)}e^{-\omega_0^2\tau^2/2}\\
&=&F_0\tau \sqrt{2\pi} e^{-\omega_0^2\tau^2/2}.
\end{eqnarray*}
The third step involved completing the square, and the final step used the fact that the integral
\begin{eqnarray*}
\int_{-\infty}^\infty dx~e^{-x^2/2}&=&\sqrt{2\pi}.
\end{eqnarray*}
To see that this integral is true, consider the square of the integral, which you can change to polar coordinates,
\begin{eqnarray*}
I&=&\int_{-\infty}^\infty dx~e^{-x^2/2}\\
I^2&=&\int_{-\infty}^\infty dxdy~e^{-(x^2+y^2)/2}\\
&=&2\pi\int_0^\infty rdr~e^{-r^2/2}\\
&=&2\pi.
\end{eqnarray*}
Finally, the expression for $x$ from Eq. (\ref{eq:Greeny2}) is
\begin{eqnarray*}
x(t>>\tau)&=&\frac{F_0\tau}{m\omega_0} \sqrt{2\pi} e^{-\omega_0^2\tau^2/2}\sin(\omega_0t).
\end{eqnarray*}

\exampleend

\subsection{Solving Equations of Motion Numerically}
%If one has a known force $F(t)$, and initial conditions $x(t=0)=x_0$ and $v(t=0)=v_0$, one can solve for the equations of motion numerically. First, one must choose a small time step $\Delta t$, smaller than any characteristic time scale of the problem. One can then define a mesh $x_n$, where $n=0$ so some maximum number of steps $N$. We will defines these values as
\begin{eqnarray}
x_n=x(n\Delta t).
\end{eqnarray}
Assume that one knows $x_n$ for all $i<\le j$. One can express the velocities and accelerations in Newton's equations of motion for a mass $m$ as:

\begin{eqnarray}
v_n&=&\frac{x_{n+1}-x_{n-1}}{2\Delta t},\\
\nonumber
a_n&=&\frac{v_{n+1/2}-v_{n-1/2}}{\Delta t}\\
\nonumber
&=&\frac{x_{n+1}-2x_n+x_{n-1}}{(\Delta t)^2}.
\end{eqnarray}
The equations of motion at $t_n=n\Delta t$ become
\begin{eqnarray}
F(x_n)&=&ma_n.
\end{eqnarray}
If one knows $x_{n-1}$ and $x_n$ the only unknown in the equation is $x_{n+1}$. One can solve for it, then move onto the next $n$. Note that to proceed one needs to know $x$ at two points. This can be tricky depending on how the initial conditions are specified.

\example
Write a numerical program to solve the evolution of a particle of mass $m$ feeling a spring force, $-kx$ and a drag force, $-bv$. Assume there is also some external force, $F(t)=F_0\sin\omega t$. Let the initial conditions be $x(t=0)=0$ and $v(t=0)=v_0$.

{\bf Solution:} The differential equation,
\begin{eqnarray*}
m\ddot{x}+b\dot{x}+kx&=&0,\\
\end{eqnarray*}
becomes
\begin{eqnarray*}
\frac{m}{(\Delta t)^2}\left(x_{n+1}-2x_n+x_{n-1}\right)+\frac{b}{2\Delta t}\left(x_{n+1}-x_{n-1}\right)+kx_n&=&F(n\Delta t).
\end{eqnarray*}
Solving for $x_{n+1}$,
\begin{eqnarray*}
\left\{\frac{m}{(\Delta t)^2}+\frac{b}{2\Delta t}\right\}x_{n+1}&=&\left[\frac{2m}{(\Delta t)^2}-k\right]x_n+F(n\Delta t)
+\left[-\frac{m}{(\Delta t)^2}+\frac{b}{2\Delta t}\right]x_{n-1},\\
x_{n+1}&=&\frac{\left[\frac{2m}{(\Delta t)^2}-k\right]x_n+F(n\Delta t)
+\left[-\frac{m}{(\Delta t)^2}+\frac{b}{2\Delta t}\right]x_{n-1}}{\frac{m}{(\Delta t)^2}+\frac{b}{2\Delta t}}.
\end{eqnarray*}
In order to iterate forward to find $x_{n+1}$, one must know $x_{n-1}$ and $x_n$. However, to get started, one only knows one value of $x$, along with the velocity being zero. To get $x$ at two time steps, one must can use the above two pieces of information,
\begin{eqnarray*}
v_0&=&\frac{x_1-x_{-1}}{2\Delta t},\\
-bv_0-kx_0&=&m\frac{x_1-2x_0+x_{-1}}{\Delta t^2},
\end{eqnarray*}
then combine the equations to eliminate $x_{-1}$ to solve for $x_1$. The fact that $x_0=0$ makes the algebra simpler,
\begin{eqnarray*}
x_1&=&v_0\Delta t-\frac{bv_0\Delta t^2}{2m}.
\end{eqnarray*}

The program might read:
{\tt\begin{verbatim}
double F(double t){
   double F0=????,omega=????;
   return F0*sin(omega*t);
}
void main(){
   const int Ntsteps=???;
   double x[Ntsteps+1],dt=???,k=???,m=???,b=???,v0=???;
   x[0] = 0.0;
   x[1] = v0*dt-0.5*b*v0/m;
   for(int it=1;it<Ntsteps;it=it+1){
      x[it+1]=( (2.0*m/(dt*dt)) -k)*x[it] + F(it*dt)
      + (0.5*b/dt)*x[it-1] ) / ( (m/(dt*dt) + 0.5*b/dt );
   }
}
\end{verbatim}}
Question marks would be replaced by the given parameters of the problem.

\exampleend

\subsection{Exercises}

\begin{enumerate}

\item A floating body of uniform cross-sectional area $A$ and of mass density $\rho$ and at equilibrium displaces a volume $V$. Show that the period of small oscillations about the equilibrium position is given by
\[
\tau=2\pi\sqrt{V/gA}
\]

\item Show that the critically damped solution, Eq. (\ref{eq:criticallydamped}), is indeed the solution to the differential equation.

\item Consider an over-damped harmonic oscillator with a mass of $m=2$ kg, a damping factor $b=20$ Ns/m, and a spring constant $k=32$ N/m. If the initial position is $x=0.125$ m, and if the initial velocity is $-2.0$ m/s, find and graph the motion as a function of time. Graphically, find the time at which the mass crosses the origin.

\item Consider a particle of mass $m$ moving in a one-dimensional potential,
\[
V(x)=-k\frac{x^2}{2}+\alpha\frac{x^4}{4}.
\]
\begin{enumerate}
\item What is the angular frequency for small vibrations about the minimum of the potential? What is the effective spring constant?
\item If you add a small force $F=F_0\cos(\omega t-\phi)$, and if the particle is initially at the minimum with zero initial velocity, find its position as a function of time.
\item If there is a small drag force $-bv$, repeat (b).
\end{enumerate}

\item Consider the periodic force, $F(t+\tau)=F(t)$,
\[
F(t)=\left\{\begin{array}{rl}
-A,&-\tau/2<t<0\\
+A,&0<t<\tau/2
\end{array}\right.
\]
Find the coefficients $f_n$ and $g_n$ defined in Eq. (\ref{eq:fourierdef2}).

\item A ``delta'' function is a function that is zero everywhere except where the argument is zero. At this point the function is infinite so that the area under the curve is unity. The delta function obeys the relations
\begin{eqnarray*}
\int_a^b dt'~ \delta(t'-t_0)&=&1,\\
\int_a^b dt'~ f(t')\delta(t'-t_0)&=&f(t_0),
\end{eqnarray*}
as long as the time $t_0$ lies between the limits $a$ and $b$. Otherwise, the integrals are zero.
\begin{enumerate}
\item Show that the following function
\[
\left.\frac{1}{\pi}\frac{\Lambda}{\Lambda^2+x^2}\right|_{\Lambda\rightarrow 0}=\delta(x).
\]
i.e. show that it is zero everywhere except the origin and that it integrates to unity.
\item A step function, $\Theta(t)$, a.k.a. the ``Theta'' function or the Heaviside function, is zero for negative arguments and is unity for positive arguments. Show that
\[
\frac{d}{dx}\Theta(x-x_0)=\delta(x-x_0).
\]
\item Using the definition of Fourier coefficients in Eq.s (\ref{eq:fourierdef1}) and (\ref{eq:fourierdef2}), show that
\[
\delta(t-t_0)=-\frac{1}{\tau}+\frac{2}{\tau}\sum_{n=0}^{\infty}\cos(\omega_n(t-t_0)),~~~\omega_n=2n\pi/\tau.
\]
\end{enumerate}

\item Consider the complex function in the interval $-\tau/2<t<\tau/2$,
\[
f(t)=-\frac{1}{\tau}+\frac{2}{\tau}\sum_{n=0}^\infty e^{in\omega(t-t_0)}, ~~~\omega=2\pi/\tau.
\]
\begin{enumerate}
\item Using the fact that if one integrates over the interval, $-\tau/2<t<\tau/2$, that $\int dt ~e^{in\omega t}=0$ for $n\ne 0$, show that
\[
\int dt f(t)=1.
\]
\item Using the fact that $\sum_n x^n=1/(1-x)$, show that
\[
f(t)=-\frac{1}{\tau}+\frac{2/\tau}{1-e^{i\omega(t-t_0)}}.
\]
\item From the expression in (b), show that the real part of $f(t)$ obeys
\[
\Re f(t)=0,~~{\rm for}~t\ne t_0
\]
This shows that $\Re f$ is a delta function and validates the result of the previous problem.
\end{enumerate}

\item A particle of mass $m$ in an undamped harmonic oscillator with angular frequency $\omega_0$ is at rest in the bottom of the well, when it experiences a force
\[
F(t)=\left\{\begin{array}{rl}
0,&t<0\\
G,&0<t<\tau\\
0,&t>\tau\end{array}
\right.
\]
Find $x(t)$ for $t>\tau$ using Eq. (\ref{eq:Greeny2}).

\item Consider a particle of mass $m$ in a harmonic oscillator with angular frequency $\omega_0$ and no damping. It experiences an external force,
\[
F(t)=f_0\Theta(t)e^{-\gamma t}.
\]
A ``Theta'' function is a step function, and is zero for negative arguments and unity for positive arguments.
\begin{enumerate}
\item Find a particular solution, $x_p(t)$, assuming it is proportional to $e^{-\gamma t}$.
\item For a particle initially at rest at the origin at $t=0$, find $x(t)$ by adding in the homogenous solutions and matching the BC, determine the arbitrary constants.
\item Use Eq. (\ref{eq:Greeny}) or Eq. (\ref{eq:Greeny2}) to find $x(t)$. Check that you get the same result as (b).
\end{enumerate}

\end{enumerate}


\documentclass[a4paper]{article}

\input{temp}

\begin{document}

\title{Metric and Topological spaces}
\date{Easter 2016}

\maketitle

\newpage

\tableofcontents

\newpage

\section{Introduction}
Suppose $\left(x_n\right)$ is a sequence of real numbers. $\left(x_n\right)$ converges to $x\in \R$ if for every $\varepsilon>0$, there exists some $N$ such that $|x_n-x|<\varepsilon$ whenever $n>N$. We know that a function $f:\R \to \R$ is \emph{continuous} if $\left(f\left(x_n\right)\right)\to f\left(x\right)$ whenever $\left(x_n\right) \to x$. But what does it mean for a sequence $\left(x_n\right)$ to converge if $x_n\in X \neq \R$?

\begin{eg}
Let
\begin{equation*}
\begin{aligned}
X=\left\{A\in M_{n\times n} \left(\R\right) | A^T =A\right\}
\end{aligned}
\end{equation*}
and let $f\left(A\right)$ be the largest eigenvalue of $A$. Is $f$ continuous?
\end{eg}

\begin{eg}
Let
\begin{equation*}
\begin{aligned}
&X=\left\{f:\left[0,1\right] \to \R | f  \text{ is continuous} \right\} \\
&F\left(f\right) = f\left(\frac{1}{2}\right)
\end{aligned}
\end{equation*}
\end{eg}
Is $F$ continuous?

\begin{thm} (Intermediate value theorem)\\
If $f:\left[0,1\right]\to \R$ is continuous and $f\left(0\right)\left<0, f\left(1\right)\right>0$, then $\exists x \in \left[0,1\right]$ with $f\left(x\right)=0$.
\end{thm}

\begin{thm} (Maximum value theorem)\\
If $f:\left[0,1\right] \to \R$ is continuous, then $\exists x \in \left[0,1\right]$ such that $f\left(x\right) \geq f\left(y\right)$ for all $y\in\left[0,1\right]$.
\end{thm}

These are both theorems about $\left[0,1\right]$. However, they might not be true if we change to another domain. For example, neither of these theorems hold for $\left[0,1\right] \cap \Q$.

\begin{eg}
Let
\begin{equation*}
\begin{aligned}
f\left(x\right) = x^2-\frac{1}{2}
\end{aligned}
\end{equation*}
Then $f\left(0\right)\left<0, f\left(1\right)\right>0$, but there is no $x\in\left[0,1\right] \cap \Q$ such that $f\left(x\right) = 0$.
\end{eg}

\newpage
\section{Metric spaces}
Suppose $\left(\mathbf{v}_n\right) = \left(\left(x_n,y_n\right)\right)$ is a sequence in $\R^2$. What should it mean for $\left(\mathbf{v}_n\right)$ to converge to $\mathbf{v} = \left(x,y\right)$?\\
A natural thought would be that the sequence ocnverges to $\left(x,y\right)$ if $\left(x_n\right) \to x$ and $\left(y_n\right) \to y$. That is then equivalent to
\begin{equation*}
\begin{aligned}
&\left(x_n-x\right)^2 + \left(y_n-y\right)^2 \to 0 \iff
&|\mathbf{v}_n-\mathbf{v}| \to 0.
\end{aligned}
\end{equation*}

\begin{defi} (Metric space)\\
A \emph{metric space} is a pair $\left(X,d\right)$ where $X$ is a set and $d:X\times X \to \R$, called the \emph{metric}, or \emph{distance function}, that satisfies the following properties:
\begin{equation*}
\begin{aligned}
&\bullet d\left(x,y\right) \geq 0 \forall x,y\in X;\\
&\bullet d\left(x,y\right) = 0 \iff x=y;\\
&\bullet d\left(x,y\right) = d\left(y,x\right);\\
&\bullet d\left(x,z\right) \leq d\left(x,y\right) + d\left(y,z\right).
\end{aligned}
\end{equation*}
\end{defi}

\begin{eg}(Euclidean metric)\\
Let $X=\R^n$, $d\left(\mathbf{x},\mathbf{y}\right) = |\mathbf{x}-\mathbf{y}|$, where
\begin{equation*}
\begin{aligned}
|\mathbf{v}| = \left(\sum_{i=1}^n v_i^2\right)^\frac{1}{2}
\end{aligned}
\end{equation*}
is the \emph{Euclidean metric} on $\R^n$. Note that this satisfies the triangle inequality.
\end{eg}

\begin{eg} (Metric subspace)\\
Suppose $\left(X,d_X\right)$ is a metric space and $Y\subset X$. Then $\left(Y,d_Y\right)$ is a metric space, where $d_Y\left(y_1,y_2\right) = d_X\left(y_1,y_2\right)$, i.e. $d_Y=d_X |_{Y\times Y}$.\\
We say $\left(Y,d_Y\right)$ is a \emph{subspace} of $\left(X,d_X\right)$, or just say $Y$ is a subspace of $X$.
\end{eg}

\begin{eg}
Consider
\begin{equation*}
\begin{aligned}
\left\{A \in M_{n\times n} \left(\R\right) | A^T = A \right\} \subset \R^{n^2}.
\end{aligned}
\end{equation*}
\end{eg}

\begin{defi} (Convergence)\\
If $\left(X,d\right)$ is a metric space and $\left(x_n\right)$ is a sequence in $X$, we say $\left(x_n\right)$ converges to $x$ if for every $\varepsilon >0$ there exists $N$ such that $d\left(x_n,x\right) < \varepsilon$ whenever $n>N$.
\end{defi}

\begin{prop}
Suppose $\left(x_n\right)$ is a sequence in a metric space $\left(X,d\right)$ that $\left(x_n\right) \to x$ and $\left(x_n\right) \to y$. Then $x=y$.
\begin{proof}
Given $\varepsilon>0$, pick $N_1,N_2$ with
\begin{equation*}
\begin{aligned}
&n>N_1 \implies d\left(x_n,x\right) < \frac{\varepsilon}{2},\\
&n>N_2 \implies d\left(x_n,y\right) < \frac{\varepsilon}{2}
\end{aligned}
\end{equation*}
Then if $n>\max\left\{N_1,N_2\right\}$,
\begin{equation*}
\begin{aligned}
0\leq d\left(x,y\right)\leq d\left(x,x_n\right) + d\left(x_n,y\right) = d\left(x,x_n\right) + d\left(y,x_n\right) < \frac{\varepsilon}{2} + \frac{\varepsilon}{2} = \varepsilon.
\end{aligned}
\end{equation*}
Since $\varepsilon$ is arbitrary, $d\left(x,y\right)=0$. So $x=y$.
\end{proof}
\end{prop}

\begin{defi} (Continuity)\\
If $\left(X,d_X\right)$ and $\left(Y,d_Y\right)$ are metric spaces, then $f:X\to Y$ is \emph{continuous} if $\left(f\left(x_n\right)\right) \to f\left(x\right)$ whenever $\left(x_n\right) \to x$.
\end{defi}

\begin{prop}
If $\left(X,d_X\right), \left(Y,d_Y\right)$ and $\left(Z,d_Z\right)$ are metric spaces, and $f:X\to Y$ and $g:Y\to Z$ are both continuous, then $g \circ f:X\to Z$ is also continuous.
\begin{proof}
Suppose $\left(x_n\right) \to x$ in $X$. Since $f$ is continuous,
\begin{equation*}
\begin{aligned}
\left(f\left(x_n\right)\right) \to f\left(x\right)
\end{aligned}
\end{equation*}
in $Y$. Since $g$ is also continuous,
\begin{equation*}
\begin{aligned}
\left(g\left(f\left(x_n\right)\right)\right) \to g\left(f\left(x\right)\right)
\end{aligned}
\end{equation*}
in $Z$, i.e.
\begin{equation*}
\begin{aligned}
\left(g\circ f\left(x_n\right)\right) \to g\circ f\left(x\right).
\end{aligned}
\end{equation*}
So $g\circ f$ is continuous.
\end{proof}
\end{prop}

\begin{eg} (Discrete metric)\\
Let $X$ be any set, and let
\begin{equation*}
\begin{aligned}
d\left(x,y\right) = \left\{
\begin{array}{ll}
1 & x\neq y\\
0 & x=y
\end{array}
\right.
\end{aligned}
\end{equation*}
This is a metric space.
\end{eg}

\begin{eg}
Let $X=\R^2$, $\mathbf{x}=\left(x_1,x_2\right)$, $\mathbf{x}'=\left(x_1',x_2'\right)$, and
\begin{equation*}
\begin{aligned}
d\left(\mathbf{x},\mathbf{x}'\right) = |x_1-x_1'| + |x_2-x_2'|.
\end{aligned}
\end{equation*}
Triangle inequality follows by:
\begin{equation*}
\begin{aligned}
d\left(x,z\right) &= |x_1-z_1| + |x_2-x_2| \\
&\leq |x_1-y_1| + |y_1-z_1| + |x_2 - y_2| + |y_2 - z_2| \\
&= d\left(x,y\right) + d\left(y,z\right).
\end{aligned}
\end{equation*}
\end{eg}

\begin{eg} (British Railway metric)\\
Let $X=\R^2$, and
\begin{equation*}
\begin{aligned}
d\left(\mathbf{x},\mathbf{y}\right) = \left\{
\begin{array}{ll}
|\mathbf{x}-\mathbf{y}| &  \mathbf{x}=k\mathbf{y}\\
|\mathbf{x}| + |\mathbf{y}| & \text{ otherwise}
\end{array}
\right.
\end{aligned}
\end{equation*}
(Unless you, your destination and London are collinear, you always have to take a train to London first and transfer there.)
\end{eg}

\begin{defi}
If $V$ is a real vector space, a \emph{norm} on $V$ is a map $||\cdot|| : V \to \R$ satisfying
\begin{equation*}
\begin{aligned}
&\bullet ||\mathbf{v}|| \geq 0 \forall \mathbf{v}\in V;\\
&\bullet ||\mathbf{v}|| = 0 \iff \mathbf{v}=\mathbf{0} \in V;\\
&\bullet ||\lambda \mathbf{v}|| = |\lambda| ||\mathbf{v}||, \lambda \in \R, \mathbf{v} \in V;\\
&\bullet ||\mathbf{v}+\mathbf{w}|| \leq ||\mathbf{v}|| + ||\mathbf{w}||.
\end{aligned}
\end{equation*}
\end{defi}

\begin{eg}
Let $V = \R^n$,
\begin{equation*}
\begin{aligned}
||\mathbf{v}|| = \sum_{i=1}^n |v_i|
\end{aligned}
\end{equation*}
(this is called the Manhattan norm).
\end{eg}

\begin{lemma}
If $||\cdot||$ is a norm on $V$, then
\begin{equation*}
\begin{aligned}
d\left(\mathbf{x},\mathbf{y}\right) = ||\mathbf{x}-\mathbf{y}||
\end{aligned}
\end{equation*}
defines a metric on $V$.
\begin{proof}
Firstly
\begin{equation*}
\begin{aligned}
d\left(\mathbf{x},\mathbf{y}\right) = ||\mathbf{x}-\mathbf{y}|| \geq 0
\end{aligned}
\end{equation*}
by our definition of norm. The second holds by
\begin{equation*}
\begin{aligned}
d\left(\mathbf{x},\mathbf{y}\right) = 0 &\iff ||\mathbf{x}-\mathbf{y}|| = 0\\
&\iff \mathbf{x}-\mathbf{y}=0\\
&\iff \mathbf{x} = \mathbf{y}.
\end{aligned}
\end{equation*}
For the third condition,
\begin{equation*}
\begin{aligned}
d\left(\mathbf{y}-\mathbf{x}\right) &= ||\mathbf{y}-\mathbf{x}|| \\
&= ||\left(-1\right)\left(\mathbf{x}-\mathbf{y}\right)||\\
&= |-1| ||\mathbf{x}-\mathbf{y}||\\
&= d\left(\mathbf{x},\mathbf{y}\right)
\end{aligned}
\end{equation*}
Lastly
\begin{equation*}
\begin{aligned}
d\left(\mathbf{x},\mathbf{y}\right) + d\left(\mathbf{y},\mathbf{z}\right) &= ||\mathbf{x}-\mathbf{y}|| + ||\mathbf{y}-\mathbf{z}||\\
&\geq \mathbf{x}-\mathbf{z}\\
&= d\left(\mathbf{x},\mathbf{z}\right)
\end{aligned}
\end{equation*}
\end{proof}
\end{lemma}

The Manhattan metric on $\R^2$ is induced by the Manhattan norm (exercise).

\begin{defi}
Let $V$ be a real vector space. An \emph{inner product} on $V$ is a map $\left<\cdot, \cdot\right>: V\times V \to \R$, satisfying
\begin{equation*}
\begin{aligned}
&\bullet \left<\mathbf{v},\mathbf{v}\right> \geq 0 \forall \mathbf{v}\in V;\\
&\bullet \left<\mathbf{v},\mathbf{v}\right> = 0 \iff \mathbf{v}=\mathbf{0};\\
&\bullet \left<\mathbf{v},\mathbf{w}\right> = \left<\mathbf{w},\mathbf{v}\right>;\\
&\bullet \left<\mathbf{v},\mathbf{w_1}+\lambda \mathbf{w_2}\right> = \left<\mathbf{v},\mathbf{w_1}\right> + \lambda\left<\mathbf{v},\mathbf{w_2}\right>.
\end{aligned}
\end{equation*}
\end{defi}

The standard inner product on $\R^n$ is given by
\begin{equation*}
\begin{aligned}
\left<\mathbf{v},\mathbf{w}\right> = \mathbf{v}\cdot\mathbf{w}=\sum_{i=1}^n v_i w_i
\end{aligned}
\end{equation*}

\begin{thm} (Cauchy-Schwartz inequality)\\
If $\left<\cdot,\cdot\right>$ is an inner product on $V$, then
\begin{equation*}
\begin{aligned}
\left<\mathbf{v},\mathbf{w}\right>^2 \leq \left<\mathbf{v},\mathbf{v}\right>\left<\mathbf{w},\mathbf{w}\right>.
\end{aligned}
\end{equation*}
\begin{proof}
Consider $\left<\mathbf{v}+\lambda\mathbf{w},\mathbf{v}+\lambda\mathbf{w}\right>\geq 0$ by definition. So
\begin{equation*}
\begin{aligned}
\left<\mathbf{v},\mathbf{v}\right> + 2\lambda\left<\mathbf{v},\mathbf{w}\right>+\lambda^2\left<\mathbf{w},\mathbf{w}\right> \geq 0
\end{aligned}
\end{equation*}
Now if $ax^2 + bx + c\geq 0$ for all $x\in \R$, then $ax^2+bx+c=0$ has at most one real root. So $b^2-4ac \leq 0$.\\
Now we've just seen $a\lambda^2+b\lambda+c\geq 0$ for all $\lambda\in\R$, where $a=\left<\mathbf{w},\mathbf{w}\right>$, $b=2\left<\mathbf{v},\mathbf{w}\right>$, $c=\left<\mathbf{v},\mathbf{v}\right>$. So
\begin{equation*}
\begin{aligned}
4\left<\mathbf{v},\mathbf{w}\right>^2 \leq 4\left<\mathbf{w},\mathbf{w}\right>\left<\mathbf{v},\mathbf{v}\right>
\end{aligned}
\end{equation*}
which is the desired result.
\end{proof}
\end{thm}

\begin{coro}
If $\left<,\right>$ is an inner product on $V$, then $||\mathbf{v}|| = \left(\left<\mathbf{v},\mathbf{v}\right>\right)^{\frac{1}{2}}$ is a norm on $V$.
For the proof we just need to verify all the conditions again. Cauchy-Schwartz inequality is required for verifying the fourth condition.
\end{coro}

Another exercise: The norm on $\R^n$ induced by the standard inner product is Euclidean length:
\begin{equation*}
\begin{aligned}
||\mathbf{v}|| = |\mathbf{v}| = \left(\sum_{i=1}^n v_i^2\right)^\frac{1}{2}
\end{aligned}
\end{equation*}
The metric induced by the norm is the Euclidean norm.\\
And another exercise: is the Manhattan norm induced by an inner product on $\R^n$?

\begin{eg}
Let $V=\R^n$.\\
1)
\begin{equation*}
\begin{aligned}
||\mathbf{v}||_1=\sum_{i=1}^n |v_i|
\end{aligned}
\end{equation*}
The Manhattan norm;\\
2)
\begin{equation*}
\begin{aligned}
||\mathbf{v}||_2 = \left(\sum_{i=1}^n v_i^2\right)^\frac{1}{2}
\end{aligned}
\end{equation*}
The Euclidean norm;\\
3)
\begin{equation*}
\begin{aligned}
||\mathbf{v}||_\infty = \max_{1\leq i \leq n |v_i|}
\end{aligned}
\end{equation*}
(In example sheet:
\begin{equation*}
\begin{aligned}
||\mathbf{v}||_p = \left(\sum_{i=1}^n |v_i|^p \right)^\frac{1}{p}
\end{aligned}
\end{equation*}
is a norm for all $1\leq p < \infty$.)
\end{eg}

\begin{eg}
Let
\begin{equation*}
\begin{aligned}
V=C\left[0,1\right] := \left\{ f:\left[0,1\right] \to \R | f \text{ is continuous} \right\}
\end{aligned}
\end{equation*}
where
\begin{equation*}
\begin{aligned}
&\left(\lambda f\right)\left(x\right) = \lambda f\left(x\right),\\
&\left(f+g\right) \left(x\right) = f\left(x\right) + g\left(x\right)
\end{aligned}
\end{equation*}
\end{eg}
1)
\begin{equation*}
\begin{aligned}
||f||_1 = \int_0^1 |f\left(x\right)| dx
\end{aligned}
\end{equation*}
2)
\begin{equation*}
\begin{aligned}
||f||_2 = \left(\int_0^1 f\left(x\right)^2\right)^\frac{1}{2} dx
\end{aligned}
\end{equation*}
3)
\begin{equation*}
\begin{aligned}
||f||_\infty = \max_{x \in \left[0,1\right]} |f\left(x\right)|
\end{aligned}
\end{equation*}
This is usually called the 'sup norm'.\\
How do we know that the first two norms satisfy the second condition, i.e. the norm is zero if and only if the function is zero? This is actually a standard result in analysis:

\begin{lemma}
Suppose $f\left[0,1\right]\to\R$ is continuous. If $f \not\cong 0$, then
\begin{equation*}
\begin{aligned}
\int_0^1 |f\left(x\right)|>0
\end{aligned}
\end{equation*}
\begin{proof}
Pick $x_0\in\left[0,1\right]$ with $f\left(x_0\right) \neq 0.$ Since $f$ is continuous, there exists $\delta > 0$ such that
\begin{equation*}
\begin{aligned}
|f\left(x\right) - f\left(x_0\right)| < \frac{|f\left(x_0\right)|}{2}
\end{aligned}
\end{equation*}
whenever $|x-x_0| < \delta$. Then for $|x-x_0|<\delta$, we have
\begin{equation*}
\begin{aligned}
|f\left(x\right)| > |f\left(x_0\right)| - \frac{|f\left(x_0\right)|}{2} \geq \frac{|f\left(x_0\right)|}{2}
\end{aligned}
\end{equation*}
So if we define
\begin{equation*}
\begin{aligned}
g\left(x\right) = \left\{
\begin{array}{ll}
\frac{|f\left(x_0\right)|}{2} & |x-x_0| < \delta\\
0 & \text{  otherwise}
\end{array}
\right.
\end{aligned}
\end{equation*}
Then $|f\left(x\right)| \geq g\left(x\right)$ for all $x\in\left[0,1\right]$.\\
So
\begin{equation*}
\begin{aligned}
\int_0^1 |f\left(x\right)| dx \geq \int_0^1 |g\left(x\right)| dx = 2\delta \frac{|f\left(x_0\right)|}{2} = \delta |f\left(x_0\right)|>0.
\end{aligned}
\end{equation*}
\end{proof}
\end{lemma}

\begin{eg}
\begin{equation*}
\begin{aligned}
f_n\left(x\right) = \left\{
\begin{array}{ll}
1-nx & x\in\left[0,\frac{1}{n}\right]\\
0 & x\in\left[\frac{1}{n},1\right]
\end{array}
\right.
\end{aligned}
\end{equation*}
Then
\begin{equation*}
\begin{aligned}
||f_n||_1 = \int_0^1 |f\left(x\right)| dx = \frac{1}{2}\left(\frac{1}{n}\right)\cdot 1 = \frac{1}{2n} \to 0
\end{aligned}
\end{equation*}
as $n\to \infty$.\\
So $\left(f_n\right) \to 0$ with respect to the metric induced by $|| \cdot ||_1$.\\
On the other hand,
\begin{equation*}
\begin{aligned}
||f_n||_\infty = 1
\end{aligned}
\end{equation*}
regardless of $n$, since $f\left(0\right)=1$.\\
This means that $\left(f_n\right)$ does not converge to 0 as $n\to \infty$ with respect to the metric induced by $||\cdot||_\infty$, i.e. the sup norm.
\end{eg}

Exercise: is it possible to find a sequence that converges with respect to $||\cdot||_1$ on $\R^2$, but not with respect to $||\cdot||_\infty$?

\begin{eg} (The \emph{p-adic} norm)\\
Let $p \in \N$ be a prime number. If $a \in \Z$, let $|a|_p = p^{-k}$, where $p^k | a$, but $p^{k+1} \nmid a$.\\
So
\begin{equation*}
\begin{aligned}
&|0|_p = 0,\\
&|ab|_p = |a|_p |b|_p,\\
&|a+b|_p \leq \max\left\{|a|_p, |b|_p\right\} \leq |a|_p + |b|_p
\end{aligned}
\end{equation*}

If $r=\frac{a}{b} \in \Q$, define
\begin{equation*}
\begin{aligned}
|r|_p  = \frac{|a|_p}{|b|_p}
\end{aligned}
\end{equation*}
Then the \emph{p-adic metric} on $\Q$ is defined by
\begin{equation*}
\begin{aligned}
d_p \left(r,s\right) = |r-s|_p
\end{aligned}
\end{equation*}
\end{eg}

Exercise: 1,2,4,8,16, ... $\to 0$ with respect to $d_2$.

\newpage
\section{Open and Closed Subsets}
Let $\left(X,d\right)$ be a metric space.

\begin{defi}
If $x\in X$ and $r\in \R$ with $r>0$, let
\begin{equation*}
\begin{aligned}
B_r\left(x\right) = \left\{ y\in X | d\left(x,y\right) < r \right\}
\end{aligned}
\end{equation*}
is the \emph{open ball} of radius $r$ with centre $x$,
\begin{equation*}
\begin{aligned}
\bar{B}_r \left(x\right) = \left\{y \in X | d\left(x,y\right) \leq r \right\}
\end{aligned}
\end{equation*}
is the \emph{closed ball} of radius $r$ with centre $x$.
\end{defi}

\begin{eg}
Let $X=\R$ with the usual metric. Then
\begin{equation*}
\begin{aligned}
&B_r\left(a\right) = \left(a-r,a+r\right),\\
&\bar{B}_r\left(a\right) = \left[a-r,a+r\right].
\end{aligned}
\end{equation*}
These are just the open and closed interval respectively.
\end{eg}

\begin{eg}
Let $X=\R^3$, with the Euclidean metric. Then
\begin{equation*}
\begin{aligned}
\bar{B}_1\left(0\right) = \left\{ \mathbf{v}\in \R^3 | |\mathbf{v}| \leq 1\right\}
\end{aligned}
\end{equation*}
which is a sphere with centre 0 and radius 1.
\end{eg}

\begin{eg}
Let $X=\R^2$, with the metric induced by\\ 1) the Manhattan norm, $||\cdot ||_1$;\\
2) the Euclidean norm, $||\cdot ||_2$;\\
3) the sup norm, $||\cdot ||_\infty$.\\
Now consider $\bar{B}_1\left(0\right)$. For the Manhattan norm, this is a square with with centre 0 and edges parallel to the axes(so with edge length 2); for the Euclidean norm this is a disc with centre 0 and radius 1; for the sup norm this is a square with centre 0 but edges making an angle of $\frac{\pi}{4}$ to the axes (so with edge length $\sqrt{2}$).
\end{eg}

\begin{eg}
Let $X=\R^2$, $d$ is induced by an inner product $\left<,\right>$: if $\mathbf{v}=x\mathbf{e}_1+y\mathbf{e}_2$, then
\begin{equation*}
\begin{aligned}
\left<\mathbf{v},\mathbf{v}\right> = ax^2 + 2bxy + cy^2
\end{aligned}
\end{equation*}
Then
\begin{equation*}
\begin{aligned}
B_1\left(0\right) = \left\{\left(x,y\right) | ax^2+2bxy+cy^2 \leq 1\right\}
\end{aligned}
\end{equation*}
where
\begin{equation*}
\begin{aligned}
a=\left<\mathbf{e}_1,\mathbf{e}_1\right>,\\
b=\left<\mathbf{e}_1,\mathbf{e}_2\right>,\\
c=\left<\mathbf{e}_2,\mathbf{e}_2\right>.
\end{aligned}
\end{equation*}
This is an ellipse.\\
So we know that $||\cdot ||_\infty$, $||\cdot ||_1$ are not induced from an inner product on $\R^2$.
\end{eg}

\begin{notation}
If $A\subset X$ is a subset, then $X\backslash A$, or $X-A$, is defined as
\begin{equation*}
\begin{aligned}
X-A = \left\{x\in X | x\not\in A\right\}
\end{aligned}
\end{equation*}
which is called the complement of $A$ (in $X$).
\end{notation}

\begin{defi} (Open and closed subset)\\
If $A\subset X$, we say $A$ is an \emph{open subset} if for every $x\in A$, $\exists r>0$ such that $B_r\left(x\right) \subset A$.\\
If $C\subset X$, we say $C$ is a \emph{closed subset} if $X-C$ is an open subset of $X$.
\end{defi}

\begin{prop}
If $X$ is a metric space, then $B_r\left(x\right)$ is an open subset of $X$, and $\bar{B}_r\left(x\right)$ is a closed subset of $X$.
\begin{proof}
Suppose $b\in B_r\left(a\right)$. Then $d\left(a,b\right) < r$. So $r_0 = r-d\left(a,b\right)>0$. Now if $c\in B_{r_0}\left(b\right)$, then
\begin{equation*}
\begin{aligned}
d\left(a,c\right) \leq d\left(a,b\right)+d\left(b,c\right)<d\left(a,b\right)+r_0=r
\end{aligned}
\end{equation*}
So $c\in B_r\left(a\right)$. Thus $B_{r_0}\left(b\right) \subset B_r\left(a\right)$. So $B_r\left(a\right)$ is open.\\
For the second part, we need to show that
\begin{equation*}
\begin{aligned}
X-\bar{B}_r\left(a\right) = \left\{ x\in X | d\left(x,a\right)>r\right\}
\end{aligned}
\end{equation*}
is open. The proof is analogous to the previous proof.
\end{proof}
\end{prop}

\begin{rem}
Note that $A\subset X$ may be \emph{neither} open nor closed. In fact if we take a random subset from a random metric space $X$, this is most likely the case. For example, consider $X=\R$ with the usual metric. then an obvious example is $\left[0,1\right)$,which is neither open nor closed; $\Q \subset \R$ is a more subtle example.
\end{rem}

\begin{rem}
$A\subset X$ can also be \emph{both} open and closed. Consider
\begin{equation*}
\begin{aligned}
X=\left[-1,1\right]-\left\{0\right\}
\end{aligned}
\end{equation*}
as a subspace of $\R$. Then
\begin{equation*}
\begin{aligned}
A=\left[-1,0\right)=B_1\left(-1\right) \subset X
\end{aligned}
\end{equation*}
is open. On the other hand, this is also a closed ball, since it is also
\begin{equation*}
\begin{aligned}
\bar{B}_{\frac{1}{2}} \left(-\frac{1}{2}\right) \subset X
\end{aligned}
\end{equation*}
So $A$ is both closed and open in $X$.
\end{rem}

\begin{rem}
Note that being open or closed is \emph{not} a property of a space, but a property of a subset of a space.\\
We've seen that $\left[-1,0\right)$ is not a closed subset of $\R$, but it \emph{is} a closed subset of $\left[-1,1\right] - \left\{0\right\}$.
\end{rem}

\begin{defi}
If $\left(X,d\right)$ is a metric space and $x\in X$, then $U$ is an \emph{open neighbourhood} of $x$ if $U\subset X$ is open and $x\in U$.
\end{defi}

\begin{prop}
Suppose sequence $\left(x_n\right) \to x$ and $U$ is an open neighbourhood of $x$. Then there exists $N$ such that $x_n\in U$ for all $n>N$.
\begin{proof}
Since $U\subset X$ is open, $x\in U$, $\exists \varepsilon > 0$ with
\begin{equation*}
\begin{aligned}
B_\varepsilon \left(x\right) \subset U.
\end{aligned}
\end{equation*}
Since $\left(x_n\right) \to x$, $\exists N$ such that $d\left(x_n,x\right) < \varepsilon$ whenever $n>N$. This implies that
\begin{equation*}
\begin{aligned}
x_n \in B_\varepsilon \left(x\right)
\end{aligned}
\end{equation*}
whenever $n>N$. So $x_n\in U$ whenever $n>N$.
\end{proof}
\end{prop}

\begin{defi} (Limit point)\\
If $\left(X,d\right)$ is a metric space and $A \subset X$, we say $x\in X$ is a \emph{limit point} of $A$ if there is a sequence $\left(x_n\right) \to x$ with $x_n \in A$ for all $n$.
\end{defi}

\begin{eg}
If $a\in A$, then $a$ is a limit point of $A$. We can just take a constant sequence with value $a$, which clearly converges to $a$.
\end{eg}

\begin{eg}
Let $X = \R$ with the usual metric, $A=\left(0,1\right)$. Then
\begin{equation*}
\begin{aligned}
\left(\frac{1}{n}\right) \to 0
\end{aligned}
\end{equation*}
and $\frac{1}{n} \in A$ for all $n\geq 1$. So $0$ is a limit point of $A$.
\end{eg}

\begin{prop}
Suppose $C\subset X$ is a closed subset and $x$ is a limit point of $C$. Then $x \in C$.
\begin{proof}
Suppose $\left(x_n\right) \to x$, where $x_n \in C$, but $x\not\in C$.\\
Since $C$ is closed, $U=X-C$ is open. So
\begin{equation*}
\begin{aligned}
x \not\in C \implies X \in U
\end{aligned}
\end{equation*}
So $U$ is an open neighbourhood of $x$.\\
Now $\left(x_n\right)$ converges to $x$ and $U$ is an open neighbourhood. So by the previous proposition, there exists an $N$ such that $x_n \in U$ for all $n>N$. But $x_n \in C$ for all $n$. Contradiction.
\end{proof}
\end{prop}

\begin{thm}
Suppose $f:\left(X,d_X\right) \to \left(Y,d_Y\right)$. Then the following conditions are equivalent:\\
1) $f$ is continuous;\\
2) $f^{-1}\left(U\right)$ is open in $X$ whenever $U$ is open in $Y$;\\
3) $f^{-1}\left(C\right)$ is closed in $X$ whenever $U$ is closed in $Y$.
\end{thm}

\end{document}


\hypertarget{classnumpp_1_1differentiation_1_1symbolic_1_1differentiate}{}\section{numpp\+:\+:differentiation\+:\+:symbolic\+:\+:differentiate$<$ Function, Order $>$ Class Template Reference}
\label{classnumpp_1_1differentiation_1_1symbolic_1_1differentiate}\index{numpp\+::differentiation\+::symbolic\+::differentiate$<$ Function, Order $>$@{numpp\+::differentiation\+::symbolic\+::differentiate$<$ Function, Order $>$}}

Allows differentiation of N-\/th order.

{\ttfamily \#include $<$functions.\+hpp$>$}

\subsection*{Public Types}
\begin{DoxyCompactItemize}
\item
\mbox{\Hypertarget{classnumpp_1_1differentiation_1_1symbolic_1_1differentiate_ac0c973a49c1b2e262edd5345c4f569a7}\label{classnumpp_1_1differentiation_1_1symbolic_1_1differentiate_ac0c973a49c1b2e262edd5345c4f569a7}}
{\footnotesize template$<$std\+::size\+\_\+t Variable, std\+::size\+\_\+t... Variables$>$ }\\using {\bfseries with\+\_\+respect\+\_\+to} = typename \hyperlink{classnumpp_1_1differentiation_1_1symbolic_1_1differentiate}{differentiate}$<$ typename Function\+::template derivative$<$ Variable $>$, Order-\/1 $>$\+::template with\+\_\+respect\+\_\+to$<$ Variables... $>$
\end{DoxyCompactItemize}

\subsection{Detailed Description}
\subsubsection*{template$<$typename Function, std\+::size\+\_\+t Order$>$\newline
class numpp\+::differentiation\+::symbolic\+::differentiate$<$ Function, Order $>$}

Allows differentiation of N-\/th order.

\begin{DoxyTemplParams}{Template Parameters}
{\em Function} & Function which should be differentiated, see /ref numpp\+\_\+differentiation\+\_\+symbolic \char`\"{}tutorial\char`\"{} for more info \\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em Order} & order of the differentiation, e.\+g. 3 for 3rd order\\
\hline
\end{DoxyParams}

\begin{DoxyCode}
\textcolor{preprocessor}{#include"numpp/differentiation/symbolic.hpp"}
\end{DoxyCode}

The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item
differentiation/symbolic/functions.\+hpp\end{DoxyCompactItemize}


\chapter{Mathematical Model of Vehicle Dynamics}

This chapter will detail the mathematical model that was developed to describe the motion of the uDrone.

\section{Reference Frames and State Space}

Conventions for creating this model will follow those laid out by Thor Fossen in the 2011 Handbook of Marine Craft Hydrodynamics and Control. The fixed world frame is defined using the North-East-Down (NED) coordinate system, represented as $\{n\} = (x_n, y_n, z_n)$. in this system, $x_n$ points North, $y_n$ points East, and $z_n$ points down.

The body-fixed frame $\{b\} = (x_b, y_b, z_b)$ is fixed its origin point, $o_b$, to the uDrone. For purposes of this model, $o_b$ is set at the point on the plane of the motors at the back of the uDrone that is along its center-line. $x_b$ runs along the center-line of the vehicle, pointing from the aft (back) of the uDrone to the fore (front). $z_b$ runs from top to bottom and, following the right-hand rule, $y_b$ runs towards the starboard (right). Further, following convention, roll is defined as rotation about $x_b$, pitch as rotation about $y_b$, and yaw as rotation about $z_b$, with counter-clockwise (CCW) being the positive direction.

This choice of body frame origin reduces the complexity of modeling the forces produced by the motors. The drawback is some added complexity caused by the moments of the center of buoyancy and center of gravity relative to the chosen origin, but this is more straight forward than the complexity of calculating motor forces about a different point.

The position of the vehicle, or the body-fixed frame $\{b\}$, with respect to the world frame $\{n\}$ is expressed as $\bm{p} = [N, E, D]^T$. The attitude of the vehicle is expressed as $\bm{\Theta} = [\phi, \theta, \psi]^T$ using Euler angles. Together these create the 6-dimensional position/orientation vector $\bm{\eta} = [\bm{p}, \bm{\Theta]}^T$. The linear and angular velocities are expressed with respect to the vehicles fixed frame $\{b\}$. The linear velocity is $\bm{v} = [u, v, w]^T$ and angular velocity $\bm{\omega} = [p, q, r]^T$. when combine, these form the combine 6-dimensional velocity vector $\bm{\nu}= [\bm{v}, \bm{\omega]}^T$. All together, $\boldsymbol{\eta}$ and $\boldsymbol{\nu}$ represent the 12-dimensional state space describing the state of the uDrone \parencite{thor_kin}.

% \begin{align*}
%      \boldsymbol{p}^{n}_{b}=\left[\begin{array}{c}
%         N \\ E \\ D
%      \end{array}\right]
%      \bm{\Theta}^{n}_{b}=\left[\begin{array}{c}
%         \phi \\ \theta \\ \psi
%      \end{array}\right]
%      \bm{\eta}=\left[\begin{array}{c}
%         \bm{p} \\ \bm{\Theta}
%      \end{array}\right]
% \end{align*}
% \begin{align*}
%      \boldsymbol{v}^{b}_{b}=\left[\begin{array}{c}
%         u \\ v \\ w
%      \end{array}\right]
%      \bm{\omega}^{b}_{b}=\left[\begin{array}{c}
%         p \\ q \\ r
%      \end{array}\right]
%      \bm{\nu}=\left[\begin{array}{c}
%         \bm{v} \\ \bm{\omega}
%      \end{array}\right]
% \end{align*}

\section{Equations of Motions}

The general equation of motion for the uDrone can be derived as a function of the combine linear and angular velocity vector $\boldsymbol{\nu}$ \parencite{thor_mod}. This is shown in equation \ref{eqm}.

\begin{gather}
\underbrace{\boldsymbol{M}_{R B} \dot{\boldsymbol{\nu}}+\boldsymbol{C}_{R B}(\boldsymbol{\nu}) \boldsymbol{\nu}}_{\text {rigid-body forces}}+\underbrace{\boldsymbol{M}_{A} \dot{\boldsymbol{\nu}}+\boldsymbol{C}_{A}\left(\boldsymbol{\nu}\right) \boldsymbol{\nu}+\boldsymbol{D}\left(\boldsymbol{\nu}\right) \boldsymbol{\nu}}_{\text {hydrodynamic forces}}+\underbrace{\boldsymbol{g}(\boldsymbol{\eta})}_{\text{hydrostatic forces}}=\boldsymbol{\tau}
\label{eqm}
\end{gather}
With the terms defined as:
\begin{align*}
    \boldsymbol{\eta}&=\text{combine position and orientation}\\
    \boldsymbol{\nu}&=\text{combine linear and angular velocity}\\
    \dot{\boldsymbol{\nu}}&=\text{combine linear and angular acceleration}\\
    \boldsymbol{M}_{R B}&=\text{rigid-body system inertia matrix}\\
    \boldsymbol{C}_{R B}(\boldsymbol{\nu})&=\text{rigid-body Coriolis matrix}\\
    \boldsymbol{M}_{A}&=\text{added mass system inertia matrix}\\
    \boldsymbol{C}_{A}(\boldsymbol{\nu})&=\text{added mass Coriolis matrix}\\
    \boldsymbol{D}(\boldsymbol{\nu})&=\text{damping matrix}\\
    \boldsymbol{g}(\boldsymbol{\eta})&=\text{gravitational and buoyant forces}\\
    \boldsymbol{\tau}&=\text{control inputs}
\end{align*}
% \begin{align*}
%     \boldsymbol{\eta}&=\text{combine position and orientation}\\
%     \boldsymbol{\nu}&=\text{combine linear and angular velocity}\\
%     \dot{\boldsymbol{\nu}}&=\text{combine linear and angular acceleration}\\
%     \boldsymbol{\tau}&=\text{control inputs}\\
%     \boldsymbol{M}&=\text{system inertia matrix}\\
%     \boldsymbol{C}(\boldsymbol{\nu})&=\text{Coriolis matrix}\\
%     \boldsymbol{D}(\boldsymbol{\nu})&=\text{damping matrix}\\
%     \boldsymbol{g}(\boldsymbol{\eta})&=\text{gravitational and buoyant forces}\\
%     \boldsymbol{\tau}&=\text{control inputs}
% \end{align*}
% \begin{align*}
%     \boldsymbol{M}&=\boldsymbol{M}_{R B}+\boldsymbol{M}_{A}\\
%     \boldsymbol{C}&=\boldsymbol{C}_{R B}+\boldsymbol{C}_{A}
% \end{align*}

\section{Rigid-Body Forces}

The exact values of the system inertia ($\boldsymbol{M}$), Coriolis ($\boldsymbol{C}$), and Drag ($\boldsymbol{D}$) matrices can be determined either through intensive hydrodynamic modeling or experimentation. Due to the complexity of hydrodynamic modeling, experimentation is typically used to determine these values in underwater vehicles similar to the uDrone \parencite{hipp_pen}. It is possible, however, to estimate the rigid body matrix values using information about the vehicle generated from the 3D model. This section details these estimations and explains how they were calculated.

The rigid body system inertia matrix about the center of origin can be calculated using equation \ref{mrb} which is found in \cite{thor_rb}.
\begin{gather}
    \boldsymbol{M}_{R B}^{C O}=\left[\begin{array}{cc}
        m \boldsymbol{I}_{3 \times 3} & -m \boldsymbol{S}\left(\boldsymbol{r}_{g}^{b}\right) \\
        m \boldsymbol{S}\left(\boldsymbol{r}_{g}^{b}\right) & \boldsymbol{I}_{g}-m \boldsymbol{S}^{2}\left(\boldsymbol{r}_{g}^{b}\right)
    \end{array}\right]
    \label{mrb}
\end{gather}
% \begin{align*}
%     \boldsymbol{M}_{R B}^{C O}&=\text{rigid body system inertia matrix about the body fixed-frame origin}\\
%     \boldsymbol{I}_{3 \times 3}&=\text{3 by 3 identity matrix}\\
%     m&=\text{mass}\\
%     \boldsymbol{S}(\cdot)&=\text{cross product operator}\\
%     \boldsymbol{r}_{g}^{b}&=\text{ vector from the body fixed-frame origin to the center of gravity}\\
%     \boldsymbol{I}_{g}&=\text{inertia matrix}
% \end{align*}

In this equation, $m$ is the mass, $\boldsymbol{I}_{3 \times 3}$ is the three-by-three identity matrix, $\boldsymbol{I}_{g}$ is the inertia matrix and $\boldsymbol{r}_{g}^{b}$ is the vector from the body fixed-frame origin to the center of gravity. $\boldsymbol{S}$ is the cross product operator matrix. Before the final vehicle was constructed, m, $\boldsymbol{I}_{g}$, and $\boldsymbol{r}_{g}^{b}$ were taken from the 3D model. Those estimates are shown in equation \ref{m_matrix}.

\begin{equation}
\boldsymbol{M}_{R B}^{C O}=\left[\begin{array}{cccccc}
9.9000 & 0 & 0 & 0 & 0 & 0 \\
0 & 9.9000 & 0 & 0 & 0 & 1.4850 \\
0 & 0 & 9.9000 & 0 & -1.4850 & 0 \\
0 & 0 & 0 & 0.3420 & 0.0010 & -0.0001 \\
0 & 0 & -1.4850 & 0.0010 & 0.5577 & -0.0015 \\
0 & 1.4850 & 0 & -0.0001 & -0.0015 & 0.3167
\end{array}\right]
\label{m_matrix}
\end{equation}

With a completed vehicle these numbers can be verified and varied if needed. For example, with no ballast, the uDrone is positively buoyant. Therefore, to maintain its depth without using power to stay underwater ballast will need to be added. By placing the ballast closer to the center of the vehicle, the moments of inertia will decrease. Conversely, by placing it further from the center the moments can be increased. Additionally, the ballast can be used to change the center of gravity relative to the center of buoyancy. This will create a moment in the vehicle that can help it stay oriented or level in specific ways. This relationship is discussed further in the section \ref{hydrostatics}.

The Coriolis matrix is a function of the angular velocity of the vehicle and can be derived as shown in equation \ref{crb} from \cite{thor_rb}.
\begin{gather}
    \boldsymbol{C}_{RB}^{CO}(\boldsymbol{\nu})=\left[\begin{array}{cc}
        m \boldsymbol{S}\left(\boldsymbol{\omega}^{b}\right) & -m \boldsymbol{S}\left(\boldsymbol{\omega}^{b}\right) \boldsymbol{S}\left(\boldsymbol{r}_{g}^{b}\right) \\
        m \boldsymbol{S}\left(\boldsymbol{r}_{g}^{b}\right) \boldsymbol{S}\left(\boldsymbol{\omega}^{b}\right) & -\boldsymbol{S}\left(\left(\boldsymbol{I}_{g}-m \boldsymbol{S}^{2}\left(\boldsymbol{r}_{g}^{b}\right)\right) \boldsymbol{\omega}^{b}\right)
    \end{array}\right]
    \label{crb}
\end{gather}
% \begin{align*}
%     \boldsymbol{C}_{R B}^{C O}&=\text{rigid body Coriolis matrix about the body fixed-frame origin}\\
%     m&=\text{mass}\\
%     \boldsymbol{S}(\cdot)&=\text{cross product operator}\\
%     \boldsymbol{\omega}^b&=\text{body-fixed frame angular velocity}\\
%     \boldsymbol{r}_{g}^{b}&=\text{ vector from the body fixed-frame origin to the center of gravity}\\
%     \boldsymbol{I}_{g}&=\text{inertia matrix}
% \end{align*}

Where $\boldsymbol{\omega}^{b}$ is the body-fixed frame angular velocity vector. Since this matrix is a function of the vehicle state, it will change with motion. The actual calculations of this matrix are handled by a MatLab program written as a companion to Thor Forson’s book \parencite{mss}. The values based on the system inertia matrix in equation \ref{m_matrix} along with a velocity state vector $\bm{\nu}= [1,0,0,0,0,0]^T$, which represents only forward motion, is shown in equation \ref{c_matrix}.

\begin{equation}
\boldsymbol{C}_{RB}^{CO}(\boldsymbol{\nu})=\left[\begin{array}{cccccc}
0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 9.9000 \\
0 & 0 & 0 & 0 & -9.9000 & 0 \\
0 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 9.9000 & 0 & 0 & 0 \\
0 & -9.9000 & 0 & 0 & 0 & 0
\end{array}\right]
\label{c_matrix}
\end{equation}

\section{Hydrostatic Forces} \label{hydrostatics}

The hydrostatic term $\boldsymbol{g}(\boldsymbol{\eta})$ accounts for the forces on the uDrone caused by gravity and buoyancy. The force of gravity, or weight ($W$) is equal to the mass of the uDrone times the acceleration due to gravity. The buoyant force ($B$) is the weight of the water displaced by the uDrone. This is calculated by multiplying the volume of the uDrone, the density of water, and the acceleration due to gravity. If the location of the center of gravity and center of buoyancy (or center of volume) of the uDrone are not in the same spot then there will be a moment on the whole vehicle. Similarly, if the two forces are not equal then there will also be a net linear force on it. This value is a function of the orientation of the vehicle and can be seen in equation \ref{bigG} \parencite{thor_rb}.

\begin{equation}\label{bigG}
\boldsymbol{g}(\boldsymbol{\eta})=\left[\begin{array}{llll}
& (W-B) \sin (\theta) \\
- & (W-B) \cos (\theta) \sin (\phi) \\
- & (W-B) \cos (\theta) \cos (\phi) \\
- & \left(y_{g} W-y_{b} B\right) \cos (\theta) \cos (\phi) & + & \left(z_{g} W-z_{b} B\right) \cos (\theta) \sin (\phi) \\
& \left(z_{g} W-z_{b} B\right) \sin (\theta) & + & \left(x_{g} W-x_{b} B\right) \cos (\theta) \cos (\phi) \\
- & \left(x_{g} W-x_{b} B\right) \cos (\theta) \sin (\phi) & - & \left(y_{g} W-y_{b} B\right) \sin (\theta)
\end{array}\right]
\end{equation}

% \begin{equation}
%   \boldsymbol{g}(\boldsymbol{\eta})=\left[\begin{array}{llll}
%   0\\0\\0\\0\\0\\0
%   \end{array}\right]
% \end{equation}

Ballasting can be used to adjust the weight and center of mass on the uDrone. To simplify this equation the ballast is set so that the weight and buoyancy are equal and the center of mass and buoyancy are the same. This means the $\boldsymbol{g}$ vector will be zeros for all $\boldsymbol{\eta}$. These forces can be seen interacting on the uDrone in figure \ref{cord_frame}. Maintaining overlapped centers of buoyancy and gravity also makes the vehicle more nimble as there are less moments to overcome when rotating. This also has the benefit of making the uDrone more maneuverable. Equal weight and buoyancy reduces energy used as the uDrone does not need to overcome a force making it sink or float as it cruises through the water column.

There might be reasons to adjust the ballasting of the uDrone to impart other properties on it. For example, if the vehicle is slightly positively buoyant than it will float in the event of a power failure, allowing for it to be recovered more easily. Also, if the center of gravity is placed below the center of buoyancy, but still in line with it in the z body direction, then the vehicle will be self righting in roll. This could make control easier as roll, which should be at zero most of the time, can be ignored.

\section{Hydrodynamic Forces} \label{hydrodynamics}

The added mass system inertia matrix and added mass Coriolis matrix can only be determined through experimentation or complex fluid dynamic simulation and are not calculated in the scope of this thesis. The damping matrix, however, can be estimated using drag calculations.

The vehicle is modeled as a flat-faced cylinder moving through water in a direction along its axis. This estimation neglects two factors: 1) drag from the motors, and 2) rotational damping. Both of these forces are small in comparison to the drag of the flat-faced cylinder, so for the purposes of an approximate model, they can be ignored.

The force of drag in a single direction can be calculated using the drag equation:

\begin{gather}
F_{D}=C_{D} A \frac{\rho V^{2}}{2}
\end{gather}
\begin{align*}
    F_D&=\text{drag Force}\\
    C_D&=\text{coefficient of drag}\\
    A&=\text{cross-sectional area normal to velocity}\\
    \rho&=\text{fluid density}\\
    V&=\text{velocity}\\
\end{align*}

Based on the ratio of the diameter to the length of the main body of the uDrone, the Coefficient of drag in the direction of motion is estimated at 0.8. The density of salt water is 1024kg/m$^3$ and the surface area is calculated from the diameter of the eight inch cylinder, which is 0.037m$^2$. Putting this all together, damping force can be calculated as a function of velocity. This is:

\begin{gather}
    \boldsymbol{D}(\boldsymbol{\nu})\boldsymbol{\nu}=\left[\begin{array}{c}
        -15.0u ^2 \\ \sim 0 \\ \sim 0 \\ D_{roll} \\ D_{pitch} \\ D_{yaw}
     \end{array}\right]
\end{gather}

$u$ is the velocity in the x body direction. The last three values which refer to the rotational damping. For the purposes of calculations in the next section these values were assumed to be zero. The second and third terms, however, will always be zero, or nearly zero, as the vehicle cannot independently move in the Y or Z direction.

\section{Control Inputs}\label{control_inputs}

The control inputs are the forces put on the uDrone from the thrusters. The four motor of the uDrone are arranged on a plane, all facing the same direction. The center point between all the thrusters along that plane is the Center of Origin $C_O$ for the vehicle. Thrusters one and three spin in a counterclockwise direction while thrusters two and four spin clockwise for forward thrust. This ensures that the vehicle has no roll moment when moving forward. Figure \ref{cord_frame} shows the uDrone with the $C_O$ and rotation direction of the thrusters.

\begin{figure}[h]
\includegraphics[width=\maxwidth{\textwidth}]{img/cord_frame.png}
\caption{uDrone Coordinate Frame and Motor Directions}
\label{cord_frame}
\end{figure}

Using this convention it is possible to determine the actuation matrix, tau, as a function of thruster inputs.

\begin{gather}
    \boldsymbol{\tau}=\left[\begin{array}{c}
        F_1+F_2+F_3+F_4 \\ 0 \\ 0 \\ M_1-M_2+M_3-M_4 \\ (F_2+F_3-F_1-F_4) \frac{L}{\sqrt{2}} \\ (F_1+F_2-F_3-F_4) \frac{L}{\sqrt{2}}
     \end{array}\right]
     \label{tau}
\end{gather}

In equation \ref{tau} $F_x$ indicates the linear force produced by the $x^{th}$ motor and $M_x$ indicates the angular momentum produced by the $x^{th}$. $L$ is 0.115m, the length from $C_O$ to the center of the motor, which is the same for each motor. Unfortunately, there is no data from Blue Robotics about the moment of the thrusters, so the relationship between control input to the roll moment will need to be determined experimentally. Data is available, however, correlating motor power and thrust force.

\begin{figure}[h]
\includegraphics[width=\maxwidth{\textwidth}]{img/force_amps.png}
\caption{Force Output vs. Current Draw for T200 Thruster at 14 Volts}
\label{force_amp}
\legend{\emph{Source}: \iftoggle{usebiblatex}{\textcite{t200}}{\citet{t200}}}% See: https://upload.wikimedia.org/wikipedia/commons/8/89/Antidorcas_marsupialis%2C_male_%28Etosha%2C_2012%29.jpg
% \legend{\emph{Note}: Here is a note that is especially long to show what happens when it extends to more than one line.}
\end{figure}

Using the figure \ref{force_amp}, along with data about the uDrone battery, it is possible to calculate the maximum velocity, running time at this velocity, and running time at the operational velocity of 1m/s. While the uDrone can carry two 14V, 18Ah batteries, the intent is to use one for thrusters and the other to control all electronics. Therefore, all longevity calculations are done assuming 18Ah are available for thruster actuation.

In order to calculate maximum velocity, the drag equation is set equal to the maximum thruster force. The T200 thrusters produce a maximum thrust of 41.68N each. This is 166.7N of total thrust. Setting this equal to $15u^2$ and solving yields a maximum speed of 3.33m/s. Maintaining this velocity takes 20.29A, for a total of 81.16A. The uDrone could only maintain this speed for approximately 13.3 minute with an 18Ah battery.

Typically, however, the uDrone will be cruising at a speed of 1m/s. At this speed, the drag force is approximately 15N. To maintain this thrust each motor must produce about 3.75N of force. To maintain this force each motor will use approximately 0.5A, for a total of 2A. In order to stay conservative, a 50\% safety factor will be added to this value to account for uncalculated drag forces and actuation that affect orientations, not just forward motion. With this addition, the vehicle will use 3A for actuation during normal operation. With a single 18Ah battery used for thrusters, this will yield a dive time of approximately 6 hours.


\section*{Motivation}

\subsection*{Why are we interested in the Ising model?}
%\subsection{The Ising model: a model found in statistical mechanics}

\begin{frame}
	  	The Ising model is a mathematical model of ferromagnetism in statistical mechanics.

    Probability of a configuration $\sigma$ ({\color{TurkishRose}\textit{Boltzmann distribution}}):
    \begin{align*}
    P_\beta(\sigma) & = e^{-\beta H(\sigma)} / Z(G), \\
    Z(G) & = \sum_{\sigma \colon V \to \{+,-\}} e^{- \beta H(\sigma)}.
    \end{align*}

    \begin{itemize}
    	\item $Z(G)$ is \textit{the partition function of the Ising model}.
    	\item $Z(G)$ encodes information about the physical system.
    \end{itemize}
\end{frame}

\begin{frame}
		     \begin{align*}
		     P_\beta(\sigma) & = e^{-\beta H(\sigma)} / Z(G), \\
		     Z(G) & = \sum_{\sigma \colon V \to \{+,-\}} e^{- \beta H(\sigma)}.
		     \end{align*}

	\begin{enumerate}
		\item {\color{TurkishRose} \textbf{Problem:}} What is the complexity of evaluating $Z(G)$? \\
		%{\color{TurkishRose}\textbf{Answer:}}
		$\# \mathfs{P}$-hard in some cases.

		\item For some of those cases, $Z(G)$ admits a \textit{fully polynomial-time randomised approximation scheme} \\
		(Jerrum and Sinclair, 1993,  G\"odel prize in 1996).

		\item {\color{TurkishRose} \textbf{Problem:}} What is the complexity of approximating $Z(G)$?

		\item {\color{TurkishRose} \textbf{Application:}}  Strongly simulating \textit{instantaneous quantum polynomial-time circuits} is equivalent to approximating $|Z(G)|$ for some parameters.
	\end{enumerate}
\end{frame}


\section{Error Calculation}
\label{sec:Error_Calculation}
This section contains the error calculation of the measured values. The error calculation is done for the fitted values width $w$, diameter $d$ and grid constant $g$ (see sections \ref{subsec:Slit} to \ref{subsec:Cross-Grid}).

\subsection{Uncertainties}
\label{subsec:Uncertainties}
All conducted measurements in this experiment have uncertainties. Although it was possible to read the position on the y-axis to half a millimeter, the uncertainty is still one millimeter. This is due to the difficulty to find the exact center of the minima or maxima. The systematic uncertainties are shown in table \ref{tab:equipment} ($s_x = 1$ mm and $s_y = 1$ mm).

\subsection{Uncertainty of the Angle $\varphi$}
\label{subsec:Uncertainty_Angle}
The uncertainty $s_\varphi$ of the angle $\varphi$ is calculated with the following equation \ref{eq:uncertainty_angle}:

\begin{equation}
s_{\varphi}=\sqrt{\left(\frac{\partial \varphi}{\partial x}\Biggr|_{\varphi}\cdot s_{x}\right)^2 + \left(\frac{\partial \varphi}{\partial y}\Biggr|_{\varphi}\cdot s_{y}\right)^2}
\label{eq:uncertainty_angle}
\end{equation}

with:

\[
\frac{\partial \varphi}{\partial x}\Biggr|_{\varphi}=-\frac{y}{x^2+y^2} \qquad , \qquad \frac{\partial \varphi}{\partial y}\Biggr|_{\varphi}=\frac{x}{x^2+y^2}
\]

where:
\begin{conditions}
	s_{\varphi} & uncertainty of $\varphi$ \\
	s_x & uncertainty of x \\
	s_y & uncertainty of y \\
	x & distance between the aperture and the projection surface (see figure \ref{fig:experimental_arrangement}) \\
	y & position of the maxima or the minima
\end{conditions}

\subsection{Uncertainty of the Width $w$}
\label{subsec:Uncertainty_Width}
To derive the total uncertainty of the width $w$ the following equations are used. The statistical uncertainty $s_{w,\ \text{stat}}$ is obtained from the fits (from QtiPlot).

\begin{equation}
s_{w,\ \text{tot}}=\sqrt{s_{w,\ \text{syst}}^2+s_{w,\ \text{stat}}^2}
\label{eq:total_uncertainty_w}
\end{equation}

with:
\begin{equation}
s_{w,\ \text{syst}}=\sqrt{\left(\frac{\partial w}{\partial \varphi}\Biggr|_{w}\cdot s_{\varphi}\right)^2}
\label{eq:syst_uncertainty_w}
\end{equation}

where:
\begin{conditions}
	s_{w,\ \text{tot}} & total uncertainty of $w$ \\
	s_{w,\ \text{syst}} & systematic uncertainty of $w$ \\
	s_{w,\ \text{stat}} & statistical uncertainty of $w$ \\
	s_{\varphi} & uncertainty of $\varphi$
\end{conditions}

\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
\subsubsection{Calculated Uncertainties of the Width $w$ (Slit)}
\label{subsubsec:Uncertainty_Width_Slit}
\addtocontents{toc}{\protect\setcounter{tocdepth}{3}}
The systematic uncertainty was calculated by using equation \ref{eq:slit_maxima} and equation \ref{eq:syst_uncertainty_w}. The statistical uncertainty was obtained from table \ref{tab:Slit}. The total uncertainty was calculated by using equation \ref{eq:total_uncertainty_w}. All calculations were done in MATLAB (see appendix \ref{sec:MATLAB_Error_Calculation}).

\begin{table}[H]
	\centering
	\renewcommand{\arraystretch}{1.3}
	\begin{tabular}{r||c|c|c}
		& \textbf{Systematic} ($\mu$m) & \textbf{Statistical} ($\mu$m) & \textbf{Total} ($\mu$m) \\
		\hline\hline
		\textbf{Slit 40 $\mu$m} & -0.92 & 0.10 & 0.93 \\
		\textbf{Slit 100 $\mu$m} & -6.77 & 0.14 & 6.77 \\
	\end{tabular}
	\caption{Calculated Uncertainties for the Width $w$ of the Slit}
	\label{tab:Calculated_Uncertainties_Width_Slit}
\end{table}

To calculate the uncertainty of the 40 $\mu$m slit and the 100 $\mu$m slit the 1st order ($m = 1$) was used. It is generally best to use a low order number (greater uncertainty).

\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
\subsubsection{Calculated Uncertainties of the Width $w$ (Anti-Slit)}
\label{subsubsec:Uncertainty_Width_Anti-Slit}
\addtocontents{toc}{\protect\setcounter{tocdepth}{3}}
The systematic uncertainty was calculated by using equation \ref{eq:slit_maxima} and equation \ref{eq:syst_uncertainty_w}. The statistical uncertainty was obtained from table \ref{tab:Anti-Slit}. The total uncertainty was calculated by using equation \ref{eq:total_uncertainty_w}. All calculations were done in MATLAB (see appendix \ref{sec:MATLAB_Error_Calculation}).

\begin{table}[H]
	\centering
	\renewcommand{\arraystretch}{1.3}
	\begin{tabular}{r||c|c|c}
		& \textbf{Systematic} ($\mu$m) & \textbf{Statistical} ($\mu$m) & \textbf{Total} ($\mu$m) \\
		\hline\hline
		\textbf{Anti-Slit 230 $\mu$m} & -23.33 & 0.34 & 23.34 \\
		\textbf{Anti-Slit 124 $\mu$m} & -6.80 & 0.08 & 6.80 \\
	\end{tabular}
	\caption{Calculated Uncertainties for the Width $w$ of the Anti-Slit}
	\label{tab:Calculated_Uncertainties_Width_Anti-Slit}
\end{table}

To calculate the uncertainty of the 230 $\mu$m anti-slit the 6th order was used. To calculate the uncertainty of the 124 $\mu$m anti-slit the 1st order was used.It is generally best to use a low order number (greater uncertainty).

\newpage

\subsection{Uncertainty of the Diameter $d$}
\label{subsec:Uncertainty_Diameter}
To derive the total uncertainty of the diameter $d$ the following equations are used. The statistical uncertainty $s_{d,\ \text{stat}}$ is obtained from the fits (from QtiPlot).

\begin{equation}
s_{d,\ \text{tot}}=\sqrt{s_{d,\ \text{syst}}^2+s_{d,\ \text{stat}}^2}
\label{eq:total_uncertainty_d}
\end{equation}

with:
\begin{equation}
s_{d,\ \text{syst}}=\sqrt{\left(\frac{\partial d}{\partial \varphi}\Biggr|_{d}\cdot s_{\varphi}\right)^2}
\label{eq:syst_uncertainty_d}
\end{equation}

where:
\begin{conditions}
	s_{d,\ \text{tot}} & total uncertainty of $d$ \\
	s_{d,\ \text{syst}} & systematic uncertainty of $d$ \\
	s_{d,\ \text{stat}} & statistical uncertainty of $d$ \\
	s_{\varphi} & uncertainty of $\varphi$
\end{conditions}

\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
\subsubsection{Calculated Uncertainties of the Diameter $d$ (Circular Aperture)}
\label{subsubsec:Uncertainty_Diameter_Circular-Aperture}
\addtocontents{toc}{\protect\setcounter{tocdepth}{3}}

The systematic uncertainty was calculated by using equation \ref{eq:circular_aperture} and equation \ref{eq:syst_uncertainty_d}. The statistical uncertainty was obtained from table \ref{tab:Circular_Apertures}. The total uncertainty was calculated by using equation \ref{eq:total_uncertainty_d}. All calculations were done in MATLAB (see appendix \ref{sec:MATLAB_Error_Calculation}).

\begin{table}[H]
	\centering
	\renewcommand{\arraystretch}{1.3}
	\begin{tabular}{r||c|c|c}
		& \textbf{Systematic} ($\mu$m) & \textbf{Statistical} ($\mu$m) & \textbf{Total} ($\mu$m) \\
		\hline\hline
		\textbf{Circular Aperture 150 $\mu$m} & -10.21 & 0.83 & 10.24 \\
		\textbf{Circular Aperture 100 $\mu$m} & -4.57 & 0.55 & 4.60 \\
	\end{tabular}
	\caption{Calculated Uncertainties for the Diameter $d$}
	\label{tab:Calculated_Uncertainties_Diameter}
\end{table}

To calculate the uncertainty of the 150 $\mu$m circular aperture and the 100 $\mu$m circular aperture the 2nd Bessel coefficient ($c = 2.233$) was used (see table \ref{eq:coeffs}). It is generally best to use a low "order" number (greater uncertainty).

\newpage

\subsection{Uncertainty of the Grid Constant $g$}
\label{subsec:Uncertainty_Grid_Constant}
To derive the total uncertainty of the grid constant $g$ the following equations are used. The statistical uncertainty $s_{g,\ \text{stat}}$ is obtained from the fits (from QtiPlot).

\begin{equation}
s_{g,\ \text{tot}}=\sqrt{s_{g,\ \text{syst}}^2+s_{g,\ \text{stat}}^2}
\label{eq:total_uncertainty_g}
\end{equation}

with:
\begin{equation}
s_{g,\ \text{syst}}=\sqrt{\left(\frac{\partial g}{\partial \varphi}\Biggr|_{g}\cdot s_{\varphi}\right)^2}
\label{eq:syst_uncertainty_g}
\end{equation}

where:
\begin{conditions}
	s_{g,\ \text{tot}} & total uncertainty of $g$ \\
	s_{g,\ \text{syst}} & systematic uncertainty of $g$ \\
	s_{g,\ \text{stat}} & statistical uncertainty of $g$ \\
	s_{\varphi} & uncertainty of $\varphi$
\end{conditions}

\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
\subsubsection{Calculated Uncertainties of the Grid Constant $g$ (Cross-Grid)}
\label{subsubsec:Uncertainty_Grid_Constant_Cross-Grid}
\addtocontents{toc}{\protect\setcounter{tocdepth}{3}}

The systematic uncertainty was calculated by using equation \ref{eq:cross-grid} and equation \ref{eq:syst_uncertainty_g}. The statistical uncertainty was obtained from table \ref{tab:Cross-Grid}. The total uncertainty was calculated by using equation \ref{eq:total_uncertainty_g}. All calculations were done in MATLAB (see appendix \ref{sec:MATLAB_Error_Calculation}).

\begin{table}[H]
	\centering
	\renewcommand{\arraystretch}{1.3}
	\begin{tabular}{r||c|c|c}
		 & \textbf{Systematic} ($\mu$m) & \textbf{Statistical} ($\mu$m) & \textbf{Total} ($\mu$m) \\
		\hline\hline
		\textbf{Cross-Grid 28 $\mu$m} & -0.36 & 0.44 & 0.57 \\
		\textbf{Cross-Grid 50 $\mu$m} & -0.30 & 0.06 & 0.30 \\
	\end{tabular}
	\caption{Calculated Uncertainties for the Grid Constant $g$}
	\label{tab:Calculated_Uncertainties_Grid_Constant}
\end{table}

To calculate the uncertainty of the 28 $\mu$m cross-grid and the 50 $\mu$m cross-grid the 1st order ($m = 1$) was used. It is generally best to use a low order number (greater uncertainty).