\chapterquote{%
The epistemological value of probability theory is based on the fact that chance phenomena, considered collectively and on a grand scale, create non-random regularity.}%
{\begin{tabular}{ l l }
 -- Andrey Kolmogorov, &\textit{Limit Distributions for Sums of Independent } \\
    &\textit{Random Variables} (1954)
\end{tabular}}

This chapter presents the definitions and results from stochastic geometry applied to wireless networks that we use throughout the manuscript.
%
This review of the theory is based on the well-celebrated books
%
\begin{itemize}
    \item \textit{Stochastic Geometry and Wireless Networks} \cite{baccelli2010stochastic}.
    \item \textit{Stochastic Geometry for Wireless Networks} \cite{haenggi2012stochastic}.
\end{itemize}
%
Then, for further details and proofs, the reader can refer to them.

\begin{note}
    The reader that is not interested in mathematical details can skip to Chapter~\ref{cap:P2_00} and consult this chapter as needed.
    %
    Nevertheless, bear in mind the following intuitive definition: a point process is a collection of points randomly positioned in the $\R^d$.
\end{note}
\newpage

% % % % % % % % % % % % % % % % % %
\section{Point Processes and Random Measures} \label{sec:P1_03_01}

Let us start with the definition of a point process, which can be intuitively seen as a collection of points randomly positioned on a well-behaved space, e.g. the Euclidean space.
%
\begin{definition}[\textbf{Point process}]
    Let $(\Omega,\cal F, \P)$ be a \textit{probability space}. Let $(S,d)$ be a locally compact metric space\footnote{In a locally compact metric space every point has a closed and bounded neighborhood. A metric space is defined in Definition~\ref{def:metric_space} and a neighborhood in Definition~\ref{def:neighborhood}} and the Borel $\sigma$-algebra of $S$ be denoted by $\cal{S}$. A point process $\Phi:\Omega\times \cal S\longrightarrow \N$ is a function that satisfies:
    \setlist{nolistsep}
    \begin{itemize}[noitemsep]
        \item For every $\omega\in\Omega$, $\Phi(\omega,\cdot)$ is a locally finite measure\footnote{A locally finite measure is a measure for which every point of the measure space has a neighbourhood of finite measure.}.
        \item For every $B\in\cal S$, $\Phi(\cdot,B)$ is a random variable over $\N$.
    \end{itemize}
    A function that satisfies the above properties is also called a \textit{random measure}.

    As usual, we omit the dependence of $\Phi$ on $\omega\in\Omega$.
    %
    % Whenever $d$ is omitted, we assume the euclidean distance.
\end{definition}
%
From the above definition, we can say that $\Phi$ counts how many points are located in a given finite \textit{measurable} subset of $S$.
%
Then, the locally finite measure property is important to avoid accumulation points.

We can use this mathematical object to model the position of transmitters and receivers in wireless networks.
%
This is an interesting approach because usually the positions of these entities are random.

\begin{remark} \label{rem:PP_set_notation}
    A convenient form of specifying a point process $\Phi$ on space $S$ is using the Dirac measure $\delta_x$ at $x$. For $A\in\cal S$, $\delta_x(A) = 1$, if $x\in A$ and $\delta_x(A) = 0$ if $x\notin A$.
    %
    Since a point process consist of a \textit{countable} set of points, these points can be ordered using $\N$ and the position of these points can be defined as the stochastic process $\bm{X} = \{X_k\}_{k\in\N}$ with state space $S$ and index space $\N$. Then, we can write that
    \begin{align*}
        \Phi = \sum_{k\in\N} \delta_{X_k}.
    \end{align*}
    To state this correspondence we use the notation $\Phi \stackrel{*}{=} \{X_k\}_{k\in\N}$.
\end{remark}

\begin{note} \label{note:pp_sp}
    Now the reader might be wondering if a point process is a stochastic process (Definition~\ref{def:stoch_process}).
    %
    Using our definitions the answer is yes.
    %
    The point process $\Phi$ on $S$ can be seen as the stochastic process $\{\Phi(A)\}_{A\in\cal S}$ with index space $\cal S$ and state space $\N$, where $\cal S$ is the Borel $\sigma$-algebra of $S$.
    %
    Therefore, we can apply the results of stochastic processes in point processes as well.
    %
    Note, however, that it is not convenient to work with an index space for which its elements are sets.
    %
    % In fact, it is not clear in the literature whether a point process is a special case of a stochastic process.
    % %
    % However, using our definitions we can relate both concepts.
    % %
    % Let $\Phi$ be a point process on $S$ and $\bm{X} = \{X_0, X_1, \dots\}$ be a stochastic process with index space $\N$ and state space $S$. We define these objects such that
    % \begin{align*}
    %     \Phi(A) = \sum_{k\ge 0} \ind\{X_k\in A\} \qquad \forall A\in\cal S = \cal B(S),
    % \end{align*}
    % where $X_k$ represents the position of the $k$th point. We can do so because a point process has a countable number of points and we can map them into $\N$.
\end{note}

An important point process is the Poisson point process (PPP) because it is analytically tractable and it usually represents a lower bound on the performance of wireless networks. % The definition follows.
%
\begin{definition}[\textbf{Poisson point process}]
    Let $\Lambda$ be a locally finite measure on $\R^d$.
    %
    The Poisson point process $\Phi$ of intensity measure $\Lambda$ is a point process on $\R^d$ that satisfies
    \begin{align*}
        \P\big(\Phi(A_1)=n_1,\Phi(A_2)=n_2,\dots,\Phi(A_k)=n_k\big) = \prod_{i=1}^k \left( \frac{\Lambda(A_i)^{n_i}}{n_i!} \,\euler^{-\Lambda(A_i)} \right),
    \end{align*}
    for every $k\in\N^*$ and all bounded, mutually disjoint sets $A_i\in\cal{B}(\R^d)$ for $i\in\{1,2,\dots,k\}$.

    If for every bounded $A\in\cal{B}(\R^d)$ we have that $\int_A \d\Lambda(x) = \int_A \lambda\,\d x$ for some constant $\lambda > 0$, then we call $\Phi$ a \textit{homogeneous} Poisson point process of density $\lambda$.
\end{definition}

In particular, we can show that for the PPP $\Phi$ of intensity measure $\Lambda$ on $\R^d$, the expected number of points within a set $A\in\cal{B}(\R^d)$ denoted by $\E[\Phi(A)]$ is simply given by $\Lambda(A)$.
%
In the case of the homogeneous PPP with density $\lambda$ we further have that $\E[\Phi(A)] = \lambda\,\mu(A)$, where $\mu$ is the Lebesgue measure\footnote{Indeed $\lambda$ is the Radon–Nikodym derivative of the measure $\Lambda$ with respect to the Lebesgue measure.}.

\begin{example}
    Let $\Phi$ be a homogeneous PPP on $\R$ with density $\lambda > 0$.
    %
    Let $a < b$.
    %
    Then, $\Phi([a,b])$ follows a Poisson distribution of parameter $\lambda\,(b-a)$, i.e., $\Phi([a,b]) \sim \mathscr{P}(\lambda\,(b-a))$,
    \begin{align*}
        \P(\Phi([a,b]) = n) = \frac{\lambda^n\,(b-a)^n}{n!}\,\euler^{-\lambda\,(b-a)}, \qquad n\in\N.
    \end{align*}

    Actually, this property is much more general.
    %
    A point process $\Phi$ on $\R^d$ is a Poisson point process if and only if there exists a locally finite measure $\Lambda$ on $\R^d$ such that for every bounded set $A\in\cal B(\R^d)$, $\Phi(A)$ follows a Poisson distribution of parameter $\Lambda(A)$.
\end{example}

Analogously to the Laplace transform to characterize random variables, we have the Laplace functional to characterize point processes and it is defined as follows.
\begin{definition}[\textbf{Laplace functional}]
    The \textit{Laplace functional} of a point process $\Phi \stackrel{*}{=}\{X_k\}_{k\in\N}$ on $S$ is defined by
    \begin{align*}
        \mathscr{L}_\Phi(f) \triangleq \E\!\left[\exp\!\left( -\sum_{k\in\N} f(X_k) \right)\right] = \E\!\left[ \exp\!\left(-\int_S f(x)\,\d\Phi(x)\right) \right],
    \end{align*}
    where $f:S\longrightarrow\R$ is a non-negative \textit{measurable} function.
\end{definition}

Note that for each sample of the sample space, $\Phi$ is a well defined measure, then we can integrate with respect to the measure $\Phi(\omega, \cdot)$, for fixed $\omega\in\Omega$.

For the case of a Poisson point process there is a more straightforward calculation.
\begin{theorem}[\textbf{Campbell's theorem}] \label{th:campbell}
    The Laplace functional of a PPP of intensity measure $\Lambda$ on $\R^d$ is
    \begin{align*}
        \mathscr{L}_\Phi(f) = \E\!\left[ \exp\!\left(-\int_{\R^d} \left(1-\euler^{-f(x)}\right)\,\d\Lambda(x)\right) \right],
    \end{align*}
    where $f:\R^d\longrightarrow\R$ is a non-negative \textit{measurable} function.
\end{theorem}

A useful concept that contributes to model heterogeneous networks, i.e., networks with different classes of users, is the superposition of point processes.
%
The definition follows.
%
\begin{definition}
    The superposition of $n\in\N$ point processes $\Phi_1, \Phi_2, \dots, \Phi_n$ is defined as \[\Phi = \sum_{k=1}^n \Phi_k.\]
\end{definition}

Then, again, for the PPP case, we can show the following.
\begin{theorem}
    The superposition of $n\in\N$ independent Poisson point processes with intensities $\Lambda_1, \Lambda_2, \dots, \Lambda_n$ is a Poisson point process with intensity measure \[\Lambda = \sum_{k=1}^n \Lambda_k.\]
    % if and only if $\Lambda$ is a locally finite measure.
\end{theorem}

A useful concept to model medium access control in wireless networks is the \textit{thinning} of a point process, which consists of randomly removing some points of the point process and can represent the inactive users in a wireless network. The formal definition follows.
%
\begin{definition}
    The \textit{thinning} of a point process $\Phi \stackrel{*}{=} \{X_k\}_{k\in\N}$ on space $S$ with respect to the \textit{measurable} function $p:S\longrightarrow [0,1]$ is a point process given by
    \begin{align*}
        \Phi^{(p)} = \sum_{k\in\N} e_k\,\delta_{X_k},
    \end{align*}
    where $\{e_k\}_k$ are independent Bernoulli random variables with parameter $p(X_k)$.
\end{definition}
%
The above definition simply says that to obtain $\Phi^{(p)}$ we remove points from $\Phi$ with probability $1-p(x)$, where $x$ is the position of the corespondent point.
%
Usually, $p$ is a constant function.

Once again, let us state a related result for the Poisson point process.
\begin{theorem}
    The \textit{thinning} of a PPP of intensity measure $\Lambda$ with the function $p$ is itself a PPP of intensity measure $p\Lambda$.
\end{theorem}

Another important tool we need to study wireless networks is to be able to condition on events. For example, calculate the probability of a successful transmission given that a receiver is located at the origin (i.e. one of the points of the point process being located at the origin).
%
The probability of such event is usually 0 and the basic definition of conditional probability cannot be applied. See Definition~\ref{def:cond_prob} and the discussion below it.

Thus, using Definition~\ref{def:cond_prob_sig} is essential to not run into problems.
%
The theory of point process that deals with conditional probabilities is called Palm theory and it is quite intricate to include in this manuscript. However, we will provide a general idea.

\begin{definition}
    Let $\Phi$ be a point process on $S$.
    %
    Let $\Phi_x$ be the point process $\Phi$ conditioned to having a point on $x\in S$. Let $\Phi^!_x$ be $\Phi_x$ without the point on $x\in S$, i.e., $\Phi_x = \Phi^!_x + \delta_x$.
    %
    Then, we call $\Phi_x$ and $\Phi^!_x$ the \textit{Palm} and the \textit{reduced Palm version} of $\Phi$, respectively.
\end{definition}

% \begin{definition}
%     Let $\Phi$ be a point process on $S$ and $\mathbb{M}$ be the set of all point measures on $S$.
%     %
%     The measure $P_x^!:\mathbb{M}\longrightarrow [0,1]$ is called the \textit{reduced Palm distribution} of $\Phi$ given a point at $x\in S$.
% \end{definition}
%
% For example, the probability that the number of points inside region $A\in \cal S$ is equal to $n\in\N$ given that there is a point of the point process $\Phi$ at $x\in S$ is denoted by $P_x^!(\{
% \Phi(A)=n\})$.

For a PPP we have the following well celebrated theorem.
\begin{theorem}[\textbf{Slivnyak–Mecke Theorem}] \label{th:slivnyak}
    Let $\Phi$ be a PPP with intensity measure $\Lambda$ on $\R^d$.
    %
    For $\Lambda$-\textit{almost} all $x\in\R^d$, the \textit{reduced Palm version} $\Phi^!_x$ of a PPP $\Phi$ is equal in distribution to the original PPP $\Phi$.
    %
    That is, for almost every $A\in\cal{B}(\R^d)$ we have that $\Phi^!_x(A)$ has the same distribution as $\Phi(A)$.
\end{theorem}
% \begin{theorem}[\textbf{Slivnyak–Mecke Theorem}] \label{th:slivnyak}
%     Let $\Phi$ be a PPP with intensity measure $\Lambda$ on $\R^d$.
%     %
%     For $\Lambda$-\textit{almost} all $x\in\R^d$,
%     \begin{align*}
%         P_x^!(\cdot) = \P(\Phi\in\cdot).
%     \end{align*}
%     Thus, the \textit{reduced Palm distribution} of a PPP is equal to its original distribution.
% \end{theorem}
%
The above theorem is essential to analyze a ``typical'' user of a wireless network positioned at some point in space.

% \begin{definition}
%     A point process $\Phi$ on $S$ is \textit{stationary} if its distribution is invariant under translation, i.e., for every $A\in\cal S$ and $x\in S$, we have that the distribution of $\Phi(A)$ is the same as $\Phi(A+x)$, where $A+x \triangleq \{a+x:a\in A\}$.
% \end{definition}
% %
% This definition is in accordance with the definition of stationary for a stochastic process in view of the Note~\ref{note:pp_sp}.
% %
% Analogously we can define an ergodic point process using the definition of an ergodic stochastic process (Defintion~\ref{def:ergodic_process}). Using the ergodic theorem (Theorem~\ref{th:ergodic}), we have that if a point process $\Phi$ on space $S$ is ergodic, then for a \textit{measurable} function $f:\mathbb{M}\longrightarrow\R_+$
% \begin{align*}
%     \lim_{n\to\infty} \frac{1}{\mu(A_n)} \int_{A_n} f(\Phi+x) \d\mu(x) = \E[f(\Phi)],
% \end{align*}
% where $A_n$ is a

The formal definitions of stationary and ergodic for a point process can be deduced from the definitions for stochastic processes, because a point process is a special case of a stochastic process as explained in Note~\ref{note:pp_sp}.

From the formal definition, we can conclude that a point process is \textit{stationary} if its distribution is invariant under translation; and a point process is \textit{ergodic} if the spatial average of any integrable function over the entire space is invariant under translation and equal to the expected value.
%
In general, a PPP is not stationary nor ergodic, however, a homogeneous PPP is stationary and ergodic.

On a wireless network, the nodes may have some random quantities associated with them, e.g. short-term fading, medium access, packet arrival, and so on.
%
To handle these, we introduce the marked point process.
%
\begin{definition}[\textbf{Marked point process}]
    Let $\Phi\stackrel{*}{=}\{(X_k)\}_k$ and $\hat\Phi\stackrel{*}{=}\{(X_k,M_k)\}_k$ be point processes on space $S_X$ and $S_X\times S_M$, respectively.
    %
    Then, $\hat\Phi$ is a \textit{marked} point process if and only if $\hat\Phi(A\times S_M) = \Phi(A)$ is \textit{almost surely} finite for every bounded $A\in \cal{S}_X \triangleq \cal{B}(S_X)$. Note that $\hat\Phi(S_X \times B)$ does not need to be finite for bounded $B\in\cal{S}_M$.

    A marked point process is said to be independently marked if given the locations of the points $\{X_k\}_k$, the marks $\{M_k\}_k$ are mutually independent random vectors on $S_M$, and for every $k\in\N$ the conditional distribution of $M_k$ depends only on the location of $X_k$, i.e., $\P(M_k\in B \mid \Phi) = \P(M_k\in B\mid X_k)$ for any $B\in\cal{S}_M$, and we denote this probability measure as
    $
        F_x(B) \triangleq \P(M\in B\mid X).
    $
\end{definition}

For the Poisson point process, we have the following.
\begin{theorem}
    An independently marked PPP $\hat\Phi$ with instensity measure $\Lambda$ on $\R^d$ and marks with distribution $F_x$ on $\R^l$ is a PPP on $\R^d\times\R^l$ with intensity measure
    \begin{align*}
        \hat\Lambda(A\times B) = \int_A \int_B \d F_x(m)\,\d\Lambda(x), \qquad A\in\cal{B}(\R^d), B\in\cal{B}(\R^l).
    \end{align*}
    Thus, for a \textit{measurable} function $f:\R^d\times\R^l\longrightarrow\R_+$ we have that the Laplace functional
    \begin{align*}
        \mathscr{L}_{\hat\Phi}(f) = \E\left[ \exp\!\left( -\sum_k f(X_k,M_k) \right) \right] = \exp\!\left( - \int_{\R^d}\left(1 - \int_{\R^l} \euler^{-f(x,m)} \d F_x(m) \right) \d\Lambda(x)\right).
    \end{align*}
\end{theorem}

Finally, the mathematical entity that models the aggregate interference measured at a point $y$ of the space is presented below.
%
\begin{definition}[\textbf{Shot-noise field}]
    The shot-noise field $I_{\hat\Phi}$ associated with the marked point process $\hat\Phi$ on space $\R^d$ and marks on $\R^l$, and response function given by a \textit{measurable} function $L:\R^{d'}\times\R^d\times\R^l\longrightarrow\R_+$, is defined by
    \begin{align*}
        I_{\hat\Phi}(y) \triangleq \sum_k L(y,X_k,M_k) = \int_{\R^d}\int_{\R^l} L(y,x,m) \,\d\hat\Phi(x,m),\quad y\in\R^{d'}.
    \end{align*}
\end{definition}

\begin{remark}
    A convenient form we shall use to define a shot-noise field is through the abuse of notation $x\in\Phi$. In our context, this is not correct because $\Phi$ is a random measure, then it does not make sense to write $x\in\Phi$.
    %
    That is why we defined the notation $\Phi\stackrel{*}{=}\{X_k\}_k$ in Remark~\ref{rem:PP_set_notation}. Therefore, what we mean by $x\in\Phi$ is $x\in\{X_k\}_k$.
    %
    Using this, we can specify a shot-noise field with a more self-contained notation, for example,
    \begin{align*}
        I_{\Phi}(y) = \sum_{x\in\Phi} L(y,x,M_x),
    \end{align*}
    when the marks $M_x$ only depend on the position $x$ and are independent across the space.
\end{remark}

The term ``shot-noise'' comes from the one-dimensional process on $\R$. Imagine there is a cumulative effect of the ``shots'' which happened at times $\{X_k\}_k$ through the response function $f$ over time. Then, the shot-noise $I(t) = \sum_k f(t-X_k)$ is the cumulative effect of the shots that took place before time $t$.
%
However, in the case of a point process in $\R^d$, there is no ordering.
%
For the independently marked PPP we have the following result.
\begin{theorem} \label{th:Laplace_PPP_shot-noise}
     Let $\hat\Phi$ be an independently marked PPP with intensity measure $\Lambda$ and mark distribution $F_x$. Then, the Laplace transform of the distribution of the shot-noise $I_{\hat\Phi(y)}$ with response function $L$ is given by
     \begin{align*}
         \mathscr{L}_{I_{\hat\Phi(y)}}(s) \triangleq \E\!\left[\euler^{-s I_{\hat\Phi(y)}}\right] = \exp\!\left( -\int_{\R^d}\int_{\R^l}\left( 1 - \euler^{-s L(y,x,m)}\right) \d F_x(m)\,\d\Lambda(x) \right), \quad y\in\R^{d'}, s\in\C.
     \end{align*}
\end{theorem}

All the presented properties and theorems over the homogeneous PPP illustrate and validate the analytical tractability of this mathematical object, which is useful to model the random position of nodes in a wireless network.
%
See \cite{lee2013stochastic} for more on the model validity of the PPP applied to wireless networks.

% % % % % % % % % % % % % % % % % %
\section{Interference on Wireless Networks} \label{sec:P1_03_02}

Let us assume that the active transmitters (which are the ones that are currently transmitting a packet) of a wireless network are distributed according to a marked point process $\hat\Phi \stackrel{*}{=}\{X_k, H_k\}_{k\in\N}$ in the space $\R^d$ with marks on $\R$, where $\{X_k\}_k \stackrel{*}{=} \Phi$ is the transmitters position and $\{H_k\}_k$ is a sequence of independent random variables that represent some random phenomena, e.g. the multipath fading and shadowing coefficient of the signal.
%
Then, we are interested in the aggregate interference caused by the transmitters in a given point $y\in\R^d$ of space.
%
The interference from each transmitter can be generally represented by a function $\ell:\R_+\longrightarrow\R_+$ of the distances of the transmitters to the point $y\in\R^d$, which usually depends on the path loss model, e.g $\ell(r) = r^{-\alpha}$, $r>0$, $\alpha > 2$.
%
Then, the aggregate interference can be modeled by the shot-noise field
\begin{align} \label{eq:shot-noise_interference}
    I(y) \triangleq \sum_{k\in\N} H_k\,\ell(||X_k-y||), \quad y\in\R^d.
\end{align}

% \begin{note}
%     Note that $X\in\Phi$ is an abuse of notation in the sense that $\Phi$ is not the set of points of the point process, but a random measure. Then, \textit{a priori}, it is not correct to write $X\in\Phi$.
%     %
%     However, since this notation is used in the literature and it is convenient, we shall use it as well.
% \end{note}

An important form of characterizing the interference $I$ is through its Laplace transform
\begin{align*}
    \mathscr{L}_{I(y)}(s) &\triangleq \E\!\left[\euler^{-sI(y)}\right]
        = \E\!\left[ \exp\!\left( -s \sum_{k\in\N} H_k\,\ell(||X_k-y||)  \right) \right], \qquad s\in\C.
\end{align*}

For the special case of PPP and $\{H_k\}_k$ iid random variables that follow an exponential distribution, we can show the following very important literature result.
\begin{theorem}
     Let $\hat\Phi$ be an independently marked PPP with intensity measure $\Lambda$ on $\R^d$ and mark distribution $F_x$ on $\R$ such that the marks follow an exponential distribution of parameter $1$.
     %
     Then, the Laplace transform of the shot-noise field of interference $I$ defined in \eqref{eq:shot-noise_interference} is given by
     \begin{align*}
         \mathscr{L}_{I(y)}(s) = \int_{\R_d} \left(1 + \frac{1}{s\,\ell(||x-y||)}\right)^{-1}\,\d\Lambda(x),\quad s\in\C, y\in\R^d,
     \end{align*}

    Further, if we have a homogeneous PPP of density $\lambda > 0$, then it simplifies to
    \begin{align*}
         \mathscr{L}_I(s) = \int_{\R_d} \left(1 + \frac{1}{s\,\ell(||x||)}\right)^{-1} \lambda\,\d x,\quad s\in\C,
     \end{align*}
     which no longer depends on the position $y\in\R^d$ due to the translation invariance (ergodicity) of the homogeneous PPP.
\end{theorem}
This can be used to model homogeneous networks subjected to Rayleigh short-term fading.

Another crucial result for the theory of stochastic geometry and wireless networks can be derived for systems that operate under the \textit{capture model}.
% Another crucial result for the theory of stochastic geometry and wireless networks regards the \textit{capture model}.
%
In the capture model, if the $\mathrm{SINR}$ (i.e. the ratio between the received signal power and the received interference power plus noise) is above a threshold $\theta > 0$, then the packet is successfully received at a transmitter.
%
\begin{proposition} \label{prop:PPP_ps}
    Let us consider the capture model and Rayleigh short-term fading\footnote{The $\{H_k\}_k$ are iid and follow an exponential distribution of parameter $1$.}. Let the signal-to-interference-plus-noise ratio be given by
    \begin{align*}
        \mathrm{SINR} \triangleq \frac{H\,\ell(r)}{I + w_0},
    \end{align*}
    where $r>0$ is the transmission distance, $H\sim\mathscr{E}(1)$ is the short-term fading coefficient for the transmission, $w_0 \ge 0$ is a constant representing thermal noise, and the interference $I$ is defined in \eqref{eq:shot-noise_interference} for a given location $y\in\R^d$ of the receiver.
    %
    Then, the transmission success probability
    \begin{align} \label{eq:Ch3_ps}
        p_s \triangleq \P(\mathrm{SINR} > \theta) = \mathscr{L}_I\!\left( \theta/\ell(r) \right) \euler^{-\theta w_0/\ell(r)}.
    \end{align}

    Further, if $\Phi$ is a homogeneous PPP with density $\lambda>0$, then
    \begin{align}
        p_s = \exp\!\big( -\lambda g_\ell(r,\theta) - \theta w_0/\ell(r) \big),
    \end{align}
    where $g_\ell(r,\theta) \triangleq \displaystyle\int_{\R^d} \frac{\theta \ell(||x||)}{\theta \ell(||x||)+\ell(r)} \,\d x$.
\end{proposition}
%
Equation~\eqref{eq:Ch3_ps} is a handy formula to calculate the transmission success probability in wireless networks subjected to Rayleigh fading.
%
For the homogeneous PPP case, the function $g_\ell:\R^2_+\longrightarrow\R_+$ relates the effect of the interference per density of transmitters with the transmission success probability.
%
Further, we can see that the transmission success probability $p_s$ decays exponentially with the density of interferers $\lambda$.

\begin{example} \label{ex:classic_network}
    The classic example is a wireless network on the plane $\R^2$, limited by interference (noise is negligible and $w_0 = 0$), subjected to Rayleigh short-term fading and power law path loss function $\ell(r) = r^{-\alpha}$, $r>0$, $\alpha > 2$.
    %
    The positions of the active transmitters follow a homogeneous PPP of density $\lambda > 0$ on $\R^2$.
    %
    Then, using the \textit{capture model} with threshold for successful communication $\theta > 0$, we can show through Proposition~\ref{prop:PPP_ps} that the transmission success probability of a transmission with link distance $r>0$ is
    \begin{align*}
        p_s = \exp\!\left( -\lambda \pi r^2 \theta^\delta \frac{\delta\pi}{\sin(\delta\pi)} \right),
    \end{align*}
    where $\delta\triangleq 2/\alpha$, thus $\delta\in(0,1)$.

    From this, we have that the transmission success probability $p_s$ decreases with the density of transmitters $\lambda$, the link distance $r$, and the threshold for successful communication $\theta$, which is expected.
    %
    However, different from what is commonly expected, $p_s$ does not increase with the path loss exponent $\alpha$ in general, i.e., the increasing/decreasing analysis depends on the value of $\theta$ and the interval of $\alpha$.
\end{example}

Finally, with this example we conclude the review of stochastic geometry applied to wireless networks.


% declare document class and geometry
\documentclass[12pt]{article} % use larger type; default would be 10pt
\usepackage[margin=1in]{geometry} % handle page geometry

% import packages and commands
\input{../header2.tex}

\title{Math 217 -- Geometry and Physics -- Lec04}
\author{UCLA, Fall 2014}
\date{\formatdate{10}{10}{2014}} % Activate to display a given date or no date (if empty),
         % otherwise the current date is printed

\begin{document}
\maketitle

\section{Stuff}

Recall again the Gauss-Bonnet-Chern theorem: for $M^{2n}$ a compact closed oriented manifold, we have
\begin{equation}
\int_M \varepsilon(TM) = \chi(M) = \sum_{i=0}^{2n} (-1)^i b_i.
\end{equation}

Then we have
\begin{enumerate}
\item $H^k(M) \cong H^{2n-k}(M)$
\item Thom isomorphism: Let $\Delta \subseteq M$ be a submanifold and
\begin{equation}
N_\Delta \cong (TM|_\Delta) / T\Delta
\end{equation}
the normal bundle of $\Delta$ in $M$. Let $T(N_\Delta)$ be the Thom class of $N_\Delta$. Then the Poincare dual $\eta_\Delta$ of $\Delta$ is equal to $T(N_\Delta) \in H_c^*(N_\Delta)$ (Bott-Tu). That is, given the projection $i_{\Delta*} : N_\Delta \hookrightarrow M$ we have $i_{\Delta*} T(N_\Delta) = \eta_\Delta$.
\end{enumerate}

Given a basis $\set{ \omega_i }$ of $H^*(M) = \oplus_{i=0}^{2n} H^i (M)$, define a dual basis $\set{ \tau_i }$ of $H^*(M)^*$ through the Poincare duality $H^k \cong (H^{2n-k})^*$ such that $\int_M \omega_i \wedge \tau_j = \delta_{ij}$. Now, from Kuenneth's theorem, we know that
\begin{equation}
\begin{matrix}
H^*(M \times M) & \cong & H^*(M) & \otimes_\reals & H^*(M) \\
\set{ \pi^* \omega_i \wedge \rho^* \tau_j } & & \set{ \omega_i } & & \set{ \tau_j }.
\end{matrix}
\end{equation}
Denote $i : \Delta \hookrightarrow M \times M$, $\Delta$ the diagonal $\set{ x,x } \in M \times M$ isomorphic to $M$ and let $\eta_\Delta \in H^*(M \times M)$ be the Poincare dual of $\Delta$. Then
\begin{equation}
\eta_\Delta = \sum_{ij} c_{ij} \pi^* \omega_i \wedge \rho^* \tau_j
\end{equation}

\begin{lemma}
\begin{equation}
\eta_\Delta = \sum_i (-1)^{\deg \omega_i} \pi^* \omega_i \wedge \rho^* \tau_i
\end{equation}
\end{lemma}

\begin{proof}
We have $\pi \circ i = \opname{id}, \rho \circ i = \opname{id} \implies i^* \rho^*, i^* \pi^*$ are identity on cohomology. Then
\begin{align}
\int_\Delta i^* (\pi^* \tau_k \wedge \rho^* \omega_l) &= \int_M i^* (\pi^* \tau_k \wedge \rho^* \omega_l) \\
	&= \int_M (i^* \pi^*) \tau_k \wedge (i^* \rho^*) \omega_l \\
	&= \int_M \tau_k \wedge \omega_l \\
	&= \delta_{kl} (-1)^{\deg \tau_k \deg \omega_l}.
\end{align}
Furthermore
\begin{align}
\int_\Delta \pi^* \tau_k \wedge \rho^* \omega_l &= \int_{M \times M} (\pi^* \tau_k \wedge \rho^* \omega_l) \wedge \eta_\Delta \\
	&= \sum_{ij} c_{ij} \int_{M \times M} (\pi^* \tau_k \wedge \rho^* \omega_l) \wedge (\pi^* \omega_i \wedge \rho^* \tau_j) \\
	&= \sum_{ij} c_{ij} (-1)^{(\deg \tau_k + \deg \omega_l) \deg \omega_i} \int_{M \times M} \pi^* (\omega_i \wedge \tau_k) \wedge \rho^* (\omega_l \wedge \tau_j) \\
	&= \sum_{ij} c_{ij} (-1)^{(\deg \tau_k + \deg \omega_l) \deg \omega_i} (\int_M \omega_i \wedge \tau_k) (\int_M \omega_l \wedge \tau_j) \\
	&= \sum_{ij} c_{ij} (-1)^{(\deg \tau_k + \deg \omega_l) \deg \omega_i} \delta_{ik} \delta{lj} \\
	&= c_{kl} (-1)^{(\deg \tau_k + \deg \omega_l) \deg \omega_k}
\end{align}
where
\begin{equation}
c_{kl} =
\begin{cases}
0 & k \neq l, \\
(-1)^{\deg \omega_k} & k = l.
\end{cases}
\end{equation}
\end{proof}

\begin{lemma}
Let $T_\Delta$ be the tangent bundle of $\Delta \hookrightarrow M \times M$. Then $T_\Delta \cong N_\Delta$.
\end{lemma}

\begin{proof}
\begin{equation}
\begin{matrix}
0 & \rightarrow & T_\Delta & \rightarrow & T_{M \times M} |_\Delta & \rightarrow & N_\Delta & \rightarrow 0 \\
& & \cong & & \cong & & \cong & & \\
0 & \rightarrow & T_M & \rightarrow & TM \oplus TM & \rightarrow & T_M & \rightarrow 0
\end{matrix}
\end{equation}
We have
\begin{equation}
\int_\Delta i_\Delta^* \eta_\Delta = \int_\Delta i_\Delta^* \Phi(N_\Delta) = \int_\Delta \varepsilon(N_\Delta) = \int_M \varepsilon(TM)
\end{equation}
where $s : M \rightarrow E$ is a section and $s^* \Phi(E) = \varepsilon(E)$. We have
\begin{align}
\int_\Delta i_\Delta^* \eta_\Delta &= \sum_i (-1)^{\deg \omega_i} \int_\Delta i_\Delta^* (\pi^* \omega_i \wedge \rho^* \tau_i) \\
	&= \sum_i (-1)^{\deg \omega_i} \int_M (i^* \pi^* ) \omega_i \wedge (i^* \rho^* \tau_i) \\
	&= \sum_i (-1)^{\deg \omega_i} \int_M \underbrace{\omega_i \wedge \tau_i}_{= 1} \\
	&= \sum_{i=0}^{2n} (-1)^i \dim H^i(M) = \chi(M).
\end{align}
\end{proof}

\section{More on Lie Algebras}

Let $g$ be a Lie algebra of a Lie group $G$. We have $g = T_e G$ where $e \in G$ is the identity, and this is also seen as the space of left invariant vector fields. We have the commutator taking $g \times g \rightarrow g$ defined by $X,Y \mapsto [X,Y]$. We have the identities
\begin{enumerate}
\item $[X,Y] = -[Y, X]$, and
\item $[[X,Y],Z] + [[Y,Z], X] + [[Z,X],Y] = 0$, the Jacobi identity.
\end{enumerate}

For example the Lie group $SO_n$ has the Lie algebra $\mathfrak{so}_n$. We have $\mathfrak{so}_n \cong \Lambda^2 \reals^n$. So $\set{ e_1, \dots, e_n }$ is an orthonormal basis w.r.t. the inner product $\inner{\cdot}{\cdot}$. And we have
\begin{equation}
v \wedge w (x) = \inner{v}{x} w - \inner{w}{x} v \quad \forall x \in \reals^n
\end{equation}

There is a one to one correspondence between one parameter subgroups of $G$ and orbits of elements of $g$ passing through $e$.
\begin{equation}
\psi : \reals \rightarrow G	\quad	\leftrightarrow	\quad	\psi'(0) = X \in G
\end{equation}
Geodesics of $G$ with Killing metric on $G$.

\end{document}


% Created 2022-01-04 Tue 01:07
% Intended LaTeX compiler: pdflatex
\documentclass[presentation]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{awesomebox}
\usepackage{booktabs}
\usepackage{placeins}
\usepackage{siunitx}
\usepackage{minted}
\usetheme[progressbar=frametitle]{metropolis}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{intersections,calc,shapes.geometric}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{spot}
\newcommand{\gv}[1]{\ensuremath{\mbox{\boldmath$ #1 $}}}
\newcommand{\bv}[1]{\ensuremath{\mathbf{#1}}}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\newcommand{\abs}[1]{\left\lvert#1\right\rvert}
\newcommand{\bigqm}[1][1]{\text{\larger[#1]{\text{?}}}}
\newcommand{\order}[1]{\mathcal O \left( #1 \right)} % order of magnitude
\definecolor{scarlet}{rgb}{1.0, 0.13, 0.0}
\definecolor{shamrockgreen}{rgb}{0.0, 0.62, 0.38}
\definecolor{royalblue}{rgb}{0.25, 0.41, 0.88}
\definecolor{metropolisorange}{RGB}{235,129,27}
\definecolor{metropolisblue}{RGB}{35,55,59}
\usetheme{default}
\author{\emph{Tejaswin Parthasarathy}, Mattia Gazzola}
\date{\today}
\title{Elastica : Spatial discretization}
\subtitle{ME447: Comp. Design \& Dyn. of Soft Syst}
\hypersetup{
 pdfauthor={\emph{Tejaswin Parthasarathy}, Mattia Gazzola},
 pdftitle={Elastica : Spatial discretization},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 28.0.50 (Org mode 9.4.6)},
 pdflang={English}}
\begin{document}

\maketitle
\tikzset{>=latex}
\section{Introduction}
\label{sec:orge774469}
\begin{frame}[label={sec:org7f9ec4c}]{Integration and differentiation of functions}
More specifically numerical integration (\alert{quadrature}) and differentiation
\begin{block}{Integration}
Given \(a, b, f\) compute a numerical approximation to
\[ \int_{a}^{b} f(x) dx \]
For purposes of this course, we assume \(f\) is Riemann integrable
  \(\Rightarrow\) Integral exists and is unique
\end{block}
\begin{block}{Differentiation}
Given \(a, b, f\) compute a numerical approximation to
\[ \frac{df}{dx} \; \in \; [a,b]\]
Again we assume \(f\) is smooth enough (\(C^{r}\;\in\;[a,b]\))
\end{block}
\end{frame}
\begin{frame}[label={sec:orgf272416}]{Where are these useful?}
\begin{block}{Everywhere!}
\begin{itemize}
\item We \emph{integrated} quantitites in time in the last lecture (IVPs and
timeseries analysis)
\item Anything involving spatial quantities (BVPs, including solving PDEs using
finite differences/volume/element, spectral element and so on\ldots{})
\end{itemize}
\end{block}
\end{frame}
\begin{frame}[label={sec:org9e7d555}]{Outline}
\begin{itemize}
\item More about quadrature, and what to look for in a quadrature rule
\item Simple (yet effective) quadrature schemes and their derivation
\item Do the same for numerical differentiation
\item Give context to these methods in our soft mechanics framework
\end{itemize}
\end{frame}
\section{Quadrature}
\label{sec:org104f99a}
\begin{frame}[label={sec:orgd5e45d4}]{Interpolatory quadrature}
\begin{itemize}
\item Design a quadrature method based on interpolation of values
\item \alert{Why?} Typically values are known at few points in simulations
\end{itemize}
\begin{block}{Linear combination}
\begin{itemize}
\item As integration is a linear operator, we perform a linear weighted
combination of few function values
\end{itemize}
\[ \int_{a}^{b} f(x) dx \approx \sum_{i=1}^{n} \omega_i f(x_i) \]
\begin{itemize}
\item We can then play games with \alert{nodes} (\(x_i\)) and \alert{weights} (\(\omega_i\))
\(\Rightarrow\) different quadrature rules
\end{itemize}
\end{block}
\end{frame}
\begin{frame}[label={sec:org115bc46}]{What do we look for in a quadrature rule?}
While designing quadrature rules, you are concerned about
\begin{itemize}
\item Accuracy (how correct is your answer, and whats the convergence)
\item Function evaluations
\item Stability (does your integral ``blow up'', in the presence of errors)?
\end{itemize}

Choose \(x_i\) and \(\omega_i\) to minimize error \(\abs{\tilde{I} -I_h }\) while reducing number of function evaluations and robust to numerical errors
\end{frame}
\begin{frame}[label={sec:org065ecb3}]{Midpoint and Trapezoidal rules}
\begin{columns}
\begin{column}{0.5\columnwidth}
\begin{center}
	\begin{tikzpicture}[
	declare function={func(\x)=sin(deg(pi*\x));},
	declare function={funcder(\x)=pi*cos(deg(pi*\x));}]
	\begin{axis}%
		[grid=none,
		axis x line=bottom,
		axis y line=left,
		domain=1.52:1.62,
		xmin=1.50,
		xmax=1.64,
		ymax=-0.92,
		ymin=-1.02,
		xlabel={$t$},
		ylabel={$u(t)$},
		ticks=none,
		width=1.1\textwidth,
		title={Midpoint rule},
		title style={at={(0.5,1.0)},anchor=north},
		enlargelimits=false,
		]
		\addplot[smooth, very thick,
		color=metropolisorange]{func(x)};

		% Add rectangle betewen 1.53 and 1.61
		\filldraw[thick, color=metropolisblue, fill=metropolisblue, fill opacity=0.2]
		(axis cs: 1.53, \pgfkeysvalueof{/pgfplots/ymin})
		rectangle (axis cs: 1.61,{func(1.57)});

		% Draw point
		\node (M) [circle, minimum size=5, inner sep=0, fill=metropolisorange]
		at (axis cs: 1.57, {func(1.57)}) {};

	\end{axis}
	\end{tikzpicture}
\end{center}
\end{column}

\begin{column}{0.5\columnwidth}
\begin{center}
	\begin{tikzpicture}[
	declare function={func(\x)=sin(deg(pi*\x));},
	declare function={funcder(\x)=pi*cos(deg(pi*\x));}]
	\begin{axis}%
		[grid=none,
		axis x line=bottom,
		axis y line=left,
		domain=1.52:1.62,
		xmin=1.50,
		xmax=1.64,
		ymax=-0.92,
		ymin=-1.02,
		xlabel={$t$},
		ylabel={$u(t)$},
		ticks=none,
		width=1.1\textwidth,
		title={Trapezoidal rule},
		title style={at={(0.5,1.0)},anchor=north},
		enlargelimits=false,
		disabledatascaling
		]
		\addplot[smooth, very thick,
		color=metropolisorange]{func(x)};

		% Draw point
		\node (M) [circle, minimum size=5, inner sep=0, fill=metropolisorange]
		at (axis cs: 1.57, {func(1.57)}) {};

		% Add trapezoid betewen 1.53 and 1.61 by first defining coordinates
		% https://tex.stackexchange.com/a/324328
		\path (M) + (axis cs:-0.04,{-funcder(1.57)*0.04}) coordinate (A);
		\path (A) + (axis cs:0.0,\pgfkeysvalueof{/pgfplots/ymin}) coordinate (Ad);
		\path (M) + (axis cs:0.04, {funcder(1.57)*0.04}) coordinate (B);
		\path (B) + (axis cs:0.0,\pgfkeysvalueof{/pgfplots/ymin}) coordinate (Bd);

		\draw [thick, color=metropolisblue, fill=metropolisblue, fill opacity=0.2]
		(M) -- (A) -- (Ad) -- (Bd) -- (B) -- cycle;

		% Add rectangle betewen 1.53 and 1.61
		\draw[dashed, thin]
		(axis cs: 1.53, \pgfkeysvalueof{/pgfplots/ymin})
		rectangle (axis cs: 1.61,{func(1.57)});

	\end{axis}
	\end{tikzpicture}
\end{center}
\end{column}
\end{columns}

\begin{block}{Midpoint rule}
\[ I_h = (b-a) f \left( \frac{a + b}{2} \right) \]
\end{block}
\begin{block}{Trapezoidal rule}
\[ I_h = \frac{(b-a)}{2} \left( f(a) + f(b) \right) \]
\end{block}
\end{frame}
\begin{frame}[label={sec:org7260fc8}]{Midpoint rule}
Suppose \(x \in [a,b]\) we have with Taylor series about \(c = \frac{a +
   b}{2}\)
\[ \begin{aligned} f(x) &= f(c) + (x-c) f^\prime(c) +
   \frac{(x-c)^2}{2!}f^{\prime\prime}(c) + \cdots \end{aligned}\]
Integrate this
\[ \begin{aligned} I_{h} = \int_{a}^{b} f(x) dx &= hf(c) + \frac{(x-c)^2}{2} \biggr\rvert_{a}^{b} f^\prime(c) +
   \frac{(x-c)^3}{3!} \biggr\rvert_{a}^{b} f^{\prime\prime}(c) + \cdots \\
   & = (b-a) f \left( \frac{a + b}{2} \right) +
   \frac{h^3}{24}f^{\prime\prime}(c) + \frac{h^5}{1920}f^{iv}(c) + \cdots
   \end{aligned}\]
Error is then:
\[ e_h  = \frac{h^3}{24}f^{\prime\prime}(c) + \frac{h^5}{1920}f^{iv}(c) + \cdots\]
\end{frame}
\begin{frame}[label={sec:orgbd159d2}]{Trapezoidal rule}
Suppose \(x \in [a,b]\) we have with Taylor series about \(c = \frac{a +
   b}{2}\)
\[ \begin{aligned} f(a) &= f(c) - \frac{h}{2} f^\prime(c) +
   \frac{h^2}{2^2 \cdot 2!}f^{\prime\prime}(c) + \cdots \\
   f(b) &= f(c) + \frac{h}{2} f^\prime(c) +
   \frac{h^2}{2^2 \cdot 2!}f^{\prime\prime}(c) + \cdots \\
   \end{aligned}\]
Adding and integrating (retaining the \(x\)-dependence),
\[ \begin{aligned}
   \frac{(b-a)}{2} \left( f(a) + f(b) \right) &= I^{\text{midpoint}} +
   \frac{h^3}{2!2^2}f^{\prime\prime}(c) + \frac{h^5}{4!2^4}f^{iv}(c) + \cdots \\
   &= \tilde{I} +  \frac{h^3}{12}f^{\prime\prime}(c) + \frac{h^5}{480}f^{iv}(c) + \cdots \\
   \end{aligned}\]
Error is then:
\[ e_h  = \frac{h^3}{12}f^{\prime\prime}(c) + \frac{h^5}{480}f^{iv}(c) + \cdots\]
\alert{Twice} that of midpoint rule!
\end{frame}
\begin{frame}[label={sec:org99de5fc},fragile]{Other quadrature rules}
 \begin{itemize}
\item Many other better interpolatory (i.e. not only linear) quadrature rules exist\ldots{}
\item If nodes are equispaced and interpolation is done using polynomials
\(\Rightarrow\) \alert{Newton--Cotes} quadrature (we discuss this)
\item If nodes are zeros of the Chebyshev polynomials and interpolation using
same polynomials
\(\Rightarrow\) \alert{Clenshaw--Curtis} quadrature (seen in \texttt{scipy.integrate.quad()})
\item If nodes and weights are based on Legendre polynomials and Gauss--Legendre
points \(\Rightarrow\) \alert{Gaussian} quadrature
\item (Un)fortunately, we will not be discussing all of them in this course
\end{itemize}
\end{frame}
\begin{frame}[label={sec:org5c971ad}]{How do these perform?}
\alert{DEMO}
\begin{itemize}
\item Notice we have the \(2x\) errors showing up in numerics as well
\item Does not work that well\ldots{}Why?
\item The function to be integrated needs to be \alert{linear} for perfect integration
(even in the case of midpoint rule)
\begin{itemize}
\item Geometrical argument (from demo)
\item Error estimates (highest derivative is 2, which vanishes for a linear function)
\end{itemize}
\item Of course, real functions are not---so what do we do?
\item \alert{Composite rules}
\end{itemize}
\end{frame}
\begin{frame}[label={sec:org11cc898}]{Composite rules in quadrature}
\begin{itemize}
\item Approximate function using many piecewise linears and sum up their
contributions across all such approximations
\begin{itemize}
\item Mirrors definition of Riemann integrable functions
\item More work per integration (many more function evaluations)
\item But\ldots{}better estimates!
\end{itemize}
\item How good is our approximation? Seek error estimates\ldots{}
\end{itemize}
\begin{center}
\begin{tikzpicture}[scale=0.5]
\coordinate (p1) at (0.7,3);
\coordinate (p2) at (1,3.3);
\coordinate (p3) at (2,2.5);
\coordinate (p4) at (3,2.5);
\coordinate (p5) at (4,3.5);
\coordinate (p6) at (5,4.1);
\coordinate (p7) at (6,3.4);
\coordinate (p8) at (7,4.1);
\coordinate (p9) at (8,4.6);
\coordinate (p10) at (9,4);
\coordinate (p11) at (9.5,4.7);

% The cyan background
\fill[metropolisblue, fill opacity = 0.2]
(p2|-0,0) -- (p2) -- (p3) -- (p4) -- (p5) -- (p6) -- (p7) -- (p8) -- (p9) -- (p10) -- (p10|-0,0) -- cycle;
% the dark cyan stripe
\fill[metropolisblue, fill opacity = 0.6] (p6|-0,0) -- (p6) -- (p7) -- (p7|-0,0) -- cycle;
% the curve
\draw[thick,metropolisorange]
(p1) to[out=70,in=180] (p2) to[out=0,in=150]
(p3) to[out=-50,in=230] (p4) to[out=30,in=220]
(p5) to[out=50,in=150] (p6) to[out=-30,in=180]
(p7) to[out=0,in=230] (p8) to[out=40,in=180]
(p9) to[out=-30,in=180] (p10) to[out=0,in=260] (p11);
% the broken line connecting points on the curve
\draw (p2) -- (p3) -- (p4) -- (p5) -- (p6) -- (p7) -- (p8) -- (p9) -- (p10);
% vertical lines and labels
\foreach \n/\texto in {2/{x_0},3/{x_1},4/{},5/{},6/{x_{j-1}},7/{x_j},8/{},9/{x_{n-1}},10/{x_n}}
{
\draw (p\n|-0,0) -- (p\n);
\node[below,text height=1.5ex,text depth=1ex,font=\small] at (p\n|-0,0) {$\texto$};
}
% The axes
\draw[->] (-0.5,0) -- (10,0) coordinate (x axis);
\draw[->] (0,-0.5) -- (0,6) coordinate (y axis);
% labels for the axes
\node[below] at (x axis) {$x$};
\node[left] at (y axis) {$y$};
% label for the function
\node[above,text=metropolisorange] at (p11) {$y=f(x)$};
\end{tikzpicture}
\end{center}
\end{frame}
\begin{frame}[label={sec:org710ae4a}]{Composition using Trapezoidal rule}
\[ \begin{aligned} I_{\text{CT}} &= h \left[ \sum_{i=1}^{n-1} f_i +
   \frac{1}{2}(f_0 + f_n) \right] \\
   &= \sum_{i=1}^{n}\frac{h}{2} \left[ f_{i-1} + f_{i}\right] \\
   &= \sum_{i=1}^{n} \left[ \tilde{I} +  c_2{h^3}f^{\prime\prime}(x_{i-\frac{1}{2}}) + c_4{h^5}f^{iv}(x_{i-\frac{1}{2}}) +
   c_6{h^7}f^{vi}(x_{i-\frac{1}{2}}) + \cdots \right] \\
   &= \tilde{I} + c_2h^2 \left[ h \sum_{i=1}^{n}
   f^{\prime\prime}(x_{i-\frac{1}{2}})\right] +  c_4h^4 \left[ h \sum_{i=1}^{n}
   f^{iv}(x_{i-\frac{1}{2}}) \right] + \cdots \\
   &= \tilde{I} + \frac{h^2}{12} \left[ \int_{a}^{b} f^{\prime\prime}dx +
   \text{h.o.t} + \right]  + \frac{h^4}{480} \left[ \int_{a}^{b} f^{iv}dx +
   \text{h.o.t} + \right] + \cdots \\
   &= \tilde{I} + \frac{h^2}{12} \left[ f^\prime(b) - f^\prime(a) \right] + h.o.t.
   \end{aligned}\]
\end{frame}
\begin{frame}[label={sec:orgd11b867}]{Composite rules in quadrature}
\begin{itemize}
\item \alert{Observation} We lose an order of accuracy in cumulation!
\item Is this seen numerically? \alert{DEMO}
\item Even in timestepping, this is observed (\alert{Local} truncation error vs
\alert{Global} truncation error)
\item But, we get good estimates of the integral (especially for polynomials)
\end{itemize}
\end{frame}
\begin{frame}[label={sec:org33e6486}]{Integrand dependence}
\begin{itemize}
\item Does it depend on the function being integrated?
\item \alert{DEMO}
\item \alert{Yes}. Depending upon the end point conditions:
\begin{itemize}
\item Standard case (nothing special happens)
\item Lucky (\(f^\prime(a) = f^\prime(b) = 0\))
\item More lucky (\(f^{(k)}(a) = f^{(k)}(b) = 0 \;, k = 1,2,\cdots\))
\item Unlucky (\(f^{\prime}(a) = \infty\))
\end{itemize}
\end{itemize}
we may get better/worse performance\ldots{}
\end{frame}
\begin{frame}[label={sec:org8759439}]{Stability of quadrature}
\begin{itemize}
\item We won't explicitly dicuss stability
\item \alert{Rule of thumb}---no negative weights in interpolatory quadrature
\item All discussed quadrature rules are stable
\end{itemize}
\end{frame}
\begin{frame}[label={sec:org10de8ca}]{Soft mechanics framework}
Many temporal and spatial integrations. More explicitly,

\[ \spot<2>{\begin{aligned}
   \frac{\partial \bv{d}_j}{\partial t} &= \left( \bv{Q}^T
   \omega_{\mathcal{L}}\right) \times \bv{d}_j \\
   \frac{\partial \bv{d}_j}{\partial s} &= \left( \bv{Q}^T
   \kappa_{\mathcal{L}}\right) \times \bv{d}_j
   \end{aligned}} \]
\begin{block}<2->{Analytical integration using exponentials}
\end{block}
\[ \spot<3>{\begin{aligned}\frac{\hat{\mathbf{J}}_i}{e_i} \cdot \frac{\partial
	\boldsymbol{\omega}^i_{\mathcal{L}}}{\partial t} &=
	\Delta^h\left(\frac{\hat{\boldsymbol{\mathcal{B}}}_i\hat{\boldsymbol{\kappa}}_{\mathcal{L}}^{i}}{\mathcal{E}_i^3}\right) +
	\mathcal{A}^h\left(\frac{\hat{\boldsymbol{\kappa}}_{\mathcal{L}}^i\times\hat{\boldsymbol{\mathcal{B}}}_i
	\hat{\boldsymbol{\kappa}}_{\mathcal{L}}^i}{\mathcal{E}_i^3}
	\hat{\mathcal{D}}_i\right) + \left(\mathbf{Q}_i\mathbf{t}_i\times\hat{\mathbf{S}}_i\boldsymbol{\sigma}^i_{\mathcal{L}}\right)\hat{\ell}_i\\
	&+ \mathbf{C}^i_{\mathcal{L}},\quad i=[1,n] \end{aligned}}\]
\begin{block}<3->{\(\mathcal{A}^{h}\) using trapezoidal quadrature}
\end{block}
\end{frame}
\begin{frame}[label={sec:org2ec319d}]{The \(\mathcal{A}^{h}\) operator}
Define the \(\mathcal{A}^{h}\) operator as:
\[ \mathbf{y}_{j=1, \ldots, N+1}=\mathcal{A}^{h}\left(\mathbf{x}_{i=1, \ldots
   N}\right)=\left\{\begin{array}{ll}{\frac{\mathbf{x}_{1}}{2}} & {\text { if }
   j=1} \\ {\frac{\mathbf{x}_{j}+\mathbf{x}_{j-1}}{2}} & {\text { if } 1<j \leq
   N} \\ {\frac{\mathbf{x}_{N}}{2}} & {\text { if } j=N+1}\end{array}\right. \]
\end{frame}
\begin{frame}[label={sec:org4db7582},fragile]{The \(\mathcal{A}^{h}\) operator}
 Implementation using \texttt{numpy}
\begin{minted}[,fontsize=\scriptsize]{python}
import numpy as np

# Modified trapezoidal integration
def modified_trapz(t_x):
    """ Modified trapezoidal integration"""
    # Pads a 0 at the start of an array
    temp = np.pad(t_x, (1,0), 'constant', constant_values=(0,0))
    # Using roll calculate the integral (ghost node of 0)
    return 0.5*(temp + np.roll(temp, -1))

# data
a = np.tile(np.arange(5,), 10)
b = modified_trapz(a)
\end{minted}
\end{frame}
\section{Interlude}
\label{sec:orgf62c108}
\begin{frame}[label={sec:orgd501969}]{Some questions about the project}
\begin{enumerate}
\item Position-verlet timestepping
\item Keeping track of nodal and elemental quantities
\item Implementing contact as a damped linear spring-mass force
\item Project 3 concepts
\item Implement code in logical steps
\item Make use of the resources given to you
\end{enumerate}
\end{frame}
\section{Differentiation}
\label{sec:orga735b6b}
\begin{frame}[label={sec:orgb3d0462}]{Derivatives}
\begin{itemize}
\item Frequently we need to take derivatives of functions (sampled at
unique points)
\item One simple yet effective approach is using \alert{finite-difference} formulae
\end{itemize}
\begin{block}{Linear combination}
\begin{itemize}
\item As differentiation (wrt to one independent variable) is a linear operator,
we once again perform a linear weighted combination of few function values
\[ \frac{d f(x)}{d x} \approx \sum_{i=1}^{n} \omega_i f(x_i) \]
\item We can then play games with \alert{nodes} (\(x_i\)) and \alert{weights} (\(\omega_i\))
\(\Rightarrow\) different finite difference formulae
\end{itemize}
\end{block}
\end{frame}
\begin{frame}[label={sec:org46b6cd0}]{Example}
An example illustrating the simplest FD formula (recall the timestepping lecture)
\begin{example}[First principles]
\[ f^{\prime}(x) = \lim_{h \to 0} \frac{f(x+h) - f(x) }{h}\]
Finite differences stop before the limit is reached (i.e. they have finite
\(h\) )
\end{example}
\end{frame}
\begin{frame}[label={sec:orga0c8d02}]{Considerations for differentiation schemes?}
While designing differentiation schemes, you are concerned about
\begin{itemize}
\item Cost (i.e. function evaluations)
\item Accuracy (truncation error, how convergent is your scheme)
\item Round-off errors
\item Both these relate to stability too\ldots{}
\end{itemize}

These issues are sometimes subtle (because of the nature of differentiation),
and so we need to be careful\ldots{}
\end{frame}
\begin{frame}[label={sec:orgc2a40e4}]{Schemes for first-order derivatives}
Using Taylor series expansion, you can obtain arbitrary-order derivatives
with arbitrary-order convergence. Some examples to approximate \(\frac{df(x)}{dx}\) are shown below ( \(\delta\) represents discrete
differences)
\begin{example}[Forward differences]
\[ \frac{\delta f(x)}{\delta x} = \frac{f(x+h) - f(x)}{h}\]
\end{example}
\begin{example}[Backward differences]
\[ \frac{\delta f(x)}{\delta x} = \frac{f(x) - f(x-h)}{h}\]
\end{example}
\begin{example}[Centered differences]
\[ \frac{\delta f(x)}{\delta x} = \frac{f(x+h) - f(x-h)}{2h}\]
\end{example}
\end{frame}

\begin{frame}[label={sec:orgfac93b7}]{Schemes for higher-order derivatives}
Examples for second order derivatives
\begin{example}[Forward differences]
\[ \frac{\delta^2 f(x)}{\delta x^2} = \frac{f(x)-2f(x+h)+f(x+2h)}{1h^{2}} \]
\end{example}
\begin{example}[Backward differences]
\[ \frac{\delta^2 f(x)}{\delta x^2} = \frac{f(x)-2f(x-h)+f(x-2h)}{1h^{2}} \]
\end{example}
\begin{example}[Centered differences]
\[ \frac{\delta^2 f(x)}{\delta x^2} = \frac{f(x+h)-2f(x)+f(x-h)}{1h^{2}} \]
\end{example}
\end{frame}
\begin{frame}[label={sec:org187632c}]{What do these do?}
\begin{block}{More schemes}
Take a look at \href{http://web.media.mit.edu/\~crtaylor/calculator.html}{MIT Finite Difference Calculator} (sympy also has this
capability) and build your own schemes!
\end{block}
\begin{block}{Local polynomial representations}
Finite differences assume your function is locally a polynomial (order
depending upon the order of the finite difference calculation) and takes
derivatives of these polynomials\ldots{}
\end{block}
\begin{columns}
\begin{column}{0.48\columnwidth}
\tikz[baseline=-2]{\draw[color=metropolisblue, thick] (0,0)--(1,0);}
\(\rightarrow\) Forward difference

\tikz[baseline=-2]{\draw[color=scarlet, thick] (0,0)--(1,0);}
\(\rightarrow\) Backward difference

\tikz[baseline=-2]{\draw[color=royalblue, thick] (0,0)--(1,0);}
\(\rightarrow\) Central difference
\end{column}
\begin{column}{0.5\columnwidth}
\begin{center}
	\begin{tikzpicture}[
	declare function={func(\x)=sin(deg(pi*\x));},
	declare function={funcder(\x)=pi*cos(deg(pi*\x));}]
	\begin{axis}%
		[grid=none,
		axis x line=bottom,
		axis y line=none,
		domain=1.45:1.57,
		xmin=1.47,
		xmax=1.56,
		ymax=-0.975,
		ymin=-1.005,
		ticks=none,
		height=1.0\textwidth,
		enlargelimits=false,
		clip=true,
		disabledatascaling
		]
		\addplot[smooth, very thick,
		color=metropolisorange]{func(x)} node[pos=0.1, above, anchor=south east]
		{{\scriptsize$f(x)$}};

		% Draw points
		\node (M) [circle, minimum size=5, inner sep=0, fill=metropolisorange]
		at (axis cs: 1.5, {func(1.5)}) {};
		\node (N) [circle, minimum size=5, inner sep=0, fill=metropolisorange]
		at (axis cs: 1.52, {func(1.52)}) {};
		\node (O) [circle, minimum size=5, inner sep=0, fill=metropolisorange]
		at (axis cs: 1.55, {func(1.55)}) {};

		% % Add trapezoid betewen 1.53 and 1.61 by first defining coordinates
		% % https://tex.stackexchange.com/a/324328
		% \path (M) + (axis cs: 0.0, \pgfkeysvalueof{/pgfplots/ymin}) coordinate (Mx);
		% \path (N) + (axis cs: 0.0, \pgfkeysvalueof{/pgfplots/ymin}) coordinate (Nx);

		% Add trapezoid betewen 1.53 and 1.61 by first defining coordinates
		% https://tex.stackexchange.com/a/324328
		\coordinate (Mx) at (axis cs: 1.5,\pgfkeysvalueof{/pgfplots/ymin});
		\coordinate (Nx) at (axis cs: 1.52,\pgfkeysvalueof{/pgfplots/ymin});
		\coordinate (Ox) at (axis cs: 1.55,\pgfkeysvalueof{/pgfplots/ymin});

		% Draw derivatve from yn to yn+1 first
		% 0.44 to 0.48
		\draw[color=metropolisblue, thick] (M) -- (N);
		\draw[color=scarlet, thick] (N) -- (O);
		\draw[color=royalblue, thick] (O) -- (M);

		% node[pos=0, below right, anchor=west]{{\scriptsize $y^n$}}
		% node[below right, anchor=north west]{{\scriptsize $y^{n+1}$}}
		% node[right, anchor=south west]{Estd.};

		% % Draw actual derivatve line
		% \addplot[color=royalblue, thick] coordinates
		% { (0.44, {func(0.46) - 0.02*funcder(0.46) }) (0.48,
		% {func(0.46) + 0.02*funcder(0.46)}) } node[above]{Actual};

		% Draw connections to ground now
		\draw[dashed] (M) -- (Mx) node [above left, anchor=south east]
		{{\scriptsize$x-h$}};
		\draw[dashed] (N) -- (Nx) node [above left, anchor=south east]
		{{\scriptsize$x$}};
		\draw[dashed] (O) -- (Ox) node [above left, anchor=south east]
		{{\scriptsize$x+h$}};

	\end{axis}
	\end{tikzpicture}
\end{center}
\end{column}
\end{columns}
\end{frame}
\begin{frame}[label={sec:org3732981}]{How do these perform (accuracy) ?}
\alert{DEMO} using calculation of \(\frac{df}{dx}\)
\begin{itemize}
\item Order of accuracy depends upon the Taylor series representation (\alert{Taylor
theorem})
\item For the same function evaluations i.e. if \(n\) is the number of points
considered in our algorithm
\begin{itemize}
\item Quadrature is accurate to \(\order{h^{n+1}}\)
\item Differentation is accurate to \(\order{h^{n-1}}\)
\end{itemize}
\item Centered difference algorithms usually have a bump in order of accuracy,
for the same width of stencil
\item Lots of freedom to design own schemes\ldots{}
\end{itemize}
\end{frame}
\begin{frame}[label={sec:org6ba2d30}]{Round-off errors}
\begin{block}{Why discuss round-off errors?}
\begin{itemize}
\item Round-off errors : errors in precisely representing numbers on a computer
\item Finite precision effects were not important in quadrature, but are in
differentation.
\item \alert{Why}? Numerical differentation is susceptible to:
\begin{itemize}
\item Noise amplification
\item Cancellation errors (due to signs)
\item And as we saw last slide, is less accurate than quadrature
\end{itemize}
\end{itemize}
\end{block}
\begin{block}{Effect of round-off}
\begin{itemize}
\item If \(\epsilon\) is machine precision \(2^{-52} \approx 10^{-16}\) in
double precision we can show
\end{itemize}
\[\frac{\delta f(x)}{\delta x} = \frac{f(x+h) - f(x)}{h} \approx
	f^{\prime}(x)  + \frac{h}{2}f^{\prime\prime}(x) + \frac{\epsilon \cdot
	f}{h} + \order{h^2} \]
\end{block}
\end{frame}
\begin{frame}[label={sec:orgb90f548}]{Caution!!!}
In an ideal world, we should not be taking derivatives of functions
numerically:
\begin{itemize}
\item Differentation is \emph{unbounded}:
A function with small \(\norm{f}_{\infty}\) can have arbitrarily large \(\norm{f^{\prime}}_{\infty}\) \alert{DEMO}
\item Differentiation amplifies noise:
Smooth function with small, high-frequency wiggles (common in experiments
and under-resolved simulations) can explode \alert{DEMO}
\item Numerical differentiation : subject to cancellation and round-off errors \alert{DEMO}
\end{itemize}
\end{frame}
\begin{frame}[label={sec:orgcfd4678}]{Soft mechanics framework}
Many spatial differentiations. More explicitly,

\[ \spot<2>{\begin{aligned}
   m_i \cdot \frac{\partial \mathbf{v}_i}{\partial t} &= \Delta^h
   \left(\frac{\mathbf{Q}_i^T\hat{\mathbf{S}}_i\boldsymbol{\sigma}^i_{\mathcal{L}}}{e_i}\right)
   +\mathbf{F}_i,\quad i=[1,n+1]
   \end{aligned}} \]
\[ \spot<3>{\begin{aligned}\frac{\hat{\mathbf{J}}_i}{e_i} \cdot \frac{\partial
	\boldsymbol{\omega}^i_{\mathcal{L}}}{\partial t} &=
	\Delta^h\left(\frac{\hat{\boldsymbol{\mathcal{B}}}_i\hat{\boldsymbol{\kappa}}_{\mathcal{L}}^{i}}{\mathcal{E}_i^3}\right) +
	\mathcal{A}^h\left(\frac{\hat{\boldsymbol{\kappa}}_{\mathcal{L}}^i\times\hat{\boldsymbol{\mathcal{B}}}_i
	\hat{\boldsymbol{\kappa}}_{\mathcal{L}}^i}{\mathcal{E}_i^3}
	\hat{\mathcal{D}}_i\right) + \left(\mathbf{Q}_i\mathbf{t}_i\times\hat{\mathbf{S}}_i\boldsymbol{\sigma}^i_{\mathcal{L}}\right)\hat{\ell}_i\\
	&+ \mathbf{C}^i_{\mathcal{L}},\quad i=[1,n] \end{aligned}}\]
\begin{block}<3->{\(\Delta^{h}\) using finite differences}
\end{block}
\end{frame}

\begin{frame}[label={sec:org7ae2b5a}]{The \(\Delta^{h}\) operator}
Define the \(\Delta^{h}\) operator as:
\[\mathbf{y}_{j=1, \ldots, N+1}=\Delta^{h}\left(\mathbf{x}_{i=1, \ldots,
   N}\right)=\left\{\begin{array}{ll}{\mathbf{x}_{1}} & {\text { if } j=1}
   \\ {\mathbf{x}_{j}-\mathbf{x}_{j-1}} & {\text { if } 1<j \leq N}
   \\ {-\mathbf{x}_{N}} & {\text { if } j=N+1}\end{array}\right. \]
\end{frame}
\begin{frame}[label={sec:org306f19e},fragile]{The \(\Delta^{h}\) operator}
 Implementation using \texttt{numpy}
\begin{minted}[,fontsize=\scriptsize]{python}
import numpy as np

# Modified trapezoidal integration
def modified_diff(t_x):
    """ Modified trapezoidal integration"""
    # Pads a 0 at the end of an array
    temp = np.pad(t_x, (0,1), 'constant', constant_values=(0,0))
    # Using roll calculate the diff (ghost node of 0)
    return (temp - np.roll(temp, 1))

# data
a = np.tile(np.arange(5,), 10)
b = modified_diff(a)
\end{minted}
\end{frame}
\begin{frame}[label={sec:orga6798ae}]{Credits}
\begin{block}{A good chunk of the material in these slides are taken from Prof. Andreas Kloeckner's CS450 lectures and Prof. Paul Fischer's TAM470 lectures}
\end{block}
\end{frame}
\end{document}


\documentclass{notes}

\title{Geometrical considerations for the SPI module}
\author{Mathias Hoppe and Oskar Vallhagen}

\begin{document}
    \maketitle

    \noindent
    In this document we consider the geometry used to track pellet shards in the
    SPI module of \DREAM, and how that geometry relates to the magnetic field
    geometry used elsewhere in \DREAM.

    The SPI module uses a cartesian coordinate system with origin on the
    magnetic axis. The coordinate system is oriented such that the $z$ direction
    is parallel to the toroidal direction in $x=y=0$, as illustrated in
    figure~\ref{fig:geom}.

    \begin{figure}
        \centering
        \includegraphics[width=0.5\textwidth]{figs/SPIgeom.pdf}
        \caption{
            Illustration of the coordinate system used for the SPI module in
            \DREAM.
        }
        \label{fig:geom}
    \end{figure}

    \section{Coordinate transformations}
    In the SPI module, it is necessary to map the cartesian coordinates
    $(x,y,z)$ of the points in space to the corresponding flux surface label
    $r$. In the toroidal case, this requires a two-step procedure where the
    cartesian coordinates $(x,y,z)$ are first transformed to their corresponding
    cylindrical $(R,Z,\varphi)$ or toroidal coordinates $(\rho,\theta,\varphi)$.
    In the second step, the cylindrical or toroidal coordinates must then be
    inverted to obtain the flux surface label $r$, and this generally requires
    numerical root-finding.

    \subsection{Cylindrical coordinates}
    The transformation to cylindrical coordinates is straightforward: since
    $x$ and $z$ lie in the horizontal plane, while $y$ is always vertical, the
    major radius and vertical position $Z$ is given by
    \begin{subequations}
        \begin{align}
        R &= \sqrt{(x+R_0)^2 + z^2},\\
        Z &= y.
        \end{align}
    \end{subequations}

    \subsection{Toroidal coordinates}
    To obtain the toroidal coordinates $\rho$ and $\theta$, we first introduce
    the position vector $\vec{r} = (x+R_0,y,z)$, defined to originate in $y=0$
    on the axis of symmetry of the tokamak (the red dot in
    figure~\ref{fig:geom}). We then introduce the unit vector
    \begin{equation}
        \hat{r} = \frac{\left(\vec{r}\cdot\hat{x}\right)\hat{x} + \left(\vec{r}\cdot\hat{z}\right)\hat{z}}
        {\sqrt{\left(\vec{r}\cdot\hat{x}\right)^2 + \left(\vec{r}\cdot\hat{z}\right)^2}} =
        %
        \frac{(x+R_0)\hat{x} + z\hat{z}}{\sqrt{(x+R_0)^2+z^2}},
    \end{equation}
    which is the normalized projection of the position vector $\vec{r}$ to the
    horizontal plane. With these vectors, we can then obtain the minor radius
    vector $\vec{\rho}$ as
    \begin{equation}
        \vec{\rho} = \vec{r}-R_0\hat{r} =
        \left(x+R_0-\frac{(x+R_0)R_0}{\sqrt{\left(x+R_0\right)^2 + z^2}}\right)\hat{x}
        + y\hat{y}
        + \left(z-\frac{zR_0}{\sqrt{\left(x+R_0\right)^2 + z^2}}\right)\hat{z},
    \end{equation}
    and the magnitude of this vector is
    \begin{equation}
        \rho = \sqrt{
            \left(x+R_0-\frac{(x+R_0)R_0}{\sqrt{\left(x+R_0\right)^2 + z^2}}\right)^2
            + y^2
            + \left(z-\frac{zR_0}{\sqrt{\left(x+R_0\right)^2 + z^2}}\right)^2
        }.
    \end{equation}
    Knowing the minor radius $\rho$ corresponding to $(x,y,z)$ will get us only
    part of the way to determining the flux surface radius $r$. To fully
    determine it, we also need to know the poloidal angle $\theta$ of the
    cartesian coordinates. In numerical geometry, this is easy to obtain from
    the minor radius vector $\vec{\rho}$. By the definition of the poloidal
    angle $\theta$ in numerical toroidal geometry, we have
    \begin{equation}
        \tan\theta = \frac{\left(\vec{\rho}\cdot\hat{y}\right)\mathrm{sgn}\left(R-R_0\right)}
            {\sqrt{\left(\vec{\rho}\cdot\hat{x}\right)^2 + \left(\vec{\rho}\cdot\hat{z}\right)^2}}
        %
        = \frac{y\,\mathrm{sgn}\left(R-R_0\right)}{\sqrt{
            \left(x+R_0-\frac{(x+R_0)R_0}{\sqrt{\left(x+R_0\right)^2 + z^2}}\right)^2
            + \left(z-\frac{zR_0}{\sqrt{\left(x+R_0\right)^2 + z^2}}\right)^2
        }},
    \end{equation}
    with
    \begin{equation}
        R = \sqrt{(x+R_0)^2+z^2}.
    \end{equation}
    The sign function appears since
    $\sqrt{(\vec{\rho}\cdot\hat{x})^2 + (\vec{\rho}\cdot\hat{z})^2}$
    should correspond to the horizontal cartesian coordinate in the poloidal
    plane (which is negative in the second and third quadrants).

    \section{Cylindrical coordinates to analytic B}
    The conversion from cartesian coordinates to flux surface coordinates in the analytical B-field geometry in DREAM is most easily done via a transformation to cylindrical coordinates. The reason for this is that the poloidal angle $\theta$ does not have a simple geometrical definition in this context.

    The flux surface geometry in the analytic B mode is related to the cylindrical coordinates according to
    \begin{align}
R &= R_0 + \Delta(r) + r\cos[\theta +\delta(r) \sin\theta], \nonumber \\
Z &= r \kappa(r) \sin\theta,
\label{eq:analyticB system}
\end{align}
where $\kappa$ is the elongation, $\Delta$ the Shafranov shift and $\delta$ a triangularity parameter. We solve this equation system by eliminating the $\theta$-dependence from the equation for $R$ using the equation for $Z$, and in that way obtain an equation for $r$ alone which is straightforward to solve numerically. First, we rewrite the equation for $R$ in terms of $\cos{\theta}$ and $\sin{\theta}$ rather than $\theta$ itself:
	\begin{equation}
		R = R_0 + \Delta (r) + r[\cos{\theta}\cos{(\delta(r)\sin{\theta})} - \sin{\theta}\sin{(\delta(r)\sin{\theta})}].
		\label{eq:RAnalyticB}
	\end{equation}
	From the equation for $Z$, we have
	\begin{align}
		\sin{\theta} &= \frac{Z}{r\kappa(r)}\nonumber \\
		\cos{\theta} &= \pm \sqrt{1-\left(\frac{Z}{r\kappa(r)}\right)^2}.
		\label{eq:SinCosAnalyticB}
	\end{align}
	It remains now to determine the sign on $\cos{\theta}$. We do this by calculating the major radius $R_\mathrm{crit}$ where $\cos{\theta}=0$. As the major radius is a monotonically increasing function of $\cos{\theta}$ {\color{red}(which holds as long as $\delta < 1$, but this might be necessary to not violate other assumptions, such as monotonically varying B-fields between the two extreme points on a flux surface?)}, if $R>R_\mathrm{crit}$, $\cos{\theta}>0$, and vice versa. The critical major radius is calculated by noting that when $\cos{\theta}=0$, we have $\sin{\theta}=1$, so that
	\begin{equation}
		R_\mathrm{crit} = R_0 + \Delta(r_\mathrm{min}) - r_\mathrm{min}\sin{(\delta(r_\mathrm{min}))},
	\end{equation}
	where $r_\mathrm{min}$ is calculated (numerically) from
	\begin{equation}
		Z = r_\mathrm{min}\kappa(r_\mathrm{min}).
	\end{equation}
	With the sign of $\cos{\theta}$ known, we can finally obtain an equation with $r$ as the only unknown by inserting equation \eqref{eq:SinCosAnalyticB} into equation \eqref{eq:RAnalyticB}. As the derivative of this equation with respect to $r$ diverges at $r=r_\mathrm{min}$, it is probably best to solve this equation using a bisection method rather than a Newton method.

\section{Minimum $r$ along a shard path}
To evaluate the time averaged delta function source, it is necessary to know the value of the smallest $r$ along the shard paths \footnote{More details about the delta function source can be found in appendix A of O. Vallhagen's master's thesis or in \texttt{doc/notes/SPIDeltaSource.pdf}}. The reason for this is that the flux surface label $\rho _\mathrm{p}$ \footnote{Not to be confused with the minor radius denoted $\rho$ without subscript. We use this notation here to be consistent with O. Vallhagen's master's thesis} of a shard varies non-monotonically during the time step where it passes its minimum value $\rho _\mathrm{p,closest}$ (which is technically only closest to the magnetic axis when the cross section has a circular shape). This means that the kernel can not simply be described by a box-like function bounded by the values of $r$ at the beginning and the end of the timestep. Instead, this timestep is divided in two parts, before and after the passing of $\rho _\mathrm{p,closest}$.

To see if $\rho _\mathrm{p,closest}$ has been passed during the current time step, we check whether the projection of the shard trajectory on the gradient of the radial coordinate has changed sign, i.e.~if
\begin{equation}
	[\mathbf{x}_\mathrm{p}(t)\cdot \nabla r(\mathbf{x}_\mathrm{p}(t))] \cdot [\mathbf{x}_\mathrm{p}(t+\Delta t)\cdot \nabla r(\mathbf{x}_\mathrm{p}(t+\Delta t))]<0,
\end{equation}
where $\mathbf{x}_\mathrm{p}(t)$ is the cartesian position vector of the shard. If this condition is satisfied, we proceed by finding $\rho _\mathrm{p,closest}$ by first parameterising the line between $\mathbf{x}_\mathrm{p}(t)$ and $\mathbf{x}_\mathrm{p}(t+\Delta t)$ with a parameter $\tau$ ($0<\tau<1$) as
\begin{equation}
	\bar{\mathbf{x}}_\mathrm{p}(\tau) = \mathbf{x}_\mathrm{p}(t) + \tau [\mathbf{x}_\mathrm{p}(t+\Delta t) - \mathbf{x}_\mathrm{p}(t)].
\end{equation}
We can then find $\rho _\mathrm{p,closest}$ by solving
\begin{equation}
	\frac{\partial \rho _\mathrm{p}(\bar{\mathbf{x}}_\mathrm{p}(\tau))}{\partial \tau} = \nabla \rho _\mathrm{p} \cdot [\mathbf{x}_\mathrm{p}(t+\Delta t) - \mathbf{x}_\mathrm{p}(t)].
\end{equation}
Thus, if we can evaluate $\nabla \rho _\mathrm{p}$, we have an equation with $\tau$ as the only unknown, which is straight forward to solve with e.g. a bisection scheme.

\subsection{$\nabla r$ with analytic B geometry}
The easiest way to evaluate $\nabla \rho _\mathrm{p}$ in analytic B geometry is to convert $\bar{\mathbf{x}}_\mathrm{p}(\tau)$ to flux surface coordinates (with the functionality implemented according to the above sections in this document), and then express $\nabla \rho _\mathrm{p}$ in terms of the flux surface coordinates. With analytic B geometry, according to \texttt{doc/notes/theory.pdf}, this can be done as (here with $r=\rho _\mathrm{p}$)
\begin{align}
\nabla r &= \frac{\frac{\partial z}{\partial \theta} (\cos{\varphi}\hat{x} + \sin{\varphi}\hat{y}) - \frac{\partial R}{\partial \theta} \hat{z}}{\frac{\partial R}{\partial r}\frac{\partial z}{\partial \theta} - \frac{\partial R}{\partial \theta}\frac{\partial z}{\partial r}},
\end{align}
where
\begin{align}
\frac{\partial R}{\partial r} &= \Delta' + \cos[\theta+\delta\sin\theta]-r\delta'\sin\theta\sin[\theta+\delta\sin\theta], \nonumber \\
\frac{\partial R}{\partial \theta} &= -r(1+\delta\cos\theta)\sin[\theta+\delta\sin\theta],  \nonumber \\
\frac{\partial z}{\partial r} &=  \kappa\left(1+ \frac{r\kappa'}{\kappa}\right)\sin\theta, \nonumber \\
\frac{\partial z}{\partial \theta} &= r\kappa\cos\theta.
\end{align}

\end{document}


% \documentclass[a4paper]{article}
\documentclass[letterpaper,twocolumn]{IEEEtran}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathenv}
\usepackage{multirow}
\usepackage{breqn}
\usepackage{rotating}

\DeclareMathAlphabet{\itbf}{OML}{cmm}{b}{it}

% numérotation au sein de chaque section (du style "2.1")
% \numberwithin{equation}{section}

% commandes perso
\newcommand{\R}{\mathbb{R}}
\newcommand{\ie}{i.e.}
\newcommand{\RnX}{\mathbb{R}_n[X]}
\newcommand{\N}{\mathbb{N}}
\newcommand{\C}{\mathcal{C}}
\newcommand{\Ccinf}{\mathcal{C}_c^{\infty}}
\newcommand{\Cinf}{\mathcal{C}^{\infty}}
\newcommand{\supp}{\textrm{supp}}
\newcommand{\bx}{\mathbf{x}}
\newcommand{\bv}{\mathbf{v}}
\newcommand{\Mbv}{M_{\mathbf{v}}}
\newcommand{\Tbv}{\mathcal{F}_{\mathbf{v}}}
\newcommand{\mubv}{\mu_{\mathbf{v}}}
\newcommand{\sbv}{s_{\mathbf{v}}}
\newcommand{\Bnv}{B_n^{(\bv)}}
\newcommand{\Wnv}{W_n^{(\bv)}}

\newtheorem{definition}{Definition}
\newtheorem{lemma}{Lemma}
\newtheorem{theorem}{Theorem}

\title{Consistency of Fan-beam Projections of a Translating Object Along an Arc of a Circle}
%\author{}
\date{}

\begin{document}

%==================
\author{
	\IEEEauthorblockN{Thomas Boulier, Rolf Clackdoyle, Jérôme Lesaint, Laurent Desbat}
	\thanks{T. Boulier, R. Clackdoyle, J. Lesaint and L. Desbat are with the TIMC-IMAG laboratory, CNRS UMR 5525 and Universit\'e Grenoble Alpes (e-mail: thomas.boulier@polytechnique.edu).

	The authors would like to thank Simon Rit for his help using RTK.

	This work is partially supported by the Agence Nationale de la Recherche (France), project ``DROITE'', number ANR-12-BS01-0018, and FUI project "3D4Carm".
}
\IEEEauthorblockA{}
}

\maketitle
%========================

\begin{abstract}
In this article, we compute data consistency conditions (DCCs) in fan-beam geometry for the case of a translating object irradiated by an x-ray source moving along a short arc of a circle. The DCCs are thus a generalization of those computed in~\cite{clackdoyle2015consistency}, where the object remained still. In a second part, we use the DCCs in order to retrieve parameters of the object velocity. These results are illustrated by numerical examples.
\end{abstract}

\section{Introduction}

In the field of CT-imaging, data consistency conditions (DCCs) use the redundancy of the data in order to establish relations that must be fulfilled  between projections. These conditions are called \emph{full} when they are not only necessary but also sufficient. One of the best known DCCs are the Helgason-Ludwig (H-L) conditions~\cite{helgason1980radon,ludwig1966radon}, which are full for parallel projections. Full DCCs are also known for the case of fan-beam projections with source position taken along a straight line~\cite{clackdoyle2013necessary}.

In~\cite{clackdoyle2015consistency}, the fan-beam DCCs were modified to handle the case of a source moving along an arc of a circle. Briefly, all rays passing through the same point along a "virtual" source line between the two extreme positions of the source are gathered to form a virtual fan-beam projection. The DCCs for fan-beam projections along a line from~\cite{clackdoyle2013necessary} could then be applied; numerical examples showed a situation where an artificial detector attenuation was added, and the DCCs were invoked to recover the unknown attenuation coefficient. The case of a moving object has been tackled in~\cite{yu2007data}, where the authors used parallel-beam H-L conditions for the case of an object undergoing rigid body motion while irradiated by a fan-beam source along a circular trajectory. Those conditions allowed the authors to recover the parameters of the the movement. The parameters were subsequently incorporated into the reconstruction procedure, in order to suppress the artifacts caused by such movement.  However, using the parallel-beam H-L conditions means that the fan-beam projections had to cover all rays in the plane so that a fan-to-parallel rebinning could be achieved. The rebinning was achieved mathematically; however, the requirement of at least a standard fan-beam shortscan of $180^{\circ}$ plus fan-angle was required. In our work, we are concerned with the opposite extreme of a short arc of fan-beam measurements.

In this article, we will suppose that an object is translating while illuminated by a fan-beam source which is moving along an arc of a circle. With an adapted reference frame, we will use as in~\cite{clackdoyle2015consistency} a change of variables. Then, in a second part, we will show how the DCCs can be used in order to identify the translation velocity.

\section{Theory}
\label{sec:theory}

\subsection{Problem under consideration}
\label{sub:problem_under_consideration}

Let us begin with some notation and definitions. We will consider an object in $\R^2$ to be imaged in a fan-beam geometry with sources on an arc of circle with center $O$ and radius $R_0$ (see Figure~\ref{fig:notations}, top). The object is identified with its density function $\mathbf{x} \mapsto \mu(\mathbf{x}) \in \Ccinf(\R^2)$.
\begin{figure}[!ht]
	\centering
	\begin{tabular}{c}
	\includegraphics[width=70mm]{figs/frame_scanner_still.eps} \\
	\includegraphics[width=70mm]{figs/frame_scanner.eps}
	\end{tabular}
	\caption{Problem under consideration. The source point $s(t)$ follows the arc of circle depicted in bold. The circle has center $O$ and radius $R_0$. The object is continually undergoing a translation during the movement of the source.\label{fig:notations}}
\end{figure}
The angular velocity of the source will be denoted $\omega$, and the time $t$ will range from $-T/2$ to $T/2$, where $T>0$. Hence, if we use $s(t)$ to denote the position of the source at time $t$, we have
\begin{equation}
	s(t) = \left( -R_0 \sin(\omega t), R_0 \cos(\omega t) \right).
\label{eq:source_position}
\end{equation}
Furthermore, we will let $s(T/2)=(x_l,y_l)$ (resp. $s(-T/2)=(x_r,y_r)$) denote the extreme left (resp. right) position of the source. Since $y_l = y_r = R_0 \cos(\omega T/2)$, we will call the common value $y_0$. In the following, we will assume that $\supp(\mu)$ lies in the half-space $\{ y < y_0 \}$, and that $y_0 > 0$ (\ie $0 < \omega T < \pi$, the total arc length is less than $\pi$).

We will suppose that at any time $t$, rays are simultaneously emitted from the source $s(t)$ with each ray at angle $\phi$ ranging from $-\pi/2$ to $\pi/2$. With this setup in mind, we can define the operator modeling the acquired data from the object.
\begin{definition}
The \emph{fan-beam projection data} of an object with density function $\mu$ is a function $(t,\phi) \mapsto \mathcal{F}\mu(t,\phi)$ defined by
\begin{equation}
	(\mathcal{F}\mu)(t,\phi) = \int_0^{+\infty} \mu \left( s(t) + l \left[ \sin \phi, -\cos \phi \right] \right) dl,
\end{equation}
where $t \in \left[ -T/2, T/2\right]$, $\phi \in \left[ -\pi/2, \pi/2\right]$ and $s(t)$ is given by~(\ref{eq:source_position}). The operator $\mu \mapsto \mathcal{F}\mu$ is called the \emph{fan-beam projection operator}.
\end{definition}

Now let us suppose that the object is translating along a straight line with a constant velocity vector $\bv = (v_1, v_2)\in \R^2$ (see Figure~\ref{fig:notations}, bottom). In other words, if we let $\Mbv(t)$ denote its center of mass at any time $t$, we have
\begin{equation}
	\Mbv(t) =   \Mbv(0) + \left( t + T/2 \right) \bv
\label{eq:center_of_mass}
\end{equation}
The density function of the object now depends on both the spatial variable $\bx \in \R^2$ and the time $t$. If we denote the time-varying object by $\mubv$, we have
\begin{equation}
	\mubv(t,\bx) = \mu\left( \bx - \Mbv(t)\right).
\end{equation}
In this regard, the fan-beam projection data will be modified in the following way.
\begin{definition}
The \emph{fan-beam projection data of a translating object} with density function $\mu$ and  velocity vector $\bv$ is given by
\begin{equation}
	(\Tbv\mu)(t,\phi) =  ( \mathcal{F} \mubv ) (t,\phi).
\label{eq:def_Tv}
\end{equation}
\end{definition}

The aim of this note is to derive data consistency conditions (DCCs) from~(\ref{eq:def_Tv}), in order to retrieve the velocity vector $\bv$ from the knowledge of a single element of the range of $\Tbv$.

\subsection{Derivation of DCCs}

In order to derive DCCs, we will first change our reference frame, from $\left(O, x, y\right)$ to $\left(M(t), x', y'\right)$, so that the origin is the center of mass of the object at any time $t$, and the line between the start point and the end point of the source is still parallel to the $x'$-axis (see Figure~\ref{fig:change_frame}). In other words, we are performing the following change of variables
\begin{equation}
	(x,y) \leftrightarrow (x',y') = \mathcal{R}_{\beta} \left( (x,y)-\Mbv(t) \right),
\end{equation}
where $\mathcal{R}_{\beta}$ rotation by $\beta$. Note that the translation depends on $t$, but a single global rotation is applied. The angle $\beta$ is depicted in Figure~\ref{fig:change_frame} (top) and is given by
\begin{equation}
	\beta = \arctan \left( \frac{T v_2}{2R_0 \sin(\omega T/2) + T v_1} \right).
\end{equation}
Note that in this equation, the denominator can be equal to zero. This situation can occur in particular cases when $v_1 < 0$. We have studied those particular cases, both in terms of physical meaning and numerical implications. For the sake of simplicity, we will assume that $v_1$ is not too negative (e.g. $v_1 > - 2 R_0 / T$) to ensure that the denominator is non-zero.

\begin{figure}[!ht]
	\centering
	%\includegraphics[width=12cm]{figs/frame_object.eps}
	\begin{tabular}{c}
	\includegraphics[width=80mm]{figs/frame_object_before_rotation.eps} \\
	\includegraphics[width=80mm]{figs/frame_object.eps}
	\end{tabular}
	\caption{Change of reference frame: the object is now at center of the coordinate system. Top: only translation of the center of frame; bottom: after rotation of angle $\beta$. The virtual source position $(x',y_0')$ is defined in terms of $\sbv(t)$ and $\phi$; see equation~(\ref{eq:x'}).\label{fig:change_frame}}
\end{figure}

In this new reference frame, the coordinates of the source position are given by $\sbv(t)=\mathcal{R}_{\beta} \left( s(t)-\Mbv(t) \right)$. With this in mind, the data are given by the following formula
\begin{multline}
	(\Tbv\mu)(t,\phi) = \\
	\int_0^{+\infty} \mu \circ \mathcal{R}_{-\beta} \left( s_{\bv}(t) + l \left[ \sin (\phi + \beta), -\cos (\phi + \beta) \right] \right) dl,
\label{eq:F_from_sv}
\end{multline}

In other words, we are now dealing with a fixed object whose density function is given by $\mu \circ \mathcal{R}_{-\beta}$ irradiated by a source following an arc of a cycloid in the frame $\left(M(t), x', y'\right)$ (see Figure~\ref{fig:change_frame}, bottom).

Here, the extreme points $\sbv(-T/2)$ and $\sbv(T/2)$ have the same $y'$-coordinate, $y'_0$. We will call $x'_l$ (resp. $x'_r$) the $x'$-coordinates of $\sbv(T/2)$ (resp. $\sbv(-T/2)$).

Now we define what we call the \emph{virtual fan-beam projection} from a point $(x',y'_0)$.
\begin{definition}
	For any point $x'$ between $x'_l$ and $x'_r$, and for any angle $\phi \in \left[ -\pi/2, \pi/2\right]$, the \emph{virtual fan-beam projection} of the object $\mu$ is defined by
\begin{multline}
	\left( \tilde{\mathcal{F}} \mu	\right)(x',\phi') = \\
	\int_0^{+\infty} \mu \circ \mathcal{R}_{-\beta} \left( (x',y'_0) + l \left[ \sin \phi', -\cos \phi' \right] \right) dl.
\label{eq:def_Ftilde}
\end{multline}
This is called \emph{virtual} since it does not correspond to an actual position of the source.
\end{definition}

In the following lemma, we will make the connection between the virtual fan-beam projection and the fan-beam projection of the translating object.
\begin{lemma}
	Let us fix a time $t \in \left[ -T/2, T/2\right]$ and an angle $\phi \in \left[ -\pi/2, \pi/2\right]$. Let us define
	\begin{equation}
		x' = s_{1,\bv}(t) + \tan \phi \left( s_{2,\bv}(t) - y'_0 \right),
		\label{eq:x'}
	\end{equation}
	where, for any time $t$, $\left( s_{1,\bv}(t), s_{2,\bv}(t) \right)$ are the coordinates of $\sbv(t)$.
	Then, we have $\left( \tilde{\mathcal{F}} \left( \mu \circ \mathcal{R}_{-\beta} \right) \right)(x',\phi + \beta) = \left( \Tbv \mu \right)(t,\phi)$.
\label{lem:T_x_t}
\end{lemma}
The idea behind the proof of lemma~\ref{lem:T_x_t} is to note that between $x'$ and $\sbv(t)$, the integral of $\mu$ is equal to zero since the support is assumed to remain in the half-space $\left\{ y<y_0 \right\}$. Hence, instead of starting the integration from $x'$ in~(\ref{eq:def_Ftilde}), we can start from $\sbv(t)$, which will give us~(\ref{eq:F_from_sv}).

We can now define the DCCs for our problem.
\begin{theorem}
\label{theo:main}
Let us fix a density function $\mu$. For any integer $n$, there exists a function $(t,x')\mapsto \Wnv(t,x')$ such that the function $\Bnv$ defined by
\begin{equation}
	\Bnv(x') = \int_{-T/2}^{T/2} \left( \Tbv \mu \right)\left( t,\lambda^{(\bv)}(t,x') \right) \Wnv(t,x') dt,
\label{eq:DCC}
\end{equation}
is a polynomial of degree $n$. In the formula above, the angle $\lambda^{(\bv)}(t,x')$ is defined by
\begin{equation}
	\lambda^{(\bv)}(t,x') = \arctan \left( F^{(\bv)}(t,x') \right),
\label{eq:def_lambda}
\end{equation}
where $F^{(\bv)}(t,x')$ is defined as the fraction $A/B$ with
\begin{dmath}
	A = x' + \cos \beta \left( R_0 \sin(\omega t) + \left( t + T/2 \right)v_1 \right) + \\
	\sin \beta \left( R_0 \cos(\omega t) - \left( t + T/2 \right)v_2 \right)
\end{dmath}
and
\begin{dmath}
	B = \cos \beta \left( R_0 \cos(\omega t) - \left( t + T/2 \right)v_2 \right) - \sin \beta \left( R_0 \sin(\omega t) + \left( t + T/2 \right)v_1 \right) - y'_0
\end{dmath}
Moreover, it is possible to derive $\Wnv(t,x')$ analytically using the following formula
\begin{multline}
	\Wnv(t,x') = \\
	\tan^n \left( \lambda^{(\bv)}(t,x') \right) \cos \left( \lambda^{(\bv)}(t,x') \right) \frac{\partial \lambda^{(\bv)}}{\partial t} (t,x')
\end{multline}
\end{theorem}

We only have room here for an outline of the proof. The idea is to change variables in the following formula, which is known from~\cite{clackdoyle2013necessary} to be a polynomial in $x'$
\begin{equation}
	\int_{\pi/2}^{-\pi/2} \tilde{\mathcal{F}}\mu (x',\phi) \frac{\tan^n \phi}{\cos \phi} d\phi.
\label{eq:DCC_rolf}
\end{equation}
The change of variable occurs between $\phi$ in~(\ref{eq:DCC_rolf}) and $t$ in~(\ref{eq:DCC}) by using the definition in~(\ref{eq:def_lambda}).

Although the formula for $\Wnv(t,x')$ is complicated, we observe that in the case $v_1=v_2=0$, we obtain the formula (7) in~\cite{clackdoyle2015consistency} since
\begin{equation}
	F^{\left( (0,0)\right) }(t,x')= \frac{x' + R_0 \sin(\omega t)}{R_0 \cos(\omega t)}
\end{equation}

\section{Numerical simulations}

\subsection{Principles}
\label{sub:principles}
Let us suppose that we have the projections $\left( \Tbv \mu \right)(t,\phi)$. Moreover, we suppose that $T$ is known and that the velocity $\bv$ is constant (although unknown) during the interval $[-T/2, T/2]$. In order to recover $\bv$, we can perform the following optimization procedure. Since $\Bnv(x')$ in equation~(\ref{eq:DCC}) is supposed to be a polynomial of degree less than or equal to $n$, we can minimize
\begin{equation}
	\mathcal{J}(v) = \Vert \left( \textrm{res} \Bnv \right) \Vert^2
\label{eq:Jv}
\end{equation}
with respect to $\bv$, where $\textrm{res}$ is the residual of the projection onto the space of polynomials of degree $n$ or less, and $n$ is the polynomial degree to be taken into account. This procedure will give us the velocity $\bv$ using only the knowledge of the data $\left( \Tbv \mu \right)(t,\phi)$.

\subsection{Application}
\label{sub:application}

The object under consideration is an ellipse of uniform density, whose axis lengths are $30$ and $15$ millimeters respectively, and making an angle of $45^{\circ}$ with respect to the $x$-axis. The source is rotating around the object with radius $R_0 = 600 \, \textrm{mm}$, with angular velocity $\omega = 1 \, \textrm{rad} \cdot \textrm{s}^{-1}$. The detector is a plane situated at a distance of $600 \, \textrm{mm}$ from the origin. The computations of the forward problem were performed using \verb+simpleRTK+, a Python wrapping of \verb+RTK+~\cite{RTK}.

With the simulated velocity of the ellipse given by $v_1 = 0.3 \, \textrm{mm} \cdot \textrm{s}^{-1}$, and $v_2 = 0 \, \textrm{mm} \cdot \textrm{s}^{-1}$ we obtain the sinogram depicted in Figure~\ref{fig:sinogram}.
\begin{figure}[!ht]
	\centering
	\includegraphics[width=70mm]{figs/sinogram.png}
	\caption{Sinogram of a moving ellipse, with semi-axis $a = 30$ and $b = 15$, translating along the $x$-axis with velocity $\bv = (0.3,0)$. It is irradiated by a source at distance $R_0 = 600$, rotating with angle velocity $\omega = 1$. Gantry angle represents the angular position of the source, with respect to the $x$-axis $(= \omega t + \pi/2)$; see Figure~\ref{fig:notations}. The object translation occurs between gantry angles $45^{\circ}$ and $90^{\circ}$.\label{fig:sinogram}}
\end{figure}

With this configuration in mind, the functions $x' \mapsto \Bnv(x')$ for $n = 0,1,2,3$ were calculated from the simulated sinogram, and are illustrated in Figure~\ref{fig:Bnx}. Note that these expressions for $\Bnv$, follow the predicted pattern of $n^{\textrm{th}}$-degree polynomials, as can be seen by the fact that root mean square errors (RMSEs) between the actual values of $\Bnv(x)$ and their best polynomial approximations are low.
\begin{figure}
	\centering
	\begin{tabular}{cc}
	\includegraphics[width=75mm]{figs/B0.png} \\
	\includegraphics[width=75mm]{figs/B1.png} \\
	\includegraphics[width=75mm]{figs/B2.png} \\
	\includegraphics[width=75mm]{figs/B3.png}
	\end{tabular}
	\caption{From top to bottom, functions $x' \mapsto \Bnv(x')$ for $n = 0,1,2,3$ respectively. Blue points are the actual data, while red lines are the best polynomial approximations. RMSE stands for root mean square error. The $x$-axis are expressed in millimeters.\label{fig:Bnx}}
\end{figure}

With this velocity $\bv = (0.3,0)$ assumed to be unknown, we performed the minimization of the cost function $\mathcal{J}(v)$ defined in~(\ref{eq:Jv}), with a polynomial degree of $n = 2$. For this purpose, we used Powell's conjugate direction method~\cite{powell1964efficient}, which does not require differentiation of the cost function.

We studied the influence of the time during which the object was translating, \ie the angle $\alpha$ of the arc traced by the source $s(t)$ when the object was translating. As an example, for the sinogram depicted in Figure~\ref{fig:sinogram} we have $\alpha = 90^{\circ}$. Table~\ref{tab:results} summarizes all the results, where $\hat{v}$ stands for the estimated value for the velocity $v_1$. We observe that there is a limit below which the accuracy decreased dramatically.

\begin{table}[!ht]
\caption{Results of optimization \label{tab:results}}
\centering
	\begin{tabular}{ccc}
	% $\alpha$ & $95$ & $90$ & $85$ & $84$ & $83$ & $82$ & $81$ & $80$ & $75$ \\
	% \hline
	% $\hat{v}$ & $0.300$ & $0.300$ & $0.300$ & $0.300$ & $0.300$ & $0.376$ & $0.415$ & $0.436$ & $0.436$ \\
	% \hline
	  $\alpha$ & $\hat{v}$ & $\Vert v_1 - \hat{v}\Vert$ \\
	  \hline
		$95$ & $0.30$0 & $5.55 \cdot 10^{-17}$ \\
		$90$ & $0.300$ & $1.11 \cdot 10^{-16}$ \\
		$85$ & $0.300$ & $1.11 \cdot 10^{-16}$ \\
		$84$ & $0.300$ & $0$ \\
		$83$ & $0.300$ & $0$ \\
		$82$ & $0.376$ & $7.60 \cdot 10^{-2}$ \\
		$81$ & $0.415$ & $0.115$ \\
		$80$ & $0.436$ & $0.136$ \\
		$75$ & $0.436$ & $0.136$
\end{tabular}
\end{table}

\section{Conclusion}
In this work, we have proposed a way to recover the velocity parameters of a translating object in fan-beam CT from a set of projections restricted to an arc of the circular trajectory. The method uses data consistency conditions (DCCs), adapted from~\cite{clackdoyle2015consistency}. Setting the origin of the reference frame at a point which remains still with respect to the center of mass of the object, we are in fact dealing with DCCs in the case of an arc of a cycloid. Numerical examples show that these conditions work well in the case of an object translating in a direction which is parallel to the $x$-axis. Further work is in progress to recover the same results for a general translation.

\bibliographystyle{plain}
\bibliography{DCC_translation}

\end{document}