\chapter{Rigid body Dynamics}
\section{Rigid body}
A body is called a rigid body if the distance between any two points in the body does  not  change  in  time . i.e.,a rigid body  do  not  stretch, compress, or shear. Rigid  bodies,  unlike  point  masses,  can  have  forces  applied  at different points in the body.
\section{Fixed axis rotations}
The simplest motion of a rigid body  is the rotation of a rigid body about an axis fixed in space. So the axis is neither translating nor rotating.

\begin{figure}[H]
\begin{minipage}{0.45\textwidth}
	\centering
	\includegraphics[height=6cm,width=6cm]{rigidbody angularmomentum}
	\end{minipage}
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics[height=4cm,width=4cm]{rigidbody angularmomentum 1}
\end{minipage}
\caption{Fixed axis rotation of rigid body}
\label{Fixed axis rotation}
\end{figure}
The rigid body pivoted at the origin and rotates with angular speed $\omega$ around the $z$ axis, in the counterclockwise direction (as viewed from above). Consider a little piece of the body, with mass $d m$ and position $(x, y)$. This little piece travels in a circle around the origin with speed
\begin{align*}
v&=\omega r\\
\text{Where,}\ r&=\sqrt{x^{2}+y^{2}} \qquad \because x=r\cos\theta \ ;\  y=r\sin\theta
\intertext{Then, the angular momentum of this piece (relative to the origin) equals}
\mathrm{J}&=\mathrm{r} \times \mathrm{p}\\&=r(v d m) \hat{\mathrm{z}}\\&=d m r^{2} \omega \hat{\mathrm{z}}
\intertext{Then the angular momentum of the entire body is therefore}
\mathrm{J}&=\int r^{2} \omega \hat{\mathrm{z}} d m\\&=\int\left(x^{2}+y^{2}\right) \omega \hat{\mathrm{z}} d m
\intertext{Where the integration runs over the area of the body. If the density of the object is constant, as is usually the case, then we have,}
d m&=\rho d x d y
\intertext{If we define the moment of inertia around the $z$ axis to be}
I_{z} &= \int r^{2} d m\\&=\int\left(x^{2}+y^{2}\right) d m
\intertext{Then the $z$ component of the angular momentum}
J_{z}&=I_{z} \omega\\
\text{And in general, the moment of inertia,}\quad I_{z}&= \sum_{i} m_{i} r_{i}^{2}
\end{align*}
\begin{center}
	\framebox{
		\parbox[t][2.5cm]{4cm}{

			\addvspace{0.2cm} \centering

	\begin{align*}
	I&= \sum_{i} m_{i} r_{i}^{2}\\
	J&= I\omega
	\end{align*}} }
\end{center}
\subsection{Torque}
Torque about a point is defined as the rate of change of angular momentum about the same point.
\begin{align*}
\tau&=\frac{dJ}{dt}
\intertext{For a rigid body rotating about it's axis of symmetry}
\tau&=\frac{d (I\omega)}{dt}\\&=I \frac{d \omega}{dt}
\intertext{$\frac{d \omega}{dt}$\ is the angular acceleration.}
\intertext{\textbf{Case-1: } If the axis of rotation and axis of symmetry of the bbody are not one. $J$ and $\omega $ may not along the same direction. Then,}
\tau_{0}&=\frac{d (I\omega)}{dt}
\intertext{\textbf{Case-2: } If the axis of rotation fixed relative to the body . $I$ will be constant. Then,}
\tau_{0}&=I\frac{d \omega}{dt}
\intertext{In the absence of external torque $\tau=0$. Then the angular momentum about the axis of rotation is conserved. }
I\omega&= \text{Constant.}
\end{align*}
\section{Moment of Inertia tensor}
particle $P$ of the body, having the position vector $r_{i}$ with respect to $O$, has an instantaneous velocity $v_{i}$ relative to $O$, given by
\begin{align}
\mathbf{v}_{i}&=\omega \times \mathbf{r}_{i}
\intertext{The angular velocity $\omega$ has components $\omega_{x}, \omega_{y}, \omega_{z}$ along $x$, $y$ and  $z$ axes . }
\omega&=\omega_{x} \hat{\mathrm{i}}+\omega_{y} \hat{\mathrm{j}}+\omega_{z} \hat{\mathrm{k}}
\intertext{Then the angular momentum is given by,}
\mathrm{J}_{p}&=\mathrm{r}_{i} \times m_{i} \mathrm{v}_{i} \quad \text{$\mathrm{m}_{i}$ is the  mass of the particle.}
\intertext{Then the angular momentum ,}
\mathrm{J}&=\sum_{i=1}^{N} \mathrm{r}_{i} \times m_{i} \mathrm{v}_{i}\\&=\sum_{i} m_{i} \mathrm{r}_{i} \times\left({\omega} \times \mathrm{r}_{i}\right)\\
&=\sum_{i} m_{i}\left[\left(\mathrm{r}_{i} \cdot \mathrm{r}_{i}\right) \omega-\left(\mathrm{r}_{i} \cdot \omega\right) \mathrm{r}_{i}\right] \\
&=\sum_{i} m_{i}\left[\mathrm{r}_{i}^{2} \omega-\left(\mathrm{r}_{i} \cdot \omega\right) \mathrm{r}_{i}\right]
\intertext{Whose direction is not along that of angular velocity If $J_{x}, J_{y}, J_{z}$ are the components of angular momentum along $X, Y, Z$ axes respectively, then}
J_{x}&=\sum_{i} m_{i}\left[r_{i}^{2} \omega_{x}-\left(x_{i} \omega_{x}+y_{i} \omega_{y}+z_{i} \omega_{z}\right) x_{i}\right]
\intertext{It can be written as,}
\begin{split}
J_{x}&=\omega_{x} \sum_{i} m_{i}\left(r_{i}^{2}-x_{i}^{2}\right)-\omega_{y} \sum_{i} m_{i} x_{i} y_{i}-\omega_{z} \sum_{i} m_{i} x_{i} z_{i} \\
J_{y}&=-\omega_{x} \sum_{i} m_{i} x_{i} y_{i}+\omega_{y} \sum_{i} m_{i}\left(r_{i}^{2}-y_{i}^{2}\right)-\omega_{z} \sum m_{i} y_{i} z_{i} \\
J_{z}&=-\omega_{x} \sum_{i} m_{i} x_{i} z_{i}-\omega_{y} \sum_{i} m_{i} y_{i} z_{i}+\omega_{z} \sum_{i} m_{i}\left(r_{i}^{2}-z_{i}^{2}\right)
\end{split}\\\\
\begin{split}
J_{x}&=I_{x x} \omega_{x}+I_{x y} \omega_{y}+I_{x z} \omega_{z} \\
J_{y}&=I_{y x} \omega_{x}+I_{y y} \omega_{y}+I_{y z} \omega_{z} \\
J_{z}&=I_{z x} \omega_{x}+I_{z y} \omega_{y}+I_{z z} \omega_{z}
\end{split}
\intertext{Where,}
\begin{split}
I_{x x}&=\sum_{i} m_{i}\left(r_{i}^{2}-x_{i}^{2}\right)=\sum_{i} m_{i}\left(y_{i}^{2}+z_{i}^{2}\right) \\
I_{y y}&=\sum_{i} m_{i}\left(r_{i}^{2}-y_{i}^{2}\right)=\sum_{i} m_{i}\left(\dot{x}_{i}^{2}+z_{i}^{2}\right)\\
I_{z z}&=\sum_{i} m_{i}\left(r_{i}^{2}-z_{i}^{2}\right)=\sum_{i} m_{i}\left(x_{i}^{2}+y_{i}^{2}\right)
\end{split}
\intertext{And,}\
\begin{split}
I_{x y}&=-\sum_{i} m_{i} x_{i} y_{i}=I_{y x} \\
I_{x z}&=-\sum_{i} m_{i} x_{i} z_{i}=I_{z x} \\
I_{y z}&=-\sum_{i} m_{i} y_{i} z_{i}=I_{z y}
\end{split}
\intertext{Then any component of the angular momentum vector can be written as,}
J_{\alpha}&=\sum_{\beta} I_{\alpha \beta} \omega_{\beta} \quad \text { Where } \alpha, \beta=x, y, z\\
\text{Or }\ J&= I\omega
\intertext{In matrix notation,}
\left[\begin{array}{c}
J_{x} \\
J_{y} \\
J_{z}
\end{array}\right]&=\left[\begin{array}{lll}
I_{x x} & I_{x y} & I_{x z} \\
I_{y x} & I_{y y} & I_{y z} \\
I_{z x} & I_{z y} & I_{x z}
\end{array}\right] \left[\begin{array}{l}
\omega_{x} \\
\omega_{y} \\
\omega_{z}
\end{array}\right]
\intertext{The nine elements $I_{x x}, I_{x y}, \ldots, I_{x z}$ of the $(3 \times 3)$ matrix may be regarded as components of a single entity $I$. This entity $I$ is called inertia tensor. Since $I_{x y}=I_{y x}$ etc., $I$ is a symmetric tensor.}
I&= \left[\begin{array}{lll}
I_{x x} & I_{x y} & I_{x z} \\
I_{y x} & I_{y y} & I_{y z} \\
I_{z x} & I_{z y} & I_{x z}
\end{array}\right]
\end{align}
\section{Principle axes and Principle moment of inertia}
If  a body  has  symmetries  with  respect  to  some  of  the  axis,  then  some  of  the  products  of  inertia  become  zero  and  we  can  identify  the  principal  axes.   If  a  body  is  symmetric  with  respect  to  the plane $x^{\prime}=0$ then, we will have $I_{x^{\prime} y^{\prime}}=I_{y^{\prime} x^{\prime}}=I_{x^{\prime} z^{\prime}}=I_{z^{\prime} x^{\prime}}=0$ and $x^{\prime}$ will be a principal axis.
\\If we choose the axes of the coordinate system fixed in the body with respect to which \textbf{off-diagonal elements disappear and only the diagonal elements remain in the inertia tensor, then such axes are called the principal axes} of the body and the corresponding moments of inertia as the principal moments of inertia. In general the directions of the principal axes are different to those of arbitrary axes fixed in the body. If $x^{\prime}$ , $y^{\prime}$ and $z^{\prime}$ are the principle axes then the principle moment of inertia can be written as,
\begin{equation}
{I}=\left[ \begin{array}{ccc}
I_{1} & 0 & 0 \\
0 & I_{2} & 0 \\
0 & 0 & I_{3}
\end{array}\right]
\end{equation}
Where, $I_{x^{\prime} x^{\prime}}=I_{1}, I_{y^{\prime} y^{\prime}}=I_{2} \text { and } I_{z z^{\prime}}=I_{3}$
\\If $\omega_{1}, \omega_{2}, \omega_{3}$ be the components of angular velocity and $J_{1}, J_{2}, J_{3}$ those of angular momentum about the principal axes, then  for the principal axes  we obtain the angular momenta as,
\begin{align}
\left(\begin{array}{l}
J_{1} \\
J_{2} \\
J_{3}
\end{array}\right)&=\left(\begin{array}{lll}
I_{1} & 0 & 0 \\
0 & I_{2} & 0 \\
0 & 0 & I_{3}
\end{array}\right)\left(\begin{array}{l}
\omega_{1} \\
\omega_{2} \\
\omega_{3}
\end{array}\right)
\end{align}

\section{Parallel and perpendicular axes theorem}
\subsection{ Theorem of Parallel Axis }
Consider a rigid body of mass $M$ undergoing fixed-axis rotation.
\begin{theorem}
According to the theorem of parallel axis, the moment of inertia of a body about any axis is equal to the sum of moment of inertia about a parallel axis through it's center of mass and the product of the mass of the body and the square of the distance between two axes.
\begin{equation}
I= I_{cm}+M d^{2}
\end{equation}
\begin{align*}
\text{Where,}\qquad I&= \text{Moment of inertia about any axis.}\\
I_{cm}&= \text{Moment of inertia of the body about a parallel axis passing through it's center of mass.}\\
m&= \text{Mass of the body.}\\
d&= \text{Distance between the two axes.}\\
\end{align*}
\end{theorem}
\subsection{Theorem of Perpendicular Axis}
\begin{theorem}
According to the theorem of perpendicular axis, the moment of inertia of a plane lamina about an axis perpendicular to it's plane is equal to the sum of moments of inertia of the lamina about two axes  at right angles to each other, in it's own plane, and intersecting each other at the point where the perpendicular axis passes through it.\\
If  $I_{\mathrm{x}}$  and $I_{\mathrm{y}}$ be the moment of inertia of a plane lamina about $x$ and $y$ axes . Which lie in the palne of the lamina  and mutually peroendicular to each other intersecting at the origin. The n the moment of inertia  $I$ about an axis which is passing through the origin and perpendicular to the oplane of the lamina is ,
\begin{equation}
I=I_{\mathrm{x}}+I_{\mathrm{y}}
\end{equation}
\end{theorem}

\section{Moment of Inertia of some simple objects}

\subsection{Moment of Inertia of a thin uniform rod }
\subsubsection{1. About an axis passing through the center of mass and perpendicular to it's length.}
Consider a thin uniform rod of length $L$ and mass $m$ and uniform mass density $\lambda$.  Choose Cartesian coordinates, with the origin at the center of mass of the rod, which is midway between the endpoints since the rod is uniform. Choose the $x$-axis to lie along the length of the rod, with the positive $x$-direction to the right, as in the figure.\ref{Uniform rod}
\begin{figure}[H]
	\centering
	\includegraphics[height=1.8cm,width=4cm]{MI rod 1}
	\caption{Uniform rod with an axis passing through the center.}
	\label{Uniform rod}
\end{figure}
\begin{align*}
\intertext{Consider an infinitesimal mass element  $dm$ ,located at a displacement  $x$  from the
	center  of  the  rod,, } \ dm&= \lambda dx \qquad \text{Where,}\ \lambda=\frac{m}{L}
\intertext{The moment of inertia of a continuos mass distribution is given by,}\ I&= \int r^{2} d m\\
\text{Then,}\ I&=\int_{-L/2}^{L/2} x^{2} \frac{m}{L}dx\\&= \frac{m}{L} \int_{-L/2}^{L/2} x^{2} dx\\&=
\frac{m}{L} \left[\frac{x^{3}}{3} \right]_{-L/2}^{L/2} =\frac{m}{3L} \frac{2L^{3}}{8} \\&=\frac{1}{12}mL^{2}
\end{align*}
\subsubsection{2.  About an axis passing  through  the  endpoint. }
\begin{figure}[H]
	\centering
	\includegraphics[height=1.8cm,width=4cm]{MI rod 2}
	\caption{Uniform rod with an axis passing through the end point.}
	\label{Uniform rod}
\end{figure}
According to the theorem of parallel axis, the moment of inertia about any axis is given by,
\begin{align*}
I&= I_{cm}+M d^{2}\quad  \text{Where $d$ is the distance from the axis to center of mass .}\\
\text{Here,}\quad d&=\frac{L}{2}\\
I&=\frac{1}{12} m L^{2}+\frac{1}{4} m L^{2}\\&=\frac{1}{3} m L^{2}
\end{align*}
\subsection{Moment of Inertia of a Uniform Disc}
\subsubsection{1. About an axis passing through the center of mass and perpendicular to the plane of the disc.}

\begin{figure}[H]
\begin{minipage}{0.45\textwidth}
   \centering
	\includegraphics[height=4cm,width=4cm]{MI disc 1}
\end{minipage}
\begin{minipage}{0.45\textwidth}
 \centering
\includegraphics[height=3cm,width=3cm]{MI disc 2}
\end{minipage}
\caption{Uniform Disc with an axis passing through the center of mass}
\label{}
\end{figure}
Choose cylindrical coordinates with the coordinates $(r, \theta)$ in the plane and the $z$-axis perpendicular to the plane. The area element,
\begin{align*}
d a&=\rho d \rho d \theta\\
\sigma &= \frac{M}{A}=\frac{M}{\pi R^{2}}
\intertext{ The infinitesimal mass }\
d m &= \frac{M}{A} d a\\&=\frac{M}{\pi R^{2}} \rho d \rho d \theta
\intertext{Then the moment of inertia ,} \ I &=\int \rho^{2} \sigma d a \\
&=\left(\frac{M}{\pi R^{2}}\right) \int \rho^{2} d a \\
&=\left(\frac{M}{\pi R^{2}}\right) \int_{0}^{R} \int_{0}^{2 \pi} \rho^{2} \rho d \rho d \theta \\
&=\left(\frac{2 M}{R^{2}}\right) \int_{0}^{R} \rho^{3} d \rho \\
&=\frac{1}{2} M R^{2}
\end{align*}
\subsubsection{2. About an axis passing through the diameter.}
\begin{figure}[H]
	\centering
	\includegraphics[height=3cm,width=4cm]{MI disc 4}
	\caption{Uniform disc with an axis passing through the diameter.}
	\label{}
\end{figure}
By the theorem of perpendicular axis,
\begin{align*}
I_{z}&=I_{x}+I_{y}
\intertext{The moment of inertia of the disc is the same about any diameter. Let I be the moment of inertia about any diameter $xx^{\prime}$. Then it will be the moment of inertia  about a perpendicular diameter  $yy^{\prime}$}
\text{Here,}\ I_{z}&=\frac{M R^{2}}{2}\\
\text{And ,}\ I_{x}&=I_{y}=I\\
\frac{M R^{2}}{2}&= 2I\\
 I&= \frac{M R^{2}}{4}
\end{align*}
\subsection{Moment of inertia of a solid sphere .}
\subsubsection{1. About an axis passing through the diameter.}
\begin{align*}
\text{The volume element,}\ dv&= r^{2}dr \sin \theta  d\theta d\phi \\\text{The infinitesimal mass element,} \ dm &=\frac{M}{V} dv\\
&=\frac{M}{\frac{4}{3} \pi R^{3}} r^{2}dr \sin \theta  d\theta d\phi\\
\text{Here, }\ r_{\perp}&=r\sin\theta\\
I&=\int r_{\perp}^{2}+d m\\&=\iiint r^{2} \sin ^{2} \theta \cdot \frac{M}{\frac{4}{3} \pi R^{3}} r^{2} d r \sin \theta d \theta d \phi\\&=\frac{3 M}{4 \pi R^{3}} \int_{0}^{R} r^{4} d r \int_{0}^{\pi} \sin ^{3} \theta d \theta \int_{0}^{2 \pi} d \phi\\
&=\frac{3 M}{4 \pi R^{3}} \cdot \frac{R^{5}}{5} \cdot \frac{4}{3} \cdot 2 \pi\\&=\frac{2}{5} M R^{2}
\end{align*}
\subsubsection{2. About an axis passing through it's tangent.}
\begin{minipage}{0.45\textwidth}
\begin{figure}[H]
	\centering
	\includegraphics[height=5cm,width=3cm]{mi solid 1}
	\caption{About an axis passing through it's tangent.}
	\label{About an axis passing through it's tangent.}
\end{figure}
\end{minipage}\hfill
\begin{minipage}{0.45\textwidth}
	\begin{figure}[H]
		\centering
		\includegraphics[height=4cm,width=3cm]{mi solid 2}
		\caption{About an axis passing through it's diameter.}
		\label{About an axis passing through it's diameter.}
	\end{figure}
\end{minipage}\\\\
Any tangent to the sphere at any point is parallel to one of it's diameter and is at  a distance equal to $R$ from the centre.  Now by the application of the theorem of parallel axis  the moment of inertia becomes,
\begin{align*}
\intertext{According to the theorem of parallel axis, the moment of inertia about any axis is given by,}
I&= I_{cm}+M d^{2}\quad  \text{Where $d$ is the distance from the axis to center of mass .}\\
\text{Here,}\quad d&=R\\
I&=\frac{2}{5} m R^{2}+m R^{2}\\&=\frac{7}{5} m R^{2}
\end{align*}
\subsection{Moment of inertia of a spherical shell.}
\subsubsection{1. About an axis passing through it's diameter.}
On the spherical shell the mass element is ,
\begin{align*}
da&= R^{2} \sin \theta d\theta d \phi\\
\sigma&= \frac{M}{a}\\
d m&=\sigma R \sin \theta d \theta R d \phi
\intertext{where $\sigma=M / 4 \pi R^{2}$ is the surface mass density, and the distance from the rotational axis is $r=R \sin \theta$. Hence the moment of inertia to be calculated is}
I&=\int r_{\perp}^{2}+d m\\&=\iint R^{2} \sin ^{2} \theta \cdot \frac{M}{{4}\pi R^{2}} R^{2}  \sin \theta d \theta d \phi\\&=\frac{M R^{2}}{4 \pi }  \int_{0}^{\pi} \sin ^{3} \theta d \theta \int_{0}^{2 \pi} d \phi\\
&=\frac{ M R^{2}}{4 \pi} \cdot  \frac{4}{3} \cdot 2 \pi\\&=\frac{2}{3} M R^{2}
\end{align*}
\begin{minipage}{0.45\textwidth}
\begin{figure}[H]
	\centering
	\includegraphics[height=4cm,width=3cm]{mi spherical shell}
	\caption{About an axis passing through it's diameter.}
	\label{About an axis passing through it's diameter.}
\end{figure}
\end{minipage}\hfill
\begin{minipage}{0.45\textwidth}
\begin{figure}[H]
	\centering
	\includegraphics[height=4cm,width=3cm]{mi hollow spherical 2}
	\caption{About an axis passing through it's tangent.}
	\label{About an axis passing through it's tangent.}
\end{figure}
\end{minipage}
\subsubsection{2. About an axis passing through it's tangent.}
Any tangent to the sphere at any point is parallel to one of it's diameter and is at  a distance equal to $R$ from the centre.  Now by the application of the theorem of parallel axis  the moment of inertia becomes,
\begin{align*}
\intertext{According to the theorem of parallel axis, the moment of inertia about any axis is given by,}
I&= I_{cm}+M d^{2}\quad  \text{Where $d$ is the distance from the axis to center of mass .}\\
\text{Here,}\quad d&=R\\
I&=\frac{2}{3} m R^{2}+m R^{2}\\&=\frac{5}{3} m R^{2}
\end{align*}
\section{Kinetic energy of a rotating body}
The kinetic energy of a rotating body about an axis depends not only upon it's mass and angular velocity but also depends upon the position of the axis and the distribution of mass about that axis.
Suppose a body of mass $M$ is rotating about an axis . Assume that the body is a system of small particles .
\begin{align*}
\intertext{Let us consider a particle $P$ of elementary mass $m$ at a distance $r$ from the axis.}
\text{The angular velocity}&=\omega\\
\text{The linear velocity }&=r \omega
\intertext{Then the kinetic energy of rotation,}
\text{K.E}&=\frac{1}{2} m r^{2} \omega^{2}
\intertext{Hence the kinetic energy (K.E.) of rotation of the whole body is given by,}
E&=\Sigma \frac{1}{2} m r^{2} \omega^{2}\\&=\frac{1}{2} \omega^{2} \Sigma m r^{2}\\
\text{Now,} \  \Sigma m r^{2}&=I \quad \text{ The moment of inertia about the  given axis}
\intertext{Then the kinetic energy of rotation,} E&=\frac{1}{2} I \omega^{2}\\
\text{If} \ \omega&=1, \text{Obviously}\ I=2  E
\intertext{Hence the moment of inertia of a body may also be defined as twice its kinetic energy of rotation,}
\text{But angular momentum} J&=I \omega \quad \text{where $J$ is along the axis of rotation}\\
\therefore \quad J&=I\sqrt{2 E / I}=\sqrt{2 E I} \\
\text { or } E&=J^{2} / 2 I
\intertext{This is the relation between rotational kinetic energy and angular momentum on the same aaxis}
\end{align*}
\newpage
\colorlet{ocre1}{ocre!70!}
\colorlet{ocrel}{ocre!30!}
\setlength\arrayrulewidth{1pt}
\begin{table}[H]
	\centering
	\arrayrulecolor{ocre}
	\renewcommand*{\arraystretch}{1.5}
	\begin{tabular}{|p{4cm}|p{6cm}|p{3cm}|}
		\hline
		\multicolumn{3}{|c|}{\textbf{Center of mass of uniform systems}}\\\hline\hline
		\rowcolor{ocrel}Uniform body& & Moment of Inertia\\\hline
		Thin Rod (About center)&
		\includegraphics[height=1.5cm,width=3.5cm]{moment i 1}
		&\textbf{$\frac{1}{12}ML^{2}$}   \\\hline
		Thin Rod (About End)& 			\includegraphics[height=1.5cm,width=3.5cm]{moment i 2} & \textbf{$\frac{1}{2}ML^{3}$}   \\\hline
		Rectangular plane (About center)& \includegraphics[height=2.5cm,width=4cm]{ moment i 3} &\textbf{$\frac{1}{12}Ma^{2}$}   \\\hline
		Rectangular plane (About Edge)&	\includegraphics[height=2.5cm,width=4cm]{ moment i 4} & \textbf{$\frac{1Ma^{2}}{2}$}   \\\hline
		Cylinder& \includegraphics[height=2.5cm,width=3cm]{moment i 5} &\textbf{$\frac{1}{2}MR^{2}$}   \\\hline
		Cylindrical hoop& \includegraphics[height=2.5cm,width=3cm]{moment i 6} &\textbf{$MR^{2}$}   \\\hline
		Solid sphere(About diameter)& \includegraphics[height=2.5cm,width=3.2cm]{moment i 7} &\textbf{$\frac{2}{3}MR^{2}$}   \\\hline
		Spherical shell (About diameter)& \includegraphics[height=2.5cm,width=3.2cm]{moment i 8} &\textbf{$\frac{2}{5} MR^{2}$}   \\\hline
	\end{tabular}
\end{table}
\newpage
\begin{abox}
Practice set 1
\end{abox}
\begin{enumerate}
\begin{minipage}{\textwidth}
	\item An annulus of mass $M$ made of a material of uniform density has inner and outer radii $a$ and $b$ respectively. Its principle moment of inertia along the axis of symmetry perpendicular to the plane of the annulus is:
	\exyear{NET DEC 2011}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $\frac{1}{2} M \frac{\left(b^{4}+a^{4}\right)}{\left(b^{2}-a^{2}\right)}$
	\task[\textbf{B.}]$\frac{1}{2} M \pi\left(b^{2}-a^{2}\right)$
	\task[\textbf{C.}]$\frac{1}{2} M\left(b^{2}-a^{2}\right)$
	\task[\textbf{D.}]$\frac{1}{2} M\left(b^{2}+a^{2}\right)$
\end{tasks}
\begin{minipage}{\textwidth}
	\item Two bodies of equal mass $m$ are connected by a massless rigid rod of length $l$ lying in the $x y$-plane with the centre of the rod at the origin. If this system is rotating about the $z$-axis with a frequency $\omega$, its angular momentum is
	\exyear{NET DEC 2012}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $m l^{2} \omega / 4$
	\task[\textbf{B.}]$m l^{2} \omega / 2$
	\task[\textbf{C.}]$m l^{2} \omega$
	\task[\textbf{D.}]$2 m l^{2} \omega$
\end{tasks}
\begin{minipage}{\textwidth}
	\item Two masses $m$ each, are placed at the points $(x, y)=(a, a)$ and $(-a,-a)$ and two masses, $2 m$ each, are placed at the points $(a,-a)$ and $(-a, a)$. The principal moments of inertia of the system are
	\exyear{NET DEC 2015}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] $2 m^{2}, 4 m a^{2}$
	\task[\textbf{B.}]$4 m a^{2}, 8 m a^{2}$
	\task[\textbf{C.}] $4 m a^{2}, 4 m a^{2}$
	\task[\textbf{D.}] $8 m a^{2}, 8 m a^{2}$
\end{tasks}
\begin{minipage}{\textwidth}
	\item A disc of mass $m$ is free to rotate in a plane parallel to the $x y$ plane with an angular velocity $-\omega \hat{z}$ about a massless rigid rod suspended from the roof of a stationary car (as shown in the figure below). The rod is free to orient itself along any direction.
	\begin{figure}[H]
		\centering
		\includegraphics[height=4cm,width=5cm]{diagram-20210926(37)-crop}
	\end{figure}
	The car accelerates in the positive $x$-direction with an acceleration $a>0 .$ Which of the following statements is true for the coordinates of the centre of mass of the disc in the reference frame of the car?
	\exyear{NET DEC 2017}
\end{minipage}
\begin{tasks}(2)
	\task[\textbf{A.}] only the $x$ and the $z$ coordinates change
	\task[\textbf{B.}]only the $y$ and the $z$ coordinates change
	\task[\textbf{C.}]only the $x$ and the $y$ coordinates change
	\task[\textbf{D.}]all the three coordinates change
\end{tasks}
\end{enumerate}

\newpage
\begin{abox}
	Practice set 2
	\end{abox}
\begin{enumerate}
\begin{minipage}{\textwidth}
	\item A uniform solid cylinder is released on a horizontal surface with speed $5 \mathrm{~m} / \mathrm{s}$ without any rotation (slipping without rolling). The cylinder eventually starts rolling without slipping. If the mass and radius of the cylinder are $10 \mathrm{gm}$ and $1 \mathrm{~cm}$ respectively, the final linear velocity of the cylinder is.............. $\mathrm{m} / \mathrm{s}$. (up to two decimal places).
	\exyear{GATE 2017}
\end{minipage}
\begin{minipage}{\textwidth}
	\item A uniform circular disc of mass $m$ and radius $R$ is rotating with angular speed $\omega$ about an axis passing through its centre and making an angle $\theta=30^{\circ}$ with the axis of the disc. If the kinetic energy of the disc is $\alpha m \omega^{2} R^{2}$, the value of $\alpha$ is (up to two decimal places).
	\exyear{GATE 2018}
	\begin{figure}[H]
		\centering
		\includegraphics[height=3cm,width=3cm]{diagram-20210915(17)-crop}
	\end{figure}
\end{minipage}
\end{enumerate}

\newpage
\begin{abox}
	Practise set-3
\end{abox}
\begin{enumerate}[label=\color{ocre}\textbf{\arabic*.}]
	\item Show that the centre of mass of a rod of mass $M$ and length L lies midway between its ends, assuming the rod has a uniform mass per unit length.\\
	\begin{figure}[H]
		\centering
		\includegraphics[height=3cm,width=5cm]{fm14}
	\end{figure}
	\begin{answer}
		By symmetry, we see that $y_{C M}=z_{C M}=0$ if the rod is placed along the $x$ axis. Furthermore, if we call the mass per unit length $\lambda$ (the linear mass density), then $\lambda=\mathrm{M} / \mathrm{L}$ for a uniforr rod.
		If we divide the rod into elements of length $d x$, then the mass of each element is $\mathrm{dm}=? \mathrm{dx}$. Since an arbitrary element of each element is at a distance $x$ from the origin, equation gives,
		\begin{align*}
		x_{C M}&=\frac{1}{M} \int_{0}^{L} x d m\\&=\frac{1}{M} \int_{0}^{L} x \lambda d x\\&=\frac{\lambda L^{2}}{2 M}\\
		\text{Because }\lambda&=M / L \ \text{ this reduces to,}\ x_{C M}=\frac{L^{2}}{2 M}\left(\frac{M}{L}\right)=\frac{L}{2}
		\intertext{One can also argue that by symmetry,} \ x_{C M}&=\frac{L }{2}
		\end{align*}
	\end{answer}
	\item $A$ body of radius $R$ and mass $M$ is rolling horizontally without slipping with speed $v$, it then rolls $u p$ a hill to a maximum height $h .$ If $h=3 v^{2} / 4 \mathrm{~g}$, \\(a) what is the moment of inertia of the body? \\(b) what might be the shape of the body?
\begin{answer}
	\begin{align*}
	\text{(a)}\quad \mathrm{K}_{\text {total }}&=\mathrm{K}_{\text {trans. }}+\mathrm{K}_{\text {rot. }}=\frac{1}{2} \mathrm{M} \mathrm{v}^{2}+\frac{1}{2} \mathrm{I} \omega^{2}\\
	&=\frac{1}{2} M v^{2}+\frac{1}{2} I\left(\frac{v^{2}}{R^{2}}\right)=\frac{v^{2}}{2}\left[M+\frac{I}{R^{2}}\right]
	\intertext{When it rolls up a hill to height $\mathrm{h}$, the entire kinetic energy is converted into potential energy $\mathrm{M} \mathrm{g} \mathrm{h}$}
	\text{Thus} \frac{\mathrm{v}^{2}}{2}\left[\mathrm{M}+\frac{\mathrm{I}}{\mathrm{R}^{2}}\right]&=\mathrm{Mgh}=\mathrm{Mg}\left[3 \frac{\mathrm{v}^{2}}{4 \mathrm{~g}}\right]\\
	\text{or }\left[\mathrm{M}+\frac{\mathrm{I}}{\mathrm{R}^{2}}\right]&=\frac{3}{2} \mathrm{M} \\ \therefore \mathrm{I}&=\frac{\mathrm{MR}^{2}}{2}
	\intertext{\text{(b)}\quad The body may be a circular disc or a solid cylinder.}
	\end{align*}
\end{answer}
	\item Let $g$ be the acceleration due to gravity at earth's surface and $K$ be the rotational kinetic energy of the earth. Suppose the earth's radius decrease by $2 \%$, keeping all other quantities same, then
\begin{tasks}(1)
	\task[\textbf{A.}] g decreases by $2 \%$ and $\mathrm{K}$ decreases by $4 \%$
	\task[\textbf{B.}] g decreases by $4 \%$ and k increases by $2 \%$
	\task[\textbf{C.}] $\mathrm{g}$ increases by $4 \%$ and $\mathrm{K}$ decreases by $4 \%$
	\task[\textbf{D.}] g decreases by $4 \%$ and $\mathrm{K}$ increases by $4 \%$
\end{tasks}
\begin{answer}
	\begin{align*}
	\text{We know that, }g&=\frac{G M}{R^{2}}\\
	\text{Differentiating, }\frac{\mathrm{dg}}{\mathrm{g}}&=-\left(\frac{2 \mathrm{dR}}{\mathrm{R}}\right)\\
	\text{Further, }\mathrm{K}&=\frac{1}{2} \mathrm{I} \omega^{2}=\frac{1}{2}\left[\frac{3}{5} \mathrm{M} \mathrm{R}^{2}\right] \omega^{2}\\
	\text{	or }\frac{\mathrm{dK}}{\mathrm{K}}&=\frac{3}{10} \mathrm{M} \omega^{2} \times\left(\frac{2 \mathrm{dR}}{\mathrm{R}}\right)
	\intertext{When radius decreases by $2 \%$, then $\mathrm{g}$ increases by $4 \%$ and K decreases by $4 \%$.}
	\end{align*}
	So the correct answer is \textbf{Option (C)}
\end{answer}
	\item A cubical block of side $a$ is moving with velocity $v$ on a horizontal smooth plane as shown in fig. It hits a ridge at point $O$. The angular speed of the block after it hits $O$ is\\
\begin{figure}[H]
	\centering
	\includegraphics[height=1.5cm,width=5cm]{fm16}
\end{figure}
\begin{tasks}(4)
	\task[\textbf{A.}] $3 \mathrm{v} /(4 \mathrm{a})$
	\task[\textbf{B.}] $3 \mathrm{v} /(2 \mathrm{a})$
	\task[\textbf{C.}] $\sqrt{3} \mathrm{v} /(\sqrt{2} \mathrm{a})$
	\task[\textbf{D.}] Zero
\end{tasks}
\begin{answer}$\left. \right. $\\
	\begin{minipage}{0.65\textwidth}
		\begin{align*}
		\intertext{By conservation of angular momentum, we have}
		I \omega&=M \vee(a / 2)\\
		\text{	Here, }I&=\frac{M a^{2}}{6}+M\left(\frac{a}{\sqrt{2}}\right)^{2}\\&=\frac{2 M a^{2}}{3} \\
		\therefore \frac{2 \mathrm{Ma}^{2}}{3} \omega&=\frac{\mathrm{Mva}}{2} \\ \omega&=\frac{3 \mathrm{v}}{4 \mathrm{a}}
		\end{align*}
	\end{minipage}
	\begin{minipage}{0.35\textwidth}
		\begin{figure}[H]
			\centering
			\includegraphics[height=2cm,width=5cm]{fm17}
		\end{figure}
	\end{minipage}
\end{answer}
	\item A sphere is spinned in a clockwise direction by angular velocity $\omega$ and then it is released to a rough surface. Find the time elapsed by the sphere, till it starts pure rolling (coefficient of friction is $\mu$ ) and radius of sphere is $R$.\\
\begin{figure}[H]
	\centering
	\includegraphics[height=3.3cm,width=5cm]{fm18}
\end{figure}
\begin{answer}
	\begin{align}
	\mathbf{N}&=\mathrm{mg}\notag
	\intertext{$\mathrm{f}=\mu \mathrm{mg}$ (friction opposes relative motion, so it is in forward direction)}\notag\\
	a_{c m}&=\frac{f}{m}=\mu g\label{fm01}\\
	\text{Also }\mathrm{f} \times \mathrm{R}&=\mathrm{I} \alpha\notag\\
	\Rightarrow \mu \mathrm{mgR}&=\mathrm{I} \alpha \Rightarrow \alpha=\frac{\mu \mathrm{mgR}}{\mathrm{I}}=\frac{\mu \mathrm{mgR}}{2 / 5 \mathrm{mR}^{2}}=\frac{5}{2} \frac{\mu \mathrm{g}}{\mathrm{R}}\notag\\
	\omega&=\omega_{\mathrm{o}}-\alpha \mathrm{t}=\omega_{\mathrm{o}}-\frac{5}{2} \frac{\mu \mathrm{gt}}{\mathrm{R}}\label{fm02}
	\intertext{At the instant, $\mathrm{m}$ starts pure rolling}\notag
	\omega R&=v\text{ (lowest point is at rest)}\notag\\
	v_{c m}&=0+\mu g t\label{fm03}
	\intertext{$[$ from eqns. $(\ref{fm02})$ and $(\ref{fm03})$ and $\omega R=v]$}\notag
	\Rightarrow \omega \mathrm{R}&=\frac{7}{2} \mu \mathrm{gt} \Rightarrow \mathrm{t}=\frac{2}{7} \frac{\omega \mathrm{R}}{\mu \mathrm{g}}\notag
	\end{align}
\end{answer}
\item  A uniform solid cube has mass $M$ and side ' $a$ '. Calculate moment of inertia of the cube about an axis which coincides with one of it's sides
\begin{figure}[H]
	\centering
	\includegraphics[height=3cm,width=3cm]{Rigid body pset-3}
\end{figure}
\begin{answer}
	\begin{align*}
	\intertext{Moment of inertia of a cube about an axis passing through it's  centre}
	I_{c}&=\frac{Ma^{2}}{6}
	\intertext{Seperation between two axes}
	d&=\frac{a}{\sqrt{2}}
	\intertext{Then according to the parellel axis theorem}
	I&=I_{c}+Md^{2}\\
		&=\frac{Ma^{2}}{6}+M\left( {\frac{a}{\sqrt{2}}}\right) ^{2}\\
		&=\frac{2 Ma^{2}}{3}
	\end{align*}
\end{answer}
 \item A $1 \mathrm{~kg}$ mass of clay, moving with a velocity of 10 $\mathrm{m} / \mathrm{s}$, strikes a stationary wheel and sticks to it. The solid wheel has a mass of $20 \mathrm{~kg}$ and a radius of $1 \mathrm{~m}$.
\begin{figure}[H]
	\centering
	\includegraphics[height=2cm,width=5cm]{mi 1}

\end{figure}
 Assuming that the wheel and the ground are both rigid and that the wheel is set into pure rolling motion, the angular velocity of the wheel immediately after the impact is, approximately,
 \begin{tasks}(2)
 	\task[\textbf{a.}]Zero.
 	\task[\textbf{b.}]$1 / 3 \ \mathrm{rad} / \mathrm{s}$
 	\task[\textbf{c.}]$\sqrt{10 / 3}\  \mathrm{rad} / \mathrm{s}$
 	\task[\textbf{d.}]$10 / 3 \ \mathrm{rad} / \mathrm{s}$
 \end{tasks}
\begin{answer}
	The moment of inertia of wheel of mass $m$ and radius $r$ w.r.t. a normal axis passing through circumference is
	\begin{align*}
	I &=\frac{m r^{2}}{2}+m r^{2} \\
	&=\frac{3}{2} m r^{2}
	\end{align*}
	If $\omega$ is the velocity of pure rolling of wheel after the impact, total kinetic energy of both the masses before and after the impact will be equal, therefore,
	\begin{align*}
	\frac{1}{2} \times 1 \times 10^{2} &=\frac{1}{2}\left(\frac{3}{2} \times 20 \times 1^{2}\right) \omega^{2} \\
	\omega &=\sqrt{\frac{10}{3}}
	\end{align*}
	So the correct answer is \textbf{option(c)}
\end{answer}
\end{enumerate}

Classical Mechanics  -CSIR/chapter/Rigid body dynamics.tex


\documentclass[letterpaper, twoside, 12pt]{book}
\usepackage{packet}

\begin{document}

\setcounter{chapter}{1}

\chapter{Part 2.2: Sections 14.1-14.3}

\setcounter{chapter}{14}
\setcounter{section}{0}

\section{Functions of Several Variables} %14.1

\begin{definition}
  A \textbf{function $f$ of two variables} is a rule which assigns a
  real number $f(x,y)$ to each pair of real numbers $(x,y)$ for which
  that rule is defined.
  The collection of such well-defined pairs is called the
  \textbf{domain} $\text{dom}(f)$ of the function, and the set of
  real numbers which
  can possiblely be produced by the function is called its
  \textbf{range} $\text{ran}(f)$.
\end{definition}

\begin{definition}
  The \textbf{level curve} for each $k\in\text{ran}(f)$ is given by the
  equation $f(x,y)=k$.
  The \textbf{graph} of $f$ is a surface in 3D space which visualizes the function, given by the equation $z=f(x,y)$.
\end{definition}

\begin{definition}
  A \textbf{function $f$ of three variables} is a rule which assigns a
  real number $f(x,y,z)$ to each triple of real numbers $(x,y,z)$ for which
  that rule is defined.
  The collection of such well-defined triples is called the
  \textbf{domain} $\text{dom}(f)$ of the function, and the set of
  real numbers which
  can possiblely be produced by the function is called its
  \textbf{range} $\text{ran}(f)$.
\end{definition}

          \begin{problem}
            Let $f(x,y)=x\sin(x+y)$. Give the value of $f(\pi,\frac{\pi}{2})$.
          \end{problem}

          \begin{solution}

          \end{solution}

          \begin{problem}
            Let $f(x,y)=-x-y+2$. In the $xy$-plane, plot the domain of $f$,
            as well as its level curves for $k=-3,0,3$. Then plot the graph
            of $f$ in $xyz$ space.
          \end{problem}

          \begin{solution}

          \end{solution}

          \begin{problem}
            Let $f(x,y)=\sqrt{4-x^2-y^2}$. In the $xy$-plane,
            plot the domain of $f$,
            as well as its level curves for $k=0,\frac{1}{\sqrt{2}},1$.
            Then plot the graph of $f$ in $xyz$ space.
          \end{problem}

          \begin{solution}

          \end{solution}

\begin{definition}
  The \textbf{level surface} for each $k\in\text{ran}(f)$ is given by the
  equation $f(x,y,z)=k$.
  (Since the graph of a three variable function would require four
  variables and therefore is a four-dimensional object, we typically
  don't consider it.)
\end{definition}

          \begin{problem}
            Let $f(x,y,z)=\frac{x+3y^2}{z-2x}$. Give the value of $f(3,-2,1)$.
          \end{problem}

          \begin{solution}

          \end{solution}

          \begin{problem}
            Let $f(x,y,z)=-x^2+y-z^2$. In $xyz$ space, plot the level
            surfaces for $k=-2,0,2$.
          \end{problem}

          \begin{solution}

          \end{solution}

\begin{remark}
  If $P=(x,y)$, then we assume that $f(x,y)=f(P)=f(\vect{P})$.
  If $P=(x,y,z)$, then we assume that $f(x,y,z)=f(P)=f(\vect{P})$.
\end{remark}

\section{Limits and Continuity} %14.2

\begin{definition}
  If the value of the function $f(P)$ becomes arbitrarily close to the number
  $L$ as points $P$ close to $P_0$ are plugged into the function, then the
  \textbf{limit of $f(P)$ as $P$ approaches $P_0$} is $L$:
  \[\lim_{P\to P_0} f(P) = L\]
\end{definition}

\begin{theorem}
  Let $f(x,y)$ be a function of two variables.
  If there exists a curve $y=g(x)$ passing through the
  point $(x_0,y_0)$ such that $\lim_{x\to x_0}f(x,g(x))$ does not exist,
  then $\lim_{(x,y)\to(x_0,y_0)}f(x,y)$ does not exist.
\end{theorem}

          \begin{problem}
            Prove that
              \[
                \lim_{(x,y)\to(0,0)} \frac{x+y}{|x+y|}
              \]
            does not exist by considering the function $g(x)=x$.
          \end{problem}

          \begin{solution}

          \end{solution}

\begin{theorem}
  Let $f(x,y)$ be a function of two variables.
  If there exist curves $y=g(x)$ and $y=h(x)$ passing through the
  point $(x_0,y_0)$ such that
  $\lim_{x\to x_0}f(x,g(x))\not=\lim_{x\to x_0}f(x,h(x))$,
  then $\lim_{(x,y)\to(x_0,y_0)}f(x,y)$ does not exist.
\end{theorem}

          \begin{problem}
            Prove that
              \[
                \lim_{(x,y)\to(0,0)} \frac{x^6+y^2}{x^3y+x^6}
              \]
            does not exist by considering the functions
            $g(x)=x^3$ and $h(x)=2x^3$.
          \end{problem}

          \begin{solution}

          \end{solution}

\begin{theorem}
  The ``Limit Laws'' for single-variable functions also hold for
  multi-variable functions.
    \[
      \lim_{P\to P_0}(f(P)\pm g(P))
        =
      \lim_{P\to P_0}f(P) \pm \lim_{P\to P_0}g(P)
    \]
    \[
      \lim_{P\to P_0}(f(P)\cdot g(P))
        =
      \lim_{P\to P_0}f(P) \cdot \lim_{P\to P_0}g(P)
    \]
    \[
      \lim_{P\to P_0}(kf(P))
        =
      k\lim_{P\to P_0}f(P)
    \]
    \[
      \lim_{P\to P_0}\frac{f(P)}{g(P)}
        =
      \frac{\ds \lim_{P\to P_0}f(P)}{\ds \lim_{P\to P_0}g(P)}
    \]
    \[
      \lim_{P\to P_0}(f(P))^{r/s}
        =
      \left(\lim_{P\to P_0}f(P)\right)^{r/s}
    \]
\end{theorem}

\begin{theorem}
  Let $P_0=(x_0,y_0,z_0)$. Multi-variable limits which only use one
  variable may be reduced to a single-variable limit.
    \[
      \lim_{P\to P_0}f(x) = \lim_{x\to x_0}f(x)
    \]
    \[
      \lim_{P\to P_0}g(y) = \lim_{y\to y_0}g(y)
    \]
    \[
      \lim_{P\to P_0}h(z) = \lim_{z\to z_0}h(z)
    \]
\end{theorem}

          \begin{problem}
            Use the above theorems to rigorously prove that
              \[
                \lim_{(x,y)\to(1,2)}
                \frac{2x+y}{y^2}
                  =
                1
              \]
          \end{problem}

          \begin{solution}

          \end{solution}

\begin{remark}
  Due to the limit laws, the ``just plug it in'' rule applies when
  plugging in does not result in an undefined operation.
\end{remark}

          \begin{problem}
            Compute the limit
              \[
                \lim_{(x,y,z)\to(3,0,-1)}
                \frac{x\cos y}{z+x}
              \]
          \end{problem}

\begin{remark}
  There is no L'Hopital rule for multi-variable limits.
  However, you may still use it once the limit has been reduced
  to a single-variable limit.
\end{remark}

          \begin{problem}
            Compute the limit
              \[
                \lim_{(x,y)\to(3,0)}
                \frac{xy+\sin(2y)}{y}
              \]
          \end{problem}

          \begin{solution}

          \end{solution}

\begin{remark}
  Factoring and canceling (including conjugation tricks) is
  also effective for computing multi-variable limits.
\end{remark}

          \begin{problem}
            Compute the limit
              \[
                \lim_{(x,y,z)\to(1,2,4)}
                \frac{\sqrt{z}-xy}{z-x^2y^2}
              \]
          \end{problem}

          \begin{solution}

          \end{solution}

\begin{definition}
  A function $f(P)$ is \textbf{continuous} if
  $\ds \lim_{P\to P_0}f(P) = f(P_0)$ for all points $P_0$ in its domain.
\end{definition}

\begin{theorem}
  If a multi-variable function is composed of continuous single-variable
  functions, then it is also continuous.
\end{theorem}

\section{Partial Derivatives} %14.3

\begin{definition}
  The \textbf{partial derivative of $f$ with respect to a variable} is
  the rate of change of $f$ as that variable changes and all other variables
  are held constant. For example:
  \[\frac{\p f}{\p x}=f_x(x,y)=\lim_{h\to0}\frac{f(x+h,y)-f(x,y)}{h}\]
  \[\frac{\p g}{\p z}=g_z(x,y,z)=\lim_{h\to0}\frac{g(x,y,z+h)-g(x,y,z)}{h}\]
\end{definition}

          \begin{problem}
            Let $f(x,y,z)=xy^2+2z$.
            Use the definition of a partial derivative to prove that
            $\frac{\p f}{\p y} = 2xy$.
          \end{problem}

          \begin{solution}

          \end{solution}

\begin{theorem}
  Partial derivatives may be computed in the usual way by treating
  all other variables as constants.
\end{theorem}

          \begin{problem}
            Compute both partial derivatives of $f(x,y)=4x^2-5y^3+xy-1$.
          \end{problem}

          \begin{solution}

          \end{solution}

          \begin{problem}
            Compute both partial derivatives of $f(x,y)=\sin(x+3y)$.
          \end{problem}

          \begin{solution}

          \end{solution}

          \begin{problem}
            Compute both partial derivatives of $f(x,y)=e^{xy^2}$.
          \end{problem}

          \begin{solution}

          \end{solution}

\begin{definition}
  \textbf{Second-order partial derivatives} are the result of taking the
  partial derivative of a partial derivative. For example:
  \[
    f_{xy} =
    (f_x)_y =
    \frac{\p}{\p y}\left(\frac{\p f}{\p x}\right) =
    \frac{\p^2 f}{\p y\p x}
  \]
  \[
    g_{z} =
    (g_z)_z =
    \frac{\p}{\p z}\left(\frac{\p g}{\p z}\right) =
    \frac{\p^2 g}{\p z^2}
  \]
\end{definition}

\begin{theorem}
  When computing the second-order partial derivative for a sufficiently
  well-behaved function, the order in which the partial
  derivatives are taken is irrelevant. (This is sometimes called the
  \textbf{Mixed Derivative Theorem}.)
\end{theorem}

          \begin{problem}
            Verify the Mixed Derivative Theorem for
            $f(x,y)=3x^2y^2-x^3+y^4-7$.
          \end{problem}

          \begin{solution}

          \end{solution}

\end{document}


%Electrodynamics Homework_2
\documentclass[10pt,a4paper]{article}
\usepackage[UTF8]{ctex}
\usepackage{bm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\title{Electrodynamics Homework\_2}
\author{陈稼霖 \and 45875852}
\date{2019.2.25}
\begin{document}
\maketitle
\section{}
Let
\[
r=\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}
\]
be the distance between the point of the source $\vec{x}'$ and the point to measure the field $\vec{x}$. Furthermore, let us define $\vec{r}=\vec{x}'-\vec{x}$. Show the following relations
\subsection{}
\[
\nabla r=-\nabla'r=\frac{\vec{r}}{r}
\]
\textbf{pf:}
\footnotesize\begin{align*}
\nabla r=&\frac{\partial\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}{\partial x}\vec{i}+\frac{\partial\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}{\partial y}\vec{j}\\
&+\frac{\partial\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}{\partial z}\vec{k}\\
=&\frac{x-x'}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}\vec{i}+\frac{y-y'}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}\vec{j}\\
&+\frac{z-z'}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}\vec{k}\\
=&\frac{(x-x')\vec{i}+(y-y')\vec{j}+(z-z')\vec{k}}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}\\
=&\frac{\vec{r}}{r}
\end{align*}
\begin{align*}
-\nabla'r=&-\frac{\partial\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}{\partial x'}\vec{i}-\frac{\partial\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}{\partial y'}\vec{j}\\
&-\frac{\partial\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}{\partial z'}\vec{k}\\
=&\frac{x-x'}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}\vec{i}+\frac{y-y'}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}\vec{j}\\
&+\frac{z-z'}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}\vec{k}\\
=&\frac{(x-x')\vec{i}+(y-y')\vec{j}+(z-z')\vec{k}}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}\\
=&\frac{\vec{r}}{r}
\end{align*}\normalsize
\[
\therefore\nabla r=-\nabla'r=\frac{\vec{r}}{r}
\]
\subsection{}
\[
\nabla\frac{1}{r}=-\nabla'\frac{1}{r}=-\frac{\vec{r}}{r^3}
\]
\textbf{pf:}
\footnotesize\begin{align*}
\nabla\frac{1}{r}=&\frac{\partial\frac{1}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}}{\partial x}\vec{i}+\frac{\partial\frac{1}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}}{\partial y}\vec{j}\\
&+\frac{\partial\frac{1}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}}{\partial z}\vec{k}\\
=&-\frac{x-x'}{[(x-x')^2+(y-y')^2+(z-z')^2]^{\frac{3}{2}}}\vec{i}-\frac{y-y'}{[(x-x')^2+(y-y')^2+(z-z')^2]^{\frac{3}{2}}}\vec{j}\\
&-\frac{z-z'}{[(x-x')^2+(y-y')^2+(z-z')^2]^{\frac{3}{2}}}\vec{k}\\
=&-\frac{(x-x')\vec{i}+(y-y')\vec{j}+(z-z')\vec{k}}{[(x-x')^2+(y-y')^2+(z-z')^2]^{3/2}}\\
=&-\frac{\vec{r}}{r^3}
\end{align*}
\begin{align*}
-\nabla'\frac{1}{r}=&-\frac{\partial\frac{1}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}}{\partial x'}\vec{i}-\frac{\partial\frac{1}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}}{\partial y'}\vec{j}\\
&-\frac{\partial\frac{1}{\sqrt{(x-x')^2+(y-y')^2+(z-z')^2}}}{\partial z'}\vec{k}\\
=&-\frac{x-x'}{[(x-x')^2+(y-y')^2+(z-z')^2]^{\frac{3}{2}}}\vec{i}-\frac{y-y'}{[(x-x')^2+(y-y')^2+(z-z')^2]^{\frac{3}{2}}}\vec{j}\\
&-\frac{z-z'}{[(x-x')^2+(y-y')^2+(z-z')^2]^{\frac{3}{2}}}\vec{k}\\
=&-\frac{(x-x')\vec{i}+(y-y')\vec{j}+(z-z')\vec{k}}{[(x-x')^2+(y-y')^2+(z-z')^2]^{3/2}}\\
=&-\frac{\vec{r}}{r^3}
\end{align*}\normalsize
\[
\therefore\nabla\frac{1}{r}=-\nabla'\frac{1}{r}=-\frac{\vec{r}}{r^3}
\]
\subsection{}
\[
\nabla\times\frac{\vec{r}}{r^3}=0
\]
\textbf{pf:}
\begin{align*}
\nabla\times\frac{\vec{r}}{r^3}=&(\nabla\frac{1}{r^3})\times\vec{r}+\frac{1}{r^3}\nabla\times\vec{r}\\
\end{align*}
where
\begin{align*}
\nabla\frac{1}{r^3}=&\frac{\partial\frac{1}{[(x-x')^2+(y-y')^+(z-z')^2]^{3/2}}}{\partial x}\vec{i}+\frac{\partial\frac{1}{[(x-x')^2+(y-y')^+(z-z')^2]^{3/2}}}{\partial y}\vec{j}\\
&+\frac{\partial\frac{1}{[(x-x')^2+(y-y')^+(z-z')^2]^{3/2}}}{\partial z}\vec{k}\\
=&-\frac{3(x-x')}{[(x-x')^2+(y-y')^+(z-z')^2]^{5/2}}\vec{i}-\frac{3(y-y')}{[(x-x')^2+(y-y')^+(z-z')^2]^{5/2}}\vec{j}\\
&-\frac{3(z-z')}{[(x-x')^2+(y-y')^+(z-z')^2]^{5/2}}\vec{k}\\
=&-3\frac{(x-x')\vec{i}+(y-y')\vec{j}+(z-z')\vec{k}}{[(x-x')^2+(y-y')^+(z-z')^2]^{5/2}}\\
=&-\frac{3\vec{r}}{r^5}
\end{align*}
and
\begin{align*}
\nabla\times\vec{r}=&(\frac{\partial(z-z')}{\partial y}-\frac{\partial(y-y')}{\partial z})\vec{i}+(\frac{\partial(x-x')}{\partial z}-\frac{\partial(z-z')}{\partial x})\vec{j}+(\frac{\partial(y-y')}{\partial x}-\frac{\partial(x-x')}{\partial y})\vec{k}\\
=&\vec{0}
\end{align*}
Therefore,
\begin{align*}
\nabla\times\frac{\vec{r}}{r^3}=&-3\frac{\vec{r}}{r^5}\times\vec{r}+\vec{r}\\
=&\vec{0}
\end{align*}
\subsection{}
\[
\nabla\cdot\frac{\vec{r}}{r^3}=-\nabla'\cdot\frac{\vec{r}}{r^3}=0
\]
\textbf{pf:}
\begin{align*}
\nabla\cdot\frac{\vec{r}}{r^3}=&(\nabla\frac{1}{r^3})\cdot\vec{r}+\frac{1}{r^3}\nabla\cdot\vec{r}\\
=&-\frac{3\hat{r}}{r^4}\cdot\vec{r}+\frac{3}{r^3}\\
=&0
\end{align*}
where
\[
\nabla\frac{1}{r^3}=-\frac{3\vec{r}}{r^5}
\]
and
\[
\nabla\cdot\vec{r}=\frac{\partial(x-x')}{\partial x}+\frac{\partial(y-y')}{\partial y}+\frac{\partial(z-z')}{\partial z}=3
\]
So we have
\begin{align*}
\nabla\cdot\frac{\vec{r}}{r^3}=&-\frac{3\hat{r}}{r^5}\cdot\vec{r}+\frac{3}{r^3}\\
=&0
\end{align*}
Similarly,
\begin{align*}
-\nabla'\cdot\frac{\vec{r}}{r^3}=&-(\nabla'\frac{1}{r^3})\cdot\vec{r}-\frac{1}{r^3}\nabla'\cdot\vec{r}\\
=&-\frac{3\hat{r}}{r^5}\cdot\vec{r}+\frac{3}{r^3}\\
=&0
\end{align*}
Therefore,
\[
\nabla\cdot\frac{\vec{r}}{r^3}=-\nabla'\cdot\frac{\vec{r}}{r^3}=0
\]
\section{}
Show that the interaction between two fixed current loops obeys Newton's third law.

\textbf{pf:} Suppose the two fixed current loops are marked as $1$ and $2$ respectively.
The Ampere force on a short part of the current loop $2$ is
\[
d\vec{F}_{12}=I_2d\vec{l}_2\times\vec{B}_1=I_2d\vec{l}_2\times(\frac{\mu_0}{4\pi}\oint_{L_1}\frac{I_1d\vec{l}_1\times\vec{r}_{12}}{r_{12}^3})
\]
The total Ampere force on the current loop $2$ is
\begin{align*}
F_{12}=&\oint_{L_2}d\vec{F}_2=\frac{\mu_0I_1I_2}{4\pi}\oint_{L_2}\oint_{L_1}\frac{d\vec{l}_2\times(d\vec{l}_1\times\vec{r}_{12})}{r_{12}^3}\\
=&\frac{\mu_0I_1I_2}{4\pi}\oint_{L_2}\oint_{L_1}\frac{(d\vec{l}_2\cdot\vec{r}_{12})d\vec{l}_1-(d\vec{l}_2\cdot d\vec{l}_1)\vec{r}_{12}}{r_{12}^3}
\end{align*}
where
\begin{align*}
\oint_{L_2}\oint_{L_1}\frac{(d\vec{l}_2\cdot\vec{r}_{12})d\vec{l}_1}{r_{12}^3}=&\oint_{L_1}d\vec{l}_1\oint_{L_2}\frac{\vec{r}_{12}\cdot d\vec{l}_2}{r_{12}^3}\\
=&\oint_{L_1}d\vec{l}_1\iint_{S_2}\nabla\times(\frac{\vec{r}_12}{r_{12}^3})\cdot d\vec{S}_2\\
=&\oint_{L_1}d\vec{l}_1\iint_{S_2}\vec{0}\cdot d\vec{S}_2=0
\end{align*}
So we have
\[
F_{12}=-\frac{\mu_0I_1I_2}{4\pi}\oint_{L_2}\oint_{L_1}\frac{(d\vec{l}_2\cdot d\vec{l}_{1})\vec{r}_{12}}{r_{12}^3}
\]
Similarly, the Ampere force on  current loop $1$ is
\[
F_{21}=-\frac{\mu_0I_2I_1}{4\pi}\oint_{L_1}\oint_{L_2}\frac{(d\vec{l}_1\cdot d\vec{l}_2)\vec{r}_{21}}{r_{21}^3}=\frac{\mu_0I_1I_2}{4\pi}\oint_{L_2}\oint_{L_1}\frac{(d\vec{l}_2\cdot d\vec{l}_{1})\vec{r}_{12}}{r_{12}^3}
\]
Therefore,
\[
\vec{F}_{12}=-\vec{F}_{21}
\]
which means the interaction between two fixed current loops obeys Newton's third law.
\section{}
Use the equation below to find the related equation for the conduction current $\vec{J}=n_fe\vec{v}$. Solve this equation for $\vec{E}(t)=\vec{E}_0\delta(t)$ if $\vec{J}(t<0)=0$. What is $\vec{J}$ immediately after $t=0$? Connect this with the sum rule.
\[
\frac{d\vec{v}}{dt}=-\gamma\vec{v}+\frac{e}{m}\vec{E}
\]
\textbf{Sol}: Multiply both side of the equation with $e^{\gamma t}$ and move the items with $\vec{v}$ to the left side to get
\begin{align*}
&e^{\gamma t}\frac{d\vec{v}}{dt}+\gamma e^{\gamma t}\vec{v}=\frac{e}{m}e^{\gamma t}\vec{E}\\
\Longrightarrow&\frac{d(e^{\gamma t}\vec{v})}{dt}=\frac{e}{m}e^{\gamma t}\vec{E}
\end{align*}
Integrate both side of the equation about $t$ from $-\infty$ to $t$ to get
\begin{align*}
&e^{\gamma t}\vec{v}(t)=\frac{e}{m}\int_{-\infty}^{t}e^{\gamma\tau}\vec{E}(\tau)d\tau\\
\Longrightarrow&\vec{v}(t)=\frac{e}{m}\cdot e^{-\gamma t}\int_{-\infty}^{t}e^{\gamma\tau}\vec{E}(\tau)d\tau
\end{align*}
The related equation for the conduction current is
\[
\vec{J}(t)=n_fe\vec{v}(t)=\frac{n_fe^2}{m}\cdot e^{-\gamma t}\int_{-\infty}^{t}e^{\gamma\tau}\vec{E}(\tau)d\tau
\]
The electricity density immediately after $t=0$ is
\[
\vec{J}(0^+)=\frac{n_fe^2}{m}\cdot e^{-\gamma t}\int_{-\infty}^{0^+}e^{\gamma\tau}E_0\delta(\tau)d\tau=\frac{n_fe^2E_0}{m}
\]
\end{document}


% This is a model template for the solutions in computational science. You can find a very useful documentation for LaTeX in Finnish at ftp://ftp.funet.fi/pub/TeX/CTAN/info/lshort/finnish/ or in English at ftp://ftp.funet.fi/pub/TeX/CTAN/info/lshort/english/. The section List of mathematical symbols in Chapter 3 is especially useful for the typesetting of mathematical formulas.

% Compile the document to PDF by command 'pdflatex model.tex' in the terminal. The command must be run twice for the references in the text to be correct.

\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
% This includes letters such as � and �
\usepackage[T1]{fontenc}
% Use here 'Finnish' for Finnish hyphenation. You may have to compile the code twice after the change.
\usepackage[english]{babel}
\usepackage{graphicx}
% Some math stuff
\usepackage{amsmath,amsfonts,amssymb,amsbsy,commath,booktabs,hyperref}
% This is just to include the urls
\usepackage{hyperref}
\usepackage[margin=2cm]{geometry}

\setlength{\parindent}{0mm}
\setlength{\parskip}{1.0\baselineskip}

\usepackage{listings}
\usepackage{color}
\usepackage{pdfpages}

\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\lstset{frame=tb,
	language=Python,
	aboveskip=3mm,
	belowskip=3mm,
	showstringspaces=false,
	columns=flexible,
	basicstyle={\tiny\ttfamily},
	numbers=none,
	numberstyle=\tiny\color{gray},
	keywordstyle=\color{blue},
	commentstyle=\color{dkgreen},
	stringstyle=\color{mauve},
	breaklines=true,
	breakatwhitespace=true,
	tabsize=4
}

\begin{document}

\title{Becs-114.1100 Computational Science -- exercise round 6} % Replace the exercise round number
\author{Kunal Ghosh, 546247} % Replace with your name and student number
\maketitle
\section{Solution to Question 4}
\subsection{Determining the natural cubic interpoland S(x) and its Derivative S'(x) from experimental data}\label{prob2a}
\begin{figure}[ht]
	\center
    \includegraphics[scale=0.75]{plotS.png}
    \caption{Plot showing the natural cubic interpoland S(X). Values of $S(X_i)$ for $X_i$ in the range of (min(knot values), max(knot values)) are shown as red circles.}
	\label{fig:s}
\end{figure}
\begin{figure}[ht]
	\center
    \includegraphics[scale=0.75]{plotS_dash.png}
    \caption{Plot showing the first derivative of the natural cubic interpoland S'(X). Values of $S'(X_i)$ for $X_i$ in the range of (min(knot values), max(knot values)) are shown as red circles.}
	\label{fig:sdash}
\end{figure}

% \begin{table}[ht]
% \centering
% \label{my-label}
% \begin{tabular}{|c|c|c|}
% \hline
%  \textbf{n}&\textbf{RMS Error}&\textbf{Condition Number}  \\ \hline
%  2&0.73833521&15.0167409881  \\ \hline
%  5&1.02602254&282901.77002 \\ \hline
%  8&1.09505307&7657562245.89 \\ \hline
%  12&1.16783884&5.89342127254e+15 \\ \hline
%  15&2.11656192&1.74359790918e+17 \\ \hline
% \end{tabular}
% \caption{Table showing the values of n and the RMS error after solving the system of linear equations with \textbf{hilbert(n)} as the coefficients.}
% \end{table}
The corresponding python code can be found at \ref{code:problem2a}

\subsection{Determining the natural cubic interpoland S(x) and its Derivative S'(x) from experimental data}\label{prob2b}
\begin{figure}[ht]
	\center
    \includegraphics[scale=0.75]{matlabS.png}
    \caption{Plot showing the natural cubic interpoland S(X) as calculated using Matlab. Values of $S(X_i)$ for $X_i$ in the range of (min(knot values), max(knot values)) are shown as red circles.}
	\label{fig:smatlab}
\end{figure}
\begin{figure}[ht]
	\center
    \includegraphics[scale=0.75]{matlabS_dash.png}
    \caption{Plot showing the first derivative of the natural cubic interpoland S'(X) as calculated using Matlab. Values of $S'(X_i)$ for $X_i$ in the range of (min(knot values), max(knot values)) are shown as red circles.}
	\label{fig:sdash_matlab}
\end{figure}
The corresponding plots created by matlab are much more smoother because matlab implements an additional constraint that the third derivatives of the piecewise polynomials are also equal at the second and the last knots. This are apparently called the "Not-A-Knot" end conditions. This is only done when the length of \textbf{t} and \textbf{y} are same.

Natural splines are a good choice only when the functions have 0 second derivative at the end points. I read it up from here. \url{http://www.mathworks.com/matlabcentral/newsreader/view_thread/172988} would really appreciate some more information about why using the Not-A-Knot condition is better.
\\
The corresponding matlab code can be found at \ref{code:problem2b}
\clearpage

\section{Appendix A}\label{code:problem2a}
Python source code for \ref{prob2a}.
{\footnotesize
\begin{lstlisting}
from __future__ import division
import numpy as np
import pylab as pl
import string

def get_data(filename):
    retVal = None
    with open(filename) as f:
        retVal = f.readlines()
        retVal = map(string.strip, retVal)
        retVal = map(string.split, retVal)
        retVal = zip(*retVal)
        # Assuming data just has columns of floats
        for idx,_ in enumerate(retVal):
            retVal[idx] = map(float, retVal[idx])
    return retVal

def evaluate(t,y,z,x):
    i = -1
    for idx in range(len(t)-1):
        if x - t[idx] <= 0:
            i = idx
            break
    # Reduce the number of list accesses
    yi = y[i]
    ti = t[i]
    zi = z[i]
    zi1 = z[i+1]
    hi = t[i+1] - ti
    # Evaluate the value of Spline at x
    Bi = -(hi*zi1)/6 -(hi*zi)/3 +(y[i+1]-yi)/hi
    #Common product being used in Ai and Ai_dash
    Ai_dash_common = (x-ti)*(zi1-zi)
    Ai = 0.5*zi + (1/(6*hi))*Ai_dash_common
    Ri = Bi+(x-ti)*Ai
    S = yi + (x-ti)*Ri
    #Calculating the derivative now
    Ai_dash = zi + (0.5/hi)*Ai_dash_common
    S_dash = Bi + (x-ti)*Ai_dash
    return S,S_dash

if __name__ == "__main__":
    t,y = get_data("titanium.dat")
    h = [t[i+1] - t[i] for i in range(len(t)-1)]
    b = [(1/h[i])*(y[i+1]-y[i]) for i in range(len(t)-1)]
    u = [2*(h[0]+h[1])]
    v = [6*(b[1]-b[0])]
    # intermediate points
    for i in range(1,len(y)-1):
        u.append(2*(h[i]+h[i-1]) - (h[i-1]*h[i-1])/u[i-1])
        v.append(6*(b[i] - b[i-1]) - (h[i-1]*v[i-1])/u[i-1])
    z = np.zeros(len(y))
    try:
        for i in range(len(y)-2,0,-1):
            z[i] = (v[i] - h[i]*z[i])/u[i]
    except Exception,e:
        print i,len(y),len(z),len(v),len(u)

    minx,maxx = min(t),max(t)
    x_range = np.linspace(minx,maxx,100)
    S,S_dash = zip(*[evaluate(t,y,z,x) for x in x_range])

    pl.figure()
    pl.plot(x_range,S)
    pl.scatter(x_range,S,c="r")
    pl.grid()
    pl.xlabel("x")
    pl.ylabel("S(x)")
    pl.savefig("plotS.png")
    pl.figure()
    pl.plot(x_range,S_dash,c="b")
    pl.scatter(x_range,S_dash,c="r")
    pl.grid()
    pl.xlabel("x")
    pl.ylabel("S'(x)")
    pl.savefig("plotS_dash.png")
    pl.show()
    pl.close()
\end{lstlisting}
}
\clearpage

\section{Appendix B}\label{code:problem2b}
Matlab source code for \ref{prob2b}.
{\footnotesize
\begin{lstlisting}
% Getting the data
a = load('titanium.dat')
y = a(:,2)
t = a(:,1)
x = linspace(min(t),max(t),100)

% Calculating and Plotting the spline
plot(x,spline(t,y,x))
hold on
scatter(x,spline(t,y,x),'red')
xlabel('X')
ylabel('S(X)')

% Now Calculating and Plotting derivative of the Spline
f = fnder(spline(t,y))
fnplt(fnder(spline(t,y)))
hold on
scatter(x,ppval(f,x),'r')
xlabel('x')
ylabel('S'(x)')
\end{lstlisting}
}
\end{document}


\section{Contour Integration of a Complex-valued Function}
\textit{(This problem is probably out of reach for students who not yet taken a course in complex analysis. No worries, we will cover this topic during the first few weeks of Math 583A.)}\\

\noindent Consider the functions $f:\mathbb{C} \to \mathbb{C}$ and $g:\mathbb{C} \to \mathbb{C}$ defined as
\begin{equation*}
f(z) = z^2 \quad \quad \text{and} \quad \quad g(z) = z^{-1}
\end{equation*}
In this project, you will write a first-order numerical approximation scheme to compare the integrals of $f$ and of $g$ along two different contours.
\begin{enumerate}[(a)]
    \item Plotting:
    \begin{enumerate}[i.]
        \item Make a surface plot showing $Re(f(z))$ and a surface plot showing $Im(f(z))$
        \item Make a surface plot showing $Re(g(z))$ and a surface plot showing $Im(g(z))$
    \end{enumerate}
    \textit{Since $g$ is undefined at $z = 0$ and since it is radially symmetric, the surface plots for $g$ can look scary when done in cartesian co-ordinates. You may try switching to polar coordinates to make prettier plots}
    \item     We can approximate the line integral (or contour integral) of a function along a curve by discretizing the curve into $N+1$ points $z(s) \to \{z_0, z_1, z_2, \dots, z_N\}$ and then computing the sum:
    \begin{equation*}
    \int_{z_o}^{z_t} f(z) dz \approx \sum_{k = 1}^{N} f(z_k) \ (z_{k} - z_{k-1})
    \end{equation*}
    \begin{minipage}{.7\textwidth}
    Define the two curves:
    \begin{align*}
    C_1:&  \quad \text{The upper half circle of radius 1 centered at $z=0$.}\\
    C_2:&  \quad \text{The lower half circle of radius 1 centered at $z=0$.}
    \end{align*}
    Approximate the line integrals of $f$ and of $g$ along the curves $C_1$ and $C_2$.
    \end{minipage}
    \begin{minipage}{.29\textwidth}
    \begin{center}
    \begin{tikzpicture}
    \draw[ultra thick,->] (-1.2,0) -- (2.2, 0) node[below] {$Re(z)$};
    \draw[ultra thick,->] (0,-1.2) -- (0,1.6) node[left] {$Im(z)$};
    \draw[thick,blue!80!black,domain = 175:10,variable=\t,->] plot ({cos(\t)},{ sin(\t)}) node[above right] {$C_1$};
    \draw[thick,red!80!black,domain = 185:350,variable=\t,->] plot ({cos(\t)},{ sin(\t)}) node[below right] {$C_2$};
    \end{tikzpicture}
    \end{center}
    \end{minipage}
    \item[($\ast$)] \textit{Bonus:} Repeat parts (a) and (b) for the function $h(z) = z^{1/2}$.\\
    \textit{Note:} You may need to make some `executive decisions' to make sure your problem is well-posed.
\end{enumerate}


\subsection{Affine connections}

If we have a tangent vector at one point of the manifold, we can map it to a tangent vector at a nearby point on the manifold.

We can use chain rule. so we can have coordinate maps where there is no overlap.

\subsubsection{Smooth connections}

\subsubsection{Affine connection}

We have a vector in a tangent space

We have a curve on the manifold from the start point

As we "roll" the tangent, there is a unique vector in each new tangent, determined by transition map

These are affine transformations

Given two points, what path? what transfomration? if curuved then different paths will given different transformation.


% corrected LN 86
\subsubsection{Implementation of classification models}\label{implementation}~\\

In this section, the implementation of the four ANN models are presented.\\

First of all, we initialize the training and testing sets:
\lstinputlisting{sections/technical/fr1/input.py}

\begin{enumerate}[label=\arabic*.]
  \item Feedforward neural networks:
    \lstinputlisting{sections/technical/fr1/feedforward.py}
    The sequential model is used to stack four \textit{Dense} layers, which are
    fully connected layers, meaning that all neurons in one layer are connected
    to all neurons in the subsequent layer. This model is composed of one input
    layer, two hidden layers and one output layer. The first dense layer takes
    as input a vector with the same dimensions as a row in the dataset. The
    first three layers are using \textit{ReLU} as activation function whereas
    the output layer is using \textit{softmax}, which is a standard choice for
    multi-class classification problems. In between the dense layers, dropout
    layers are stacked. These dropout layers are dropping units from the model
    to prevent overfitting. The parameter \textit{loss} of the
    \textit{.compile()} function is set to
    \textit{'sparse\_categorical\_crossentropy'} since the output should be an
    integer tensor instead of a binary vector.\\

  \begin{normalize}
    Before continuing with the recurrent models, the input data has to be
    reshaped since RNN, LSTM and GRU are taking in 3D shaped input data:

    \lstinputlisting{sections/technical/fr1/inputchange.py}
  \end{normalize}

  \item RNN:
    \lstinputlisting{sections/technical/fr1/rnn.py}
    The RNN model is implemented in the same manner as the feedforward model.
    Although, this model is only stacked with one hidden layer.  Instead of
    using dense layers, this model uses \textit{SimpleRNN} layers.  The
    parameter \textit{return\_sequences} is set to \textit{True} so that the
    next simpleRNN layer has access to all the hidden states from the previous
    layer.  The output layer is again a dense layer with \textit{softmax} as the
    activation function. As input, it takes in a matrix, which is an instance of
    the 3D dataset.~\\

\newpage

  \item LSTM:
    \lstinputlisting{sections/technical/fr1/lstm.py}
    The LSTM model uses \textit{LSTM} layers and is composed of one hidden layer
    as well. Its parameter \textit{return\_sequences} is set to \textit{True}
    with the same reason as for the RNN model. The LSTM model has the same
    output layer as the two previous ones.\\
  \item GRU:
    \lstinputlisting{sections/technical/fr1/gru.py}
    The GRU model uses \textit{GRU} layers and is composed of one hidden layer.
    Its parameters are set to the same values as the RNN and LSTM model. It uses
    the same dense layer activated by the \textit{softmax} function as output
    layer.
\end{enumerate}


\appendixpage
\begin{appendix}
\section{Mathematical notation}
\label{sec:notation}
In this paper, there is extensive use of mathematical notation following some union of standards from various fields of mathematics. What follows is an attempt to define as much of this jargon as possible, such that a reader with a moderate background in the field could be reminded of its meaning.

%\newcommand{\braces}[1]{\ensuremath{\left\lbrace #1 \right\rbrace}}
%\newcommand{\angles}[1]{\ensuremath{\left\langle #1 \right\rangle}}
%\newcommand{\integers}{\ensuremath{\mathbb{Z}}}
%\newcommand{\wholes}{\ensuremath{\mathbb{N}}}
%\newcommand{\reals}{\ensuremath{\mathbb{R}}}
%\renewcommand{\vec}{\mathbf}
%\newcommand{\abs}[1]{\ensuremath{\left|#1\right|}}

\subsection{Glossary}
\begin{itemize}
\item set: A collection of things. Typically indicated by \braces{\cdot}.
\item tuple: An ordered set of a finite number of elements, typically indicated by \parens{\cdot}. Similar in structure to a vector.
\end{itemize}

\subsection{Variables}
\begin{itemize}
\item $a$: Index of a bin in a histogram.
\item $b$: Time bin as specified by lower and upper bounds. When subscripted, this can indicate bin bounds or reference the bin by index (made clear by context).
\item $\channel$: Detection channel, typically represented by some whole number.
\item $\channels$: The set of all detection channels in an experiment.
\item $\Channel$: Function of a photon which returns the detection channel the photon arrived on.
\item $\delta$: A change in some variable.
\item $\resolution$: Time resolution of a detection channel.
\item $f$: Frequency.
\item $\gn{n}$: Correlation function of $n$th order.
\item $\photon$: Photon, a tuple consisting of a detection channel and some number of arrival time properties.
\item $\photons$: The set of all photons in an experiment. A subscript typically indicates some subset, such as photons on a detection channel or in some specified time window.
\item $\Index$: Function returning the index of a histogram, given the set of channels and a tuple of elements of that set.
%\item $\Histogram$: The histogram function, which accepts bin definitions and outputs the counts in those bins.
%\item $\iota$: A ``real'' physical signal being sampled in an experiment.
\item $I$: Signal, a real-valued function of time.
\item $n$: The order of a correlation.
%\item $N$: The number of elements in a set, the length of a stream or vector, or the number of detection channels.
\item $p$: Pulse number.
\item $\Pulse$: Function of a photon which returns the pulse the photon arrived after.
\item $\rho$: Pulse delay.
\item $t$: Time.
\item $\Time$: Function of a photon which returns the arrival time of the photon.
\item $\timedelay$:  Time delay.
\item $\timewindow$: Time window, some subset of time in the experiment.
\item $\integrationtime$: Integration time for the experiment.
%\item $\emptyset$: The empty set, or a lack of a value.
\end{itemize}

\subsection{Sets}
\begin{itemize}
\item $\cap$ ($\bigcap$): Intersection of two (some number of) sets.
\item $\cup$ ($\bigcup$): Union of two (some number of) sets.
\item $\in$: Inclusion, indication that an element is a member of a set.
\item $\abs{\cdot}$: Magnitude of a scalar or vector, or the number of elements in a set.
\item $\max,\min$: The maximum or minimum elements of a set, given some rule for sorting made clear explicitly or by context.
\item $\subset$: The set on the left is a proper subset of the set on the right: its members are elements of the right-hand set, but the two sets are not equal.
\item $\subseteq$: The set on the left is a subset of the set on the right: its members are elements of the right-hand set, and the two sets may be equal.
\end{itemize}

\subsection{Named sets}
There are a number of important sets which arise frequently in this paper:
\begin{itemize}
\item \reals: The set of all real numbers
\item \integers: The set of all integers (\braces{\ldots-1,0,1,\ldots}).
\item \wholes: The set of all positive integers, and zero (\braces{0,1,\ldots}).
\end{itemize}
Additionally, there are modifiers used to indicate special subsets:
\begin{itemize}
\item $\cdot^{*}$: As a superscript, this indicates that the set only contains non-negative numbers. For example, $\reals^{*}$ contains all elements $x$ such that $\abs{x}=x$.
\item $\cdot^{+}$: As a superscript, this indicates that the set only contains positive numbers.
\item $\cdot_{n}$: As a subscript, this indicates a cyclic group of order $n$. For example, $\integers_{n}=\braces{0,1,\ldots,n-1}=\integers/n$.
\end{itemize}

\subsection{Set builder notation}
Frequently, this paper contains expressions in the following form:
\begin{equation}
\photons_{\channel}=\braces{\photon\left|\photon\in\photons;~\Channel(\photon)=\channel\right.}
\end{equation}
To read this notation, start left of the pipe to see what elements of the set look like. In this case, all elements are photons (\photon). To the right side of the pipe are the properties these elements must have, that the photon exists in the set \photons{} of photons, and that its arrival channel is $c$.

Other examples of this notation include:
\begin{align}
\reals^{*} &= \setbuilder{x}
                        {x\in\reals; \abs{x}=x} \\
\rationals &= \setbuilder{(p,q)}
                        {p\in\integers;~q\in\integers^{+}} \\
A\times B &= \setbuilder{(a,b)}
                       {a\in A;~b\in B}
\end{align}

\subsection{Ranges}
Square brackets and parentheses are used to indicate some continuous subset of values of a set. For example, the real numbers between 0 and 1, including 0 and 1, are denoted
\begin{equation}
\brackets{0,1} = \setbuilder{x}{x\in\reals;~x\ge 0;~x\le 1}
\end{equation}
To indicate that one of the endpoints is not included in the set, a parenthesis is used:
\begin{equation}
\left[0,1\right) = \setbuilder{x}{x\in\reals;~x\ge 0;~x<1}
\end{equation}
The source set is typically made clear by context.

\subsection{Other functions and relations}
\begin{itemize}
\item \angles{\cdot}: Average of the bracketed quantity over some variable or number of variables.
\item $\times$: Cartesian product of two sets.
\item $\sum$: Sum of some number of quantities.
\item $\prod$: Product of some number of quantities.
\item $\leftarrow,\rightarrow$: Assignment of some value to a variable, or association in a function.
\item $\ceil{\cdot}$: The smallest integer at least as large as the indicated quantity.
\item $\abs{\cdot}$: Magnitude of a scalar or vector, or the number of elements in a set.
\item $\equiv$: Indicates two quantities are equivalent. Typically used to denote a change in notation.
\item $\propto$: Indicates proportionality; the two sides of the relation are equal upon multiplication of one side by some scalar factor, which could be unity.
\end{itemize}

\section{C API Documentation}

\input{versions.tex}

\end{appendix}


This chapter is dedicated to describing the Filtered Poisson Process (FPP), a stochastic model used for describing the intermittent fluctuations in single point measurements obtained in the boundary of fusion experiments. The basis of this model was already developed in 1909 \cite{campbell1909study} and was further extended in the 1940s to describe noise in vacuum tubes \cite{rice1944mathematical,rice1945mathematical}. Since then, the model has been extended and used to describe fluctuations in numerous academic fields, including neuroscience, fluid dynamics and nuclear fission
\cite{segal1985miniature,fesce1986fluctuation,jang2004martingale,claps2005advances,lefebvre2008generalized,daly2010effect,elter2015performance}. The FPP has first been introduced as a model describing SOL fluctuations in 2012 \cite{garcia2012stochastic} and has since then shown excellent agreement with the statistical properties of fluctuations in various fusion experiments \cite{garcia2013intermittent,garcia2013burst,garcia2015intermittent,kube2016fluctuation,garcia2017sol,kube2018intermittent,garcia2018intermittent,theodorsen2018universality}.

\section{Filtered Poisson Process}
The FPP is a stochastic process, given by a superposition of uncorrelated pulses which are distributed according to a Poisson process. For a given time $t \in [0,T]$ the process $\Phi_k(t)$ can be written as \cite{garcia2012stochastic,garcia2016stochastic}
\begin{equation}
	\Phi_k(t) = \sum_{k=1}^{K(T)} A_k \,\phi\left(\frac{t-t_k}{\tau_\mathrm{d}}\right).
\end{equation}
Here, the random variables are defined as follows: $K(T)$ stands for the number of pulses arriving in the time interval $[0,T]$, $A_k$ is the pulse amplitude and $t_k$ the pulse arrival time. It is further assumed that all pulses have the same pulse  shape $\phi$ and duration time $\tau_\mathrm{d}$.

Alternatively, the process can be expressed as a convolution of the pulse shape and a delta pulse train
\begin{equation}\label{conv}
	\Phi_k(t) = [\phi * f_K] \left(\frac{t}{\tau_\mathrm{d}}\right),
\end{equation}
where $f_K$ is the forcing defined as a train of delta pulses
\begin{equation}
	f_K(\theta) = \sum_{k=1}^{K(T)} A_k \,\delta\left(\theta - \frac{t_k}{\tau_\mathrm{d}}\right).
\end{equation}
As the process can be expressed as a train of delta pulses filtered through the pulse shape, it is called a \textit{Filtered Poisson Process}.

For a given time interval $[0,T]$, the number of pulses $K(T)$ follows a Poisson distribution \begin{equation}
	P_K(K|T) = \frac{1}{K!} \left(\frac{T}{\tau_\mathrm{w}}\right)^K \textrm{exp}\left(-\frac{T}{\tau_\mathrm{w}}\right),
\end{equation}
with intensity $T/\tau_\mathrm{w}$. The waiting times between two consecutive pulses are independent and exponentially distributed with mean value $\tau_\mathrm{w}$ and the arrival times $t_k$ are independent and uniformly distributed in the interval $[0,T]$. These properties of the process are consistent with experimental measurements, showing exponentially distributed waiting times \cite{garcia2015intermittent,kube2018intermittent,garcia2017sol,garcia2018intermittent}. Time series with quasi-periodic arrival times are observed in SOL simulations utilizing Rayleigh–Bénard like convection models \cite{decristoforo2020intermittent} and are discussed in Paper II in further detail. The amplitudes are chosen to be exponentially distributed, as this is observed in experimental measurements \cite{kube2018intermittent,garcia2017sol,garcia2018intermittent}.

In the following, we will discuss two pulse shapes that are most relevant for SOL fluctuation measurements and corresponding numerical simulations. Firstly, the pulse shape of an asymmetric, two-sided exponential pulse is defined as
\begin{equation}
	\phi(\theta,\lambda) = \begin{cases} \mathrm{exp}\left(-\frac{\theta}{1-\lambda}\right), &\theta \geq 0,\\
		\mathrm{exp}\left(\frac{\theta}{\lambda}\right), &\theta < 0.
	\end{cases}
\end{equation}
Here, $\theta$ is a dimensionless variable and $\lambda$ stands for the asymmetry parameter with $\lambda \in (0,1)$. In some cases, a one-sided exponential pulse is applied with $\lambda = 0$, which refers to the limit $\lim_{\lambda\to 0} \phi(\theta,\lambda)$. Exponential pulses stand in good agreement with experimental measurements \cite{antar2003universality,boedo2005edge,garcia2007fluctuations,garcia2007collisionality,garcia2013intermittent,garcia2015intermittent,garcia2017sol,kube2018intermittent,garcia2018intermittent} and numerical SOL simulations \cite{garcia2007fluctuations,decristoforo2021numerical}.  Secondly, Lorentzian pulses are considered which are defined as
\begin{equation}
	\psi(\theta) = \frac{1}{\pi}\frac{1}{1+\theta^2}.
\end{equation}
These can also be generalized to a skewed Lorentzian, however no closed analytical form is known and require a definition via the inverse Fourier transform \cite{garcia2018skewed}. Indications for Lorentzian pulses in time series in the edge region \cite{maggs2011generality,van2012relevance,maggs2015chaotic,zhu2017chaotic} and corresponding numerical simulations \cite{decristoforo2020intermittent} have been reported. Exponential pulses consist of a discontinuous peak and exponential tales, whereas Lorentzian pulses have a smooth peak and algebraic tails. The consequences of these properties will be apparent in the following discussions.

Calculating moments of distributions of the process requires the integrals of the pulse shapes, defined as
\begin{equation}
	I_n = \int_{-\infty}^{\infty} d\theta [\phi(\theta)]^n.
\end{equation}
For exponential pulses this results in $I_{\phi,n} = 1/n$, independent of the pulse asymmetry $\lambda$. For Lorentzian pulses the first four integrals are given by $I_{\psi,1} = 1$, $I_{\psi,2} = 1/2\pi$, $I_{\psi,3} = 3/8\pi^2$ and $I_{\psi,4} = 5/16\pi^3$.

The main property of the FPP is given by the ratio of the pulse duration and average waiting time,
\begin{equation}
	\gamma = \frac{\tau_\mathrm{d}}{\tau_\mathrm{w}},
\end{equation}
which is referred to as the intermittency parameter. For short waiting times and long duration times, $\gamma \gg 1$, the level of pulse overlap is high, resulting in a large mean value and small relative variation around the mean. In the opposite limit, $\gamma \ll 1$, the signal is dominated by individual, isolated pulses, resulting in a small mean value and large relative fluctuations. Numerical realizations of the FPP with different intermittency parameters are shown for one-sided exponential pulses in \Figref{Fig:garcia_realizations} and for symmetric Lorentzian pulses in \Figref{Fig:garcia_realizations_lorentz} displaying the features of these processes.
\begin{figure}
	\centering
	\begin{minipage}{.48\linewidth}
		\includegraphics[width=\linewidth]{figures/garcia_realizations.png}
		\caption{Realizations of the FPP with one-sided exponential pulses and different intermittency parameters. Reprinted from \cite{garcia2016stochastic}, with the permission from AIP Publishing.}
		\label{Fig:garcia_realizations}
	\end{minipage}
	\hfill
	\begin{minipage}{.48\linewidth}
		\includegraphics[width=\linewidth]{figures/garcia_lorentz.png}
		\caption{Realizations of the FPP with Lorentzian pulses and different intermittency parameters. Reprinted from \cite{garcia2017power}, with the permission from AIP Publishing.}
		\label{Fig:garcia_realizations_lorentz}
	\end{minipage}
\end{figure}

\section{Moments and PDFs}
The four lowest order central moments of the FPP take the form
\begin{subequations}
	\begin{align}
		\langle\Phi\rangle  &= \gamma \langle A \rangle I_1,\\
		\Phi^2_\mathrm{rms} &= \gamma \langle A^2\rangle I_2,\\
		S_\Phi &= \frac{1}{\gamma^{1/2}}\frac{\langle A^3\rangle I_3}{\langle A^2\rangle^{3/2} I_2^{3/2} },\\
		F_\Phi &= 3 + \frac{1}{\gamma} \frac{\langle A^4\rangle I_4}{\langle A^2\rangle^2 I_2^2},
	\end{align}
\end{subequations}
where $S_\Phi$ stands for the skewness of the process and $F_\Phi$ is the kurtosis or flatness \cite{garcia2012stochastic}. The last two moments exhibit the parabolic relationship
\begin{equation}\label{parabolic}
	F_\Phi = 3 + \frac{\langle A^2\rangle \langle A^4\rangle}{\langle A^3\rangle^2}\frac{I_2 I_4}{I^2_3} S_\Phi^2.
\end{equation}
Inserting the expressions for the integrals of the pulse shapes for two-sided exponential and Lorentzian pulses and assuming exponentially distributed amplitudes simplifies these expressions further. For exponential pulses the expression for the relative fluctuation level becomes
\begin{equation}
	\frac{\Phi_{\mathrm{rms}}}{\langle \Phi\rangle} = \gamma^{-1/2},
\end{equation}
and the universal parabolic relationship of \Eqref{parabolic} reduces to
\begin{equation}
	F_\Phi = 3 + \frac{3}{2} S_\Phi^2,
\end{equation}
which stands in good agreement with experimental measurements \cite{labit2007universal,sattin2009statistics,sattin2009parabolic}. Notably, these expressions do not depend on the pulse asymmetry parameter, $\lambda$.

The PDF of the process with exponential pulses is given by a Gamma distribution with shape parameter $\gamma$ and scale parameter $\langle A \rangle$ \cite{theodorsen2018probability},

\begin{equation}
	P_{\Phi,\phi}(\Phi) = \frac{\Phi^{\gamma-1}}{\langle A\rangle^\gamma \Gamma(\gamma)}\mathrm{exp}\left(-\frac{\Phi}{\langle A\rangle}\right).
\end{equation}
Typically, the realization of the process is normalized to have zero mean and unit standard deviation,
\begin{equation}\label{norm}
	\widetilde{\Phi} = \frac{\Phi - \langle\Phi\rangle}{\Phi_{\mathrm{rms}}},
\end{equation}
with the according PDF \cite{theodorsen2018probability},
\begin{equation}
	P_{\widetilde{\Phi},\phi}(\widetilde{\Phi}) = \frac{\gamma^{\gamma/2}}{\Gamma(\gamma)}\left(\widetilde{\Phi} + \gamma^{1/2} \right)^{\gamma-1}\mathrm{exp}\left(-\gamma^{1/2}\widetilde{\Phi} - \gamma\right).
\end{equation}
This expression is used as a fit in \Figref{Fig:theodorsen_pdf}. For an FPP of Lorentzian pulses no closed expressions for its PDF is known. However, it can be derived by taking the inverse Fourier transform of its corresponding characteristic function resulting in \cite{garcia2018lorentz}
\begin{equation}
	\begin{split}
	P_{\widetilde{\Phi},\psi}(\widetilde{\Phi}) = \left(\frac{\pi}{\gamma}\right)^{1/2}\int_{0}^{\infty}\textrm{d}w\,\mathrm{exp}\left(-\frac{\gamma\pi w\, \mathrm{sin}\left(1/2\, \mathrm{arctan}\, w\right)}{(1+w^2)^{1/4}}\right)\\
	\times \mathrm{cos}\left(\pi\gamma w + \sqrt{\pi\gamma}\widetilde{\Phi}w-\frac{\gamma\pi w\, \mathrm{cos}\left(1/2\, \mathrm{arctan}\, w\right)}{(1+w^2)^{1/4}}\right).
	\end{split}
\end{equation}
For both exponential and Lorentzian pulses the PDF of the processes are characterized by the intermittency parameter. The PDFs are shown for a range of different $\gamma$ in \Figref{Fig:garcia_pdf} and \Figref{Fig:garcia_pdf_lorentz}. The PDFs are unimodal for all values of $\gamma$ and have an exponential tail towards large fluctuation amplitudes for small values of $\gamma$. In the opposite limit, the PDFs approach a normal distribution with vanishing mean and unit standard deviation for $\widetilde{\Phi}$.

\begin{figure}
	\centering
	\begin{minipage}{.48\linewidth}
		\includegraphics[width=\linewidth]{figures/garcia_pdf.png}
		\caption{PDFs of a FPP with exponential pulses with different intermittency parameters $\gamma$. Reprinted from \cite{garcia2016stochastic}, with the permission from AIP Publishing.}
		\label{Fig:garcia_pdf}
	\end{minipage}
	\hfill
	\begin{minipage}{.48\linewidth}
		\includegraphics[width=\linewidth]{figures/garcia_pdf_lorentz.png}
		\caption{PDFs of a normalized FPP with Lorentzian pulses with different intermittency parameters $\gamma$. Reprinted from \cite{garcia2018lorentz}, with the permission from AIP Publishing.}
		\label{Fig:garcia_pdf_lorentz}
	\end{minipage}
\end{figure}
\section{Second order statistics}

In order to calculate the second order moments, namely the power spectral density (PSD) and the Auto-correlation function (ACF), we consider the FPP as a convolution of a pulse train $f_K$ and a pulse shape $\phi$. The Fourier transform of the FPP is given by the product of the Fourier transform of $f_K$ and $\phi$. The power spectrum of $\Phi$ can therefore be expressed as the product of the power spectrum of $f_K$ and $\phi$. The power spectrum of $f_K$ is flat due to the uncorrelated delta pulses, so that the frequency dependence of the spectrum of $\Phi$ is only dependent on $\phi$. The ACF is given by the Fourier transform of the PSD. For two-sided exponential pulses the PSD of an FPP normalized according to \Eqref{norm}, takes the form \cite{garcia2017auto}
\begin{equation}
	\Omega_{\widetilde{\Phi},\phi}(\omega;\lambda) = \frac{2 \tau_\mathrm{d}}{[1+(1-\lambda)^2\tau_\mathrm{d}^2\omega^2][1+\lambda^2\tau_\mathrm{d}^2\omega^2]},
\end{equation}
with the according ACF
\begin{equation}
	R_{\widetilde{\Phi},\phi}(r;\lambda) = \frac{1}{1-2\lambda}\left[\left(1-\lambda\right)\mathrm{exp}\left(-\frac{|r|}{(1-\lambda)\tau_\mathrm{d}}\right) -\lambda\,\mathrm{exp}\left(-\frac{|r|}{\lambda\tau_\mathrm{d}}\right)\right].
\end{equation}
The ACF and PSD are displayed for a range of $\gamma$-values in \Figsref{Fig:garcia_acf} and \ref{Fig:garcia_psd}.
\begin{figure}
	\centering
	\begin{minipage}{.48\linewidth}
		\includegraphics[width=\linewidth]{figures/garcia_acf.png}
		\caption{Auto-correlation function of a normalized FPP consisting of two-sided exponential pulses with different asymmetry parameters $\lambda$. Reprinted from \cite{garcia2017auto}, with the permission from AIP Publishing.}
		\label{Fig:garcia_acf}
	\end{minipage}
	\hfill
	\begin{minipage}{.48\linewidth}
		\includegraphics[width=\linewidth]{figures/garcia_psd.png}
		\caption{Power spectral density of a normalized FPP consisting of two-sided exponential pulses with different asymmetry parameters $\lambda$. Reprinted from \cite{garcia2017auto}, with the permission from AIP Publishing.}
		\label{Fig:garcia_psd}
	\end{minipage}
\end{figure}
In contrast to the PDFs, the second order statistics are independent of $\gamma$ but change for different $\lambda$. In the limits of a one-sided exponential pulse, the ACF is purely exponential and the PSD is Lorentzian shaped. For $\lambda$ close to zero or 1, the spectrum has an intermediate range where the spectrum falls with $\omega^{-2}$ before it falls with $\omega^{-4}$ in the high frequency limit. This expression is in excellent agreement with the experimental measurements shown in \Figref{Fig:theodorsen_psd} with $\lambda=0.1$.

For Lorentzian pulses the PSD of a normalized FPP takes an exponential form \cite{garcia2018skewed}
\begin{equation}
	\Omega_{\widetilde{\Phi},\psi}(\omega) = 2\pi\tau_\mathrm{d}\, \mathrm{exp}\left(-2\tau_\mathrm{d}|\omega|\right),
\end{equation}
and the ACF is Lorentzian shaped,
\begin{equation}
	R_{\widetilde{\Phi},\psi}(r) = \frac{4}{4+(r/\tau_\mathrm{d})^2}.
\end{equation}
These expressions can be generalized to skewed Lorentzian pulses, however no closed expressions are known. An alternative formulation is presented in \cite{garcia2018skewed}.

\section{Excess time statistics}
Expressions for excess time statistics, specifically the rate of level crossings above a given threshold and the average time spent above this threshold, can be derived for an FPP. In the context of fluctuations in the SOL of fusion experiments, these quantities are crucial considering the energy of incoming particles to the vessel walls and the energy threshold of physical sputtering. The number of sputtered particles per incoming particle is specified by the modified Bohdansky yield function \cite{marandet2016assessment}. The mean yield as a function of energy of an incoming deuterium particle on a tungsten wall is plotted for a range of relative fluctuation levels in \Figref{Fig:theodorsen_yield}. For constant energy, no sputtering occurs beneath 200 eV. For realistic scenarios of $E_\mathrm{rms}/\langle E\rangle > 0$ sputtering already occurs at significantly lower mean energies. An accurate description of excess time statistics is therefore of importance for fusion experiments.

For an FPP the number of level crossings is given by Rice's formula \cite{rice1945mathematical}
\begin{equation}
	X(\Phi) = T\int_{0}^{\infty} \mathrm{d}\dot{\Phi}\, \dot{\Phi}P_{\Phi,\dot{\Phi}}\left(\Phi,\dot{\Phi}\right).
\end{equation}
Here $\dot{\Phi}$ stands for the derivative of the process $\Phi$ and $P_{\Phi,\dot{\Phi}}\left(\Phi,\dot{\Phi}\right)$ for the joint PDF between $\Phi$ and $\dot{\Phi}$. This formulation requires the process to be differentiable, hence an FPP consisting of one-sided exponential pulses cannot be considered this way. For two-sided exponential pulses with $\lambda \in (0,1)$ the rate of up-crossings is given by \cite{theodorsen2018level}
\begin{equation}\label{rate}
	\frac{\tau_\mathrm{d}}{T}X(\Phi) = \frac{\lambda^{\gamma\lambda-1}(1-\lambda)^{\gamma(1-\lambda)-1}}{\gamma\Gamma(\gamma\lambda)\Gamma(\gamma(1-\lambda))}\left(\frac{\gamma\Phi}{\langle\Phi\rangle}\right)^\gamma\mathrm{exp}\left(-\frac{\gamma\Phi}{\langle\Phi\rangle}\right).
\end{equation}
For this expression, the limit $\lambda\rightarrow0$ exists. \Eqref{rate} is plotted for exponential pulses with $\lambda=0$ and $\lambda=1/2$ and a range of $\gamma$-values in \Figref{Fig:theodorsen_avtime}. From this, the PDF of time as well as mass above a given threshold can be determined analytically for the limits $\gamma\rightarrow 0$ and $\gamma\rightarrow \infty$  and numerically with Monte Carlo simulations for general $\gamma$ \cite{theodorsen2018level}.
\begin{figure}
	\centering
	\begin{minipage}{.48\linewidth}
		\includegraphics[width=\linewidth]{figures/yield_fun_mE_W.eps}
		\caption{Mean yield  function for a range of relative fluctuation levels. Image courtesy of A. Theodorsen \cite{theodorsen2018statistical}.}
		\label{Fig:theodorsen_yield}
	\end{minipage}
	\hfill
	\begin{minipage}{.48\linewidth}
		\includegraphics[width=\linewidth]{figures/theodorsen_rate.png}
		\caption{Rate of up-crossings for a FPP consisting of exponential pulses with $\lambda=0$ (dashed line) and $\lambda=1/2$ (full line) for various $\gamma$-values. Reprinted figure with permission from \cite{theodorsen2018level}. Copyright (2018) by the American Physical Society.}
		\label{Fig:theodorsen_avtime}
	\end{minipage}
\end{figure}

At the time of writing this thesis, excess time statistics of an FPP consisting of Lorentzian pulses have not been investigated.

\section{Density profiles}\label{n_prof}
The FPP can be extended to include a spatial variable $x$, resulting in a model of advecting single pulses and corresponding profiles. In the following, this model is discussed in the context of filament motion in SOL plasmas. The presented notation is consistent with \cite{garcia2016stochastic}. Alternative formulations based on a Lagrangian approach to filament dynamics result in equivalent expressions \cite{militello2016scrape,militello2016relation,walkden2017interpretation,militello2018two}.

The model is given by a superposition of pulses
\begin{equation}
	\Phi_K(x,t) = \sum_{k=1}^{K} \phi_k(x,t).
\end{equation}
In contrast to previous sections $\phi_k$ is compounded by both amplitude and pulse shape. For simplicity, we keep $K$ constant in the following derivation. The evolution of individual pulses, neglecting pulse interaction, is given by the modified advection equation,
\begin{equation}\label{phi_equation}
	\frac{\partial \phi_k}{\partial t} + v_\perp\frac{\partial \phi_k}{\partial x} + \frac{\phi_k}{\tau_\parallel} = 0,
\end{equation}
with $v_\perp$ as the radial velocity and $\tau_\parallel$ representing the parallel transit time, describing parallel losses along the magnetic field. Note, that we assume $v_\perp$ and $\tau_\parallel$ to be constant for all filaments. Following \Eqref{phi_equation}, individual pulses can be written as the product of their amplitude and pulse shape, $	\phi_k(x,t) = A_k(t)\varphi_k(x-x_k-v_k t)$ with $x_k$ as the position of the pulse at $t=0$. The individual amplitudes are assumed to satisfy the expression
\begin{equation}
	\frac{\mathrm{d}A_k}{\mathrm{d}t} = -\frac{A_k}{\tau_\parallel}.
\end{equation}
The solution for this amplitude equation can be expressed by introducing the initial amplitude $A_{0k}$ resulting in
\begin{equation}
	A_k(t) = A_{0k}\,\mathrm{exp}\left(-\frac{t+x_k/v_\perp}{\tau_\parallel}\right),
\end{equation}
with the pulse $k$ being located at $x=0$ at time $-x_k/v_\perp$. We further assume the pulse shape to take the form of an exponential function,
\begin{equation}
	\varphi_k(x) = \Theta\left(-\frac{x}{l_\perp}\right)\mathrm{exp}\left(\frac{x}{l_\perp}\right),
\end{equation}
where $\Theta$ is the Heaviside function and $l_\perp$ is the radial size of the pulse. Note, that this pulse shape is consistent with the findings shown in \Figref{Fig:garcia_1}. We now consider the signal at a reference position $\xi$. At the reference time $t_k = (\xi - x_k)/v_\perp$ for pulse $k$ at position $\xi$, the process takes the form
\begin{equation}
	\Phi_K(\xi, t) = \sum_{k=1}^{K}A_{0k}\,\mathrm{exp}\left(-\frac{\xi}{v_\perp \tau_\parallel}\right)\Theta\left(\frac{t-t_k}{\tau_\perp}\right)\exp\left(-\frac{t-t_k}{\tau_\mathrm{d}}\right),
\end{equation}
with $\tau_\perp = l_\perp/v_\perp$ and the pulse duration given by the harmonic mean of the perpendicular and parallel transit time $\tau_\mathrm{d} = \tau_\parallel\tau_\perp/(\tau_\parallel+\tau_\perp)$. By averaging over uniformly distributed pulse arrivals, the resulting radial profile takes the exponential form
\begin{equation}
	\langle\Phi\rangle(\xi) = \frac{\tau_\mathrm{d}}{\tau_w}\langle A_0\rangle\mathrm{exp}\left(-\frac{\xi}{v_\perp\tau_\parallel}\right).
\end{equation}
The resulting scale length of the profile is governed by the radial velocity of the filaments and the parallel transit time. Multiple realizations at individual points in time and the corresponding mean profile are shown in \Figref{Fig:militello}.

The application of this model exhibits numerous limitations. The assumption of constant radial velocities and pulse size is an overly simplified description for filament transport in the SOL. In addition, the assumption of radially constant $\tau_w$ and therefore radially constant $\gamma$ does not hold in experimental observations. Interactions between individual filaments and two-dimensional motion are also not considered. However, this mathematical model still provides valuable insight in the relation between individual filaments and radial profiles in the SOL and can serve as a framework to relate isolated blob and filament studies to turbulence simulations and experimental measurements.

\begin{figure}[t]
	\centering
	\includegraphics[width=9cm]{figures/militello_profile.png}
	\caption{Radial exponential density profile (black dashed line) illustrated as the mean of individual density realizations (colored lines) given by a superposition of individual exponentially shaped pulses. Image courtesy of F. Militello \cite{militello_profiles}.}
	\label{Fig:militello}
\end{figure}
\section{Deconvolution method}
Since the FPP can be expressed as a convolution of a pulse function $\phi$ and a forcing, consisting of delta-function pulses $f_K$, shown in \Eqref{conv}, one can attempt to estimate the forcing if the pulse shape is known \cite{theodorsen2018universality, decristoforo2020intermittent, kube2020comparison}. For a given forcing, one can determine the pulse amplitudes $\{ A_k \}_{k=1}^K$ and arrival times $\{ t_k \}_{k=1}^K$ directly. This method has the advantage of capturing pulses of all sizes, not only events above a certain threshold as is the case for conditional averaging. Additionally, the problem of pulse overlap is less severe. In order to estimate the forcing, a modified Richardson-Lucy deconvolution algorithm can be used \cite{richardson1972bayesian,lucy1974iterative}. The algorithm is initialized with a first guess for the forcing $f_K^{(1)}$. This value is iteratively updated with the $n$-th iteration given by
\begin{equation}
	f_K^{(n+1)} = f_K^{(n)} \frac{D*\widehat{\phi}}{f_K^{(n)}*\phi*\widehat{\phi}}.
\end{equation}
Here, $\widehat{\phi}(t) = \phi(-t)$ and $D$ denotes the investigated time series. This algorithm converges to the least squares solution \cite{dell2007model}. The initial guess for the forcing matters little as it only determines the number of iterations required until the algorithm converges.

This deconvolution algorithm thereby provides a versatile tool to analyze time series of SOL fluctuations in experiments and simulations, as it can provide clear results even for relatively short time series.


% \documentclass[a4paper, 10px]{ctexart}
\documentclass{ctexart}
\usepackage{amsmath}
\usepackage[left=1in, right=1in, top=1.2in, bottom=1.2in]{geometry}
\usepackage{ctex}
\usepackage[utf8]{inputenc}
\usepackage{boxproof}
\usepackage{fontspec}
\usepackage{a4wide}
\usepackage{listings}
% \setmainfont[Scale = 1]{Palatino}
% \setCJKmainfont{Songti SC}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{plain}{
    \fancyhead[L]{East China Normal University}
    \fancyhead[R]{}
    \fancyfoot[C]{\thepage}
}
\def\premise{\mathrm{premise}}
\def\assumption{\mathrm{assumption}}
\def\MT{\mathrm {MT\ }}
\def\LEM{\mathrm{LEM}}
\def\intro{\mathrm{i\ }}
\def\elim{\mathrm{e\ }}
\def\introa{\mathrm{i_1\ }}
\def\elima{\mathrm{e_1\ }}
\def\introb{\mathrm{i_2\ }}
\def\elimb{\mathrm{e_2\ }}

\def\n{\neg}
\def\d{\vee}
\def\c{\wedge}
\def\NNF{\texttt{NNF}}
\def\IMPLFREE{\texttt{IMPL\_FREE}}
\def\CNF{\texttt{CNF}}
\def\DISTR{\texttt{DISTR}}

\title{Logic in Computer Science Assignment 2}
\author{10185101210 陈俊潼}
\date{October 2020}

\begin{document}

\maketitle

\section{}

\subsection{Convert the following formula into CNF.}

$\neg(r \rightarrow(\neg((p \vee q) \wedge(\neg p \rightarrow(q \wedge r)))))\\$

Let $\phi = \neg(r \rightarrow(\neg((p \vee q) \wedge(\neg p \rightarrow(q \wedge r)))))$.

First apply \IMPLFREE:

$$
\begin{aligned}
    \IMPLFREE(\phi) &= \n(r\to (\n((p\d q) \c (\n p \to (q \c r))))) \\
    &= \n(\IMPLFREE(r \to (\n ((p \d q) \c  (\n p \to (q \c r)))))) \\
    &= \n(\n r \d \IMPLFREE (\n((p \d q) \c (\n p \to (q \c r))))) \\
    &= \n(\n r \d (\n(\IMPLFREE (p \d q) \c \IMPLFREE (\n p \to (q \c r))))) \\
    &= \n(\n r \d (\n((p \d q) \c (\IMPLFREE (\n p \to (q \c r)))))) \\
    &= \n(\n r \d (\n((p \d q) \c (\n \n p \d \IMPLFREE(q \c r))))) \\
    &= \n(\n r \d (\n((p \d q) \c (\n \n p \d (\IMPLFREE q \c \IMPLFREE r))))) \\
    &= \n(\n r \d (\n((p \d q) \c (\n \n p \d(q \c r))))) \\
\end{aligned}
$$

Then apply \NNF:

$$
\begin{aligned}
    \NNF(\IMPLFREE(\phi)) &= \NNF(\n(\n r \d (\n((p \d q) \c (\n \n p \d(q \c r)))))) \\
    &= \NNF(\n \n r) \c \NNF (\n (\n ((p \d q) \c (\n \n p \d (q \c r))))) \\
    &= r \c \NNF ((p \d q) \c (\n \n p \d (q \c r))) \\
    &= r \c (\NNF(p \d q) \c \NNF (\n \n p \d (q \c r))) \\
    &= r \c ((\NNF p \d \NNF q) \c (\NNF (\n \n p) \d \NNF (q \c r)))\\
    &= r \c ((p \d q) \c (p \d (q \c r)))
\end{aligned}
$$

\newpage

Then apply \CNF:

$$
\begin{aligned}
    \CNF(\NNF(\IMPLFREE(\phi))) &= \CNF(r \c ((p \d q) \c (p \d (q \c r)))) \\
    &= r \c \CNF((p \d q) \c (p \d (q \c r)))\\
    &= r \c \CNF(p \d q) \c \CNF(p \d (q \c r))\\
    &= r \c \DISTR(p, q) \c \DISTR(\CNF(p), \CNF((q \c r))) \\
    &= r \c \DISTR(p, q) \c \DISTR(p, (q \c r)) \\
    &= r \c (p \d q) \c \DISTR(p, q) \c \DISTR(p, r)\\
    &= r \c (p \d q) \c (p \d q) \c (p \d r)\\
    &= r \c (p \d q) \c (p \d r) \\
\end{aligned}
$$

Above is the result of \CNF \ algorithm. Further more, this result can be simplified by:

$$
\begin{aligned}
    r \c (p \d q) \c (p \d r) &=  r \c (p \d r) \\
\end{aligned}
$$

\subsection{Determine the satisfiablity of the following formula with Horn algorithm.}

$
(p \wedge q \wedge s \rightarrow \perp) \wedge(q \wedge s \rightarrow p) \wedge(\top \rightarrow s) \wedge(s \rightarrow q)\\
$

Marked initially: $\top$

Since $\top \to s$, mark s. (Now marked: s, $\top$)

Since $s \to q$, mark q. (Now marked: s, q, $\top$)

Since $q \c s \to p$, mark p. (Now marked: s, p, q, $\top$)

Since $p \c q \c s \to \bot$, mark bot. (Now marked: s, p, q, $\top$, $\bot$)

Since $\bot$ is marked at last, from Horn's algorithm, this formula is not satisfiable.
\end{document}