\subsection{Simple iterations}

\begin{Algorithm*}{vector-iteration}{Vector iteration (power method)}

\end{Algorithm*}

\begin{Theorem}{vector-iteration}
  Lat $\mata\in\Cnn$ be diagonalizable such that $\lambda_1$ is the
  unique eigenvalue with maximal modulus. Let furthermore the
  component of $v^{(0)}$ in direction of the first eigenvector be
  nonzero. Then, the factors $\alpha_k$ and vectors $v^{(k)}$ of the
  vector iteration converge to the eigenvalue $\lambda_1$ and its
  associated eigenvector. Moreover, there holds
  \begin{align}
    \abs{\alpha_{k+1}-\lambda_1}
    &\le \frac{\abs{\lambda_1}}{\abs{\lambda_2}} \abs{\alpha_{k}-\lambda_1}\\
    \norm{v^{(k+1)}-u_1}
    &\le \frac{\abs{\lambda_1}}{\abs{\lambda_2}} \norm{v^{(k)}-u_1}
  \end{align}
\end{Theorem}

\begin{Remark}{vector-iteration}
  The proof actually requires, that the entry defining $\alpha_k$
  remains the same during the iteration, at least during the steps
  used for detecting convergence.

  The result does not actually require that $\mata$ is diagonalizable,
  as long as $\lambda_1$ is single and of largest modulus.
\end{Remark}

\begin{Algorithm*}{shifted-vector-iteration}{Shifted vector iteration}
  The vector iteration can be applied to the matrix $\mata-\sigma\id$
  for some $\sigma\in\C$.

  Then, $\alpha_k$ converges to the eigenvalue $\lambda$ such that
  $\lambda-\sigma$ has largest modulus. $v^{(k)}$ converges to an
  eigenvector for this eigenvalue.
\end{Algorithm*}

\begin{Algorithm*}{inverse-iteration}{The inverse power method}

\end{Algorithm*}

\begin{Algorithm*}{Rayleigh-iteration}{The Rayleigh quotient iteration}

\end{Algorithm*}

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


\section{Quadratic Hamiltonians and the Equipartition Function}
\begin{align}
    H &= \sum_{i=1}^{N}\left(
    \frac{p_i^2}{2m_i} + \frac{m_i\omega_i^2}{2}x_1^2
    \right)
\end{align}
The partition function is
\begin{align}
    Z &= \int_{-\infty}^{\infty} \prod_{i=1}^{N} \frac{dx_i\, dp_i}{h^N}
    e^{-\beta\sum_{i}\left(
    \frac{p_i^2}{2m_i}
    + \frac{m_i\omega_i^2}{2} x_i^2
    \right)}\\
    &=
    \prod_{i=1}^{N}\frac{1}{h}\int_{-\infty}^{\infty} e^{%
    -\frac{\beta m_i\omega_i^2}{2}x_i^2
    }
    \int_{-\infty}^{\infty} dp_i\,
    e^{-\beta \frac{p_i^2}{2m_i}}\\
    &= {\left(\frac{k_B T}{\hbar}\right)}^{N} \frac{1}{\prod_{i=1}^{N}\omega_i}
\end{align}
Then the free energy is
\begin{align}
    F &= -k_B T \ln Z \\
    &=
    -N k_B T \ln\left( \frac{k_B T}{2} \right)
    +
    k_B T \sum_{i=1}^{N} \ln\omega_i
\end{align}
The energy is
\begin{align}
    E &= F + TS
\end{align}
where
\begin{align}
    S &= \frac{\partial F}{\partial T}\\
    &= Nk_B \ln\left( \frac{k_B T}{\hbar}  \right)
    + \frac{N k_B T}{T}
    - k_B \sum_{i=1}^{N}\ln \omega_i
\end{align}
and so the energy is
\begin{align}
    E &= Nk_B T =
    \left(
    \frac{k_B T}{2}
    + \frac{k_B T}{2}
    \right) N
\end{align}
Textbooks are confusing and students fall for it.
I think a 1D harmonic oscillator has 1 degree of freedom.
I think a 1D free particle also has 1 degree of freedom.
Forget degrees of freedom,
what matters is the number of quadratic terms in the Hamiltonian.

Each quadratic term in the Hamiltonian has energy $\frac{1}{2}k_B T$.

\begin{example}
    1D array of masses connected by springs with periodic boundary conditions.
\end{example}
The Hamiltonian is
\begin{align}
    H &=
    \sum_{i=1}^{N}\left[
    \frac{p_i^2}{2m}
    + \frac{k}{2} {\left( x_i - x_{i-1} \right)}^2
    \right]
\end{align}
So this is quadratic but a slightly more complicated quadratic.
You see there are cross-terms like $-2x_2x_3 + \cdots$ in there.
You have to account for boundary conditions too.
You have to say that $x_N = x_0$,
including the one that wraps around.
There are 3 terms and they are all there.

What you learn in Chacko's class is that you can do a change of variables that's
going to make this quadratic Hamiltonian that is decoupled.
This is called finding the normal modes.
It's something you're going to relearn in Chacko's class.

I'm going to state here that you can do a change in variables.
That's going to be equivalent to this
\begin{align}
    H &=
    \sum_{i=0}^{N-1}\left[
    \frac{p_i^2}{2m}
    + \frac{m\omega_1^2}{2} q_i^2
    \right]
\end{align}
Basically the $q_i$s are Fourier transforms of the $x_i$'s.
You will find that the magic works and the $q$'s are independent of one another.

If there s one canonical transformation to learn,
it's this one.
The range of applicability of this calculation is huge.
Basically physics is to do more and more complicated cases of harmonic
oscillators.

Now I can complete the partition function of these guys,
taking both terms and just writing the answer.

What is the average energy of this guy of temperature $T$?

It's $\frac{1}{2}k_B T$ for every quadratic term.
There are $2N$ terms.
This is going to be again
\begin{align}
    E &= \frac{1}{2}k_B T \times 2 \times N = Nk_BT
\end{align}
All you needed to know how many normal modes.
You didn't even need to find the frequency.
In physics 101,
they shake a slinky.
There are transverse modes,
longitudinal modes,
and more complicated modes I can't do with my hands.
Each one has different frequencies.
Some long wavelength ones move fast or slow,
but it doesn't matter for the average energy $E$,
it's just $\frac{1}{2}k_BT$ for every quadratic term in the Hamiltonian.

We can now state the equipartition theorem.

\begin{question}
    How do you know how many terms?
\end{question}
If you start with $N$ coordinates,
you get $N$ normal modes no matter how complicated.

\begin{theorem}[Equipartition]
    The thermal average energy of a Hamiltonian $H$ is
    \begin{align}
        E &= \frac{1}{2} k_B T N
    \end{align}
    where $N$ is hte numbero f quadratic terms in $H$.
\end{theorem}
This is true for classical systems.

Let's consider a few systems now for examples.

\begin{example}
    Imagine you have a solid insulator.
    what is the average enregy of an insulating solid?
\end{example}
Please give an example of a solid.
You give 5 things that re not solids with crystal structures.
Glass, styrofoam, plastic.
They're all rigid,
but they're not solids.
The reason I'm not talking about insulators,
is because they have electrons that move around adn that changes the energy.
I'm thinking of an insulator solid,
just a bunch of molecules in a lattice that shake.

The modules have an equilibrium position,
andthey shake around in a complicated way.
To first approximation,
they have some quadratic terms,
and you expand in powers like the distance between the atoms,
and the energy is quadratic.

You want to know how many modules htere are.
Supposey ou have $N$ modules on my chunck of rock.
How many quadratic terms do I have in the Hamiltnian?

There's a 3D knietic term,
so that's 3 quadratic terms for the kinetic enregy.
Whata bout the potential energy?
Again every module has 3 coordiantes $x,y,z$,
so there are 3 quadratic terms per molecule.
So the energy should be
\begin{align}
    E &= \left(
    \underbrace{3N}_{\text{kinetic}}
    + \underbrace{3N}_{potential}
    \right)
    \frac{1}{2}k_B T\\
    &= 3Nk_B T
\end{align}

\begin{question}
    Are you assuming a cubic lattice?
\end{question}
No, it could bea really complicated crystal structure,
but you still have the same number of normal modes.

The specific heat of the substance is
\begin{align}
    c &= \frac{1}{N}\frac{\partial E}{\partial T} = 3k_B
\end{align}

We could check this.
Every insulating solid should have exactly the same specific heat.
That's amazing.
Andi t's not just any number,
nad it's a specific number.

You can see this thing here
What I have here isa bunch of pure elements,
andh ere I have a specific heat of hte number.
The line in  the middle is $3k_B$.

This starts from 30,
and they're all around 23.
So you know there are bad ones like potassium 29,
there's another one 23.

It's an amazing result.
See the work we did.

\begin{question}
    Are we assuming only neighbouring particles are talking to each other?
\end{question}
No, I could have $x_1$ connected to $x_{42}$.
As long as the energy is quadratic in distance,
it doesn't matter.
You could find the normal modes,
and you find there are $3N$ normal modes,
and that's the only thing that matters.

\begin{question}
    At higher temperatures in a crystal lattice,
    you'l have anharonic effects
    like thermal expansion,
    does that influene the specifi heat?
\end{question}
There's no non-linear effects that contribute at high temperature.
How much does a rock expand when you heat a rock.

This is the Dulong-Petit law.
Validity because it really cnovineced people that convineced people statistical
mechanics was right.
It's failure is that it suggested quantum mechanics.

Before we dothat,
let's do a really classic case.
Classic in classical mechanics and classic in that you do it in high school.

\begin{example}[diatomic gas]
    Ideal, nonrelativistic, classical gas.
    What if it's diatomic?
\end{example}
The molecules now look like this.
[picture]
So what's the answer?
If there are $N$ molecules,
how many quadratic terms are you going to have?

Every particle can move in the $x,y,z$ directions,
but the two particles don't move independently,
so that's $6N$ terms.
But there is a potential term for the spring between the two particles,
so
\begin{align}
    E &= (6N + N)\frac{1}{2}k_B T = \frac{7}{2}Nk_B T
\end{align}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CS622: Theory of Formal Languages
% Copyright 2014 Pejman Ghorbanzade <pejman@ghorbanzade.com>
% Creative Commons Attribution-ShareAlike 4.0 International License
% More info: https://github.com/ghorbanzade/beacon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section*{Question 3}

Consider the context-free grammar $ G = (\{S,X_1,X_2,X_3\},\{a,b\},S,\{S\rightarrow X_1 S X_2 X_3, S\rightarrow \lambda, X_1 \rightarrow ab, X_1 \rightarrow X_1 X_2 X_3, X_2 \rightarrow a X_1 b, X_2 \rightarrow \lambda, X_3 \rightarrow X_2 X_1 a b, X_3 \rightarrow b, X_3 \rightarrow \lambda \})$.
Construct an equivalent grammar without erasure productions.

\subsection*{Solution}

We use the procedure described in Theorem 4.5.4 given in \cite{simovici1999theory}.
$G$ is reconstructed as $ G = (\{S,X_1,X_2,X_3, X_a, X_b\},\{a,b\},S,\{S\rightarrow X_1 S X_2 X_3, S\rightarrow \lambda, X_1 \rightarrow X_aX_b, X_1 \rightarrow X_1 X_2 X_3, X_2 \rightarrow X_a X_1 X_b, X_2 \rightarrow \lambda, X_3 \rightarrow X_2 X_1 X_a X_b, X_3 \rightarrow X_b, X_3 \rightarrow \lambda, X_a \rightarrow a, X_b \rightarrow b \})$.

The sequence of subsets of $\{S,X_1,X_2,X_3, X_a, X_b\}$ constructed in Theorem 4.5.4 would be,

\begin{equation}
\begin{aligned}
U_0 &= \{X | X\in A_N, X\rightarrow \lambda \in P\}\\
&= \{S, X_2, X_3\}
\end{aligned}
\end{equation}

\begin{equation}
\begin{aligned}
U_{1} &= U_{0} \cup \{X\in A_N | X\rightarrow \alpha \in P, \alpha \in U^*_0\}\\
&= \{S, X_2, X_3\} \cup \emptyset\\
&= U_{0}
\end{aligned}
\end{equation}

Therefore, the set of productions $P^\prime$ constructed is given by

\begin{equation}
\begin{aligned}
P^\prime =\ & \{S\rightarrow X_1SX_2X_3,\ S\rightarrow X_1SX_2,\ S\rightarrow X_1SX_3,\ S\rightarrow X_1X_2X_3,\\
& S\rightarrow X_1S,\ S\rightarrow X_1X_2,\ S\rightarrow X_1X_3,\ S\rightarrow X_1,\\
& X_1 \rightarrow X_aX_b,\ X_1\rightarrow X_1X_2X_3,\ X_1 \rightarrow X_1X_2,\ X_1 \rightarrow X_1X_3\\
& X_2 \rightarrow X_aX_1X_b,\ X_3\rightarrow X_2X_1X_aX_b,\ X_3\rightarrow X_1X_aX_b,\\
& X_3 \rightarrow X_b,\ X_a\rightarrow a,\ X_b \rightarrow b\}
\end{aligned}
\end{equation}

And the equivalent grammar $G^\prime=(A_N, A_T, S, P^\prime)$ would be the equivalent grammar of $G$ without erasure productions.


\documentclass[12pt]{article}
\setlength\parindent{0pt}
\usepackage{graphicx}
\usepackage[margin=1.0in]{geometry}
\usepackage{amsmath}
\usepackage{ulem}
\usepackage{color}
\usepackage{hyperref}
\setlength{\parindent}{2em}
\graphicspath{ {./images/} }
\title{CTA200H Assignment 2}
\author{Sarah Thiele}
\date{\today}

\begin{document}
\maketitle

\section{Question 1:}
\subsection{Methods}
This question studied the divergence of the magnitude-squared of the function
\begin{align}
    z_{i+1}=z_i + c
\end{align}
for numbers $c$ in the complex plane with real and imaginary parts $-2 \leq x,y \leq 2$. Here the magnitude, or absolute value, squared is defined as $|z_{i+1}|^2=(Re[z_{i+1}])^2+(Im[z_{i+1}])^2$. In order to work with every combination of $x$ and $y$ values, I defined 400-element arrays of each, and used numpy's function "meshgrid" which created a 2-dimensional array filled with the $x$ and $y\cdot i$ arrays. I then defined my complex array ``c" to be the sum of the zeroth and first dimension of the mesh such that we get a $400^2$ length array of the form $x+iy$. I arbitrarily defined an epsilon value of $\epsilon=100.0$ to use as a divergence measure, and a maximum iteration count of $i=1000$. We were given $z_0 = 0.0$.

I next defined a function $recursion(c)$ which takes in the mesh c and uses a for loop to iterate Function (1). At each iteration, it takes the magnitude squared of the updated $z$ value, i.e $|z_{i+1}|^2$. If this value is greater than epsilon, then that element of the c array is said to be divergent. The function than adds the divergent values from that iteration to an array of divergent numbers, and adds the iteration number to another array the same number of times as the amount of divergent $z$ values there are for the iteration. e.g if three numbers diverge at iteration $i$, then those three numbers will be appended to the array defined as ``z\_div", and the iteration number $i$ will be appended three times to the array ``i\_div". This allows for every divergent element to have an iteration number associated with it when we plot the colour dimension, dependent on this quantity. The function then gets rid of values from the c array and the $z_i$ array which are divergent using a Boolean mask, and then moves on to the next iteration. Once we hit the maximum iteration number, the function defines all the remaining numbers to be those that remain bounded, and returns the arrays of bounded and divergent numbers as well as the iteration number array. We can then plot the complex plane with two colours defining the bound vs. divergent values, as we see in Figure 1, or with a colour scale which depends on the iteration number of divergence, like in Figure 2 and zoomed in version Figure 3, using matplotlib.

\begin{figure}
    \centering
    \includegraphics[scale=0.80]{Q1plot3_CITA200HA2.png}
    \caption{The divergence of complex magnitudes for $c = x + iy$ with $-2\leq x,y \leq 2$. The light blue region represents values that remain bounded, and the dark blue values diverge. Divergence was defined to be when $|z_{i+1}|^2 \geq 100.0$.}
    \label{fig:my_label}
\end{figure}

\begin{figure}
    \centering
    \includegraphics[scale=0.73]{Q1plot1_CITA200HA2.png}
    \caption{The same procedure as Figure 1, now coloured according to the value at which the number diverged, which is shown according to the colour bar. The light purple inner region again represents values which stay bounded.}
    \label{fig:my_label}
\end{figure}

\begin{figure}
    \centering
    \includegraphics[scale=0.73]{Q1plot2_CITA200HA2.png}
    \caption{A closer look at our plot from Figure 2.}
    \label{fig:my_label}
\end{figure}

\pagebreak
\subsection{Analysis}

What arises from the results of this question is the \href{https://en.wikipedia.org/wiki/Mandelbrot_set}{\color{blue}\uline{Mandelbrot Set}}, which would become increasingly intricate if we were to iterate with arrays of a smaller step size. Unfortunately, the computation time increases extremely fast for this function. We see that values closest to and on the boundary of the bounded region diverge much later than values further away from the bounded region. Outside the boundary, the values diverge almost immediately. We see that besides the main cardioid, the pattern is periodic with various sized circular bulbs. Furthermore the pattern is symmetric when flipped across the $x$-axis. When we zoom in, we can see there are small trails of slightly larger divergence iteration numbers that seep into the outer regions. These trails are lighter (diverge later) than those on the boundary. There is also a very faint tail that points straight leftwards from the smallest leftside bulb of the pattern and connects in a straight line to a small dot at ~(-1.75, 0.00).

The zoomed-in plot had higher resolution, as it was along a smaller range of values ($-1.30 \leq x \leq -0.50$ and $0.00 \leq y \leq 0.65$), and the $x$ and $y$ arrays were each 600 elements in length. The faint trails are more pronounced and we can see some of the finer detail along the boundary.

\section{Question 2:}
\subsection{Methods}
\subsubsection{SIR Model}
In this question we were investigating the SIR Model in epidemeology which models the spread of disease for a given population. It is based on the following set of three ordinary differential equations:

\begin{align}
    \frac{dS}{dt} &= -\frac{\beta S I}{N} \\
    \frac{dI}{dt} &= \frac{\beta S I}{N} - \gamma I \\
    \frac{dR}{dt} &= \gamma I
\end{align}

As we can see, $\frac{dS}{dt} + \frac{dI}{dt} + \frac{dR}{dt} = 0$. Here $S(t)$ is the amount of the population susceptible to the disease and $I(t)$ is the number of infected individuals. In our homework it states that $R(t)$ is the number of recovered individuals who are now immune, but often $R(t)$ in the SIR model is simply the removed population, i.e those which are no longer susceptible or infected. It does not differentiate between those who are deceased and those that are recovered and now immune. For our purposes we will assume a death rate of 0\% such that $R(t)$ is the number of recovered individuals.

For the SIR Model, $\beta$ is the average number of contacts per person per time, i.e the infection rate, and $\gamma$ is often defined as $\frac{1}{T}$, where $T$ is the amount of time an individual is infectious for before an outcome occurs. N is the population number.

The mathematical term $R_0$ to used to describe how contagious a disease is. It tells us how many people one individual will infect on average. It is also described with $R_0 = \frac{\beta}{\gamma}$. I chose $R_0 = 5$, and then calculated three values for $\beta$ from three values of $\gamma$ I chose from common ranges I saw online. We were also given initial values for S, I and R as 999, 1, and 0 respectively. The population number N is 1000.

To solve the system of ODEs, I used scipy.integrate's solve\_ivp. I first defined a model function which takes in a time array, a vector of S, I, and R for a particular time step, and the two parameters $\beta$ and $\gamma$. It calculates the current rate of change from the three equations and returns them in a list. For various values of $\beta$ and $\gamma$, solve\_ivp solves the system of ODEs for the defined time span of 0 to 200 and outputs a time array and the values of S, I, and R as a function of time. I then plotted the various curves.

\subsubsection{SIRD Model}

We now switch to the SIRD Model. S is again the number of people susceptible, and I those infected, to a disease as a function of time. The SIRD model is important as it differentiates the old R, the removed population from the SIR model, into either being recovered/immune (R) or deceased (D). $\beta$ is the infection rate, $\gamma$ is the recovery rate, and we add $\mu$, the now non-zero mortality rate. The ODEs change now to accommodate this:

\begin{align}
    \frac{dS}{dt} &= - \frac{\beta S I}{N} \\
    \frac{dI}{dt} &= \left(\frac{\beta S}{N} - \gamma - \mu\right) \cdot I \\
    \frac{dR}{dt} &= \gamma I \\
    \frac{dD}{dt} &= \mu I
\end{align}

I assumed a mortality rate of 1\% and an initial death number of 0. The rest of the solution is the same as for the SIR Model, just with an extra ODE to solve. The other initial values, population number, and arrays for $\beta$ and $\gamma$ also remain the same. See \hyperref[subsec:AnalysisQ2]{\color{blue}\uline{here}} for analysis of Figure 4 and 5.

\begin{figure}
    \centering
    \includegraphics[scale=0.35]{SIR_Model_CTA200HQ2.png}
    \caption{Caption}
    \label{fig:my_label}
\end{figure}

\begin{figure}
    \centering
    \includegraphics[scale=0.35]{SIRD_Model_CTA200HQ2.png}
    \caption{Caption}
    \label{fig:my_label}
\end{figure}

\pagebreak

\subsection{Analysis}
\label{subsec:AnalysisQ2}

\subsubsection{SIR Model: Figure 4}
We see the expected general trends: the susceptible population decreases as people are moved into either the infected or recovered category over time; the number of infected individuals increases rapidly, and decreases quite quickly as well for our parameters, with the decline of infection mirrored by a steep incline in recovered, or in general removed, individuals; All three curves asymptotically approach a single value. We see that the peak of the number of infected individuals occurs at about the same time where the curves pertaining to the susceptible and recovered populations intersect. This makes sense intuitively: to the right of this peak, the number of removed individuals overtakes the number of susceptible and continues increasing, and so the number of infected individuals decreases as we move forward in time. To the left of the peak, the number of susceptible individuals is higher than those recovered, so there are more people able to become infected and hence the number of infected is increasing, creating this global maximum.

The amplitude of the curves and their decay times depend on the $\beta$ and $\gamma$ values. For constant $\beta$, across a row in Figure 4, the amplitude of the peak of infection becomes lower, and not all individuals become infected for higher values of $\gamma$ over the investigated time span, such that the susceptible population curve does not reach zero. Since $\gamma$ is the inverse of the average time an individual is infected, a higher $\gamma$ means a fast recovery time, and so for constant infection rate this means the disease will be less aggressive but for a longer period of time. The decay rate of the curves, or their slope trend, remains similar across the figure's rows. For constant $\gamma$, down the figure columns, we see that the amplitude of the infection curve increases, as well as becomes steeper, i.e a smaller standard deviation. The slopes of the other curves also become much steeper. This is because for a constant recovery rate, an increase in the infection rate means that a disease will spread rapidly, hence the fast spike, and then decay as people recover.

\subsection{SIRD Model: Figure 5}
For this model, we see the same trends as for the SIR Model. The only difference is that we now have a curve for the deceased individuals. It approaches a singular value which is a certain percentage of the population based on the mortality rate $\mu$ and the other parameters. The deceased curve increases faster for higher infection rates as expected. We also see the recovered line approach a lower value than for the previous model because not all individuals who's cases were resolved resulted in recovery - the disease also has a death rate now.

We can interpret the two models as either that the SIR Model is working with a disease with a mortality rate $\mu=0$, and the SIRD model has $\mu \neq 0$, or that the SIR Model simply does not differentiate between recovered and deceased individuals. Either way, this explains the changes in amplitude of the recovered population.

\end{document}


\documentclass{article}
\usepackage[utf8]{inputenc}

\title{MAT257 Notes}
\author{Jad Elkhaleq Ghalayini}
\date{October 15 2018}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{enumitem}
\usepackage{graphicx}
\usepackage{cancel}

\usepackage[margin=1in]{geometry}

\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}
\newtheorem{definition}{Definition}
\newtheorem*{corollary}{Corollary}
\newtheorem{exercise}{Exercise}

\newcommand{\reals}[0]{\mathbb{R}}
\newcommand{\nats}[0]{\mathbb{N}}
\newcommand{\ints}[0]{\mathbb{Z}}
\newcommand{\rationals}[0]{\mathbb{Q}}
\newcommand{\brac}[1]{\left(#1\right)}
\newcommand{\sbrac}[1]{\left[#1\right]}
\newcommand{\mc}[1]{\mathcal{#1}}
\newcommand{\eval}[3]{\left.#3\right|_{#1}^{#2}}
\newcommand{\ip}[2]{\left\langle#1,#2\right\rangle}
\newcommand{\prt}[2]{\frac{\partial #1}{\partial #2}}

\begin{document}

\maketitle

\section*{Implicit Function Theorem}

Assume we have a function \(F(x, y) = 0\). Can we solve for \(y\) as a function \(y = g(x)\) near a point \((a, b)\) such that \(F(a, b) = 0\)?
For example, assume \(f(x, y) = x^2 + y^2 - 1\).
This relationship, of course, defines the unit circle. Can we solve for \(y\) at a function of \(x\) at any point on the unit circle? No: we can't do so where \(y = 0\), we can only get \(x\) as a function of \(y\).
If we pick a point \((a, b) \in \reals^2\) however, and assume \(a \neq \pm 1\), then there are open intervals \(I, J\) such that for every \(x \in I\), there is a unique \(y = g(x) \in J\) such that \(f(x, y) = 0\).

Let's restrict our attention to a small enough interval such that \(b > 0\). Of course, then, we can explicitly write down what the solution is:
\[g(x) = \sqrt{1 - x^2}\]

Sometimes in this context people say that one of the variables is dependent and the other is independent. Which is which? How should you understand that language? Well, the dependent variable is the one that is determined by the independent one you specify. But that notion, it depends on where you are: at the poles \(x = \pm 1\), we can only solve for \(x\), whereas at the poles \(y \pm 1\), we can only solve for \(y\).

Furthermore, we may not be able to find a nice formula for \(g\). However, by what's known as ``implicit differentiation,'' we can find a formula for the \textit{derivative of} \(g\).

\section*{Implicit Differentiation}
Let's assume we have a function
\[F(x, g(x)) = 0\]
Whether or not we have a formula for \(g\), we can use the chain rule to obtain
\[\frac{d}{dx}F(x, g(x)) = \partial_1(x, g(x)) + \partial_2(x, g(x))g'(x) = 0\]
So we find that
\[g'(x) = -\frac{\partial_1(x, g(x))}{\partial_2(x, g(x))}\]
Now this formula depends on \(g\). Is this weird or expected? Well, it makes sense. Consider the example above: we might have two solutions (points on the circle) on top of each other for a given \(x\)-coordinate. This formula works for \textit{both} of them.

\end{document}


\chapter{Einstein's Field Equations}
We will derive Einsteins Equations by physical considerations. Remember that the
Poisson equation reads
\begin{equation}
\Delta\Phi=4\pi\varrho\, .
\end{equation}
So matter (energy) is the source of the gravitational field $\Phi$.  From SR we
know that the energy momentum tensor $\tensor{T}{_\mu_\nu}$ is an adequate
generalisation of energy.
We therefore put $\tensor{T}{_\mu_\nu}$ as the right hand side of a yet to be
found equation, and ask for the left hand side. We would like a tensor
$\tensor{S}{_\mu_\nu}$, related to the geometry, so that we can express
\begin{equation}
\tensor{S}{_\mu_\nu}=\tensor{T}{_\mu_\nu}
\,.
\end{equation}
In SR, the energy momentum tensor $\tensor{T}{_\mu_\nu}$ is conserved i.e.
$\tensor{T}{_\mu_\nu^{,\nu}}=0$. As a natural extension, we demand that the
energy momentum tensor of general relativity is \emph{covariantly} conserved
\begin{equation}
\tensor{\nabla}{^\nu}\tensor{T}{_\mu_\nu}=\tensor{T}{_\mu_\nu^{;\nu}}=0
\end{equation}
\begin{theorem}[Lovelock]
For a four dimensional space
\footnotemark{} the most general divergence free tensor $\tensor{A}{_\mu_\nu}$ is
given by
\begin{equation}
\tensor{A}{_\mu_\nu}= c_1\tensor{G}{_\mu_\nu}+c_2\tensor{g}{_\mu_\nu}\, .
\end{equation}
Where $\tensor{G}{_\mu_\nu}$ is the \emph{Einstein tensor}
$\tensor{G}{_\mu_\nu}:=\tensor{R}{_\mu_\nu}-\frac{1}{2}\tensor{g}{_\mu_\nu}R$.
\end{theorem}
\footnotetext{this does certainly not hold true for
$d>4$}
The theorem immediately implies \emph{Einstein's field equations}
\begin{equation}
\tensor{R}{_\mu_\nu}-\frac{1}{2}R\tensor{g}{_\mu_\nu}-\Lambda\tensor{g}{_\mu_\nu}
=\kappa\tensor{T}{_\mu_\nu}\, ,\label{eq:EinstFG}
\end{equation}
with some constants $\kappa$, $\Lambda$.
Of course we identify Einsteins constant $\kappa=\frac{8\pi
G\textsubscript{N}}{c^2}$ and the cosmological constant $\Lambda$. As a slight
variation, we can rewrite equation \eqref{eq:EinstFG} as
\begin{equation}
\tensor{R}{_\mu_\nu}-\frac{1}{2}R\tensor{g}{_\mu_\nu}
=\kappa\left(\tensor{T}{_\mu_\nu}-\frac{\Lambda}{\kappa}\tensor{g}{_\mu_\nu}\right)
\end{equation}
so that the left hand side represents the geometrical part and the right hand
side the matter content and we identify $\Lambda$ with an vacuum energy.
Wheeler condenses this in the statement:
\begin{quote}
Geometry tells matter how to move, matter tells geometry how to
curve.
\end{quote}
\begin{sidenote}
In the time of the inflation the cosmological constant must have been large.
Since it is small today it has do decay with time.
\end{sidenote}
There is also an variational derivation dating back to Hilbert that is
simpler than Einsteins initial derivation. We start by considering a general action
\begin{equation}
S\textsubscript{g}=\fourint  \tilde{\mathcal{L}}\,
\end{equation}
where $\tilde{\mathcal{L}}$ must transform as a (scalar) density. Therefore we
define a scalar $\mathcal{L}=\frac{\tilde{\mathcal{L}}}{\sqrt{-g}}$
\begin{equation}
S\textsubscript{g}=\fourint \sqrt{-g}\mathcal{L}
\end{equation}
One can think of various contributions to $\mathcal{L}$, e.g.
\begin{equation*}
R,\, \square
R,\,\tensor{\nabla}{^\mu}\tensor{\nabla}{^\mu}\tensor{R}{_\mu_\nu},\,
\tensor{R}{_\mu_\nu}\tensor{R}{^\mu^\nu}
,\,\tensor{R}{_\mu_\nu_\sigma_\varrho}\tensor{R}{^\mu^\nu^\sigma^\varrho}\dots\,,
\end{equation*}
which are contractions, so that the resulting quantity becomes a scalar.
We have no contributions of the metric alone, because
$\tensor{g}{_\mu_\nu_{;\sigma}}=0$. From Yang-Mills theory one would expect a
structure
\begin{equation}
\mathcal{L}\sim\tensor{F}{_\mu_\nu}\tensor{F}{^\mu^\nu}\,,
\end{equation}
but $\Gamma$ is not the fundamental field but $g$ is. If we demand that we only
have up to second derivatives of $g$ the only allowed term in the Lagrangian is
$R$.
\begin{sidenote}[On higher derivatives]
If we include higher order derivatives of $g$ in the right way we can make the
resulting theory renormalizable. However we violate unitarity and introduce
so-called ghost fields which are associated with the additional degrees of freedom we get.
\end{sidenote}
\begin{remark}[Dimensions]
In natural units\footnote{So that length has dimension of inverse mass.} the
line element $\dif s^2$ has dimension, \\${[\dif
s^2]=\textrm{M}^{-2}}$.\footnote{Where M refers to the dimension of mass.}
Since further ${\left[\tensor{x}{^\mu}\right]=\textrm{M}^{-1}}$,
the Lagrange density must have Dimension
${\left[\mathcal{L}\right]=\textrm{M}^{4}}$.
\end{remark}
This constraint leads to the \emph{Einstein-Hilbert-action}
\begin{equation}
S\textsubscript{EH}=\frac{1}{2\kappa}\fourint \sqrt{-g}(R-2\Lambda)
\end{equation}
We now check that its variation indeed reproduces Einstein's equations. To do
so we introduce the formalism of \emph{functional derivation}. Let therefore
$\Phi=\{\varphi,\tensor{A}{^\mu},\Psi,\dots\}$ be a collection of fields.
$F[\Phi]$ a functional.
We define the variation of $F$ as
\begin{equation}
\delta F:=\int \dif x\, \frac{\delta F}{\delta\Phi^i}\delta\Phi^i\,.
\end{equation}
Typically the functionals are given in the form
\begin{equation}
S[\Phi]=\int \dif x\, L(x,\Phi)\, ,
\end{equation}
where $L$ is some local function.
\begin{equation}
\frac{\delta\tensor{g}{_\varrho_\sigma}(x)}{\delta\tensor{g}{_\mu_\nu}(x')}=\tensor*{\delta}{*^\mu*^\nu*_\varrho*_\sigma}\delta(x,x')\
\end{equation}
Where
$\tensor*{\delta}{*^\mu*^\nu*_\varrho*_\sigma}=\frac{1}{2}\left(\tensor*{\delta}{^\nu_\varrho}\tensor*{\delta}{^\mu_\sigma}+\tensor*{\delta}{^\mu_\varrho}\tensor*{\delta}{^\nu_\sigma}\right)$
is the unity of the space of symmetric rank two tensors
\begin{remark}
In general $\delta(x,x')\neq \delta(x-x')$
\end{remark}
We transform to the origin of an RNCS, so that the Christoffel symbols vanish.
In that coordinate system the covariant and the partial derivative coincide:
$\tensor{\partial}{_\mu}=\tensor{\nabla}{_\mu}$.
\begin{equation}
\begin{split}
\delta \tensor{R}{^\rho_\mu_\nu_\sigma}
&=\delta \tensor{\partial}{_\nu}\cSym{\rho}{\mu}{\sigma}
-\delta \tensor{\partial}{_\mu}\cSym{\rho}{\nu}{\sigma}\\
&=\tensor{\partial}{_\nu}\delta \cSym{\rho}{\mu}{\sigma}
-\tensor{\partial}{_\mu}\delta \cSym{\rho}{\nu}{\sigma}\\
\end{split}
\end{equation}
Attention: i.A. $\delta\tensor{\partial}{_\mu}\neq\tensor{\partial}{_\mu}\delta$
\begin{equation}
\begin{split}
\delta \tensor{R}{_\mu_\nu}
&=\delta \tensor{R}{^\rho_\mu_\rho_\nu}\\
&=\tensor{\partial}{_\rho}\delta \cSym{\rho}{\mu}{\nu}
-\tensor{\partial}{_\mu}\delta \cSym{\rho}{\rho}{\nu}\\
&=\tensor{\nabla}{_\rho}\delta \cSym{\rho}{\mu}{\nu}
-\tensor{\nabla}{_\mu}\delta \cSym{\rho}{\rho}{\nu}\\
\end{split}
\end{equation}
This holds in a general frame since it is a tensor equation.
\begin{equation}
\begin{split}
\delta R &=\delta \left(\tensor{g}{^\mu^\nu}\tensor{R}{_\mu_\nu}\right)\\
&=\tensor{R}{_\mu_\nu}\delta\tensor{g}{^\mu^\nu}
+\tensor{g}{^\mu^\nu}\delta\tensor{R}{_\mu_\nu}\\
\end{split}
\end{equation}
Use \eqref{eq:grels}
\begin{equation}
\begin{split}
2\kappa\delta S\textsubscript{EH}
&=\fourint \left[
(R-2\Lambda)\delta\sqrt{-g}+\sqrt{-g}\delta R\right]\\
&=\fourint \left[
\frac{1}{2}\sqrt{-g}\tensor{g}{^\mu^\nu}\delta\tensor{g}{_\mu_\nu}
(R-2\Lambda)+\sqrt{-g}\left(\tensor{R}{_\mu_\nu}\delta\tensor{g}{^\mu^\nu}
+\tensor{g}{^\mu^\nu}\delta\tensor{R}{_\mu_\nu}\right)\right]\\
&=\fourint \sqrt{-g}\left[
\frac{1}{2}\tensor{g}{^\mu^\nu}
(R-2\Lambda)+\tensor{R}{^\mu^\nu}\right]\delta\tensor{g}{_\mu_\nu}
+\fourint \sqrt{-g}\tensor{g}{^\mu^\nu}\delta\tensor{R}{_\mu_\nu}
\\
\end{split}
\end{equation}
We treat both occurring terms separately
\begin{equation}
\begin{split}
\fourint \sqrt{-g}\tensor{g}{^\mu^\nu}\delta\tensor{R}{_\mu_\nu}
&=\fourint \sqrt{-g}\tensor{g}{^\mu^\nu}\left(\tensor{\nabla}{_\rho}\delta
\cSym{\rho}{\mu}{\nu} -\tensor{\nabla}{_\mu}\delta \cSym{\rho}{\rho}{\nu}\right)
\\
&=\fourint \tensor{\nabla}{_\rho}\left(\sqrt{-g}\tensor{g}{^\mu^\nu}\delta
\cSym{\rho}{\mu}{\nu}\right)\\
&\phantom{=}-\int\dif{}^4 x \tensor{\nabla}{_\mu}\left(\sqrt{-g}\tensor{g}{^\mu^\nu}\delta
\cSym{\rho}{\rho}{\nu}\right)
\end{split}
\end{equation}
The Integrals vanish by \name{Gauß} law (neglecting surface Terms). We are left
with
\begin{equation}
\begin{split}
2\kappa\delta S\textsubscript{EH}
&=\fourint \sqrt{-g}\left[
\frac{1}{2}\tensor{g}{^\mu^\nu}
(R-2\Lambda)+\tensor{R}{^\mu^\nu}\right]\delta\tensor{g}{_\mu_\nu}
\end{split}
\end{equation}
So that we can now finally calculate the variation with respect to the metric
field
\begin{equation}
\frac{\delta
S\textsubscript{EH}[\tensor{g}{_\mu_\nu}(x)]}{\delta\tensor{g}{_\mu_\nu}(x')}
=\sqrt{-g}\left[\frac{1}{2}\tensor{g}{^\mu^\nu}
(R-2\Lambda)+\tensor{R}{^\mu^\nu}\right]
\end{equation}
It vanishes if
\begin{equation}
\tensor{R}{^\mu^\nu}+\frac{R}{2}\tensor{g}{^\mu^\nu}
-\Lambda\tensor{g}{^\mu^\nu}=0\, .
\end{equation}
so we have finally derived Einsteins field equations from an variational
principle.
%TODO add some text, to much formulas
\section{Introduction of Matter}
In the gravitational context we mean be \emph{matter} any non gravitational
fields this include scalar fields $\varphi$, spinor fields $\Psi$, gauge fields
$\tensor{A}{^\mu}$,\dots. We collect all of them in a multivariable $\Phi$.
A local action can be written as
\begin{equation}
S\textsubscript{m}[\Phi,g]=\fourint  \sqrt{-g}
L\textsubscript{m}\left(\Phi,\tensor{\nabla}{_\mu}\Phi,g\right)
\end{equation}
$\tensor{g}{^\mu^\nu}$ appears in $L\textsubscript{m}$ because the derivatives
$\tensor{\nabla}{_\mu}, \tensor{\partial}{_\mu}$ must be contracted.
Additionally it enters via $\sqrt{-g}$.
\begin{example}[Free scalar field]
The action of a free scalar field in Minkovski space has the form
\begin{equation}
S\textsubscript{m}=\fourint  \left(-\frac{1}{2}\tensor{\eta}{^\mu^\nu}
\tensor{\partial}{_\mu}\varphi\tensor{\partial}{_\nu}\varphi-\frac{1}{2}m^2\varphi^2\right)\,.
\end{equation}
The minus sign in front of the partial derivative should come as no surprise
since we have $\tensor{\eta}{^0^0}=-1\, \dot{\varphi}^2>0$. In a non inertial
frame we have to make the usual replacements
\begin{equation}
\tensor{\eta}{_\mu_\nu}\to \tensor{g}{_\mu_\nu}\, , \quad
\tensor{\partial}{_\mu}\to
\tensor{\nabla}{_\mu}\,, \quad \dif{}^4 x \to \dif{}^4 x\, \sqrt{-g}\, ,
\end{equation}
which is also known as a \emph{minimal coupling description}. The action for a
scalar $\varphi$ in the presence of gravity,
i.e. a dynamical $\tensor{g}{_\mu_\nu}(x)$, reads as
\begin{equation}
S\textsubscript{m}=\fourint\,
\sqrt{-g}\left(-\frac{1}{2}\tensor{g}{^\mu^\nu} \tensor{\nabla}{_\mu}\varphi\tensor{\nabla}{_\nu}\varphi
-\frac{1}{2}m^2\varphi^2\right)\,.
\end{equation}
 The combined action of scalar field and
gravity is given as
\begin{equation}
S[g,\varphi]=S\textsubscript{g}[g]+S\textsubscript{m}[g,\varphi]\,.
\end{equation}
The variation with respect to the field $\varphi$ is
\begin{equation}
\begin{split}
\frac{\delta S[g,\varphi]}{\delta
\varphi\left(x'\right)}&=\frac{\delta S\textsubscript{m}[g,\varphi]}{\delta
\varphi\left(x'\right)}\\
&=\fourint\sqrt{-g}\left[-\tensor{g}{^\mu^\nu}
\tensor{\nabla}{_\mu}\varphi\tensor{\nabla}{_\nu}\left(\frac{\delta
\varphi(x)}{\delta \varphi\left(x'\right)}\right)-m^2\varphi\frac{\delta
\varphi(x)}{\delta \varphi\left(x'\right)}\right]\,,
\end{split}
\end{equation}
where we used that the $\delta$ and $\tensor{\nabla}{_\mu}$ commute. Partial
integration yields
\begin{equation}
\begin{split}
\frac{\delta S\textsubscript{m}[g,\varphi]}{\delta \varphi\left(x'\right)}&=\fourint \sqrt{-g}\left(\square_{g}-m^2\right)\varphi\delta(x,x')\\
&=\sqrt{-g}\left(\square_{g}-m^2\right)\varphi\, ,
\end{split}
\end{equation}
with $\square_{g}:=\tensor{g}{^\mu^\nu}
\tensor{\nabla}{_\mu}\tensor{\nabla}{_\nu} $ the
\emph{\name{Laplace–Beltrami} operator}, a generalisation of the ordinary
Laplacian to curved space.
Demanding that the variation with respect to $\varphi$ vanishes implies the
\emph{Klein-Gordon equation}
\begin{equation}
\left(\square_g-m^2\right)\varphi=0
\end{equation}
We can also vary the action with respect to the metric
field $\tensor{g}{_\mu_\nu}$ resulting in
\begin{equation}
\frac{\delta S[g,\varphi]}{\delta
\tensor{g}{_\mu_\nu}\left(x'\right)}=
\frac{\delta S\textsubscript{g}[g]}{\delta
\tensor{g}{_\mu_\nu}\left(x'\right)}
+\frac{\delta S\textsubscript{m}[g,\varphi]}{\delta
\tensor{g}{_\mu_\nu}\left(x'\right)}
=\frac{\sqrt{-g}}{2\kappa}\left(\tensor{G}{^\mu^\nu}+\Lambda\tensor{g}{^\mu^\nu}
\right)+\frac{\delta S\textsubscript{m}[g,\varphi]}{\delta
\tensor{g}{_\mu_\nu}\left(x'\right)}\,.
\end{equation}
To recover the Einstein equations it is convenient to define the
energy-momentum tensor
\begin{equation}
\tensor{T}{^\mu^\nu}:=-\frac{2}{\sqrt{-g}}\frac{\delta
S\textsubscript{m}[g,\varphi]}{\delta \tensor{g}{_\mu_\nu}\left(x'\right)}\,.
\end{equation}
We can now proceed in calculating the quantity we have just introduced for a
scalar field
\begin{equation}
\begin{split}
\frac{\delta
S\textsubscript{m}[g,\varphi]}{\delta \tensor{g}{_\mu_\nu}\left(x'\right)}
&=\int \dif{}^4x \frac{\delta\sqrt{-g}}{\delta
\tensor{g}{_\mu_\nu}}\left(-\frac{1}{2}\tensor{g}{^\mu^\nu}
\tensor{\nabla}{_\mu}\varphi\tensor{\nabla}{_\nu}\varphi-\frac{1}{2}m^2\varphi^2\right)\\
&\phantom{=}+
\sqrt{-g}\left(-\frac{1}{2}\tensor{g}{^\alpha^\varrho}\tensor{g}{^\beta^\sigma} \tensor{\nabla}{_\alpha}\varphi\tensor{\nabla}{_\beta}\varphi\frac{\delta
\tensor{g}{_\varrho_\sigma}}{\delta \tensor{g}{_\mu_\nu}}\right)\\
&=\frac{1}{2}\int \dif{}^4 x
\sqrt{-g}\left(-\frac{1}{2}\tensor{g}{^\mu^\nu}\tensor{\nabla}{_\varrho}\varphi\tensor{\nabla}{^\varrho}\varphi-\frac{1}{2}\tensor{g}{^\mu^\nu}m^2\varphi^2
+\tensor{\nabla}{^\mu}\varphi\tensor{\nabla}{^\nu}\varphi\right)\delta(x,x')\\
&=\frac{1}{2}\sqrt{-g}\left(-\frac{1}{2}\tensor{g}{^\mu^\nu}\tensor{\nabla}{_\varrho}\varphi\tensor{\nabla}{^\varrho}\varphi-\frac{1}{2}\tensor{g}{^\mu^\nu}m^2\varphi^2
+\tensor{\nabla}{^\mu}\varphi\tensor{\nabla}{^\nu}\varphi\right)
\end{split}
\end{equation}
So that
\begin{equation}
\tensor{T}{^\mu^\nu}(\varphi)
=-\frac{1}{2}\tensor{g}{^\mu^\nu}\tensor{\nabla}{_\varrho}\varphi\tensor{\nabla}{^\varrho}\varphi
+\tensor{\nabla}{^\mu}\varphi\tensor{\nabla}{^\nu}\varphi
-\frac{1}{2}\tensor{g}{^\mu^\nu}m^2\varphi^2
\end{equation}
As we have noticed, the Einstein Tensor is covariantly conserved (contracted
Bianci identities). The Einstein equation then implies that also
$\tensor{T}{^\mu^\nu_{;\nu}}=0$ this can be checked for the given Tensor
\begin{equation}
\begin{split}
\tensor{\nabla}{_\mu}\tensor{T}{^\mu^\nu}
&=\tensor{g}{^\mu^\nu}\tensor{\nabla}{_\mu}\tensor{\nabla}{_\varrho}\varphi\tensor{\nabla}{^\varrho}\varphi+\square\varphi\tensor{\nabla}{^\nu}\varphi+\tensor{\nabla}{^\mu}\varphi\tensor{\nabla}{_\mu}\tensor{\nabla}{^\nu}\varphi
-\tensor{g}{^\mu^\nu}m^2\varphi\tensor{\nabla}{_\mu}\varphi\\
&=\tensor{\nabla}{^\nu}\varphi\left(\square-m^2\right)\varphi\\
&=0
\end{split}
\end{equation}
Where the last equality holds because $\varphi$ satisfies the Klein-Gordon
equation.
\end{example}
The Einstein equations are ten quasi linear, i.e. the highest order
derivative appears only linear, differential equations for the metric field
$\tensor{g}{_\mu_\nu}$. Strictly speaking the Einstein equations are
\emph{nonlinear}.
% \begin{sidenote}
% If you substract the constrains imposed by the Bianci identities you end with
% two DOFs, which are associated with the polarisation states of the graviton.
% \end{sidenote}
How do we find a solution to this equations?
\begin{enumerate}
  \item Prescribe $\tensor{T}{_\mu_\nu}$. This is only possible for high
  symmetry problems, e.g. the \name{Schwazschild} solution and the cosmological
  solutions (\name{Friedmann}'s equations)
  \item Assume $\tensor{g}{_\mu_\nu}$, then compute $\tensor{T}{_\mu_\nu}$ and
  (try!) to interpret this.
\end{enumerate}
%TODO part about Intrinsic vs extrinsic curvature, image??
\subsection{ADM-Decomposition}
\begin{figure}[hbtp]
\centering
 \includegraphics{foliation.pdf}
\caption{Foliation of spacetime into spatial hypersurfaces $\Sigma_t$.}
\end{figure}
The formulation of initial value problems is not as easy as it is in classical
physics.\footnote{In fact, depending on the setting, a well defined formulation
can be impossible.} Assume we know either
\begin{itemize}
  \item $\tensor{g}{_\mu_\nu}$ on $\Sigma_{t_0}$
  \item $\tensor{g}{_\mu_\nu_{;j}}$, $\tensor{g}{_\mu_\nu_{;0}}$ on
  $\Sigma_{t_0}$
\end{itemize}
We then see the spacetime as a
collection of spacelike hypersurfaces
at time $t$ $\Sigma_t=\left\{\tensor{x}{^0}=t\right\}$. For simplicity we
consider a vacuum solution to the Einstein equations, i.e.
\begin{equation}
0=G=R-2R\implies\tensor{R}{_\mu_\nu}=0\,.
\end{equation}
Divided into the respective parts the field equations are
\begin{align}
0&=\tensor{R}{_0_0}=-\frac{1}{2}\tensor{g}{^i^j}\tensor{g}{_i_j_{,00}}+\tensor{M}{_0_0}\,,\\
0&=\tensor{R}{_0_i}=-\frac{1}{2}\tensor{g}{^0^j}\tensor{g}{_i_j_{,00}}+\tensor{M}{_0_i}\,,\\
0&=\tensor{R}{_i_j}=-\frac{1}{2}\tensor{g}{^0^0}\tensor{g}{_i_j_{,00}}+\tensor{M}{_i_j}\,.
\end{align}
Where $\tensor{M}{_\mu_\nu}$ is a rest term containing lower order
time derivatives.
This shows that there are no second order time derivatives of
$\tensor{g}{_0_\mu}$. We have 10 equations and 6 undetermined functions. The
DOFs can be used for a coordinate transformation, so that
$\tensor{g}{_0_\mu_{,00}}=0$ on $\Sigma_{t_0}$. This is always possible but we
will not proof this. It can be further shown, by means of the contracted Bianci
identities, that this implies $\tensor{g}{_0_\mu_{,00}}=0$ on \emph{all}
hypersurfaces $\Sigma_{t}$.
% \begin{equation}
% \tensor{\partial}{_0}\tensor{G}{^0^\nu}=
% \tensor{\partial}{_i}\tensor{G}{^i^\nu}
% -\cSym{\nu}{0}{\lambda}\tensor{G}{^\lambda^\nu}
% -\cSym{0}{\nu}{\lambda}\tensor{G}{^\mu^\lambda}\,.
% \end{equation}
Since we have to much freedom the solution will not be unique. We have the
freedom to choose four coordinates
\begin{equation}
\tensor{x}{^{\mu^\prime}}=\tensor{f}{^{\mu^\prime}}\left(\tensor{x}{^\mu}\right)\,.
\end{equation}
One typical choice is the \emph{harmonic\footnote{A function $f$ is said to be
harmonic if it satisfies $\square f = 0$.} gauge}
\begin{equation}
\square\tensor{x}{^\mu}=0\,.
\end{equation}
We can expand the d'Alembertian, using \eqref{eq:quabla}, to
\begin{equation}
\begin{split}
\square\tensor{x}{^\mu}&=g^{-\nicefrac{1}{2}}\tensor{\partial}{_\varrho}\left(g^{\nicefrac{1}{2}}\tensor{g}{^\varrho^\sigma}\tensor{\partial}{_\sigma}\tensor{x}{^\mu}\right)\\
&=g^{-\nicefrac{1}{2}}\tensor{\partial}{_\varrho}\left(g^{\nicefrac{1}{2}}\tensor{g}{^\varrho^\sigma}\tensor{\delta}{_\sigma^\mu}\right)\\
&=g^{-\nicefrac{1}{2}}\tensor{\partial}{_\varrho}\left(g^{\nicefrac{1}{2}}\tensor{g}{^\varrho^\mu}\right)\,,\\
\end{split}
\end{equation}
the harmonic gauge is therefore equivalent to
\begin{equation}
\tensor{\partial}{_\varrho}\left(g^{\nicefrac{1}{2}}\tensor{g}{^\varrho^\mu}\right)=0\,
.\\
\end{equation}
The equation can be divided into spatial and time components and derive by the
zero component, so that
\begin{equation}
\tensor*{\partial}{*_0^2}\left(g^{\nicefrac{1}{2}}\tensor{g}{^0^\mu}\right)
=
-\tensor{\partial}{_i}\left[\tensor{\partial}{_0}\left(g^{\nicefrac{1}{2}}\tensor{g}{^0^\mu}\right)\right]\,
,\end{equation}
which fixes the second order time derivatives of the relevant components
$\tensor{g}{^0^\mu}$. Therefore now the time evolution can be solved.
%TODO Missing part?
\subsubsection{Degrees of freedom}
\begin{itemize}
  \item[\textsf{\textbf{10}}]
  componnents for every spacetime point from the symmetric $\tensor{g}{_\mu_\nu}$
  \item[\textsf{\textbf{-4}}] from the
  constraint equation $\tensor{G}{_\mu_\nu^{;\nu}}=0$
  \begin{itemize}
    \item
    $\tensor{G}{^0^0}=\kappa \tensor{T}{^0^0}$ ensures that the
    evolution is independent of the choice of spatial coordinates on
    $\Sigma_{t_0}$.
    \item
    $\tensor{G}{^i^0}=\kappa \tensor{T}{^i^0}$ ensures that the time
    evolution is independent of the way we foliated spacetime into spacial
    hypersurfaces $\Sigma_{t}.    $
  \end{itemize}
  \item[\textsf{\textbf{-4}}] due to the freedom
  to choose coordinates (i.e. a gauge).
\end{itemize}
We are left with two physical degrees of freedom which may be interpreted as the
polarisation states of the graviton field.
\subsubsection{Comparison with electrodynamics in flat spacetime}
In electrodynamics instead of \name{Einstein}'s equations we have the field
equations for the four potential $\tensor{A}{_\mu}$:
\begin{equation}
\square\tensor{A}{_\mu}-\partial_\mu\left(\partial_\nu\tensor{A}{^\nu}
\right)=0\,.
\end{equation}
As we did for the gravitational field, we take a look
at the zero component. We find
\begin{equation}
\begin{split}
0&=-\partial_0^2\tensor{A}{_0}+\partial_i\partial^i\tensor{A}{_0}
-\partial_0\left(-\partial_0\tensor{A}{_0}+\partial_iA^i\right)\\
&= \partial_i\partial^i\tensor{A}{_0}-\partial_0\partial_iA^i
\end{split}
\end{equation}
This equation is equivalent to $\nabla\vec{E}=0$ and the Bianchi identities.
So once again $\tensor{A}{_0}$ is \emph{not} determined by the dynamical
evolution equation because there is no second order time derivative analogous to
$\tensor{g}{_0_0}$. Since $\tensor{A}{_0}$ is not determined and cannot be
specified on the initial time slice. This reflects some internal redundancy
namely gauge invariance of the theory. For any scalar function $\Lambda$, the
transformation
\begin{equation}
\tensor{A}{_\mu}\to\tensor*{A}{*_\mu^\prime}=
\tensor{A}{_\mu}+\partial_\mu\Lambda\,,
\end{equation}
leaves the physics invariant. It is trivial to check that
the field strength tensor \\
${\tensor{F}{_\mu_\nu}=\partial_\mu\tensor{A}{_\nu}-\partial_\nu\tensor{A}{_\mu}}$ stays invariant. Perhaps more
interesting the field equation is also gauge invariant:
\begin{equation}
\begin{split}
\square\tensor*{A}{*_\mu^\prime}-\partial_\mu\left(\partial_\nu\tensor*{A}{*^\nu^\prime}
\right)
&=
\square\tensor{A}{_\mu}+\square\partial_\mu\Lambda-\partial_\mu\left(\partial_\nu\tensor{A}{^\nu}
\right)-\partial_\mu\square\Lambda\\
&=
\square\tensor{A}{_\mu}-\partial_\mu\left(\partial_\nu\tensor{A}{^\nu}
\right)\,.
\end{split}
\end{equation}
Thus if $\tensor{A}{_\mu}$ is a solution to the field
equation $\tensor*{A}{*_\mu^\prime}$ is and therefore both are physically
indistinguishable. We can also fix a gauge for example the \emph{Lorentz gauge}:
\begin{equation}
\partial_\mu\tensor{A}{^\mu}=0\, .
\end{equation}
If we derive this by the zero component we get
\begin{equation}
\partial_{0}^2\tensor{A}{^0}=-\partial_i\partial_0\tensor{A}{^i}\, ,
\end{equation}
so as with $\tensor{g}{_0_0}$ the evolution of the zero component is now related
to the other components. There is still one residual gauge condition, namely we can
still transform
\begin{equation}
\tensor{A}{_\mu}\to\tensor*{A}{*_\mu^\prime}=
\tensor{A}{_\mu}+\partial_\mu\Lambda\, ,
\end{equation}
but to keep the gauge, we have to demand that $\square\Lambda=0$.
Again we count the DOFs:
\begin{itemize}
  \item[\textsf{\textbf{4}}] components of the potential
  $\tensor{A}{_\mu}$.
  \item[\textsf{\textbf{-1}}] from constraint
  $\nabla\vec{E}=0$.
  \item[\textsf{\textbf{-1}}] from gauge freedom
  $\Lambda$.
\end{itemize}
This leaves two physical degrees of freedom, the polarisation states of a
photon.

\begin{remark}
As we have have seen there is a direct correspondence between the gauge freedom
in electrodynamics and the freedom of choice of coordinates of coordinates in
GR.
\end{remark}


\subsection{Creating statistics}

We take a sample from the distribution.

\(x=(x_1, x_2,...,x_n)\)

A statistic is a function on this sample.

\(S=S(x_1, x_2,...,x_n)\).


\section{Complex analysis}\label{sec:complex_analysis}

Complex analysis an extension of \fullref{sec:real_analysis}, which is concerned with studying functions with values in \hyperref[def:vector_space_dimension]{finite-dimensional} \hyperref[def:set_of_complex_numbers]{complex} \hyperref[def:hilbert_space]{Hilbert spaces} \( \BbbC^n \) rather than Euclidean spaces \( \BbbR^n \). A lot of results are different, however much of \fullref{sec:real_analysis} is delegated here because it holds in greater generality. For these general results, through the section, \( \BbbK \) will refer to either \( \BbbR \) or \( \BbbC \).

Despite complex analysis being a very rich field, we are mostly concerned with special functions, to which we dedicate the following sections:
\begin{itemize}
  \item \Fullref{subsec:power_series}
  \item \Fullref{subsec:trigonometric_functions}
  \item \Fullref{subsec:exponential_function}
  \item \Fullref{subsec:trigonometric_polynomials}
  \item \Fullref{subsec:special_functions}
\end{itemize}


\documentclass[a4paper]{article}

\usepackage{hyperref}

% Set up page size
\usepackage[margin=1.5cm, includefoot, footskip=30pt]{geometry}

% Nice way to display code
\usepackage{minted}

% Import images
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{multicol}

\usepackage{tikz}
\usetikzlibrary{calc}

\title{Modelling the effect of vaccinations using differential equations}
\author{Vince Knight}
\date{}

\begin{document}
\maketitle

\section{Introduction}\label{sec:introduction}

The World Health Organisation estimates that the measles vaccination has saved
more than 17 million lives since 2000~\cite{who}.  It is possible to model the
effect of vaccination using differential equations. The model considered here is
called an SIR model which is a compartementalised model of infection where
individuals can be in one of 3 states:

\begin{itemize}
    \item Susceptible (S): members of the population who may become infected;
    \item Infected (I): infected members of the population who will eventually
        recover;
    \item Recovered (R): recovered members of the population, not that
        mathematically death is here equivalent to recovery.
\end{itemize}

Figure~\ref{fig:sir_model} shows this diagrammatically.

\begin{figure}[!hbtp]
    \begin{center}
        \begin{tikzpicture}
            \node [draw, fill=blue!20] (S) at (0, 0) {S};
            \node [draw, fill=red!20] (I) at ($(S) + (2, 0)$) {I};
            \node [draw, fill=green!20] (R) at ($(I) + (2, 0)$) {R};

            \draw [->] (S) edge [out=45, in=135] node [above] {\(\alpha\)} (I);
            \draw [->] (I) edge [out=45, in=135] node [above] {\(\beta\)} (R);
            \draw [->] (S) edge [out=-45, in=-135] node [above] {\(\mu\)} (R);
        \end{tikzpicture}
    \end{center}
    \caption{The SIR model}
    \label{fig:sir_model}
\end{figure}

The parameters of the model shown in Figure~\ref{fig:sir_model} are:

\begin{itemize}
    \item \(\alpha\) the infection rate;
    \item \(\beta\) the recovery rate;
    \item \(\mu\) the vaccination percentage;
\end{itemize}

This can be expressed mathematically:

\begin{align}
    \frac{dS}{dt} &= - \alpha I S - \mu S\\
    \frac{dI}{dt} &=  \alpha I S - \beta I\\
    \frac{dR}{dt} &=  \mu S + \beta I
\end{align}

In the next section we will use Sympy to attempt to solve these equations
analytically:

\section{(Not) finding an exact solution}

It is possible to use Sympy to solve systems of differential equations, however
when attempting to do this here it appears to fail:

\begin{minted}{python}
>>> import sympy as sym
>>> S, I, R = sym.Function("S"), sym.Function("I"), sym.Function("V")
>>> N, mu, alpha, beta, t = sym.symbols("N, mu, alpha, beta, t")
>>> eq1 = sym.Derivative(S(t), t) - (- alpha * S(t) * I(t) - mu * R(t))
>>> eq2 = sym.Derivative(I(t), t) - (alpha * I(t) * S(t) / N  - beta * I(t))
>>> eq3 = sym.Derivative(R(t), t) - (beta * I(t) + mu * R(t))
>>> sym.dsolve((eq1, eq2, eq3))
NotImplementedError                       Traceback (most recent call last)
...
\end{minted}

I believe that this is due to the complexity of the differential equations that
Sympy is unable to handle analytically. An exact solution of the model without
vaccination is obtained in~\cite{harko2014exact}.
In the next section we will however solve these equations numerically.

\section{Solving the equations numerically and the effect of vaccination rates}

We can use a numerical integration technique to solve these equations
numerically. The technical publication describing the specific algorithm used is
described in~\cite{radhakrishnan1993description}.

First we create a function that gives expressions for the
derivatives at any given point in time:

\begin{minted}{python}
>>> def dx(x, t, alpha, beta, mu):
...     return (- alpha * x[1] * x[0] - mu * x[0],
...             alpha * x[1] * x[0]  - beta * x[1],
...             beta * x[1] + mu * x[0])
\end{minted}

We can then plot a number of different scenarios as shown in
Figure~\ref{fig:scenarios}. Here is the code that corresponds to the first plot:

\begin{minted}{python}
>>> alpha = 1 / 1000  # Every 1000 interactions leads to infection
>>> beta = 1 / 5  # take 5 time units to recover
>>> N = 10 ** 4  # Population of 10 thousand people
>>> mu = 0  # 0 vaccination rate
>>> ts = np.linspace(0, 10, 5000)
>>> xs = integrate.odeint(func=dx, y0=np.array([N - 1, 1, 0]), t=ts, args=(alpha, beta, mu))
>>> S, I, R = xs.T
>>> plt.figure()
>>> plt.plot(ts, S, label="Susceptibles")
>>> plt.plot(ts, I, label="Infected")
>>> plt.plot(ts, R, label="Recovered")
>>> plt.legend()
>>> plt.title(f"$\max(I)={round(max(I))}$ ($\\alpha={alpha}$, $\\beta={beta}$,
$\mu={mu}$)");
\end{minted}

\begin{figure}[!hbtp]
    \begin{center}
        \includegraphics[width=.3\textwidth]{base_scenario.pdf}
        ~
        \includegraphics[width=.3\textwidth]{moderate_vaccination_rate.pdf}
        ~
        \includegraphics[width=.3\textwidth]{high_vaccination_rate.pdf}
        \caption{The evolution of the population for different vaccination rates}
        \label{fig:scenarios}
    \end{center}
\end{figure}

It is also possible to compute the maximum percentage of infection as a function
of the vaccination rate:

\begin{minted}{python}
>>> vaccination_rates = np.linspace(0, 1, 500)
>>> max_percent_of_infected = []
>>> for mu in vaccination_rates:
...     xs = integrate.odeint(func=dx, y0=np.array([N - 1, 1, 0]), t=ts, args=(alpha, beta, mu))
>>> S, I, R = xs.T
>>> max_percent_of_infected.append(max(I) / N)
>>> plt.figure()
>>> plt.plot(vaccination_rates, max_percent_of_infected)
>>> plt.xlabel("Vaccination rate")
>>> plt.ylabel("% of population infected");
\end{minted}

This is shown in Figure~\ref{fig:effect_of_vaccination_rate}.

\begin{figure}[!hbtp]
    \begin{center}
        \includegraphics[width=.6\textwidth]{effect_of_vaccination_rate.pdf}
        \caption{The effect of vaccination rate on maximum infection percentage}
        \label{fig:effect_of_vaccination_rate}
    \end{center}
\end{figure}

\section{Conclusion}

We see in our model that a large vaccination rate is required to ensure a high
level of immunity (ie a low maximum level of total infection). This type of
approach uses differential equations to model the interactions of individuals
and the spread of disease, finally we solve these equations using techniques
from numerical analysis.

\bibliographystyle{plain}
\bibliography{bibliography.bib}

\end{document}


% !TEX program = pdflatex

\documentclass[11pt]{article}
\usepackage{amsmath,amsfonts,amsthm,amssymb,geometry,dsfont}
\usepackage[usenames,dvipsnames,svgnamesable]{xcolor}
\usepackage[capitalise,noabbrev]{cleveref} %
\usepackage[round]{natbib}
\usepackage{natbib}
\crefname{equation}{}{} %
\crefname{assumption}{Assumption}{Assumptions}
\crefname{property}{Property}{Properties}
\geometry{left=1in,right=1in,top=0.6in,bottom=1in}

\newcommand{\D}[1][]{\ensuremath{\boldsymbol{\partial}_{#1}}}
\newcommand{\R}{\ensuremath{\mathbb{R}}}
\newcommand{\diff}{\ensuremath{\mathrm{d}}}
\newcommand{\set}[1]{\ensuremath{\left\{{#1}\right\}}}
\newcommand{\indicator}[1]{\ensuremath{\mathds{1}\left\{{#1}\right\}}}
\newcommand{\condexpec}[3][]{\ensuremath{\mathbb{E}_{#1}\left[{#2} \; \middle| \; {#3} \right]}}
\newcommand{\expec}[2][]{\ensuremath{\mathbb{E}_{{#1}}\left[ {#2} \right]}}
\geometry{left=1in,right=1in,top=0.6in,bottom=1in}
\newenvironment{psmallmatrix}
{\left(\begin{smallmatrix}}
	{\end{smallmatrix}\right)}

\begin{document}
\title{Derivation on discretized differential operators on (ir)regular grids with reflecting barrier conditions}
\author{@chiyahn}
\maketitle

\section{Setup}

\begin{itemize}
	\item Define an irregular grid $\set{z_i}_{i=1}^P$ with $z_1 = \underline{z}$ and $z_P = \bar{z}$. Denote the grid with the variable name, i.e. $z \equiv \set{z_i}_{i=1}^P$.
	\item Denote the distance between the grid points as the \textit{backwards} difference
	\begin{align}
	\Delta_{i,-} &\equiv z_i - z_{i-1},\, \text{for } i = 2,\ldots, P\\
	\Delta_{i,+} &\equiv z_{i+1} - z_i,\, \text{for } i = 1,\ldots, P-1
	\end{align}

	\item Assume $\Delta_{1, -} = \Delta_{1, +}$ and $\Delta_{P, +} = \Delta_{P, -}$, due to ghost points, $z_0$ and $z_{P+1}$ on both boundaries. (i.e.he distance to the ghost nodes are the same as the distance to the closest nodes).  Then define the vector of backwards and forwards first differences as
	\begin{align}
	\Delta_{-} &\equiv \begin{bmatrix} z_2 - z_1 \\
	\text{diff}(z)
	\end{bmatrix}\\
	\Delta_{+} &\equiv \begin{bmatrix} \text{diff}(z)\\
	z_P - z_{P-1}
	\end{bmatrix}
	\end{align}
	\item Reflecting barrier conditions:
	\begin{align}
	\xi v(\underline{z}) + \D[z]v(\underline{z} ) &= 0\label{eq:new-BC1}\\
	\xi v(\bar{z}) + \D[z]v(\bar{z}) &= 0\label{eq:new-BC2}
	\end{align}
\end{itemize}

Let $L_1^{-}$ be the discretized backwards first differences and $L_2$ be the discretized central differences subject to the Neumann boundary conditions in \cref{eq:new-BC1,eq:new-BC2} such that $L_1^{-} v(z)$ and $L_2 v(z)$ represent the first and second derivatives of $v(z)$ respectively at $z$. For second derivatives, we use the following numerical scheme from \cite{achdou17}:

\begin{equation}
v''(z_i) \approx \dfrac{ \Delta_{i,-} v( z_i + \Delta_{i,+}) - (\Delta_{i,+} + \Delta_{i,-}) v( z_i ) + \Delta_{i,+} v( z_i - \Delta_{i,-})}{\frac{1}{2}(\Delta_{i,+} + \Delta_{i,-}) \Delta_{i,+} \Delta_{i,-} }, \text{for } i = 1, \ldots, P
\end{equation}

\subsection{Regular grids}
Suppose that the grids are regular, i.e., elements of $\text{diff}(z)$ are all identical with $\Delta$ for some $\Delta > 0$.

Using the backwards first-order difference, \eqref{eq:new-BC1} implies
\begin{align}
\dfrac{v(\underline{z}) - v(\underline{z}-\Delta)}{\Delta} &= - \xi v(\underline{z})
\end{align}
at the lower bound.

Likewise, \eqref{eq:new-BC2} under the forwards first-order difference yields
\begin{align}
\dfrac{v(\overline{z} + \Delta) - v(\overline{z})}{\Delta} &= - \xi v(\overline{z})
\end{align}
at the upper bound.

The discretized central difference of second order under \eqref{eq:new-BC1} at the lower bound is
\begin{align}
\dfrac{v (\underline{z} + \Delta) - 2 v(\underline{z}) + v(\underline{z}-\Delta)}{\Delta^2} &=   \dfrac{v(\underline{z} + \Delta) - v(\underline{z})}{\Delta^2} - \dfrac{1}{\Delta}\dfrac{v (\underline{z}) - v(\underline{z}-\Delta) }{\Delta}  \\
&= \dfrac{v(\underline{z} + \Delta) - v(\underline{z})}{\Delta^2} + \dfrac{1}{\Delta} \xi v(\underline{z})  \\
&= \dfrac{1}{\Delta^2}  (- 1 + \Delta \xi) v(\underline{z})  + \dfrac{1}{\Delta^2}  v(\underline{z} + \Delta)
\end{align}
Similarly, by \eqref{eq:new-BC2}, we have
\begin{align}
\dfrac{v (\bar{z} + \Delta) - 2 v(\bar{z} ) + v(\bar{z} -\Delta)}{\Delta^2} &=   \dfrac{v(\bar{z} - \Delta) - v(\bar{z})}{\Delta^2} + \dfrac{1}{\Delta}\dfrac{ v(\bar{z}+\Delta) - v (\bar{z}) }{\Delta}  \\
&= \dfrac{v(\bar{z} - \Delta) - v(\bar{z})}{\Delta^2}  - \dfrac{1}{\Delta} \xi v(\bar{z})  \\
&= \dfrac{1}{\Delta^2}  (- 1 - \Delta \xi) v(\bar{z})  + \dfrac{1}{\Delta^2}  v(\bar{z} - \Delta)
\end{align}
at the upper bound.

Thus, the corresponding discretized differential operator $L_1^{-}$, $L_1^{+}$, and $L_2$ are defined as

\begin{align}
L_1^{-} &\equiv \frac{1}{\Delta}\begin{pmatrix}
1 - (1 + \xi \Delta) &0&0&\dots&0&0&0\\
-1&1&0&\dots&0&0&0\\
\vdots&\vdots&\vdots&\ddots&\vdots&\vdots&\vdots\\
0&0&0&\dots&-1&1&0\\
0&0&0&\cdots&0&-1&1
\end{pmatrix}_{P\times P}\label{eq:L-1-regular} \\
L_1^{+} &\equiv \frac{1}{\Delta}\begin{pmatrix}
-1&1&0&\dots&0&0&0\\
0&-1&1&\dots&0&0&0\\
\vdots&\vdots&\vdots&\ddots&\vdots&\vdots&\vdots\\
0&0&0&\dots&0&-1&1\\
0&0&0&\cdots&0&0&-1+(1-\xi \Delta)
\end{pmatrix}_{P\times P}\label{eq:L-1-plus-regular} \\
L_2 &\equiv \frac{1}{\Delta^2}\begin{pmatrix}
-2 + (1 + \xi\Delta) &1&0&\dots&0&0&0\\
1&-2&1&\dots&0&0&0\\
\vdots&\vdots&\vdots&\ddots&\vdots&\vdots&\vdots\\
0&0&0&\dots&1&-2&1\\
0&0&0&\cdots&0&1&-2 + (1- \xi\Delta)
\end{pmatrix}_{P\times P}\label{eq:L-2-regular}
\end{align}

\subsection{Irregular grids}
Using the backwards first-order difference, \eqref{eq:new-BC1} implies
\begin{align}
\dfrac{v(\underline{z}) - v(\underline{z}-\Delta_{1, -})}{\Delta_{1, -}} &= - \xi v(\underline{z})
\end{align}

at the lower bound. Likewise, the forwards first-order difference under \eqref{eq:new-BC2} yields
\begin{align}
\dfrac{v(\overline{z} + \Delta_{P, +}) - v( \overline{z})}{\Delta_{P, +}} &= - \xi v(\overline{z})
\end{align}
at the upper bound.

Note that we have assumed that $\Delta_{1,-} = \Delta_{1,+}$ and $\Delta_{P,+} = \Delta_{P,-}$ for the ghost notes. The discretized central difference of second order scheme at the lower bound under \eqref{eq:new-BC1} is
\begin{align}
&\dfrac{\Delta_{1,-} v( \underline{z} + \Delta_{1,+}) - (\Delta_{1,+} + \Delta_{1,-}) v(\underline{z}) + \Delta_{1,+}  v( \underline{z} - \Delta_{1,-})}{\frac{1}{2}(\Delta_{1,+} + \Delta_{1,-}) \Delta_{1,+} \Delta_{1,-} } \\
&=
\dfrac{v (\Delta_{1, +}) - 2 v(\underline{z}) + v(-\Delta_{1, +})}{\Delta_{1, +}^2} \\
&= \dfrac{v(\underline{z} + \Delta_{1, +}) - v(\underline{z})}{\Delta_{1, +}^2} - \dfrac{1}{\Delta_{1, +}}\dfrac{v(\underline{z}) - v(\underline{z}-\Delta_{1, +}) }{\Delta_{1, +}}  \\
&= \dfrac{v(\underline{z} + \Delta_{1, +}) - v(\underline{z})}{\Delta_{1, +}^2} + \dfrac{1}{\Delta_{i,+}} \xi v(\underline{z})  \\
&= \dfrac{1}{\Delta_{1, +}^2}  (- 1 + \Delta_{1, +} \xi) v(\underline{z})  + \dfrac{1}{\Delta_{1, +}^2}  v(\underline{z} + \Delta_{1, +})
\end{align}
Similarly, by \eqref{eq:new-BC2}, we have
\begin{align}
&\dfrac{\Delta_{P,-} v( \bar{z} + \Delta_{P,+}) - (\Delta_{P,+} + \Delta_{P,-}) v(\bar{z} ) + \Delta_{P,+}  v( \bar{z} - \Delta_{P,-})}{\frac{1}{2}(\Delta_{P,+} + \Delta_{P,-}) \Delta_{P,+} \Delta_{P,-} } \\
&=\dfrac{v (\bar{z} + \Delta_{P,-}) - 2 v(\bar{z} ) + v(\bar{z} -\Delta_{P,-})}{\Delta_{P,-}^2} \\
&=   \dfrac{v(\bar{z} - \Delta_{P,-}) - v(\bar{z})}{\Delta_{P,-}^2} + \dfrac{1}{\Delta_{P,-}}\dfrac{ v(\bar{z}+\Delta_{P,-}) - v (\bar{z}) }{\Delta_{P,-}}  \\
&= \dfrac{v(\bar{z} - \Delta_{P,-}) - v(\bar{z})}{\Delta_{P,-}^2}  - \dfrac{1}{\Delta_{P,-}} \xi v(\bar{z})  \\
&= \dfrac{1}{\Delta_{P,-}^2}  (- 1 - \Delta_{P,-} \xi) v(\bar{z})  + \dfrac{1}{\Delta_{P,-}^2}  v(\bar{z} - \Delta_{P,-})
\end{align}
at the upper bound.

Thus, the corresponding discretized differential operator $L_1^{-}$, $L_1^{+}$, and $L_2$ are defined as

\begin{align}
L_1^{-} &\equiv \begin{pmatrix}
\Delta^{-1}_{1,-} [1 - (1 + \xi \Delta_{1,-})] &0&0&\dots&0&0&0\\
-\Delta_{2,-}^{-1}&\Delta_{2,-}^{-1}&0&\dots&0&0&0\\
\vdots&\vdots&\vdots&\ddots&\vdots&\vdots&\vdots\\
0&0&0&\dots&-\Delta_{P-1,-}^{-1}&\Delta_{P-1,-}^{-1}&0\\
0&0&0&\cdots&0&-\Delta_{P,-}^{-1}&\Delta_{P,-}^{-1}
\end{pmatrix}_{P\times P}\label{eq:L-1} \\
L_1^{-} &\equiv \begin{pmatrix}
-\Delta_{1,+}^{-1}&\Delta_{1,+}^{-1}&0&\dots&0&0&0\\
0&-\Delta_{2,+}^{-1}&\Delta_{2,+}^{-1}&\dots&0&0&0\\
\vdots&\vdots&\vdots&\ddots&\vdots&\vdots&\vdots\\
0&0&0&\cdots&0&-\Delta_{P-1,+}^{-1}&\Delta_{P-1,+}^{-1}\\
0&0&0&\dots&0&0&\Delta_{P,+}^{-1}  [-1 + (1 - \xi \Delta_{P,+})]  \\
\end{pmatrix}_{P\times P}\label{eq:L-1-plus} \\
L_2 &\equiv \begin{psmallmatrix}
\Delta_{1,+}^{-2}[-2 + (1+\xi \Delta_{1,+})] &\Delta_{1,+}^{-2}&0&\cdots&0&0&0 \\
\vdots&\ddots&\ddots&\ddots&\ddots&\vdots&\vdots\\
0&\cdots&2(\Delta_{i,+}+\Delta_{i,-})^{-1} \Delta_{i,-}^{-1} &-2\Delta_{i,-}^{-1} \Delta_{i,+}^{-1}  & 2 (\Delta_{i,+}+\Delta_{i,-})^{-1} \Delta_{i,+}^{-1}&\cdots&0 \\
\vdots&\vdots&\vdots&\ddots&\ddots&\ddots&\vdots\\
0&0&0&\cdots&0&\Delta_{P,-}^{-2}&\Delta_{P,-}^{-2} [-2 + (1- \xi\Delta_{P,-})]
\end{psmallmatrix}_{P\times P}\label{eq:L-2}
\end{align}

\subsection{Differential operators by basis}
Define the following basis matrices:

\begin{align}
U_1^{-} &\equiv \begin{pmatrix}
1  &0&0&\dots&0&0&0\\
-1&1&0&\dots&0&0&0\\
\vdots&\vdots&\vdots&\ddots&\vdots&\vdots&\vdots\\
0&0&0&\dots&-1&1&0\\
0&0&0&\cdots&0&-1&1
\end{pmatrix}_{P\times P}\label{eq:L-1-basis} \\
U_1^{+} &\equiv \begin{pmatrix}
-1  &1&0&\dots&0&0&0\\
0&-1&1&\dots&0&0&0\\
\vdots&\vdots&\vdots&\ddots&\vdots&\vdots&\vdots\\
0&0&0&\dots&0&-1&1\\
0&0&0&\cdots&0&0&-1
\end{pmatrix}_{P\times P}\label{eq:L-1+-basis} \\
\end{align}

and the boundary conditions for the reflecting conditions:

\begin{align}
B_{1}  &\equiv \begin{pmatrix}
(1 + \xi \Delta^{-1}_{1,-}) &0&\dots&0&0\\
0&0&\dots&0&0\\
\vdots&\vdots&\ddots&\vdots&\vdots\\
0&0&\cdots&0&0\\
0&0&\cdots&0&0
\end{pmatrix}_{P\times P} \\
B_{P}  &\equiv \begin{pmatrix}
0 &0&\dots&0&0\\
0&0&\dots&0&0\\
\vdots&\vdots&\ddots&\vdots&\vdots\\
0&0&\cdots&0&0\\
0&0&\cdots&0&(1 - \xi \Delta^{-1}_{P,+})
\end{pmatrix}_{P\times P}
\end{align}

\subsubsection{Regular grids}
For regular grids with the uniform distance of $\Delta > 0$, \eqref{eq:L-1-regular} and \eqref{eq:L-2-regular} can be represented by

\begin{align}
L_1^{-} &= \dfrac{1}{\Delta} U_1^{-} - B_1 \\
L_1^{+} &= \dfrac{1}{\Delta} U_1^{+} + B_P \\
L_2 &= \dfrac{1}{\Delta^2} (U_1^+ - U_1^-) + B_1 + B_P
\end{align}

\subsubsection{Irregular grids}
For notational brevity, for vectors with the same size, $x_1, x_2$, define $x_1 x_2$ as the elementwise-multiplied vector. Then, we have
\begin{align}
L_1^{-} &= \text{diag}(\Delta_{-} )^{-1} U_1^{-} - B_1 \\
L_1^{+} &= \text{diag}(\Delta_{+} )^{-1} U_1^{+} + B_P \\
L_2 &= \text{diag} \left[ \frac{1}{2} ( \Delta_+ + \Delta_- ) \Delta_+ \right]^{-1}  U_1^{+} -
 \text{diag} \left[ \frac{1}{2} ( \Delta_+ + \Delta_- ) \Delta_- \right]^{-1}  U_1^{-}
+ B_1 + B_P
\end{align}
We can simplify this expression further by introducing a new notation. Let $x^{-1}$ be defined as the elementwise inverse of a vector $x$ that contains no zero element. Then, $L_2$ can be represented as
\begin{align}
L_2 &=
2\left[ \text{diag} \left( ( \Delta_+ + \Delta_- )^{-1} \Delta_+^{-1} \right) U_1^{+} -
\text{diag} \left( ( \Delta_+ + \Delta_- )^{-1} \Delta_-^{-1} \right) U_1^{-}  \right]
+ B_1 + B_P \\ \label{eq:L-2-by-basis}
&= 2 \text{diag} \left( ( \Delta_+ + \Delta_- )^{-1} \right) \left[ \text{diag} \left(  \Delta_+^{-1} \right) U_1^{+} -
\text{diag} \left(  \Delta_-^{-1} \right) U_1^{-}  \right]
+ B_1 + B_P
\end{align}

The diagonal elements of \eqref{eq:L-2-by-basis} are also identical with the one provided in \eqref{eq:L-2} -- to see this, note that the diagonal elements of \eqref{eq:L-2-by-basis}, modulo $B_1$ and $B_P$, are
\begin{align}
-2 \left[ (\Delta_+ + \Delta_-)^{-1} \Delta_+^{-1} + (\Delta_+ + \Delta_-)^{-1} \Delta_-^{-1} \right] &= -2 (\Delta_+ + \Delta_-)^{-1}  ( \Delta_+^{-1} + \Delta_-^{-1} ) \\
&= -2(\Delta_+ + \Delta_-)^{-1} (\Delta_+^{-1} \Delta_-^{-1}) (\Delta_+ + \Delta_- )  \\
&= -2 (\Delta_+^{-1} \Delta_-^{-1})
\end{align}
which is identical with $\text{diag} (L_2)$ with $L_2$ from \eqref{eq:L-2} except the first row and last row that are affected by $B_1$ and $B_P$.

\bibliographystyle{mnras}
\bibliography{hact}
\end{document}


\section{Metric Spaces: Examples and Definitions}

A \emph{metric space} is a set equipped with a notion of distance between points. Such
spaces arise in many contexts. We begin by considering a few examples.

\vspace{0.2in}
\noindent Examples:

\begin{enumerate}
\item
\item
\end{enumerate}

\begin{defn}

Let X be a non-empty set and $x, y \in X$ . Let $d: X\times X \rightarrow \mathbb{R}$
such that it satisfies

\begin{enumerate}
    \item Positivity:
    \begin{enumerate}
        \item $d(x,y) \geq 0$
        \item $d(x,x) = 0$
        \item $d(x,y) = 0 \ \Rightarrow\ x = y$
    \end{enumerate}
    \item Symmetry:  $d(x,y) = d(y, x)$
    \item Triangle Inequality: $d(x,y)+d(y,z) \geq d(x,z)$

\end{enumerate}

\noindent Then $X$ is called a metric space with the metric $d$.

\end{defn}

\vspace{0.1in}

\noindent Some more examples:

\begin{enumerate}
\item
\item
\item
\item
\end{enumerate}

\begin{rmk}
    We would often like to allow $d(x,y)=\infty$ so $d:X\times X \Rightarrow [0, \infty]$
\end{rmk}

\vspace{0.1in}

\begin{exr}
Let $d_{n} : X\times X \rightarrow \mathbb{R}$ is a metric on X, $\forall n \in \mathbb{N}$.
Prove that $d(x, y) = \operatorname*{inf}\limits_{n \in \mathbb{N}}\{d_{n}(x,y)\}$ satisfies
all conditions except 1(c).
\end{exr}

\begin{exr}
Let $d : X\times X \rightarrow \mathbb{R}$ satisfies all properties of a metric
expect 1(c) in Definition 1.1.

\begin{enumerate}
\item Show that the relation  $$x \sim y \xLeftrightarrow[]{Defn} d(x,y) = 0$$
  is an equivalence realtion on X.

\item Show that there is a well defined function
  $\bar{d} : \bigslant{X}{\sim} \times \bigslant{X}{\sim} \rightarrow \mathbb{R} $
  given by $$ \bar{d}([x], [y]) = d(x, y) $$
  where $[x]$ is an equivalence class of $X$ under $\sim$.

\item Show that $\bar{d}$ is a metric on $\bigslant{X}{\sim}$.
\end{enumerate}
\end{exr}


\subsection{Sketch Proofs}
\begin{proof}[Proof of Divergence Theorem in Convex Domains]
    Consider $\underline{F}=F_z\underline{e_z}$ and a volume $V$ with $\partial V=S_+\cup S_-$ divided by a surface such that both $S_+,S_-$ project to the same surface $A$ on the $x-y$ plane (which is possible since the domain is convex).
    We describe the surfaces as
    $$S_{\pm}=\{\underline{x}=\underline{x}(x,y)=\begin{pmatrix}
        x\\
        y\\
        g_{\pm}(x,y)
    \end{pmatrix}:(x,y)\in A\}$$
    Therefore
    \begin{align*}
        \int_V\frac{\partial F_z}{\partial z}\,\mathrm dV&=\iint_A\left( \int_{g_-(x,y)}^{g_+(x,y)} \frac{\partial F_z}{\partial z}\,\mathrm dz\right)\,\mathrm dx\,\mathrm dy\\
        &=\iint_A(F_z(x,y,g_+(x,y))-F_z(x,y,g_-(x,y)))\,\mathrm dx\,\mathrm dy
    \end{align*}
    Now note that
    $$\mathrm d\underline{S}=\frac{\partial\underline{x}}{\partial x}\times\frac{\partial\underline{x}}{\partial y}\,\mathrm dx\,\mathrm dy=\begin{pmatrix}
        -\partial g_\pm/\partial x\\
        -\partial g_\pm/\partial y\\
        1
    \end{pmatrix}\,\mathrm dx\,\mathrm dy$$
    Now we need the normal to point out of $V$, hence on $S_\pm$.
    $$\mathrm d\underline{S}=\pm\begin{pmatrix}
        -\partial g_\pm/\partial x\\
        -\partial g_\pm/\partial y\\
        1
    \end{pmatrix}\,\mathrm dx\,\mathrm dy$$
    So
    $$\int_{\partial V}F_z\underline{e_z}\cdot\mathrm d\underline{S}=\iint_A(F_z(x,y,g_+(x,y))-F_z(x,y,g_-(x,y)))\,\mathrm dx\,\mathrm dy=\int_V\frac{\partial F_z}{\partial z}\,\mathrm dV$$
    Now we can do the same thing on $F_y\underline{e_y}$ and $F_x\underline{e_x}$, so adding them up gives the theorem by linearity.
\end{proof}
Note that the same proof works for two dimensional case.
Now we want to proof Green's Theorem by the divergence theroem in two dimensions.
After that we shall prove that Green's Theorem implies Stokes' Theorem.
\begin{proof}[Proof of Green's using Divergence]
    Consider the vector field $\underline{F}=(Q,-P)$, so by Divergence Theorem,
    \begin{align*}
        \iint_A\left( \frac{\partial Q}{\partial x}-\frac{\partial P}{\partial y} \right)\,\mathrm dx\,\mathrm dy
        &=\int_A\nabla\cdot\underline{F}\,\mathrm dA\\
        &=\oint_{\partial A}\underline{F}\cdot\underline{n}\,\mathrm ds\\
        &=\oint_{\partial A}\begin{pmatrix}
            Q\\
            -P
        \end{pmatrix}\cdot\begin{pmatrix}
            y^\prime(s)\\
            -x^\prime(s)
        \end{pmatrix}\,\mathrm ds\\
        &=\oint_{\partial A}P\,\mathrm dx+Q\,\mathrm dy
    \end{align*}
    which is precisely Green's.
\end{proof}
\begin{proof}[Proof of Stokes' by Green's]
    For $A\subset\mathbb R^2,Q=Q(u,v),P=P(u,v)$, we have
    $$\iint_A\left( \frac{\partial Q}{\partial u}-\frac{\partial P}{\partial v} \right)\,\mathrm du\,\mathrm dv=\oint_{\partial A}P\,\mathrm du+Q\,\mathrm dv$$
    Consider the surface $S=\{\underline{x}(u,v):(u,v)\in A\}$ and boundary $\partial S=\{\underline{x}(u,v):(u,v)\in\partial A\}$.
    Choose
    $$\begin{cases}
        P=\underline{F}(\underline{x}(u,v))\cdot\partial\underline{x}/\partial u\\
        Q=\underline{F}(\underline{x}(u,v))\cdot\partial\underline{x}/\partial v
    \end{cases}$$
    Note that
    \begin{align*}
        P\,\mathrm du+Q\,\mathrm dv
        &=\underline{F}(\underline{x}(u,v))\cdot\frac{\partial\underline{x}}{\partial u}\,\mathrm du+\underline{F}(\underline{x}(u,v))\cdot\frac{\partial\underline{x}}{\partial v}\,\mathrm dv\\
        &=\underline{F}(\underline{x}(u,v))\cdot\left( \frac{\partial\underline{x}}{\partial u}\,\mathrm du+\frac{\partial\underline{x}}{\partial v}\,\mathrm dv \right)\\
        &=\underline{F}(\underline{x}(u,v))\cdot\mathrm d\underline{x}(u,v)\\
        \implies \oint_{\partial A}P\,\mathrm du+Q\,\mathrm dv&=\oint_{\partial S}\underline{F}\cdot\mathrm d\underline{x}
    \end{align*}
    On the other hand, we can differentiate to get
    \begin{align*}
        \frac{\partial Q}{\partial u}&=\frac{\partial}{\partial u}\left( \underline{F}(\underline{x}(u,v))\cdot\partial\underline{x}/\partial v \right)\\
        &=\frac{\partial x_j}{\partial u}\frac{\partial F_i}{\partial x_j}\frac{\partial x_i}{\partial v}+F_i(\underline{x}(u,v))\frac{\partial^2 x_i}{\partial u\partial v}
    \end{align*}
    Similarly
    $$\frac{\partial P}{\partial v}=\frac{\partial x_j}{\partial v}\frac{\partial F_i}{\partial x_j}\frac{\partial x_i}{\partial u}+F_i(\underline{x}(u,v))\frac{\partial^2 x_i}{\partial v\partial u}$$
    Now combining these two and using the symmetries in second partial derivatives,
    \begin{align*}
        \left(\frac{\partial Q}{\partial u}-\frac{\partial P}{\partial v}\right)\,\mathrm du\,\mathrm dv&=\left(\frac{\partial x_j}{\partial u}\frac{\partial F_i}{\partial x_j}\frac{\partial x_i}{\partial v}-\frac{\partial x_j}{\partial v}\frac{\partial F_i}{\partial x_j}\frac{\partial x_i}{\partial u}\right)\,\mathrm du\,\mathrm dv\\
        &=(\nabla\times\underline{F})\cdot\left( \frac{\partial\underline{x}}{\partial u}\times\frac{\partial\underline{x}}{\partial v} \right)\,\mathrm du\,\mathrm dv\\
        &=(\nabla\times\underline{F})\cdot\mathrm d\underline{S}
    \end{align*}
    Combining this with Green's Theorem gives the result.
\end{proof}


\subsection{Example: R-RTR-RTR mechanism}

\begin{frame}
	\begin{block}{Example 4: R-RTR-RTR mechanism}
		\begin{table}
			\begin{minipage}{0.5\linewidth}
				\begin{tabular}{l|l}
					& $l_{AB}=l_1=0.15m$\\
					& $l_{AC}=l_2=0.1m$\\
					Given & $l_{CD}=l_3=0.15m$\\
					& $l_{DF}=l_4=0.4m$\\
					& $l_{AG}=l_5=0.3m$\\
					& $\theta_1=30^{\circ}$\\ \hline
					Find & $\vb{r}{B}$, $\vb{r}{D}$, $\vb{r}{G}$
				\end{tabular}
			\end{minipage}\hfill
			\begin{minipage}{0.5\linewidth}
				\begin{figure}
					\includegraphics[width=55mm]{images/R-RTR-RTR.png}
				\end{figure}
			\end{minipage}
		\end{table}
	\end{block}
\emph{Solution}\vskip2.5mm
Position of joint B:  $\displaystyle \vb{r}{B} = x_B\ih + y_B\jh = l_1\cos{\theta_1}\ih + l_1\sin{\theta_1}\jh$\\
Position of joint C:  $\displaystyle \vb{r}{C} = x_C\ih + y_C\jh = 0.1\jh$\\
Position of joint D:  $\displaystyle \vb{r}{D} = x_D\ih + y_D\jh$\\
\end{frame}

\begin{frame}
Position of joint E: $\displaystyle \vb{r}{E} = x_E\ih + y_E\jh$\\
Position of joint G: $\displaystyle \vb{r}{G} = x_G\ih + y_G\jh$

	\[\Rightarrow \begin{cases}
	x_D^2 + (y_D-x_C)^2 = l_3^2\\
	\displaystyle \frac{y_D-y_C}{x_D-x_C} = \frac{y_D-y_B}{x_D-x_B}
	\end{cases} \]

	Solving the system of equations yields $x_{D_1}$ and $x_{D_2}$. Since $\theta_1\in [0,90)$, the condition is $x_D\leq x_C$

	\[\Rightarrow\begin{cases}
	\displaystyle \theta_2=\arctan{\frac{y_B-y_C}{x_B-x_C}}\\
	\displaystyle\theta_3=\theta_2\\
	\displaystyle\theta_4=\arctan{\frac{y_D}{x_D}}\\
	\displaystyle\theta_5=\theta_4
	\end{cases}\]

For other an arbitrary angle $\theta_1$, finding the right condition is tricky (\textit{4 conditions} corresponding to 4 quadrants of 1 full rotation).
\end{frame}

\begin{frame}
	\begin{table}
		\centering
		\begin{tabular}{l|l|l|l}
			$1^{st}$ quadrant & $2^{nd}$ quadrant & $3^{rd}$ quadrant & $4^{th}$ quadrant \\\hline
			$x_D\leq x_C=0$   & $x_D\geq x_C=0$   & $x_D\geq x_C=0$   & $x_D\leq x_C=0$
		\end{tabular}
		\caption{4 conditions to find $x_D$ from $[0,2\pi]$}
	\end{table}

	For this mechanism, observe that for any $\theta_1$:

	\begin{itemize}
		\item $x_Dx_B<0$
		\item $\vb{r}{{DC}}$ and $\vb{r}{{DF}}$ have the same angle
		\item $\vb{r}{D}$ and $\vb{r}{G}$ have the same angle
	\end{itemize}

	Using these properties, we can obtain direct solution of position analysis for the mechanism:\\

	\begin{itemize}
		\item Find $\vb{r}{D}$
		\[\begin{cases}
		\displaystyle\langle \vb{Ox},\vb{r}{CD}\rangle = \arctan{\frac{y_B-y_C}{x_B-x_C}} + \pi\\
		\displaystyle\vb{r}{D} = \vb{r}{C} + sign(x_B)l_3\left(\cos{\langle\vb{Ox},\vb{r}{CD}\rangle}\ih + \sin{\langle \vb{Ox},\vb{r}{CD}\rangle}\jh\right)
		\end{cases}\]
	\end{itemize}
\end{frame}

\begin{frame}
	\begin{itemize}
		\item Find $\vb{r}{F}$
		\[\begin{cases}
		\displaystyle \langle \vb{Ox}, \vb{r}{FC}\rangle = \arctan{\frac{y_C-y_D}{x_C-x_D}}\\
		\displaystyle\vb{r}{F} = \vb{r}{C}+sign(x_B)(l_4-l_3)\left(\cos{\langle \vb{Ox},\vb{r}{FC}\rangle\ih} + \sin{\langle \vb{Ox},\vb{r}{FC}\rangle\jh}\right)
		\end{cases}\]
		\item Find $\vb{r}{G}$
		\[\begin{cases}
		\displaystyle \langle \vb{Ox}, \vb{r}{G}\rangle = \arctan{\frac{y_D}{x_D}}\\
		\displaystyle\vb{r}{G} = -sign(x_B)l_5\left(\cos{\langle \vb{Ox},\vb{r}{G}\rangle\ih}+\sin{\langle \vb{Ox},\vb{r}{G}\rangle\jh}\right)
		\end{cases}\]
	\end{itemize}
Note that $\arctan{\theta}\in(-\frac{\pi}{2}, \frac{\pi}{2})$, which leads to the presence of $sign(x_B)$.
\end{frame}

\begin{frame}{MATLAB R2019a code}
\lstinputlisting[style=Matlab-editor, basicstyle=\mlttfamily]{codes/RRTRRTR-position01.m}
\end{frame}

\begin{frame}{MATLAB R2019a code}
\lstinputlisting[style=Matlab-editor, basicstyle=\mlttfamily]{codes/RRTRRTR-position02.m}
\end{frame}
\begin{frame}{MATLAB R2019a code (direct solution)}
	\lstinputlisting[style=Matlab-editor, basicstyle=\mlttfamily]{codes/RRTRRTR-position1.m}
\end{frame}
\begin{frame}{MATLAB R2019a code (direct solution)}
\lstinputlisting[style=Matlab-editor, basicstyle=\mlttfamily]{codes/RRTRRTR-position2.m}
\end{frame}
\begin{frame}{Plotting using MATLAB R2019a}
\lstinputlisting[style=Matlab-editor, basicstyle=\mlttfamily]{codes/RRTRRTR-plot.m}
\end{frame}
\begin{frame}{Output figure}
\centering
\includegraphics[width=100mm]{images/RRTRRTR-plot.png}
\end{frame}
\begin{frame}{Trajectory plotting using MATLAB R2019a}
\lstinputlisting[style=Matlab-editor, basicstyle=\mlttfamily]{codes/RRTRRTR-trajectory.m}
\end{frame}
\begin{frame}{Output figure}
\centering
\includegraphics[width=100mm]{images/RRTRRTR-trajectory.png}
\end{frame}


\subsection{Double Fourier representation}
Suppose $\Omega$ is bounded and $R$ is the maximum norm of an element of $\Omega$. Then
\begin{equation}
\left|\frac{\omega}{a} \cdot x+b\right| \geq \max \left(0,|b|-\frac{R|\omega|}{|a|}\right).
\end{equation}
Suppose $\boldsymbol{\sigma} \in W^{m, \infty}(\mathbb{R})$ is non-zero and it satisfies the polynomial decay condition
\begin{equation}\label{eq:assdecay}
\left|\sigma^{(k)}(s)\right| \leq C_{p}(1+|s|)^{-p}
\end{equation}
for $0\le k\le m+1$ and some $p> 1$.
Define
\begin{equation}
h(b,\omega)=\bigg (1+ \max \bigg(0, |b|-{R|\omega|\over |a|}\bigg )\bigg )^{-p}.
\end{equation}
It follows that
\begin{equation}\label{eq:decaypro}
\left|\sigma^{(k)}\left(\frac{\omega}{a} \cdot x+b\right)\right| \leq C_{p}\left(1+\left|\frac{\omega}{a} \cdot x+b\right|\right)^{-p} \leq C_{p}h(b,\omega)
\end{equation}
Moreover,
\begin{equation}
\begin{aligned}
\int_{\mathbb{R}} h(b, \omega) d b &=\int_{|b| \leq \frac{R|\omega|}{|a|}} d b+2 \int_{b>\frac{R|\omega|}{|a|}}\left(1+b-\frac{R|\omega|}{|a|}\right)^{-p} d b \\
&=2 R|a|^{-1}|\omega|+2\left[(1-p)^{-1}\left(1+b-\frac{R|\omega|}{|a|}\right)^{1-p}\right]^{\infty} \\
&=2 R|a|^{-1}|\omega|+\frac{2}{p-1} \leq C_{1}(p, \operatorname{diam}(\Omega), \sigma)(1+|\omega|)
\end{aligned}
\end{equation}

\begin{theorem}
Let $\Omega\subset \mathbb{R}^d$ be a bounded domain. If the activation function  $\boldsymbol{\sigma} \in W^{m, \infty}(\mathbb{R})$ is non-zero and it satisfies the polynomial decay condition
\begin{equation}\label{eq:assdecay}
\left|\sigma^{(k)}(s)\right| \leq C_{p}(1+|s|)^{-p}
\end{equation}
for $0\le k\le m+1$ and some $p> 1$, we have
\begin{equation}
\inf _{f_{n} \in \Sigma_{d}^{n}(\sigma)}\left\|f-f_{n}\right\|_{H^{m}(\Omega)} \leq|\Omega|^{\frac{1}{2}} C(p, m, \operatorname{diam}(\Omega), \sigma) n^{-\frac{1}{2}-\frac{t}{(2+t)(d+1)}}\|f\|_{\mathscr{B}^{m+1+\varepsilon}}
\end{equation}
where $t=\min (p-1, \varepsilon),$ for any $f \in \mathscr{B}^{m+1+\varepsilon}$
\end{theorem}
\begin{proof}
Let $\theta=(\omega, b)$, $\hat f(\omega)=|\hat f(\omega)| e^{ib(\theta)}$,
\begin{equation}
\lambda(\theta) = {\rho(\theta)\over \|\rho(\theta)\|_{L^1(G)}} \qquad \text{with}\qquad \rho(\theta) = (1+|\omega|)^mh(b,\omega)|\cos b(\theta)| |\hat f(\omega)|.
\end{equation}
The polynomial decay condition \eqref{eq:assdecay} implies that
\begin{equation}\label{eq:rhostratify}
\|\rho(\theta)\|_{L^1(G)}\le  C_1(p, {\rm diam}(\Omega), \sigma)\|f\|_{\mathcal{B}^{m+1}}.
\end{equation}
Define
\begin{equation}
g(x,\theta) = {\|\rho(\theta)\|_{L^1(\Theta)}\over 2\pi |\hat \sigma (a)|(1+|\omega|)^{m}h(b,\omega)} {\rm sgn} (\cos b(\theta))\sigma ({\omega\over a}\cdot x+b).
\end{equation}
Thus
\begin{equation}
f(x)=\int_G g(x,\theta)\lambda(\theta)d\theta
\end{equation}
with $G=\mathbb{R}^d\times \mathbb{R}$.

Let $G = G_A\cup G_A^c$ with
$$
G_A=\big \{(\omega, b): |b|\le A,\ |\omega|\le {A|a|\over 2R}\big \}.
$$
The interval $[-A,A]$ can be divided into $n_b$ subintervals  $\{G_i^b\}_{i=1}^{n_b}$ such that
$$
|b - b'|<An^{-{1\over d+1}}\quad b, b'\in G_i^b,\quad 1\leq i\leq n_b
$$
for $n_b\ge 2\lceil  n^{1\over d+1}\rceil$.
The interval $[-{A|a|\over 2R}, {A|a|\over 2R}]$ can be divided into $n_\omega$ subintervals $\{G_i^\omega \}_{i=1}^{n_\omega}$ such that
$$
|\omega_j - \omega'_j| \leq {A|a|\over R}n^{-{1\over d+1}}\qquad  \omega,   \omega' \in G_i^\omega,\quad 1\leq i\leq n_\omega
$$
for $n_\omega\ge \lceil n^{1\over d+1}\rceil$.
The product of these intervals gives the following decomposition
$$
G_A=\tilde G_1\cup \tilde G_2\cup \cdots \cup \tilde G_M
$$
such that for any $\theta=(\omega, b)$ and $\theta'=(\omega',b')$ in $\tilde G_i$,
\begin{equation}
|b - b'|<An^{-{1\over d+1}}, \quad \|\omega - \omega'\|_{\ell^\infty} \leq {A|a|\over R}n^{-{1\over d+1}}.
\end{equation}
Each $\tilde G_i$ can be divided into two subsets:
\begin{equation}
\tilde G_i^1 = \{\theta\in \tilde G_i: \cos (b(\theta))\ge 0\}\quad \tilde G_i^2 = \{\theta\in \tilde G_i: \cos (b(\theta))\le 0\}.
\end{equation}
This leads to a decomposition of $G_A$ by $G_A=\cup_{i=1}^{2M} G_i$. For any $ \theta, \theta'\in G_i$,
\begin{equation}
|b - b'|<An^{-{1\over d+1}}, \quad \|\omega - \omega'\|_{\ell^\infty} \leq {A|a|\over R}n^{-{1\over d+1}}, {\rm sgn} (\cos b(\theta))={\rm sgn} (\cos b(\theta')).
\end{equation}
Denote $G_A^c = G_{2M+1}$. Let $n_i=\lceil \lambda(G_i)n\rceil$ and
\begin{equation}
f_{n}(x)=\sum_{i=1}^{2 M+1} \frac{\lambda(G_{i})}{n_{i}} \sum_{j=1}^{n_{i}}g(x,\theta_{i,j}).
\end{equation}
According to Theorem \ref{lem:stratifiedapprox},
\begin{equation}
\mathbb{E}\left(\left\|f - f_{n}\right\|_{H^{m}(\Omega)}^{2}\right)\le
 \sum_{i=1}^{2M+1}  \frac{\lambda^2(G_i)}{n_{i}}  \sup_{\theta_{i},\theta_{i}'\in G_i} \| g(x,\theta_i) - g(x,\theta_i')\|^2_{H^m(\Omega)}
\end{equation}

Notice that
\begin{equation}
D_x^\alpha g(x,\theta) = {\|\rho(\theta)\|_{L^1(G)}\over 2\pi |\hat \sigma (a)|(1+|\omega|)^{m}h(b,\omega)|a|^{|\alpha|} }{\rm sgn} (\cos b(\theta))  \omega^\alpha \sigma^{(|\alpha|)} ({\omega\over a}\cdot x+b).
\end{equation}
We first consider $\sup_{\theta,\theta'\in G_i} \| g(x,\theta_i) - g(x,\theta_i')\|^2_{H^m(\Omega)} $ ($1\le i\le 2M$).
\begin{equation}
| D_x^\alpha \big (g(x,\theta_i) - g(x,\theta_i')\big )|\le |a|^{-|\alpha|}| q(x, \theta_i) - q(x, \theta_i')|
\end{equation}
with
\begin{equation}
q(x, \theta)=(2 \pi|\hat{\sigma}(a)|)^{-1} \|\rho(\theta)\|_{L^1(G)} \omega^{\alpha}(1+|\omega|)^{-m} h(b, \omega)^{-1} \sigma^{(|\alpha|)}\left(\frac{\omega}{a} \cdot x+b\right).
\end{equation}
We now differentiate $D_x^\alpha g(x,\theta)$ with respect to $\omega$ and $b$, noting that for $|\alpha|\le m$,
\begin{equation}
| (1 + |\omega|)^{-m}\omega^\alpha|,\ |D_\omega \big((1 + |\omega|)^{-m}\omega^\alpha\big ) | \lesssim 1
\end{equation}
\begin{equation}
| h(\omega, b)^{-1}|\le \bigg (1+ \max \bigg(0, |b|-{R|\omega|\over |a|}\bigg )\bigg )^{p}
\end{equation}
\begin{equation}
|D_\omega h(\omega, b)^{-1}|,\ |D_b h(\omega, b)^{-1}|\le \bigg (1+ \max \bigg(0, |b|-{R|\omega|\over |a|}\bigg )\bigg )^{p-1}\le \bigg (1+ \max \bigg(0, |b|-{R|\omega|\over |a|}\bigg )\bigg )^{p}.
\end{equation}
It follows from \eqref{eq:assdecay} that
\begin{equation}
\left|D_{b} q(x, \omega, b)\right| \lesssim C_{p}\left(1+\left|\frac{\omega}{a} \cdot x+b\right|\right)^{-p}\left(1+\max \left(0,|b|-\frac{R|\omega|}{|a|}\right)\right)^{p}\|f\|_{\mathscr{B}^{m+1}}
\lesssim C_{p}\|f\|_{\mathscr{B}^{m+1}}
\end{equation}
Similarly, we obtain, since $|x| \leq R$
\[
\left|D_{\omega} q(\omega, b, x)\right| \lesssim \frac{R}{|a|}\|f\|_{\mathscr{B}^{m+1}}
\]
Thus,
\begin{equation}
| D_x^\alpha \big (g(x,\theta_i) - g(x,\theta_i')\big )|\lesssim   A n^{-1 /(d+1)}\|f\|_{\mathscr{B}^{m+1}},
\end{equation}
and
\begin{equation}
\sup_{\theta,\theta'\in G_i} \| g(x,\theta_i) - g(x,\theta_i')\|^2_{H^m(\Omega)} \lesssim   A^2 n^{-2 /(d+1)}|\Omega|^{\frac{1}{2}}\|f\|_{\mathscr{B}^{m+1}},
\end{equation}

Consider $\sup_{\theta,\theta'\in G_{2M+1}} \| g(x,\theta_i) - g(x,\theta_i')\|^2_{H^m(\Omega)} $. By \eqref{eq:decaypro},
\begin{equation}
\| D_x^\alpha g(x,\theta)\|_{L^\infty(\Omega)} \le  {\|\rho(\theta)\|_{L^1(G)}\over 2\pi |\hat \sigma (a)||a|^{|\alpha|} } \|{1\over (1+|\omega|)^{m}h(b,\omega)} \omega^\alpha \sigma^{(|\alpha|)} ({\omega\over a}\cdot x+b)\|_{L^\infty(\Omega)}
\le  C_p{\|\rho(\theta)\|_{L^1(G)}\over 2\pi |\hat \sigma (a)||a|^{|\alpha|} }.
\end{equation}
Thus,
\begin{equation}
\sup_{\theta,\theta'\in G_{2M+1}} \| g(x,\theta_i) - g(x,\theta_i')\|^2_{H^m(\Omega)}
\le
2\sup_{\theta,\in G_{2M+1}} \| g(x,\theta) \|^2_{H^m(\Omega)}
\le
2C_p{\|\rho(\theta)\|_{L^1(G)}\over 2\pi |\hat \sigma (a)| }\sum_{|\alpha|\le m}|a|^{-|\alpha|}.
\end{equation}
By \eqref{eq:rhostratify},
\begin{equation}
\sup_{\theta,\theta'\in G_{2M+1}} \| g(x,\theta_i) - g(x,\theta_i')\|^2_{H^m(\Omega)}
\le |\Omega|  C(p, m, \operatorname{diam}(\Omega), \sigma)\|f\|_{\mathscr{B}^{m+1}}^2.
\end{equation}

The final ingradient we need is a bound on the probability measure of $G_{2M+1}.$ To do this, we break the set $G_{A}^{c}$ into two pieces, $A_{1},$ where $|\omega|>\frac{A|a|}{2 R},$ and $A_{2},$ where $|\omega| \leq \frac{A|a|}{2 R}$ and $|b|>A .$ We get
\[
\lambda(G_{2M+1} ) \leq \frac{1}{I(p, \Omega, \sigma, f)}\left[\int_{A_{1}}(1+|\omega|)^{m} h(b, \omega)|\hat{f}(\omega)| d b d \omega+\int_{A_{2}}(1+|\omega|)^{m} h(b, \omega)|\hat{f}(\omega)| d b d \omega \right]
\]
By integrating out $b,$ we immediately obtain
\[
\int_{A_{1}}(1+|\omega|)^{m} h(b, \omega)|\hat{f}(\omega)| d b d \omega \leq \int_{|\omega|>\frac{A|a|}{2 R}} C_{p}(1+|\omega|)^{m+1}|\hat{f}(\omega)| d \omega \lesssim\|f\|_{\mathscr{B}^{m+1+\varepsilon} }A^{-\varepsilon}
\]
On the other hand, on $A_{2}$ we have $|\omega| \leq \frac{A|a|}{2 R}$ and $|b|>A .$ This implies that
\[
|b|-\frac{R|\omega|}{|a|} \geq \frac{A}{2}
\]
so that for $|\omega| \leq \frac{A|a|}{2 R},$ we have
\[
\int_{|b|>A} h(\omega, b)=\int_{|b|>A}\left(1+\max \left(0,|b|-\frac{R|\omega|}{|a|}\right)\right)^{-p} \leq \int_{|x|>\frac{A}{2}}(1+x)^{-p} \lesssim\left(1+\frac{A}{2}\right)^{1-p}
\]
Integrating in $b \text { and then } \omega, \text { we obtain (recall } A \geq 1)$
\[
\int_{A_{2}}(1+|\omega|)^{m} h(b, \omega)|\hat{f}(\omega)| d b d \omega \lesssim\left(1+\frac{A}{2}\right)^{1-p} \int_{|\omega| \leq \frac{A|a|}{2 R} |}(1+|\omega|)^{m}|\hat{f}(\omega)| d \omega \lesssim\|f\|_{\mathscr{B}^{m+1+\varepsilon}} A^{1-p}
\]
Thus,
\[
\lambda(G_{2M+1} )  \lesssim A^{-\min (p-1, \varepsilon)}
\]
All these estimates lead to
\[
\mathbb{E}(\|f_{n}-f\|_{H^{m}(\Omega)}^{2}) \lesssim
|\Omega| \frac{\|f\|_{\mathscr{B}^{m+1+\varepsilon}}^{2}}{n}\left[A^{-\min (p-1, \varepsilon)}+A^{2} n^{-2 /(d+1)}\right]
\]
Optimizing over $A,$ we obtain, for $A=n^{2 /[(d+1)(2+\min (p-1, \varepsilon))]}$
\[
\mathbb{E} (\|f_{n}-f\|_{H^{m}(\Omega)}^{2} ) \lesssim
| \Omega\|\| f \|_{\mathscr{S}^{m+1+\varepsilon}}^{2} n^{-1-} \frac{2 \sin (p-1, \varepsilon)}{(d+1)(2+\min (p-1, \varepsilon))}
\]
This bound on the expectation means that there must exist samples $\left(\omega_{i j}, b_{i j}, \eta_{i j}\right)$ such that $\tilde{f}_{n}$ defined by
\[
\|f_{n}-f \|_{H^{m}(\Omega)}^{2} \lesssim
|\Omega|\|f\|_{\mathscr{S}^{m+1+\varepsilon}}^{2} n^{-1-\frac{2 \min (p-1, \varepsilon)}{(d+1)(2+\min (p-1, \varepsilon))}}
\]
Thus we finally get
\[
\inf _{f_{n} \in \Sigma_{d}^{3+1}(\sigma)}\left\|f_{n}-f\right\|_{H^{m}(\Omega)} \leq|\Omega|^{\frac{1}{2}} C(p, m, \operatorname{diam}(\Omega), \sigma)\|f\|_{\mathscr{B}^{m+1+\varepsilon} }n^{{-\frac{1}{2}}-\frac{\min (p-1, \varepsilon)}{(d+1)(2+\min (p-1, \varepsilon))}}
\]
as desired.

\end{proof}


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{amsmath}

\title{Lines in the projective plane $\mathbb{P}^2$}
\author{Dave Neary}
\date{June 2021}

\begin{document}

\maketitle

\section{Introduction}

The projective plane $\mathbb{P}^2$ is the set of points on the affine plane, plus
the points at infinity representing different slopes. The addition of the points at
infinity guarantees that any two distinct lines intersect at one point exactly. It can
also be describes by the set of triples $[X; Y; Z]$ not all zero, which are equivalent
up to multiplication by a scalar - $[1; 2; 3]$ and $[2; 4; 6]$ refer to the same point.

For a point $[X;Y;Z] \in \mathbb{P}^2$, if $Z \neq 0$ then this maps to the point in
the Cartesian (or affine) plane $(\frac{X}{Z}, \frac{Y}{Z})$. If $Z=0$, the point
corresponds to a point at infinity (the intersection point of all lines with the
slope $-\frac{X}{Y}$).

\section{Lines in the projective plane}

Common results in Euclidean geometry hold also in the projective plane, with some differences.

\begin{itemize}
    \item Given two distinct points in the projective plane $P_1=[a_1; a_2; a_3],
    P_2=[b_1; b_2; b_3]$ there is a unique line $L: \alpha X + \beta Y + \gamma Z = 0$
    which goes through both points.
    \item Given two distinct lines in the projective plane, they intersect at exactly one point.
\end{itemize}

Recall that if $P_1 = \lambda P_2$ for some scalar factor then $P_1=P_2$ (if it helps, think
of these as equivalence classes like fractions: $\frac{4}{2} = \frac{6}{3}$). So the triples
$(a_1, a_2, a_3), (b_1, b_2, b_3)$ are linearly independent if they are distinct points in $\mathbb{P}^2$.

Then:
\[
\begin{pmatrix}
a_1 & a_2 & a_3 \\
b_1 & b_2 & b_3
\end{pmatrix} \begin{pmatrix}
\alpha \\ \beta \\ \gamma
\end{pmatrix} = \begin{pmatrix}
0 \\ 0
\end{pmatrix}
\]
has a solution, unique up to multiplication by a scalar, with $[\alpha; \beta; \gamma] \in \mathbb{P}^2$.
As we have seen, a point in $\mathbb{P}^2$ is essentially the same as a line through the
origin in $\mathbb{A}^3$. Given $P=[X;Y;Z]$ we can write that line in parametric form with:
\[ L: \vec{p} = \lambda \begin{pmatrix} X \\ Y \\ Z \end{pmatrix} \]

Given this, you can see that the two linearly independent vectors $P_1, P_2$ define a plane
through the origin in $\mathbb{A}^3$ defined by:
\[ C: \vec{p} = \lambda_1 \begin{pmatrix} a_1 \\ a_2 \\ a_3 \end{pmatrix}
+ \lambda_2 \begin{pmatrix} b_1 \\ b_2 \\ b_3 \end{pmatrix}\]

This maps to the line in $\mathbb{P}^2$:
\[ L: \alpha X + \beta Y + \gamma Z = 0 \]

where the vector
\[P_3 = \begin{pmatrix} \alpha \\ \beta \\ \gamma \end{pmatrix} \]

satisfies the relationships $P_1 \cdot P_3 = 0$ and $P_2 \cdot P_3 = 0$ - that is,
$P_3$ is orthogonal to both $P_1$ and $P_2$. In other words, it is a scalar multiple
of $P_1 \times P_2$.

We can calculate $\alpha, \beta, \gamma$ with:
\[ \begin{vmatrix} \alpha & \beta & \gamma \\
a_1 & a_2 & a_3 \\
b_1 & b_2 & b_3 \end{vmatrix} = 0 \]
or:
\[L: \alpha \begin{vmatrix} a_2 & a_3 \\ b_2 & b_3 \end{vmatrix}
- \beta  \begin{vmatrix} a_1 & a_3 \\ b_1 & b_3 \end{vmatrix}
+ \gamma \begin{vmatrix} a_1 & a_2 \\ b_1 & b_2 \end{vmatrix} = 0\]

Similarly, given two lines $L_1: \alpha_1 X + \beta_1 Y + \gamma_1 Z = 0,
L_2: \alpha_2 X + \beta_2 Y + \gamma_2 Z = 0$, $L_1, L_2$ are linearly independent, and
there is a unique solution $[X_1; Y_1; Z_1]$ (up to multiplication by a scalar) for the system:
\[
\begin{pmatrix}
\alpha_1 & \beta_1 & \gamma_1 \\
\alpha_2 & \beta_2 & \gamma_2
\end{pmatrix} \begin{pmatrix}
X_1 \\ Y_1 \\ Z_1
\end{pmatrix} = \begin{pmatrix}
0 \\ 0
\end{pmatrix}
\]

which means that any two homogeneous lines intersect at exactly one point in $\mathbb{P}^2$.

\end{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Written By Michael Brodskiy
% Class: Analytic Geometry & Calculus III (Math-292)
% Professor: V. Cherkassky
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\documentclass[12pt]{article}
\usepackage{alphalph}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}
\usepackage{titling}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{amssymb}
\usepackage[super]{nth}
\usepackage{everysel}
\usepackage{ragged2e}
\usepackage{geometry}
\usepackage{fancyhdr}
\geometry{top=1.0in,bottom=1.0in,left=1.0in,right=1.0in}
\newcommand{\subtitle}[1]{%
  \posttitle{%
    \par\end{center}
    \begin{center}\large#1\end{center}
    \vskip0.5em}%

}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=blue,
citecolor=blue,
}

\urlstyle{same}

\title{Lecture VI Notes}
\date{June 23, 2020}
\author{Michael Brodskiy\\ \small Professor: V. Cherkassky}

% Mathematical Operations:

% Sum: $$\sum_{n=a}^{b} f(x) $$
% Integral: $$\int_{lower}^{upper} f(x) dx$$
% Limit: $$\lim_{x\to\infty} f(x)$$

\begin{document}

\maketitle

\section{Arc Length and Curvature of Three Dimensional Functions $-$ 13.3}

As the arc length of a two dimensional function is defined by: $\int_{a}^{b} \sqrt{f'(t)^2 + g'(t)^2} dt$, the arc length of a three dimensional function is defined by: $\int_{a}^{b} \sqrt{f'(t)^2 + g'(t)^2 + h'(t)^2} dt$, or more simply: $\int_{a}^{b} |\overrightarrow{r}'(t)|dt$\\

The curvature, $\kappa$, of a vector function may be found using the formula: $\kappa(t)=\frac{|\overrightarrow{r}'(t)\text{ x } \overrightarrow{r}''(t)|}{|\overrightarrow{r}'(t)|^3}$

\end{document}