\title{Coloring}
%\author{}
\date{}

\begin{document}

\tableofcontents

\section{3-Coloring on a Ring}
\label{sec:ColorRing}

\quicksec{ColorRing}
(\href{\examplespec/ColorRing.prot}{spec},
\href{\examplesett/ColorRing.args}{args},
(\href{\examplespec/ColorRing.prot}{synt},
\href{\examplesoln/ColorRing.prot}{soln})

The \ilfile{examplespec/ColorRing.prot} file specifies a bidirectional ring topology where each process wishes to obtain a different value than its neighbors.
Each process has $3$ colors to choose from.
This is a very simple protocol and is useful for instruction.

\codeinputlisting{../../../examplespec/ColorRing.prot}
The invariant can also be specified outside of the process definition as:
\begin{code}
(future & silent)
  (forall i <- Nat % N : c[i] != c[i+1]);
\end{code}
outside of the process definition.

The commands in this tutorial should be executed from within the top-level project directory on a Linux system.
First make a directory \ilfile{tmp/} to store some files.
\begin{code}
mkdir tmp
\end{code}

\subsection{Synthesis}
Synthesize a 3-coloring protocol that works on rings of size $3$, $4$, and $5$.
\begin{code}
./bin/protocon -x examplespec/ColorRing.prot -param N 3..5 -o tmp/color.prot
\end{code}

\subsection{Verification}
Check if the protocol is self-stabilizing rings of size $7$. It should be fine!
\begin{code}
./bin/protocon -verify -x tmp/color.prot -param N 7
\end{code}

\subsection{Model Checking with Spin}
We can also verify this protocol's correctness in the \href{http://spinroot.com}{Spin model checker} (here's a \href{../../tut/spin.html}{quick setup guide}).
First output a model in the Promela language for a ring of $6$ processes.
\begin{code}
./bin/protocon -nop -x tmp/color.prot -param N 6 -o-promela tmp/color.pml
\end{code}
Now open the model in iSpin.
\begin{code}
cd tmp
ispin color.pml
\end{code}
In the \ilkey{Edit/View} tab, add the following lines to the end of the file.
This defines a predicate \ttvbl{Legit} that evaluates to true in all legitimate states.
There are also two temporal properties that define closure and convergence.
Closure ensures that once the ring has a valid coloring, no process will change its state in a way that violates that property.
Convergence ensures that from any initial state, the ring will eventually reach a valid coloring.
\begin{code}
#define Legit \
  (c[0] != c[1] && c[1] != c[2] && \
   c[2] != c[3] && c[3] != c[4] && \
   c[4] != c[5] && c[5] != c[0])
ltl Closure { [] (Legit -> [] Legit) }
ltl Convergence { [] <> Legit }
\end{code}
Perform a \ilkey{Syntax Check}; there should be nothing to report.
Now switch to the \ilkey{Verification} tab so we can verify that closure and convergence hold.
Under \ilkey{Liveness}, ensure that the \ilkey{acceptance cycles} bubble is filled.
Next, under \ilkey{Never Claims}, click \ilkey{use claim} and type \ilkey{Closure} for the \ilkey{claim name}.
Verify closure holds by clicking \ilkey{Run}.
Now verify that covergence holds.
\textit{Can you make a change to the 3-coloring protocol that breaks closure? How about convergence?}

\subsection{Parallel Search}
When a problem instance is difficult, it may help to perform multiple searches at the same time using the \ilflag{-parallel} flag.
Since multiple searches are occurring simultaneously, the search progress output is hidden.
This is remedied with the \ilflag{-o-log} flag to create log files \ilfile{search.log.}\ilsym{tid} for each thread of index \ilsym{tid}.
\begin{code}
./bin/protocon -parallel -x examplespec/ColorRing.prot -param N 3..5 -o tmp/color.prot -o-log tmp/color.log
\end{code}
If these log files are not desired, simply do not give the flag.

To control the number of threads used at runtime, simply give a number after the \ilflag{-parallel} flag.
For example, imagine we want to use exactly $2$ threads.

\begin{code}
./bin/protocon -parallel 2 -x examplespec/ColorRing.prot -param N 5
\end{code}

\section{Distributed 3-Coloring on a Ring}
\label{sec:ColorRingDistrib}

\quicksec{ColorRingDistrib}
(\href{\examplespec/ColorRingDistrib.prot}{spec},
\href{\examplesett/ColorRingDistrib.args}{args},
\href{\examplesoln/ColorRingDistrib.prot}{soln})

\section{Distance-2 5-Coloring on a Ring}
\label{sec:ColorRingLocal}

\quicksec{ColorRingLocal}
(\href{\examplespec/ColorRingLocal.prot}{spec},
\href{\examplesett/ColorRingLocal.args}{args},
\href{\examplesoln/ColorRingLocal.prot}{soln})

\end{document}


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

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

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

{\bf \large \sf Purpose}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
Binary Phase Shift Keyed (BPSK) signal.
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf Synopsis}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
\begin{verbatim}
[y,am] = anabpsk(N)
[y,am] = anabpsk(N,ncomp)
[y,am] = anabpsk(N,ncomp,f0)
\end{verbatim}
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf Description}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
        {\ty anabpsk} returns a succession of complex sinusoids of {\ty
        ncomp} points each, with a normalized frequency {\ty f0} and an
        amplitude equal to -1 or +1, according to a discrete uniform
        law. Such signal is only 'quasi'-analytic.\\

\hspace*{-.5cm}\begin{tabular*}{14cm}{p{1.5cm} p{8.5cm} c}
Name & Description & Default value\\
\hline
        {\ty N }    & number of points\\
        {\ty ncomp} & number of points of each component & {\ty N/5}\\
        {\ty f0}    & normalized frequency              & {\ty 0.25}\\
  \hline {\ty y}     & signal\\
        {\ty am}    & resulting amplitude modulation     \\
\hline
\end{tabular*}

\end{minipage}
\vspace*{1cm}

{\bf \large \sf Example}
\begin{verbatim}
         [signal,am]=anabpsk(300,30,0.1);
         subplot(211); plot(real(signal));
         subplot(212); plot(am);
\end{verbatim}
\vspace*{.5cm}

{\bf \large \sf See Also}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
\begin{verbatim}
anafsk, anaqpsk, anaask.
\end{verbatim}
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf Reference}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
[1] W. Gardner {\it Introduction to Random Processes, with Applications to
Signals and Systems}, 2nd Edition, McGraw-Hill, New-York, p. 360 ,1990.
\end{minipage}


\chapter{Special Theory of Relativity}\label{c1}
\section{Galilean relativity}\label{c1s1}
The idea of relative motion is as old as Newton's mechanics. Consider two
observers, $O$ and $O^\prime$ with their frames of reference $S$ and $S^\prime$.
If the axes of $S$ and $S^\prime$ are parallel to each other but the origin of
$S^\prime$ is displaced by $\vec{R}$ from the origin of $S$ then a point
$\vec{r}$ in $S$ appears as
\begin{equation}\label{c1s1e1}
\pvec{r}^\prime = \vec{r} - \vec{R}
\end{equation}
in $S^\prime$. The two observers will disagree on the coordinates of a point.
However, the disagreement will always be to the extent given in equation \eqref
{c1s1e1}. If the observer $O$ finds $O^\prime$ moving then their measurements
of velocities of other bodies will not match. $O$ will measure $\vec{v} =
\dot{\vec{r}}$, $O^\prime$ will measure $\pvec{v}^\prime =
\dot{\pvec{r}}^\prime$ and the two will be related as
\begin{equation}\label{c1s1e2}
\pvec{v}^\prime = \vec{v} - \vec{V},
\end{equation}
where $\vec{V} = \dot{\vec{R}}$ is the velocity of $O^\prime$ as measured by
$O$. Likewise, if $O$ finds that $O^\prime$'s velocity changes with time then
their measurements of acceleration will be related as
\begin{equation}\label{c1s1e3}
\pvec{a}^\prime = \vec{a} - \vec{A},
\end{equation}
where $\vec{a} = \ddot{\vec{r}}, \pvec{a}^\prime = \ddot{\pvec{r}}^\prime$
and $\vec{A} = \ddot{\vec{R}}$. If $O$ observes a body moving in a straight
line with a uniform velocity then $O^\prime$ sees it accelerating. This is the
origin of pseudo-forces. Equations \eqref{c1s1e1} are called Galilean
transformations and they describe the Galilean relativity.

Galilean transformation does not explicitly mention that the mass of a body
does not change across frames of references. It was assumed to be obvious and
not worth mentioning. Likewise, it was also assumed that the time remains
unaffected by relative motion. Therefore, we also have
\begin{eqnarray}
t^\prime &=& t \label{c1s1e4} \\
m^\prime &=& m. \label{c1s1e5}
\end{eqnarray}
Einstein's theory, described in the next sections, proved that these tacit
assumptions are untenable.

\subsection{Problem set 1}\label{c1s1s1}
\begin{enumerate}
\item Alice is standing on the platform and sees Bob on a train passing at a
uniform speed $V = 40$ kmph. Bob rolls a ball on the floor of the train and
measures its speed to be $v^\prime = 5$ kmph. What will be Alice's measurement
of the ball's speed if the ball moves (a) in the direction of the train,
(b) against the direction of the train and (c) sideways?
\item Bob is siting on a flat wagon of a train. The floor of the wagon is
smooth and there is a ball placed on it. The train begins to move. Both Alice
and Bob observe that the ball rolls in a direction opposite to that of the
train. How will Alice and Bob explain the motion of the ball?
\item A fighter-pilot drops a bomb from an aircraft flying at a uniform speed.
How will his co-pilot see it descending? How will an observer on ground see it
dropping? (Assume that the wind does not affect the motion of the bomb.)
\end{enumerate}

If the observer $O^\prime$ is moving at a uniform velocity with respect to $O$
then $\vec{A} = 0$ and $\pvec{a}^\prime = \vec{a}$. Therefore, if $O$ observes
a body at rest then $O^\prime$ observes it to be moving at a \emph{uniform}
velocity $\pvec{v}^\prime = -\vec{V}$.

Newton's first law states that every body continues to be in a state of rest
or of uniform motion in a straight line unless a force acts on it. A frame of
reference in which Newton's first law holds good is called an \emph{inertial
frame of reference}.

\subsection{Problem set 2}\label{c1s1s2}
\begin{enumerate}
\item If $S$ is an inertial frame and if $S^\prime$ moves at a uniform velocity
$\vec{V}$ then show that $S^\prime$ is also an inertial frame of reference.
\item A tractor is attached to three trailers, each of mass $m$. The tractor
itself has a mass $M$. The tractors starts to pull its consist with an
acceleration $a$. Find the tension in each of the couplings. (A coupling is a
device that connects one vehicle to another.)
\end{enumerate}

If a body does not feel a force in one inertial frame of reference then it
does not feel it in any other frame of reference moving uniformly with respect
to the first frame. All inertial frames of reference are equivalent. Observers
in inertial frames may disagree on position and velocities of bodies but never
on their accelerations. Newton's laws are valid in all inertial frames of
reference. As an example, consider two space ships $S$ and $S^\prime$ observing
the planets. Let $\vec{r}_1$ and $\vec{r}_2$ be their positions with respect
to $S$. Then, the force between them is
\begin{equation}\label{c1s1e6}
\vec{F} = -\frac{Gm_1m_2}{|\vec{r}_1 - \vec{r}_2|^3}(\vec{r}_1 - \vec{r}_2).
\end{equation}
Here $m_1$ and $m_2$ are the masses of the planets at positions $\vec{r}_1$
and $\vec{r}_2$ with respect to the origin of $S$ and $G$ is the universal
gravitational constant. The acceleration of mass
$m_1$ is
\begin{equation}\label{c1s1e7}
\vec{a}_1 = -\frac{Gm_2} {|\vec{r}_1 - \vec{r}_2|^3}(\vec{r}_1 - \vec{r}_2).
\end{equation}
Observer $O^\prime$ will express this force as
\begin{equation}\label{c1s1e8}
\pvec{F}^\prime =
-\frac{Gm_1m_2}{|\pvec{r}_1^\prime - \pvec{r}_2^\prime|^3}
(\pvec{r}_1^\prime - \pvec{r}_2^\prime).
\end{equation}
and $m_1$'s acceleration as
\begin{equation}\label{c1s1e9}
\pvec{a}_1^\prime = -\frac{Gm_2} {|\pvec{r}_1^\prime - \pvec{r}_2^\prime|^3}
(\pvec{r}_1^\prime - \pvec{r}_2^\prime).
\end{equation}
Equation \eqref{c1s1e1} assures that the right hand sides of equations
\eqref{c1s1e6} and \eqref{c1s1e8} are the same. The inertial nature of the
frames $S$ and $S^\prime$ assures that the left hand sides are also the same.
The law of motion, Newton's second law, is valid in both frames of reference.
The governing equation are identical, albeit with different variables.

Continuing with the example of the two planets, if $S^\prime$ was accelerating
with respect to $S$ then $\pvec{a}_1^\prime$ would have been $\vec{a} - \vec{A}$
and equation \eqref{c1s1e9} would have been
\begin{equation}\label{c1s1e10}
\pvec{a}_1^\prime = -\frac{Gm_2} {|\pvec{r}_1^\prime - \pvec{r}_2^\prime|^3}
(\pvec{r}_1^\prime - \pvec{r}_2^\prime) + \vec{A}.
\end{equation}
The form of this equation is not the same as \eqref{c1s1e7}.

Laws of physics are expressed in a mathematical form. When we say that Newton's
laws remain unchanged across inertial frames of reference we mean that their
mathematical form remains unchanged. The variables in one frame are replaced
with the variables in another frame but there are no extra or fewer terms. If
one were to do an experiment in any of these frames one will get identical
results.

When the laws of physics change, one can devise experiments to observe the
change. For instance, in the accelerating frame in which we got \eqref{c1s1e10}
we can do an experiment whose results will differ from those in the inertial
frame $S$. The reason for the difference is the additional term on the right
hand side of \eqref{c1s1e10}.

We will illustrate how Newton's laws are affected in a non-inertial frame
of reference. We will analyse the circular motion of a person sitting in a
merry-go-round. From the viewpoint of an observer $S$ on the ground - an
inertial frame of reference - the person in the merry-go-round, $S^\prime$ is
accelerating. Therefore, he expects that there is a net force acting on
$S^\prime$. He lists the forces on $S^\prime$.
\begin{enumerate}
\item $S^\prime$'s weight,
\item The tension in the rod that bears $S^\prime$'s weight,
\item The tension in the rod that connects $S^\prime$ to the merry-go-round's
axis.
\end{enumerate}
$S$ concludes that the first two forces balance each other because $S^\prime$
does not undergo a vertical motion. The third force is responsible for
$S^\prime$'s acceleration. He writes Newton's second law as
\begin{equation}\label{c1s1e11}
m\frac{v^2}{r} = T,
\end{equation}
where $m$ is $S^\prime$'s mass, $v$ is his speed, $r$ is the radius of the
merry-go-round and $T$ is the tension in the rod that connects $S^\prime$ to
the merry-go-round's axis.

We can also confirm that Newton's third law is valid in $S$'s frame of
reference. For each of three forces on $S^\prime$ enumerated above, $S^\prime$
also exerts a force of reaction. $S^\prime$ pulls the earth towards him and he
also pulls the two rods, vertical and horizontal, towards him.

Let us now analyse the same experiment from the non-inertial frame of
$S^\prime$. He includes the same forces acting on his body as $S$ and he
realizes that the net force on him is the horizontal tension $T$. However, he
is at rest in his frame of reference. So concludes that Newton's first law has
failed. That is why, he further concludes, he is in a non-inertial frame of
reference. Newton's second law also fails because his acceleration is zero
in spite of a horizontal force acting on him. In order to save Newton's second
law he introduces a pseudo-force, the centrifugal force, that exactly balances
the horizontal tension $T$. The horizontal tension pulls him towards the
merry-go-round's axis and the centrifugal force pushes him away by an equal
amount, keeping him at rest.

\subsection{Problem set 3}\label{c1s1s3}
\begin{enumerate}
\item The introduction of centrifugal force allowed $S^\prime$ to extend
Newton's second law to his non-inertial frame. Nevertheless, show that Newton's
third law fails. (Hint: Find all action-reaction pairs.)
\end{enumerate}

Since Newton's laws are valid in all inertial frames of reference we cannot
conduct a mechanical experiment in a frame of reference to find out if it is
at rest or in motion. It was believed that there is a frame of reference, with
respect to the fixed stars, that is at rest and everything else in the universe
moves. If there is a space ship floating in the space with its engines turned
off and if it is away from the gravitational influence of the stars then it is
an example of an inertial frame of reference. But nothing in the world is a true
inertial frame because nothing is completely isolated from its surroundings.

We know that the earth goes around the sun and rotates about its axis. Therefore
it is \emph{not} an inertial frame of reference. One can detect its motion
using mechanical experiments alone. For example, Focault's pendulum shows the
accelerated motion of the earth. However, the acceleration is quite small for
experiments at the laboratory scale and one often approximates the earth to be
an inertial frame of reference.

For almost two hundred years, Newton's laws and the two types of frames of
reference sufficed to explain all mechanical phenomena. In the later half of
the nineteenth century, Maxwell unified the fields of electricity and magnetism
in his theory of classical electrodynamics. He predicted the existence of
electromagnetic waves and proposed that light is an electromagnetic wave. A
wave in three dimensions is the solution of the partial differential equation
of the form
\begin{equation}\label{c1s1e12}
\frac{\partial^2\phi}{\partial x^2} + \frac{\partial^2\phi}{\partial y^2} +
\frac{\partial^2\phi}{\partial z^2} =
\frac{1}{c^2}\frac{\partial^2\phi}{\partial t^2},
\end{equation}
where the function $\phi = \phi(x, y, z, t)$ represents the oscillating
quantity and $c$ is the speed of the wave. Consider two inertial frames of
reference $S$ and $S^\prime$. If $S^\prime$ moves at a speed $v$ along the
$x$-axis of $S$ then coordinates in the two frames are related as
\begin{eqnarray}
x^\prime &=& x - vt \label{c1s1e13} \\
y^\prime &=& y \label{c1s1e14} \\
z^\prime &=& z \label{c1s1e15} \\
t^\prime &=& t \label{c1s1e16}
\end{eqnarray}
We will show in the next problem set that the wave equation \eqref{c1s1e12}
does not retain its form under the transformation of \eqref{c1s1e13} to
\eqref{c1s1e15}. We can, therefore, devise an experiment that detects the
motion of $S^\prime$.

Several ingenious experiments were conducted to detect the earth's motion using
optical phenomena. None succeeded in its goals. We are, therefore, left with
two alternatives,
\begin{enumerate}
\item Galilean transformations are the correct but Maxwell's electrodynamics is
not.
\item Maxwell's electrodynamics is right but Galilean transformations and
Newton's need a modification.
\end{enumerate}
There was no experimental evidence in support of the first alternative
\cite{panofsky2005classical}. The second alternative was proposed by Einstein
\cite{einstein1905electrodynamics} in 1905.
\subsection{Problem set 4}
\begin{enumerate}
\item If equation \eqref{c1s1e16} is replaced by $t^\prime = t + \alpha$, where
$\alpha$ is a constant, then show that time intervals are remain invariant.
\item Show that distance between two points remains invariant under the
transformation of equations \eqref{c1s1e13} to \eqref{c1s1e16}. (Hint: Choose
two points $(x_1, y_1, z_1)$ and $(x_2, y_2, z_2)$ in $S$. Find their
coordinates $(x_1^\prime, y_1^\prime, z_1^\prime)$ and $(x_2^\prime,
y_2^\prime, z_2^\prime)$ in $S^\prime$. Use the standard formula to compute the
Euclidean distance between the points in the two frames.)
\item We will now show that the wave equation \eqref{c1s1e12} is not invariant
under the transformation defined by equations \eqref{c1s1e13} and
\eqref{c1s1e16}.
\begin{enumerate}
\item In the frame $S^\prime$, $\phi$ is a function of $x^\prime, y^\prime,
z^\prime, t^\prime$. Recall the definition of the
`differential' of $\phi$,
\[
d\phi = \frac{\partial\phi}{\partial x^\prime}dx^\prime +
\frac{\partial\phi}{\partial y^\prime}dy^\prime +
\frac{\partial\phi}{\partial z^\prime}dz^\prime +
\frac{\partial\phi}{\partial t^\prime}dt^\prime
\]
Find
\[
\frac{\partial\phi}{\partial x} = \frac{\partial\phi}{\partial x^\prime}
\frac{\partial x^\prime}{\partial x} + \frac{\partial\phi}{\partial y^\prime}
\frac{\partial y^\prime}{\partial x} + \frac{\partial\phi}{\partial z^\prime}
\frac{\partial z^\prime}{\partial x} + \frac{\partial\phi}{\partial t^\prime}
\frac{\partial t^\prime}{\partial x}
\]
Hence find
\[
\frac{\partial^2\phi}{\partial {x}^2}.
\]
\item Get the expressions for
\[
\frac{\partial^2\phi}{\partial {y}^2}, \frac{\partial^2\phi}{\partial {z}^2},
\frac{\partial^2\phi}{\partial {t}^2}
\]
using similar steps.
\item Substitute the second partial derivatives obtained in the previous two
steps in the wave equation \eqref{c1s1e12}.
\end{enumerate}
\end{enumerate}

\section{Postulates and their kinematic consequences}\label{c1s2}
Einstein proposed a new theory of relativity based on the two postulates
\begin{enumerate}
\item the laws of physics are the same in all frames of reference and
\item the speed of light is the same in all frames of reference.
\end{enumerate}
The speed of light is thus a universal constant. The second postulate has a
profound impact on our ideas of distances and time intervals. It asserts that
the speed of a pulse of light starting from a vehicle moving with speed $v$
and going in same direction as the vehicle is not $c + v$ but $c$. We will now
show that keeping $c$ constant makes time intervals to expand and lengths to
contract.

\subsection{Time dilation}
To that end we consider a simple clock that has a light source and detector
at one end of a rigid rod of length $L_0$ and a mirror at the other end. A light
pulse emitted by the source travels up the length of the rod, gets reflected
by the mirror and is detected after a time
\begin{equation}\label{c1s2e1}
t_0 = 2L_0/c.
\end{equation}
We will now observe the same clock in an inertial frame moving with velocity
$\vec{v} = v\hat{i}$.  The clock itself is aligned along the $y$ axis,
transverse to the motion.  In this frame, the pulse of light does not take the
same path in its onward and return journey. If $t$ is the time taken for it to
be detected, then $t/2$ is the time it takes to reach the mirror. However, in
that time, the clock has moved a distance $vt/2$. The light pulse, therefore,
travels along the hypotenuse of the triangle whose other two sides have lengths
$vt/2$ along the horizontal direction and $L_0$ along the vertical one.
Therefore, its onward path length is $\sqrt{L_0^2 + v^2t^2/4}$. It is easy to
check that the path length of its return journey is also the same. As seen
from a frame at rest, the pulse travels a distance $2\sqrt{L_0^2 + v^2t^2/4}$
in time $t$. Therefore,
\begin{equation}\label{c1s2e2}
c = \frac{2\sqrt{L_0^2 + v^2t^2/4}}{t}.
\end{equation}
Upon rearranging,
\[
c^2t^2 = 4L_0^2 + v^2t^2 \Rightarrow \left(1 - \frac{v^2}{c^2}\right)t^2 =
\frac{4L_0^2}{c^2}.
\]
Using equation \eqref{c1s2e1} we get
\begin{equation}\label{c1s2e3}
t = \frac{t_0}{\sqrt{1 - \beta^2}},
\end{equation}
where
\begin{equation}\label{c1s2e4}
\beta = \frac{v}{c}.
\end{equation}
Equation \eqref{c1s2e3} tells that the time taken for a pulse to start from
one of the clock, get reflected at the other and return depends on the frame
of reference. For an observer at rest with respect to the clock the time is
$t_0$. An observer who sees the clock in motion measures it as $t$ and the two
are not equal.

Note that in this derivation we have assumed that the length $L_0$ of the
moving clock did not change. We will justify this assumption at the end of the
next subsection.

\subsection{Length contraction}
Now suppose that we are given a rod of length $L_0$ as measured in a frame of
reference in which the rod is at rest. We will find out its length when it is
moving with a velocity $\vec{v} = v\hat{i}$. Once again we use a pulse of light
for our measurement. The rod is fitted with a source of light and a detector
at one end and a mirror at the other end. As seen by an observer at rest,
if $t_1$ is the time taken by a pulse of light in its onward journey then
\begin{equation}\label{c1s2e5}
t_1 = \frac{L + vt_1}{c}.
\end{equation}
If $L$ is the length of the rod measured by the observer at rest, then the pulse
has to travel an additional distance $vt_1$ in its onward journey because the
mirror moved by that distance. In its reverse journey, however, its has to
cover a path of length $L - vt_2$ because the detector approached it by the
distance $vt_2$. Thus,
\begin{equation}\label{c1s2e6}
t_2 = \frac{L - vt_2}{c}.
\end{equation}
From equations \eqref{c1s1e5} and \eqref{c1s2e6} we get
\begin{eqnarray*}
t_1 &=& \frac{L/c}{1 - \beta} \\
t_2 &=& \frac{L/c}{1 + \beta}
\end{eqnarray*}
and the total time
\begin{equation}\label{c1s2e7}
t = t_1 + t_2 = \frac{2L/c}{1 - \beta^2}.
\end{equation}
Now $t$ is the time measured by the observer who sees the rod moving. It is
related to the time measured by an observer at rest with respect to the rod by
equation \eqref{c1s2e3}. We can write \eqref{c1s2e7} in terms of $t_0$ to get
\begin{equation}\label{c1s2e8}
t_0 = \frac{2L/c}{\sqrt{1 - \beta^2}}.
\end{equation}
In the frame in which the rod is at rest, $t_0 = 2L_0/c$ so that
\begin{equation}\label{c1s2e9}
L = L_0\sqrt{1 - \beta^2}.
\end{equation}
Since $\beta < 1$, $L < L_0$. Moving bodies appear shorter.
If $v < c, \beta < 1$ and hence $t > t_0$. Time intervals between events appear
to be dilated. Events in moving frame appear to be happening at a slower pace.

We will now show that transverse length is unaffected by motion. Consider an
experiment in which two
identical rings, $R_1$ and $R_2$, of radius $L_0$ are travelling along their
symmetry axis at a speed $v$ in opposite direction. With respect to $R_1$,
$R_2$'s has shrunk and it passes through $R_1$ when the come together. The
same thing happens from the point of view of $R_2$. From the point of view of
an observer at rest, the rings collide. An experiment cannot give different
results in different frames of reference. Therefore we rule out the possibility
of transverse contraction. The idea of length contraction is a bit subtle as
Penrose \cite{penrose1959apparent} explained in the case of the observation of
a moving sphere and Micheal Weiss \cite{weiss1995} explained in an article.

\subsection{Classical Doppler effect}
We instinctively know whether a vehicle sounding a siren is approaching us or
receding from us. The apparent change in the frequency of sound when there is
a relative motion between the source and receiver of sound is called Doppler
effect.

Let a source $S$ of sound emit waves at frequency $\nu_0$ and a detector $D$
approach it with a uniform velocity $\vec{v}$. If $D$ were still, it would
see the compressions of the wave pass by with a speed $c_s$. However, because
it is approaching the source with a velocity $v$, it sees compressions passing
by with speed $c_s + v$. The wavelength of the wave is seen to be unchanged.
Therefore, the apparent frequency is
\[
\nu = \frac{c_s + v}{\lambda} = \frac{c_s}{\lambda}
\left(1 + \frac{v}{c_s}\right).
\]
Now, $c_s/\lambda - \nu_0$ so that
\begin{equation}\label{c1s2e10}
\nu = \nu_0\left(1 + \frac{v}{c_s}\right).
\end{equation}

Now consider the situation when the detector is stationary but the source
approaches it with a uniform velocity $\vec{v}$. If $S$ were still the detector
will notice a compression every $\lambda$ m apart. However, because $S$ is
approaching $D$ with a speed $v$ the distance is reduced by $v/\nu_0$. The
apparent wavelength is
\[
\lambda = \lambda_0 - \frac{v}{\nu_0} = \frac{c_s}{\nu_0} - \frac{v}{\nu_0}.
\]
Since $\lambda = c_s/\nu$, $\nu$ being the apparent frequency, we have
\begin{equation}\label{c1s2e11}
\nu = \frac{\nu_0}{1 - v/c_s}.
\end{equation}

The formulae for the cases (i) source is stationary and the detector is in
motion and (ii) the other way round, are not symmetric. Does this contradict
our statement that in the world of classical physics one cannot tell which
reference frame is moving? It does not. There are three velocities involved
in the equations, all of them measured with respect to the medium through
which sound waves travel. In the case of equation \eqref{c1s2e10}, $c_s + v$
is the relative velocity of the sound waves with respect to $D$. It is $c_s
-v$ in case of \eqref{c1s2e10}. If we call $c_{sD}$ the relative velocity
in either case, equations \eqref{c1s2e10} and \eqref{c1s2e11} becomes
\begin{eqnarray}
\nu &=& \nu_0\frac{c_{sD}}{c_s} \\
\nu &=& \nu_0\frac{c_s}{c_{sD}}
\end{eqnarray}
In either cases, the numerator is the speed of sound with respect to the moving
body and the denominator is the speed of sound with respect to the medium.

\subsection{Relativistic Doppler effect}
Consider a source of emitting radiation of frequency $\nu_0$. If a detector
$D$ is travelling perpendicular to the direction of propagation of the
radiation, then $D$ will detect a crest every $\nu^{-1}$ seconds. In the frame
of the source, a crest is seen every $\nu_0^{-1}$ seconds. The two times are
related as
\[
\nu^{-1} = \frac{\nu_0^{-1}}{1 - \beta^2}
\]
or
\begin{equation}\label{c1s2e14}
\nu = \nu_0\sqrt{1 - \beta^2}.
\end{equation}
$D$ observes the frequency of the radiation to be lesser than that measured by
$S$. This is the reason relativistic Doppler effect is sometimes described as
\emph{red shift}. The apparent frequency shifts towards the lower end of the
spectrum where the red light is.

Now consider the case when the detector $D$ moves away from the source $S$ with
velocity $v$ along the direction of propagation of radiation. In the frame of
reference of $D$, a time interval $\nu_0^{-1}$ is measured to be
$\nu_0^{-1}/\sqrt{1 - \beta^2}$. Within this time interval, a crest lags behind
by a distance $(\nu_0^{-1}/\sqrt{1 - \beta^2})v$ and is observed after a time lag
$(\nu_0^{-1}/\sqrt{1 - \beta^2})v/c$. Therefore, the apparent period of the wave
is
\[
\nu^{-1} = \frac{\nu_0^{-1}}{\sqrt{1 - \beta^2}} +
\frac{\nu_0^{-1}}{\sqrt{1 - \beta^2}}\frac{v}{c} =
\frac{\nu_0^{-1}}{\sqrt{1 - \beta^2}}(1 + \beta)
\]
or
\begin{equation}\label{c1s2e15}
\nu = \nu_0\sqrt{\frac{1 - \beta}{1 + \beta}}.
\end{equation}

When the detector moves towards the source with a velocity $v$ along the
direction of propagation of radiation then a crest is seen after a time
$\nu_0^{-1}/\sqrt{1 - \beta^2} - (\nu_0^{-1}/\sqrt{1 - \beta^2})v/c$ so that the
apparent frequency is
\[
\nu^{-1} = \frac{\nu_0^{-1}}{\sqrt{1 - \beta^2}}\left(1 - \frac{v}{c}\right) =
\frac{\nu_0^{-1}}{\sqrt{1 - \beta^2}}(1 - \beta)
\]
or
\begin{equation}\label{c1s2e16}
\nu = \nu_0\sqrt{\frac{1 + \beta}{1 - \beta}}.
\end{equation}
The apparent frequency shift towards `red' when the source and the detector move
away from each other, as equation \eqref{c1s2e15} shows. On the other hand,
equation \eqref{c1s2e16} shows that it shifts towards `violet' when they move
toward each other. These observations are qualitatively true even in the case of
the classical Doppler effect.

\subsection{Synchronisation of clocks}
Consider two frames of reference, $S$ and $S^\prime$. Let there be clocks $C_1$
and $C_2$ placed a distance $L_0$ apart in $S$. Assume further that the clocks
are synchronised. That is, they read zero at the same time. Let $S^\prime$ move
with respect to $S$ with a velocity $\vec{v} = v\hat{i}$. Let $C^\prime$ be a
clock in $S^\prime$ which was synchronised with $C_1$ when they were at two were
together.

In the classical world, $C^\prime$ will find itself synchronised with $C_2$ when
it reaches its location. However, that is not so in the relativistic world. An
observer in $S^\prime$ travels a distance $L_0$ in his own frame at a speed $v$
and therefore takes a time $\delta t^\prime = L_0/v$. He measures the distance
between the two clocks in $S$ to be $L_0\sqrt{1 - \beta^2}$ and therefore
estimates that the time elapsed in $C_2$ is $L_0\sqrt{1 - \beta^2}/v$. The two
readings of time are not the same and the difference between the two is the loss
of synchronization between moving clocks. It is,
\begin{equation}\label{c1s2e17}
\Delta = \frac{L_0}{v\sqrt{1 - \beta^2}} - \frac{L_0\sqrt{1 - \beta^2}}{v},
\end{equation}
where we have ensured that both the times are measured with respect to the same
frame of reference, $S$. Upon simplification, we get
\begin{equation}\label{c1s2e18}
\Delta = \frac{L_0\beta^2}{v\sqrt{1 - \beta^2}} = \frac{L\beta^2}{v}.
\end{equation}

\section{Relativistic dynamics}\label{c1s3}
We will consider the collision of two identical objects $A$ and $B$ such that
$A$ is at rest in frame $S$ and $B$ is at rest in frame $S^\prime$. As usual,
we will assume that $S^\prime$ moves with respect to $S$ at a velocity $\vec{v}
= v\hat{i}$. When the position vectors of the two bodies have the same $x$-
coordinate, they are imparted velocities equal in magnitude but towards each
other. Let $V$ be their magnitude. Observers in both frames agree that the
two objects travel a distance $Y/2$ before they collide, $Y$ being the vertical
separation between the two. An observer in $S$ will record that the object $A$
travelled for a time
\[
T = \frac{Y}{2V}
\]
before colliding with $B$. However object $B$ was seen to travel for a time
\[
T_B = \frac{T}{\sqrt{1 - \beta^2}}
\]
before colliding. Therefore, the observer in $S$ concludes that the velocity
of the object $B$ was
\[
V_B = \frac{Y}{2T_B} = \frac{Y}{2T}\sqrt{1 - \beta^2}.
\]
After collision, both observers agree that the two objects rebound and retrace
their paths. In particular, the observer in $S$ concludes that the quantity
\[
m_AV - m_B\sqrt{1 - \beta^2}V
\]
is conserved. Note that this \emph{does not} imply that the quantity $m_AV -
m_BV$ will also be conserved.

We now consider a situation when $V$ is very small although we place no such
restriction on $v$. The velocity of $m_B$ as seen from $S$ is $v\hat{i} +
V\hat{j} \approx v\hat{i}$. If we then define
\[
\vec{p} = \frac{m_B\vec{v}}{\sqrt{1 - \beta^2}}
\]
then we conclude that $\vec{p}_A + \vec{p}_B$ is conserved in an elastic
collision.

Thus the relativistically correct definition of the
momentum of an object whose mass is $m$ in a frame in which it is at rest
and which is observed to move at a velocity $\vec{v}$ in another frame is
\begin{equation}\label{c1s3e1}
\vec{p} = \frac{m\vec{v}}{\sqrt{1 - v^2/c^2}}.
\end{equation}
Newton's second law continues to be
\begin{equation}\label{c1s3e2}
\frac{d\vec{p}}{dt} = \vec{F},
\end{equation}
except that the momentum $\vec{p}$ is defined by equation \eqref{c1s3e1}. If
we define
\begin{equation}\label{c1s3e3}
\gamma = \frac{1}{\sqrt{1 - \beta^2}},
\end{equation}
where $\beta$ is defined in \eqref{c1s2e4} then it is easy to see that
\begin{equation}\label{c1s3e4}
\vec{F} = \gamma^3 m\vec{a},
\end{equation}
where $\vec{a} = \dot{\vec{v}}$. We refrain from calling the quantity
\[
\frac{m}{\sqrt{1 - \beta^2}}
\]
as the relativistic mass because if that we correct then we would have $\vec{F}$
equal its product with the object's acceleration.

The work energy theorem in classical mechanics states that when a force
$\vec{F}$ accelerates an object from the state of rest to a velocity $u$ then
the kinetic energy of the object is
\begin{equation}\label{c1s3e5}
T = \int_0^u \vec{F}\cdot d\vec{s},
\end{equation}
where $\vec{s}$ denotes the displacement of the particle. Using the fact that
$\vec{p} = \gamma m\vec{v}$,
\[
T = \int_0^u \frac{d}{dt}(\gamma m\vec{v})\cdot d\vec{s} =
\int_0^u \vec{v}\cdot d(\gamma m\vec{v}).
\]
Integrating by parts,
\[
T = \gamma mv^2\Big|_0^u - \int_0^u \gamma m\vec{v}\cdot d\vec{v} =
\frac{mu^2}{\sqrt{1 - u^2/c^2}} - \frac{mc^2}{2}\int_0^u
\frac{1}{\sqrt{1 - v^2/c^2}}d\left(\frac{v^2}{c^2}\right).
\]
Using the fact that
\[
\int\frac{dx}{\sqrt{1 - x}} = -2\sqrt{1 - x},
\]
we have
\begin{equation}\label{c1s3e6}
T = \frac{mu^2}{\sqrt{1 - u^2/c^2}} + mc^2\sqrt{1 - u^2/c^2} - mc^2
= \gamma mc^2 - mc^2.
\end{equation}
The factor $mc^2$ is independent of the motion of $m$ and can therefore be
called the \emph{rest energy}. The energy of a body of mass $m$ moving at a
velocity $\vec{v}$ is thus,
\begin{equation}\label{c1s3e7}
E = \gamma mc^2.
\end{equation}
From equations \eqref{c1s3e1} and \eqref{c1s3e7} we observe that
\begin{equation}\label{c1s3e8}
E^2 - p^2c^2 = \frac{m^2c^4}{1 - v^2/c^2} - \frac{m^2v^2c^2}{1 - v^2/c^2} =
m^2c^4.
\end{equation}
We observe that the quantity $E^2 - p^2c^2$ is a constant. Written in another
way, the quantity
\begin{equation}\label{c1s3e9}
p^2 - \frac{E^2}{c^2} = p_x^2 + p_y^2 + p_z^2 - \frac{E^2}{c^2}
\end{equation}
is conserved.

Equation \eqref{c1s3e6} also suggests that it takes an infinite amount of
energy to accelerate an object of mass $m$ to the speed of light. Therefore,
we assume that objects travelling at the speed of light have no mass. Equation
\eqref{c1s3e8} simplifies to
\begin{equation}\label{c1s3e10}
E = pc
\end{equation}
for light.

\section{Lorentz transformation}\label{c1s4}
Equations \eqref{c1s1e1}, \eqref{c1s1e4} and \eqref{c1s1e5} describe the
relation between the coordinates of events in two frames of reference in the
classical world of Galilean relativity. In this section we will get similar
expressions for Einstein's special theory of relativity. The general
expressions of such transformations is
\begin{eqnarray}
x^\prime &=& f_x(x, y, z, t) \\
y^\prime &=& f_y(x, y, z, t) \\
z^\prime &=& f_z(x, y, z, t) \\
t^\prime &=& f_t(x, y, z, t)
\end{eqnarray}
We want a 1-1 relationship between the coordinates in the two frames. We can
guarantee that only if we assume that the functions $f_x, f_y, f_z, f_t$ are
linear. If the $S^\prime$ frame moves with a velocity $\vec{v} = v\hat{i}$ with
respect to $S$ then we do not expect the $y$ and $z$ coordinates to be affected.
Therefore, the above set of equations is simplified to
\begin{eqnarray}
x^\prime &=& f_x(x, y, z, t) \\
y^\prime &=& y \\
z^\prime &=& z \\
t^\prime &=& f_t(x, y, z, t).
\end{eqnarray}
The way there is no preferred frame of reference in the world, there is neither
a preferred direction. The world is isotropic. Therefore, we do not expect
$x^\prime$ and $t^\prime$ to depend on $y$ and $z$ when the relative motion is
along the $x$ axis. As a result, the equations further simplify to
\begin{eqnarray}
x^\prime &=& f_x(x, t) \\
y^\prime &=& y \label{c1s4e10} \\
z^\prime &=& z \label{c1s4e11} \\
t^\prime &=& f_t(x, t).
\end{eqnarray}
Since $f_x$ is a linear function, it is of the form $a_xx + a_tt$, where $a_x$
and $a_t$ are constants. We would like them to be dimensionless. So we write
the linear function as $a_xx - a_tvt = k(x - vt)$. Thus,
\begin{equation}\label{c1s4e13}
x^\prime = k(x - vt).
\end{equation}
If the equations of physics should be identical in all inertial frames of
reference then the inverse relation should be
\begin{equation}\label{c1s4e14}
x = k(x^\prime + vt^\prime).
\end{equation}
We now use the fact that the velocity of light is the same in both frames of
reference. That is
\begin{eqnarray}
x &=& ct \label{c1s4e15} \\
x^\prime &=& ct^\prime. \label{c1s4e16}
\end{eqnarray}
In order to use these equations we would like and equation analogous to
\eqref{c1s4e13} that expresses $t^\prime$ in terms of $x$ and $t$. We can get
it if we substitute \eqref{c1s4e13} in \eqref{c1s4e14}. Thus,
\[
x = k^2x - k^2vt + kvt^\prime
\]
or
\begin{equation}\label{c1s4e17}
t^\prime = kt + \frac{1 - k^2}{kv}x.
\end{equation}
Substitute \eqref{c1s4e13} and \eqref{c1s4e17} into \eqref{c1s4e16} to get
\begin{equation}\label{c1s4e18}
kx - kvt = ckt + c\frac{1 - k^2}{kv}x.
\end{equation}
Rearranging it,
\[
\left(k - c\frac{1 - k^2}{kv}\right)x = kc(1 + \beta)t \Rightarrow
kc\left(\frac{1}{c} - \frac{1 - k^2}{k^2v}\right)x = kc(1 + \beta)t
\]
or
\[
x = \frac{1 + \beta}{1/c - (1 - k^2)/(k^2v)}t,
\]
where $\beta$ is defined in \eqref{c1s2e4}. Comparing this with equation
\eqref{c1s4e15} we get
\[
c = \frac{1 + \beta}{1/c - (1 - k^2)/(k^2v)} \Rightarrow
\frac{1}{c} - \frac{1 - k^2}{k^2v} = \frac{1 + \beta}{c} \Rightarrow
k^2(1 + \beta) - 1 = k^2\beta(1 + \beta)
\]
Continuing further,
\[
k^2(1 + \beta)(1 - \beta) = 1
\]
or
\begin{equation}\label{c1s4e19}
k = \frac{1}{\sqrt{1 - \beta^2}}.
\end{equation}
Substituting \eqref{c1s4e19} in \eqref{c1s4e13} and \eqref{c1s4e17} we get
\begin{eqnarray}
x^\prime &=& \frac{x - vt}{\sqrt{1 - \beta^2}} \label{c1s4e20} \\
t^\prime &=& \frac{t - vx/c^2}{\sqrt{1 - \beta^2}}. \label{c1s4e21}
\end{eqnarray}
We can write these equations in a more symmetrical form as
\begin{eqnarray}
x^\prime &=& \gamma(x - \beta ct) \label{c1s4e22} \\
ct^\prime &=& \gamma(ct - \beta x) \label{c1s4e23}
\end{eqnarray}
where $\gamma$ is defined by equation \eqref{c1s3e3}. These two equations, along
with \eqref{c1s4e10} and \eqref{c1s4e11} define the transformations between two
inertial frames of reference in Einstein's relativity. They are called \emph{
Lorentz transformations}.

\subsection{Problem set 5}
\begin{enumerate}
\item Derive the expressions for length contraction and time dilation using
Lorentz transformations.
\item Show that $x^2 + y^2 + z^2 - c^2t^2 = {x^\prime}^2 + {y^\prime}^2 +
{z^\prime}^2 - c^2{t^\prime}^2$ where the two sets of coordinates are related
by Lorentz transformation.
\item Show that the inverse Lorentz transformations are
\begin{eqnarray}
x &=& \gamma(x^\prime + \beta ct^\prime) \label{c1s4e24} \\
y &=& y^\prime \label{c1s4e25} \\
z &=& z^\prime \label{c1s4e26} \\
ct &=& \gamma(ct^\prime + \beta x^\prime) \label{c1s4e27}
\end{eqnarray}
\item Using the inverse Lorentz transformations, show that
\begin{eqnarray}
dx &=& \gamma(dx^\prime + \beta cdt^\prime) \label{c1s4e28} \\
dy &=& dy^\prime \\
dz &=& dz^\prime \\
cdt &=& \gamma(cdt^\prime + \beta dx^\prime) \label{c1s4e29}
\end{eqnarray}
If a particle moves with a velocity
\[
\vec{u} = \frac{dx}{dt}\hat{i} + \frac{dy}{dt}\hat{j} + \frac{dz}{dt}\hat{k}
\]
then we want to find out how it transforms itself to the $S^\prime$ frame of
reference where
\[
\pvec{u}^\prime = \frac{dx^\prime}{dt^\prime}\hat{i} +
\frac{dy^\prime}{dt^\prime}\hat{j} + \frac{dz^\prime}{dt^\prime}\hat{k}
\]
Now show that the velocities transform as
\begin{eqnarray}
u_x &=& \frac{v + u_x^\prime}{1 + (vu_x^\prime)/c^2} \label{c1s4e30} \\
u_y &=& \frac{u_y^\prime \sqrt{1 - \beta^2}}{1 + (vu_x^\prime)/c^2} \label{c1s4e31} \\
u_z &=& \frac{u_z^\prime \sqrt{1 - \beta^2}}{1 + (vu_x^\prime)/c^2} \label{c1s4e32}
\end{eqnarray}
\end{enumerate}