\section{Preliminaries}
\label{sect:erssat-preliminaries}

An E-MAJSAT formula $\Qf$ has the form $\exists X,\random{} Y.\pf(X,Y)$,
where $X$ and $Y$ are two disjoint sets of Boolean variables,
and $\pf(X,Y)$ is a CNF formula.

\subsection{Solving E-MAJSAT with weighted model counting}
Given an E-MAJSAT formula $\Qf=\exists X,\random{} Y.\pf(X,Y)$ and an assignment $\as$ over $X$,
cofactoring the matrix with $\as$ results in a formula $\pcf{\pf}{\as}$ referring only to variables in $Y$.
The prefix $\random{} Y$ induces a weighting function $\wt: Y \mapsto [0,1]$ for each variable $y \in Y$,
where $\wt(y)$ equals the probability annotated on the randomized quantifier of $y$.
As a result, the conditional satisfying probability $\spb{\random{} Y.\pcf{\pf}{\as}}$,
which equals the weight of the formula $\pcf{\pf}{\as}$ under the weighting function $\wt$,
can be obtained by invoking a weighted model counter.
In the following,
the invocation to a weighted model counter is expressed by $\texttt{ComputeWeight}(\random{} Y.\pcf{\pf}{\as})$, which returns the conditional satisfying probability $\spb{\random{} Y.\pcf{\pf}{\as}}$.

\subsection{Clause selection}
\label{sect:erssat-clause-select}

\textit{Clause selection}~\cite{Janota2015,Rabe2015} is a novel technique for QBF solving.
Given a CNF formula $\pf(X,Y)$ over are two disjoint variable sets $X$ and $Y$,
we divide each clause $C\in\pf$ into two sub-clauses $\cx$ and $\cy$,
where $\cx$ (resp. $\cy$) consists of the literals whose variables are from $X$ (resp. $Y$).
For example, given a clause $C=(x_1 \lor x_2 \lor y_1 \lor y_2)$,
we have $\cx=(x_1 \lor x_2)$ and $\cy=(y_1 \lor y_2)$.
Clearly, $C=\cx\lor\cy$.

A clause $C$ is said to be \textit{selected} by an assignment $\as$ over $X$ if $\as$ falsifies every literal in $\cx$;
$C$ is said to be \textit{deselected} if $\as$ assigns some literal in $\cx$ to $\top$;
$C$ is said to be \textit{undecided} if it is neither selected nor deselected.
We also use $\pcf{\pf}{\as}$ to denote the set of clauses selected by an assignment $\as$ over $X$.

A \textit{selection variable} $\sv{C}$ is introduced for each clause $C$ and defined by $\sv{C}\equiv\lnot\cx$.
Hence, $\sv{C}$ is an indicator of the selection of clause $C$.
That is, $\sv{C}=\top$ (resp. $\sv{C}=\bot$) indicates $C$ is selected (resp. deselected).
Let $S$ be the set of selection variables for clauses in $\pf(X,Y)$.
The formula $\select(X,S)=\bigwedge\limits_{C\in\pf}(\sv{C}\equiv\lnot\cx)$ is called a \textit{selection relation} of $\pf(X,Y)$.

\begin{example}
    \label{ex:erssat-select}
    Consider a formula $\pf(X,Y)$ over two variable sets $X=\{e_1,e_2,e_3\}$ and $Y=\{r_1,r_2,r_3\}$.
    $\pf(X,Y)$ consists of four clauses:
    \begin{itemize}
        \item[] $C_1: (e_1 \lor r_1 \lor r_2)$
        \item[] $C_2: (e_1 \lor e_2 \lor r_1 \lor r_2 \lor \lnot r_3)$
        \item[] $C_3: (\lnot e_2 \lor \lnot e_3 \lor r_2 \lor \lnot r_3)$
        \item[] $C_4: (\lnot e_1 \lor e_3 \lor r_3)$
    \end{itemize}
    A set $S$ of selection variables $\{\sv{1},\sv{2},\sv{3},\sv{4}\}$ is introduced for each clause, respectively.
    The selection relation $\select(X,S)$ of $\pf(X,Y)$ equals
    \begin{align*}
        \select(X,S)=
        (\sv{1} \equiv \lnot e_1) \land
        (\sv{2} \equiv \lnot e_1 \land \lnot e_2) \land
        (\sv{3} \equiv e_2 \land e_3) \land
        (\sv{4} \equiv e_1 \land \lnot e_3).
    \end{align*}
    Consider a complete assignment $\as_1=\lnot e_1 \lnot e_2 \lnot e_3$ over $X$.
    $C_1$ and $C_2$ are selected while $C_3$ and $C_4$ are deselected,
    as can be seen from the selection relation cofactored with $\as_1$,
    which results in $\pcf{\select(X,S)}{\as_1}=s_1s_2\neg s_3 \neg s_4$.
    Consider a partial assignment $\as_2=\lnot e_1 e_3$ over $X$.
    It selects $C_1$, deselects $C_4$, and leaves $C_2$ and $C_3$ undecided.
    Notice that the two complete assignments $\lnot e_1 \lnot e_2 e_3$ and $\lnot e_1 e_2 e_3$ consistent with $\as_2$ select $\{C_1, C_2\}$ and $\{C_1, C_3\}$, respectively.
    The clause $C_1$ selected by the partial assignment $\as_2$ lies in the intersection of the sets of clauses selected by the two complete assignments consistent with $\as_2$.
\end{example}


\section{The \findiii algorithm---using a logic function}
\Label{sec:findiii}

In this section we specify linear search yet another way.
This requires more preparing work but results in a more concise function contract.

\subsection{The logic function \Find}

We start with a \emph{recursive} definition of the \acsl function \Find.
Due to the considerable number of associated lemmas of the function
\Find we split its definition into several listings.
Note that \Find comes as two \emph{overloaded} functions.
While the first version is defined for \emph{array sections} the latter is intend
for \emph{complete arrays}.

The listings start with lemmas which express elementary
properties directly related to an incremental increase of the array \inl{a[0..n-1]}.
The latter lemmas are somewhat more higher-level and will
be useful for the verification of \findiii.
It will be there that we also reuse the predicates
\logicref{SomeEqual}and
\logicref{NoneEqual}.
%
At the end of this section we will also discuss in what sense the contracts
of \findii and \findiii are equivalent.

\begin{logic}[hbt]
\begin{minipage}{0.99\textwidth}
\lstinputlisting[linerange={1-60}, style=acsl-block, frame=single]{Source/Find.acsl}
\end{minipage}
\caption{\Label{logic:Find-1}The logic function \Find (1)}
\input{Listings/Find.acsl.labels.tex}
\input{Listings/Find.acsl.index.tex}
\end{logic}

\FloatBarrier

\begin{logic}[hbt]
\begin{minipage}{0.99\textwidth}
\lstinputlisting[linerange={61-92}, style=acsl-block, frame=single]{Source/Find.acsl}
\end{minipage}
\caption{\Label{logic:Find-2}The logic function \Find (2)}
\end{logic}

\FloatBarrier

\subsection{Formal specification of \findiii}

Using the logic function \Find we can now give a third specification of linear search.
The contract of \specref{findiii} is considerably shorter than that of \specref{findii}.
Of course, we had to put much more effort into the definition of the \acsl
function \logicref{Find}.

\input{Listings/find3.h.tex}

\clearpage

\subsection{Implementation of \findiii}

The following listing shows the implementation of \implref{findiii}.
In order to achieve a complete verification we had to add the assertion \inl{found}.

\input{Listings/find3.c.tex}

A question that remains is in what sense the contract of \specref{findii} is equivalent to
the one of \specref{findiii}.
We will answer this question in the following section.

\subsection{The equivalence of \findii and \findiii}
\Label{sec:findiv}
\Label{sec:findv}

We consider the contracts of \specref{findii} and \specref{findiii} as \emph{equivalent}
if each one is sufficient to verify the other.
To this end we introduce yet another two examples \findiv and \findv.

The implementation of \implref{findiv} consists just of a call to \findiii.

\input{Listings/find4.c.tex}

\clearpage

The contract of \specref{findiv}, however, is the same as the one of \specref{findii}.

\input{Listings/find4.h.tex}

Analogously, the implementation of \implref{findv} is simply a call to \findii.

\input{Listings/find5.c.tex}

On the other hand, the contract of \specref{findv} is the same as the one of \specref{findiii}.
%
The verification of the functions \findiv and \findv
(cf.\ Table~\ref{tbl:result-nonmutating}) then shows the equivalence
of the respective contracts of \specref{findii} and \specref{findiii}.

\input{Listings/find5.h.tex}

\clearpage


\documentclass{article}
\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{cancel}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, calc}
\allowdisplaybreaks

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

\begin{document}
\title{Notes}
\date{April 28, 2014}
\maketitle
bijections

self-conjugate $\leftrightarrow$ distinct odd parts

odd-parts $\leftrightarrow$ distinct parts

\section*{homework}
prove that when you conjugate two partitions it reverses the majorization order.

induction on size of partition? notational question. give yourself some notation.

\[\lambda=\lambda_1+\lambda_2+\lambda_3+\dots+\lambda_k\]
\begin{align*}
  \mu\le\lambda\text{ so } \lambda_1+\dots+\lambda_i\ge\mu_1+\dots+\mu_i\\
  \mu=\mu_1+\mu_2+\dots+\mu_k
\end{align*}
\section*{schr\"{o}der paths: 8.5}
\subsubsection*{definition}
a dissection of a polygon is a partition of its interior into regions by inserting noncrossing diagonals.
  \begin{tikzpicture}
    \node (pol) [draw, thick, blue!90!black,rotate=90,minimum size=4cm,regular polygon, regular polygon sides=5] at (0,0) {};
    %\foreach \n [count=\nu from 1, remember=\n as \lastn, evaluate={\nu+\lastn}] in {1,2,...,4}
    %\node[anchor=\n*(360/5)]at(pol.side \n){$a_{\nu}$};
    \draw (pol.corner 1) -- (pol.corner 3);
    \draw (pol.corner 3) -- (pol.corner 5);
    %\node[anchor=5*(360/5)]at(pol.side 5){$((a_1 a_2)(a_3 a_4))$};
  \end{tikzpicture}

question: how many dissections of triangle, square, pentagon? 1,3,11

question apply multiplication scheme like map to dissections to obtain bracketings

\subsubsection*{definition}
a bracketing of $a_1\dots a_n$ is a multiplication scheme where parentheses can enclose any  number of variables
\subsection*{theorem}
bracketings of n variables are in bijections with dissections of an $n+1$-gon.
\subsubsection*{definition}
a large schr\"{o}der path is a path  from $(0,0)$ to $(2n,0)$ with steps in the set which never go below the x-axis. note that dyck paths are schr\"{o}der paths with no $(1,0)$ steps

question how many large schr\"{o}der pths are there for n=1,2,3...
$R_n=2S_{n+1}$ where $R_n$ is large and $S_n$ is small.

question: what is a recurrance for $R_n$?

$R_n$ start with (0)+start with (1). $R_n=R_{n+1}+\sum\limits_{k=1}^n{R_{k-1}R_{n-k}}$. define $R_0=1$.
\end{document}


\pagebreak
\chapter{Transcranial Temporal Interference Stimulation (tTIS) Theory}

To better understand the physics behind the simulations, a brief explanation regarding the conduction within the media is presented in \autoref{sec:e_ohmic_qs}, followed by an analysis regarding the \gls{tTIS} hypothesis based on Grossman et al.\cite{Grossman2017} work.

\section{Electric Field Ohmic Quasi-static Approximation}
\label{sec:e_ohmic_qs}

Generally Maxwell's equations for electromagnetic wave propagation in a medium are as follows:
% Maxwells equations
\begin{center}
\begin{minipage}{.35\linewidth}
    \begin{equation}
        \nabla\cdot\vec{E}=\dfrac{\rho}{\epsilon}
    \end{equation}
\end{minipage}
\begin{minipage}{.35\linewidth}
    \begin{equation}
        \nabla\cdot\vec{B} = 0
    \end{equation}
\end{minipage}\break
\begin{minipage}{.35\linewidth}
    \begin{equation}
        \label{eq:maxwell_curl_e}
        \nabla\times\vec{E}=-\dfrac{\partial\vec{B}}{\partial t}
    \end{equation}
\end{minipage}
\begin{minipage}{.35\linewidth}
    \begin{equation}
        \nabla\times\vec{B} = \mu\Bigg(\vec{J} + \epsilon\dfrac{\partial\vec{E}}{\partial t}\Bigg)
    \end{equation}
\end{minipage}
\end{center}

\noindent The problem in question, finding the electrical field distribution in a volume using low frequencies, can be approached by simplifying the general form of Maxwell's equations and deriving the Quasi-static approximation format. The first step is to define the assumptions taken in order for such an approach to be valid.

For the frequencies used in the studied problem, in \si{kHz} range, the displacement current can be neglected making the Ohmic currents dominate. Also, since the magnetic field is not time variant, based on \autoref{eq:maxwell_curl_e} we can write:
\begin{equation}
    \label{eq:curl_zero_e_field}
    \nabla\times\vec{E} = \vec{0}
\end{equation}
and as we know when a field is irrotational then it can be calculated from a scalar potential ($\phi$) as seen below:
\begin{equation}
    \label{eq:e_field_from_potential}
    \boxed{\vec{E} = -\nabla\phi}
\end{equation}

\noindent Moreover, since the sum of currents entering and exiting the volume is zero \textit{(Kirchhoff's second law)} we can denote:
\begin{equation}
    \nabla\cdot\vec{J} = 0
\end{equation}
where here $\vec{J}$ is the ohmic current seen below as it is assumed that there are no current sources in the volume:
\begin{equation}
    \label{eq:sigma_e_0}
    \vec{J} = \sigma\vec{E}\Rightarrow\boxed{\nabla\cdot\big(\sigma\vec{E}\big) = 0}
\end{equation}
with $\sigma$ being the electrical conductivity of each medium. Finally, based on \cref{eq:e_field_from_potential,eq:sigma_e_0} the final relationship describing the problem can be derived:
\begin{equation}
    \label{eq:laplace_e}
    \boxed{\nabla\cdot(\sigma\nabla\phi) = 0}
\end{equation}

\autoref{eq:laplace_e} describes the problem of conduction, using bulk conductors, but it is worth noting that the equation is only valid in the frequency domain where the displacement current effects are negligible and only when there is no charge generated \textit{(charge is conserved)}. Furthermore, care shall be taken with the conductivity values, since depending on the material it may be dependant on the frequency used for the stimulation.

\pagebreak
\section{Temporal Interference}
The utilization of \gls{tTIS} to achieve targeted \gls{DBS} was first introduced by Grossman et al.\cite{Grossman2017}. This technique takes advantage of the spatial electromagnetic wave interference, using frequencies at the \si{kHz} range, having almost no effect on neurons since it is known that they do not respond to higher than 1\si{kHz} \draft{(citation needed)} frequencies.
\\\vspace{1pt}

\begin{wrapfigure}{r}{0.48\textwidth}
    \vspace{-10pt}
    \centering
    \includegraphics[width = 0.44\textwidth]{assets/images/brain_figure_ttis.pdf}
    \caption[Depiction of the \gls{tTIS} pattern and the vector direction of the electric field. The purple area is the \gls{ROI} where interference happens.]{Depiction of the \gls{tTIS} pattern and the vector direction of the electric field. The purple area is the \gls{ROI} where interference happens. Image by \href{https://pixabay.com/users/openclipart-vectors-30363/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=150935}{OpenClipart-Vectors} from \href{https://pixabay.com/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=150935}{Pixabay}}
    \label{fig:brain_elec_demo}
\end{wrapfigure}

Using two pairs of electrodes (\autoref{fig:brain_elec_demo}), with each pair having a slightly different frequency, an interference pattern can be generated in the conducting medium oscillating at the difference of the two frequencies. Depending on the nature of the medium the pattern can vary and as illustrated in Grossman et al.\cite{Grossman2017} when a uniform medium is used, it is simple and easy to calculate.

Since the modulation happens in the 3D space, there will be different patterns in the $x$, $y$ and $z$ directions. According to Grossman et al.\cite[page 20]{Grossman2017}, at any location $\vec{r} = (x,y,z)$ the envelope amplitude of the \gls{AM} of the electric field produced by the temporal interference, it is calculated as:
\begin{equation}
    \label{eq:directional_amplitude}
    \vec{E}(\vec{n},\vec{r}) = \Big|\big|(\vec{E_1} + \vec{E_2})\cdot\vec{n}\big| - \big|(\vec{E_1} - \vec{E_2})\cdot\vec{n}\big|\Big|
\end{equation}
where $\vec{E_1} = \vec{E_1}(\vec{r})$, $\vec{E_2} = \vec{E_2}(\vec{r})$ are the electric fields coming from the two electrodes and $\vec{n} = \vec{n}(\vec{r})$ is the unit vector at the direction of interest.
\\\vspace{1pt}

What is of interest is the maximum amplitude of modulation at a specific location since the modulation will vary with time between zero and maximum. To calculate that amplitude across all directions, the analysis on Grossman et al.\cite[page 20]{Grossman2017} can be better supported by the analysis done on Rampersad et al.\cite[section 2.5]{Rampersad2019} and based on the two aforementioned publications, a complete description will be given here. The formula to calculate the maximum modulation amplitude, along all directions at a specific location, $\vec{r} = (x,y,z)$, is:
\begin{equation}
    \label{eq:max_mod_amplitude}
    \vec{E}_{AM}^{max}(\vec{r}) = \begin{cases}
        2\big|\vec{E_2}\big| & \text{if}\; \big|\vec{E_2}\big| < \big|\vec{E_1}\big|\cos\alpha \\
        &\\
      2\dfrac{\Big|\big|\vec{E_2}\big|\times\big(\vec{E_1} - \vec{E_2}\big)\Big|}{\big|\vec{E_1} - \vec{E_2}\big|} & \text{otherwise}
    \end{cases}
\end{equation}
where $\alpha$ is the angle between $\vec{E_1}$ and $\vec{E_2}$, while \autoref{eq:max_mod_amplitude} holds true only if $\alpha < 90\si{\degree}$. Whenever $\alpha \geq 90\si{\degree}$, the sign of one of the two fields can be flipped \textit{(it must be done is a consistent fashion)} since reaching peak field strength at different time points across different areas, is what makes the $< 90\si{\degree}$ rule to be violated. Such a change is possible considering that \autoref{eq:max_mod_amplitude} calculates the maximum effect over one oscillation, so the overall effect is the one that we care. The calculation of $\vec{E}_{AM}^{max}$ can be seen in \autoref{alg:max_modulation_amplitude} at \autoref{appndx:algorithms}.


\chapter{Method}
\label{chap:method}

The Serpent 2 Monte Carlo code uses a combination of  ray tracing and
delta-tracking to simulate the propagation of particles. The \gls{wdt}
method modifies delta-tracking for an absorbing medium, replacing virtual
collisions with a weight reduction. In this chapter, we will discuss
the \gls{wdt} routine for absorption events, and extend the method to
include scattering. We will then define the \gls{wdt} threshold, a key
parameter for its implementation in Serpent 2.

\section{\Acrlong{wdt}}
\label{sec:wdt}

Morgan and Kotlyar~\cite{morgan2015} introduced a method to improve the
inefficiencies of Woodcock delta-tracking in the presence of large
absorbers. The method, \gls{wdt}, replaces the
rejection sampling algorithm of delta-tracking with a weight reduction
algorithm. This process is similar to survival biasing, or implicit capture.

\subsection{Implicit Statistical Events}
\label{sec:implicit}

We consider a process that can result in multiple outcomes, each with
their own probability. One approach is to sample a random variable and
determine which outcome actually occurred. If the event occurs many
times, we can instead replace the
statistical process by using the expected value of the random process
\cite{lux1991}. The expected value of a random variable $x$ that can
take values ${x_1 \ldots x_n}$ with  probabilities ${p_1 \ldots p_n}$, respectively,
is given by:
\begin{equation}
  \label{eq:expval}
  E[x] = x_1p_1 + x_2p_2 \ldots + x_{n}p_n\:.
\end{equation}
For example, imagine we have a bag with four coins, three worth \$0.25 and
one worth \$0.10. The values and their probabilities are:
\begin{align*}
  x_1 = 0.25, \quad p_1 = \frac{3}{4} = 0.75 \:;\\
  x_2 = 0.10, \quad p_2 = \frac{1}{4} = 0.25\:.
\end{align*}
For a given draw, we could sample a random value and use the
probabilities $p_1$ and $p_2$ to determine the coin drawn. Or, we can
describe the expected value of the drawn coin:
\begin{align*}
  E[x] &= x_1p_1 + x_2p_2 \\
  &= (0.25 \times 0.75) + (0.10 \times 0.25) \\
  &= 0.2125
\end{align*}
\begin{minipage}{1.0\linewidth}
  This value represents the average value of a coin drawn, if we
  perform many draws. The following Matlab code replicates this
  procedure:
\begin{lstlisting}
v = 0;
n = 1000;
for i = 1:n
    xi = rand;
    v = v + (xi < 0.25)*0.1 + (xi >= 0.25)*0.25;
end
\end{lstlisting}
\end{minipage}
% will the campus get picky about the margins? Can you indent this?
% Removed the line numbers, they were extraneous anyway -jsr
Although the exact values will vary due to the small sample size, \verb|v/n|
$\approx 0.2125$, as we expected.

This framework is often applied to neutron propagation in a process
called ``survival biasing'' \cite{lewis1993}. At each collision location, the type of
interaction is sampled and the appropriate action taken. In the case
of a capture event, the neutron is ``killed'' (removed from the
simulation). While this accurately reflects the physical reality, it
does not produce good statistics. Assuming we are using a collision
estimator, the neutron's contribution to our simulation is the history
of collisions. Each of these provide a score to that particular
collision, contributing to the overall simulation
statistics. Capture events that kill neutrons, therefore, are
removing the very particles we need to generate better statistics,
resulting in the need for many more particles. Mitigating this issue
is the goal of survival biasing.

Survival biasing avoids killing neutrons by replacing capture
events with an expected outcome. As described above, we do not need to
track the outcome of every single event, but can rely on the expected
value. This will give us, on average, the outcome of our many
events. To eliminate our explicit consideration of capture events,
we therefore have two possible event types: capture events, and
scattering events. The probabilities $p$ will be given by the
ratios of the cross-sections:
\begin{align*}
  p_{c} = \frac{\Sigma_{c}}{\Sigma_t} \:,\\
  p_{s} = \frac{\Sigma_{s}}{\Sigma_t}\:,
\end{align*}
where $\Sigma_{c}$ and $\Sigma_{s}$ are the macroscopic cross-sections
for capture and scattering, respectively.

In the coin example, each had a different monetary value, giving us an
expected value when we drew many times. We must introduce something
similar for neutrons. It is convention to call this intrinsic value
``weight'', which represents the importance of the neutron. All
neutrons are born with the same weight, usually unity, and are killed
when they have zero weight. At each point of interaction, the incoming
neutron has an initial weight based on the neutron's history $w_i$,
and a final weight $w_f$ that depends on the type of interaction. A
capture event that kills a neutron immediately forces the final weight
of the neutron to zero $w_{f,c} = 0$. We can then
calculate the expected value of the interaction of a neutron with
initial weight $w_i$:
% what is w_{f}? is it final and w_{i} is initial, wrt the specific interaction?
% you can probably shorten scattering to s and capture to c
\begin{align*}
  E[w_f] &= w_{f,s}p_\mathrm{s} +
           w_{f,c}p_\mathrm{c} \\
  &= w_{f,s}p_\mathrm{s}
\end{align*}
A scattering event merely changes the location of the neutron in
energy and angle phase space, leaving its importance
unchanged. Therefore, $w_{f,s} = w_i$ and:
\begin{align*}
  E[w_f] = w_ip_s\:.
\end{align*}
With implicit capture
% what is the now? with implicit capture? Yes -jsr
every collision is considered to be a non-capture event. The
neutron continues with a lower weight, proportional to the probability
that the event was scattering. The weight lost in the collision is
scored as capture:
\begin{align*}
  S_c &= E[w_i - w_f] \\
  &= E[w_i] - E[w_f] \\
&= w_i - w_ip_{s} \\
&= w_i(1-p_{s})\:,
\end{align*}
where $S_c$ is the score for capture. A similar method will be used
by weighted delta-tracking.
%S = socre? Yes -jsr

\subsection{Russian Rouletting}
\label{sec:rouletting}

When the survival biasing routine described in Sec.~\ref{sec:implicit}
is used, the loss of neutrons is entirely reliant on leakage from the
problem or fission events. Neutrons will continue to undergo
collisions and subsequent weight reduction until they have a very low
weight. These particles will only contribute small amounts to our
statistics, so tracking them is computationally inefficient.  To
mitigate this, a lower cutoff for the weight is introduced. Once
neutrons are below this weight, they have a chance of being killed by
a Russian Rouletting routine.
\begin{algorithm}
\caption{Rouletting Routine}\label{alg:roulette}
\begin{algorithmic}[1]
\If{weight $<$ weight threshold}
   \State $\xi \gets $ random number $\in [0,1)$
   \If{$\xi < $ roulette probability}
     \State Kill particle
   \Else
     \State $w_f \gets w_i$/(roulette probability) \label{inc}
   \EndIf
\EndIf
\end{algorithmic}
\end{algorithm}

The general algorithm is shown in
Algorithm~\ref{alg:roulette}. Following a collision, if the weight of the colliding particle is
below a defined weight threshold, a random number is sampled. If this
number is below a defined rouletting probability, the particle is
killed. If the particle survives rouletting, its weight is increased
proportionaly to the rouletting probability. By either killing low weight
particles or increasing their weight, the inefficiency of tracking
low-weight particles can be reduced.

\subsection{\Acrlong{wdt}}
\label{sec:wdttheory}

Morgan and Kotlyar~\cite{morgan2015} introduced a method to improve
the inefficiencies of Woodcock delta-tracking in the presence of large
absorbers. The method, \gls{wdt}, replaces the rejection sampling of
delta-tracking with a weight reduction. This is similar to the process
of implicit capture discussed in Section~\ref{sec:implicit}.

The \gls{wdt} method samples the particle path length in the same fashion as
Woodcock delta-tracking. As described in Section~\ref{sec:delta-tracking},
after each path length is sampled, the delta-tracking method accepts the
collision as real with the probability shown in
Eq.~\ref{eq:preal}. The \gls{wdt} method bypasses this rejection sampling by
accepting all collisions as real with a subsequent reduction in
weight. As discussed in Section~\ref{sec:implicit}, replacing a
statistical event requires calculation of the expectated value. In
this case, the two events are a real collision and a virtual
collision:
\begin{equation}
  \label{eq:wdtexpected}
  E[w_f] = w_{f,\mathrm{real}}P_{\mathrm{real}} + w_{f,\mathrm{virt}}P_{\mathrm{virt}}\:.
\end{equation}
Morgan and Kotlyar examine a 1D test case with absorption. As an
absorption event removes the particle, the resulting final weight of a
real collision is zero. A virtual collision is rejected, and therefore
leaves the weight unchanged. Inserting the appropriate values into
Eq.~\eqref{eq:wdtexpected} gives the expected value of the final
weight for an absorption event:
\begin{align*}
  \label{eq:mkexpected}
  E[w_f] &= w_{f,\mathrm{real}}P_{\mathrm{real}} +
           w_{f,\mathrm{virt}}P_{\mathrm{virt}} \\
  &= 0 + w_iP_{\mathrm{virt}} \\
  &= w_i(1-P_\mathrm{real}) \\
  &= w_i\left(1-\frac{\Sigma_t}{\Sigma_\mathrm{maj}}\right)\:.
\end{align*}
The particle that is left following the collision continues propagating
as if it underwent a virtual collision. In this case, the absorption
is then scored using the expectation value of the score.
\begin{align*}
  S_\mathrm{absorption} &= E[w_i - w_f] \\
  &= E[w_i] - E[w_f] \\
  &= w_i\left(\frac{\Sigma_t}{\Sigma_\mathrm{maj}}\right)
\end{align*}
This algorithm is implemented by Kotlyar and Morgan in a 1D problem and the
results are verified with an analytical solution. The authors point
out that a rouletting routine should be implemented when \gls{wdt} is used,
to prevent the tracking of low-weight neutrons.

\section{\Acrlong{wdt} with scattering}
\label{sec:wdt_scattering}

In a scattering event, the weight of the incident particle does not
change. Therefore, application of the expectation value as in
Section~\ref{sec:wdttheory} results in an expected value of the final
weight equal to the initial weight:
\begin{align*}
  E[w_f] &= w_{f,\mathrm{real}}P_{\mathrm{real}} +
           w_{f,\mathrm{virt}}P_{\mathrm{virt}} \\
  &= w_iP_\mathrm{real} + w_iP_{\mathrm{virt}} \\
  &= w_i(P_\mathrm{real} + 1 -P_\mathrm{real}) \\
  &= w_i\:.
\end{align*}

This doesn't model what we expect. We can view \gls{wdt} as splitting
the weighted neutron into two particles. One carries the real portion
of the weight and experiences the collision. The other carries the
virtual portion of the weight and continues propagating as if no
collision occurred. This works fine for absorption, where the portion
that experiences the collision does not propagate: it is immediately
killed and scored. But, when the neutron is split into a scattering
portion and a virtual portion, no weight is lost because neither of
those events change the weight.

Therefore, extension of this methodology to scattering requires duplication of
the particle at the point of collsion. The virtual portion of the
weight is carried away by a particle that propagates as if no
collision has occured, and the real portion is carried away by a
particle that undergoes scattering. In problems with scattering, this
results in a rapid multiplication of neutrons. When implemented into
Serpent 2, this multiplication very quickly filled any available
neutron buffer in simulations of a \gls{bwr}, ending
the simulation. We therefore expanded the \gls{wdt} method with a
novel approach to handling scattering. This approach combines the
\gls{wdt} methodology with the standard delta-tracking rejection
sampling in a way that has not been done before.

% Add a sentence or two in here (or a quick additional paragraph) pointing out that this
% is new: no one has done this before. It's good to explicitly call attention to your
% contribution so that readers are clear what's new and what was your intellectual contribution.

\subsection{Scattering Rejection Sampling}
\label{sec:scattering}

As described in the last section, the \gls{wdt} method may result in
an intractable simulation when applied to scattering.
This occurred because the \gls{wdt} method splits the incoming weight
in two: one portion for a real collision, one portion for a virtual
collision. We developed a new methodology that avoids splitting the
neutron when scattering, while keeping the splitting otherwise. To
accomplish this, the original delta-tracking rejection sampling was
moved into the scattering subroutine. The algorithm is shown in
Alg.~\ref{alg:scattalg} and a flow chart of the routine is shown in
Fig.~\ref{fig:wdt}.

\begin{figure}[p]
\begin{algorithm}[H]
\caption{\Acrlong{wdt} with scattering}\label{alg:scattalg}
\begin{algorithmic}[1]
  \State \textbf{Sample} path length
  \State \textbf{Sample} collision type
  \If{collision type == (capture or fission)}
    \State \textbf{Score} capture or fission $\gets
    w_iP_\mathrm{real}$
    \State \textbf{Score} collision  $\gets w_iP_\mathrm{real}$
    \State $w_f \gets w_i(1-P_\mathrm{real})$
    \State \textbf{Execute} virtual collision
  \Else
    \State \textbf{Sample} random number $\xi \in [0,1)$
    \If{$\xi < P_\mathrm{real}$} \Comment{Collision is real}
    \State \textbf{Score} scattering $\gets w_i$
    \State \textbf{Score} collision $\gets w_i$
      \State \textbf{Execute} scattering collision
    \Else \Comment{Collision is virtual}
    \State \textbf{Execute} virtual collision
    \EndIf
  \EndIf
\end{algorithmic}
\end{algorithm}
  \centering
  \includegraphics[scale=0.5]{images/wdt}
  \caption{\Acrlong{wdt} with scattering rejection sampling.\label{fig:wdt}}
\end{figure}
Note that there are two separate scoring events in each collision
subroutine: scoring of the actual collision type for calculating
specific reaction rates, and scoring of collision itself used by the
collision flux estimator. In addition, scoring the fission reaction
also encompasses generation of fission neutrons.

In the original delta-tracking routine, the rejection sampling takes
place prior to collision type sampling, and collision scoring can
occur between the two. This is the routine that Serpent 2 used, prior
to modification for the above scheme. By moving the rejection sampling
after the collision type sampling, the collision score is no longer
agnostic to the type of collision that will occur. Therefore, in the
implementation of this routine in Serpent 2, the collision scoring was
moved after the collision type sampling.

\section{Implementation in Serpent 2}
\label{sec:method_implementation}

The \gls{wdt} algorithm is implemented to work alongside the current
implementation of ray tracing and delta-tracking, as described in
Sec.~\ref{sec:serpent2}. \gls{wdt} is designed to improve the
effectiveness of delta-tracking when the change of a virtual collision
is high. We can hypothesize that the algorithm will benefit in the
regime where $P_{\mathrm{real}}$ is low. At high values of
$P_{\mathrm{real}}$, a majority of the weight of the incoming particle
is scored. This leaves the particle that undergoes a virtual collision
with a very low weight, relying on the rouletting routine to prevent
computational inefficiency. These two situations imply that
there is a region between low and high values of $P_\mathrm{real}$
where \gls{wdt} may provide benefit.

This region is defined by two values, summarized in
Fig.~\ref{fig:ray_wdt}. On the lower end, the value of $(1-c)$ defines
the threshold below which surface tracking is used. On the upper end,
a new parameter $t_{\mathrm{wdt}}$ defines the threshold below which
\gls{wdt} will be used instead of normal delta-tracking. This provides
the user with the ability to exactly define the region where \gls{wdt}
will be used.
\begin{figure}[hbtp]
  \centering
  \begin{align*}
    \mathrm{Mode} =
    \begin{cases}
      \mathrm{Ray tracing}, & P_\mathrm{real} < 1-c \\
      \mathrm{\gls{wdt}}, & 1-c \leq P_\mathrm{real} < t_{\mathrm{wdt}}
      \\
      \mathrm{Delta-tracking}, & P_\mathrm{real} \geq t_{\mathrm{wdt}}
    \end{cases}
  \end{align*}
  \begin{tikzpicture}[scale=1.5]
    \draw[thick] (0,0) -- (10.0,0);
    \foreach \x in {0,1,...,10}
    {
      \draw (\x, 0.1) -- (\x, -0.1);
      \pgfmathsetmacro\result{\x * 0.1}
      \node [below] at (\x, -0.2) {\small $\pgfmathprintnumber{\result}$};
    }
    \node [left] at (0,0) {$P_{\mathrm{real}}$};
    \draw[ thick, <->] (0,0.2) -- (1,0.2);
    \draw[ thick, <->] (1,0.2) -- (4,0.2);
    \draw[ thick, <->] (4,0.2) -- (10,0.2);
    \node [above] at (0.5, 0.2) {Ray tracing};
    \node [above] at (2.5, 0.2) {WDT};
    \node [above] at (7, 0.2) {Delta-tracking};
  \end{tikzpicture}
  \caption[Implemented selection scheme for ray-tracing, weighted and normal
    delta-tracking.]{Implemented selection scheme for ray-tracing, weighted, and normal
    delta-tracking. Shown using the values of $(1-c)=0.1$ and $t_{\mathrm{wdt}}=0.4$.}
  \label{fig:ray_wdt}
\end{figure}
% this makes sense; I still think you can get rid of the previous figure.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../masters_report"
%%% End:


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage[letterpaper, total={7.5in, 9in}]{geometry}

\title{Stochastic Processes}
\author{Grant Smith }
\date{Spring 2022}

\begin{document}

\maketitle

\section{Primer on Random Variables and Conditional Random Variables}

In this section, I want to give two views on conditional probabilities and show how they coincide. The first view is very early in a probability textbook:

$$P(A|B) = \frac{P(A \cap  B)}{P(B)}$$

Also please note that it might appear that $P(A|B)$ is proportional to $P(A)$ perhaps by a proportionality factor such as $1/P(B)$, but that is not true because $P(A)$ is not proportional to $P(A \cap  B)$.  They are truly different distrubutions.  Thus, $P(A|B)$ is totally different from $P(A)$, because $P(A \cap  B)$ is totally different from $P(A)$, which is the crutial insight.  The only situation in which they would be similar would be if $A$ and $B$ are independent, at which point the scaling intuition would be true.

Next, I want to explain how if two random variables ($X_1$ and $X_2$) are defined on the same event space, observing one random variable, say $X_1$, filters your event space into a smaller event space, and now there is a new random variable that is $X_2$ restricted to that smaller event space. Let's call the value we observe $x_1$.  The new, restricted, event space is $X_1^{-1}(x_1)$, which means it is the inverse image of $x_1$ under the random variable (aka function) $X_1$.  Our notation for this is $X_2 | X_1 = x_1$. Also note that the probability measure defined on the original event space is now modified to a new measure which depends on the observed value of $X_1$.  This measure (of course) adds up to 1, and those elements in the event space previously added up to less than or equal to 1, so in general they get bigger, but the probability of each element does not necessarily increase.  Also, they are not scaled linearly or anything like that -- we do not know how they change until we know the two random variables.

\section{Stochastic Process Introduction}

I want to develop a little intuition between how we think about stochastic processes, for example, the stock market, and how they're defined in a probability book.  First of all, here is a picture:

\includegraphics[width=4in]{stochastic_ image.png}
\centering

We have a sample space, $\Omega$, and from that sample space, we map to functions of time (or anything else you want).  We call it a stochastic process, but all it is is a function from a sample space to a space of functions.  The notation is $X_t$, but what's under the hood is the following:

$$X_t = x : \Omega \rightarrow \left(\mathbb{R}^+ \rightarrow  \mathbb{R} \right)$$

But we don't really perceive that sample space.  What we perceive (for example when observing the stock market) is that we've observed a process up to a certain time, and we don't know what's going to happen next.  How does that fit into the framework above? Let's start with a picture of a stochastic process.  Here it is, and ignore the 3.5 for now. We'll use it in about two paragraphs.

\includegraphics[width=4in]{filtration_part_1.png}
\centering

Let's say this is a stock price over time, and we'll call it $X_t$.  The picture on the right is all the possible trajectories, and the sample space on the left has a corresponding event for each trajectory (I didn't count, so the dots and the trajectories probably don't align, but that's okay).

At our initial time, we have no idea which of these trajectories the stock will take.  But then let's wait a little bit (wait until time 3.5) and observe the price.  Let's say the trajectory we observe is the following:

\includegraphics[width=2.2in]{filtration_part_2.png}
\centering

So now we have information about which of the original trajectories are still possible, and which ones are impossible. This is called a filtration, and in our case, we have the filtration at time 3.5, so we will call it$\mathcal{F}_{3.5}$, but in general, it would be $\mathcal{F}_{t}$.

So now we want to figure out what happens to our stochastic process $X_t$ given the information (aka filtration) we know at time 3.5. What the filtration does is filter out all the trajectories that cannot be the case, and it leaves in all the remaining possible trajectories.  The picture is:

\includegraphics[width=4in]{filtration_part_3.png}
\centering

You'll notice that the trajectories that don't align with our filtration are gray, and the events in the sample space that correspond to those trajectories are also gray.  And the trajectories that are possible are still black, and their corresponding events are also still black.

This should feel like a conditional probability, and that's exactly what's happening. We want $Y_t := X_t | \mathcal{F}_{3.5}$.  Thus, $Y_t$ is given by the following drawing:

\includegraphics[width=4in]{filtration_part_4.png}
\centering

At this point, we've really explained a lot.  One last part you might be wondering is what would happen if we changed the 3.5.  And you'd be right. So our $Y_t$ is dependent upon our observation duration. So I'll ammend our notation to be $X_t(s) := X_t | \mathcal{F}_{s}$, which means that the stochastic process we get (a.k.a. remaining trajectories) depends on how long we observe.  So we could say that $Y_t = X_t(3.5)$.  So let's draw another picture for another time, say 4.5. We will start with what we've observed by time = 4.5:

\includegraphics[width=2.2in]{filtration_4.5.png}
\centering

And now we can gray out from the picture of $X_t(3.5)$:

\includegraphics[width=3.2in]{Filtration_grayed_4.5.png}
\centering

And it is hard to see, but one of the elements in the sample space is also grayed out. Which leaves us with our final image of $X_t(4.5)$:

\includegraphics[width=3.2in]{final_4.5.png}
\centering

And this time, it's very clear that I miscounted, and there should only be four elements in the sample space corresponding to the four possible trajectories.

Grant, a note to you, you wanted to write about what $X_t(s)$ looks like???

Lastly, I'm working on making a GeoGebra activity to illustrate this. When it's up, I'll update the link, but here is my account for now: https://www.geogebra.org/u/gsmithapples.

\section{Differentiation and Integration}
Here is the best way I know to think about stochastic differentiation and integration. We'll redraw our picture, and its equation and notation are given below.

\includegraphics[width=4in]{stochastic_ image.png}
\centering

$$X_t = x : \Omega \rightarrow \left(\mathbb{R}^+ \rightarrow  \mathbb{R} \right)$$
$$x(\varsigma_1) = f_1(t)$$
$$x(\varsigma_2) = f_2(t)$$
$$x(\varsigma) = f_\varsigma(t)$$

And note that $x$ is simply a deterministic function.  Also note that we can partially apply and curry however we want, so we also have the following, which will be useful in the following section:

$$X_t = x : \Omega \rightarrow \left(\mathbb{R}^+ \rightarrow  \mathbb{R} \right) = \Omega \rightarrow \mathbb{R}^+ \rightarrow  \mathbb{R} = x :  \left(\Omega  , \mathbb{R}^+\right)\rightarrow  \mathbb{R}$$

\subsection{Differentiation}
We have that:

$$X_t' = \frac{\partial}{\partial t}x(\varsigma,t)= \frac{x\left(\varsigma, t + h\right) - x\left(\varsigma, t\right)}{h} = \frac{f_\varsigma\left(t + h\right) - f_\varsigma\left(t\right)}{h} = \frac{df_\varsigma}{dt} =g\left(\varsigma, t\right)$$

Which means that $X_t'$ is just the probability weighted derivatives of the trajectories. Which, just like $x$, is just a deterministiic function of $\varsigma$ and $t$

Side note that this does not work in Brownian Motion because the individual trajectories in Brownian Motion are not differentiable (anywhere).  I think we might be able to do it with some form of a weak derivative, though, just not the regular one.

Also note that we are using the prime notation for a derivative, but it is a partial derivative. That's okay because $\Omega$ isn't necessarily a continuous variable like $t$ is, so when we're differentiating, it is understood that we're differentiating with respect to the only reasonable option, $t$.

\subsection{Integration}
We have that:
$$\int X_t= \int_{s = 0}^{s = t} X_s ds = \int_{s = 0}^{s = t} x\left(\varsigma,s\right) ds = \int_{s = 0}^{s = t} f_\varsigma\left(s\right) ds  = h\left(\varsigma,t\right)$$

Which means that $\int X_t$ is just the probability weighted integrals of the trajectories.  Which, just like $x$ and $g$, is just a deterministic function of $\varsigma$ and $t$

I think we can do this with Brownian Motion because even though Brownian Motion trajectories are not (in the normal sense) differentiable, they are integrable.

\subsection{Differentiation and Integration Example}
Suppose there are only two states of the world, Heads and Tails.  And if Heads is flipped, our world is $x^2 + 2$ and if Tails is flipped, we get $1$.  Our process is:

\includegraphics[width=3in]{ExampleProcess.png}
\centering

\[X_t = \begin{cases}
    t^2 + 2 & H \\
    1 & T
 \end{cases}
\]

Then we also know:

\[\int X_t = \begin{cases}
    \frac{1}{3}t^3 + 2t + C_1 & H \\
    t + C_2 & T
 \end{cases}
\]
\[X_t = \begin{cases}
    t^2 + 2 & H \\
    1 & T
 \end{cases}
\]
\[X'_t = \begin{cases}
    2t & H \\
    0 & T
 \end{cases}
\]

And those integration constants are deterministic (i.e. they are just numbers).

\section{Ito Processes}

\subsection{Intro}

If you have a stochastic process that can be written \textbf{\emph{as a function of}} Ito processes, a.k.a. it can be written \textbf{\emph{in terms of}} Ito processes, then you can write it \textbf{\emph{as}} an Ito Process. And that's what Ito's formula tells us how to do.  This is the equation of an Ito process:

$$Z_t = Z_0 + \int_{0}^{t} u_s ds + \int_{0}^{t} \sigma_s dW_t$$

So if we have a stochastic process given to us in terms of an Ito process like above, then we can write it as above. Mathematically, that means we have a process $Z_t = f(t,X_t)$ where $X_t$ is an Ito process, and we will show that this new stochastic process is itself an Ito process, and we will be able to explicitly state its formula.  This is done with Ito's formula:

$$Z_t = f(t,X_t) = a + \int_{s=0}^{s=t} \frac{\partial f}{\partial t}(s,X_s) + \mu_s \frac{\partial f}{\partial x}(s,X_s) + \frac{1}{2}{\sigma _s}^2\frac{\partial^2 f}{{\partial x}^2}(s,X_s)  ds + \int_{s=0}^{s=t}\sigma_s\frac{\partial f}{\partial x}(s,X_s) dW_s   $$

Which, you will notice, is in the form of an Ito process, which is the goal.  It helps us transform an arbitrary process written in terms of an Ito process ($Z_t$ or $f(t,X_t)$) into an explicitly stated Ito process.

\subsection{Derivation}

Let's try to approximate $f$ with a Taylor Series.  The statement is the following (and accompanied with the same thing with explicit dependencies):

$$\Delta f = \frac{df}{dt} * \Delta t$$
$$\Delta f(t, \Delta t) = \frac{df}{dt}(t) * \Delta t$$

Where $\Delta f$ is the name of a function, and it now depends on two things: $x$ and $\Delta t$.  What about an approximation with a second order term?  In one dimension, we could have:

$$\Delta f = \frac{df}{dt} * \Delta t + \frac{1}{2} \frac{d^2f}{dt^2} \Delta t ^2$$

And in two dimensions, we would have:

$$\Delta f = \frac{\partial f}{\partial t} \Delta t + \frac{\partial f}{\partial x} \Delta x + \frac{1}{2}\frac{\partial^2 f}{{\partial t}^2} {\Delta t}^2 + \frac{1}{2}\frac{\partial^2 f}{{\partial t}^2} {\Delta x}^2 +  \frac{\partial^2 f}{\partial t \partial x} \Delta t\Delta x$$

And with dependencies stated explicitly:

$$\Delta f(t,x,\Delta t,\Delta x) = \frac{\partial f}{\partial t}(t,x) \Delta t + \frac{\partial f}{\partial x}(t,x) \Delta x  + \frac{1}{2}\frac{\partial^2 f}{{\partial t}^2}(t,x) {\Delta t}^2 + \frac{1}{2}\frac{\partial^2 f}{{\partial t}^2}(t,x) {\Delta x}^2 +  \frac{\partial^2 f}{\partial t \partial x}(t,x) \Delta t\Delta x$$

Or if we wanted to write it a little differently, instead of using $\Delta$ notation on $t, x$, we could write them at times 1 and 2:

$$\Delta f(t_1,t_2,x_1,x_2) = \frac{\partial f}{\partial t}(t_1,x_1) *[t_2-x_1] + \frac{\partial f}{\partial x}(t_1,x_1) *[x_2-x_1]  + ... $$

$$... +  \frac{1}{2}\frac{\partial^2 f}{{\partial t}^2}(t_1,x_1) * {[t_2-t_1]}^2 + \frac{1}{2}\frac{\partial^2 f}{{\partial x}^2}(t_1,x_1) * {[x_2-x_1]}^2 +  \frac{\partial^2 f}{\partial t \partial x}(t_1,x_1) *[t_2-t_1]*[x_2-x_1]$$

What is the benefit of this different notation instead of the deltas? The benefit is that now it's obvious that when you replace the $t$s or $x$s, you replace the first and second, i.e. you replace the value and the $d$, rather than just the value.

Now I'm just going to plug in the stochastic $X_t$ for $x$

$$\Delta f(t_1,t_2,X_1,X_2) = \frac{\partial f}{\partial t}(t_1,X_1) *[t_2-t_1] + \frac{\partial f}{\partial x}(t_1,X_1) *[X_2-X_1]  + ... $$

$$... +  \frac{1}{2}\frac{\partial^2 f}{{\partial t}^2}(t_1,X_1) * {[t_2-t_1]}^2 + \frac{1}{2}\frac{\partial^2 f}{{\partial x}^2}(t_1,X_1) * {[X_2-X_1]}^2 +  \frac{\partial^2 f}{\partial t \partial x}(t_1,X_1) *[t_2-t_1]*[X_2-X_1]$$

Here we notice that $X_t$ is also a function of t. So our Taylor series and chain rule can be a little different.  In particular, if we let $\Delta t$ go very small, there might be some behavior in $X_t$ that could help us. What if $f$ is a function of $t$ and $x$, but $X_t$ is also a function of $t$? I think that's what's going on in our problem.  So we have:

$$\Delta f(t_1,t_2,X_{t_1},X_{t_2}) = \frac{\partial f}{\partial t}(t_1,X_{t_1}) *[t_2-t_1] + \frac{\partial f}{\partial x}(t_1,X_{t_1}) *[X_{t_2}-X_{t_1}]  + ... $$

$$... +  \frac{1}{2}\frac{\partial^2 f}{{\partial t}^2}(t_1,X_{t_1}) * {[t_2-t_1]}^2 + \frac{1}{2}\frac{\partial^2 f}{{\partial x}^2}(t_1,X_{t_1}) * {[X_{t_2}-X_{t_1}]}^2 +  \frac{\partial^2 f}{\partial t \partial x}(t_1,X_{t_1}) *[t_2-t_1]*[X_{t_2}-X_{t_1}]$$

But now if we know $X_t$, this is a function of only $t_1$ and $t_2$.  And then we can say $t_2 = t_1 + h$. We can also start calling $t_1$ just $t$

$$\Delta f(t,h) = \frac{\partial f}{\partial t}(t,X_{t}) *h + \frac{\partial f}{\partial x}(t,X_{t}) *[X_{t+h}-X_{t}]  + ... $$

$$... +  \frac{1}{2}\frac{\partial^2 f}{{\partial t}^2}(t,X_{t}) * {h}^2 + \frac{1}{2}\frac{\partial^2 f}{{\partial x}^2}(t,X_{t}) * {[X_{t+h}-X_{t}]}^2 +  \frac{\partial^2 f}{\partial t \partial x}(t,X_{t}) *h*[X_{t+h}-X_{t}]$$

Now we use the fact that $X_t$ is an Ito Process given by:

$$X_t = a + \int_{s=0}^{s=t} \mu_sds + \int_{s=0}^{s=t} \sigma_sdW_s$$

And finding the difference between times $t$ and $t+h$:

$$X_{t+h} - X_t = a + \int_{s=0}^{s=t+h} \mu_sds + \int_{s=0}^{s=t+h} \sigma_sdW_s - \left(a + \int_{s=0}^{s=t} \mu_sds + \int_{s=0}^{s=t} \sigma_sdW_s\right) = $$

$$ =  X_{t+h} - X_t = \int_{s=0}^{s=t+h} \mu_sds - \int_{s=0}^{s=t} \mu_sds+ \int_{s=0}^{s=t+h} \sigma_sdW_s - \int_{s=0}^{s=t} \sigma_sdW_s$$

We now make a temporary notation switch so our work in a few steps will be cleaner, and we will substitute it in:

$$P_t := \int_{s=0}^{s=t} \mu_sds$$
$$Q_t := \int_{s=0}^{s=t} \sigma_sdW_s$$
$$  X_{t+h} - X_t = P_{t+h} -P_t+ Q_{t+h} - Q_t$$

Now plug this in for the step above the Ito Process.

$$\Delta f(t,h) = \frac{\partial f}{\partial t}(t,X_{t}) *h + \frac{\partial f}{\partial x}(t,X_{t}) *[P_{t+h} -P_t+ Q_{t+h} - Q_t]  + ... $$

$$... +  \frac{1}{2}\frac{\partial^2 f}{{\partial t}^2}(t,X_{t}) * {h}^2 + \frac{1}{2}\frac{\partial^2 f}{{\partial x}^2}(t,X_{t}) * {[P_{t+h} -P_t+ Q_{t+h} - Q_t]}^2 +  \frac{\partial^2 f}{\partial t \partial x}(t,X_{t}) *h*[P_{t+h} -P_t+ Q_{t+h} - Q_t]$$

At this point, we are ready (in a pretty mathematically justifiable way) to do an integration. We'll start at $t=0$ and go up to an arbitrary $t$.  And during this process, we'll add up very small $\Delta f$ values until we get the actual change from $t=0$ to $t$, which will just give us the value at $t$ (assuming we know the value at $t=0$, which we'll assume we do).  It is not obvious yet, but if we can do that, we'll be a lot closer to having our function of $t$ that we want, $Z_t$.

So let's say we have $n$ partitions of our interval $[0,t]$, and we add up $n$ versions of $\Delta f$ values.  Then our $t$ and $h$ would be:

$$t = \frac{it}{n}, h = \frac{t}{n}$$

And we could sum the equation and reorder the last two terms:

$$Z_t^n = \sum_{i=1}^{i = n} \Delta f\left(ih,h\right) = \sum_{i=1}^{i = n} \frac{\partial f}{\partial t}(ih,X_{ih}) *h + \sum_{i=1}^{i = n}\frac{\partial f}{\partial x}(ih,X_{ih}) *[\Delta P_t+ \Delta Q_t] +  \frac{1}{2}\sum_{i=1}^{i = n}\frac{\partial^2 f}{{\partial t}^2}(ih,X_{ih}) * {h}^2 + ... $$

$$...   + \sum_{i=1}^{i = n} \frac{\partial^2 f}{\partial t \partial x}(ih,X_{ih}) *h*[\Delta P_t+ \Delta Q_t] + \frac{1}{2}\sum_{i=1}^{i = n}\frac{\partial^2 f}{{\partial x}^2}(ih,X_{ih}) * {[\Delta P_t+ \Delta Q_t]}^2$$

and simplifying and collecting terms:

$$Z_t^n = \sum_{i=1}^{i = n} \Delta f\left(ih,h\right) = \sum_{i=1}^{i = n} \frac{\partial f}{\partial t}(ih,X_{ih}) *h + \sum_{i=1}^{i = n}\frac{\partial f}{\partial x}(ih,X_{ih}) *[\Delta P_t] + \sum_{i=1}^{i = n}\frac{\partial f}{\partial x}(ih,X_{ih}) *[\Delta Q_t] +  $$

$$ \frac{1}{2}\sum_{i=1}^{i = n}\frac{\partial^2 f}{{\partial t}^2}(ih,X_{ih}) * {h}^2 + \sum_{i=1}^{i = n} \frac{\partial^2 f}{\partial t \partial x}(ih,X_{ih}) *h*[\Delta P_t] + ... $$

$$...   + \sum_{i=1}^{i = n} \frac{\partial^2 f}{\partial t \partial x}(ih,X_{ih}) *h*[ \Delta Q_t]+ \frac{1}{2}\sum_{i=1}^{i = n}\frac{\partial^2 f}{{\partial x}^2}(ih,X_{ih}) * {[\Delta P_t+ \Delta Q_t]}^2$$

And squaring the $\Delta P_t$ and $\Delta Q_t$ terms and splitting across the sum:

$$Z_t^n = \sum_{i=1}^{i = n} \Delta f\left(ih,h\right) = \sum_{i=1}^{i = n} \frac{\partial f}{\partial t}(ih,X_{ih}) *h + \sum_{i=1}^{i = n}\frac{\partial f}{\partial x}(ih,X_{ih}) *[\Delta P_t] + \sum_{i=1}^{i = n}\frac{\partial f}{\partial x}(ih,X_{ih}) *[\Delta Q_t] +  $$

$$ \frac{1}{2}\sum_{i=1}^{i = n}\frac{\partial^2 f}{{\partial t}^2}(ih,X_{ih}) * {h}^2 + \sum_{i=1}^{i = n} \frac{\partial^2 f}{\partial t \partial x}(ih,X_{ih}) *h*[\Delta P_t]  + \sum_{i=1}^{i = n} \frac{\partial^2 f}{\partial t \partial x}(ih,X_{ih}) *h*[ \Delta Q_t]+ ... $$

$$...  + \frac{1}{2}\sum_{i=1}^{i = n}\frac{\partial^2 f}{{\partial x}^2}(ih,X_{ih}) {\Delta P_t}^2 + \frac{1}{2}\sum_{i=1}^{i = n}\frac{\partial^2 f}{{\partial x}^2}(ih,X_{ih}){\Delta Q_t}^2 + 2\frac{1}{2}\sum_{i=1}^{i = n}\frac{\partial^2 f}{{\partial x}^2}(ih,X_{ih})\Delta Q_t \Delta P_t$$

And now we take the limit at $n$ approaches $\infty$, and a bunch of terms cancel. :

$$Z_t^\infty = f(t,X_t) - f(0,X_0) = \int_{s=0}^{s=t} \frac{\partial f}{\partial t}(s,X_s) ds + \int_{s=0}^{s=t}\frac{\partial f}{\partial x}(s,X_s) d P_s + \int_{s=0}^{s=t}\frac{\partial f}{\partial x}(s,X_s) d Q_s +  $$

$$...  +  \frac{1}{2}\sum_{i=1}^{i = \infty}\frac{\partial^2 f}{{\partial x}^2}(ih,X_{ih}){\Delta Q_t}^2 $$

And focusing on the top line, we can substitute back in for $P_s$ and $Q_s$:

$$Z_t^\infty = f(t,X_t) - f(0,X_0) = \int_{s=0}^{s=t} \frac{\partial f}{\partial t}(s,X_s) ds + \int_{s=0}^{s=t}\frac{\partial f}{\partial x}(s,X_s) \mu_s d s + \int_{s=0}^{s=t}\frac{\partial f}{\partial x}(s,X_s) \sigma_sdW_s +  $$

$$...  +  \frac{1}{2}\sum_{i=1}^{i = \infty}\frac{\partial^2 f}{{\partial x}^2}(ih,X_{ih}){\Delta Q_t}^2 $$

And again focusing on the top line, we can combine like terms:

$$Z_t^\infty = f(t,X_t) - f(0,X_0) = \int_{s=0}^{s=t} \frac{\partial f}{\partial t}(s,X_s) + \mu_s \frac{\partial f}{\partial x}(s,X_s)  ds + \int_{s=0}^{s=t}\frac{\partial f}{\partial x}(s,X_s) \sigma_sdW_s +  $$

$$...  +  \frac{1}{2}\sum_{i=1}^{i = \infty}\frac{\partial^2 f}{{\partial x}^2}(ih,X_{ih}){\Delta Q_t}^2 $$

And now we focus on the bottom line and given that ${\Delta Q_t}^2$ approaches ${\sigma _t}^2dt$, we get:

$$Z_t^\infty = f(t,X_t) - f(0,X_0) = \int_{s=0}^{s=t} \frac{\partial f}{\partial t}(s,X_s) + \mu_s \frac{\partial f}{\partial x}(s,X_s)  ds + \int_{s=0}^{s=t}\frac{\partial f}{\partial x}(s,X_s) \sigma_sdW_s +  $$

$$...  +  \frac{1}{2}\int_{s=0}^{s=t}\frac{\partial^2 f}{{\partial x}^2}(s,X_s) {\sigma _s}^2 ds $$

And now we can combine like terms again, and we have Ito's formula:

$$Z_t = f(t,X_t) = a + \int_{s=0}^{s=t} \frac{\partial f}{\partial t}(s,X_s) + \mu_s \frac{\partial f}{\partial x}(s,X_s) + \frac{1}{2}{\sigma _s}^2\frac{\partial^2 f}{{\partial x}^2}(s,X_s)  ds + \int_{s=0}^{s=t}\sigma_s\frac{\partial f}{\partial x}(s,X_s) dW_s   $$

\end{document}


\chapter{Entries}

This chapter provides manual entries for pre-defined \ML{} identifiers
in the \HOL{} system.  These include: general-purpose functions, such
as functions for list processing, arithmetic, input/output, and
interface configuration; functions for processing the types and terms
of the \HOL{} logic, for setting up theories, and for using the
subgoal package; primitive and derived forward inference rules; and
tactics and tacticals.  The arrangement is alphabetical.  If an
entry's title box includes a parenthesised word to the right, this
identifies the ML structure where that identifier is bound.
The interactive system starts with some structures already present,
others will need to be \texttt{load}-ed first.

%%% Local Variables:
%%% mode: plain-tex
%%% TeX-master: "reference"
%%% End:


\documentclass[12]{scrartcl}
\usepackage{amssymb,amsmath,gensymb,dsfont,calc,multicol,fullpage}
\makeatletter
\newcommand\Aboxed[1]{
   \@Aboxed#1\ENDDNE}
\def\@Aboxed#1&#2\ENDDNE{%
   &
   \settowidth\@tempdima{$\displaystyle#1{}$}
   \setlength\@tempdima{\@tempdima+\fboxsep+\fboxrule}
   \kern-\@tempdima
   \boxed{#1#2}
}
\makeatother

\begin{document}

\title{Homework 27, Section 5.1: 18, 21, 23, 25, 31}
\author{Alex Gordon}
\date{\today}
\maketitle
\section*{Homework}
\subsection*{18.}
Upper triangular matrix, so the eigenvalues are the values on the diagonal $= 5, 0, 3$
\subsection*{21. A)}
False. The equation $Ax = \lambda x$ must have a nontrivial solution.
\subsection*{21. B)}
True. If 0 is an eigenvalue then is equivalent to $Ax = 0$, which has a nontrivial solution if and only if A is not invertible. Thus 0 is an eigenvalue of A if and only if A is not invertible.
\subsection*{21. C)}
True. The set of all solutions of $A - \lambda I)x = 0$ is just the null space of the matrix $Ax = \lambda I$.
\subsection*{21. D)}
True. To check if it is an eigenvector, just multiply it by the matrix in question.
\subsection*{21. E)}
True. Although row reduction is used to find eigenvectors, it cannot be used to find eigenvalues.
\subsection*{23.}
If a 2 x 2 matrix A were to have three distinct eigen values then by theorem 2 there would correspond three linearly independent eigenvectors. This is impossible because the vectors all belong to a two-dimensional vector space, in which any set of three vectors in linearly dependent.
\subsection*{25.}
If $\lambda$ is an eigenvalue of A then there is a nonzero vector x such that $Ax - \lambda x$. Since $x \neq 0$, $\lambda$ cannot be zero. This then means that $\lambda^{-1} Ax = A^{-1}x$, which shows that $\lambda^{-1}$ is an eigenvalue of $A^{-1}$.
\subsection*{31.}
Suppose T reflects points through a line that passes through the origin of the matrix. The line is multiples of some nonzero vector v, so the points on the line do not move under A. So T(v) = v. If A is the standard matrix of T, then $Av = v$. Thus v is an eigenvector of A corresponding to the eigenvalue 1. This also means another eigenspace is generated by any nonzero vector u that is perpendicular to the given line. This, by the properties of transformation, each vector on the line through the vector u is transformed onto the vector -x, meaning the eigenvalue is -1.
\end{document}


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

\section{GW energy}

\marginpar{Monday\\ 2021-5-17, \\ compiled \\ \today}

Because of the equivalence principle, there can be no local definition of energy density or of a stress-energy tensor for \(g_{\mu \nu }\).

However, we can define the Landau-Lifshitz pseudotensor (which is actually a tensor density): from the gothic metric
%
\begin{align}
\mathfrak{g}^{\alpha \beta } = \sqrt{-g } g^{\alpha \beta }
\,
\end{align}
%
we define
%
\begin{align}
\Lambda^{\alpha \mu \beta \nu } = \mathfrak{g}^{\alpha \beta } \mathfrak{g}^{\mu \nu } - \mathfrak{g}^{\alpha \nu } \mathfrak{g}^{\beta \mu }
\,,
\end{align}
%
a four-tensor density which has the same symmetries as the Riemann tensor.
Also, we have the properties that
%
\begin{align}
\partial_{\mu } \partial_{\nu } \Lambda^{\alpha \mu \beta \nu } = 2 (-g) G^{\alpha \beta } + 16 \pi (-g) \tau^{\alpha \beta }_{LL}
\,,
\end{align}
%
where \(G^{\alpha \beta }\) is the Einstein tensor, while \(\tau_{LL}\) (defined to contain whatever remains) is called the Landau-Lifshitz tensor: this can also be expressed as
%
\begin{align}
\partial_{\mu } \partial_{\nu } \Lambda^{\alpha \mu \beta \nu } =
16 \pi (-g) \qty(T^{\alpha \beta } + \tau_{LL}^{\alpha \beta })
\,.
\end{align}

If we take a further derivative with respect to \(\alpha \), in a vacuum, we find
%
\begin{align}
\partial_{\alpha } \partial_{\mu } \partial_{\nu } \Lambda^{\alpha \mu \beta \nu } = \partial_{\alpha } \tau_{LL}^{\alpha \beta } = 0
\,,
\end{align}
%
where the last equality is due to the symmetries of \(\Lambda \). Therefore, the tensor \(\tau_{LL}\) is conserved, and we can try to interpret it as the ``energy of the gravitational field''.

In normal coordinates at any given point \(\tau_{LL}\) is identically zero.

A global concept of energy does not exist for certain spacetimes --- see ADM and the Hamiltonian formulation of GR.

However, asymptotically flat spacetimes have some nice properties.

If we foliate a spacetime \((M, g)\) into 3D spacelike hypersurfaces \(\Sigma \), we say it is asymptotically flat if the reduced metric \(\gamma_{ij} \to f_{ij}\) tends towards the Minkowski metric at radial infinity.

In this case, we can associate an energy to \(\Sigma \).
Using these concepts, there is hope to identify some quantity which represents GW energy.

We explore directions at infinity which are \textbf{asymptotically null}, and suppose that at \(\Sigma_{t_{1, 2}}\) we have stationary states, with dynamics in between.

Then, if there is a difference of energy \(\Delta E = E_2 - E_1 \), we expect there to be a flux of ``some \(\tau_{\mu \nu }\)'' from the surface.

We can work in linearized theory: \(g = f + h\).
The characteristics we expect a definition of energy to have are, at the very least
\begin{enumerate}
    \item quadratic in \(h\),
    \item generate curvature via a stress-energy tensor \(\tau_{\alpha \beta }\),
    \item gauge invariant under infinitesimal coordinate transformations.
\end{enumerate}

We start by specifying the \(LL\) tensor to the weak field case.
The metric reads \(g = \eta + h^{(1)} + h^{(2)} + \order{3}\), where by the indices in parentheses we mean orders in some expansion parameter.

The Ricci reads
%
\begin{align}
R_{\mu \nu } =
R_{\mu \nu }^{(0)} +
R_{\mu \nu }^{(1)} +
R_{\mu \nu }^{(2)} +
\order{3}
\,.
\end{align}

Now, \(R_{\mu \nu }^{(0)} = (\text{Ric}[\eta ])_{\mu \nu } \sim \eta \partial^2 \eta  = 0\), but if we had a non-flat background this would not hold.
On the other hand,
%
\begin{align}
R^{(1)}_{\mu \nu } = \qty(\text{Ric}^{(1)}[h^{1}])_{\mu \nu } \sim \eta \partial^2 h^{(1)}
\,,
\end{align}
%
where \(\text{Ric}^{(i)}\) is the Ricci operator expanded up to \(i\)-th order. This is relevant in the second-order term:
%
\begin{align}
R^{(2)}_{\mu \nu } =
\qty(\text{Ric}^{(1)} [ h^{(2)}])_{\mu \nu }
\qty(\text{Ric}^{(2)} [ h^{(1)}])_{\mu \nu }
\sim
\eta \partial^2 h^{(2)} + h^{(1)} \partial^2 h^{(1)}
\,.
\end{align}

Then, the EFE in vacuo read
%
\begin{align}
0 =
R^{(0)}_{\mu \nu } +
R^{(1)}_{\mu \nu } +
R^{(2)}_{\mu \nu } +  \order{3}
\,,
\end{align}
%
therefore to order 0 we have the \(\eta \) metric; to order \(1\) we can calculate \(h^{(1)}\), while to order \(2\) we can assume the \(h^{(1)}\) metric is already calculated and solve \(R^{(2)}_{\mu \nu } = 0\) for \(h^{2}\).

The second order equation reads
%
\begin{align}
G^{(1)}_{\mu \nu }[h^{(2)}] &= \qty(\text{Ric}^{(1)}[h^{2}] - \frac{1}{2} R^{(1)} [h^{2}]\eta )_{\mu \nu }  \\
&=\qty(- \text{Ric}^{(2)} [h^{1}] + \frac{1}{2} R^{(2)}[h^{1}] \eta )_{\mu \nu }   \\
&\overset{?}{=} 8 \pi \tau_{\mu \nu }
\,,
\end{align}
%
but can this actually be our GW stress-energy tensor? It is symmetric, it is quadratic in \(h\), and due to the Bianchi identities it is also conserved.
However, it is not gauge invariant, and it is not unique!

If \(h^{(1)}\) is \textbf{asymptotically flat}, then \(h \sim \order{1/r}\), \(\partial_{i} h \sim \order{1/r^2}\) and \(\partial_{i} \partial_{j} h \sim \order{1/r^3}\).

In this case, \(E = \int_{\Sigma } \dd[3]{x} \tau_{00} \) is both \textbf{gauge invariant} and \textbf{unique}: \(E[h_{\mu \nu } + 2 \partial_{(\mu } \xi_{\nu )}] = E[h_{\mu \nu }]\).

We can then write an energy flux in the form
%
\begin{align}
\Delta E = -\int_{S} \dd[2]{y} \tau_{\mu 0} n^\mu
\,,
\end{align}
%
across a surface \(S\) which determines the spatial boundary of \(\Sigma \) over time.

Weak-field GR can be interpreted as a field theory on \(\eta \) for the field \(h\).

Physically speaking, it is true that we can ``eliminate'' the gravitational field at a point, but here we are more interested in the following question:
can the GW in a neighborhood of that point contribute to the curvature via a gauge invariant tensor?

The issue comes down to: what is the distinction between ``waves'' and background?

One can prove that a suitable average of \(\text{Ric}^{(2)}[h^{(1)}]\) is actually gauge-invariant: this is the \textbf{Isaacson tensor},
%
\begin{align}
\tau_{\alpha \beta } = \frac{c^{4}}{32 \pi G} \expval{\partial_{\mu } h_{\alpha \beta } \partial_{\nu } h^{\alpha \beta }}
\,,
\end{align}
%
due to the fact that \(\text{Ric}^{(2)}[h] \sim h \partial \partial h + \partial h \partial h + \partial (h \partial h)\).

Let us take the derivative \(\partial_{\mu} \tau^{\mu \nu }\):
%
\begin{align}
\int_{V} \dd[3]{x} \qty(\partial_0 \tau^{00} + \partial_{i} \tau^{0i})
&= \dot{E} + \oint_{S} \dd[2]{y} \tau_{0i} n^i  \\
&= \dot{E} + r^2 \oint \dd[2]{y} \expval{\partial^{0} h_{ij} \partial_{r} h^{ij}}
\,,
\end{align}
%
which yields the quadrupole formula:
%
\begin{align}
\dv{E_{GW}}{t} &= \frac{c^3}{32 \pi G} r^2 \int \dd{\Omega } \expval{\partial_{t} h_{ij}^{TT} \partial_{t} h_{ij}^{TT}}  \\
&= \frac{G}{5 c^{5}}\expval{ \dot{\ddot{Q}}_{ij} \dot{\ddot{Q}}^{ij}}
\,.
\end{align}

Let us look at some dimensional analysis:
%
\begin{align}
[Q] &= a ML^2  \\
[\dot{\ddot{Q}}] &= a ML^2 T^{-3} \sim a \Omega^3 M L^2 = E^2 T^{-2}\\
[ \frac{G}{c^{5}}] &= T E^{-1}
\,.
\end{align}
%
The factor \(G / c^{5}\) is the inverse of a power: \(c^{5} / G \approx \SI{e52}{W}\), a very large power, and we are dividing by it.
This suggests a potential rewriting of the formula, which was an idea of Weber's:
%
\begin{align}
\dot{E} \sim \frac{G}{c^{5}} a^2 \Omega^{6} M^2 R^{4} = \dots
= a^2 \frac{c^{5}}{G} \qty( \frac{v}{c})^{6} \frac{GM}{c^2 R}
\,.
\end{align}

The power is therefore huge if \(v \sim c\) and \(R \sim R_S\)!

The above formula for \(\dot{E}\) is \emph{correct} for a leading-order description of a binary system, if we take \(a^2 = 32/5\), \(\Omega \) to be the orbital frequency, \(M\) to be \(\mu \) (the reduced mass), and \(R\) the orbital radius. So,
%
\begin{align}
\dot{E} = \frac{32}{5} \frac{G \mu^2}{c^{5}} R^{4} \Omega^3
\,.
\end{align}

Of course, \(\dot{E} _{\text{orbital energy}} = - \dot{E} _{\text{gw}}\).

\end{document}


\documentclass{article}
\usepackage[section]{placeins}
\usepackage{graphicx, wrapfig, amsmath, amssymb, physics, hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,
    urlcolor=cyan,
    }

\author{Yaghoub Shahmari}
\title{Report - Problem Set No 6}
\date{\today}
\graphicspath{ {../Figs/} }

\begin{document}
    \maketitle
    \section*{Problem 1}
    \textbf{Basic description:}

    In this problem, we're going to find the answer to the integral of a function.
    So we will follow the instructions introduced by the book.
    We will deploy both methods of the Monte Carlo algorithm for solving an integration.
    As the problem told us:

    $$f_{(x)} = \int e^{-x^2} \mathop{dx} \Rightarrow I = \int_0^2 e^{-x^2} \mathop{dx} = \frac{\sqrt{\pi}}{2} \mathrm{erf}_{(2)}$$

    We solved the integration for different amounts of samples for both methods
    and showed the benchmark result of each one in the notebook (Q1-1DInt.ipynb).
    We also showed the distribution of answers for both methods.
    And finally, we will show the answers, errors, and performance for each amount of samples.

    \textbf{The results:}

    \begin{figure}[!htb]
        \centering
        \includegraphics[scale = 0.25]{/Q1/IMCVilPlot}
        \label{fig:1.1}
        \includegraphics[scale = 0.25]{/Q1/SMCVilPlot}
        \label{fig:1.2}
        \caption{Distribution of answers for both methods.}
    \end{figure}

    \begin{figure}[!htb]
        \centering
        \includegraphics[scale = 0.42]{/Q1/MCAnswerPlot}
        \label{fig:1.3}
        \includegraphics[scale = 0.42]{/Q1/MCErrorPlot}
        \label{fig:1.4}
        \includegraphics[scale = 0.42]{/Q1/MCPerformPlot}
        \label{fig:1.5}
        \caption{Plot of answers, errors, and performance for both methods.}
    \end{figure}

    \pagebreak

    \section*{Problem 2}
    \textbf{Basic description:}

    In this problem, we want to find the center of mass of
    a sphere whit specific mass distribution.
    So we have to find the answer to a 2D integration.
    As we know:

    $$R_{CoM} = \frac{I}{M} \Rightarrow R_{CoM} = \frac{\int_{Sphere} z \rho dV}{\int_{Sphere} \rho dV},\ \rho = \rho_0 (3 + \frac{r}{R} \cos{\theta}) \Rightarrow$$
    $$ R_{CoM} = \frac{\int_0^R\int_0^\pi (3+\frac{r}{R}\cos{\theta})r^3\sin{\theta}\cos{\theta} d\theta dr}{\int_0^R\int_0^\pi (3+\frac{r}{R}\cos{\theta})r^2\sin{\theta} d\theta dr}$$

    That has the exact answer of $R_{CoM} = \frac{R}{15}$.
    We drew the distribution of a bunch of answers.
    Also, we calculated the values of errors.
    The final answer is $R_{CoM} = 0.0665806190158467$.
    All steps and values are available in the notebook.

    \textbf{The results:}

    \begin{figure}[!htb]
        \centering
        \includegraphics[scale = 0.25]{/Q2/IHistPlot}
        \label{fig:2.1}
        \includegraphics[scale = 0.25]{/Q2/MHistPlot}
        \label{fig:2.2}
        \caption{Distribution of answers of integration of I and M.}
    \end{figure}

    \pagebreak

    \section*{Problem 3}
    \textbf{Basic description:}

    In this problem, we want to create the Normal distribution
    by moving samples of the Uniform distribution in a span
    with various chances of movement and deploying the Metropolis algorithm.
    As we know the best distribution comes out with $a_r \approx 0.5$.
    So we draw a distribution with $a_r \approx 0.5$.
    Then, we will show the relation between $\Delta$ and $a_r$.
    And finally, we will show the Auto Correlation and Correlation length.
    The Correlation length will come out by finding the exponent of the Auto Correlation.

    \textbf{The results:}

    \begin{figure}[!htb]
        \centering
        \includegraphics[scale = 0.4]{/Q3/NormalHist}
        \label{fig:3.1}
        \caption{Metropolis Normal Distribution with $a_r \approx 0.5$.}
    \end{figure}

    \begin{figure}[!htb]
        \centering
        \includegraphics[scale = 0.4]{/Q3/AcceptanceRatio}
        \label{fig:3.2}
        \caption{Acceptance Ratio plot.}
    \end{figure}

    \begin{figure}[!htb]
        \centering
        \includegraphics[scale = 0.3]{/Q3/Autocorrelation1}
        \label{fig:3.3}
        \includegraphics[scale = 0.3]{/Q3/Autocorrelation2}
        \label{fig:3.4}
        \includegraphics[scale = 0.3]{/Q3/CorrelationLength}
        \label{fig:3.5}
        \caption{Auto correlation and Correlation Length Plot.}
    \end{figure}

    \pagebreak

    \centering
    \textbf{The whole data I gathered is in \href{https://github.com/shahmari/ComputationalPhysics-Fall2021/tree/main/ProblemSet7/Data}{this link}}

    Thanks for watching :)
\end{document}


\section{Matching Features}\label{sec:match-feat}

In order to support alphabet-based laws and definitions,
we introduce the notion of ``list variables'',
that match against zero or more variables satisfying some property.
These list-variables encode simple expressions that give
some flexibility in how they match.
We further classify as follows:
\begin{description}
  \item[Reserved:]  $O$, $M$, $S$
  \item[Generic:] $\lst v$, $\lst e$, \ldots (lowercase)
\end{description}
Here are some examples of laws that require this list-matching facility:
\begin{description}
%
\item[Sequential Composition]
$$
  P ; Q ~\defs~ \exists O_m \bullet P[O_m/O'] \land Q[O_m/O]
$$
Here the $O$ list-variable matches all the undecorated
observation variables., i.e. the alphabet, of the theory.
In practise we also need a side condition that says all the $O_m$
are fresh --- we don't want to rely on $P$ and $Q$ only having free variables
in that alphabet.
The idea is that \texttt{O}, \texttt{M} and \texttt{S} are reserved-variable root strings that
correspond to $O$, $M$ and $S$, respectively.
%
\item[Assignment]
$$
  x := e ~\defs~ ok \implies ok' \land x' = e
    \land S'\less x = S\less x
$$
List-variable $S$ refers to all the program or user variables,
those that appear explicitly in the programming notation (script) under study.
This are different from the model variables (often referred to as
``auxiliary''), denoted by $M$ that capture observable aspects
of system behaviour beyond what can be expressed with just the $S$
values. Examples of variables in $M$ include $ok$, $wait$, $tr$, etc.
The expression $S'\less x = S\less x$
denotes the conjunction of identities of the form $v'=v$
where $v \in S\setminus\setof x$.
If $x$ is an observation variable
then the above law only works for that variable,
and in fact could be expanded out (given $S$)
to an explicit law for that variable.
If $x$ is not an observation variable,
then it should be a ``variable-variable'',
and typically we cannot complete the match of $S\less x$
until
other context information tells us to which variables $x$ must match.
\par
We can have more than one subtracted variable:
$$
  x,y := e,f ~\defs~ ok \implies ok' \land x' = e \land y'=f
    \land S'\less{x,y} = S\less{x,y}
$$
\item[Simultaneous Assignment]
Way more than just two subtracted variables!
\begin{eqnarray*}
  \lefteqn{x_1,\ldots,x_n ::= e_1, \ldots , e_n}
\\ &=& \lst x := \lst e
\\ &\defs&
     ok \implies ok'
     \land x'_1 = e_1 \land \ldots \land x'_n = e_n
     \land S'\less{x_1,\ldots,x_n} = S\less{x_1,\ldots,x_n}
\\ &=& ok \implies ok'
    \land \lst x' = \lst e
    \land S'\less{\lst x} = S\less{\lst x}
\end{eqnarray*}
In the mathematical form, we use indices and ellipsis
to suggest that we have lists of variables and expressions
of the same length.
\item[Skip]
\begin{eqnarray*}
  \Skip &\defs& ok \implies ok' \land S'=S
\end{eqnarray*}
A simple form of a simple simultaneous assignment!
\end{description}

From the above examples,
a number of general observations can be made:
\begin{itemize}
  \item
    All list-variables match against lists of things (zero or more).
    This means they can only occur in certain places:
    \begin{itemize}
      \item quantifier binding variable lists
      \item replacement/target lists in substitutions
       \item in 2-place (atomic) predicates, provided both places
        are occupied by a single meta-variable.
    \end{itemize}
  \item
    A predicate involving two list-variables mandates that both
    match lists of the same size, and the predicate
    is interpreted as the \emph{conjunction} of instances of that predicate
    over corresponding pairs from the match-list.
    It can also match a single such predicate also using two list-variables.
  \item
    Some list-variables ($O$, $S$, $M$)
    denote specific sets of variables.
    The matching rules for these differ from those for regular variables,
    in that $O$ and $O'$ can only match themselves or their expansions,
    while $O_a$ and $O_b$ can match with a binding---subscript decorations
    are viewed as general patterns, and are not considered ``known''.
  \item
    Other list-variables  ($x_1$, $e_1$, \ldots)
    are local names used as general placeholder.
    These simply match all the variables/ expressions /whatever
    that occur in the relevant position.
  \item
    These list-variables won't only appear in match patterns,
    but could also appear in test/goal predicates,
    so we could imagine the following predicate fragment:
    $$
       \exists ok_m,S_m \bullet \ldots
    $$
    matching against a similar fragment from the definition of
    sequential composition:
    $$
      \exists O_n \bullet \ldots
    $$
    Here the match binding would include
    $O_n \mapsto \setof{ok_m} \cup S_m$.
  \item
    The reserved list-variables are \emph{precise},
    in the sense that on any given matching context,
    they match a known fixed collection of variables
    (so there shouldn't be a need in most cases to defer a match).
    An exception is in a generic theory that has no specific observation
    variables defined, when these list-variables can only match
    themselves, and $O$ being able to match $S,M$.
\end{itemize}


\vssub
\subsection{~Non-ice source term integration} \label{sub:source}
\vssub

The source terms not involving ice are accounted for by solving

%---------------------%
% Step : Source terms %
%---------------------%
% eq:step_source

\begin{equation}
\frac{\p N}{\p t} = \cS_{no~ice} \: . \label{eq:step_source}
\end{equation}

\noindent
As in \wam, a semi-implicit integration scheme is used. In this scheme the
discrete change of action density $\Delta N$ becomes \citep{art:WAM88}

% eq:implicit_st

\begin{equation}
\Delta N(k,\theta) = \frac{\cS(k,\theta)}{1- \epsilon D(k,\theta)\Delta t}
\: , \label{eq:implicit_st} \end{equation}

\noindent
where $D$ represents the diagonal terms of the derivative of $\cS$ with
respect to $N$ \citep[Eqs. 4.1 through 4.10]{art:WAM88}, and where $\epsilon$
defines the offset of the scheme. Originally, $\epsilon = 0.5$ was implemented
to obtain a second-order accurate scheme. Presently, $\epsilon = 1$ is used because it is more appropriate for the large time steps in the equilibrium range of
the spectrum \citep{pro:HA98,art:HA01} and it results in much smoother
integration of the spectrum. The change of $\epsilon$ has little impact on
mean wave parameters, but makes the dynamical time stepping as described below
more economical.

The semi-implicit scheme is applied in the framework of a dynamic
time-stepping scheme \citep{tol:JPO92}. In this scheme, integration over the
global time step $\Delta t_g$ can be performed in several dynamic time steps
$\Delta t_d$, depending on the net source term $\cS$, a maximum change of
action density $\Delta N_m$ and the remaining time in the interval $\Delta
t_g$. For the $n^{\rm th}$ dynamic time step in the integration over the
interval $\Delta t_g$, $\Delta t_d^n$ is calculated in three steps as

% ------ Dynamic s.t. int. scheme ------- %
% eq:st_d_1
% eq:st_d_2a
% eq:st_d_2b
% eq:st_d_3

\begin{equation}
\Delta t_d^n =
\min_{f<f_{hf}} \left [ \frac{\Delta N_m}{|\cS|}
\left ( 1 + \epsilon D \frac{\Delta N_m}{|\cS|} \right ) ^{-1}
\right ] \: , \label{eq:st_d_1}
\end{equation} \begin{equation}
\Delta t_d^n = \max \: \left [ \: \Delta t_d^n \: , \:
\Delta t_{d,\min} \right ] \: , \label{eq:st_d_2a}
\end{equation} \begin{equation}
\Delta t_d^n = \min \: \left [ \: \Delta t_d^n \: , \:
\Delta t_g - \sum_{i=1}^{n-1} \Delta t_d^i
 \: \right ] \: , \label{eq:st_d_2b}
\end{equation}

\noindent
where $\Delta t_{\min}$ is a user-defined minimum time step, which is added to
avoid excessively small time steps. The corresponding new spectrum $N^n$
becomes

\begin{equation}
N^n = \max\: \left [ \: 0 \: , \: N^{n-1} +
\left ( \frac{\cS \Delta t_d}{1 - \epsilon D \Delta t_d} \right )
\: \right ] \: . \label{eq:st_d_3}
\end{equation}

The maximum change of action density $\Delta N_m$ is determined from a
parametric change of action density $\Delta N_p$ and a filtered relative
change $\Delta N_r$

% eq:st_d_4
% eq:st_d_5
% eq:st_d_6
% eq:st_d_7

\begin{equation}
\Delta N_m (k,\theta) = \min \: \left [ \:
\Delta N_p (k,\theta) \: , \: \Delta N_r (k,\theta)
\: \right ] \: , \label{eq:st_d_4}
\end{equation} \begin{equation}
\Delta N_p (k,\theta) = X_p \: \frac{\alpha}{\pi} \:
\frac{(2\pi)^4}{g^2} \: \frac{1}{\sigma k^3}
\: , \label{eq:st_d_5}
\end{equation} \begin{equation}
\Delta N_r (k,\theta) = X_r \; \max \: \left [ \:
N(k,\theta) \: , \: N_f \: \right ] \: , \label{eq:st_d_6}
\end{equation} \begin{equation}
N_f = \max \: \left [ \: \Delta N_p (k_{\max},\theta) \: ,
\: X_f \: \max_{\forall k,\theta} \left \{ N(k,\theta) \right \}
\: \right ] \: , \label{eq:st_d_7} \end{equation}

\noindent
where $X_p$, $X_r$ and $X_f$ are user-defined constants (see
Table~\ref{tab:st_d_p}), $\alpha$ is a {\sc pm} spectrum energy level (set to $\alpha =
0.62\times 10^{-4}$) and $k_{\max}$ is the maximum discrete wavenumber. The
parametric spectral shape in (\ref{eq:st_d_5}) corresponds in deep water to
the well-known high-frequency shape of the one-dimensional frequency spectrum
$F(f) \propto f^{-5}$. The link between the filter level and the maximum
parametric change in (\ref{eq:st_d_7}) is used to assure that the dynamic time
step remains reasonably large in cases with extremely small wave energies. A
final safeguard for stability of integration is provided by limiting the
discrete change of action density to the maximum parametric change
(\ref{eq:st_d_5}) in conditions where Eq.~(\ref{eq:st_d_2a}) dictates $\Delta
t_d^n$. In this case Eq.~(\ref{eq:st_d_2a}) becomes a limiter as in the WAM
model. Impacts of limiters are discussed in detail in for instance
\cite{art:HJ99,art:HJ01}, \cite{art:HA01} and \cite{tol:GAOS02}.

% tab:st_d_p

\begin{table}
\begin{center} \begin{tabular}{|l|c|c|c|c|} \hline \hline
                 & $X_p$     & $X_r$             & $X_f$ &
$\Delta t_{d,\min}$      \\ \hline
\wam\ equivalent & $\frac{\pi}{24}10^{-3}\Delta t$
 & $\infty (\geq 1)$ & --    & $\Delta t_g$  \\
 suggested       & 0.1-0.2  & 0.1-0.2 & 0.05 & $\approx 0.1 \Delta t_g$ \\
default setting  &  0.15    &   0.10  & 0.05 & -- \\ \hline \hline
\end{tabular} \end{center}
\caption{User-defined parameters in the source term integration
 scheme}
\label{tab:st_d_p} \botline \end{table}

The dynamic time step is calculated for each grid point separately, adding
additional computational effort only for grid points in which the spectrum is
subject to rapid change. The source terms are re-calculated for every dynamic
time step.

It is possible to compile \ws\ without using a linear growth term. In such a
case, waves can only grow if some energy is present in the spectrum. In
small-scale applications with persistent low wind speeds, wave energy might
disappear completely from part of the model. To assure that wave growth can
occur when the wind increases, a so-called seeding option is available in \ws\
(selected during compilation). If the seeding option is selected, the energy
level at the seeding frequency $\sigma_{\rm seed} = \min(\sigma_{\max}, 2\pi
f_{hf})$ is required to at least contain a minimum action density

% ------ Spectral seeding ------- %
% eq:seed

\begin{eqnarray}
N_{\min}(k_{seed},\theta) & = &
        6.25 \times 10^{-4} \frac{1}{k_{\rm seed}^3 \: \sigma_{\rm seed}}
        \max \left [ \: 0. \: , \: \cos^2 ( \theta - \theta_w ) \right ]
                             \nonumber \\ & & \hspace{5mm}
        \min \left [ \: 1 \: , \: \max \left ( \: 0 \: , \:
        \frac{|u_{10}|}{X_{\rm seed} g \sigma_{\rm seed}^{-1}}-1
\: \right ) \: \right ] \: , \label{eq:seed} \end{eqnarray}

\noindent
where $g \sigma_{\rm seed}^{-1}$ approximates the equilibrium wind speed for
the highest discrete spectral frequency. This minimum action distribution is
aligned with the wind direction, goes to zero for low wind speeds, and is
proportional to the integration limiter (\ref{eq:st_d_5}) for large wind
speeds. $X_{\rm seed} \geq 1$ is a user-defined parameter to shift seeding to
higher frequencies. Seeding starts if the wind speed reaches $X_{\rm seed}$
times the equilibrium wind speed for the highest discrete frequency, and
reaches its full strength for twice as high wind speeds. The default model
settings include the seeding algorithm, with $X_{\rm seed} = 1$.

In model version 3.11, surf-zone physics parameterizations have been
introduced. Such physics, particularly depth-induced breaking, operate on much
smaller time scales than deep water and limited-depth physics outside the surf
zone. To assure reasonable behavior for larger time steps, an additional
optional limiter has been adopted from the SWAN model, which can be used instead of
modeling surf-breaking explicitly.  This limiter is similar to the Miche
style maximum wave height in the depth-limited wave breaking source term of
Eq.~(\ref{eq:BJ78_Miche}). In this limiter, the maximum wave energy $E_m$ is
computed as

% ------ Surf zone limiter ------ %
% eq:MLIM

\begin{equation}
E_m = \frac{1}{16} [ \gamma_{lim}  \tanh ( \bar{k} d ) / \bar{k} ] ^2
\:\:\: , \label{eq:MLIM}
\end{equation}

\noindent
where $\gamma_{lim}$ is a factor comparable to $\gamma_M$ in
Eq.~(\ref{eq:BJ78_Miche}), with the caveat that $\gamma_M$ is representative
for an individual wave, whereas $\gamma_{lim}$ is representative for the
significant wave height. For monochromatic waves, the original expression by
\cite{art:Miche44} would correspond to $\gamma_{lim} = 0.94$ and replacing
$H_s$ by the height $H$ of the waves. Here this idea is applied to random
waves.  In shallow water, this limits $H_s$ to be less than $\gamma_{lim} d$.
If the total spectral energy $E$ is larger than the maximum energy $E_m$, the
limiter is applied by simply rescaling the spectrum by the factor $E/E_m$,
loosely following the argumentation from \cite{art:EB96} and used
in \para\ref{sec:DB1}.

This limiter can be switched on or off in the
compilation of the model, and $\gamma_{lim}$ can be adjusted by the user. The
default is set to $\gamma_{lim} = 1.6$ because $H_{rms}$ values close to $d$
have indeed been recorded and thus taking a ratio $H_s/H_{rms}$ of 1.4, using
1.6 allows this large steepness to be exceeded by some margin.  Note that this
limiter should be used as a `safety valve' only, and hence that it should be
less strict than the breaking criterion in the surf-breaking or whitecapping
source terms, if these source terms are modeled explicitly.

Also, this limiter does not guarantee that all parts of the spectrum are
realistic. Indeed, the use of a mean wavenumber, as in the Komen et
al. dissipation, makes it possible to have unrealistically steep short waves
in the presence of swell. A future extension of this limiter could be to limit
the steepness with a partial spectral integration in frequencies, to make sure
that waves of all scales are indeed not too steep.

\vssub
\subsection{~Ice source terms integration} \label{sub:icesource}
\vssub

Because the attenuation and scattering in the ice can be very strong (although they are linear), it is convenient
to perform a separate integration of the ice terms $S_{\mathrm{ice}}=S_{\mathrm{id}}+S_{\mathrm{is}}$. This combines
a dissipation term
\begin{equation}
S_{\mathrm{id}}/\sigma  = \beta_{\mathrm{id}} N ,
\end{equation}
 and a scattering term
which is of the form
\begin{equation}
 \frac{S_{\mathrm{is}}(k,\theta)}{\sigma} =  \int_0^{2\pi}\beta_{\mathrm{is}} [N(k,\theta')-N(k,\theta)] d\theta'  ,
 \end{equation}
 in which the scattering coefficient $\beta_{\mathrm{is}}$ is a priori a function of the difference in direction between
 incident $\theta'$ and scattered $\theta$ directions, as well as the shape of ice floes. In general
  the directional spectrum $N(k,.)$ is a vector with {\F NTH} (number of directions) components,
and the source term is a vector of the same size  given by the matrix product $S/\sigma = M N(k,.)$ where
$M$ is a positive symmetric square {\F NTH} by {\F NTH} matrix with components given from the $\beta_{\mathrm{id}}$ values.
The matrix $M$ is easily diagonalized as
\begin{equation}
 M  =  V D V^T  ,
 \end{equation}
 where $D$ is a diagonal matrix containing all eigenvalues and $V$ is the array of eigenvectors,
 and $V^T$ is its transpose. As a result the split wave action equation for ice source terms
 \begin{equation}
\frac{\p}{\p t} \frac{N}{c_g}   = \frac{S_{\mathrm{id}}}{\sigma c_g} ,
 \end{equation}
 can be rewritten for the action $N_i$ of each eigenvector $V_i$ with eigenvalue $\lambda_i$ as
  \begin{equation}
\frac{\p}{\p t} \frac{N_i}{c_g}   = \frac{\beta_{\mathrm{id}} + \lambda_i}{\sigma c_g} N_i ,
 \end{equation}
 which has the following exact solution
   \begin{equation}
 {N_i}(t+\Delta t_g)   = N_i(t) \exp \left[ (\beta_{\mathrm{id}} + \lambda_i) +\Delta t_g\right].
 \end{equation}

 In all cases the eigenvector corresponding to an isotropic spectrum has an eigenvalue $\lambda=\beta_{\mathrm{id}}$.
 In the case of an isotropic back-scatter, the other eigenvalues are all equal to $(\beta_{\mathrm{id}} + \beta_{\mathrm{is}})$.
 This decomposition over the two eigenspaces simplifies the solution to
%---------------------%
% Step : Source terms %
%---------------------%
% eq:exact_st_ice
\begin{equation}
 N(t+\Delta t_g) = \exp(\beta_{\mathrm{id}} \Delta t_g) \overline{N}(t)  + \exp \left[\left(\beta_{\mathrm{id}} + \beta_{\mathrm{is}}\right) \Delta t_g\right] \left[N(t)-\overline{N}(t)\right]
, \label{eq:exact_st_ice} \end{equation}
where $\overline{N}$ is the average over all directions. As a result, for a spatially homogeneous field,
the spectrum exponentially tends to isotropy over a time scale $1/(\beta_{\mathrm{id}})$.


% ================================================================
%                          DOCUMENTO
% ================================================================

\documentclass{scrbook}

% ================================================================
%                          PACCHETTI
% ================================================================

% dare una spiegazione
\usepackage{tikz}
\usetikzlibrary{arrows}

% ??
\usepackage{amsmath,amssymb,amsthm,thmtools}

% glossario
\usepackage{makeidx}

% ??
\usepackage{mathtools} % per \MoveEqLeft

% QR-code
\usepackage{qrcode}

\usepackage{array} % per formattare le colonne di un tabular

% ================================================================
%                           ALIAS ?
% ================================================================

% sono presi da paolini
% https://github.com/paolini/AnalisiUno/blob/master/AnalisiUno.tex

\newcommand{\eps}{\varepsilon}
\renewcommand{\phi}{\varphi}
\newcommand{\loc}{\mathit{loc}}
\newcommand{\weakto}{\rightharpoonup}
\newcommand{\implied}{\Longleftarrow}
\let\subsetstrict\subset
\renewcommand{\subset}{\subseteq}
\renewcommand{\supset}{\supseteq}

% calligraphic letters
\newcommand{\A}{\mathcal A}
\newcommand{\B}{\mathcal B}
\newcommand{\C}{\mathcal C}
\newcommand{\D}{\mathcal D}
\newcommand{\E}{\mathcal E}
\newcommand{\F}{\mathcal F}
\newcommand{\FL}{\mathcal F\!\mathcal L}
\renewcommand{\H}{\mathcal H}
\newcommand{\K}{\mathcal K}
\renewcommand{\L}{\mathcal L}
\newcommand{\M}{\mathcal M}
\renewcommand{\P}{\mathcal P}
\renewcommand{\S}{\mathcal S}
\newcommand{\U}{\mathcal U} %% intorni

% blackboard letters
\newcommand{\CC}{\mathbb C}
\newcommand{\HH}{\mathbb H}
\newcommand{\KK}{\mathbb K}
\newcommand{\NN}{\mathbb N}
\newcommand{\QQ}{\mathbb Q}
\newcommand{\RR}{\mathbb R}
\newcommand{\TT}{\mathbb T}
\newcommand{\ZZ}{\mathbb Z}

\newcommand{\abs}[1]{{\left|#1\right|}}
\newcommand{\Abs}[1]{{\left\Vert #1\right\Vert}}
\newcommand{\enclose}[1]{{\left( #1 \right)}}
\newcommand{\Enclose}[1]{{\left[ #1 \right]}}
\newcommand{\ENCLOSE}[1]{{\left\{ #1 \right\}}}
\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor}
\newcommand{\ceil}[1]{\left\lceil #1 \right\rceil}

\newcommand{\To}{\rightrightarrows}
\renewcommand{\vec}[1]{\boldsymbol #1}
\newcommand{\defeq}{:=}
\DeclareMathOperator{\divergence}{div}
\renewcommand{\div}{\divergence}
% \DeclareMathOperator{\ker}{ker}  %% already defined
\DeclareMathOperator{\Imaginarypart}{Im}
\renewcommand{\Im}{\Imaginarypart}
\DeclareMathOperator{\Realpart}{Re}
\renewcommand{\Re}{\Realpart}
%\DeclareMathOperator{\arg}{arg}
\DeclareMathOperator{\tg}{tg}
\DeclareMathOperator{\arctg}{arctg}
\DeclareMathOperator{\tgh}{tgh}
\DeclareMathOperator{\settsinh}{settsinh}
\DeclareMathOperator{\settcosh}{settcosh}
\DeclareMathOperator{\setttgh}{setttgh}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\im}{im}
\DeclareMathOperator{\sgn}{sgn}
\DeclareMathOperator{\diag}{diag}

\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
postheadspace=1em,
qed=,
%shaded={rulecolor=blue!20,rulewidth=1pt,bgcolor=blue!5}
]{theorem_style}

\declaretheoremstyle[
spaceabove=6pt, spacebelow=6pt,
postheadspace=1em,
qed=,
%shaded={rulecolor=yellow!50,rulewidth=1pt,bgcolor=yellow!5}
]{axiom_style}

\numberwithin{equation}{chapter}
\declaretheorem[name=Teorema,numberwithin=chapter]{theorem}
\declaretheorem[name=Lemma,sibling=theorem]{lemma}
\declaretheorem[name=Proposizione,sibling=theorem]{proposition}
\declaretheorem[name=Corollario,sibling=theorem]{corollary}
\declaretheorem[name=Paradosso,sibling=theorem]{paradox}
\declaretheorem[style=axiom_style,name=Assioma,sibling=theorem]{axiom}
\declaretheorem[name=Definizione,sibling=theorem]{definition}
\declaretheorem[style=exercise_style,name=Esempio,sibling=theorem]{example}
\declaretheorem[style=exercise_style,name=Esercizio,sibling=theorem]{exercise}
\declaretheorem[style=exercise_style,name=Osservazione,sibling=theorem]{remark}

% ================================================================
%                           DOCUMENTO
% ================================================================

% inizio documento
\begin{document}

% definizione titolo
\title{Formule utili\\\mbox{}\\
\qrcode{https://github.com/i-friends/mah_tips}
}
\author{Luca Ciucci e chi altro si vuole aggiungere}
\maketitle% genera titolo

\section{Introduction}
Here is the text of your introduction.

\begin{equation}
\A\AA
    \label{simple_equation}
    \alpha = \sqrt{ \beta }
\end{equation}

\subsection{Subsection Heading Here}
Write your subsection text here.

\section{Conclusion}
Write your conclusion here.

\include{chapters/analisi}

\end{document}


\section{The high energy $\gamma$-nucleon and $\gamma$-nucleus
 interactions.}

\hspace{1.0em}We consider the following kinematic
variables for $\gamma$-nucleon
scattering: the Bjorken-$x$ variable defined as $x=Q^2/2m\nu$ with $Q^2$, $\nu$
and $m$ the photon virtuality, the photon energy and nucleon mass,
respectively.
The the squared total energy of the $\gamma$-nucleon system is given by
$s=Q^2(1-x)/x + m^2$. We restrict consideration to
 the range of small $x$-values and  $Q^2$ is much
less than $s$.

The Generalized Vector Dominance Model (GVDM) \cite{BSY78}
 assumes that the virtual photon
fluctuates into intermediate $q\bar{q}$-states $V$ of mass $M$ which
 subsequently may
interact with a nucleon $N$.
Thus the total photon-nucleon cross section
 can be expressed by a relation \cite{PRW95}:
\begin{equation}
\begin{array}{c}
\label{HEGI1}\sigma_{\gamma N}(s,Q^2)=4\pi\alpha_{em}\int_{M^2_0}^{M^2_{1}}
dM^2D(M^2)\times \\
\times (\frac{M^2}{M^2+Q^2})^2(1+\epsilon\frac{Q^2}{M^2})\sigma_{VN}(s,Q^2),
\end{array}
\end{equation}
where integration over $M^2$ should be performed between $M^2_0=4m^2_{\pi}$
 and $M^2=s$.
Here $\alpha_{em} = e^2/4\pi = 1/137$ and the density
 of $q\bar{q}$-system per
unit mass-squared is given by
\begin{equation}
\label{HEGI2}D(M^2)= \frac{R_{e^{+}e^{-}}(M^2)}{12\pi^2M^2},
\end{equation}
\begin{equation}
\label{HEGI3} R_{e^{+}e^{-}}(M^2)=\frac{\sigma_{e^{+}e^{-}\rightarrow
hadrons}(M^2)}{\sigma_{e^{+}e^{-}\rightarrow
\mu^{+}\mu^{-}}(M^2)}\approx 3\Sigma_{f}e^2_{f},
\end{equation}
where $e^2_{f}$ the squared charge of quark with flavor $f$.
$\epsilon$ is the
ratio between the fluxes of longitudinally
 and transversally polarized photons.

Similarly the
 inelastic cross section for the scattering of a $\gamma$ with virtuality
$Q^2$ and with  a nucleus $A$ at impact parameter $B$
and the $\gamma$-nucleon c.m.
energy squared $s$ is given by \cite{ERR97}:
\begin{equation}
\begin{array}{c}
\label{HEGI4}\sigma_{\gamma A}(s,Q^2,B)=4\pi\alpha_{em}\int_{M^2_0}^{M^2_{1}}
dM^2D(M^2)\times \\
\times (\frac{M^2}{M^2+Q^2})^2(1+\epsilon\frac{Q^2}{M^2})\sigma_{VA}(s,Q^2,B),
\end{array}
\end{equation}

To calculate $\gamma$-nucleon or $\gamma$-nucleus inelastic cross sections
we need model for the $M^2$-,
 $Q^2$- and $s$-dependence of the $\sigma_{VN}$ or $\sigma_{VA}$. For
 these we  apply the
Gribov-Regge approach, similarly as it was done for $h$-nucleon or $h$-nucleus
inelastic cross sections.

The
 effective cross section for the interaction of a $q\bar{q}$-system with
squared mass $M^2$ with nucleus for the coherence length
\begin{equation}
\label{HEGI5} d=\frac{2\nu}{M^2+Q^2}
\end{equation}
exceeding the average distance between two nucleons
can be written as follows
\begin{equation}
\begin{array}{c}
\label{HEGI6}\sigma_{V A}(s,Q^2,B)=\int \prod_{i=1}^{A}
d^3 r_i\rho_A({\bf r}_i)
\times \\
\times (1 - |\prod_{i=1}^{A}[1-u(s,Q^2,M^2, b^2_i)]|^2).
\end{array}
\end{equation}
Here the amplitude (eikonal)
$u(s,Q^2,M^2, b^2_i)$ for the interaction of
the hadronic fluctuation with $i$-th nucleon
is given by \cite{ERR97}
\begin{equation}
\begin{array}{c}
\label{HEGI7}u(s,Q^2,M^2,{\bf b}_i)=
\frac{\sigma_{VN}(s,Q^2,M^2)} {8 \pi \lambda(s,Q^2,M^2)} \times \\
\times (1-i \rho \exp{[-\frac{b^2}{4\lambda(s,Q^2,M^2)}]},
\end{array}
\end{equation}
where $\rho\approx 0$ is the ratio of real and imaginary parts of scattering
amplitude at $0$ angle.
The amplitude parameters: the effective $q\bar{q}$-nucleon cross section
\begin{equation}
\label{HEGI8} \sigma_{VN}(s,Q^2,M^2)=\frac{\tilde{\sigma}_{VN}(s,Q^2)}{M^2+Q^2+C^2},
\end{equation}
where $C^2=2$ \ GeV$^2$,
and
\begin{equation}
\label{HEGI9}\lambda(s,Q^2,M^2)=2+\frac{m^2_{\rho}}{M^2+Q^2} +
\alpha_{P}^{\prime}
\ln{(\frac{s}{M^2+Q^2})}.
\end{equation}
The values of $\tilde{\sigma}_{VN}(s,Q^2)$ are calculated in paper
\cite{ERR97}.
It was shown \cite{ERR97} that $Q^2$ dependence of $\sigma_{VN}(s,Q^2)$
is very week at $Q^2 < m^2_{rho} + C^2$, where $m_{\rho}$ is
$\rho$-meson mass, and we omitted this dependence. We also use
$\sigma_{VN}(s,Q^2)$ calculated  in \cite{ERR97} at $M^2=m^2_{rho}$.

 If coherence length is smaller that an internuclear distance integrated
over $B$ then cross section
$\sigma_{VA}=A\sigma_{VN}$.