# Exercise 4

## Kinematic dip PDF derivation

Consider a great number of non-interacting particles, each of which with a
random momentum $\vec{p}$ with module between 0 and $p_{\text{max}}$ randomly
angled with respect to a coordinate system {$\hat{x}$, $\hat{y}$, $\hat{z}$}.
Once the polar angle $\theta$ is defined, the momentum vertical and horizontal
components of a particle, which will be referred as $p_v$ and $p_h$, are the
ones shown in @fig:components.  
If $\theta$ is evenly distributed on the sphere and the same holds for the
module $p$, which distribution will the average value of the absolute value of
$p_v$ follow as a function of $p_h$?

\begin{figure}
\hypertarget{fig:components}{%
\centering
\begin{tikzpicture}
  % Axes
  \draw [thick, ->] (5,2) -- (5,8);
  \draw [thick, ->] (5,2) -- (2,1);
  \draw [thick, ->] (5,2) -- (8,1);
  \node at (1.5,0.9) {$x$};
  \node at (8.5,0.9) {$y$};
  \node at (5,8.4)   {$z$};
  % Momentum
  \definecolor{cyclamen}{RGB}{146, 24, 43}
  \draw [ultra thick, ->, cyclamen] (5,2)     -- (3.8,6);
  \draw [thick, dashed, cyclamen]   (3.8,0.8) -- (3.8,6);
  \draw [thick, dashed, cyclamen]   (5,7.2)   -- (3.8,6);
  \draw [ultra thick, ->, pink]     (5,2)     -- (5,7.2);
  \draw [ultra thick, ->, pink]     (5,2)     -- (3.8,0.8);
  \node at (4.8,1.1) {$\vec{p_h}$};
  \node at (5.5,6.6) {$\vec{p_v}$};
  \node at (3.3,5.5) {$\vec{p}$};
  % Angle
  \draw [thick, cyclamen] (4.4,4) to [out=80,in=210] (5,5);
  \node at (4.7,4.2) {$\theta$};
\end{tikzpicture}
\caption{Momentum components.}\label{fig:components}
}
\end{figure}

The aim is to compute $\langle |p_v| \rangle (p_h) dp_h$.

Consider all the points with $p_h \in [p_h ; p_h - dp_h]$: the values of
$p_v$ that these points can assume depend on $\theta$ and the total momentum
length $p$.

$$
  \begin{cases}
  p_h = p \sin{\theta} \\ p_v = p \cos{\theta}
  \end{cases}
  \thus |p_v| = p |\cos{\theta}| = p_h \frac{|\cos{\theta}|}{\sin{\theta}}
  = |p_v| (\theta)
$$

It looks like the dependence on $p$ has disappeared, but obviously it has
not. In fact, it lies beneath the limits that one has to put on the possible
values of $\theta$. For the sake of clarity, take a look at @fig:sphere (the
system is rotation-invariant, hence it can be drown at a fixed azimuthal angle).

\begin{figure}
\hypertarget{fig:sphere}{%
\centering
\begin{tikzpicture}
  % p_h slice
  \definecolor{cyclamen}{RGB}{146, 24, 43}
  \filldraw [cyclamen!15!white] (1.5,-3.15) -- (1.5,3.15) -- (1.75,3.05)
                             -- (2,2.85) -- (2,-2.85) -- (1.75,-3.05)
                             -- (1.5,-3.15);
  \draw [cyclamen] (1.5,-3.15) -- (1.5,3.15);
  \draw [cyclamen] (2,-2.9)    -- (2,2.9);
  \node [cyclamen, left] at (1.5,-0.3) {$p_h$};
  \node [cyclamen, right] at (2,-0.3) {$p_h + dp_h$};
  % Axes
  \draw [thick, ->] (0,-4) -- (0,4);
  \draw [thick, ->] (0,0)  -- (4,0);
  \node at (0.3,3.8) {$z$};
  \node at (4,0.3) {$hd$};
  % p_max semicircle
  \draw [thick, cyclamen] (0,-3.5) to [out=0, in=-90] (3.5,0);
  \draw [thick, cyclamen] (0,3.5)  to [out=0, in=90]  (3.5,0);
  \node [cyclamen, left] at (-0.2,3.5)  {$p_{\text{max}}$};
  \node [cyclamen, left] at (-0.2,-3.5) {$-p_{\text{max}}$};
  % Angles
  \draw [thick, cyclamen, ->] (0,1.5) to [out=0, in=140] (0.55,1.2);
  \node [cyclamen] at (0.4,2) {$\theta$};
  \draw [thick, cyclamen] (0,0) -- (1.5,3.15);
  \node [cyclamen, above right] at (1.5,3.15) {$\theta_x$};
  \draw [thick, cyclamen] (0,0) -- (1.5,-3.15);
  \node [cyclamen, below right] at (1.5,-3.15) {$\theta_y$};
  % Vectors
  \draw [ultra thick, cyclamen, ->] (0,0) -- (1.7,2.2);
  \draw [ultra thick, cyclamen, ->] (0,0) -- (1.9,0.6);
  \draw [ultra thick, cyclamen, ->] (0,0) -- (1.6,-2);
\end{tikzpicture}
\caption{Momentum space at fixed azimuthal angle ("$hd$" stands for
"horizontal direction"). Some vectors with $p_h \in [p_h, p_h +dp_h]$
are evidenced.}\label{fig:sphere}
}
\end{figure}

As can be seen, $\theta_x$ and $\theta_y$ are the minimum and maximum tilts
angles of these vectors respectively, because if a point had $p_h \in [p_h; p_h
+ dp_h]$ and $\theta < \theta_x$ or $\theta > \theta_y$, it would have $p >
p_{\text{max}}$. Therefore their values are easily computed as follow:

$$
  p_h = p_{\text{max}} \sin{\theta_x} = p_{\text{max}} \sin{\theta_y}
  \thus \sin{\theta_x} = \sin{\theta_y} = \frac{p_h}{p_{\text{max}}}
$$

Since the average value of a quantity is computed by integrating it over all the
possible quantities it depends on weighted on their probability, one gets:

$$
  \langle |p_v| \rangle (p_h) dp_h = \int_{\theta_x}^{\theta_y} 
  d\theta P(\theta) \cdot  P(p) \, dp \cdot |p_v| (\theta)
$$

where $d\theta P(\theta)$ is the probability of generating a point with $\theta
\in [\theta; \theta + d\theta]$ and $P(p) \, dp$ is the probability of
generating a point with $\vec{p}$ in the pink region in @fig:sphere, given a
fixed $\theta$.  
The easiest to deduce is $P(p) \, dp$: since $p$ is evenly distributed, it
follows that:

$$
  P(p) \, dp = \frac{1}{p_{\text{max}}} dp
$$

with:

$$
  dp = p(p_h + dp_h) - p(p_h)
     = \frac{p_h + dp_h}{\sin{\theta}} - \frac{p_h}{\sin{\theta}}
     = \frac{dp_h}{\sin{\theta}}
$$

hence

$$
  P(p) \, dp = \frac{1}{p_{\text{max}}} \cdot \frac{1}{\sin{\theta}} \, dp_h
$$

For $d\theta P(\theta)$, instead, one has to do the same considerations done
in @sec:3, from which:

$$
  P(\theta) d\theta = \frac{1}{2} \sin{\theta} d\theta
$$

Ultimately, having found all the pieces, the integral must be computed:

\begin{align*}
  \langle |p_v| \rangle (p_h) dp_h &= \int_{\theta_x}^{\theta_y} 
  d\theta \frac{1}{2} \sin{\theta} \cdot
  \frac{1}{p_{\text{max}}} \frac{1}{\sin{\theta}} \, dp_h \cdot
  p_h \frac{|\cos{\theta}|}{\sin{\theta}}
  \\
  &= \frac{1}{2} \frac{p_h dp_h}{p_{\text{max}}} \int_{\theta_x}^{\theta_y}
  d\theta \frac{|\cos{\theta}|}{\sin{\theta}} 
  \\
  &= \frac{1}{2} \frac{p_h dp_h}{p_{\text{max}}} \cdot \mathscr{O}
\end{align*}

Then, with a bit of math:

\begin{align*}
  \mathscr{O} &= \int_{\theta_x}^{\theta_y} d\theta
  \frac{|\cos{\theta}|}{\sin{\theta}}
  \\
  &= \int_{\theta_x}^{\frac{\pi}{2}} d\theta \frac{\cos{\theta}}{\sin{\theta}}
  - \int_{\frac{\pi}{2}}^{\theta_y} d\theta \frac{\cos{\theta}}{\sin{\theta}}
  \\
  &= \left[ \ln{(\sin{\theta})} \right]_{\theta_x}^{\frac{\pi}{2}}
  - \left[ \ln{(\sin{\theta})} \right]_{\frac{\pi}{2}}^{\theta_y}
  \\
  &= \ln{(1)} -\ln{ \left( \frac{p_h}{p_{\text{max}}} \right) }
  - \ln{ \left( \frac{p_h}{p_{\text{max}}} \right) } + \ln{(1)}
  \\
  &= 2 \ln{ \left( \frac{p_{\text{max}}}{p_h} \right) }
\end{align*}

\newpage
Hence, in conclusion:

\begin{align*}
  \langle |p_v| \rangle (p_h) dp_h &= \frac{1}{2} \frac{p_h dp_h}{p_{\text{max}}}
  \cdot 2 \ln{ \left( \frac{p_{\text{max}}}{p_h} \right) }
  \\
  &= \ln{ \left( \frac{p_{\text{max}}}{p_h} \right) }
  \frac{p_h}{p_{\text{max}}} dp_h
\end{align*}

Namely:

\begin{figure}
\hypertarget{fig:plot}{%
\centering
\begin{tikzpicture}
  \definecolor{cyclamen}{RGB}{146, 24, 43}
  % Axis
  \draw [thick, <->] (0,5) -- (0,0) -- (11,0);
  \node [below right] at (11,0) {$p_h$};
  \node [above left] at (0,5) {$\langle |p_v| \rangle$};
  % Plot
  \draw [domain=0.001:10, smooth, variable=\x,
         cyclamen, ultra thick] plot ({\x},{12*ln(10/\x)*\x/10});
  \node [cyclamen, below] at (10,0) {$p_{\text{max}}$};
\end{tikzpicture}
\caption{Plot of the expected distribution.}\label{fig:plot}
}
\end{figure}


## Monte Carlo simulation

The same distribution should be found by generating and binning points in a
proper way.  
A number of $N = 50'000$ points were generated as a couple of values ($p$,
$\theta$), with $p$ evenly distrinuted between 0 and $p_{\text{max}}$ and
$\theta$ given by the same procedure described in @sec:3, namely:

$$
  \theta = \text{acos}(1 - 2x)
$$

with $x$ uniformely distributed between 0 and 1.  
The data binning turned out to be a bit challenging. Once $p$ was sorted and
$p_h$ was computed, the bin in which the latter goes in must be found. If $n$ is
the number of bins in which the range [0, $p_{\text{max}}$] is willing to be
divided into, then the width $w$ of each bin is given by:

$$
  w = \frac{p_{\text{max}}}{n}
$$

and the $j^{th}$ bin in which $p_h$ goes in is:

$$
  j = \text{floor} \left( \frac{p_h}{w} \right)
$$

where 'floor' is the function which gives the upper integer lesser than its
argument and the bins are counted starting from zero.  
Then, a vector in which the $j^{\text{th}}$ entry contains the sum $S_j$ of all
the $|p_v|$s relative to each $p_h$ fallen into the $j^{\text{th}}$ bin and the
number num$_j$ of entries in the $j^{\text{th}}$ bin was reiteratively updated.
At the end, the average value of $|p_v|_j$ was computed as $S_j /
\text{num}_j$.  
For the sake of clarity, for each sorted couple, it works like this:

  - the couple $[p; \theta]$ is generated;
  - $p_h$ and $p_v$ are computed;
  - the $j^{\text{th}}$ bin in which $p_h$ goes in is computed;
  - num$_j$ is increased by 1;
  - $S_j$ (which is zero at the beginning of everything) is increased by a factor
    $|p_v|$.

At the end, $\langle |p_h| \rangle_j$ = $\langle |p_h| \rangle (p_h)$ where:

$$
  p_h = j \cdot w + \frac{w}{2} = w \left( 1 + \frac{1}{2} \right)
$$

The following result was obtained:

![Histogram of the obtained distribution.](images/dip.pdf)
