It has been seen in the previous section that the complete solution of a Riemann problem in solid dynamics is possible for simple problems.
However, such a solution may become complicated for multi-dimensional problems or for other non-linear problems.
Numerical methods such as upwind or Godunov-based methods \cite{Leveque} require the solution of many Riemann problems within a discretized medium.
When dealing with non-linear problems, the exact solution of those problems may increase drastically the computational cost, making the numerical scheme unappealing.
Moreover, numerical procedures often require only little information about the solution of Riemann problems and do not need the complete solution. In that context, alternative procedures have been developed in order to take into account the characteristic structure of a hyperbolic system by computing an approximate solution of Riemann problems.
Approximate Riemann solvers developed for Computational Fluid Dynamics allow to extract information for either flux functions (\textit{HLL, HLLC, Roe} and \textit{Osher} approximate Riemann solvers \cite{Trangenstein}, \cite{Toro}) or for vectors of conserved quantities (\textit{approximate--state Riemann solver} \cite[Ch.9]{Toro}, \cite[Ch.22]{Leveque}).
Some of these have been applied to specific problems in solid mechanics problems such as the Osher approximate solver (see \cite{Lee_FVM} and \cite{Haider_FVM}) or the HLLC approximate solver (see \cite{Ortega_HLLD}) for hyperelasticity .
We recall here the formulation of the approximate-state Riemann solver for solid mechanics.
The approach is then applied to the non-linear problem of section \ref{sec:SVK_solution}.

\subsection{General ideas}
As in the previous section, we consider the Riemann problem in the space direction $\vect{N}$:
\begin{equation}
  \label{eq:RP_approx}
  \begin{aligned}
  &\Qcb_t + \Jbsf\(\Qcb\) \drond{\Qcb}{X_N} = \vect{0}, \\
  &\left\lbrace
    \begin{aligned}
      & \Qcb(X_N,t=0) = \Qcb^L \quad \text{if } X_N< 0\\
      & \Qcb(X_N,t=0) = \Qcb^R \quad \text{if } X_N> 0
    \end{aligned}
    \right.
  \end{aligned}
\end{equation}
The approach for developing an approximate-state Riemann solver consists in linearizing the problem \eqref{eq:RP_approx} by approximating $\Jbsf$ in the vicinity of $\Qcb^L$ and $\Qcb^R$ by a constant matrix $\bar{\Jbsf}=\Jbsf\(\Qcb^L,\Qcb^R\)$ \cite[Ch.15]{Leveque}. Note that this approximation is valid for small jumps in initial data (\textit{i.e }$\Qcb^L\approx\Qcb^R$) and that $\bar{\Jbsf}$ must ensure hyperbolicity of the system, namely $\bar{\Jbsf}$ has real eigenvalues and a complete set of independent eigenvectors. The approximate matrix also satisfies the consistency condition:
\begin{equation}
  \label{eq:approx_constistency}
  \bar{\Jbsf}\(\Qcb,\Qcb\)=\Jbsf\(\Qcb\)
\end{equation}

Such a matrix can be defined by using the definition of right eigenvectors and characteristic speeds $\Jbsf \Rbsf = \Rbsf \Cbsf \Rightarrow \Jbsf = \Rbsf \Cbsf \Rbsf^{-1}$ in which left-going (\textit{resp. right-going}) characteristics and associated eigenvectors are assumed to depend on $\Qcb^L$ (\textit{resp. on} $\Qcb^R$) only. Namely, one writes:
\begin{align*}
  &\Rbsf = \matrice{\Rcb^1(\Qcb^L),\cdots,\Rcb^I(\Qcb^L),\Rcb^{I+1}(\Qcb^R),\cdots,\Rcb^m(\Qcb^R)} \\
  &\Cbsf=\matrice{c_1(\Qcb^L) & & & & & \\ & \cdots & & && \\ & &c_I(\Qcb^L) & & &\\ & & &c_{I+1}(\Qcb^R)& & \\ & & & &\cdots &\\ &&&&&c_m(\Qcb^R)}
\end{align*}
where $c_I(\Qcb)$ and $m$ are the highest negative eigenvalue and the dimension of the Jacobian matrix.

At last, the linearized Riemann problem thus written enables the determination of every state vector $\Qcb(x,t)$ by following the procedure described in section \ref{subsec:charac_Linear_problems} for linear problems, recalled here for convenience for a system of dimension $m$:
\begin{equation}
  \label{eq:approx_RS}
  \begin{aligned}
    &  \Qcb^R-\Qcb^L=\sum_{i=1}^{m} \Rcb^i\delta^i \\
    &  \Qcb(x,t) =\Qcb^R -\sum_{i=I+1}^{m} \Rcb^i\delta^i \\
    &  \Qcb(x,t) =\Qcb^L+ \sum_{i=1}^{I} \Rcb^i\delta^i
  \end{aligned}
\end{equation}
where the point ($x,t$) lies in the region bounded by the characteristics $I$ and $I+1$.

\begin{remark}
  Note that since one can define a complete set of independent eigenvectors of the Jacobian matrix, the matrix $\Rbsf$ is non-singular so that $\bar{\Jbsf}$ can be uniquely determined.
  % Moreover, the linearization proposed amounts to considering a heterogeneous medium where $\Qcb^{L}$ and $\Qcb^R$ act as material parameters.
\end{remark}

\subsection{Application: Hyperelastic plane wave}
We finish this section with an illustration of the approximate Riemann solver by considering the plane wave problem in the Saint-Venant-Kirchhoff medium treated in section \ref{sec:SVK_solution}.
Recall that the eigenvalues and right eigenvectors matrices read for that problem:
\begin{equation}
  \label{eq:SVK_matrices}
  \Cbsf = \matrice{-c & 0 \\ 0 & c} \quad ; \quad \Rbsf = \matrice{c & -c\\ 1&1} \:,\quad c=\sqrt{\frac{\lambda + 2\mu}{2\rho_0}(3F^2-1)}
\end{equation}
Hence, the linearized problem is written with:
\begin{equation}
  \label{eq:SVK_matrices_linear}
  \Cbsf = \matrice{-c_L & 0 \\ 0 & c_R} \quad ; \quad \Rbsf = \matrice{c_L & -c_R\\ 1&1}
\end{equation}
In section \ref{subsec:charac_Linear_problems}, the expression of the wave strengths vector $\vect{\delta}$ has been established for general linear systems of dimension $2$ (see equation \eqref{eq:wave_strengths}):
\begin{equation}
  \vect{\delta}=\frac{1}{c_R+c_L}\matrice{c_R \Delta F +\Delta v\\ c_L \Delta F -\Delta v}
\end{equation}
leading to the solution $\Qcb $ between the two discontinuous waves:
\begin{equation}
  \label{eq:SVK_approx_solution}
  \Qcb  = \Qcb^L + \delta^1 \Rcb^1 = \matrice{v_L \\F_L} +\delta^1 \matrice{c_L \\1} \quad \text{or} \quad \Qcb  = \Qcb^R - \delta^2 \Rcb^2 = \matrice{v_R \\F_R} -\delta^2 \matrice{-c_R \\1}
\end{equation}
Substitution of $\delta^{1,2}$ from the second equations into the first provides straight line equations in the phase plane ($F,v$):
\begin{equation}
  \label{eq:approx_straight}
  v  = v_L + c_L(F -F_L) \quad ; \quad v  = v_R + c_R(F_R-F )
\end{equation}
\begin{figure}[h!]
  \centering
  {\input{chapter2/pgfFigures/1S2R_solution_approx} \phantomsubcaption \label{subfig:SVK_Approx1}}
  {\input{chapter2/pgfFigures/1S2R_solution_weak3} \phantomsubcaption \label{subfig:SVK_Approx4}}
  \caption{Comparison of approximate (dashed lines) and exact (solid lines) solution for a one-dimensional strain problem in a Saint-Venant-Kirchhoff hyperelastic material}
  \label{fig:comparison_exact_approx}
\end{figure}
The intersection of those straight lines in the phase plane corresponds to the approximate solution. Figure \ref{fig:comparison_exact_approx} shows comparisons of approximate and exact solutions for various initial data, all leading to a $1$-shock--$2$-rarefaction exact solution. As expected, approximate and exact solutions are different and get closer for small initial discontinuities, satisfying the linearization assumption $\Qcb^L\approx \Qcb^R$. As a consequence, a big initial discontinuity is considered in figure \ref{fig:comparison_exact_approx}\subref{subfig:SVK_Approx1} so that the approximation error is larger than that of figure \ref{fig:comparison_exact_approx}\subref{subfig:SVK_Approx4} for which initial data are based on a weak jump.

%%% Local Variables:
%%% mode: latex
%%% ispell-local-dictionary: "american"
%%% TeX-master: "../mainManuscript"
%%% End:


% LaTeX2e Template by Stephen Iota (https://stepheniota.github.io/)
% last updated: Aug. 2018

% for papers
%\documentclass[aps,onecolumn,superscriptaddress]{revtex4-1}

% https://www-d0.fnal.gov/Run2Physics/WWW/templates/revtex4.pdf
% https://cdn.journals.aps.org/files/revtex/auguide4-1.pdf
% for revTeX4-1 class options

% for other
\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}

%%%%%%%%%%%%%%%%
%%% Packages %%%
%%%%%%%%%%%%%%%%

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts} % to remove math font when typesetting equations
\usepackage{graphicx}
\usepackage{enumitem} % to change labels in enum/item
\usepackage[dvipsnames]{xcolor} % for colored links

% always put this at the end
\usepackage[
	colorlinks=true,
	citecolor=green!50!black,
	linkcolor=NavyBlue!75!black,
	urlcolor=green!50!black,
	hypertexnames=false]{hyperref}

 %%%%%%%%%%%%%%%%%%
 %% New Commands %%
 %%%%%%%%%%%%%%%%%%

\newcommand{\email}[1]{\texttt{\href{mailto:#1}{#1}}}

\newcommand{\hint}[1]{\color{Blue}{#1}}

%----------------------------------------------------
%%%%%%%%%%%%%%%%%%
%% Front Matter %%
%%%%%%%%%%%%%%%%%%

%\pagenumbering{gobble} % no page numbers
\graphicspath{{figures/}} % set directory for figures

%%%%%%%%%%%%%
%%% Title %%%
%%%%%%%%%%%%%
\begin{document}

\begin{center}

\Large{\textsc{Worksheet 2a}: \textbf{Understanding Charge Distributions}}

\end{center}

\vspace{.5mm}

%%%%%%%%%%
%% INFO %%
%%%%%%%%%%

\begin{tabular}{rl}
\textsc{SI Leader}:
&
Stephen Iota (\email{siota001@ucr.edu})
\\
\textsc{Course}:
&
Physics 40C (Fall 2018); Dr.~Laura Sales
\\
\textsc{Date}:
&
October 9, 2018
\end{tabular}

%%%%%%%%%%%%%%
%% PROBLEMS %%
%%%%%%%%%%%%%%

\subsubsection*{README}

``\textit{How do I even start this problem?!}''\\
1) Take a deep breath
2) carefully read the question
3) draw and label figure and axes
4) identify unknown and knowns
5) write down relevant concepts and equations and
6) crunch the numbers!

\section{Conceptual Questions}

\begin{enumerate}[label=(\alph*)]
\item Give examples of symmetric shapes and non-symmetric shapes.
\item When is the dipole approximation valid?
\item Describe the dynamics of a dipole placed in a \textbf{uniform} electric field.
\begin{itemize}
	\item Does it experience a force?
	\item Does it move? If so, how?
\end{itemize}
\item At the dot, in what direction does the electric field point?

\includegraphics[width=.2\linewidth]{W2a_Fig1.png}
\item What are ways to increase the magnitude of the electric field at the dot?

\includegraphics[width=.2\linewidth]{W2a_Fig2}
\item Draw the electric field lines for the positively charged rod above.
\item How much faster does the $\vec{E}$ field of a point charge decay compared to the $\vec{E}$ field of a charged-thin wire?
\end{enumerate}

\section{The Electric Field of a Continuous Distribution}

\begin{enumerate}[label=(\alph*)]

	\item The electric field strength $2.0$ cm from the surface of a $10$-cm-diameter metal ball is $50,000$ N/C. What is the total  charge $Q$ (in nC) on the metal ball?
	\item The electric field strength $10.0$ cm away from a very long charged wire\footnote{\label{text}Look in text/notes to find relevant $\vec{E}$ field equation.} is $2000$ N/C. What is the electric field strength $5.0$ cm from the wire?

\end{enumerate}

\section{Through the Wire}

No notes or textbook this time!
Show that the electric field $\vec{E}$ at point $p$ a distance $r$ above a wire of length $L$ with total charge $Q$ is:
$$\vec{E}(p) = \frac{\lambda}{4\pi\epsilon}\int_{-\frac{L}{2}}^ \frac{L}{2} \! \mathrm{d}x \ \frac{x}{(r^2 + x^2)^\frac{3}{2}}  \ \hat{y}$$

\includegraphics[width=.4\linewidth]{W2a_fig3.png}

\hint{\texttt{Hint 1}: See problem 1(a)}

\hint{\texttt{Hint 2}: Use the Pythagorean theorem}

\end{document}


\documentclass[11pt]{article}
\usepackage{graphicx,amsmath,amsfonts,amssymb,graphicx}
\usepackage[varg]{txfonts}
\usepackage{enumerate}
\usepackage{hyperref}
\usepackage{listings}
\usepackage{color}
\urlstyle{tt}

\usepackage{geometry}
\geometry{%
  letterpaper,
  lmargin=2cm,
  rmargin=2cm,
  tmargin=2cm,
  bmargin=2cm,
  footskip=12pt,
  headheight=12pt}

\usepackage{lastpage}
\usepackage{fancyhdr}
%\pagestyle{fancy}
%\headheight 35pt

\def\squarebox#1{\hbox to #1{\hfill\vbox to #1{\vfill}}}
\def\qed{\hspace*{\fill}
        \vbox{\hrule\hbox{\vrule\squarebox{.667em}\vrule}\hrule}}
\newenvironment{solution}{\begin{trivlist}\item[]{\bf Solution:}}
                      {\textbf{//} \end{trivlist}}
\lstset{
	language=MATLAB,              % choose the language of the code ("language=Verilog" is popular as well)
   tabsize=3,							  % sets the size of the tabs in spaces (1 Tab is replaced with 3 spaces)
	basicstyle=\tiny,               % the size of the fonts that are used for the code
	numbers=left,                   % where to put the line-numbers
	numberstyle=\tiny,              % the size of the fonts that are used for the line-numbers
	stepnumber=2,                   % the step between two line-numbers. If it's 1 each line will be numbered
	numbersep=5pt,                  % how far the line-numbers are from the code
	%backgroundcolor=\color{mygrey}, % choose the background color. You must add \usepackage{color}
	%showspaces=false,              % show spaces adding particular underscores
	%showstringspaces=false,        % underline spaces within strings
	%showtabs=false,                % show tabs within strings adding particular underscores
	frame=single,	                 % adds a frame around the code
	tabsize=3,	                    % sets default tabsize to 2 spaces
	captionpos=b,                   % sets the caption-position to bottom
	breaklines=true,                % sets automatic line breaking
	breakatwhitespace=false,        % sets if automatic breaks should only happen at whitespace
	%escapeinside={\%*}{*)},        % if you want to add a comment within your code
	%commentstyle=\color{BrickRed}   % sets the comment style
}
\begin{document}

\title{\bf{CSE397: Assignment \#4}}
\author{Nicholas Malaya \\ Department of Mechanical Engineering \\
Institute for Computational Engineering and Sciences \\ University of
Texas at Austin} \date{}
\maketitle
\newpage

\subsection*{ Problem 1}
\textbf{Frequency-domain inverse wave problem.}

\begin{enumerate}
\item[(a)]
\begin{solution}
The weak form of the state equation is given by:
\begin{displaymath}
\int_{\Omega}\nabla u \cdot \nabla p - k^2mup - fp\hspace{2 mm}dx -
 \int_{\Gamma}p\nabla u \cdot n\hspace{2 mm}ds \hspace{1 cm} \forall p
 \in H^1_0(\Omega)
\end{displaymath}
However since p = 0 on the boundary then the boundary term is zero. The
 Lagragian is therefore:
\begin{displaymath}
\mathcal{L}(u,p,m) := \int_{\Omega}\nabla u \cdot \nabla p - k^2mup -
 fp\hspace{2 mm}dx + \int_{\Omega}\left(u - u^{obs}\right)^2 dx +
 \frac{\beta}{2}\int_{\Omega}\nabla m \cdot \nabla m dx
\end{displaymath}
We now take variations with respect to each of the parameters:
\begin{align}
\delta_u\mathcal{L}(\tilde{u}) &= \int_{\Omega}(u-u^{obs})\tilde{u} +
 \nabla\tilde{u}\cdot\nabla p - k^2m\tilde{u}p \hspace{2 mm} dx = 0
 \hspace{1 cm} \forall\tilde{u} \in H^1_0(\Omega) \nonumber \\
\delta_p\mathcal{L}(\tilde{p}) &= \int_{\Omega} \nabla u \cdot
 \nabla\tilde{p} - k^2mu\tilde{p} - f\tilde{p} \hspace{2 mm} dx = 0
 \hspace{1 cm} \forall\tilde{p} \in H^1_0(\Omega) \nonumber \\
\delta_m\mathcal{L}(\tilde{m}) &= \int_{\Omega} \beta \nabla m \cdot
 \nabla\tilde{m} - k^2\tilde{m}up \hspace{2 mm} dx = 0 \nonumber
\end{align}
The last of these equations is the gradient equation. It depends
 on both p and u which come from the adjoint and state
 equations. u is found to be the solution of the
 following:
\begin{align}
-\Delta u - k^2mu &= f\hspace{5 mm} \text{on } \Omega \nonumber \\
u &= 0 \hspace{5 mm} \text{on } \partial\Omega \nonumber
\end{align}
and $p$ is found to be the soultion to the adjoint equation:
\begin{align}
-\Delta p - k^2mp &= u^{obs} - u \hspace{5 mm} \text{on } \Omega \nonumber \\
p &= 0 \hspace{5 mm} \text{on } \partial\Omega \nonumber.
\end{align}
Using the solutions of these equations then gives the gradient with
 $\delta_m\mathcal{L}(\tilde{m}) = 0$.
\end{solution}

\item[(b)] Derive an expression for the (infinite dimensional) action of
	   the Hessian in a direction m in the single source and frequency case.

\begin{solution}
To get the application of a Hessian on a vector, one needs the second
 variation of the three weak forms in the previous section. These are:
\begin{align}
\left(\delta_u+\delta_m+\delta_p\right)\left(\delta_u\mathcal{L}\right)
 &= \int_\Omega \hat{u}\tilde{u} - k^2\hat{m}\tilde{u}p -
 k^2m\tilde{u}\hat{p} + \nabla\tilde{u}\cdot\nabla\hat{p} \hspace{2 mm}
 dx \nonumber \\
\left(\delta_u+\delta_m+\delta_p\right)\left(\delta_p\mathcal{L}\right)
 &= \int_\Omega \nabla\hat{u}\cdot\nabla\tilde{p} - k^2m\hat{u}\tilde{p}
 - k^2\hat{m}u\tilde{p} \hspace{2 mm} dx \nonumber \\
\left(\delta_u+\delta_m+\delta_p\right)\left(\delta_m\mathcal{L}\right)
 &= \int_\Omega \beta\nabla\hat{m}\cdot\nabla\tilde{m} -
 k^2\tilde{m}\hat{u}p - k^2\tilde{m}u\hat{p} \hspace{2 mm} dx \nonumber
\end{align}
However this introduces two new variables $\hat{p}$ and $\hat{u}$
 which need to be solved for. From the second variation one gets
 $\hat{u}$. Its strong form is given by:
\begin{align}
-\Delta\hat{u}-k^2m\hat{u} &= k^2\hat{m}u \hspace{5 mm} \text{on }
 \Omega \nonumber \\
\hat{u} &= 0 \hspace{5 mm} \text{on } \partial\Omega \nonumber
\end{align}
Similarly $\hat{p}$ is given by the solution to the second variation of the adjoint equation:
\begin{align}
-\Delta\hat{p} - k^2m\hat{p} &= k^2\hat{m}p - \hat{u}\hspace{5 mm} \text{on } \Omega \nonumber \\
\hat{p} &= 0 \hspace{5 mm} \text{on } \partial\Omega \nonumber
\end{align}
Using the solution to the state equation ($u$), the solution to the
 adjoint equation ($p$), $m$, the solution to the second variation of
 the state equation ($\hat{u}$), the solution to the second variation of
 the adjoint equation ($\hat{p}$), and given a direction $\hat{m}$, the
 action of the Hessian in a direction $\hat{m}$ is given by:
\begin{displaymath}
\int_\Omega \beta\nabla\hat{m}\cdot\nabla\tilde{m} -
 k^2\tilde{m}\hat{u}p - k^2\tilde{m}u\hat{p} \hspace{2 mm} dx = 0
\end{displaymath}
\end{solution}

\item[(c)] Derive an expression for the (infinite dimensional) gradient
	   for an arbitrary number of sources and frequencies. How many
	   state and adjoint equations have to be solved for a single
	   gradient computation?

\begin{solution}
The gradient is still calculated in the same manner as in the previous
 case with a single source and frequency. Therefore it is the variation
 of the Lagrangian with respect to m. However, now for each $u_{ij}$
 there is a corresponding adjoint variable $p_{ij}$ and the Lagrangian
 takes a slightly different form than before. With all of the
 frequencies and sources the minimization problem is given as stated:
\begin{displaymath}
\min_m J(m) :=
 \frac{1}{2}\sum_{i=1}^{N_f}\sum_{j=1}^{N_s}\int_{\Omega}\left(u_{ij} -
 u_{ij}^{obs}\right)^2 dx + \frac{\beta}{2}\int_{\Omega}\nabla m \cdot
 \nabla m dx
\end{displaymath}
To form the Lagrangian this needs to be paired with the state equation. However the state equation for a single $u_{ij}$ is given by:
\begin{align}
-\Delta u_{ij} - k_i^2m(x)u_{ij}(x) &= f_j(x)\hspace{5 mm} \text{on }
 \Omega \hspace{5 mm} i = 1, 2, ..., N_f \hspace{5 mm} j = 1, 2, ...,
 N_s \nonumber \\
u_{ij} &= 0 \hspace{5 mm} \text{on } \partial\Omega \nonumber
\end{align}
Therefore one needs to carry all $N_sN_f$ of these into the
 Lagrangian. Note that in weak form, a single state equation looks like:
\begin{displaymath}
\int_{\Omega}\nabla u_{ij} \cdot \nabla p_{ij} - k_i^2mu_{ij}p_{ij} -
 f_jp_{ij}\hspace{2 mm}dx \hspace{1 cm} \forall p_{ij} \in H^1_0(\Omega)
\end{displaymath}
Again the boundary term is zero since $p_{ij} = 0$ on the boundary. With
 the weak forms for each of the $u_{ij}$, the Lagrangian is given by:
\begin{displaymath}
\mathcal{L} := \sum_{i=1}^{N_f}\sum_{j=1}^{N_s}\int_{\Omega}\left(\nabla
 u_{ij} \cdot \nabla p_{ij} - k_i^2mu_{ij}p_{ij} - f_jp_{ij}\right)dx +
 \frac{1}{2}\sum_{i=1}^{N_f}\sum_{j=1}^{N_s}\int_{\Omega}\left(u_{ij} -
 u_{ij}^{obs}\right)^2 dx + \frac{\beta}{2}\int_{\Omega}(\nabla m \cdot
 \nabla m) dx
\end{displaymath}
Taking a variation with respect to $m$ of this gives:
\begin{displaymath}
\int_{\Omega} \beta (\nabla m \cdot \nabla\tilde{m})dx -
 \sum_{i=1}^{N_f}\sum_{j=1}^{N_s}\int_{\Omega}(k_i^2\tilde{m}u_{ij}p_{ij})dx
\end{displaymath}
This will give the gradient for a point $m$, provided a solution is
 available for each of the $u_{ij}$ and the $p_{ij}$. Obtaining those
 solutions requires $N_sN_f$ solves of the state and adjoint equations
 for a total of $2N_sN_f$ PDE solves.
\end{solution}
\end{enumerate}

\newpage
\subsection*{Problem 2}

\begin{enumerate}
\item[(a)] Report the solution of the inverse problem and the number of
	  required iterations for the following cases:

%Report the reconstructions and the number of required
%	  iterations for the following cases:

\begin{enumerate}
 \item[$\bullet$] Noise level of 0.01 (roughly $1\%$ noise), and
	      regularization $\beta = 5 \cdot 10^{-10}$.
 \item[$\bullet$] Same, but with $\beta = 0$, i.e., no regularization.
 \item[$\bullet$] No noise, and use $m \equiv 4$ and $m \equiv 8$ as
	      initial guesses for the parameter. Do you find the same
	      solution? Explain the behavior.
\end{enumerate}
\begin{solution}
The following table summarizes the number of iterations for each of the
 desired start conditions:
\begin{center}
\begin{tabular}{| c | c | c | c |} \cline{1-4}
Noise & $\beta$ & $m$ & No. of Iterations \\ \cline{1-4}
0.01 & 5E-10 & 8 & 284 \\ \cline{1-4}
0.01 & 0.0 & 8 & 27 \\ \cline{1-4}
0.0 & 0.0 & 8 & 27 \\ \cline{1-4}
0.0 & 0.0 & 4 & 24 \\ \cline{1-4}
\end{tabular}
\end{center}
The results of these trials are can be quite different. The case with noise
 and regularization yields the following result:
\begin{center}
\includegraphics[width = 6 cm]{figs/prob2aNoiseRegM8.jpg}
\end{center}

The case with no regularization resulted in:
\begin{center}
\includegraphics[width = 6 cm]{figs/prob2aNoiseNoRegM8.jpg}
\end{center}

The case with no noise and no regularization and $m = 8$:
\begin{center}
\includegraphics[width = 6 cm]{figs/prob2aNoNoiseNoRegM8.jpg}
\end{center}

The case with no noise and no regularization and $m = 4$:
\begin{center}
\includegraphics[width = 6 cm]{figs/prob2aNoNoiseNoRegM4.jpg}
\end{center}

Note the difference in the final cases where the result for $m = 4$ ($a$
 in the image) is vastly different from the other results. This is a
 direct result of steepest descent being dependent on the start
 value. The case with no noise or regularization with $m = 8$ provides a
 solution close to the truth. Similarly
 the $m = 4$ solution is close to the true solution except for the
 diagonals. Note also that the $p$ values are also rather
 different. This is likely due to the adjoint being sensitive to
 $m$. $u$ should also be sensitive to $m$, but the end result look
 roughly the same because of the misfit penalization.
\end{solution}

\item[(b)] Add the advective term v = (30, 0) to the inverse problem and its COMSOL
	  implementation and plot the resulting reconstruction of m for
	  a noise level of 0.01 and for a reasonably chosen regularization parameter.

\begin{solution}
After adding the advective term, the result for a noise level of 0.01
 and regularization of 5e-10 is given by:
\begin{center}
\includegraphics[width = 6 cm]{figs/prob2bNoiseRegM8.jpg}
\end{center}
\end{solution}

\item[(c)] Since the coefficient m is discontinuous, a better choice of
	   regularization is total variation
	   rather than Tikhonov regularization, to prevent an overly smooth
	   reconstruction. Modify the implementation and plot the result
	   for a reasonably chosen regularization parameter

%Since the coefficient $m$ is discontinuous, a better choice is to use total variation
%regularization rather than Tikhonov regularization to prevent an overly smooth
%reconstruction. Modify the implementation and plot the result for a reasonably
%chosen regularization parameter.

\begin{solution}
 Since one is switching to a total variational regularization parameter,
 now two choices of parameters are needed. For the solution shown below,
 the calculation was done with the same advective term, regularization
 parameter beta, and noise level as before in part b, however it also
 uses a tau of 1e-1 as requested. The result found is:
\begin{center}
\includegraphics[width = 6 cm]{figs/prob2c.jpg}
\end{center}
Note that the drift from the advective term is not fully removed by this
 regularization, though the solution is much closer than with Tikhonov
 regularization.
\end{solution}
\end{enumerate}

\newpage
\subsection*{Code}
Here is the code for part c:
\lstinputlisting{code/elliptic_sd_ip_adv_TV.m}
\end{document}


\documentclass{beamer}

\usepackage{graphicx}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{eso-pic}
\usepackage{mathrsfs}
\usepackage{url}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{hyperref}
\usepackage{booktabs}
% \usepackage{bbm}
\usepackage{cooltooltips}
\usepackage{colordef}
\usepackage{beamerdefs}
\usepackage{lvblisting}

\usepackage{multimedia}
\usepackage{algorithmicx}
\usepackage[noend]{algpseudocode}
\usepackage{algorithm}

\pgfdeclareimage[height=2cm]{logobig}{hulogo}
\pgfdeclareimage[height=0.7cm]{logosmall}{Figures/LOB_Logo}

\renewcommand{\titlescale}{1.0}
\renewcommand{\titlescale}{1.0}
\renewcommand{\leftcol}{0.6}

\title[Eigenvalue Problems - Numerical Solutions]{Eigenvalues and Eigenvectors}
\authora{Thomas Siskos}
\authorb{}
\authorc{}

\def\linka{siskosth@student.hu-berlin.de}
\def\linkb{http://github.com/thsis/NIS18}
\def\linkc{}

\institute{Numerical Introductory Seminar \\
Humboldt--University Berlin \\}

\hypersetup{pdfpagemode=FullScreen}

\begin{document}
% 0-1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame[plain]{

\titlepage
}

\frame{
  \frametitle{Agenda}
  \tableofcontents
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Motivation}
\frame[containsverbatim]{
\frametitle{PCA}
\begin{columns}[onlytextwidth]
\begin{column}{0.25\textwidth}
	\begin{itemize}
		\item The iris dataset is already linearly separable.
		\item With various techniques we can show this in even more detail.
	\end{itemize}
\end{column}
\begin{column}{0.75\textwidth}
\begin{figure}
  	\begin{center}
	\includegraphics[scale=0.20]{../media/plots/iris_raw.png}
    \caption{\href {https://github.com/thsis/NIS18/blob/master/tests/tests_models.py}{Iris Pairplot}  \protect\includegraphics[scale=0.05]{qletlogo.pdf}}
	\end{center}
\end{figure}
\end{column}
\end{columns}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\frame[containsverbatim, label=PCA-prop]{
\frametitle{PCA}
\begin{columns}[onlytextwidth]
\begin{column}{0.65\textwidth}
	\begin{itemize}
		\item objective:
		\begin{equation}
		\label{pca_obj}
            max\ \delta^{\prime} Var \left(X\right) \delta \; s.t. \; \sum \delta_i^2 = 1.
        \end{equation}
        where $X \in \mathbb{R}^{n \times m}; m,n \in \mathbb{N}; \delta \in \mathbb{R}^m$
		\item solution \hyperlink{PCA-proof}{\beamergotobutton{Proof}}
:
		\begin{equation}
		\label{pca_sol}
			Y = \Gamma^{\prime} \left(X - \mu\right)
		\end{equation}
		where $Y \in \mathbb{R}^{n \times m}$ is the matrix of rotations,
		      $\Gamma \in \mathbb{R}^{m \times m}$ is the matrix of eigenvectors,
		      $\mu \in \mathbb{R}^m$ is the vector of sample means.
	\end{itemize}
\end{column}
\begin{column}{0.35\textwidth}
\begin{figure}
	\includegraphics[width=3.5cm, height=5cm]{../media/plots/iris_pca.png}
	\caption{\href {https://github.com/thsis/NIS18/blob/master/tests/tests_models.py}{Iris PCA}  \protect\includegraphics[scale=0.05]{qletlogo.pdf}}
\end{figure}
\end{column}
\end{columns}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\frame{
\frametitle{LDA}
\begin{itemize}
	\item objective:
		\begin{equation}
		\label{lda_obj}
  			max \ \frac{w^{\prime}S_B w}{w^{\prime}S_W w},
		\end{equation}
	where
	\begin{align*}
  	S_B &= \sum\limits_{c}^{C} (\mu_c - \mu)(\mu_c - \mu)^{\prime}, \\
  	S_W &= \sum\limits_{c}^{C} \sum\limits^{n}_{i=1} (x_i - \mu_c)(x_i - \mu_c)^{\prime}
	\end{align*}
	and $x_i \in \mathbb{R}^m$, $\mu_c$ is the vector of class means.
\end{itemize}

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\frame[containsverbatim, label=LDA-prop]{
\frametitle{LDA}
\begin{columns}[onlytextwidth]
\begin{column}{0.65\textwidth}
\begin{itemize}
\item solution \hyperlink{LDA-proof}{\beamergotobutton{Proof}}:
\begin{equation}
  \label{lda_sol}
    S_B^{\frac{1}{2}}S_{W}^{-1}S_B^{\frac{1}{2}} v = \lambda v
  \end{equation}
  with $$    v = S_B^{\frac{1}{2}} w, $$ where this is again an Eigenvalue problem and it's solution will provide the rotation that ensures the largest possible (linear) separability.
\item Now how do we get the Eigenvalues?
\end{itemize}
\end{column}
\begin{column}{0.35\textwidth}
\begin{figure}
	\begin{center}
	\includegraphics[width=3.5cm, height=5cm]{../media/plots/iris_lda.png}
	\caption{\href {https://github.com/thsis/NIS18/blob/master/tests/tests_models.py}{Iris LDA}  \protect\includegraphics[scale=0.05]{qletlogo.pdf}}
	\end{center}
\end{figure}
\end{column}
\end{columns}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Key Idea \& Definitions}
\frame{
\frametitle{Eigenvalue}
If $A$ is an $n \times n$ matrix, $v$ is a non-zero vector and $\lambda$ is a scalar, such that
\begin{equation}
\label{eigenvalue-def}
Av = \lambda v
\end{equation}
then $v$ is called an \textit{eigenvector} and $\lambda$ is called an \textit{eigenvalue} of the matrix $A$.
An eigenvalue of A is a root of the characteristic equation,
\begin{equation}
\label{eigenvalue-solve}
det\left(A - \lambda I \right) = 0
\end{equation}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsection{Characteristic Polynomial \& Diagonal Matrices}
\frame[label=companion_prop]{
\frametitle{The characteristic polynomial}
Consider the polynomial
\begin{equation}
\label{characteristic-polynomial}
f(\lambda) = \lambda^p + a_{p-1}\lambda^{p-1} + \dots + a_1 \lambda + a_0
\end{equation}
We now construct a matrix $A \in \mathbb{R}^{n \times n}$ such that the eigenvalues of $A$ are the roots of the polynomial $f(\lambda)$ \hyperlink{companion_exmpl}{\beamergotobutton{Example}}:
\begin{equation}
\label{companion-matrix}
A = \begin{bmatrix}
        0    & 1    & 0    & \dots & 0 \\
        0    & 0    & 1    & \cdots & 0 \\
             &      &      & \ddots & \\
        0    & 0    & 0    & \dots  & 1 \\
        -a_0 & -a_1 & -a_2 & \dots  & -a_{p-1} \\
    \end{bmatrix}
\end{equation}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsection{Similarity Transformations}
\frame[containsverbatim]{
\frametitle{General Idea}

What are the eigenvalues of $X_1$ and $X_2$?

\begin{columns}[onlytextwidth]
\begin{column}{0.3\textwidth}
\begin{equation*}
X_1 = \begin{bmatrix}
1 & 0 & 0 & 0 \\
0 & 2 & 0 & 0 \\
0 & 0 & 3 & 0 \\
0 & 0 & 0 & 4 \\
\end{bmatrix}
\end{equation*}
\end{column}
\begin{column}{0.7\textwidth}
\begin{equation*}
X_2 = \begin{bmatrix}
        2.297 & -0.461 & -0.459 &  0.225 \\
       -0.461 &  1.4   & -0.097 & -0.829 \\
       -0.459 & -0.097 &  2.672 &  0.224 \\
        0.225 & -0.829 &  0.224 &  3.631 \\
\end{bmatrix}
\end{equation*}
\end{column}

\end{columns}
}

\frame[label=similarity_prop]{
\frametitle{Similarity Transformations}

Two $n \times n$ matrices $A$ and $B$, are said to be \textit{similar} if there exists a nonsingular matrix $P$ such that
\begin{equation}
\label{similarity-prop}
A = P^{-1} B P
\end{equation}

If the two matrices $A$ and $B$ are similar, then they also share the same eigenvalues. \hyperlink{similarity_proof}{\beamergotobutton{Proof}}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsubsection{Householder Reflections}
\frame[label=householder_prop]{
\frametitle{Householder Reflections}
Let $u$ and $v$ be orthonormal vectors and let $x$ be a vector in the space spanned by $u$ and $v$, such that
$$x = c_1 u + c_2 + v$$
for some scalars $c_1$ and $c_2$. The vector
$$\tilde{x}=-c_1 u + c_2 v$$
is a \textit{reflection} of x through the line difined by the vector u. Now consider the matrix

\begin{equation}
Q = I - 2 uu^{\prime}.
\end{equation}

Note that \hyperlink{householder_proof}{\beamergotobutton{Proof}}:
$$Qx = \tilde{x}$$
}

\frame{
\frametitle{Householder Reflections}
We will use Householder-Reflections to tranform a vector
$$a = (a_1, \dots, a_n)$$
into
$$\hat{a} = (\hat{a}_1, 0, \dots, 0)$$
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsubsection{Givens Rotations}
\frame[containsverbatim]{
\frametitle{Givens Rotations}
Using orthogonal transformations we can also rotate a vector in such a way that a specified element becomes 0 and only one other element in the vector is changed.

\begin{columns}[onlytextwidth]
\begin{column}{0.5\textwidth}
$$
Q = \begin{bmatrix}
\cos\theta & \sin\theta \\
-\sin\theta & \cos\theta
\end{bmatrix}
$$
\end{column}
\begin{column}{0.5\textwidth}
	\includegraphics[scale=.5]{../media/plots/givens.png}
\end{column}
\end{columns}

}
\frame[label=givens_prop]{
\frametitle{Givens Rotations}

\begin{equation}
V_{pq}(\theta) = \begin{bmatrix}
                      1 &  &  &  &  &  &  &  &  \\
                       & \ddots &  &  &  &  & &  &  \\
                       &  & 1 &  &  &  &  &  &  \\
                       &  &  & \cos\theta &  & \sin\theta &  &  &  \\
                       &  &  &  & \ddots &  &  &  &  \\
                       &  &  & -\sin\theta &  & \cos\theta &  &  &  \\
                       &  &  &  &  &  & 1 &  &  \\
                       &  &  &  &  &  &  & \ddots &  \\
                       &  &  &  &  &  &  &  & 1 \\
                 \end{bmatrix}
\end{equation}
	where $\cos\theta = \frac{x_p}{||x||}$ and $\sin\theta = \frac{x_q}{||x||}$

}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Algorithms}
\subsection{Jacobi-Method}
\frame{
\frametitle{Jacobi Method}

The Jacobi method for determining the eigenvalues of a symmetric matrix $A$ uses a sequence of orthogonal similarity transformations that result in the transformation:
$$A = P  \Lambda P^{-1}$$ or rather: $$\Lambda=P^{-1}AP$$
where we use Givens Rotations to obtain $P$. The Jacobi iteration is:
\begin{equation}
\label{j-meth}
A^{k} = V_{p_k q_k}(\theta_k)A^{k-1}V_{p_k q_k}(\theta_k)
\end{equation}

The Jacobi Method is of $O(n^3)$
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame{
\frametitle{Jacobi-Method}
\begin{algorithm}[H]
\caption{\texttt{jacobi}}
\label{j-algo}
\begin{algorithmic}
  \Require symmetric matrix $A$
  \Ensure $0 < precision < 1$
  \Statex \textbf{initialize: } $L \gets A$; $U \gets I$; $L_{max} \gets 1$
  \While{$L_{max} > precision$}
    \State Find indices $i$, $j$ of largest value in lower triangle of $abs(L)$
        \State $L_{max} \gets L_{i,j}$
            \State $\alpha \gets \frac{1}{2}\cdot \arctan(\frac{2A_{i, j}}{A_{i, i}-A_{j, j}})$
    \State $V \gets I$
    \State $V_{i, i}, V_{j, j} \gets \cos \alpha$; $V_{i, j}, V_{j, i} \gets -\sin \alpha, \sin \alpha$
    \State $A \gets V^{\prime} A V$; $U \gets UV$

  \EndWhile
  \Return $diag(A), U$
\end{algorithmic}
\end{algorithm}
}
\subsection{QR-Method}
\frame{
\frametitle{QR-Method}
The QR-Method is the most common algorithm for obtaining eigenvalues and eigenvectors of a matrix $A$. It relies on the so called QR-Factorization:
\begin{equation}
A = QR,
\end{equation}
where $Q$ is an orthogonal and $R$ is an upper triangular matrix. \\
The QR iteration is:
\begin{equation}
  A^k = Q_{k-1}^{\prime} A_{k-1} Q_{k-1} = R_{k-1}Q_{k-1}
\end{equation}

The QR Method is of $O(n^3)$
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Basic Variant}
\frame{
\frametitle{Basic QR-Method}
\begin{algorithm}[H]
\caption{\texttt{QRM1}}
\label{qr1-meth}
  \begin{algorithmic}
    \Require square matrix $A$
    \Statex \textbf{initialize: } $conv \gets False$
    \While{not $conv$}
      \State $Q, R \gets$ QR-Factorization of $A$
      \State $A \gets RQ$
      \If{$A$ is diagonal}
        \State $conv \gets \texttt{True}$
        \Statex
      \EndIf
    \EndWhile
    \Return $diag\left(A\right), Q$
  \end{algorithmic}
\end{algorithm}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Hessenberg Variant}
\frame{
\frametitle{Refined QR-Method}

\begin{columns}[onlytextwidth]
\begin{column}{0.5\textwidth}
For faster convergence it is common to convert the matrix first into a so called upper Hessenberg form.
\end{column}
\begin{column}{0.5\textwidth}
$$
\begin{bmatrix}
 X & X & X & X & X & X & X \\
 X & X & X & X & X & X & X \\
 0 & X & X & X & X & X & X \\
 0 & 0 & X & X & X & X & X \\
 0 & 0 &  0 & X & X & X & X \\
 0 & 0 & 0 & 0 & X & X & X \\
 0 & 0 & 0 & 0 & 0 & X & X \\
\end{bmatrix}
$$
\end{column}
\end{columns}

\begin{algorithm}[H]
\caption{\texttt{QRM2}}
\label{qr2-meth}
\begin{algorithmic}
  \Require square matrix $A$
  \State $A \gets \texttt{hessenberg(}A\texttt{)}$
  \State continue with: \Call {QRM1} A
\end{algorithmic}
\end{algorithm}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame{
  \frametitle{QRM2 Visualized}
  \begin{center}
    \movie[width=8cm, height=5.35cm]{\includegraphics[width=8cm, height=5.35cm]{Figures/placeholder.jpg}}{Figures/qrm_symmetric.mp4}

    \href {https://github.com/thsis/NIS18/blob/master/analysis/animation.py}{QR-Method} \includegraphics[scale=0.05]{qletlogo.pdf}
  \end{center}

}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Accelerated Variant}
\frame{
\frametitle{Accelerated QR-Method}

We can accelerate the QR-Method by creating an artificial zero on the main diagonal of $A^k$s Hessenberg form $T$ at an iteration step $k$:

\begin{align*}
T^{\star} &= T - t _{p-1, p-1} I \\
T^{\star} &= QR \\
T         &= T^{\star} + t _{p-1, p-1} I
\end{align*}
}

\frame{
\frametitle{Accelerated QR-Method}
\begin{algorithm}[H]
\begin{algorithmic}
\Require square matrix $A \in \mathbb{R}^{p \times p}$
\State $T \gets \texttt{hessenberg}(A),\ conv \gets False$
\While{not $conv$}
    \State $Q, R \gets$ QR-Factorization of $T - t_{p-1, p-1} I$
    \State $T \gets RQ + t_{p-1, p-1}I$
    \If{$T$ is diagonal}
        \State $conv \gets True$
    \EndIf
\EndWhile
\Return $diag\left(T\right), Q$
\end{algorithmic}
\end{algorithm}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Analysis}
\subsection{Accuracy}
\frame{
\frametitle{Unit tests - Idea}
\begin{enumerate}
\item Construct a $p \times p$ matrix, with known Eigenvalues $\lambda_{true} \in \mathbb{R}^p$. To do this we can invert the spectral decomposition.
\item Run the implemented algorithm on it, obtain the computed Eigenvalues $\lambda_{algo} \in \mathbb{R}^p$.
\item Assess $L_1$-Norm: $|\lambda_{true} - \lambda_{algo}|$, pass the test if it is smaller than a threshold $\epsilon$
\end{enumerate}

Repeat the procedure $1000$ times.
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Efficiency}
\frame{
\frametitle{Time taken}
\begin{figure}
\begin{center}

  	\caption{\href {https://github.com/thsis/NIS18/blob/master/tests/tests_eigen.py}{Unit-tests: Time}  \includegraphics[scale=0.05]{qletlogo.pdf}}
  \includegraphics[width=11.5cm, height=5cm]{../media/plots/time_boxplot.png}
\end{center}
\end{figure}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame{
\frametitle{Iterations needed}
\begin{figure}
\begin{center}
\caption{\href {https://github.com/thsis/NIS18/blob/master/tests/tests_eigen.py}{Unit-tests: Iterations}  \protect\includegraphics[scale=0.05]{qletlogo.pdf}}
  \includegraphics[width=11.5cm, height=5cm]{../media/plots/iterations_boxplot.png}

\end{center}
\end{figure}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame[label=PCA-proof]{
\frametitle{PCA: proof}
The objective of \hyperlink{PCA-prop}{\beamergotobutton{PCA}}:
	$$
	max\ \delta^{\prime} Var \left(X\right) \delta \; s.t. \; \sum \delta_i^2 = 1
	$$
Corresponding Lagrangean:
    $$
    \mathcal{L}(Var \left(X\right), \delta, \lambda) =
    \delta^{\prime} Var \left(X\right) \delta - \lambda \left(\delta^{\prime}\delta - 1\right),
    $$
    where $\lambda \in \mathbb{R}^m$ \\
First order condition:
	\begin{align}
	\frac{\partial \mathcal{L}}{\partial \delta} &\stackrel{!}{=} 0 \notag\\
	2Var(X)\delta - 2\lambda_k \delta &\stackrel{!}{=} 0 \notag\\
	Var(X)\delta  &= \lambda_k \delta \notag
	\end{align}
Which is now reduced to a common Eigenvalue problem.
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame[label=LDA-proof]{
\frametitle{LDA: proof}
The objective of \hyperlink{LDA-prop}{\beamergotobutton{LDA}}:
  $$ max \ \frac{w^{\prime}S_B w}{w^{\prime}S_W w},$$
Which we can reformulate to:
  $$ max w^{\prime}S_B w \ s.t. w^{\prime}S_W w = 1. $$
Corresponding Lagrangean:
  $$ \mathcal{L}(w, S_B, S_W, \lambda) = w^{\prime}S_B w - \lambda \left(w^{\prime}S_W w - 1\right)$$
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame{
\frametitle{LDA: proof}
First order condition:
\begin{align*}
\frac{\partial \mathcal{L}}{\partial w} &\stackrel{!}{=} 0 \notag \\
2S_B w - 2 \lambda S_W w &\stackrel{!}{=} 0 \notag \\
S_{W}^{-1}S_B w &= \lambda w, \\
\end{align*}

which is known as a generalized Eigenvalue problem. We can redefine
\begin{align*}
S_B &= S_B^{\frac{1}{2}} S_B^{\frac{1}{2}} \\
v &= S_B^{\frac{1}{2}} w
\end{align*}
}
\frame{
\frametitle{LDA: proof}
We then get:
\begin{align*}
S_{W}^{-1}S_B w &= \lambda w \\
S_{W}^{-1}S_B^{\frac{1}{2}} \underbrace{S_B^{\frac{1}{2}} w}_v  &= \lambda w \\
S_B^{\frac{1}{2}} S_{W}^{-1}S_B^{\frac{1}{2}} v  &=\lambda \underbrace{S_B^{\frac{1}{2}} w}_v
\end{align*}
We can also rewrite this as:
$$S_B^{-\frac{1}{2}}S_{W}^{-1}S_B^{-\frac{1}{2}} v = \lambda v$$

Which now an Eigenvalue problem of a symmetric, positive semidefinite matrix \hyperlink{LDA-prop}{\beamergotobutton{back}}.

}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame[label=similarity_proof]{
\frametitle{Eigenvalues of similar matrices}
From the definition in (\ref{similarity-prop}) it follows immediately that a matrix $A$ with Eigenvalues $\lambda_1, \dots, \lambda_n$ is similar to the matrix $diag(\lambda_1, \dots, \lambda_n)$.

If $A$ and $B$ are similar, as in (\ref{similarity-prop}), it holds:
\begin{align*}
B - \lambda I &= P^{-1} B P - \lambda P^{-1} I P \notag \\
              &= A - \lambda I.
\end{align*}
 Hence $A$ and $B$ have the same eigenvalues. Additionally, important transformations are based around orthogonal matrices. If $Q$ is orthogonal and
\begin{equation*}
A = Q^{\prime} B Q,
\end{equation*}
$A$ and $B$ are said to be \textit{orthogonally similar} \hyperlink{similarity_prop}{\beamergotobutton{back}}.
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame[label=companion_exmpl]{
\frametitle{Companion-Matrix: Example}
Demonstrate that the companion matrix \hyperlink{companion_prop}{\beamergotobutton{back}}:
\begin{enumerate}
  \item corresponds to a polynomial.
  \item has eigenvalues equal to the roots of the polynomial.
\end{enumerate}
 $$A = \begin{bmatrix}
           0    & 1 \\
           -a_0 & -a_1 \\
       \end{bmatrix}$$

  \begin{align*}
      det \left(A - \lambda I\right) &= \begin{bmatrix}
                                            0 - \lambda    & 1 \\
                                            -a_0           & -a_1- \lambda \\
       \end{bmatrix} \\
                                     &= -\lambda\left(-a_1 - \lambda\right) + a_0 \\
                                     &= \lambda^2 + a_1 \lambda + a_0
  \end{align*}

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\frame[label=householder_proof]{
\frametitle{Householder Reflections: proof}
\hyperlink{householder_prop}{\beamergotobutton{back}}
Remember:
\begin{itemize}
\item $Q = I - 2 uu^{\prime}$.
\item $u$ $v$ are orthonormal.
\end{itemize}

\begin{align*}
Qx &= c_1 u + c_2 v - 2c_1 uuu^{\prime} - 2 c_2 v uu^{\prime} \\
   &= c_1 u + c_2 v - 2c_1 u^{\prime}uu - 2 c_2 u^{\prime} v u \\
   &= -c_1 u + c_2 v\\
   &= \tilde{x}
\end{align*}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame{
\frametitle{Sources}
\begin{thebibliography}{3}

\bibitem{NME}
Seffen B{\"o}rm and Christian Mehl.
Numerical Methods for Eigenvalue Problems.
Walter de Gruyter GmbH \& Co.KG, Berlin/Boston, 2012.

\bibitem{NLA}
James E. Gentle.
Numerical Linear Algebra for Applications in Statistics.
Springer Science + Business Media, New York, 2003.

\bibitem{MVA}
Wolfgang K. H{\"a}rdle and L{\'e}opold Simar.
Applied Multivariate Statistical Analysis.
Springer-Verlag Gmbh, Berlin, Heidelberg, 2015.

\end{thebibliography}
}

\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
% \usepackage{amscd, amsfonts, amsmath, amssymb, amstext, amsthm, caption, epsfig, fancyhdr, float, graphicx, latexsym, mathtools, multicol, multirow, algorithm, chngcntr}
\usepackage[english]{babel}
\usepackage{booktabs}

\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subfig}
\usepackage{xspace}
\usepackage{fourier}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usepackage{tkz-graph}
\usetikzlibrary{automata,arrows,positioning,calc}
\usetikzlibrary{positioning}
\usetikzlibrary{fit}
\usetikzlibrary{backgrounds}
\usetikzlibrary{calc}
\usetikzlibrary{shapes}
\usetikzlibrary{mindmap}
\usetikzlibrary{decorations.text}
\usetikzlibrary{snakes}

% \theoremstyle{definition} % insert bellow all blocks you want in normal text
% \newtheorem{definition}{Definition}

% tikzmark command, for shading over items
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20,
    text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20,
    text width=5em, text centered, rounded corners]
\tikzstyle{line} = [draw]
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
    minimum height=2em]

\usepackage[most]{tcolorbox}

\setbeamertemplate{blocks}[rounded][shadow=true] % use rounded blocks with standard beamer shadow

% Distributions.
\newcommand*{\UnifDist}{\mathsf{Unif}}
\newcommand*{\ExpDist}{\mathsf{Exp}}
\newcommand*{\DepExpDist}{\mathsf{DepExp}}
\newcommand*{\GammaDist}{\mathsf{Gamma}}
\newcommand*{\LognormalDist}{\mathsf{LogNorm}}
\newcommand*{\WeibullDist}{\mathsf{Weib}}
\newcommand*{\ParetoDist}{\mathsf{Par}}
\newcommand*{\NormalDist}{\mathsf{Norm}}

\newcommand*{\GeometricDist}{\mathsf{Geom}}
\newcommand*{\NegBinomialDist}{\mathsf{NegBin}}
\newcommand*{\PoissonDist}{\mathsf{Poisson}}
\newcommand*{\BivariatePoissonDist}{\mathsf{BPoisson}}
\newcommand*{\CyclicalPoissonDist}{\mathsf{CPoisson}}

\newcommand*{\iid}{\textbf{iid}\@\xspace}
\newcommand*{\pdf}{\textbf{pdf}\@\xspace}
\newcommand*{\cdf}{\textbf{cdf}\@\xspace}
\newcommand*{\pmf}{\textbf{pmf}\@\xspace}
\newcommand*{\abc}{{\textbf{abc}}\@\xspace}
\newcommand*{\smc}{\textbf{smc}\@\xspace}
\newcommand*{\mcmc}{\textbf{mcmc}\@\xspace}
\newcommand*{\ess}{\textbf{ess}\@\xspace}
\newcommand*{\mle}{\textbf{mle}\@\xspace}
\newcommand*{\bic}{\textbf{bic}\@\xspace}
\newcommand*{\kde}{\textbf{kde}\@\xspace}
\newcommand*{\glm}{\textbf{glm}\@\xspace}
\newcommand*{\xol}{\textbf{xol}\@\xspace}
\newcommand*{\cpu}{\textbf{cpu}\@\xspace}
\newcommand*{\gpu}{\textbf{gpu}\@\xspace}
\newcommand*{\arm}{\textbf{arm}\@\xspace}

\def \si {\sigma}
\def \la {\lambda}
\def \al {\alpha}
% \def\e*{\end{eqnarray*}}
\def \di{\displaystyle}

\def \E{\mathbb E}
\def \N{\mathbb N}
\def \Z{\mathbb Z}
\def \NZ{\mathbb{N}_0}
\def \I{\mathbb I}
\def \w{\widehat}
\def \P {\mathbb P}
\def \V{\mathbb V}

\newcommand{\CL}{\mathbb{C}}
\newcommand{\RL}{\mathbb{R}}
\newcommand{\nat}{{\mathbb N}}
\newcommand{\Laplace}{\mathscr{L}}
\newcommand{\e}{\mathrm{e}}
\newcommand{\ve}{\bm{\mathrm{e}}} % vector e

\renewcommand{\L}{\mathcal{L}} % e.g. L^2 loss.

\newcommand{\ih}{\mathrm{i}}
\newcommand{\oh}{{\mathrm{o}}}
\newcommand{\Oh}{{\mathcal{O}}}
\newcommand{\Exp}{\mathbb{E}}

\newcommand{\Norm}{\mathcal{N}}
\newcommand{\LN}{\mathcal{LN}}
\newcommand{\SLN}{\mathcal{SLN}}

\renewcommand{\Pr}{\mathbb{P}}
\newcommand{\Ind}{\mathbb I}
\newcommand\bfsigma{\bm{\sigma}}
\newcommand\bfSigma{\bm{\Sigma}}
\newcommand\bfLambda{\bm{\Lambda}}
\newcommand{\stimes}{{\times}}
\def \limsup{\underset{n\rightarrow+\infty}{\overline{\lim}}}
\def \liminf{\underset{n\rightarrow+\infty}{\underline{\lim}}}

% vertical separator macro
\newcommand{\vsep}{
  \column{0.0\textwidth}
    \begin{tikzpicture}
      \draw[very thick,black!10] (0,0) -- (0,7.3);
    \end{tikzpicture}
}
\newcommand\blfootnote[1]{%
  \begingroup
  \renewcommand\thefootnote{}\footnote{#1}%
  \addtocounter{footnote}{-1}%
  \endgroup
}

% More space between lines in align
% \setlength{\mathindent}{0pt}

% Beamer theme
\usetheme{ZMBZFMK}
\usefonttheme[onlysmall]{structurebold}
\mode<presentation>
\setbeamercovered{transparent=10}

% align spacing
\setlength{\jot}{0pt}

\setbeamertemplate{navigation symbols}{}%remove navigation symbols

\title[BLOCKASTICS]{Stochastic models for blockchain analysis}
\author{Pierre-O. Goffard}
\institute[ISFA]{Institut de Science Financières et d'Assurances\\
 \texttt{pierre-olivier.goffard@univ-lyon1.fr}
}
\date{\today}
% \titlegraphic{\includegraphics[width=2.5cm]{../../Figures/bfs_logo.png}}

\begin{document}
\begin{frame}
  \titlepage
\end{frame}
\begin{frame}
  \tableofcontents
\end{frame}

\section{Introduction}
\begin{frame}{Blockchain}
A decentralized data ledger made of blocks maintained by achieving consensus in a P2P network.
\begin{columns}
\begin{column}{0.5\textwidth}
% \small

\begin{itemize}
  \item Decentralized
  \item Public/private
  \item Permissionned/permissionless
  \item Immutable
  \item Incentive compatible
\end{itemize}
\end{column}
\begin{column}{0.5\textwidth}
\begin{center}
\begin{tikzpicture}[-, >=stealth', auto, semithick, node distance=01cm]
\tikzstyle{every edge}=[snake=expanding waves,segment length=1mm,segment angle=10, draw]

\tikzstyle{full node}=[circle, fill=tublue,draw=tublue,thick,text=black,scale=0.8]
\tikzstyle{light node}=[circle, fill=white,draw=tublue,thick,text=black,scale=0.8]
\node[full node]    (1)                     {};
\node[full node]    (2)[above right of=1]         {};
\node[full node]    (3)[above left of=1]         {};
\node[full node]    (4)[below of=1]         {};
\node[full node]    (5)[right of=4]         {};
\node[full node]    (6)[below of=4]         {};
\node[light node]    (7)[left of=1]         {};
\node[light node]    (8)[right of=2]         {};
\node[light node]    (9)[left of=4]         {};
\node[light node]    (10)[above right of=5]         {};
\node[light node]    (11)[ right of=5]         {};
\node[light node]    (12)[ below right of=5]         {};
% \node[light node]    (4)[above of=2]         {};
\path

(1) edge node{} (2)
    edge node{} (3)
    edge node{} (7)
    ;
\path
(5) edge node{} (10)
    edge node{} (11)
    edge node{} (12)
    ;
    \path
(4) edge node{} (5)
    edge node{} (1)
    edge node{} (9)
    edge node{} (6)
    ;
    \path
(2) edge node{} (8)
    ;
\end{tikzpicture}
\end{center}
\end{column}
\end{columns}

\vspace{0.2cm}
\begin{tcolorbox}[enhanced,drop shadow, title=Focus of the talk]
Public and permissionless blockchain equipped with the Proof-of-Work protocol.
\end{tcolorbox}
\end{frame}

\begin{frame}{Consensus protocols}
The mechanism to make all the nodes agree on a common data history.\\
\vspace{0.3cm}
The three dimensions of blockchain systems analysis
\begin{enumerate}
  \item Efficiency
  \begin{itemize}
    \item Throughputs
    \item Transaction confirmation time
  \end{itemize}
  \item Decentralization
  \begin{itemize}
    \item Fair distribution of the accounting right
  \end{itemize}
  \item Security
  \begin{itemize}
    \item Resistance to attacks
  \end{itemize}
\end{enumerate}
\footnotesize
\begin{thebibliography}{1}
\bibitem{Fu2020}
X.~Fu, H.~Wang, and P.~Shi, ``A survey of blockchain consensus algorithms:
  mechanism, design and applications,'' {\em Science China Information
  Sciences}, vol.~64, nov 2020.
\end{thebibliography}
\end{frame}
\begin{frame}{Applications of blockchain: Cryptocurrency}
\begin{columns}
\begin{column}{0.5\textwidth}

{\footnotesize
\begin{thebibliography}{1}
\bibitem{Na08}
S.~Nakamoto, ``Bitcoin: A peer-to-peer electronic cash system.'' Available at
  \href{https://bitcoin.org/bitcoin.pdf}{https://bitcoin.org/bitcoin.pdf},
  2008.
\end{thebibliography}
}
\end{column}
\begin{column}{0.5\textwidth}  %%<--- here
    \begin{center}
     \includegraphics[width=0.5\textwidth]{../../Figures/bitcoin-6284869_1920.png}
     \end{center}
\end{column}
\end{columns}

\begin{itemize}
  \item Transaction anonymity
  \item Banking and reliable currency in certain regions of the world
  \item Money Transfer worldwide (at low fare)
  \item No need for a thrusted third party
\end{itemize}
\end{frame}
\begin{frame}{Decentralized finance}
DEFI creates new financial architecture
\begin{columns}
\begin{column}{0.5\textwidth}
\begin{itemize}
\item[+] Non custodial
\item[+] Anonymous
\item[+] Permisionless
\item[+] openly auditable
\end{itemize}
\end{column}
\begin{column}{0.5\textwidth}
\begin{itemize}
\item[-] Unregulated
\item[-] Tax evasion
\item[-] Fraud
\item[-] Money laundering
\end{itemize}
\end{column}
\end{columns}
\vspace{0.5cm}
Extends the Bitcoin promises to more complex financial operations
\begin{itemize}
  \item Collateralized lending
  \item Decentralized Exchange Platform
  \item Tokenized assets
  \item Fundraising vehicle (ICO, STO, ...)
\end{itemize}
\vspace{0.3cm}
\scriptsize
\begin{thebibliography}{1}

\bibitem{werner2021sok}
S.~M. Werner, D.~Perez, L.~Gudgeon, A.~Klages-Mundt, D.~Harz, and W.~J.
  Knottenbelt, ``Sok: Decentralized finance (defi),'' 2021.

\end{thebibliography}

\end{frame}
\begin{frame}{What's inside a block?}
A block consists of
\begin{itemize}
\item a header
\item a list of "transactions" that represents the information recorded through the blockchain.
\end{itemize}
The header usually includes
\begin{itemize}
\item the date and time of creation of the block,
\item the block height which is the index inside the blockchain,
\item the hash of the block
\item the hash of the previous block.
\end{itemize}
\begin{tcolorbox}[enhanced,drop shadow, title=Question]
What is the hash of a block?
\end{tcolorbox}
\end{frame}
\begin{frame}{Cryptographic Hash function}
\small
A function that maps data of arbitratry size (message) to a bit array of fixed size (hash value)
$$
h:\{0,1\}^\ast\mapsto \{0,1\}^d.
$$
A good hash function is
\begin{itemize}
\item deterministic
\item quick to compute
\item One way
\begin{itemize}
  \scriptsize
\item[$\hookrightarrow$] For a given hash value $\overline{h}$ it is hard to find a message $m$ such that
$$
h(m) = \overline{h}
$$
\end{itemize}
\item Colision resistant
\begin{itemize}
\item[$\hookrightarrow$] Impossible to find $m_1$ and $m_2$ such that
$$
h(m_1) = h(m_2)
$$
\end{itemize}
\item Chaotic
$$m_1\approx m_2\Rightarrow  h(m_1) \neq h(m_2)$$
\end{itemize}
\end{frame}
\begin{frame}{SHA-256}
The SHA-256 function which converts any message into a hash value of $256$ bits.
\begin{tcolorbox}[enhanced,drop shadow, title=Example]
The hexadecimal digest of the message
$$
\texttt{Sweet home Alabama}
$$
is
\footnotesize
$$
\texttt{50f3257a3d22a56247a8978fd2505e8cdd64e1cb06e52c941d09e234722dc275}
$$
\end{tcolorbox}
\end{frame}
\begin{frame}{Mining a block}
\begin{figure}[!ht]
    \includegraphics[width = \textwidth]{../../Figures/block_not_mined.png}
    \captionsetup{width=0.8\textwidth}
    \centering
    \caption{A block that has not been mined yet.}
    \label{fig:block_not_mined}
\end{figure}
\end{frame}
\begin{frame}{Mining a block}
The maximum value for a 256 bits number is
$$
T_\text{max} = 2^{256}-1 \approx 1.16e^{77}.
$$
Mining consists in drawing at random a nonce
$$
\text{Nonce} \sim \text{Unif}(\{0,\ldots, 2^{32}-1\}),
$$
until
$$
h(\text{Nonce}|\text{Block info})<T,
$$
where $T$ is referred to as the target.
\begin{tcolorbox}[enhanced,drop shadow, title=Difficulty of the cryptopuzzle]
$$
D = \frac{T_{\max}}{T}.
$$
\end{tcolorbox}

\end{frame}
\begin{frame}{Mining a block}
If we set the difficulty to $D = 2^4$ then the hexadecimal digest must start with at least $1$ leading $0$
\begin{figure}[!ht]
    \includegraphics[width = \textwidth]{../../Figures/block_mined.png}
    \captionsetup{width=0.8\textwidth}
    \centering
    \caption{A mined block with a hash value having on leading zero.}
    \label{fig:block_mined}
\end{figure}
The number of trial is geometrically distributed
\begin{itemize}
\item Exponential inter-block times
\item Lenght of the blockchain = Poisson process
\end{itemize}
\end{frame}
\begin{frame}{Bitcoin protocol}
\begin{itemize}
  \item One block every 10 minutes on average
  \item Depends on the hashrate of the network
  \item Difficulty adjustment every 2,016 blocks ($\approx$ two weeks)
  \item Reward halving every 210,000 blocks
\end{itemize}
Check out \url{https://www.bitcoinblockhalf.com/}

\end{frame}
\section{Double spending attack}
\begin{frame}{Double spending attack}
\scriptsize
\begin{enumerate}
\item Mary transfers 10 BTCs to John
\item The transaction is recorded in the public branch of the blockchain and John ships the good.
\item Mary transfers to herself the exact same BTCs
\item The malicious transaction is recorded into a private branch of the blockchain
\begin{itemize}
  \scriptsize
\item Mary has friends among the miners to help her out
\item The two chains are copycat up to the one transaction
\end{itemize}
\end{enumerate}
\begin{tcolorbox}[enhanced,drop shadow, title=Fact (Bitcoin has only one rule)]
The longest chain is to be trusted
\end{tcolorbox}
\end{frame}
\begin{frame}{Double spending in practice}
\scriptsize
Vendor are advised to wait for $\alpha\in\mathbb{N}$ of confirmations so that the honest chain is ahead of the dishonest one.
\begin{center}
\begin{tikzpicture}[-, >=stealth', auto, semithick, node distance=1cm]
% \tikzstyle{block} = [rectangle, draw, fill=blue!20,
%     text width=5em, text centered, rounded corners]
\tikzstyle{block}=[rectangle, fill=black,draw=black,thick,text=black,scale=0.6]
\tikzstyle{block}=[rectangle, fill=white,draw=black,thick,text=black,scale=0.8]
\tikzstyle{confirmed block}=[rectangle, fill=white,draw=blue,thick,text=black,scale=0.8]
\tikzstyle{bad block}=[rectangle, fill=white,draw=red,thick,text=black,scale=0.8]
\node[block]    (1)                     {\tiny $\text{M}\rightarrow \text{J}$};
\node[block]    (2)[right of=1]                     {};
\node[block]    (3)[right of=2]                     {};
\node[block]    (4)[right of=3]                     {};
\node[confirmed block]    (5)[right of=4]                     {};

\node[bad block]    (6)[below of=1]         {\tiny $\text{M}\rightarrow \text{M}$};
\node[block]    (7)[right of=6]         {};
\node[block]    (8)[right of=7]         {};
\path
(1) edge[ left]     node{}     (2)
(2) edge[ left]     node{}     (3)
(3) edge[ left]     node{}     (4)
(4) edge[ left]     node{}     (5)
(6) edge[ left]     node{}     (7)
(7) edge[ left]     node{}     (8);

\end{tikzpicture}
\end{center}
In the example, vendor awaits $\alpha = 4$ confirmations, the honest chain is ahead of the dishonest one by $z = 2$ blocks.
\begin{tcolorbox}[enhanced,drop shadow, title=Fact (PoW is resistant to double spending)]
\begin{itemize}
\item Attacker does not own the majority of computing power
\item Suitable $\alpha$
\end{itemize}
Double spending is unlikely to succeed.
\end{tcolorbox}
\tiny
\begin{thebibliography}{1}
\bibitem{Na08}
S.~Nakamoto, ``Bitcoin: A peer-to-peer electronic cash system.'' Available at
  \href{https://bitcoin.org/bitcoin.pdf}{https://bitcoin.org/bitcoin.pdf},
  2008.

\end{thebibliography}

\end{frame}
\begin{frame}{Mathematical set up}
\footnotesize
Assume that
\begin{itemize}
\item $R_0=z\geq1$ (the honest chain is z blocks ahead)
\item at each time unit a block is created
\begin{itemize}
  \footnotesize
\item[$\hookrightarrow$] in the honest chain with probability $p$
\item[$\hookrightarrow$] in the dishonest chain with probability $q=1-p$
\end{itemize}
\end{itemize}
The process $(R_n)_{n\geq0}$ is a random walk on $\mathbb{Z}$ with
$$R_n=z+Y_1+\ldots+Y_n,$$
where $Y_1,\ldots,Y_n$ are the \textbf{i.i.d.} steps of the random walk.

\end{frame}
\begin{frame}{Double spending rate of success}
\scriptsize
Double spending occurs at time
$$
\tau_z=\inf\{n\in \mathbb{N}\text{ ; }R_n=0\}.
$$
\begin{tikzpicture}
  %Origin and axis
  \coordinate (O) at (0,0);
  \draw[->] (-1,0) -- (9,0) coordinate[label = {below:$n$}] (xmax);
  \draw[->] (0,-0.5) -- (0,3) coordinate[label = {left:$Z_n$}] (ymax);
  %Lower linear boundary

  %Stochastic process trajectory

  \draw (0,0) node[tublue,left] {} node{};
  \draw[very thick,tublue,-] (0,1) -- (1,1) node[pos=0.5, above] {} ;
  \draw[very thick,dashed,tublue] (1,1) -- (1,1.5) node[pos=0.5, right] {};
  \draw[very thick,tublue,-] (1,1.5) -- (2,1.5) node[pos=0.5, above] {};
  \draw[very thick,dashed,tublue] (2,1.5) -- (2,2) node[pos=0.5, right] {};
  \draw[very thick,tublue,-] (2,2) -- (3,2) node[pos=0.5, above] {};
  \draw[very thick,dashed,tublue] (3,2) -- (3,1.5) node[pos=0.5, right] {};
  \draw[very thick,tublue,-] (3,1.5) -- (4,1.5)node[pos=0.5, above] {};
  \draw[very thick,dashed,tublue] (4,1.5) -- (4,1) node[pos=0.5, right] {};
  \draw[very thick,tublue,-] (4,1) -- (5,1) node[pos=0.5, above] {};
  \draw[very thick,dashed,tublue] (5,1) -- (5,0.5) node[pos=0.5, right] {};
  \draw[very thick,tublue,-] (5,0.5) -- (6,0.5) node[pos=0.5, above] {};
  \draw[very thick,dashed,tublue,-] (6,0.5) -- (6,1) node[pos=0.5, above] {};
   \draw[very thick,tublue,-] (6,1) -- (7,1) node[pos=0.5, above] {};
    \draw[very thick,dashed,tublue,-] (7,1) -- (7,0.5) node[pos=0.5, above] {};
     \draw[very thick,tublue,-] (7,0.5) -- (8,0.5) node[pos=0.5, above] {};
     \draw[very thick,dashed,tublue,-] (8,0.5) -- (8,0) node[pos=0.5, above] {};
  %Jump Times
  \draw (1,0) node[black,below] {$1$} node{ \color{black}$\bullet$};
  \draw (2,0) node[black,below] {$2$} node{ \color{black}$\bullet$};
  \draw (3,0) node[black,below] {$3$} node{ \color{black}$\bullet$};
  \draw (4,0) node[black,below] {$4$} node{ \color{black}$\bullet$};
  \draw (5,0) node[black,below] {$5$} node{ \color{black}$\bullet$};
  \draw (6,0) node[black,below] {$6$} node{ \color{black}$\bullet$};
  \draw (7,0) node[black,below] {$7$} node{ \color{black}$\bullet$};
  \draw (8,0) node[black,below] {$8$} node{ \color{black}$\bullet$};
  %Level of the counting process
   \draw (0,0) node[black,below left] {$0$} node{ \color{black}$\bullet$};
   \draw (0,0.5) node[black,left] {$1$} node{ \color{black}$\bullet$};
   \draw (0,1) node[black,left] {$z=2$} node{ \color{black}$\bullet$};
   \draw (0,1.5) node[black,left] {$3$} node{ \color{black}$\bullet$};
   \draw (0,2) node[black,left] {$4$} node{ \color{black}$\bullet$};
   \draw (0,2.5) node[black,left] {$5$} node{ \color{black}$\bullet$};

  % %Aggregated Capital gains
%  \draw (0,1.5) node[blue,below right] {$\mu_1$} node{ \color{blue}$-$};
%  \draw (0,2.25) node[blue,left] {$\mu_2$} node{ \color{blue}$-$};
%  \draw (0,3.75) node[blue,left] {$\mu_3$} node{ \color{blue}$-$};
  %Ruin time = First-crossing time time
%  \draw (5,0) node[black,above right] {$\tau_u$} node{ \color{black}$\times$};
%  \draw[dotted,black] (0,3.28) -- (5,3.28);
%  \draw[dotted,black] (5,0) -- (5,3.28);
\end{tikzpicture}
\begin{tcolorbox}[enhanced,drop shadow, title=Double spending theorem]
If $p>q$ then the double-spending probability is given by
$$
\phi(z) = \mathbb{P}(\tau_z<\infty)=\left(\frac{q}{p}\right)^{z}.
$$
\end{tcolorbox}

\end{frame}
\begin{frame}{Refinements of the double spending problem}
\scriptsize
The number of blocks $M$ found by the attacker until the honest miners find $\alpha$ blocks is a negative binomial random variable with \pmf
$$
\mathbb{P}(M = m) = \binom{\alpha+m-1}{m}p^\alpha q^m,\text{ }m\geq0.
$$
The number of block that the honest chain is ahead of the dishonest one is given by
$$
Z= (\alpha-M)_+.
$$
Applying the law of total probability yields the probability of successful double spending with
$$
\mathbb{P}(\text{Double Spending}) = \mathbb{P}(M\geq \alpha) + \sum_{m = 0}^{\alpha - 1}\binom{\alpha+m-1}{m}q^{\alpha} p^{m}.
$$
\tiny

\begin{thebibliography}{1}
  \bibitem{rosenfeld2014analysis}
M.~Rosenfeld, ``Analysis of hashrate-based double spending,'' {\em arXiv
  preprint arXiv:1402.2009}, 2014.
  \bibitem{GRUNSPAN2018}
C.~Grunspan and R.~Perez-Marco, ``Double spend race,'' {\em
  International Journal of Theoretical and Applied Finance}, vol.~21,
  p.~1850053, dec 2018.
\end{thebibliography}

\end{frame}
\begin{frame}{Refinements of the double spending problem}
\scriptsize
Let the length of honest and dishonest chain be driven by counting processes
\begin{itemize}
\item Honest chain $\Rightarrow$ $z+N_t\text{ , }t\geq0$, where $z\geq1$.
\item Malicious chain $\Rightarrow$ $M_t\text{ , }t\geq0$
\item Study the distribution of the first-\textit{rendez-vous} time
$$
\tau_z=\inf\{t\geq0\text{ , } M_t=z+N_t\}.
$$
\end{itemize}
If $N_t\sim\text{Pois}(\lambda t)$ and $M_t\sim\text{Pois}(\mu t)$ such that $\lambda>\mu$ then
$$
\phi(z) = \left(\frac{\mu}{\lambda}\right)^z,\text{ }z\geq 0.
$$
\tiny
\begin{thebibliography}{1}

\bibitem{Goffard2019}
P.-O. Goffard, ``Fraud risk assessment within blockchain transactions,'' {\em
  Advances in Applied Probability}, vol.~51, pp.~443--467, jun 2019.
\newblock \url{https://hal.archives-ouvertes.fr/hal-01716687v2}.

\bibitem{Bowden2020}
R.~Bowden, H.~P. Keeler, A.~E. Krzesinski, and P.~G. Taylor, ``Modeling and
  analysis of block arrival times in the bitcoin blockchain,'' {\em Stochastic
  Models}, vol.~36, pp.~602--637, jul 2020.
\end{thebibliography}

\end{frame}

\section{Insurance risk theory}
\begin{frame}{Cramer-Lunberg model}
\begin{columns}
\begin{column}{0.5\textwidth}
\scriptsize
The financial reserves of an insurance company over time have the following dynamic
\begin{equation*}
R_t = z +ct - \sum_{i = 1}^{N_t}U_i\text{, }t\geq0,
\end{equation*}
where
\begin{itemize}
  \item $z>0$ denotes the initial reserves
  \item $c$ is the premium rate
  \item $(N_t)_{t\geq0}$ is a counting process that models the claim arrival
  \begin{itemize}
    \scriptsize
    \item[$\hookrightarrow$]  Poisson process with intensity $\lambda$
  \end{itemize}
  \item The $U_i$'s are the randomly sized compensations
  \begin{itemize}
    \scriptsize
    \item[$\hookrightarrow$] non-negative, \textbf{i.i.d.}
  \end{itemize}
\end{itemize}
\end{column}
\begin{column}{0.5\textwidth}
\begin{tikzpicture}
  %Origin and axis
  \coordinate (O) at (0,0);
  \draw[->] (-0.5,0) -- (5.5,0) coordinate[label = {below:\scriptsize$t$}] (xmax);
  \draw[->] (0,-0.5) -- (0,4) coordinate[label = {right:\scriptsize$R_t$}] (ymax);
   %Initial reserves
  \draw (0,2) node[black,left] {\scriptsize$z$} node{};
 % % %Length of the honest chain
  \draw[thick, tublue,-] (0,2) -- (2,3) node[pos=0.5, above] {};
  \draw[thick, dashed, tublue] (2,3) -- (2,1) node[pos=0.5, left] {\scriptsize\color{black}$U_1$};
  \draw[thick, tublue] (2,1) -- (3,1.5) node[pos=0.5, above] {};
  \draw[thick, dashed, tublue] (3,1.5) -- (3, 0.5) node[pos=0.5, left] {\scriptsize\color{black}$U_2$};
  \draw[thick, tublue] (3,0.5) -- (5, 1.5) node[pos=0.5, above] {};
   \draw[thick, dashed, tublue] (5,1.5) -- (5, -0.5) node[pos=0.5,above left] {\scriptsize\color{black}$U_3$};

  %Block finding Times
  \draw (2,0) node[black,below] {\scriptsize$T_1$} node{ \color{black}$\bullet$};
  \draw (3,0) node[black,below] {\scriptsize$T_2$} node{ \color{black}$\bullet$};
  \draw (5,0) node[black,below left] {\scriptsize$\tau_z$} node{ \color{black}$\bullet$};
\end{tikzpicture}
\end{column}
\end{columns}

\end{frame}
\begin{frame}{Ruin probabilities}
\scriptsize
Define the ruin time as
$$
\tau_z = \inf\{t\geq0\text{ ; }R_t <0\}
$$
and the ruin probabilities as
$$
\psi(z,t) = \mathbb{P}(\tau_z < t)\text{ and }\psi(z) = \mathbb{P}(\tau_z < \infty)
$$
We look for $z$ such that
$$
\mathbb{P}(\text{Ruin}) = \alpha\text{ (0.05)},
$$
given that
$$
c=(1+\eta)\lambda\mathbb{E}(U),
$$
with
$$\eta>0\text{ (net profit condition)}$$
otherwise
$$\psi(z)=1.$$

\tiny
\begin{thebibliography}{1}

\bibitem{Asmussen_2010}
S.~Asmussen and H.~Albrecher, {\em Ruin Probabilities}.
\newblock {WORLD} {SCIENTIFIC}, sep 2010.

\end{thebibliography}

\end{frame}

\begin{frame}{Ruin probability computation}
\scriptsize
Let
$$
S_t = z - R_t,\text{ }t\geq0
$$
\begin{tcolorbox}[enhanced,drop shadow, title=Theorem (Wald exponential martingale)]
If $(S_t)_{t\geq0}$ is a L\'evy process or a random walk then
$$
\{\exp\left[\theta S_t-t\kappa(\theta)\right]\text{ , }t\geq0\},\text{ is a martingale,}
$$
where $\kappa(\theta)=\log\mathbb{E}\left(e^{\theta S_1}\right)$.
\end{tcolorbox}
\begin{tcolorbox}[enhanced,drop shadow, title=Theorem (Representation of the ruin probability)]

If $S_t\overset{\textbf{a.s.}}{\rightarrow} -\infty$, and there exists $\gamma>0$ such that $\{e^{\gamma S_t}\text{ , }t\geq0\}$ is a martingale then
$$
\mathbb{P}(\tau_z<\infty)=\frac{e^{-\gamma z}}{\mathbb{E}\left[e^{\gamma \xi(z)}|\tau_z<\infty\right]},
$$
where $\xi(z)=S_{\tau_z}-z\text{ denotes the deficit at ruin.}$
\end{tcolorbox}
\end{frame}
\begin{frame}{Sketch of Proof}
\scriptsize
\begin{itemize}
\item Because of the net profit condition $S_t = \sum_{i=1}^{N_t}U_i-ct\rightarrow -\infty$ as $t\rightarrow\infty$
\item $(S_t)_{t\geq0}$ is a Lévy process, let $\gamma$ be the (unique, positive) solution to
$$
\kappa(\theta) = 0\text{ (Cramer-Lundberg equation)}.
$$
\item  $(e^{\gamma S_t})_{t\geq0}$ is a Martingale then apply the Optional stopping theorem at $\tau_z$.

\end{itemize}
\end{frame}
\section{Link to double spending}
\begin{frame}{Double spending in Satoshi's framework}
\scriptsize
\begin{itemize}
\item The risk reserve process is $R_t=z+Y_1+\ldots+Y_t.$
\item The claim surplus process is $S_t=-(Y_1+\ldots+Y_t).$
\item $\kappa(\theta)=0$ is equivalent to
$$pe^{-\theta}+qe^{\theta}=1.$$
\begin{itemize}
\item[$\hookrightarrow$]\scriptsize $\gamma=\log(p/q).$
\end{itemize}
\item If $p>q$ then $S(t)\rightarrow - \infty$.
\item  $\xi(z)=S_{\tau_z}-z=0$ \textbf{a.s}.
\end{itemize}
Thus,
$$\mathbb{P}(\tau_z<\infty)=\left(\frac{q}{p}\right)^{z}.$$
\end{frame}

\begin{frame}{Double spending with Poisson processes}
\begin{columns}
\begin{column}{0.5\textwidth}
\scriptsize
\begin{itemize}
\item Suppose that
$$
N_t\sim\text{Pois}(\lambda t)\text{ and }M_t\sim\text{Pois}(\mu t)
$$
such that $\lambda>\mu$.
\item The risk reserve process is $R_t=z+N_t-M_t.$
\item The claim surplus process is $S_t=M_t-N_t.$
\end{itemize}
\begin{tcolorbox}[enhanced,drop shadow, title=Fact]
The difference of two Poisson processes is not a Poisson process, However it is L\'evy!
\end{tcolorbox}
\end{column}
\begin{column}{0.5\textwidth}
\begin{tikzpicture}
  %Origin and axis
  \coordinate (O) at (0,0);
  \draw[->] (-0.5,0) -- (5.5,0) coordinate[label = {above:\scriptsize$t$}] (xmax);
  \draw[->] (0,-0.5) -- (0,5) coordinate[label = {right:\scriptsize$n$}] (ymax);
 %Length of the honest chain
  \draw[thick,tublue,-] (0,3) -- (2,3) node[pos=0.5, above] {} ;
  \draw[thick,tublue] (2,3) -- (2,4) node[pos=0.5, above] {};
  \draw[thick,tublue] (2,4) -- (5.5,4) node[pos=0.5, right] {};
  % %Length of the Malicious chain
  \draw[very thick,dashed,red,-] (0,0) -- (0.75,0) node[pos=0.5, above] {} ;
  \draw[very thick,dashed,red] (0.75,0) -- (0.75,1) node[pos=0.5, right] {};
  \draw[very thick,dashed,red] (0.75,1) -- (1.25,1) node[pos=0.5, above] {};
  \draw[very thick,dashed,red] (1.25,1) -- (1.25,2) node[pos=0.5, right] {};
  \draw[very thick,dashed,red] (1.25,2) -- (2.5,2) node[pos=0.5, above] {};
  \draw[very thick,dashed,red] (2.5,2) -- (2.5,3) node[pos=0.5, right] {};
  \draw[very thick,dashed,red] (2.5,3) -- (5,3) node[pos=0.5, right] {};
  \draw[very thick,dashed,red] (5,3) -- (5,4) node[pos=0.5, above] {};
  \draw[very thick,dashed,red] (5,4) -- (5.5,4) node[pos=0.5, above] {};
  %Jump Times of the malicious chain
  \draw (0.75,0) node[red,below] {\scriptsize$S_1$} node{ \color{red}$\bullet$};
  \draw (1.25,0) node[red,below] {\scriptsize$S_2$} node{ \color{red}$\bullet$};
  \draw (2.5,0) node[red,below] {\scriptsize$S_3$} node{ \color{red}$\bullet$};
  \draw (5,0) node[black,below] {\scriptsize$S_4=\tau_z$} node{ \color{black}$\bullet$};
  % %Jump Times of the honest chain
  \draw (2,0) node[tublue,below] {\scriptsize$T_1$} node{ \color{tublue}$\bullet$};
  % %Aggregated Capital gains
  \draw (0,1) node[black,left] {\scriptsize$1$} node{ \color{black}$-$};
  \draw (0,2) node[black,left] {\scriptsize$2$} node{ \color{black}$-$};
  \draw (0,3) node[black,left] {\scriptsize$z$} node{};
  \draw (0,4) node[black,left] {\scriptsize$4$} node{ \color{black}$-$};
  % %Ruin time = First-meeting time
  % \draw (7,0) node[black,below] {$\tau_z$} node{ \color{black}$\times$};
  % \draw[dotted,black] (7,3) -- (7,0);
\end{tikzpicture}
\end{column}
\end{columns}
\end{frame}
\begin{frame}{Double spending with Poisson processes}

\begin{itemize}
\item $\kappa(\theta)=0$ is equivalent to
$$
\mu e^{\theta}+\lambda e^{-\theta}-(\lambda+\mu)=0.
$$

\begin{itemize}
\item[$\hookrightarrow$] $\gamma=\log(\lambda/\mu).$
\end{itemize}
\item If $\lambda>\mu$ then $S_t\rightarrow - \infty$.
\item $\xi(z)=S_{\tau_z}-z=0$ \textbf{a.s}.
\end{itemize}
Thus
$$\mathbb{P}(\tau_z<\infty)=\left(\frac{\mu}{\lambda}\right)^{z}.$$

\end{frame}

\begin{frame}{Double spending cost}
\scriptsize
Mining cryptocurrency in PoW equipped blockchain is energy consuming
\begin{itemize}
\item[$\hookrightarrow$] Operational cost for miners
\end{itemize}
Per time unit a miner pays
$$
c = \pi_W\cdot W\cdot q,
$$
where
\begin{itemize}
  \item $\pi_W$ is the electricty price per kWh
  \item $W$ is the consumption of the network \url{https://cbeci.org/}
  \item  $q$ is the attacker's hashpower
\end{itemize}
\begin{tcolorbox}[enhanced,drop shadow, title=Fact]
The cost of double spending is $c\cdot \tau_z$.
\end{tcolorbox}
\begin{tcolorbox}[enhanced,drop shadow, title=Theorem (\textbf{P.d.f.} of the double spending time)]
If $\{N_t\text{ , }t\geq0\}$ is a Poisson process then the \textbf{p.d.f.} of $\tau_z$ is given by
\begin{equation*}
f_{\tau_z}(t)=\mathbb{E}\left[\frac{z}{z+N_t}f_{S_{N_t+z}}(t)\right],\text{ for }t\geq0.
\end{equation*}
\end{tcolorbox}
\end{frame}
\begin{frame}{Sketch of the proof}
\scriptsize
Let's condition upon the values of $N_t$,
\begin{itemize}
  \item if $N_t=0$ then
  $$\tau_z = S_z\text{ and }f_{\tau_z|N_t=0}(t) = f_{S_z}(t)$$
  \item If $N_t = n$ for $n\geq 1$ then
  $$
  \{\tau_z = t\} = \bigcup_{k = 1}^n\{T_k\leq S_{z+k-1}\}\cup\{S_{n+z} = t\}
  $$
We have
\begin{eqnarray*}
f_{\tau_z|N_t = n}(t) &=& \mathbb{P}(U_{1:n}\leq S_z/t,\ldots,U_{n:n}\leq S_{z+n-1}/t\Big\rvert S_{n+z}=t)f_{S_{n+z}}(t)\\
&=&\frac{z}{z+n}f_{S_{n+z}}(t).
\end{eqnarray*}
Thanks to the properties of the Abel-Gontcharov polynomials.
\end{itemize}
\tiny
\begin{thebibliography}{1}

\bibitem{Goffard2019}
P.-O. Goffard, ``Fraud risk assessment within blockchain transactions,'' {\em
  Advances in Applied Probability}, vol.~51, pp.~443--467, jun 2019.
\newblock \url{https://hal.archives-ouvertes.fr/hal-01716687v2}.
\bibitem{Grunspan2021}
C.~Grunspan and R.~P{\'{e}}rez-Marco, ``{ON} {PROFITABILITY} {OF} {NAKAMOTO}
  {DOUBLE} {SPEND},'' {\em Probability in the Engineering and Informational
  Sciences}, pp.~1--15, feb 2021.

\bibitem{Brown2020}
M.~Brown, E.~Peköz, and S.~Ross, ``{BLOCKCHAIN} {DOUBLE}-{SPEND} {ATTACK}
  {DURATION},'' {\em Probability in the Engineering and Informational
  Sciences}, pp.~1--9, may 2020.

\bibitem{Jang2020}
J.~Jang and H.-N. Lee, ``Profitable double-spending attacks,'' {\em Applied
  Sciences}, vol.~10, p.~8477, nov 2020.

\end{thebibliography}
\end{frame}
\section{Conclusion}
\begin{frame}{Take home message}
Blockchain is an emerging technologies with great research opportunities for researchers of many fields
\begin{itemize}
  \item Computer science
  \item Applied probability
  \item Statistics
  \item Economics
  \item Operations research
\end{itemize}
\end{frame}
\end{document}