\documentclass{article}
\usepackage{ws_template}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{a4wide}
\usepackage{graphicx}
\usepackage{booktabs}

% please submit the corresponding pdf by email to
% homework@class,brml.org, and write "homework sheet xx" in the
% title.  No more, no less!  (Instead of xx, however,
% put the decimal number of the homework sheet.)

% Please update the following line, only change XX to the homework
% sheet number
\title{homework sheet 02}

\author{
\name{Denys Sobchyshak}\\
\imat{03636581}\\
\email{denys.sobchyshak@gmail.com}
\And
\name{Sergey Zakharov} \\
\imat{03636642}\\
\email{ga39pad@mytum.de}
}

% The \author macro works with any number of authors. There are two commands
% used to separate the names and addresses of multiple authors: \And and \AND.
%
% Using \And between authors leaves it to \LaTeX{} to determine where to break
% the lines. Using \AND forces a linebreak at that point. So, if \LaTeX{}
% puts 3 of 4 authors names on the first line, and the last on the second
% line, try using \AND instead of \And before the third author name.

\begin{document}
\maketitle

\section{Basic Probability}

\textbf{Problem 1:}\\
Let's denote whether a person is a terrorist or not by the variable A, then:\\
\[P(A = 1) = 0.01\]
\[P(A = 0) = 0.99\]
The variable B stands for the scanner recognition ( B = 1 -- a terrorist, B = 0 -- not a terrorist ):
\[P(B = 1|A = 1) = 0.95 \quad P(B = 1|A = 0) = 0.05\]
\[P(B = 0|A = 1) = 0.05 \quad P(B = 0|A = 0) = 0.95\]
Using the Bayes' theorem we can now get the answer:
\begin{equation*}
	\begin{aligned}
	P(A = 1|B = 1) & = \frac{P(B = 1|A = 1)P(A = 1)}{P(B = 1|A = 1)P(A = 1) + P(B =1|A = 0)P(A = 0)} \\
				   &  = \frac{0.95*0.01}{0.95*0.01 + 0.05*0.99} \approx 0.16
	\end{aligned}
\end{equation*}
\\
\textbf{Problem 2:}\\
Again using the Bayes' theorem:
\[ P(2\ red\  balls\ in\ the\ box\ |\ 3\ red\ balls\ drawn) =\]
\[= \frac{P(3\ red\  balls\ drawn\ |\ 2\ red\ balls\ in\ the\ box)P(2\ red\ balls\ in\ the\ box)}{P(3\ red\  balls\ drawn)}\]

The numerator:
\[P(3\ red\  balls\ drawn\ |\ 2\ red\ balls\ inside)P(2\ red\ balls\ inside)=1*1/4=1/4\]
and denominator:
\[P(3\ red\  balls\ drawn)=P(3\ red\  balls\ drawn|2\ red\ balls\ inside)P(2\ red\ balls\ inside)+\]
\[+P(3\ red\  balls\ drawn|2\ white\ balls\ inside)P(2\ white\ balls\ inside)+\]
\[+P(3\ red\  balls\ drawn|1\ red\ and\ 1\ white\ ball\ inside)P(1\ red\ and\ 1\ white\ ball\ inside)=\]
\[=1*1/4+0+1/8*1/2=5/16\]

Therefore:
\[ P(2\ red\  balls\ inside\ |\ 3\ red\ balls\ drawn)=4/5\]
\newpage
\textbf{Problem 3:}\\
Firstly we show that:
\[P(u,n_B,N) = P(u|n_B,N)P(n_B,N) = P(n_B|u,N)P(u,N) = P(n_B|u,N)P(u)P(N)\]
Thus:
\[P(u|n_B,N)=\frac{P(n_B|u,N)P(u)P(N)}{P(n_B|N)} \]
Using the sum rule and given $P(n_{B}|u,N) =\bigl(\begin{smallmatrix}
    N \\
    n_B
  \end{smallmatrix}\bigr)
  f_{u}^{n_B}{(1-f_u)}^{N-n_B}$:\\
\[P(n_{B}|N) = \sum_{u}{P(u)P(N)P(n_{B}|u,N)}\]

\[P(u|n_B,N)=\frac{P(n_B|u,N)P(u)}{\sum_{u}{P(n_{B}|u,N)P(u)}} =
 \frac{P(u)}{\sum_{u}{P(n_{B}|u,N)P(u)}}
 \bigl(\begin{smallmatrix}
    N \\
    n_B
  \end{smallmatrix}\bigr)
  f_{u}^{n_B}{(1-f_u)}^{N-n_B}\]

The conditional distribution:
\begin{table}[h]
\begin{center}
	\begin{tabular}{l l}
	\toprule
	$u$ & $P(u|n_B=3,N)$ \\
	\midrule
	0 & 0 \\
	1 & 0.063 \\
	2 & 0.22 \\
	3 & 0.29 \\
	4 & 0.24 \\
	5 & 0.13 \\
	6 & 0.047 \\
	7 & 0.0099 \\
	8 & 0.00086 \\
	9 & 0.0000096 \\
	10 & 0 \\
	\bottomrule
	\end{tabular}\\
\caption{Conditional probability of $u$ given $n_B=3$ and $N=10$}
\end{center}
\end{table}

\textbf{Problem 4:}\\
\[P(Black|n_{B},N) = \sum_{u}{P(Black|u,n_{B},N)P(u|n_{B},N)}\]
Having $ P(Black|u,n_{B},N) = f_{u}$:
\[P(Black|n_{B},N) = \sum_{u}{f_{u}P(u|n_{B},N)} \approx 0.33\]
\textbf{Problem 5:}\\

\[ \mu=\int_{-\infty}^{\infty}xp(x)\mathrm{d}x=\int_{0}^{1}x\mathrm{d}x=1/2\]
\[ {\sigma}^2=\int_{-\infty}^{\infty}{(x-\mu)}^2p(x)\mathrm{d}x=\int_{0}^{1}{(x-\mu)}^2\mathrm{d}x=\left.\frac{{(x-\mu)}^3}{3}\right|_0^1=1/12\]

\newpage
\textbf{Problem 6:}\\
Part 1:
\[E[X] = E_Y[E_{X|Y}[X]]\]

Proof: \\
\[ E_{X|Y}[X] = \int_{-\infty}^{+\infty} p(x|y)g(x)dx \]
Then:
\[ E_Y[E_{X|Y}[X]] = \iint p(x|y)g(x)dx p(y)dy = \iint p(x,y)g(x)dxdy = \int (p(x)*g(x))dx = E[X] \]
Part 2:
\begin{equation*}
	\begin{aligned}
	E_{Y}[Var_{X|Y}[X]] & + Var_{Y}[E_{X|Y}[X]] = E_{Y}[(E_{X|Y}[X^2]-E_{X|Y}[X]^2] + E_{Y}[E_{X|Y}[X]-E_{Y}(E_{X|Y}[X]))^2]\\
	& = E[X^2]-E[X]^2 + E_{Y}[E_{X|Y}[X]^2 + (E_{Y}(E_{X|Y}[X]))^2 - 2E_{X|Y}[X] * E_{Y}(E_{X|Y}[X])]\\
	& = E[X^2]-E[X]^2 + E_{X}[X]^2 + (E_{Y}(E_{X|Y}[X]))^2 - 2E_{X}[X] * E_{Y}(E_{X|Y}[X])\\
	& = E[X^2]-E[X]^2 + E_{X}[X]^2 + (E_{X}[X]^2 - 2E_{X}[X] * E_{X}[X])\\
	& = E[X^2]-E[X]^2 = Var[X]\\
	\end{aligned}
\end{equation*}

\section{Probability Inequalities}

\subsection{Markov Inequality}
\textbf{Problem 7:}\\

\[P(X>c)\le \frac{E[X]}{c}\]
Proof:\\
\[E[X]=\int_0^{\infty}xP(x)\mathrm{d}x=
    \int_0^cxP(x)\mathrm{d}x+\int_c^{\infty}xP(x)\mathrm{d}x\ge\]
    \[\ge\int_c^{\infty}xP(x)\mathrm{d}x\ge
    \int_c^{\infty}cP(x)\mathrm{d}x=
    c\int_c^{\infty}P(x)\mathrm{d}x=
    cP(X>c)\]
If we flip a fair coin $n$ times the probability of getting more than $(3/4)n$ heads is
\[P(X>(3/4)n)\le \frac{(1/2)n}{(3/4)n}=2/3\]

\subsection{Chebyshev Inequality}
\textbf{Problem 8:}\\

\[P(|X-E[X]|>a)\le \frac{Var[X]}{a^2}\]
Proof:\\
Let's first write the Markov Inequality:
\[P(X>a)\le \frac{E[X]}{a}\]
Now let's replace $X$ with $|X-\mu|$:
\[P(|X-\mu|>a)\le \frac{E[|X-\mu|]}{a}\]
The probability $P(|X-\mu|>a)$ is equal to probability $P({(X-\mu)}^2>a^2)$. So now let's apply Markov Inequality to the latter one:
\[P({(X-\mu)}^2>a^2)\le \frac{E[{(X-\mu)}^2]}{a^2}\]
And as we already mentioned, probability $P(|X-\mu|>a)$ is equal to probability $P({(X-\mu)}^2>a^2)$. And the numerator is actually a variance. So we get:
\[P(|X-E[X]|>a)\le \frac{Var[X]}{a^2}\]
If we flip a fair coin $n$ times we get the following bound for probability of getting more than $(3/4)n$ heads:
\[P(X>(3/4)n)\le P(|X-E[X]|>n/4)\le \frac{Var[X]}{{(n/4)}^2}=\frac{n/4}{{(n/4)}^2}=4/n\]

\subsection{Jensen's Inequality}
\textbf{Problem 9:}\\
\[ f(\lambda_1 x_1 + \dots + \lambda_n x_n) \le \lambda_1 f(x_1) + \dots + \lambda_n f(x_n) \]

Proof:\\
We shall show that if $ f(\lambda_1 x_1 + \dots + \lambda_n x_n) \le \lambda_1 f(x_1) + \dots + \lambda_n f(x_n) $ is the same for $n = m - 1$, it is also valid for $n = m$. \\ Let us assume that $\lambda \neq 0$ in the set $\lambda_1,...,\lambda_n$. Then $\beta = \lambda_2 + \dots +\lambda_n > 0$\\ and $\frac{\lambda_2}{\beta} + \dots + \frac{\lambda_n}{\beta} = 1$. Using the convexity if the function, we find
\[ f(\lambda_1 x_1 + \dots + \lambda_n x_n) = f(\lambda_1 x_1 + \dots + \beta*(\frac{\lambda_2}{\beta} x_2 + \dots + \frac{\lambda_n}{\beta} x_n)) \le \] \[ \lambda_1 f(x_1) + \beta f (\frac{\lambda_2}{\beta} x_2 + \dots + \frac{\lambda_n}{\beta} x_n), \] since $\lambda_1 + \beta = 1$ and $(\frac{\lambda_2}{\beta} x_2 + \dots + \frac{\lambda_n}{\beta} x_n) \in ]a,b[$.
By the induction hypothesis, we now have \[ f(\frac{\lambda_2}{\beta} x_2 + \dots + \frac{\lambda_n}{\beta} x_n) \le \frac{\lambda_2}{\beta} f(x_2) + \dots + \frac{\lambda_n}{\beta} f(x_n).\] Therefore \[f(\lambda_1 x_1 + \dots + \lambda_n x_n) \le \lambda_1 f(x_1) + \beta f(\frac{\lambda_2}{\beta} x_2 + \dots + \frac{\lambda_n}{\beta} x_n) \le \] \[\lambda f(x_1) + \lambda f(x_2) + \dots + \lambda f(x_n).\]
By induction we conclude that $ f(\lambda_1 x_1 + \dots + \lambda_n x_n) \le \lambda_1 f(x_1) + \dots + \lambda_n f(x_n) $  holds for any $n \in \mathbb{N}$.

\end{document}


% Chapter 3
\chapter{Conclusion and Future Work} % Main chapter title
\label{chapterConclusionAndFutureWork}
\indent
The depth sensor technologies opens a new epoch for \gls{3D} markets. Ever since Microsoft brought the low-cost depth camera Kinect into consumer market, \gls{RGBD} cameras are famous for their \gls{3D} reconstruction applications in research areas of \gls{HCI}. Graphic processing units (GPUs) can solve large data parallel problems at a higher speed than the traditional CPU, while being more affordable and energy efficient \cite{GPUadvantage_2015}. With floating point calculation and matrix operation, GPUs are specialized many-core processors that are optimized for graphic processing \cite{GPUadvantage02_2013}. Without calibration, the horizontal and vertical \gls{FoV} could help generate \gls{3D} reconstruction in camera space naturally on \gls{GPU} through proportional calculations in fragment shader, which nevertheless is badly deformed by the lens distortions and \emph{depth distortion}. Due to image formation, some methods must be designed to establish the correct correspondence between raw images streams from the camera and the real-time \gls{3D} reconstruction feedback. Traditionally, the camera calibration is done based on a pinhole-camera model and a high-order distortion removal model. However, there will be a lot of calculations in the fragment shader to process parameters. There will be at least five intrinsic parameters from intrinsic camera matrix and another five parameters from distortion removal vector, while the distortion correction in this method requires multiplication calculations to achieve the high order polynomial. In order to get rid of both the lens distortion and the \emph{depth distortion} while still be able to do simple calculations on the \gls{GPU} fragment shader, a new solution is needed. %
%
%\section{Conclusion}
\\\indent
In this thesis, a novel per-pixel calibration method with look-up table based \gls{3D} reconstruction on \gls{GPU} in real-time is introduced, using a rail calibration system. This rail calibration system offers possibilities of collecting infinite calibration points with dense distributions that can cover all pixels in a sensor. Not only lens distortions, but \emph{depth distortion} can also be handled by a per-pixel \(\gls{D}\) to \(\gls{worldZ}\) mapping with data along \(\gls{worldZ}\)-axis collected on the rail. Instead of utilizing the traditional pinhole camera model, two polynomial mapping models are employed in this calibration method. The first model is the two-dimensional \(4^{th}\) order polynomial mapping from \(R/C\) to \(\gls{worldX}/\gls{worldY}\) during the frames data collection, which takes care of the removal of lens distortions; and the second model is the linear mapping from \(\gls{D}\) to \(\gls{worldZ}\), which can handle \enquote{depth distortion}. The method consists of two big steps: \(X^WY^WZ^W+\gls{D}\) data collection and mapping parameters determination. \(\gls{D}\) is simply from depth streams. \(\gls{worldZ}\) is from external based on the camera's position on the rail. And the undistorted (\(\gls{worldX}, \, \gls{worldY}\)) are from the transformation of \(R/C\) by a \(4^{th}\) order polynomial mapping model, during which lens-distortions could be removed. This method is claimed as \enquote{data-based} calibration method, because both of the two mapping models are determined and calculated by real streams data from the camera.
\\\indent
With the fewest calculations, the undistorted \gls{3D} world coordinates (\(\gls{worldX}, \, \gls{worldY}, \, \gls{worldZ}\)) for every single pixel could be looked up in real-time based on \(\gls{D}\) from a \(\gls{imageColumn}\)-by-\(\gls{imageRow}\)-by-\(6\) look-up table. Only three linear equations with six parameters need to be calculated in the fragment shader. Two out of six parameters \(a/b\) are to determine the per-pixel \(\gls{worldZ}\), which is generated from per-pixel depth value \(\gls{D}\); and the other four parameters \(c/d/d/f\) are to determine the per-pixel \(\gls{worldX}/\gls{worldY}\) respectively, which are mapped by per-pixel linear beam equation from the per-pixel \(\gls{worldZ}\). Note that \enquote{real-time} here means being able to show an undistorted frame in \gls{3D} world space before the start of the second frame processing, and this \gls{LUT} based \gls{3D} reconstruction method can realize real-time very well. The data-based per-pixel calibration method could be applied universally on any \gls{RGBD} cameras. With the alignment of RGB pixels using a pinhole camera matrix, it could even work on a combination of a random Depth sensor and a random RGB sensor.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%                                                                %%%%%%%%%%%%%%%%%
%%%%%%%%%%     5.2  Future Work                                    %%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%                                                                %%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\section{Future Work}
%
\\\indent
The rail calibration system and per-pixel calibration method with \gls{LUT}-based real-time \gls{3D} reconstruction could be applied universally to all kinds of \gls{RGBD} cameras. With a more precise calibration system and corresponding \gls{DIP} technologies, there could be a huge improvement space for calibration accuracy. Hardware improvement is sometimes more important than a software updating. Concretely the system in the lab now can only handle a working distance \(\gls{worldZ}\) from 1.165m to 2.565m. Considering that the depth resolution deteriorates notably with depth, it might not be a simple linear relationship from \(\gls{D}\) and \(\gls{worldZ}\), when the depth \(\gls{D}\) value goes much further than the limit of the rail. In that case, the per-pixel \(\gls{D}\) to \(\gls{worldZ}\) mapping could be changed from singular linear to segmented mapping function when \(\gls{D}\) gets larger than a certain value.
\\\indent
Not only the rail, the planar pattern could also be changed based on the resolution of the camera (\textit{e.g.}, size of the dots and side distance of the unit square-shaped of the uniform grid could be larger when the camera has a supper high resolution). A two dimensional object is totally enough for calibrating \gls{KinectV2}, because the \gls{NIR} stream have same pixels' distortions with the depth stream. However, if \gls{NIR} stream could not be used to extract points \(R/C\) in image space (\textit{e.g.} a structured light based depth sensor) while the size (pixel numbers) of the RGB sensor does not share the same one with the depth sensor, we could make the planar pattern into a \enquote{three dimension mode}: change the printed dots into real wholes such that the depth stream could detect a difference between the \enquote{dots} and \enquote{white background}.
\\\indent
Instead of using a laser distance measurer to manually input \(\gls{worldZ}\) into every frame at the very beginning of the frame data collection, we could add a tracking module onto the rail to active the frame collection by software. In this way, not only \(\gls{worldZ}\) could be traced by the tracking module, but also the frame collection could be automatically done by the activation from the tracking module, recording one frame data after every certain distance of movement has been detected.
\\\indent
Besides the hardware enhancement, softwares like \gls{DIP} process can also be improved. The order of polynomial model that help map from image space \(R/C\) to world space \(\gls{worldX}/\gls{worldY}\) could also be heightened for a better accuracy, as long as there will be enough calibrating points to offer the coordinates pairs of both image space and world space. Considering the possible lens-distortions of the RGB sensor, the high order polynomial mapping could also be applied into the color values' alignment from RGB sensor pixels to depth sensor pixels.


\documentclass{article}
%\usepackage{fullpage}
%\usepackage{nopageno}
\usepackage[margin=1.5in]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[normalem]{ulem}
\usepackage{fancyhdr}
%\renewcommand\headheight{12pt}
\pagestyle{fancy}
\lhead{March 12, 2014}
\rhead{Jon Allen}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\section*{Project Prep}
I chose binary trees. I found out you can map Dyck paths to binary trees and back. I also never really thought about how many ways you could symmetrise the treees. The statistic finder is meh, just generates trees. The database is interesting in that the statistics in there are kind of random from where I'm sitting. Like for example the first statistic is ``The number of left oriented leafs except the first one.''
\section*{Chapter 5}
\begin{enumerate}
\setcounter{enumi}{29}\item
Prove that the only antichain of $S=\{1,2,3,4\}$ of size 6 is the antichain of all 2-subsets of $S$

We can easily see that the only antichain that contains $\emptyset$ is $\{\emptyset\}$, similarly the only antichain containing $S$ is $\{S\}$.
Both of these are obviously of size one.
We see then that any antichain that is to be bigger than 6 must contain a subset of size 1,2 or 3.
Lets pick a subset of size one to be in our antichain.
Without loss of generality we say that subset is $\{1\}$.
Since any other subsets in our antichain must not be a superset of $\{1\}$ we can form the remaining subsets in our antichain from $\{2,3,4\}$.
We know from theorem 5.3.3 that we can form an antichain of maximum size $\binom{3}{\left\lfloor \frac{3}{2}\right\rfloor}=3$ from this set of size 3.
The maximum size then of an antichain containing a subset of size 1 is then $3+1=4$ which is less than 6.
The antichain we are looking for then must be made up entirely of subsets of size 2 and 3.
Since the antichain we are looking for is not all subsets of size two, we must have at least one of size 3.

Let us assume our antichain contains a subset of size 3.
Canditates for the antichain consist of any subsets of $A$ with the last element from $S$ added in, or the last element of $S$ only.
Without loss of generality we choose a subset $A$ of size 3 from $S$ to be in our antichain.
We'll say $A=\{1,2,3\}$.
Then an antichain with $A$ can also contain the subset the remaining element, $\{4\}$ or any two combinations from $S$ which contain the remaining element and one element from $A$, eg, $\{1,4\}$, or three combinations of the remaining element and two elements from $A$ eg, $\{1,2,4\}$. Any subsets not containing the last element are subsets of $A$ and therefore not candidates for inclusion in the antichain.
There is one possible combination consisting solely of the last element, 3 combinations consisting of the remaining element and one of the elements from $A$ and 3 combinations consisting of the remaining element and two of the 3 elements in $A$.
So we have taken one of our 6 possible subsets with $A$. Leaving us with 5 slots to fill with 7 candidates.
If we choose the remaining element as a subset of our antichain, then none of the other candidates will fit, as they all also contain the remaining element. This gives us an antichain of size 2.
Likewise if we choose one of the 2 element subsets consisting of an element in $A$ and the remaining element of $S$ then we have chosen a subset that is also a subset of two of the 3 element subsets. This gives us an antichain of size 2 and a pool of size 3. This gives us a maximum of 5 subsets in our antichain at this point.
So, no matter how we choose from our pool of 7 candidates, we reduce the available remaining candidates to the point where we can not build an antichain of size 6.$\Box$
%Let us assume our antichain contains a subset of size 2. Say without loss of generality  $\{1,2\}$. Then the biggest possible antichain containing this set is given by adding the sizes of the largest possible antichains of the original set without each element of $\{1,2\}$ and subtracting the possible antichains of the original set without either element. So again without loss of genrality we have $\{2,3,4\}$ and $\{1,3,4\}$ minus largest antichain of $\{3,4\}$ which is $2\cdot\binom{3}{\left\lfloor\frac{3}{2}\right\rfloor}-\binom{2}{\left\lfloor\frac{2}{2}\right\rfloor}=2*3-1=5$. And adding back in the original set we chose, we have a maximum antichain size of 6.
\setcounter{enumi}{32}\item
Construct a partition of the subsets of $\{1,2,3,4,5\}$ into symmetric chains.
\begin{align*}
  \emptyset\subset\{1\}\subset\{1,2\}\subset\{1,2,3\}\subset\{1,2,3,4\}\subset\{1,2,3,4,5\}\\
  \{5\}\subset\{1,5\}\subset\{1,2,5\}\subset\{1,2,3,5\}\\
  \{4\}\subset\{1,4\}\subset\{1,2,4\}\subset\{1,2,4,5\}\\
  \{4,5\}\subset\{1,4,5\}\\
  \{2\}\subset\{2,3\}\subset\{2,3,4\}\subset\{2,3,4,5\}\\
  \{2,5\}\subset\{2,3,5\}\\
  \{2,4\}\subset\{2,4,5\}\\
  \{3\}\subset\{1,3\}\subset\{1,3,4\}\subset\{1,3,4,5\}\\
  \{3,5\}\subset\{1,3,5\}\\
  \{3,4\}\subset\{3,4,5\}\\
\end{align*}
%34 is for graduate students
%\item
%In a partition of the subsets of $\{1,2,\dots,n\}$ into symmetric chains, how many chains have only one subset in them? two subsets? $k$ subsets?
\setcounter{enumi}{36}\item
Use the multinomial theorem to show that, for positive integers $n$ and $t$,
\begin{align*}
  t^n&=\sum{\binom{n}{n_1n_2\dots n_t}},
\end{align*}
where the summation extends over all nonnegative integral solutions $n_1,n_2,\dots,n_t$ of $n_1+n_2+\dots+n_t=n$
\begin{align*}
  t^n&=(1_1+1_2+\dots1_t)^n\\
  &=\sum{\binom{n}{n_1n_2\cdots n_t}{1_1}^{n_1}{1_2}^{n_2}\cdots{1_t}^{n_t}}\\
  &=\sum{\binom{n}{n_1n_2\cdots n_t}}
\end{align*}
\item
Use the multinomial theorem to expand $(x_1+x_2+x_3)^4$
\begin{align*}
  (x_1+x_2+x_3)^4&=\sum\limits_{n_1+n_2+n_3=4}{\binom{4}{n_1n_2n_3}{x_1}^{n_1}{x_2}^{n_2}{x_3}^{n_3}}\\
  &=\binom{4}{4\;0\;0}{x_1}^4{x_2}^0{x_3}^0
  +\binom{4}{0\;4\;0}{x_1}^0{x_2}^4{x_3}^0
  +\binom{4}{0\;0\;4}{x_1}^0{x_2}^0{x_3}^4\\
  &\quad+\binom{4}{3\;1\;0}{x_1}^3{x_2}^1{x_3}^0
  +\binom{4}{3\;0\;1}{x_1}^3{x_2}^0{x_3}^1
  +\binom{4}{0\;3\;1}{x_1}^0{x_2}^3{x_3}^1\\
  &\quad+\binom{4}{1\;3\;0}{x_1}^1{x_2}^3{x_3}^0
  +\binom{4}{0\;1\;3}{x_1}^0{x_2}^1{x_3}^3
  +\binom{4}{1\;0\;3}{x_1}^1{x_2}^0{x_3}^3\\
  &\quad+\binom{4}{2\;0\;2}{x_1}^2{x_2}^0{x_3}^2
  +\binom{4}{2\;2\;0}{x_1}^2{x_2}^2{x_3}^0
  +\binom{4}{0\;2\;2}{x_1}^0{x_2}^2{x_3}^2\\
  &\quad+\binom{4}{2\;1\;1}{x_1}^2{x_2}^1{x_3}^1
  +\binom{4}{1\;2\;1}{x_1}^1{x_2}^2{x_3}^1
  +\binom{4}{1\;1\;2}{x_1}^1{x_2}^1{x_3}^2\\
  &={x_1}^4+{x_2}^4+{x_3}^4\\
  &\quad+4{x_1}^3{x_2}+4{x_1}^3{x_3}+4{x_2}^3{x_3}\\
  &\quad+4{x_1}{x_2}^3+4{x_2}{x_3}^3+4{x_1}{x_3}^3\\
  &\quad+6{x_1}^2{x_3}^2+6{x_1}^2{x_2}^2+6{x_2}^2{x_3}^2\\
  &\quad+12{x_1}^2{x_2}{x_3}+12{x_1}{x_2}^2{x_3}+12{x_1}{x_2}{x_3}^2\\
\end{align*}
\setcounter{enumi}{39}\item
What is the coefficient of ${x_1}^3{x_2}^3x_3{x_4}^2$ in the expansion of
\[(x_1-x_2+2x_3-2x_4)^{9}?\]

\[\binom{9}{3\;3\,1\;2}\cdot1^3\cdot(-1)^3\cdot2^1\cdot(-2)^2=5040\cdot -1\cdot2\cdot4=-40320\]

\setcounter{enumi}{41}\item
Prove the identity (5.21) by a combinatorial argument. (\emph{Hint:} Consider the permutations of a multiset of objects of $t$ different types with repetition numbers $n_1,n_2,\dots,n_t$, respectively. Partition these permutations according to what type of object is in the first position.)

We know that $\binom{n}{n_1n_2\cdots n_t}$ gives us the number of permutations of a multiset of objects of $t$ different types with repetition numbers $n_1,n_2,\dots,n_t$, respectively. Now lets calculate the number of permutations of the same multiset which start with an object of type $i$. The number of objects we are choosing from is reduced by one to $n-1$ because the first object is chosen already. Likewise we have $n_i-1$ objects of type $i$ to choose from. So we have $\binom{n-1}{n_1,\dots,n_i-1,\dots,n_t}$ permutations which start with the $i$ object type. Now if we want to find the total number of permutations, we just add together all the permutations possible possible which start with every type.
\begin{align*}
  \sum\limits_{i=1}^t{\binom{n-1}{n_1\dots n_i\dots n_t}}
\end{align*}
Which gives us our identity.$\Box$
\end{enumerate}
\section*{Chapter 6}
\begin{enumerate}
\item
Find the number of integers between 1 and 10,000 inclusive that are not divisible by 4,5, or 6.

I'll start by just saying that all the math I do will be integer math, e.g. $\frac{10}{2}=2$. So we can just subtract from 10,000 the number of integers that are divisable by 4,5, or 6 to get the number of integers that are not. The number of integers divisable by 4 is $10000/4=2500$. Similarly for 5 we have $10000/5=2000$ and for 6 we have $10000/6=1666$. Since 20 is the least common multiple of 5 and 4 the number of integers that can be obtained by dividing 10000 by 4 or 5 is $10000/20=500$ and similarly for 4 and 6 we have $10000/12=833$. And for 5 and 6 $10000/30=333$. Finally the number of integers that can be obtained by dividing by 4,5, or 6 is $10000/60=166$. Putting it all together with the inclusion-exclusion principle (inverted since we are subtracting from the total) we have $10000-2500-2000-1666+500+833+333-166=5334$ integers.
\item
Find the number of integers between 1 and 10,000 inclusive that are not divisible by 4,6,7, or 10.

As in problem 1, all math will be integer math, not real. Logic is also the same as in problem 1.
\begin{align*}
  \text{lcm}(4,6)&=12&\text{lcm}(4,7)&=28&\text{lcm}(10,4)&=20\\
  \text{lcm}(6,7)&=42&\text{lcm}(6,10)&=30&\text{lcm}(7,10)&=70\\
  \text{lcm}(4,6,7)&=84&\text{lcm}(4,6,10)&=60&\text{lcm}(6,7,10)&=210&\text{lcm}(4,7,10)&=140\\
  \text{lcm}(4,6,7,10)&=420\\
  10000/4&=2500&10000/6&=1666&10000/7&=1428&10000/10&=1000\\
  10000/12&=833&10000/28&=357&10000/20&=500\\
  10000/42&=238&10000/30&=333&10000/70&=142\\
  10000/84&=119&10000/60&=166&10000/210&=47&10000/140=71\\
  10000/420&=23
\end{align*}
So we have $10000-2500-1666-1428-1000+833+357+500+238+333+142-119-166-47-71+23=5429$ integers.
\item
Find the number of integers between 1 and 10,000 that are neither perfect squares nor perfect cubes.

Because $\sqrt{10000}=100$ the perfect squares between 1 and 10000 inclusive are $\{1^2,2^2,\dots,100^2\}$. There are then 100 perfect squares. Similarly because $21^3<10000<22^3$ there are 21 perfect cubes which are $\{1^3,2^3,\dots,21^3\}$. Now if something is a perfect cube \emph{and} a perfect square, than it is a perfect sixth root. Because $4^6<10000<5^6$ there are 4 numbers which are perfect roots and perfect squares between 1 and 10000. Putting it all together we have $10000-100-21+4=9883$ integers that are neither perfect cubes, nor perfect squares.
\end{enumerate}

\end{document}


\chapter{Governing equations}
{\bf \Large
\begin{tabular}{ccc}
\hline
  Correnspoinding author & : & Hirofumi Tomita\\
\hline
\end{tabular}
}

\section{Continuity equations}

The continuity equations for each material can be described as the flux form:
\begin{eqnarray}
&&  \frac{\partial \rho q_d}{\partial t}
+ \nabla \cdot\left(\rho q_d{\bf u}\right)  = {\rm DIFF}\left[q_d\right]
\label{eq:rho_d}\\
&&  \frac{\partial \rho q_v}{\partial t}
+ \nabla \cdot\left(\rho q_v {\bf u}\right)  = S_v + {\rm DIFF}\left[q_v\right]
\label{eq:rho_v}\\
&&  \frac{\partial \rho q_l}{\partial t}
+ \nabla \cdot\left(\rho q_l {\bf u}\right)
+ \frac{\partial \rho q_l w_l}{\partial z}=S_l + {\rm DIFF}\left[q_l\right]
\label{eq:rho_l}\\
&&  \frac{\partial \rho q_s}{\partial t}
+ \nabla \cdot\left(\rho q_s {\bf u}\right)
+ \frac{\partial \rho q_s w_s}{\partial z}=S_s + {\rm DIFF}\left[q_s\right]
\label{eq:rho_s}
\end{eqnarray}
The summation of the mass concentrations should be unit:
\begin{eqnarray}
&& q_d + q_v + q_l + q_s = 1. \label{eq:total_massconcentration}
\end{eqnarray}
The source terms of water substances should satisfy the following relation:
\begin{eqnarray}
  S_v + S_l + S_s = 0.
\end{eqnarray}
The summation of Eqs.(\ref{eq:rho_d})-(\ref{eq:rho_s}) gives the
continuity equation of total density:
\begin{eqnarray}
&&  \frac{\partial \rho}{\partial t}
+ \nabla\cdot\left(\rho{\bf u}\right)
+ \frac{\partial \rho q_l w_l}{\partial z}
+ \frac{\partial \rho q_s w_s}{\partial z}
=0, \label{eq:rhotot}
\end{eqnarray}
For this derivation,
we assume that
the operator ${ \rm DIFF}\left[\right]$ is distributive.
Using Eq.(\ref{eq:total_massconcentration}),
\begin{eqnarray}
&&  { \rm DIFF}\left[q_d\right]
+{ \rm DIFF}\left[q_v\right]
+{ \rm DIFF}\left[q_l\right]
+{ \rm DIFF}\left[q_s\right]\nonumber\\
&=&{ \rm DIFF}\left[q_d+q_v+q_l+q_s\right]
={ \rm DIFF}\left[1\right] = 0
\end{eqnarray}

\section{Momentum equations}

The momentum equations for the gas, liquid, and solid material
are described as
\begin{eqnarray}
&&  \frac{\partial \rho \left(q_d+q_v\right) {\bf u}}{\partial t}
+ \nabla \cdot \left[\rho \left(q_d+q_v\right){\bf u} \otimes {\bf u}\right]\\
&=&
-\nabla p - \left[\rho \left(q_d+q_v\right)g + (f_l+f_s)\right] {\bf e_z}\nonumber\\
&&+{\bf u} S_v +{\rm DIFF}\left[(q_d+q_v){\bf u}\right]
\label{eq:momgas}\\
&&  \frac{\partial \rho q_l {\bf u}}{\partial t}
+ \nabla \cdot \left(\rho q_l{\bf u} \otimes {\bf u}\right)
+ \frac{\partial \rho q_l {\bf u} w_l}{\partial z}
=
 - \left(\rho q_l g - f_l\right) {\bf e_z}\nonumber\\
&&+{\bf u} S_l+{\rm DIFF}\left[q_l{\bf u}\right]
\label{eq:momliquid}\\
&&  \frac{\partial \rho q_s {\bf u}}{\partial t}
+ \nabla \cdot \left(\rho q_s{\bf u} \otimes {\bf u}\right)
+ \frac{\partial \rho q_s {\bf u }w_s}{\partial z}
=
 - \left(\rho q_s g - f_s\right) {\bf e_z}\nonumber\\
&&+{\bf u} S_s+{\rm DIFF}\left[q_s{\bf u}\right]
\label{eq:momsolid}
\end{eqnarray}
The pressure is derived from the equation of state as
\begin{eqnarray}
p=\rho \left(q_d R_d + q_v R_v\right) T.\label{eq:state}
\end{eqnarray}
The summation of Eqs.(\ref{eq:momgas})-(\ref{eq:momsolid})
gives the total momentum equation as
\begin{eqnarray}
&&  \frac{\partial \rho {\bf u}}{\partial t}
+ \nabla \cdot \left(\rho{\bf u} \otimes {\bf u}\right)
+ \left(\frac{\partial \rho q_l w_l}{\partial z}
+ \frac{\partial \rho q_s w_s}{\partial z}\right) {\bf e_z}\nonumber\\
&=&
-\nabla p - \rho g {\bf e_z}
+{\rm DIFF}\left[{\bf u}\right]
\label{eq:momtot}
\end{eqnarray}
Note that the drag forces by water loading does not appear
in Eq.(\ref{eq:momtot}),
because those term are cancelled out through the summation.

\section{Thermodynamics equations}

The equations of the internal energies are described as
\begin{eqnarray}
&&  \frac{\partial \rho (q_d e_d + q_v e_v) }{\partial t} +
  \nabla \cdot \left[ \rho (q_d e_d + q_v e_v ){\bf u} \right] \nonumber\\
&=& - p \nabla \cdot {\bf u} + Q_{d}+ Q_{v} + {\rm DIFF}\left[(q_d+q_v)T^{*} \right]
\label{eq:thermogas}\\
&&  \frac{\partial \rho q_l e_l}{\partial t} +
  \nabla \cdot \left( \rho q_l e_l {\bf u} \right)
+ \frac{\partial \rho q_l e_l w_l}{\partial z}
= Q_l + {\rm DIFF}\left[q_l T^{*} \right]
\label{eq:thermoliquid}\\
&&  \frac{\partial \rho q_l e_s}{\partial t} +
  \nabla \cdot \left( \rho q_s e_s {\bf u} \right)
+ \frac{\partial \rho q_s e_s w_s}{\partial z}
= Q_s + {\rm DIFF}\left[q_s T^{*} \right]
\label{eq:thermosolid}
\end{eqnarray}
where $T^*$ is some kind of potential temperature, discussed later.
The internal energies are defined as
\begin{eqnarray}
&& e_d = c_{vd} T\\
&& e_v = c_{vv} T\\
&& e_l = c_{l} T\\
&& e_s = c_{s} T,
\end{eqnarray}
The summation of Eqs.(\ref{eq:thermogas})-(\ref{eq:thermosolid})
gives the following internal energy equations:
\begin{eqnarray}
&&  \frac{\partial \rho e  }{\partial t}
+  \nabla \cdot \left( \rho e {\bf u} \right)
+ \frac{\partial \rho q_l e_l w_l}{\partial z}
 + \frac{\partial \rho q_s e_s w_s}{\partial z}
 + p \nabla \cdot {\bf u}\nonumber\\
&=&  Q + {\rm DIFF}\left[T^{*} \right]
\label{eq:etot}
\end{eqnarray}
where
\begin{eqnarray}
&&  e = q_d e_d + q_v e_v + q_l e_l + q_s e_s,
\end{eqnarray}
and the total diabatic heating is described as
\begin{eqnarray}
&&  Q = Q_d + Q_v + Q_l + Q_s.
\end{eqnarray}

\section{Conseptual seperation for solving the set of equations}

Eqs.(\ref{eq:rho_v})-(\ref{eq:rho_s}),(\ref{eq:rhotot}),(\ref{eq:momtot}),
and (\ref{eq:state}) with Eq.(\ref{eq:etot}) are the complete set of equations.
For solving them easily, we seperate the set of equations conceptually as
\begin{eqnarray}
&&  \frac{\partial \phi}{\partial t} =
\left(\frac{\partial \phi}{\partial t}\right)_{dynamics}
+\left(\frac{\partial \phi}{\partial t}\right)_{physics}\\
&&\phi^{*} = \phi^{n} +
\Delta t \left(\frac{\partial \phi}{\partial t}\right)_{dynamics}\\
&&\phi^{n+1} = \phi^{*} +
\Delta t \left(\frac{\partial \phi}{\partial t}\right)_{physics}
\end{eqnarray}
The falling proccess of liquid and solid waters,
the source and sink process of water vapor, and
the diabatic heating process for energy equations are treated
as physical process, the others are treated as dynamical proccess.

According to this scheme,
the dynamical process can be written as
\begin{eqnarray}
&&  \frac{\partial \rho q_v}{\partial t}
+ \nabla \cdot\left(\rho q_v {\bf u}\right)  = 0
\label{eq:rho_v_d}\\
&&  \frac{\partial \rho q_l}{\partial t}
+ \nabla \cdot\left(\rho q_l {\bf u}\right) = 0
\label{eq:rho_l_d}\\
&&  \frac{\partial \rho q_s}{\partial t}
+ \nabla \cdot\left(\rho q_s {\bf u}\right)
= 0
\label{eq:rho_s_d}\\
&&  \frac{\partial \rho}{\partial t}
+ \nabla\cdot\left(\rho{\bf u}\right)
=0 \label{eq:rhotot_d}\\
&&  \frac{\partial \rho {\bf u}}{\partial t}
+ \nabla \cdot \left(\rho{\bf u} \otimes {\bf u}\right)
=
-\nabla p - \rho g {\bf e_z} \label{eq:momtot_d}\\
&&  \frac{\partial \rho e  }{\partial t}
+  \nabla \cdot \left( \rho e {\bf u} \right)
 + p \nabla \cdot {\bf u}
=  0 \label{eq:etot_d}
\end{eqnarray}

On the other hand,
the physical processes are as follows:
\begin{eqnarray}
&&  \frac{\partial \rho q_v}{\partial t}  = S_v
+{\rm DIFF}\left[q_v \right]
\label{eq:rho_v_p}\\
&&  \frac{\partial \rho q_l}{\partial t}
+ \frac{\partial \rho q_l w_l}{\partial z}=S_l
+{\rm DIFF}\left[q_l \right]
\label{eq:rho_l_p}\\
&&  \frac{\partial \rho q_s}{\partial t}
+ \frac{\partial \rho q_s w_s}{\partial z}=S_s
+{\rm DIFF}\left[q_s \right]
\label{eq:rho_s_p}\\
&&  \frac{\partial \rho}{\partial t}
+ \frac{\partial \rho q_l w_l}{\partial z}
+ \frac{\partial \rho q_s w_s}{\partial z}
=0 \label{eq:rhotot_p}\\
&&  \frac{\partial \rho {\bf u}}{\partial t}
+ \frac{\partial \rho q_l {\bf u} w_l}{\partial z}
+ \frac{\partial \rho q_s {\bf u} w_s}{\partial z}
= {\rm DIFF}\left[{\bf u} \right]
 \label{eq:momtot_p}\\
&&  \frac{\partial \rho e  }{\partial t}
+ \frac{\partial \rho q_l e_l w_l}{\partial z}
 + \frac{\partial \rho q_s e_s w_s}{\partial z}
=  Q + {\rm DIFF}\left[T^{*} \right] \label{eq:etot_p}
\end{eqnarray}

\section{Conservation of thermodynamics in the dynamical process}

Equation (\ref{eq:etot_d}) is not a complete flux form,
because the internal energy itself is not conserved
both in the Euler sense and in the Lagrangian sense.
In this section, we consider the conservative
quantity for thermodynamics equation.

In the dry atmosphere, the potential temperature for dry air,
which is defined as
\begin{eqnarray}
\theta_d &=& T \left(\frac{p_{00}}{p}\right)^{R_d/c_{pd}},
\end{eqnarray}
is used as a conserved quantity it is conserved along the Lagrange trajectory
$c_{pd}$ $R_d$ are the specific heats at constant pressure and
However, it is no longer satisfied when the water substances are included.

Sinece Eq.(\ref{eq:rhotot_d}) is equivallent to
\begin{eqnarray}
  \frac{d \rho}{dt}+\rho \nabla \cdot {\bf u} = 0,
\end{eqnarray}
Equation (\ref{eq:etot_d}) is
\begin{eqnarray}
  \rho \frac{de}{dt} - \frac{p}{\rho}\frac{d \rho}{dt} =0. \label{eq:etot_d2}
\end{eqnarray}
Dividing by $\rho$, this equation can be written as
\begin{eqnarray}
  \frac{de}{dt} + p \frac{d}{dt}\left(\frac{1}{\rho}\right) = 0.
\label{eq:thermodyn}
\end{eqnarray}
Substiting Eq.(\ref{eq:state}) into Eq.(\ref{eq:thermodyn}),
\begin{eqnarray}
&& \frac{d  q_d c_{vd}   T}{dt} + p \frac{d}{dt} \left[\frac{q_d R_d T}{p}\right]
+\frac{d  q_v c_{vv}   T}{dt} + p \frac{d}{dt} \left[\frac{q_v R_v T}{p}\right]
\nonumber\\
&&+\frac{d  q_l c_{l}   T}{dt}+\frac{d  q_s c_{s}   T}{dt} =0
\label{eq:thermodyn_dash}
\end{eqnarray}

Since Eqs.(\ref{eq:rho_v_d})-(\ref{eq:rhotot_d}) give
\begin{eqnarray}
  \frac{d q_d}{dt} = \frac{d q_v}{dt} = \frac{d q_l}{dt} = \frac{d q_s}{dt} = 0,
\end{eqnarray}
Equation (\ref{eq:thermodyn_dash}) gives the following form:
\begin{eqnarray}
&& q_d  \left[\frac{d  c_{vd}   T}{dt} +  p \frac{d}{dt} \left[\frac{ R_d T}{p}\right]\right]
+q_v \left[\frac{d  c_{vv}   T}{dt} + p \frac{d}{dt} \left[\frac{ R_v T}{p}\right]\right]\nonumber\\
&&+ q_l  \frac{d  c_{l}   T}{dt} + q_s  \frac{d  c_{s}   T}{dt} =0
\end{eqnarray}
Dividing this equation by $T$,
\begin{eqnarray}
%1
&&q_d  \left[c_{pd} \frac{1}{T}\frac{d T}{dt}
+  R_d p \frac{d}{dt} \left(\frac{1}{p}\right)\right]
+q_v  \left[c_{pv} \frac{1}{T}\frac{d T}{dt}
+  R_v p \frac{d}{dt} \left(\frac{1}{p}\right)\right]\nonumber\\
&&+ q_l c_{l} \frac{1}{T}  \frac{d   T}{dt}
  + q_s c_{s} \frac{1}{T}  \frac{d   T}{dt} =0\\
%2
&&q_d c_{pd} \left[ \frac{d \ln T}{dt}
+  \frac{R_d}{c_{pd}} \frac{d}{dt} \left[\ln \left(\frac{1}{p}\right)\right]\right]
+q_v c_{pv}  \left[\frac{d \ln T}{dt}
+  \frac{R_v}{c_{pv}} \frac{d}{dt} \left[\ln \left(\frac{1}{p}\right)\right]\right]\nonumber\\
&&+ q_l c_{l}  \frac{d \ln T}{dt}
  + q_s c_{s}  \frac{d \ln T}{dt} =0 \label{eq:thermdyn2}\\
&&
 q_d c_{pd} \frac{d \ln \theta_d}{dt}
+q_v c_{pv} \frac{d \ln \theta_v}{dt}
+q_l c_l   \frac{d \ln T}{dt}
+q_s c_s   \frac{d  \ln T}{dt}=0\\
&&
\frac{d}{dt}\left[ \ln \left(
\theta_d^{q_d c_{pd}} \theta_v^{q_v c_{pv}} T^{q_l c_l} T^{q_s c_s}
\right)\right] = 0 \label{eq:lnThetaconserveation}
\end{eqnarray}
Thus,
\begin{eqnarray}
&&\frac{d}{dt}\left[
\theta_d^{q_d c_{pd}} \theta_v^{q_v c_{pv}} T^{q_l c_l} T^{q_s c_s}
\right] = 0
\end{eqnarray}
Thus, the following quantity is conserved along the flow trajectory;
\begin{eqnarray}
\Theta = \theta_d^{q_d c_{pd}} \theta_v^{q_v c_{pv}} T^{q_l c_l} T^{q_s c_s}
\end{eqnarray}
where $\theta_v$ is the potential temperature for water vapor, defined as
\begin{eqnarray}
\theta_v &=& T \left(\frac{p_{00}}{p}\right)^{R_v/c_{pv}}
\end{eqnarray}

The equation of state has the following expression using $\Theta$.
\begin{eqnarray}
\Theta &=&
T^{q_d c_{pd}} \left(\frac{p_{00}}{p}\right)^{q_d R_d}
T^{q_v c_{pv}} \left(\frac{p_{00}}{p}\right)^{q_v R_v}
T^{q_l c_l}  + T^{q_s c_s} \\
&=&
T^{q_d c_{pd} +q_vc_{pv}+q_lc_l+q_sc_s}
\left(\frac{p_{00}}{p}\right)^{q_d R_d + q_v R_v} \\
&=&
T^{c_p^*}\left(\frac{p_{00}}{p}\right)^{R^*},
\end{eqnarray}
where
\begin{eqnarray}
  c_p^* &\equiv& q_d c_{pd} +q_vc_{pv}+q_lc_l+q_sc_s\\
  R^* &\equiv& q_d R_d + q_v R_v
\end{eqnarray}
We define a new potential temperature
\begin{eqnarray}
\theta \equiv \Theta^{1/c_p^*} &=& T \left(\frac{p_{00}}{p}\right)^{R^*/c_p^*}
%&=& T \left(\frac{p_{00}}{p}\right)^{\frac{R_d}{c_{pd}} \alpha}
\end{eqnarray}
%% where
%% \begin{eqnarray}
%%   \alpha &=& \frac{q_d + q_v \frac{R_v}{R_d}}{q_d + q_v \frac{c_{pv}}{c_{pd}}+q_l\frac{c_l}{c_{pd}}
%% +q_s\frac{c_s}{c_{pd}}}
%% \end{eqnarray}

The pressure expression is derived diagnostically as follows:
\begin{eqnarray}
p&=&\rho (q_d R_d + q_v R_v) \theta \left(\frac{p}{p_{00}}\right)^{\frac{R^*}{c_{p}^*}}\\
p^{1-\frac{R^*}{c_{p}^*}}&=&\rho R^* \theta \left(\frac{1}{p_{00}}\right)^{\frac{R^*}{c_{p}^*}}\\
p&=&p_{00}\left(\frac{\rho \theta R^*}{p_{00}} \right)^{\frac{c_{p}^*}{c_{p}^*- R^*}}
\end{eqnarray}

Note that
\begin{eqnarray}
  \frac{d \theta}{dt} = \frac{1}{a} \Theta^{1/a-1} \frac{d \Theta}{dt} = 0
  \label{eq:theta_theta_relation}
\end{eqnarray}
Therefore, $\rho \theta$ can be employed for the prognostic varaiable!

Figure \ref{fig:fig1}(a) gives the vertical profile of the temperature
in the U.S.standard atmosphere and Fig.\ref{fig:fig1}(b) shows
the vetical profiles of $\theta/\theta_d$ under this temperature condition
when we assume that $q_v$ is mass concentration of water vapor at the saturation,
$q_l+q_s$ gives 0.0, 0.01, 0.02, and 0.04.
The differnce between $\theta$ and $\theta_d$ becomes
larger with the height and it may not be negligible.

\section{Diabatic heating in the physical process}

If the prognostic variable for thermodynamics is changed
from the internal energy to the newly defined potential temperature $\theta$,
the diabatic heating in Eq.(\ref{eq:etot_p}) should be modified.
Through
the manupulation from Eq.(\ref{eq:etot_d2}) to Eq.(\ref{eq:lnThetaconserveation}),
Eq.(\ref{eq:etot_p}) without turbulence term can be written as
\begin{eqnarray}
  \frac{d \ln \Theta}{dt} = \frac{Q}{\rho T}
  \label{eq:dlntheta_dt}
\end{eqnarray}
On the other hand, Eq.(\ref{eq:theta_theta_relation}) gives
\begin{eqnarray}
  \frac{d \theta}{dt} = \frac{1}{c_p^*} \Theta^{1/a} \frac{d \ln \Theta}{dt}
  \label{eq:dtheta_dt}
\end{eqnarray}
Substituting Eq.(\ref{eq:dlntheta_dt}) into Eq.(\ref{eq:dtheta_dt}),
\begin{eqnarray}
  \frac{d \theta}{dt} = \frac{1}{c_p^*}
  \left(\frac{p}{p_{00}}\right)^{\frac{R^*}{c_p^*}} \frac{Q}{\rho}
\end{eqnarray}

\section{Summary of equations in the dynamical process and physical process}
\subsection{The dynamical process}
\begin{eqnarray}
&&  \frac{\partial \rho q_v}{\partial t}
+ \nabla \cdot\left(\rho q_v {\bf u}\right)  = 0
\label{eq:rho_v_d2}\\
&&  \frac{\partial \rho q_l}{\partial t}
+ \nabla \cdot\left(\rho q_l {\bf u}\right) = 0
\label{eq:rho_l_d2}\\
&&  \frac{\partial \rho q_s}{\partial t}
+ \nabla \cdot\left(\rho q_s {\bf u}\right)
= 0
\label{eq:rho_s_d2}\\
&&  \frac{\partial \rho}{\partial t}
+ \nabla\cdot\left(\rho{\bf u}\right)
=0 \label{eq:rhotot_d2}\\
&&  \frac{\partial \rho {\bf u}}{\partial t}
+ \nabla \cdot \left(\rho{\bf u} \otimes {\bf u}\right)
=
-\nabla p - \rho g {\bf e_z} \label{eq:momtot_d2}\\
&&  \frac{\partial \rho \theta  }{\partial t}
+  \nabla \cdot \left( \rho \theta {\bf u} \right) =  0 \label{eq:etot_d2}\\
&& p=p_{00}\left(\frac{\rho \theta R^*}{p_{00}} \right)^{\frac{c_{p}^*}{c_{p}^*- R^*}}
\end{eqnarray}
where
\begin{eqnarray}
  c_p^* &\equiv& q_d c_{pd} +q_vc_{pv}+q_lc_l+q_sc_s\\
  R^* &\equiv& q_d R_d + q_v R_v
\end{eqnarray}

\subsection{The physical process}
\begin{eqnarray}
&&  \frac{\partial \rho q_v}{\partial t}  = S_v
+{\rm DIFF}\left[q_v \right]
\label{eq:rho_v_p2}\\
&&  \frac{\partial \rho q_l}{\partial t}
= - \frac{\partial \rho q_l w_l}{\partial z}+S_l
+{\rm DIFF}\left[q_l \right]
\label{eq:rho_l_p2}\\
&&  \frac{\partial \rho q_s}{\partial t}
=- \frac{\partial \rho q_s w_s}{\partial z}+S_s
+{\rm DIFF}\left[q_s \right]
\label{eq:rho_s_p2}\\
&&  \frac{\partial \rho}{\partial t}
=- \frac{\partial \rho q_l w_l}{\partial z}
 - \frac{\partial \rho q_s w_s}{\partial z}
 \label{eq:rhotot_p2}\\
&&  \frac{\partial \rho {\bf u}}{\partial t}
=
- \frac{\partial \rho q_l {\bf u} w_l}{\partial z}
- \frac{\partial \rho q_s {\bf u} w_s}{\partial z}
+{\rm DIFF}\left[{\bf u} \right]
 \label{eq:momtot_p2}\\
&&  \frac{\partial \rho \theta  }{\partial t}
=  \frac{1}{c_p^*} \left(\frac{p}{p_{00}}\right)^{\frac{R^*}{c_p^*}}
\left[Q
 - \frac{\partial \rho q_l e_l w_l}{\partial z}
 - \frac{\partial \rho q_s e_s w_s}{\partial z}
\right]
 + {\rm DIFF}\left[\theta \right] \label{eq:etot_p2}
\end{eqnarray}

\begin{figure}[t]
  (a)\\
  \includegraphics{./figure/us_std_atm_profile.eps}\\
  (b)\\
  \includegraphics{./figure/theta_theta_d_profile.eps}\\
  \caption{Thee vertical profile of (a) U.S. standard atmosphere,
  (b) Several profiles of $\theta/\theta_d$.}
  \label{fig:fig1}
\end{figure}


% ====================== Packages =============================
\documentclass[a4paper,12pt]{article}
\usepackage[left=2cm, right=2cm, top=2.5cm, bottom=2.5cm]{geometry}
\usepackage{fancyhdr , lipsum}
\usepackage{mathptmx}
\usepackage{anyfontsize}
\usepackage{t1enc}
\usepackage{csquotes}
\usepackage{enumitem}
\usepackage{xcolor}
\usepackage[linktocpage]{hyperref}
\usepackage{graphicx}
\usepackage{float}
\usepackage{cancel}
\usepackage{subcaption}
\usepackage[section]{placeins}
\usepackage[T1]{fontenc}
\usepackage{fontspec}
\usepackage{tcolorbox}
\usepackage[english]{babel}
\usepackage[export]{adjustbox}
\usepackage{parskip}
\usepackage{siunitx}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{tikz}
\usepackage{soul}
\def\checkmark{\tikz\fill[scale=0.4](0,.35) -- (.25,0) -- (1,.7) -- (.25,.15) -- cycle;}
\usepackage{setspace}
% Header and Footer
\usepackage{lipsum}%% a garbage package you don't need except to create examples.
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{Linear Algebra HW 5}
\rhead{ Page :  \thepage}
\cfoot{Hossein Dehghanipour - 9532250}
% End ofHeader and Footer
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\newcommand{\thedate}{\today}
\setlength{\parindent}{0pt}
\usepackage{atbegshi}% http://ctan.org/pkg/atbegshi
\AtBeginDocument{\AtBeginShipoutNext{\AtBeginShipoutDiscard}}

%====================== Border ================================

% ====================== Begin Doc =============================
\begin{document}

    \begin{titlepage}
        \begin{center}
            \title{\Large{\textbf{Linear Algebra - HW 5}}}
            \author{Hossein Dehghanipour - 9532250}
            \date{\today}
        \end{center}
    \end{titlepage}

    \maketitle
\begin{doublespace}
\begin{flushleft}
\begin{doublespace}
	Teacher :  Dr.Mehrzad Bighash
\end{doublespace}
\begin{doublespace}
	TA : Ms.F.Lotfi
\end{doublespace}
\end{flushleft}
\end{doublespace}

\newpage
\setmainfont{Times New Roman}
\pagenumbering{roman}
\tableofcontents
\thispagestyle{empty}
\newpage
\pagenumbering{arabic}

% *************** Questions Section ******************

\fontsize{15pt}{15pt}
\newcommand{\nnl}{\newline \noindent}
\newcommand{\ptx}{ P_{tx} }
\newcommand{\prx}{ P_{rx} }
%===================================
\section {Question 1}

\begin{figure}[h!]
	\centering
	\includegraphics*[height=3cm]{Q1}
\end{figure}

\begin{figure}[h!]
	\centering
	\includegraphics*[height=8cm]{Pic1}
\end{figure}

\begin{align*}
	&S = \pi r^2 = 4\pi \\
	&S^\prime = S * \left\| det \begin{pmatrix} a & b\\c & d \end{pmatrix} \right\|  \Rightarrow \\
	&S^\prime = S *\left\| ad - bc \right\| \Rightarrow 4\pi \left\| ad - bc \right\|
\end{align*}
\line(1,0){450}
\newpage
%===================================
\section {Question 2 }
\begin{figure}[h!]
	\centering
	\includegraphics*[height=3cm]{Q2}
\end{figure}

\begin{doublespace}
	As we know , $ I_n = \begin{pmatrix} 1 & 0 & 0 & 0\\0 & 1 & 0 & 0\\0 & 0 & \ddots & 0\\0 & 0 & 0 & 1 \end{pmatrix}_{n\times n}$ \\
	And we also know that $A \otimes I_n = \begin{pmatrix} A & 0 & 0 & 0\\0 & A & 0 & 0\\0 & 0 & \ddots & 0\\0 & 0 & 0 & A \end{pmatrix}_{n\times n}$\\
	We also know as a fact that $ det\begin{pmatrix} A & 0\\0 & D \end{pmatrix} = det(A)det(D) \Rightarrow $ so \\
	$det\begin{pmatrix} A & 0 & 0 & 0\\0 & A & 0 & 0\\0 & 0 & \ddots & 0\\0 & 0 & 0 & A \end{pmatrix}_{n\times n} =\underbrace{det(A)*det(A)*....*det(A)}_{\text{n times}} = det(A)^n $\\
\end{doublespace}

\line(1,0){450}
\newpage
%===================================

%===================================
\section {Question 3 }

\begin{figure}[h!]
	\centering
	\includegraphics*[height=2cm]{Q3}
\end{figure}

\begin{doublespace}
	\begin{align*}
		&det(AB^2) = 72 \Rightarrow det(A)det(B)^2 = 72 \\
		&det(A^2B^2) = 144 \Rightarrow det(A)^2 * det(B)^2 = 144\\
		&det(A) = ? , det(2A) = ? , det(AB) = ? \\
		&\frac{det(A^2B^2)}{det(AB^2)} = \frac{144}{72} \Rightarrow  \frac{ det(A) \cancel{det(A)}  \cancel{ det(B)^2}}{\cancel{det(A)} \cancel{det(B)^2}} \Rightarrow \textcolor{blue}{ det(A) = 2}  \\
		& det(A)det(B)^2 = 72 \Rightarrow 2 * det(B)^2 = 72 \Rightarrow \textcolor{blue}{ det(B) = 6} \\
		&det(2A) = 2^6 * det(A) = 2^6 * 2 = 2^7   \Rightarrow \textcolor{blue}{ det(2A) = 2^7 }\\
		&det(AB) = det(A) det(B) = 6 * 2 = 12 \Rightarrow \textcolor{blue}{det(AB) = 12 }
	\end{align*}
\end{doublespace}
\line(1,0){450}
\newpage
%===================================
\section {Question 4 }

\begin{figure}[h!]
	\centering
	\includegraphics*[height=5cm]{Q4}
\end{figure}

\subsection{Part I}
\begin{doublespace}
I would like to calculate the determinant using the second row due to having the most number of zeros which makes my calculations a lot easier.
	\begin{align*}
		&A = \begin{pmatrix} 0 & 5 & 1 & 4\\ 0 & 1 & 0 & 0\\ 8 & 1 & 7 & 5\\ 2 & 1 & 9 & 4\\ \end{pmatrix}\\
		& det(A) = (-1) det(A_{22}) + 0 = -det(A_{22}) \\
		& A^\prime = A_{22} = \begin{pmatrix} 0 & 1 & 4\\ 8  & 7 & 5\\ 2 & 9 & 4\\ \end{pmatrix} \\
		&det(A_{22}) = 0 * \dots -(1) det(A^\prime_{12}) + 4*det(A^\prime_{13}) \Rightarrow \\
		& = (-1)\begin{vmatrix}
			8 & 5  \\
			2 & 4 \\
			\end{vmatrix}
		+
		(4)\begin{vmatrix}
			8 & 7 \\
			2 & 9  \\
			\end{vmatrix}
		= (32 - 10 ) * (-1) + 4(72-14) = -22 + 4(58) = 232 - 22 = 210
	\end{align*}
\end{doublespace}
\line(1,0){450}

\subsection{Part II}
\begin{doublespace}
I would like to calculate the determinant using the second row due to having the most number of zeros which makes my calculations a lot easier.
	\begin{align*}
		&B = \begin{pmatrix} 4 & 2 & 7 & 0\\ 3 & 6 & 9 & 4\\ 1 &4 & 3 & 9\\ 4 & 0 & 1 & 1\\ \end{pmatrix}\\
		& det(B) = (4) det(B_{11}) -  (3) det(B_{12}) +  (7) det(B_{13})  \\
		& \textcolor{red}{det(B_{11}) = ? } \Rightarrow  B_{11} = \begin{pmatrix} 6 & 9 & 4\\ 4  & 3 & 9\\ 0 & 1 & 1\\ \end{pmatrix} \Rightarrow \\%% Det(11)
		& = (6)\begin{vmatrix} 3 & 9  \\ 1 & 1 \\ \end{vmatrix}  + (-4)\begin{vmatrix} 9 & 4 \\ 1 & 1  \\ \end{vmatrix} = (6*-6 ) - 4*5 =  -36 -20 = -56 \Rightarrow \\
		& \textcolor{blue}{det(B_{11}) =  -56 } \\
		& \textcolor{red}{det(B_{12}) = ? } \Rightarrow  B_{12} = \begin{pmatrix} 3 & 9 & 4\\ 1  & 3 & 9\\ 4 & 1 & 1\\ \end{pmatrix} \Rightarrow \\%% Det(12)
		& = (3)\begin{vmatrix} 3 & 9  \\ 1 & 1 \\ \end{vmatrix}  + (-9)\begin{vmatrix} 1 & 9 \\ 4 & 1  \\ \end{vmatrix} + (4)\begin{vmatrix} 1 & 3 \\ 4 & 1  \\ \end{vmatrix} = 3(-6) -9(-35) + 4(-11) = 253 \Rightarrow \\
		& \textcolor{blue}{det(B_{12}) = 253 } \\
		& \textcolor{red}{det(B_{13}) = ? } \Rightarrow  B_{13} = \begin{pmatrix} 3 & 6 & 4\\ 1  & 4 & 9\\ 4 & 0 & 1\\ \end{pmatrix} \Rightarrow \\%% Det(13)
		& = (4)\begin{vmatrix} 6 & 4  \\ 4 & 9 \\ \end{vmatrix}  + (1)\begin{vmatrix}3 & 6 \\ 1 & 4  \\ \end{vmatrix} = 4(56-16)  + (12-6) = 158 \Rightarrow \\
		& \textcolor{blue}{det(B_{13}) = 158 } \\
		&det(B) = 4(-56) -3(253) +7(158) = 123 \\
	\end{align*}
\end{doublespace}
\line(1,0){450}
\newpage
%===================================
\section {Question 5 }

\begin{figure}[h!]
	\centering
	\includegraphics*[height=1.5cm]{Q5}
\end{figure}

\begin{doublespace}
Prove that $det(A^{adj}) = det(A)^{n-1} $\\
	\begin{align*}
		&A^{-1} = \frac{A^{adj}}{det(A)} \Rightarrow \\
		 &A^{adj} = A^{-1} *  det(A) \xrightarrow{\text{*A from left}} \\
		&A * A^{adj} = A*A^{-1} *  det(A) \Rightarrow \\
		&A * A^{adj} = I_n * det(A) \xrightarrow{\text{det() from both sides}} \\
		&det(A * A^{adj}) =det( I_n * det(A))\\
	\end{align*}
We know that $ det(\alpha I_n) = \alpha^n $\\
	\begin{align*}
	&det(A * A^{adj}) =det( I_n * det(A)) \Rightarrow \\
	&det(A) * det(A^{adj}) =  det(A)^n \Rightarrow \\
	&det(A^{adj}) = det(A)^{n-1}
	\end{align*}
\end{doublespace}
\line(1,0){450}
\newpage
%===================================
End of this HomeWork.\\
This file is written in \LaTeX
% ====================== End Doc =============================
\end{document}

Samples/Sample 6 - Algebra HW 5/HW 5 .tex


\documentclass[main.tex]{subfiles}
\begin{document}

\subsection{Neutrino oscillations in vacuum}

\marginpar{Tuesday\\ 2021-12-14}

A ``vacuum'' in this context is a situation with very low fermion density, air is a good approximation for it for example.
We will later quantify the effects of interactions with matter.

The solution of Schrödinger's equation for that Hamiltonian is
%
\begin{align}
\left[\begin{array}{c}
\nu_1  \\
\nu_2  \\
\nu_3
\end{array}\right]
= e^{-i H_m x} \left[\begin{array}{c}
\nu_1  \\
\nu_2  \\
\nu_3
\end{array}\right]_0
\,,
\end{align}
%
but the interesting thing is to rewrite this in the flavor basis:
%
\begin{align}
H_f = U H_m U ^\dag = p \mathbb{1} + \frac{1}{2E} U M^2 U ^\dag
\,,
\end{align}
%
where \(M^2\) is the diagonal matrix with the square masses on the diagonal.

This is not a diagonal Hamiltonian anymore!

Factoring out the evolution according to \(p \mathbb{1}\) we get
%
\begin{align}
i \dv{}{x} \left[\begin{array}{c}
\nu _e \\
\nu _\mu  \\
\nu _\tau
\end{array}\right]
= \frac{1}{2E} U M^2 U ^\dag
\left[\begin{array}{c}
\nu _e \\
\nu _\mu  \\
\nu _\tau
\end{array}\right]
\,.
\end{align}

Since this is not diagonal, we can have both flavor \emph{appearance} and flavor \emph{disappearance}.

The evolution is given by the exponential
%
\begin{align}
S = \exp(-i H_f x) = \exp(- \frac{i}{2E} U M^2 U ^\dag x) = U \exp(-i \frac{M^2}{2E} x ) U ^\dag
\,,
\end{align}
%
because of the properties of unitary matrices in exponentials.

It is convenient to write this in components, \(\nu _\beta = S_{\beta \alpha } \nu _\alpha \):
%
\begin{align}
S_{\beta \alpha } = \sum _{i} U_{\beta i} \exp(-i \frac{m^2_i}{2E} )  U_{\alpha i} ^\dag
\,,
\end{align}
%
and the probability for this will be \(P(\nu _\alpha \to \nu _\beta ) = P_{\beta \alpha } = \abs{ S_{\beta \alpha }}^2\).

This modulus can be explicitly rewritten as
%
\begin{align} \label{eq:oscillation-probabilities}
P_{ \alpha \beta  } = \underbrace{\delta_{\alpha \beta } - 4 \sum _{i < j} \Re J^{ij}_{\alpha \beta } \sin^2 \left(\frac{ \Delta m^2_{ij} x}{4E}\right)}_{\text{CP-conserving}}
- \underbrace{2 \sum _{i<j} \Im J^{ij}_{\alpha \beta } \sin(\frac{\Delta m^2_{ij} x}{2E})}_{\text{CP-violating}}
\,,
\end{align}
%
where \(\Delta m^2_{ij} = m^2_i - m^2_j\) while \(J^{ij}_{\alpha \beta } = U_{\alpha i} U_{\beta i} ^\dag U_{\alpha j} ^\dag U_{\beta j}\).
This is called the Jarlskog invariant (Cecilia Jarlskog studied this first in the context of the CKM matrix).

This all is in natural units; the SI units version is
%
\begin{align}
\frac{\Delta m^2_{ij} x}{4E} \approx \num{1.267} \left(\frac{\Delta m^2_{ij}}{\SI{}{eV}}\right) \left(\frac{x}{\SI{}{m}}\right) \left(\frac{\SI{}{MeV}}{E}\right)
\,.
\end{align}

Interchanging \(\nu \) and \(\overline{\nu}\) is equivalent to
interchanging \(U \) and \(U *\);
interchanging \(\alpha \) and \(\beta \) is equivalent to
interchanging \(U\) and \(U ^\dag\).

What is the behavior of this under CP and T symmetries?

Let us call \(S\) the source of neutrinos, and \(D\) their detector.
We have \(\nu _\alpha \) at \(S\), and detect \(\nu _\beta \) at \(D\).

A CP transformation means we swap \(S\) and \(D\), and have \(\overline{\nu}_\alpha \) travelling backward to be detected as \(\overline{\nu}_\beta\).

A \(T\) transformation swaps \(S\) and \(D\) again.

If CP is conserved,
%
\begin{align}
P(\nu _\alpha \to \nu _\beta ) = P(\overline{\nu}_\alpha \to \overline{\nu}_\beta )
\,,
\end{align}
%
meaning that we must have \(U = U^{*}\); while if \(T\) is conserved we must have
%
\begin{align}
P(\nu _\alpha \to \nu _\beta ) = P(\nu _\beta \to \nu _\alpha )
\qquad \text{and} \qquad
P(\overline{\nu} _\alpha \to \overline{\nu} _\beta ) = P(\overline{\nu} _\beta \to \overline{\nu} _\alpha )
\,,
\end{align}
%
meaning that we must have \(U = U ^*\).

\todo[inline]{Say we observed \(P(\nu _e \to \nu _\mu ) \neq P(\overline{\nu} _e \to \overline{\nu}_\mu )\). Would that not prove that \(\nu _e \neq \overline{\nu}_e\) and/or \(\nu _\mu \neq \overline{\nu}_\mu \), meaning that neutrinos are not Majorana?}

A CPT transformation, therefore, must satisfy
%
\begin{align}
P(\nu _\alpha \to \nu _\beta ) = P(\overline{\nu}_\beta \to \overline{\nu}_\alpha )
\,.
\end{align}

This surely holds! It can be seen by the requirement \(U = U^{**}\), but it also holds in general as a theorem about field theories.

The CP-violating part can be isolated as shown in equation \eqref{eq:oscillation-probabilities}.

In the parametrization of the \(U _{\text{PMNS}}\) the CP-violation is parametrized as \(\delta \); it is currently compatible with 0.

In order to observe CP violation we must have \(\delta \neq 0, \pi \) (meaning that \(U \neq U^{*}\));
the second condition is that we must be looking at \(\alpha \neq \beta \)! In disappearance experiments the CP-violating part cancels.

All the mixing angles must be nonzero: \(\theta_{ij} \neq 0\).

The fourth condition is that all square mass differences are nonzero: \(\Delta m^2_{ij} \neq 0\).

CP violation is a genuine 3-neutrino phenomenon, it cannot be observed with 2!
Current experimental results are compatible with all conditions being realized, but it's hard since \(\delta m^2\) is about 30 times smaller than \(\Delta m^2\).

Most current experiments are only sensitive to a submatrix
%
\begin{align}
\left[\begin{array}{c}
\nu _\alpha  \\
\nu _\beta
\end{array}\right]
=
\left[\begin{array}{cc}
\cos \theta  & \sin \theta  \\
-\sin \theta  & \cos \theta
\end{array}\right]
\left[\begin{array}{c}
\nu _i  \\
\nu _j
\end{array}\right]
\,,
\end{align}
%
where \(\theta = \theta_{ij}\).

In this case, the probability simply reads
%
\begin{align}
P_{\alpha \beta } = \sin^2 2 \theta \sin^2 \left(\frac{\Delta m^2 L}{4E}\right)
\,,
\end{align}
%
while \(P_{\alpha \alpha } = 1 - P_{\alpha \beta }\).

We have no information on the sign of \(\Delta m^2\) since it is inside a \(\sin^2\); there is no information on the absolute masses, there is no information on \(\nu \leftrightarrow \overline{\nu}\).

There is an analogy with a double-slit experiment.

Practically, we do not observe probabilities but fluxes:
%
\begin{align}
R_\beta = \int \Phi _\alpha \otimes P_{\alpha \beta } \otimes \sigma _\beta \otimes \epsilon _\beta
\,,
\end{align}
%
which will be a multidimensional integral in general, a marginalization over all the parameters we do not care about --- the flux at the source, the interaction cross-section, the detector efficiency.

Let's say we have a \(\nu _\alpha \to \nu _\beta \) appearance experiment, and we do not observe anything.

What is typically done is to draw an \emph{exclusion zone} in the \(\Delta m^2, \sin^2 2 \theta \) plane.
The range for \(\theta \) is therefore \(0\) to \(\theta = \pi /4\).

Suppose, instead, that we observe a certain rate of \(\beta \) with \(R_\beta = R \pm \sigma _\beta \).

In that case as well we can draw an allowed band.
If we also have some spectral information, we can also measure \(L / E\), therefore we can intersect several of these bands and measure \(\Delta m^2 \) and \(\theta \) simultaneously.

We typically have \emph{octant ambiguity}: the respective \(\pi /4 < \theta < \pi /2\) value is typically also allowed.

This ambiguity has been removed for \(\theta_{12} \) and \(\theta_{23}\), not for \(\theta_{13} \).

Experiments which are sensitive to \(\Delta m^2 = m_3^2 - m^2_{1, 2}\):
\begin{enumerate}
    \item short baseline reactors, which attempt to observe \(\overline{\nu}_e \to \overline{\nu}_e\) with \(L \sim \SI{1}{km}\) and \(E \sim \text{few}\ \SI{}{MeV}\);
    \item long baseline accelerators, which attempt to observe \(\nu _\mu \to \nu _\mu \) or \(\nu _e\) or \(\nu _\tau \) (or antineutrinos), with \(L \sim \num{100} \divisionsymbol \SI{1000}{km}\) and \(E \sim 1 \divisionsymbol \SI{10}{GeV}\);\footnote{These are able to observe appearance as well as disappearance since the energy is so high! }
    \item atmospheric neutrino experiments, which attempt to observe \(\nu _\mu \to \nu _\mu \) or \(\nu _e\) (or antineutrinos) with \(L \sim 10 \divisionsymbol \SI{e4}{km}\) and \(E \geq \SI{1}{GeV}\).
\end{enumerate}

For these experiments, we typically have \(\delta m^2 L / 4 E \ll 1\), therefore we can take \(\delta m^2 \approx 0\).

The probability can then be written as
%
\begin{align}
P_{\alpha \beta } &= 4 \abs{U_{\alpha 3}}^2 \abs{U_{\beta 3}}^2 \sin^2 \left(\frac{\Delta m^2 L }{4E}\right) \\
P_{\alpha \alpha  } &= 1 - 4 \abs{U_{\alpha 3}}^2 (1 -\abs{U_{\alpha  3}})^2 \sin^2 \left(\frac{\Delta m^2 L }{4E}\right)
\,,
\end{align}
%
so these are able to probe a whole column of the mixing matrix; therefore, we can use these to measure \(\theta_{13} \) and \(\theta_{23} \), as well as \(\abs{ \Delta m^2}\).

Explicitly,
%
\begin{align}
P_{ee} &= 1 - \sin^2 2 \theta_{13} \sin^2 \left(\frac{\Delta m^2 L }{4E}\right)  \\
P_{\mu e} &= s^2_{23} \sin 2 \theta_{13} \sin^2 \left(\frac{\Delta m^2 L}{4E}\right)  \\
P_{\mu \mu } &= 1 - c^2_{13} s^2_{23} \left(1 - c^2_{13} s^2_{23}\right) \sin^2 \left(\frac{\Delta m^2 L }{4 E}\right)  \\
P_{\mu \tau } &= c^{4}_{13} \sin^2 2 \theta_{13} \sin^2 \left(\frac{\Delta m^2 L}{4E}\right)
\,,
\end{align}
%
the first three have been probed by atmospheric neutrinos, the first has been probed by short baseline experiments, the second two have been probed by long baseline experiments, the last has only been probed by OPERA (CERN to LNGS).

Atmospheric neutrinos have been probed by SuperKamiokande and IceCube.

The octant ambiguity for \(\theta_{13}\) from \(P_{ee}\) is resolved by \(P_{\mu \mu }\): it is indeed small and \(< \pi /4\).

On the other hand, \(\theta_{23}\) is close to \(\pi / 4\), and it is not determined in which octant it lies.

In the opposite case, we have \(\delta m^2 L / 4E\) of order 1, while \(\Delta m^2 L / 4 E \gg 1\), meaning that those oscillations are averaged away.

One can do this with hundreds of kilometers \(L\) but low energies, \(E \sim \text{few}\ \SI{}{MeV}\).

One finds, for KamLAND as well as for solar neutrinos:
%
\begin{align}
P_{ee}^{2 \nu } = c_{13}^{4} P_{2 \nu } + s_{13}^{4}
\qquad \text{where} \qquad
P_{2 \nu } = 1 - \sin^2 2 \theta_{12} \sin^2 \left(\frac{ \delta m^2 L}{4 E}\right)
\,.
\end{align}

These experiments are sensitive to the first row of the mixing matrix.

They measure \(\delta m^2 \sim \SI{7.5e-5}{eV^2}\).

Luckily there is a different possibility: solar neutrinos.
These break the ambiguity, thanks to matter effects.

\end{document}


\chapter{Miscellaneous}
\label{chap:Miscellaneous}

In this chapter, we will learn some miscellaneous
functions. It might seem counterintuitive to start
with miscellanea, but it is probably a good idea
to read this before arithmetics and more advanced
topics. You may read \secref{sec:Marshalling}
later. Before reading this chapter you should
have read \chapref{chap:Get started}.

\vspace{1cm}
\minitoc

\newpage
\section{Assignment}
\label{sec:Assignment}

To be able to do anything useful, we must assign
values to integers. There are three functions for
this: {\tt zseti}, {\tt zsetu}, and {\tt zsets}.
The last letter in the names of these function
describe the data type of the input, `i', `u',
and `s' stand for `integer', `unsigned integer',
and `string`, respectively. These resemble the
rules for the format strings in the family of
{\tt printf}-functions. `Integer' of course refer
to `signed integer'; for integer types in C,
part from {\tt char}, the keyword {\tt signed}
is implicit.

Consider {\tt zseti},

\begin{alltt}
   \textcolor{c}{z_t two;}
   \textcolor{c}{zinit(two);}
   zseti(two, 2);
\end{alltt}

\noindent
assignes {\tt two} the value 2. The data type of
the second parameter of {\tt zseti} is {\tt int64\_t}.
It will accept any integer value in the range
$[-2^{63},~2^{63} - 1] = [-9223372036854775808,~9223372036854775807]$,
independently of the machine.\footnote{{\tt int64\_t}
is defined to be a signed 64-bit integer using two's
complement representation.} If this range so not wide
enough, it may be possible to use {\tt zsetu}. Its
second parameter of the type {\tt uint64\_t}, and thus
its range is $[0,~2^{64} - 1] = [0,~18446744073709551615]$.
If a need negative value is desired, {\tt zsetu} can be
combined with {\tt zneg} \psecref{sec:Sign manipulation}.

For enormous constants or textual input, {\tt zsets}
can be used. {\tt zsets} will accept any numerical
value encoded in decimal ASCII, that only contain
digits, \emph{not} decimal points, whitespace,
apostrophes, et cetera. However, an optional plus
sign or, for negative numbers, an ASCII minus sign
may be used as the very first character. Note that
a proper UCS minus sign is not supported.

Using what we have learned so far, and {\tt zstr}
which we will learn about in \secref{sec:String output},
we can construct a simple program that calculates the
sum of a set of numbers.

\begin{alltt}
   \textcolor{c}{#include <stdio.h>
   #include <stdlib.h>
   #include <zahl.h>}

   int
   main(int argc, char *argv[]) \{
       z_t sum, temp;
       \textcolor{c}{jmp_buf failenv;
       char *sbuf, *argv0 = *argv;
       if (setjmp(failenv)) \{
           zperror(argv0);
           return 1;
       \}
       zsetup(failenv);
       zinit(sum);
       zinit(term);}
       zsetu(sum, 0);
       for (argv++; *argv; argv++) \{
           zsets(term, *argv);
           zadd(sum, sum, term);
       \}
       \textcolor{c}{printf("\%s\textbackslash{}n", (sbuf = zstr(sum, NULL, 0)));
       free(sbuf);
       zfree(sum);
       zfree(term);
       zunsetup();
       return 0;}
   \}
\end{alltt}

Another form of assignment available in libzahl is
copy-assignment. This done using {\tt zset}. As
easily observable, {\tt zset} is named like
{\tt zseti}, {\tt zsetu}, and {\tt zsets}, but
without the input-type suffix. The lack of a
input-type suffix means that the input type is
{\tt z\_t}. {\tt zset} copies value of second
parameter into the reference in the first. For
example, if {\tt v}, of the type {\tt z\_t}, has
value 10, then {\tt a} will too after the instruction

\begin{alltt}
   zset(a, v);
\end{alltt}

{\tt zset} does not necessarily make an exact
copy of the input. If, in the example above, the
{\tt a->alloced} is greater than or equal to
{\tt v->used}, {\tt a->alloced} and {\tt a->chars}
are preserved, of course, the content of
{\tt a->chars} is overridden. If however,
{\tt a->alloced} is less then {\tt v->used},
{\tt a->alloced} is assigned a minimal value at
least as great as {\tt v->used} that is a power
of 2, and {\tt a->chars} is updated accordingly
as described in \secref{sec:Integer structure}.
This of course does not apply if {\tt v} has the
value 0; in such cases {\tt a->sign} is simply
set to 0.

{\tt zset}, {\tt zseti}, {\tt zsetu}, and
{\tt zsets} require that the output-parameter
has been initialised with {\tt zinit} or an
equally acceptable method as described in
\secref{sec:Create an integer}.

{\tt zset} is often unnecessary, of course
there are cases where it is needed. In some case
{\tt zswap} is enough, and advantageous.
{\tt zswap} is defined as

\begin{alltt}
   \textcolor{c}{static inline} void
   zswap(z_t a, z_t b)
   \{
       z_t t;
       *t = *a;
       *a = *b;
       *b = *t;
   \}
\end{alltt}

\noindent
however its implementation is optimised to be
around three times as fast. It just swaps the members
of the parameters, and thereby the values. There
is no rewriting of {\tt .chars} involved; thus
it runs in constant time. It also does not
require that any argument has been initialised.
After the call, {\tt a} will be initialised
if and only if {\tt b} was initialised, and
vice versa.

\newpage
\section{String output}
\label{sec:String output}

Few useful things can be done without creating
textual output of calculations. To convert a
{\tt z\_t} to ASCII string in decimal, we use the
function {\tt zstr}, declared as

\begin{alltt}
   char *zstr(z_t a, char *buf, size_t n);
\end{alltt}

\noindent
{\tt zstr} will store the string it creates into
{\tt buf} and return {\tt buf}. However, if {\tt buf}
is {\tt NULL}, a new memory segment is allocated
and returned. {\tt n} should be at least the length
of the resulting string sans NUL termiantion, but
not larger than the allocation size of {\tt buf}
minus 1 byte for NUL termiantion. If {\tt buf} is
{\tt NULL}, {\tt n} may be 0. However if {\tt buf}
is not {\tt NULL}, it is unsafe to let {\tt n} be
0, unless {\tt buf} has been allocated by {\tt zstr}
for a value of {\tt a} at least as larger as the
value of {\tt a} in the new call to {\tt zstr}.
Combining non-\texttt{NULL} {\tt buf} with 0 {\tt n}
is unsafe because {\tt zstr} will use a very fast
formula for calculating a value that is at least
as large as the resulting output length, rather
than the exact length.

The length of the string output by {\tt zstr} can
be predicted by {\tt zstr\_length}, decleared as

\begin{alltt}
   size_t zstr_length(z_t a, unsigned long long int radix);
\end{alltt}

\noindent
It will calculated the length of {\tt a} represented
in radix {\tt radix}, sans NUL termination. If
{\tt radix} is 10, the length for a decimal
representation is calculated.

Sometimes it is possible to never allocate a {\tt buf}
for {\tt zstr}. For example, in an implementation
of {\tt factor}, you can reuse the string of the
value to factorise, since all of its factors are
guaranteed to be no longer than the factored value.

\begin{alltt}
   void
   factor(char *value)
   \{
       size_t n = strlen(value);
       z_t product, factor;
       zsets(product, value);
       printf("\%s:", value);
       while (next_factor(product, factor))
           printf(" \%s", zstr(factor, value, n));
       printf("\verb|\|n");
   \}
\end{alltt}

Other times it is possible to allocate just
once, for example of creating a sorted output.
In such cases, the allocation can be done almost
transparently.

\begin{alltt}
   void
   output_presorted_decending(z_t *list, size_t n)
   \{
       char *buf = NULL;
       while (n--)
           printf("\%s\verb|\|n", (buf = zstr(*list++, buf, 0)));
   \}
\end{alltt}

\noindent
Note, this example assumes that all values are
non-negative.

\newpage
\section{Comparison}
\label{sec:Comparison}

libzahl defines four functions for comparing
integers: {\tt zcmp}, {\tt zcmpi}, {\tt zcmpu},
and {\tt zcmpmag}. These follow the same naming
convention as {\tt zset}, {\tt zseti}, and
{\tt zsetu}, as described in \secref{sec:Assignment}.
{\tt zcmpmag} compares the absolute value, the
magnitude, rather than the proper value. These
functions are declared as

\begin{alltt}
   int zcmp(z_t a, z_t b);
   int zcmpi(z_t a, int64_t b);
   int zcmpu(z_t a, uint64_t b);
   int zcmpmag(z_t a, z_t b);
\end{alltt}

\noindent
They behave similar to {\tt memcmp} and
{\tt strcmp}.\footnote{And {\tt wmemcmp} and
{\tt wcscmp} if you are into that mess.}
The return value is defined

\vspace{1em}
\(
    \mbox{sgn}(a - b) =
    \left \lbrace \begin{array}{rl}
        -1 & \quad \textrm{if}~a < b \\
         0 & \quad \textrm{if}~a = b \\
        +1 & \quad \textrm{if}~a > b
    \end{array} \right .
\)
\vspace{1em}

\noindent
for {\tt zcmp}, {\tt zcmpi}, and {\tt zcmpu}.
The return for {\tt zcmpmag} value is defined

\vspace{1em}
\(
    \mbox{sgn}(\lvert a \rvert - \lvert b \rvert) =
    \left \lbrace \begin{array}{rl}
        -1 & \quad \textrm{if}~\lvert a \rvert < \lvert b \rvert \\
         0 & \quad \textrm{if}~\lvert a \rvert = \lvert b \rvert \\
        +1 & \quad \textrm{if}~\lvert a \rvert > \lvert b \rvert
    \end{array} \right .
\)
\vspace{1em}

\noindent
It is discouraged, stylistically, to compare against
$-1$ and $+1$, rather, you should always compare
against $0$. Think of it as returning $a - b$, or
$\lvert a \rvert - \lvert b \rvert$ in the case of
{\tt zcmpmag}.

\newpage
\section{Marshalling}
\label{sec:Marshalling}

libzahl is designed to provide efficient communication
for multi-processes applications, including running on
multiple nodes on a cluster computer. However, these
facilities require that it is known that all processes
run the same version of libzahl, and run on compatible
microarchitectures, that is, the processors must have
endianness, and the intrinsic integer types in C must
have the same widths on all processors. When this is not
the case, string conversion can be used (see \secref{sec:Assignment}
and \secref{sec:String output}), but when it is the case
{\tt zsave} and {\tt zload} can be used. {\tt zsave} and
{\tt zload} are declared as

\begin{alltt}
   size_t zsave(z_t a, char *buf);
   size_t zload(z_t a, const char *buf);
\end{alltt}

\noindent
{\tt zsave} stores a version- and microarchitecture-dependent
binary representation of {\tt a} in {\tt buf}, and returns
the number of bytes written to {\tt buf}. If {\tt buf} is
{\tt NULL}, the numbers bytes that would have be written is
returned. {\tt zload} unmarshals an integers from {\tt buf},
created with {\tt zsave}, into {\tt a}, and returns the number
of read bytes. {\tt zload} returns the value returned by
{\tt zsave}.


\section{Tuples}


%!TEX root = ../../report.tex

\subsection{CityGen } % (fold)
\label{sec:citygen}

CityGen \cite{Kelly2008} it's an interactive system that aims  to ``rapidly create the urban geometry typical of a modern city". The users can interact and control the generation process. The system, like others, is able to generate road networks that act as foundations to the model. It also can generate buildings but can not achieve the complexity and realism of other systems.

\subsubsection{Road Network} % (fold)
\label{ssub:road_network}

CityGen divided this problem in two steps. First the generation of the \emph{Primary Road Network}, and after that, the \emph{Secondary Road Network}. This two steps use different methods to generate the roads.
Undirected planar graphs are used to represent all roads. Two graphs for the Primary roads and one for each zone to store the secondary roads.

\begin{itemize}
	\item[Primary Road Generation] The primary road network uses two graphs, one high level graph that correspond directly to the primary road intersections. It represents the topological structure of the city by it's primary roads, and connections between them. The user is allowed to manipulate this high level graph, to change the high level structure ("topography of the primary road network") of the city .

There is also the low level graph that is generated from the other one, and defines the real path that the roads have in the terrain. It has the same nodes as the first graph and many more, that indicate the points on the terrain which the road passes.

To generate the low level graph it is used ``sampling, plotting and interpolation processes".
\end{itemize}

\begin{figure}[htbp]
	\centering
	\includegraphics[width=0.85\textwidth]{img/CityGen/RoadGraphs.png}
	\caption{The lighter graph is the High level graph, and the evolution to the darker Low-level graph }
	\label{fig:graphs}
\end{figure}

\begin{itemize}
	\item[Secondary Road Generation] The author defined city cells as districts, that are the areas of terrain that are enclosed by primary roads. The secondary road network is generated inside this cells using a growth based algorithm similar to the L-Systems technique as shown in Figure~\ref{fig:graphs2}.
\end{itemize}

\begin{figure}[htbp]
	\centering
	\includegraphics[width=0.85\textwidth]{img/CityGen/SecondaryRoadGrowth.png}
	\caption{}
	\label{fig:graphs2}
\end{figure}

% subsubsection road_network (end)

\subsubsection{Buildings} % (fold)
\label{ssub:buildings}

This system generates buildings also. Each building is created in lots that are identified after the extraction of enclosed regions, called blocks, from the secondary graph. Lots that don't have direct access to the roads are excluded.

Based on the type of block the building footprints are created. After that building geometry is generated by extruding the footprint. The height of each is determined by a height parameter and a noise factor that can be also manipulated. A block is shown in the Figure~\ref{fig:primitiveShapes}, with only primitive shapes.

\begin{figure}[htbp]
	\centering
	\includegraphics[width=0.85\textwidth]{img/CityGen/BockPrimitiveShapes.png}
	\caption{Primitive Shape Buildings}
	\label{fig:primitiveShapes}
\end{figure}

With this primitive shapes, CityGen uses ``advanced materials with shaders to simulate additional geometry".

% subsubsection buildings (end)

% subsection citygen (end)


\subsection{Normal goods}

As income rises, demand also rises.

This is the same as saying the income elasticity of demand is above \(0\).

\(\xi_i =\dfrac{\delta x_{di}}{\delta I}\dfrac{I}{x_{di}}\)

\subsection{Inferior goods}

An inferior good is one where the demand falls as income increases.

This is the same as the income elasticity of demand being less than \(0\).

\subsection{Necessities}

Necessities are goods which increase in demand as income rises, but by a smaller proportion.

The income elasticity of demand is between \(0\) and \(1\).

\subsection{Luxuries}

Luxuries are goods which increase in demand as income rises, by a larger proportion.

The income elasticity of demand is above \(1\).