\chapter{A Non-Equilibrium Green's Function (NEGF) Based Magnetic Tunnel Junction (MTJ) Simulator in MATLAB\texttrademark}

\section{Introduction}

The Non-Equilibrium Green's Function (NEGF) based transport model was proposed in \cite{Salahuddin2007e,Datta2012b}. This document presents an implementation of a MATLAB\texttrademark{} based solver that calculates the $I-V$ characteristics of a magnetic tunnel junction (MTJ) using the proposed model. The NEGF model is based on the single band effective mass Hamiltonian ($\mathcal{H}$) and self-energy ($\Sigma_{L,R}$) which are used to calculate Green's function ($G$), electron correlation matrix ($G^n$) and charge current density ($J$). Fig.~\ref{fig:negf_grid} shows the device structure and coordinate system used for modeling MTJs. In a 1-D system, the Hamiltonian may be written for five regions: (a) the left ferromagnet (FM) contact, (b) the right FM contact, (c) the oxide channel, (d) the left FM-oxide interface, and (d) the right oxide-FM interface. Generally, the Hamiltonian, $\mathcal{H}$, may be written as \begin{equation}
\mathcal{H}=\left[\begin{IEEEeqnarraybox}[\scriptsize][c]{/c/c/c/c/c/c/c/c/c/c/c/}
\alpha_{HL1} & \beta_{HL1} & 0 & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots & 0 \\
\beta^{\dagger}_{HL1} & \ddots & \ddots & \ddots & ~ & ~ & ~ & ~ & ~ & ~ & \vdots \\
0 & \ddots & \alpha_{HL1} & \beta_{HL1} & \ddots & ~ & ~ & ~ & ~ & ~ & \vdots \\
\vdots & \ddots & \beta^{\dagger}_{HL1} & \alpha_{IL} & \beta_{OX} & \ddots & ~ & ~ & ~ & ~ & \vdots \\
\vdots & ~ & \ddots & \beta^{\dagger}_{OX} & \alpha_{OX} & \ddots & \ddots & ~ & ~ & ~ & \vdots \\
\vdots & ~ & ~ & \ddots & \ddots & \ddots & \ddots & \ddots & ~ & ~ & \vdots \\
\vdots & ~ & ~ & ~ & \ddots & \ddots & \alpha_{OX} & \beta_{OX} & \ddots & ~ & \vdots \\
\vdots & ~ & ~ & ~ & ~ & \ddots & \beta^{\dagger}_{OX} & \alpha_{IR} & \beta_{HL2} & \ddots & \vdots \\
\vdots & ~ & ~ & ~ & ~ & ~ & \ddots & \beta^{\dagger}_{FM,R} & \alpha_{HL2} & \ddots & 0 \\
\vdots & ~ & ~ & ~ & ~ & ~ & ~ & \ddots & \ddots & \ddots & \beta_{HL2} \\
0 & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots & \cdots & 0 & \beta^{\dagger}_{HL2} & \alpha_{HL2}
\end{IEEEeqnarraybox}\right]\label{eq:genHam}
\end{equation}where the number of $\alpha_{HL1}$, $\alpha_{OX}$ and $\alpha_{HL2}$ correspond to the number of grid points to model the left FM contact, the oxide channel, and the right FM contact, respectively, in the direction of electron transport (the \emph{longitudinal} direction). When a 1-D problem is considered (refer to Fig.~\ref{fig:negf_grid}), we write \afterpage{
\begin{figure}[!t]
\centering
\includegraphics[scale=0.75]{ResearchNotes_NEGF/figs/simframe/negf_grid.eps}
\caption{Illustration of the reference axis (left) and Non-Equilibrium Green's Function based description of the magnetic tunnel junction (right). The reference axis shows how magnetization angles are named in this work. The coupling between lattice sites are $t_{FM}$ and $t_{OX}$ and individual lattice sites are described by the Hamiltonian $\alpha_{HL1}$, $\alpha_{HL2}$ and $\alpha_{OX}$. The complete Hamiltonian describing the MTJ is written in terms of $t_{FM}$, $t_{OX}$, $\alpha_{HL1}$, $\alpha_{HL2}$ and $\alpha_{OX}$.}
\label{fig:negf_grid}
\end{figure}\begin{figure}[!t]
\centering
\includegraphics[scale=0.75]{ResearchNotes_NEGF/figs/simframe/negf_grid.eps}
\caption{Temp holder}
\label{fig:bandDiags}
\end{figure}
\clearpage
}\begin{IEEEeqnarray}{rCl}
\alpha_{HL1}&=&\alpha_{FM,L} = 2t_{FM,Left}I \\
\alpha_{HL2}&=&\alpha_{FM,R} = 2t_{FM,Right}I \\
\alpha_{OX}&=&\alpha_{Ch} = 2t_{OX}I \\
\alpha_{IL}&=&\frac{\alpha_{OX}+\alpha_{FM,L}}{2} \\
\alpha_{IR}&=&\frac{\alpha_{OX}+\alpha_{FM,R}}{2} \\
\beta_{HL1}&=&\beta_{FM,L} = -t_{FM,Left}I \\
\beta_{HL2}&=&\beta_{FM,R} = -t_{FM,Right}I \\
\beta_{OX}&=&-t_{OX}I
\end{IEEEeqnarray} where $I$ is the $2\times{}2$ identity matrix. Then, effective masses are used to write \begin{IEEEeqnarray}{rCl}
t_{FM,Left}&=&\frac{\hbar^{2}}{2m^{*}_{FM,Left}a^{2}} \\
t_{FM,Right}&=&\frac{\hbar^{2}}{2m^{*}_{FM,Right}a^{2}} \\
t_{OX}&=&\frac{\hbar^{2}}{2m^{*}_{OX}a^{2}}
\end{IEEEeqnarray}where $a$ is the uniform grid spacing, $\hbar=\frac{h}{2\pi}$ is the reduced Planck constant, and $m^{*}_{OX}$, $m^{*}_{FM,Left}$, and $m^{*}_{FM,Right}$ are the effective electron masses in the oxide channel, the left FM contact, and the right FM contact, respectively. Note that the on-site energy at every grid point is represented by a $2\times{}2$ matrix to handle the spin degeneracy when $\mathcal{H}$ is written this way.

In a ferromagnetic material, the conduction bands for up-spin and down -spin electrons are split. As illustrated in Fig.~\ref{fig:bandDiags}, $U_{b}$ is the barrier height of the tunnel barrier, and $\Delta_{L}$ and $\Delta_{R}$ are the splitting energies between the bottom of the conduction bands for up-spin and down-spin electrons in the left FM contact and right FM contact, respectively. The potential barrier of the tunnel oxide is included in $\mathcal{H}$ by writing \begin{IEEEeqnarray}{rCl}
\alpha_{OX}&=&\alpha_{Ch}+U_{b}I \\
\alpha_{IL}&=&0.5\times\left(\alpha_{OX}+\alpha_{FM,L}+U_{b}\right) \\
\alpha_{IR}&=&0.5\times\left(\alpha_{OX}+\alpha_{FM,R}+U_{b}\right)
\end{IEEEeqnarray}where $I$ is the $2\times{}2$ identity matrix. Then, to include the conduction band splitting, we rewrite \begin{IEEEeqnarray}{rCl}
\alpha_{HL1}&=&\alpha_{FM,L}+U_{split,L} \\
\alpha_{HL2}&=&\alpha_{FM,R}+U_{split,R} \\
\alpha_{IL}&=&0.5\times\left(\alpha_{OX}+\alpha_{FM,L}+U_{b}+U_{split,L}\right) \\
\alpha_{IR}&=&0.5\times\left(\alpha_{OX}+\alpha_{FM,R}+U_{b}+U_{split,R}\right) \\
U_{split,L}&=&\begin{bmatrix}
0 & 0 \\
0 & \Delta_{L}
\end{bmatrix} \label{eq:onsiteL} \\
U_{split,R}&=&\begin{bmatrix}
0 & 0 \\
0 & \Delta_{R}
\end{bmatrix} \label{eq:onsiteR}
\end{IEEEeqnarray}Eqs.~(\ref{eq:onsiteL}) and (\ref{eq:onsiteR}) are written assuming the magnetization directions of the left and right FM contacts are the same and are pointing in the $+\widehat{z}$ direction of the reference frame. If they are different, we may choose one of the FM contacts (e.g., left FM contact) to be the reference frame and define its magnetization direction to be the $+\widehat{z}$ direction. Using the left FM contact as the reference frame, the magnetization direction of the right FM contact, $\widehat{m}$, may be written. In this example, a unitary transformation needs to be performed on $U_{split,R}$ to rewrite it as \begin{equation}
U_{split,R} = \frac{\left(I-\vv{\sigma}\cdot\widehat{m}\right)\Delta_{R}}{2} \label{eq:unitaryTrans}
\end{equation}where $\vv{\sigma}$ is the vector of Pauli spin matrices. Note that for any arbitrarily chosen reference frame, unitary transformation is performed on both $U_{split,L}$ and $U_{split,R}$, using $\widehat{m}$ to be the magnetization vector direction for the corresponding ferromagnetic contact in the chosen reference frame. By definition, the dot product in Eq.~(\ref{eq:unitaryTrans}) yields a $2\times{}2$ matrix that is a linear combination of the Pauli spin matrices given by \begin{equation}
\vv{\sigma}\cdot\widehat{m} = m_{x}\vv{\sigma}_{x}+m_{y}\vv{\sigma}_{y}+m_{z}\vv{\sigma}_{z}
\end{equation}where the components of the vectors have been explicitly written. Note that unitary transformations acting on identity matrices does not do anything. Hence, only $U_{split,L}$ and $U_{split,R}$ needs to be modified to obtain $\mathcal{H}$ when any of the magnetizations do not point along the $+\widehat{z}$ direction of the chosen reference frame.

The applied voltage across the MTJ modifies the potential profile along the longitudinal direction of the MTJ and may be modeled as $U_{V}$. The non-zero entries of $U_{V}$ are on its main diagonal and may be calculated using \begin{equation}
U_{V}(i,i)=\left\lbrace \,
\begin{IEEEeqnarraybox}[][c]{l?s}
\frac{qV}{2}I & if $i$ is in $HL1$ or $IL$, \\
\frac{-qV}{2}I & if $i$ is in $HL2$ or $IR$, \\
qV\left(\frac{1}{2}-\frac{i}{N+1}\right)I & if $i$ is in $OX$.
\end{IEEEeqnarraybox} \right.
\end{equation}where $N$ is the total number of grid points in the OX region. Next, the full Hamiltonian, $\mathcal{H}_{Full}$, is written as \begin{equation}
\mathcal{H}_{Full}=\mathcal{H}+U_{V}
\end{equation}

The self-energy matrices, $\Sigma_{L,R}$, represent the coupling of the external system to the contacts. Based on the construction of $\mathcal{H}_{Full}$,  the non-zero components $\Sigma_{L}$ and $\Sigma_{R}$ are on the top left and bottom right, respectively. The non-zero parts of the self-energies may be written as \begin{equation}\label{eq:self_energyL}
\Sigma_{L}=
\begin{bmatrix}
-t_{FM,Left}exp\left(-ik_{L}^{\uparrow}a\right) & 0 \\
0 & -t_{FM,Left}exp\left(-ik_{L}^{\downarrow}a\right)
\end{bmatrix}
\end{equation}\begin{equation}\label{eq:self_energyR}
\Sigma_{R}=
\begin{bmatrix}
-t_{FM,Right}exp\left(-ik_{R}^{\uparrow}a\right) & 0 \\
0 & -t_{FM,Right}exp\left(-ik_{R}^{\downarrow}a\right)
\end{bmatrix}
\end{equation} where \begin{equation}
k_{L}^{\uparrow}=cos^{-1}\left(1-\frac{E+\frac{qV}{2}}{2t_{FM,Left}} \right)
\end{equation}\begin{equation}
k_{R}^{\uparrow}=cos^{-1}\left(1-\frac{E-\frac{qV}{2}}{2t_{FM,Right}} \right)
\end{equation}\begin{equation}
k_{L}^{\downarrow}=cos^{-1}\left(1-\frac{E+\frac{qV}{2}-\Delta_{L}}{2t_{FM,Left}} \right)
\end{equation}\begin{equation}
k_{R}^{\downarrow}=cos^{-1}\left(1-\frac{E-\frac{qV}{2}-\Delta_{R}}{2t_{FM,Right}} \right)
\end{equation}$E$ is the energy level of interest. This form of Eqs.~(\ref{eq:self_energyL}) and (\ref{eq:self_energyR}) are used if the magnetization direction is in the $+\widehat{z}$ direciton. As before, a unitary transformation needs to be performed on $\Sigma_{L,R}$ of the FM contact whose magnetization direction is not in the $+\widehat{z}$ direciton of the reference frame. The matrix for unitary transformation is given by \begin{equation}
\Lambda_{trans} =
\begin{bmatrix}
cos\left(\frac{\theta}{2}\right)exp\left(i\frac{\phi}{2}\right) & sin\left(\frac{\theta}{2}\right)exp\left(-i\frac{\phi}{2}\right) \\
-sin\left(\frac{\theta}{2}\right)exp\left(i\frac{\phi}{2}\right) & cos\left(\frac{\theta}{2}\right)exp\left(-i\frac{\phi}{2}\right) \\
\end{bmatrix}
\end{equation} where $\theta$ and $\phi$ correspond to the spherical angles of the magnetization vector direction to the Cartesian axis in the reference frame. The self-energy matrices are transformed using \begin{equation}
\Sigma_{L,R}^{new}=\Lambda_{trans}\Sigma_{L,R}^{old}\Lambda_{trans}^{\dagger}
\end{equation}

With the Hamiltonian ($\mathcal{H}_{Full}$) and the self-energy matrices ($\Sigma_{L,R}$), all quantities of interest may be calculated from the following:
\begin{align}
\textbf{Green's function: } G(E) &= (EI - \mathcal{H}_{Full} - \Sigma_L - \Sigma_R)^{-1} \\
\textbf{Spectral density: } A &= i(G-G^{\dagger})=G \Gamma G^{\dagger} \\
\textbf{Electron correlation function: } G^{n}(E) &= G(\Sigma_{L}^{in} + \Sigma_{R}^{in})G^{\dagger} \label{eq:eCorrFunc} \\
\textbf{In-scattering function: } \Sigma_{L,R}^{in}(E) &= \Gamma_{L,R}(E)f_{L,R}(E) \\
\textbf{Broadening matrix: } \Gamma_{L,R}(E) &= i(\Sigma_{L,R} - \Sigma_{L,R}^{\dagger})
\end{align} The diagonal elements of $A$ and $G^n$ correspond to the local density of states and electron density, respectively. $\Sigma^{in}$ is the in-scattering function describing the rate at which electrons enter the device from the $L$ and $R$ contacts, and $f_{L,R}(E)$ are the Fermi functions in the $L$ and $R$ contacts. \begin{IEEEeqnarray}{rCl}
f_{L}(E)&=&\frac{1}{1+exp\left(\frac{E-\mu_{L}}{k_{B}T}\right)} \\
f_{R}(E)&=&\frac{1}{1+exp\left(\frac{E-\mu_{R}}{k_{B}T}\right)}
\end{IEEEeqnarray}where $k_{B}$ is the Boltzmann constant, $T$ is the absolute temperature of the system, and $\mu_{L}$ and $\mu_{R}$ are the electrochemical potential of the left and right FM contacts, respectively. The charge and spin currents flowing through the MTJ are then calculated using
\begin{center}
\textbf{\underline{Charge current density}}
\end{center}
\begin{equation}\label{eq:negf_jcurr}
J_{k,k+1} = Real \left(\frac{1}{i\hbar} \int_{E} \left( Trace \left(\mathcal{H}_{Full,k,k+1}G_{k+1,k}^n - G_{k,k+1}^n\mathcal{H}_{Full,k+1,k} \right)\right) dE \right)
\end{equation}\begin{center}
\textbf{\underline{Spin current density}}
\end{center}
\begin{equation}\label{eq:negf_js}\begin{aligned}
\vv{J}_{S} &= J_{k,k+1}^{Spin} \\
&= Real \left(\frac{1}{i2e\mu_{0}M_{S}V_{magnet}} \int_{E} \left( Trace \left\lbrace \widehat{\sigma} \cdot \left(\mathcal{H}_{Full,k,k+1}G_{k+1,k}^n - G_{k,k+1}^n\mathcal{H}_{Full,k+1,k} \right)\right\rbrace\right) dE \right)
\end{aligned}\end{equation} where $G^n$ is the electron correlation function calculated as given by Eq.~(\ref{eq:eCorrFunc}), $e$ is the elementary charge, $\mu_{0}$ is the permeability of vacuum, $M_{S}$ and $V_{magnet}$ is the saturation magnetization and volume of the magnetic layer the torque is acting on in the MTJ. The charge and spin currents calculated using the NEGF approach are used to determine the spin-transfer torque exerted on the free ferromagnetic layer of the MTJ.

\section{Extending the 1-D model to higher dimension systems}\label{sec:extendDim}

The model presented thus far only models the electron transport in the MTJ considered as a 1-D wire. In real devices, the lateral dimensions may be substantially larger and hence, the 1-D model may not apply. However, the methodology above can still be used for systems with higher order dimensions. The Hamiltonian is written differently for 2-D and for 3-D systems. Let us consider the a 2-D MTJ first. The same approach presented earlier may be used to write $\mathcal{H}$, except that $\alpha_{HL1}$, $\alpha_{HL2}$, $\alpha_{IL}$, $\alpha_{IR}$ , $\alpha_{OX}$, $\beta_{HL1}$, $\beta_{HL2}$, $\beta_{IL}$, $\beta_{IR}$, and $\beta_{OX}$ needs to be rewritten. Assume that $N_{t}$ grid points lie in the \emph{transverse} direction (the direction perpendicular to the longitudinal direction). First, note that every line of grid points in the transverse direction lie in only one of the five defined regions. Using the left FM contact as an example, we rewrite \begin{IEEEeqnarray}{rCl}
\alpha_{HL1}&=&\left[ \begin{IEEEeqnarraybox}[][c]{/c/c/c/c/c/}
2\alpha_{FM,L} & \beta_{FM,L} & 0 & \cdots & 0 \\
\beta^{\dagger}_{FM,L} & \ddots & \ddots & \ddots & \vdots \\
0 & \ddots & \ddots & \ddots & 0 \\
\vdots &\ddots & \ddots & \ddots & \beta_{FM,L} \\
0 & \cdots & 0 & \beta^{\dagger}_{FM,L} & 2\alpha_{FM,L}
\end{IEEEeqnarraybox}\right] \label{eq:modAlph2d} \\
\beta_{HL1}&=&-t_{FM,Left}I \label{eq:modBeta2d}
\end{IEEEeqnarray}where $I$ is the $2N_{t}\times2N_{t}$ identity matrix. To account for the conduction splitting, $U_{split,L}$ is added to every $2\times{}2$ entry on the main diagonal of $\alpha_{HL1}$. The same approach is used to modify $\alpha_{HL2}$ and $\beta_{HL2}$. $\alpha_{OX}$ and $\beta_{OX}$ are modified using the same approach given in Eqs.~(\ref{eq:modAlph2d}) and (\ref{eq:modBeta2d}), except that $U_{b}I$ is added to every $2\times{}2$ entry on the main diagonal of $\alpha_{OX}$. Then, \begin{IEEEeqnarray}{rCl}
\alpha_{IL}&=&0.5\times\left(\alpha_{HL1}+\alpha_{OX}\right) \\
\alpha_{IR}&=&0.5\times\left(\alpha_{HL2}+\alpha_{OX}\right)
\end{IEEEeqnarray}The rewritten $\alpha_{HL1}$, $\alpha_{HL2}$, $\alpha_{IL}$, $\alpha_{IR}$ , $\alpha_{OX}$, $\beta_{HL1}$, $\beta_{HL2}$, and $\beta_{OX}$ are then used to write $\mathcal{H}$ as given by Eq.~(\ref{eq:genHam}).

In a 3-D system, transverse directions forms a 2-D plane of grid points. Hence, $\alpha_{HL1}$, $\alpha_{HL2}$, $\alpha_{IL}$, $\alpha_{IR}$ , $\alpha_{OX}$, $\beta_{HL1}$, $\beta_{HL2}$, $\beta_{IL}$, $\beta_{IR}$, and $\beta_{OX}$ each models a 2-D plane of grid points. Consider a 2-D plane in the $HL1$ region with $N_{t1}\times{}N_{t2}$ number of grid points. We write along the direction with $N_{t1}$ points\begin{IEEEeqnarray}{rCl}
\alpha_{1D,HL1}&=&\left[ \begin{IEEEeqnarraybox}[][c]{/c/c/c/c/c/}
3\alpha_{FM,L} & \beta_{FM,L} & 0 & \cdots & 0 \\
\beta^{\dagger}_{FM,L} & \ddots & \ddots & \ddots & \vdots \\
0 & \ddots & \ddots & \ddots & 0 \\
\vdots &\ddots & \ddots & \ddots & \beta_{FM,L} \\
0 & \cdots & 0 & \beta^{\dagger}_{FM,L} & 3\alpha_{FM,L}
\end{IEEEeqnarraybox}\right] \label{eq:modAlph2d_alt} \\
\beta_{1D,HL1}&=&-t_{FM,Left}I \label{eq:modBeta2d_alt}
\end{IEEEeqnarray}where $I$ in Eq.~(\ref{eq:modBeta2d_alt}) is the $2N_{t1}\times2N_{t1}$ identity matrix and $\alpha_{1D,HL1}$ is a $2N_{t1}\times2N_{t1}$ matrix. We can then write \begin{IEEEeqnarray}{rCl}
\alpha_{HL1}&=&\left[ \begin{IEEEeqnarraybox}[][c]{/c/c/c/c/c/}
\alpha_{1D,HL1} & \beta_{1D,HL1} & 0 & \cdots & 0 \\
\beta^{\dagger}_{1D,HL1} & \ddots & \ddots & \ddots & \vdots \\
0 & \ddots & \ddots & \ddots & 0 \\
\vdots &\ddots & \ddots & \ddots & \beta_{1D,HL1} \\
0 & \cdots & 0 & \beta^{\dagger}_{1D,HL1} & \alpha_{1D,HL1}
\end{IEEEeqnarraybox}\right] \label{eq:modAlph3d} \\
\beta_{HL1}&=&-t_{FM,Left}I\label{eq:modBeta3d}
\end{IEEEeqnarray}where $I$ in Eq.~(\ref{eq:modBeta3d}) is the $(2N_{t1}N_{t2})\times(2N_{t1}N_{t2})$ identity matrix and $\alpha_{HL1}$ is a $(2N_{t1}N_{t2})\times(2N_{t1}N_{t2})$ matrix. To account for the conduction band splitting between up-spin and down-spin electrons, $U_{split,L}$ is added to every $2\times2$ entry along the main diagonal of $\alpha_{HL1}$. The same approach is used to rewrite $\alpha_{HL2}$ and $\beta_{HL2}$. $\alpha_{OX}$ is rewritten as prescribed by Eqs.~(\ref{eq:modAlph2d_alt}) and (\ref{eq:modAlph3d}), while $\beta_{OX}$ is rewritten as prescribed by Eqs.~(\ref{eq:modBeta2d_alt}) and (\ref{eq:modBeta3d}). However, $U_{b}I$, where $I$ here is the $2\times2$ identity matrix, is added to every $2\times2$ entry along the main diagonal of $\alpha_{OX}$. Also, just like in the 2-D system, the interfaces are modeled as \begin{IEEEeqnarray}{rCl}
\alpha_{IL}&=&0.5\times\left(\alpha_{HL1}+\alpha_{OX}\right) \\
\alpha_{IR}&=&0.5\times\left(\alpha_{HL2}+\alpha_{OX}\right)
\end{IEEEeqnarray}The rewritten $\alpha_{HL1}$, $\alpha_{HL2}$, $\alpha_{IL}$, $\alpha_{IR}$ , $\alpha_{OX}$, $\beta_{HL1}$, $\beta_{HL2}$, and $\beta_{OX}$ are then used to write $\mathcal{H}$ as given by Eq.~(\ref{eq:genHam}).

\section{The mode space approach}

Note the size of $\mathcal{H}$ grows quadratically with the total number of grid points. As the number of dimensions of the system increases, the size of $\mathcal{H}$ quickly increases as well. Clearly, there may not be enough computer memory to accommodate the numerical program for solving large 3-D systems. Fortunately, the problem for 2-D and 3-D systems may be reduced to multiple 1-D problems using the mode space approach, which drastically reduces the memory requirement for the numerical program. The main reason that allows us to reduce the number of dimensions is that the solutions to the Schr\"odinger equation for the MTJ system may be written as \begin{equation}
\psi_{i}=\psi_{0}\cdot{}exp(i\vv{r}\cdot\vv{k}_{\perp})\cdot{}exp(i\vv{r}\cdot\vv{k}_{\parallel})
\end{equation}where $i=\sqrt{-1}$, $\vv{k}_{\perp}$ is the longitudinal wave vector, and $\vv{k}_{\parallel}$ is the transverse wave vector. In other words, $\alpha_{HL1}$, $\alpha_{HL2}$, $\alpha_{OX}$, $\alpha_{IL}$ and $\alpha_{IR}$ may be diagonalized and our system of equations going into Eq.~(\ref{eq:genHam}) may be rewritten such that \begin{IEEEeqnarray}{rCl}
\alpha_{HL1}&=&2t_{FM,Left}I + E_{t} \\
\alpha_{HL2}&=&2t_{FM,Right}I + \frac{E_{t}t_{FM,Left}}{t_{FM,Right}} \\
\alpha_{OX}&=&2t_{OX}I + \frac{E_{t}t_{FM,Left}}{t_{OX}} \\
\alpha_{IL}&=&(t_{FM,Left}+t_{OX})I + \frac{2E_{t}t_{FM,Left}}{(t_{FM,Left}+t_{OX})} \\
\alpha_{IR}&=&(t_{FM,Right}+t_{OX})I + \frac{2E_{t}t_{FM,Left}}{(t_{FM,Right}+t_{OX})} \\
\beta_{HL1}&=&-t_{FM,Left}I \\
\beta_{HL2}&=&-t_{FM,Right}I \\
\beta_{OX}&=&-t_{OX}I \\
E_{t}(j,j)&=&\frac{\hbar^{2}\left|\vv{k}_{\parallel}(j,j)\right|^{2}}{2m^{*}_{FM,L}}
\end{IEEEeqnarray}The non-zero entries of $E_{t}$ are on its main diagonal, and $I$ is the identity matrix. The size of $I$ is such that the number of entries along each row and column corresponds to twice the number of grid points in the transverse directions of the system. The same system of equations may be solved by considering each $E_{t}$ separately. For each $E_{t}$, $\mathcal{H}$ is written as in the 1-D case but with \begin{IEEEeqnarray}{rCl}
\alpha_{HL1}&=&\alpha_{FM,L} = 2t_{FM,Left}I + E_{t} \\
\alpha_{HL2}&=&\alpha_{FM,R} = 2t_{FM,Right}I + \frac{E_{t}t_{FM,Left}}{t_{FM,Right}}\\
\alpha_{OX}&=&\alpha_{Ch} = 2t_{OX}I + \frac{E_{t}t_{FM,Left}}{t_{OX}} \\
\alpha_{IL}&=&\frac{\alpha_{OX}+\alpha_{FM,L}}{2} \\
\alpha_{IR}&=&\frac{\alpha_{OX}+\alpha_{FM,R}}{2} \\
\beta_{HL1}&=&\beta_{FM,L} = -t_{FM,Left}I \\
\beta_{HL2}&=&\beta_{FM,R} = -t_{FM,Right}I \\
\beta_{OX}&=&-t_{OX}I
\end{IEEEeqnarray} where $I$ is the $2\times{}2$ identity matrix.

The transverse mode energies, $E_{t}$, depends on the dimensionality of the system, the number of transverse grid points, and the type of boundary conditions. In Section~\ref{sec:extendDim}, we have written $\mathcal{H}$ using box boundary conditions. Let us consider the 2-D case first. It turns out that we may write the mode energies as \begin{IEEEeqnarray}{rCl}
E_{t}&=&2t_{FM,Left}\times\left(1-cos\left(k_{\parallel}a\right)\right)
\end{IEEEeqnarray}When the box boundary condition is used, the plane wave solution to the Schr\"odinger equation must be periodic in the transverse direction. Furthermore, it must go to zero at both ends along the transverse direction due to box boundary conditions. Hence, we can write the plane wave solution as \begin{IEEEeqnarray}{rCl}
\Psi_{\nu}&=&\Psi_{0}exp\left(ik_{\perp}l_{\perp}\right)sin(k_{\parallel}l_{\parallel}) \\
k_{\parallel}(N_{t}+1)a &=& \nu\pi \text{~when~}l_{\parallel}=(N_{t}+1)a
\end{IEEEeqnarray}where $\nu$ is an integer in [1, $N_{t}$] and $N_{t}$ is the number of grid points in the transverse direction. Then,\begin{IEEEeqnarray}{rCl}
E_{t}&=&2t_{FM,Left}\times\left(1-cos\left(\frac{\nu\pi}{N_{t}+1}\right)\right)
\end{IEEEeqnarray} On the other hand, periodic boundary conditions (\emph{pbc}) may also be used to model devices where the characteristic does not depend on the boundary condition. When using \emph{pbc}, $\alpha_{HL1}$ is written as \begin{IEEEeqnarray}{rCl}
\alpha_{HL1}&=&\left[\begin{IEEEeqnarraybox}[][c]{/c/c/c/c/c/c/}
2\alpha_{FM,L} & \beta_{FM,L} & 0 & \cdots & 0 & \beta^{\dagger}_{FM,L} \\
\beta^{\dagger}_{FM,L} & \ddots & \ddots & \ddots & \ddots & 0 \\
0 & \ddots & \ddots & \ddots & \ddots & \vdots \\
\vdots & \ddots & \ddots & \ddots & \ddots & 0 \\
0 & \ddots & \ddots & \ddots & \ddots & \beta_{FM,L} \\
\beta_{FM,L} & 0 & \cdots & 0 & \beta^{\dagger}_{FM,L} & 2\alpha_{FM,L}
\end{IEEEeqnarraybox}\right]
\end{IEEEeqnarray}and similarly for $\alpha_{HL2}$, $\alpha_{IL}$, $\alpha_{IR}$ , and $\alpha_{OX}$. The plane wave solution to the Schr\"odinger equation is only required to be periodic in the transverse direction. Hence, \begin{IEEEeqnarray}{rCl}
\Psi_{\nu}&=&\Psi_{0}exp\left(ik_{\perp}l_{\perp}\right)exp(ik_{\parallel}l_{\parallel}) \\
k_{\parallel}(N_{t})a &=& 2\nu\pi \text{~when~} l_{\parallel}=N_{t}a
\end{IEEEeqnarray}where $\nu$ is an integer in [1, $N_{t}$] and $N_{t}$ is the number of grid points in the transverse direction. Then,\begin{IEEEeqnarray}{rCl}
E_{t}&=&2t_{FM,Left}\times\left(1-cos\left(\frac{2\nu\pi}{N_{t}}\right)\right)
\end{IEEEeqnarray}

The transverse mode energies for 3-D systems may be constructed from the same approach we just described. Let us consider the longitudinal direction to be in the $+\widehat{z}$ direction, and the transverse directions to be $+\widehat{x}$ and $+\widehat{y}$. Furthermore, assume there are $N_{t1}$ and $N_{t2}$ grid points in the $x$ and $y$ directions, respectively. We invoke the fact that plane wave solutions to the Schr\"odinger equation have the form \begin{equation}
\Psi_{\nu} = \Psi_{0}e^{i\left(k_{x}r_{x} + k_{y}r_{y} + k_{z}r_{z}\right)}
\end{equation}Since $k_{x}$ and $k_{y}$ are decoupled, the combined transverse mode energy is a linear combination of every permutation of the transverse mode energy in the $x$ and $y$ direction ($E_{t,x}$ and $E_{t,y}$, respectively). Hence, every $E_{t,x}$ and $E_{t,y}$ are first obtained by choosing integers $\nu_{x}$ and $\nu_{y}$ in the range [1, $N_{t1}$] and [1, $N_{t2}$], respectively. If both directions have box boundary conditions, then we can write \begin{IEEEeqnarray}{rCl}
E_{t,x}&=&2t_{FM,Left}\times\left(1-cos\left(\frac{\nu_{1}\pi}{N_{t1}+1}\right)\right) \\
E_{t,y}&=&2t_{FM,Left}\times\left(1-cos\left(\frac{\nu_{2}\pi}{N_{t2}+1}\right)\right)
\end{IEEEeqnarray}and calculate $E_{t}=E_{t,x}+E_{t,y}$ using every permutation of $E_{t,x}$ and $E_{t,y}$. If both directions have \emph{pbc}, then use \begin{IEEEeqnarray}{rCl}
E_{t,x}&=&2t_{FM,Left}\times\left(1-cos\left(\frac{2\nu_{1}\pi}{N_{t1}}\right)\right) \\
E_{t,y}&=&2t_{FM,Left}\times\left(1-cos\left(\frac{2\nu_{2}\pi}{N_{t2}}\right)\right)
\end{IEEEeqnarray}instead. If the box boundary condition is applied along the $x$ direction but \emph{pbc} along the $y$ direction, then use \begin{IEEEeqnarray}{rCl}
E_{t,x}&=&2t_{FM,Left}\times\left(1-cos\left(\frac{\nu_{1}\pi}{N_{t1}+1}\right)\right) \\
E_{t,y}&=&2t_{FM,Left}\times\left(1-cos\left(\frac{2\nu_{2}\pi}{N_{t2}}\right)\right)
\end{IEEEeqnarray}instead. If the box boundary condition is applied along the $y$ direction but \emph{pbc} along the $x$ direction, then use \begin{IEEEeqnarray}{rCl}
E_{t,x}&=&2t_{FM,Left}\times\left(1-cos\left(\frac{2\nu_{1}\pi}{N_{t1}}\right)\right) \\
E_{t,y}&=&2t_{FM,Left}\times\left(1-cos\left(\frac{\nu_{2}\pi}{N_{t2}+1}\right)\right)
\end{IEEEeqnarray} The charge and spin currents flowing through the MTJ are calculated for each mode and all contributions are summed together to obtain the actual charge and spin current flowing through the MTJ, giving
\begin{center}
\textbf{\underline{Charge current density}}
\end{center}
\begin{equation}\label{eq:negf_jcurr_modeDis}
J_{k,k+1} = \sum_{E_{t}} Real \left(\frac{1}{i\hbar} \int_{E_{z}} \left( Trace \left(\Upsilon \right)\right) \partial{}E_{z} \right)
\end{equation}\begin{center}
\textbf{\underline{Spin current density}}
\end{center}
\begin{equation}\label{eq:negf_js_modeDis}
\vv{J}_{S} = \sum_{E_{t}} Real \left(\frac{1}{i2e\mu_{0}M_{S}V_{magnet}} \int_{E_{z}} \left( Trace \left\lbrace \widehat{\sigma} \cdot \Upsilon\right\rbrace\right) \partial{}E_{z} \right)
\end{equation}where $\Upsilon$ is given by\begin{equation}
\Upsilon=\mathcal{H}_{Full,k,k+1}(E_{t})G_{k+1,k}^n(E_{t}) - G_{k,k+1}^n(E_{t})\mathcal{H}_{Full,k+1,k}(E_{t})
\end{equation}and $\mathcal{H}_{Full}$ and $G^{n}$ are now functions of $E_{t}$.

\section{Approximating mode space calculations in NEGF}\label{sec:negf_Soln}

In MTJs, the Fermi level in the FM contacts are deep inside the conduction band and as a result, the grid spacing may need to be very small in order for the numerical solutions to converge (even in the 1-D case). Even for MTJs with $10~\text{nm}\times10~\text{nm}$ cross-sectional area, the number of transverse modes needed to be considered to calculate its $I-V$ characteristic can be in the tens of thousands. Since the NEGF calculations for each transverse mode energy is independent of the others, the numerical simulation can be easily parallelized and executed on a large computer cluster to obtain the results quickly. However, because the data needs to be communicated to every computing node in the cluster, the simulation might be slowed down if the network traffic is too heavy. To overcome this issue, we first note that when the MTJ size is sufficiently large, the number of transverse modes in $k$-space is very dense. Hence, it may be possible to turn the discrete summation in Eqs.~(\ref{eq:negf_jcurr_modeDis}) and (\ref{eq:negf_js_modeDis}) into a continuous integral. This approach was proposed in \cite{Duke1969} and was used by Tsu-Esaki to model resonant tunneling diodes \cite{Tsu1973a}.

When we change the summation over modes in 3-D to a continuous integration, it can be converted as \begin{equation}
\sum_{E_{t,x}}\sum_{E_{t,y}}\sum_{E_{t,z}} \rightarrow \int\int\int\partial{}k_{x}\partial{}k_{y}\partial{}k_{z}
\end{equation}However, the triple integral can be converted into a single integral if we integrate over the actual energy of the transverse mode instead. \begin{equation}
\int\int\int\partial{}k_{x}\partial{}k_{y}\partial{}k_{z} \rightarrow \int\partial{}k_{\parallel} \rightarrow DOS(E_{t}) \int\partial{}E_{t}
\end{equation}where $DOS(E_{t})$ is the density of states. This can be done if we know the dispersion relation, which is assumed to be quadratic for most problems \begin{equation}
E_{t} = \frac{\hbar^{2}(\vv{k}\cdot\vv{k})}{2m^{*}_{eff}}=\frac{\hbar^{2}(k^{2}_{x}+k^{2}_{y}+k^{2}_{z})}{2m^{*}_{eff}}=\frac{\hbar^{2}{}k^{2}_{\parallel}}{2m^{*}_{eff}}
\end{equation}where $m^{*}_{eff}$ is the effective mass of the electron. Rearranging, \begin{equation}
k_{\parallel}=\frac{\sqrt{2m^{*}_{eff}E_{t}}}{\hbar} \label{eq:kERel}
\end{equation}We also need to determine $DOS(E_{t})$. In a 3-D box which has \emph{pbc} in all three Cartesian coordinate directions. The $k$-states are separated by \begin{equation}
\Delta{}k_{x}=\frac{\pi}{L_{x}},~\Delta{}k_{y}=\frac{\pi}{L_{y}},~\Delta{}k_{z}=\frac{\pi}{L_{z}}
\end{equation}where $L_{x}$, $L_{y}$ and $L_{z}$ is the length of each side of the confining box. Furthermore, each $k_{x}$, $k_{y}$ and $k_{z}$ falls in the range [$-\pi$, $\pi$]. Hence, in $k$-space, each state occupies a volume given by \begin{equation}
\text{Volume~occupied~by~a~state~in~k-space~for~a~3-D~box}=\frac{2\pi}{L_{x}}\times\frac{2\pi}{L_{y}}\times\frac{2\pi}{L_{z}}=\frac{8\pi^{3}}{\Omega}
\end{equation}where $\Omega=L_{x}L_{y}L_{z}$. To get the \emph{density of states}, we need to determine how many states are uncovered when $E_{t}$ changes to $E_{t}+\partial{}E_{t}$. This corresponds to a change in volume in $k$-space. When $E_{t}$ changes, the volume changes spherically. \begin{table}[!t]
\caption{Summary of $DOS(E_{t})$ calculations}
\centering
\label{tab:DOS}
\begin{IEEEeqnarraybox}[\IEEEeqnarraystrutmode][c]{v/c/v/c/v/c/v/c/v/c/v/c/v}
\IEEEeqnarrayrulerow \\
& \raisebox{-7pt}[0pt][0pt]{Dimensions} && \raisebox{-7pt}[0pt][0pt]{$\Omega$} && \text{Volume~of} && \text{Volume~of~sphere} && \text{Number~of~states} && \raisebox{-7pt}[0pt][0pt]{$DOS(E_{t})$}  \\
& && && \text{one~state} && \text{in~}k\text{-space} && \text{in~sphere} && \\
\IEEEeqnarrayrulerow \\
& \raisebox{-2pt}[0pt][0pt]{3-D} && \raisebox{-2pt}[0pt][0pt]{$L_{x}L_{y}L_{z}$} && \begin{IEEEeqnarraybox}[\IEEEeqnarraystrutsize{24pt}{11pt}][c]{c}\frac{8\pi^{3}}{\Omega}\end{IEEEeqnarraybox} && \begin{IEEEeqnarraybox}[\IEEEeqnarraystrutsize{24pt}{11pt}][c]{c}\frac{4\pi{}k_{\parallel}^{3}}{3}\end{IEEEeqnarraybox} && \begin{IEEEeqnarraybox}[\IEEEeqnarraystrutsize{27pt}{10pt}][c]{c}\frac{\Omega{}\left(2m^{*}_{eff}E_{t}\right)^{\frac{3}{2}}}{6\pi^{2}\hbar^{3}}\end{IEEEeqnarraybox} && \begin{IEEEeqnarraybox}[\IEEEeqnarraystrutsize{20pt}{10pt}][c]{c}\frac{\Omega2\pi(2m^{*}_{eff})^\frac{3}{2}}{h^{3}}\sqrt{E_{t}}\end{IEEEeqnarraybox} \\
\IEEEeqnarrayrulerow \\
& \raisebox{-2pt}[0pt][0pt]{2-D} && \raisebox{-2pt}[0pt][0pt]{$L_{x}L_{y}$} && \begin{IEEEeqnarraybox}[\IEEEeqnarraystrutsize{18pt}{10pt}][c]{c}\frac{4\pi^{2}}{\Omega}\end{IEEEeqnarraybox} && \pi{}k_{\parallel}^{2} && \begin{IEEEeqnarraybox}[\IEEEeqnarraystrutsize{18pt}{10pt}][c]{c}\frac{\Omega2\pi{}m^{*}_{eff}E_{t}}{h^{2}}\end{IEEEeqnarraybox} && \begin{IEEEeqnarraybox}[\IEEEeqnarraystrutsize{18pt}{10pt}][c]{c}\frac{\Omega2\pi{}m^{*}_{eff}}{h^{2}}\end{IEEEeqnarraybox} \\
\IEEEeqnarrayrulerow \\
& \raisebox{-1.5pt}[0pt][0pt]{1-D} && \raisebox{-1.5pt}[0pt][0pt]{$L_{x}$} && \begin{IEEEeqnarraybox}[\IEEEeqnarraystrutsize{18pt}{10pt}][c]{c}\frac{2\pi}{\Omega}\end{IEEEeqnarraybox} && 2k_{\parallel} && \begin{IEEEeqnarraybox}[\IEEEeqnarraystrutsize{21pt}{8.5pt}][c]{c}\frac{\Omega2\sqrt{2m^{*}_{eff}E_{t}}}{h}\end{IEEEeqnarraybox} && \begin{IEEEeqnarraybox}[\IEEEeqnarraystrutsize{21pt}{13pt}][c]{c}\frac{\Omega}{h}\sqrt{\frac{2m^{*}_{eff}}{E_{t}}}\end{IEEEeqnarraybox} \\
\IEEEeqnarrayrulerow
\end{IEEEeqnarraybox}
\end{table}The volume of a sphere is \begin{equation}
Volume = \frac{4\pi{}k_{\parallel}^{3}}{3}
\end{equation}and the total number of states in that volume is \begin{equation}
\text{Number of states~in~volume}=\frac{4\pi{}k_{\parallel}^{3}}{3}\times\frac{\Omega}{8\pi^{3}}=\frac{\Omega{}k_{\parallel}^{3}}{6\pi^{2}} \label{eq:3dspv}
\end{equation}Substituting Eq.~(\ref{eq:kERel}) into (\ref{eq:3dspv}), we get \begin{equation}
\text{Number of states~in~volume}=\frac{\Omega(2m^{*}_{eff}E_{t})^{\frac{3}{2}}}{6\pi^{2}\hbar^{3}}
\end{equation}Then, we can calculate the density of states given as \begin{equation}
DOS(E_{t}) = \frac{\partial}{\partial{}E_{t}} \left(\text{Number of states~in~volume}\right)=\frac{\Omega2\pi(2m^{*}_{eff})^\frac{3}{2}}{h^{3}}\sqrt{E_{t}}
\end{equation}The same process can be repeated to calculate $DOS(E_{t})$ for 2-D and 1-D confinements, and the results are summarized in Table~\ref{tab:DOS}. Note that the number of states in sphere listed in Table~\ref{tab:DOS} is missing a factor of 2 compared to the texts found in the literature. In the literature, the factor of 2 is used to account for degeneracy in energy levels. In the NEGF approach used in this work, the degeneracy is handled by writing $\mathcal{H}$ to include up-spin and down-spin. Hence, the number of states in sphere is as listed in Table~\ref{tab:DOS}. It is important to note the parabolic dispersion relationship assumption used to obtain these results.

Once we obtain $DOS(E_{t})$, we may then calculate the charge and spin currents as \begin{equation}
\Upsilon=\mathcal{H}_{Full,k,k+1}(E_{t})G_{k+1,k}^n(E_{t}) - G_{k,k+1}^n(E_{t})\mathcal{H}_{Full,k+1,k}(E_{t})
\end{equation}
\begin{center}
\textbf{\underline{Charge current density}}
\end{center}
\begin{equation}\label{eq:negf_jcurr_modeCont}
J_{k,k+1} = Real \left(\frac{1}{i\hbar} \int_{E_{t}}\int_{E_{z}} DOS(E_{t})\cdot\left( Trace \left( \Upsilon \right)\right) \partial E_{z} \partial E_{t} \right)
\end{equation}\begin{center}
\textbf{\underline{Spin current density}}
\end{center}
\begin{equation}\label{eq:negf_js_modeCont}
\vv{J}_{S} = Real \left(\frac{1}{i2e\mu_{0}M_{S}V_{magnet}} \int_{E_{t}}\int_{E_{z}} DOS(E_{t})\cdot\left( Trace \left\lbrace \widehat{\sigma} \cdot \Upsilon\right\rbrace\right) \partial E_{z} \partial E_{t} \right)
\end{equation}

Note that we can use the same procedure to determine $DOS(E_{t})$ if box boundary conditions are used. When box boundary conditions are used, the number of $k$-states long each $k$ direction is same as when \emph{pbc} is used. However, the each state is found in [0, $\pi$] instead of [$-\pi$, $\pi$]. It seems as if the volume occupied by each state in $k$-space is smaller. However, the difference in the range over which the states are found needs to be accounted for. In the 3-D case, all $k$-states are in the first octant. In the 2-D case, all $k$-states are in the first quadrant. In the 1-D case, all $k$-states are in the left half. As a result, we get the same number of states in $k$-space sphere regardless of boundary conditions. Hence, $DOS(E_{t})$ is independent of boundary conditions when the grid spacing is sufficiently small. When we simulate an MTJ, we can assume that the electron tunneling probability is independent of the transverse mode energy. Furthermore, we have $L_{x}, L_{y} \geq 10$~nm and the grid spacing needed for numerical results to converge is usually $a\leq0.1$ \AA. Hence, we can approximate the sum over modes as an integral and calculate the charge and spin currents using \begin{center}
\textbf{\underline{Charge current density}}
\end{center}
\begin{equation}\label{eq:negf_jcurr_mode3D}
J_{k,k+1} = Real \left(\frac{m^{*}_{eff}A_{MTJ}}{i2\pi\hbar^{3}} \int_{E_{t}}\int_{E_{z}} \left( Trace \left( \Upsilon \right)\right) \partial E_{z} \partial E_{t} \right)
\end{equation}\begin{center}
\textbf{\underline{Spin current density}}
\end{center}
\begin{equation}\label{eq:negf_js_mode3D}
\vv{J}_{S} = Real \left(\frac{m^{*}_{eff}A_{MTJ}}{i\hbar^{2}4\pi e\mu_{0}M_{S}V_{magnet}} \int_{E_{t}}\int_{E_{z}} \left( Trace \left\lbrace \widehat{\sigma} \cdot \Upsilon\right\rbrace\right) \partial E_{z} \partial E_{t} \right)
\end{equation}where $A_{MTJ}$ is the cross-sectional area of the MTJ.

\section{Using spin current in simulation of magnetization dynamics}

In the free layer of an MTJ, the Landau-Lifshitz-Gilbert (LLG) equation used to model its behavior. The LLG equation is given as \begin{equation}
\frac{\partial\widehat{m}}{\partial t} = -|\gamma| \widehat{m}\times\vv{H}_{eff} + \alpha\left(\widehat{m}\times\frac{\partial\widehat{m}}{\partial t}\right) + \vv{STT}
\end{equation}where $\vv{H}_{eff}$ is the effective magnetic field (including all anisotropy fields, externally applied magnetic fields and magnetostatic field) acting on the free layer, which has a magnetization direction given by $\widehat{m}$. $\gamma$ is the gyromagnetic ratio (usually $2.211\times10^{5}$ m$\cdot$A$^{-1}\cdot$s$^{-1}$) and $\alpha$ is the unitless Gilbert's damping factor. As proposed by Slonczewski \cite{Slonczewski1996c}, the spin-transfer torque is given by \begin{equation}
\vv{STT}=\widehat{m}\times\vv{J}_{S}\times\widehat{m}
\end{equation}where $\vv{J}_{S}$ was given in Eqs.~(\ref{eq:negf_js}), (\ref{eq:negf_js_modeDis}), (\ref{eq:negf_js_modeCont}) and (\ref{eq:negf_js_mode3D}).


\documentclass[class=report, float=false, crop=false]{standalone}
\usepackage[subpreambles=true]{standalone}

\input{preamble}

\graphicspath{{figures/images/}}

% \begin{cbunit}

\begin{document}

\chapter{Elastic force between ellipsoids}
\label{appendix:force}

\section{Reduced belonging matrix}

An ellipsoid $\mathcal{A}$ of centre $\vec{v}$ and semi-axes $(R_i)_{i=1:3}$ can be described by the matrix
\begin{equation}
\bar{B}(O,(R_i)_{i=1:3}) \equiv O \text{diag}(R_i^{-2})_{i=1:3} O^T
\end{equation}
where $O$ is the symmetric rotation matrix corresponding to the change of basis from the ellipsoid frame to the reference frame, such as
\begin{equation}
\forall \vec{r} \in \mathbb{R}^3, \begin{cases} (\vec{r} - \vec{v})^T \bar{B} (\vec{r} - \vec{v}) < 1 &\text{ if } \vec{r} \in \mathcal{A} \setminus \bar{\mathcal{A}} \\ (\vec{r} - \vec{v})^T \bar{B} (\vec{r} - \vec{v}) = 1 &\text{ if } \vec{r} \in \bar{\mathcal{A}} \\ (\vec{r} - \vec{v})^T \bar{B} (\vec{r} - \vec{v}) > 1 &\text{ if } \vec{r} \notin \mathcal{A} \end{cases}
\end{equation}
and with which we can write
\begin{equation}
\mu^2(\vec{r}\in\mathbb{R}^3) = (\vec{r}-\vec{v})^T\bar{B}(O,(R_i)_{i=1:3})(\vec{r}-\vec{v})
\label{rescaling_factor_squared}
\end{equation}
where $\mu(\vec{r})$ is the rescaling factor that has to be applied to the axes of $\mathcal{A}$ for $\vec{r}$ to be on its surface.\\

For simplicity, we will write $\bar{B}_{\mathcal{A}} \equiv \bar{B}(O,(R_i)_{i=1:3})$.\\

We have for all $\vec{r}$ on the surface of $\mathcal{A}$ that $\mu^2(\vec{r})=1$, therefore the surface of $\mathcal{A}$ is an isosurface of $\mu^2$. Therefore, we can conclude that the vector
\begin{equation}
\vec{\nabla}\mu^2(\vec{r}) = 2\bar{B}_{\mathcal{A}}(\vec{r}-\vec{v})
\end{equation}
is orthogonal to the surface of $\mathcal{A}$ in $\vec{r}$.

\section{Force}

We assumed that the force exerted on an ellipsoid $\mathcal{A}$ by an ellipsoid $\mathcal{B}$ of centre $\vec{r}_{\mathcal{A}}$ and $\vec{r}_{\mathcal{B}}$ respectively is
\begin{equation}
\vec{f}_{\mathcal{A}\mathcal{B}}^{\text{el}}(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}}) = k_e (1 - \mu(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}}))\frac{d\mu}{d\vec{r_{\mathcal{A}}}}(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}})
\end{equation}
according to equation \ref{pre_force_el_ellipsoids}, where $\mu(\vec{r}_{\mathcal{A}},\vec{r}_{\mathcal{B}})$ is the rescaling factor that has to be applied to both $\mathcal{A}$ and $\mathcal{B}$ for them to be externally tangent.\\

Contrarily to the case of spheres, we have for ellipsoids that the rescaling factor $\mu(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}})$ is not uniquely determined by the positions of their centres. Indeed, if we were to add $\vec{dr_{\mathcal{A}}}$ to the position $\vec{r_{\mathcal{A}}}$ of the centre of ellipsoid $\mathcal{A}$, the contact point $\vec{r_C}$ with ellipsoid $\mathcal{B}$ would move as well.\\

Since we are looking for the first derivative of the quantity $\mu(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}})$, we will approximate rescaled ellipsoids by their respective tangent planes at $\vec{r_C}$ as suggested by \cite{donev}.\\

\begin{figure}[h!]
\centering
\includestandalone{figures/tikz/derivative_rescaling_factor}
\caption{Ellipsoids rescaled with rescaling factor $\mu(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}})$ and their contact plane in plain thick trait. Ellipsoids rescaled with rescaling factor $\mu(\vec{r_{\mathcal{A}}} + \vec{dr_{\mathcal{A}}},\vec{r_{\mathcal{B}}})$ and their contact plane in dashed trait.}
\label{contact_points_fig}
\end{figure}

If ellipsoid $\mathcal{A}$ is moved by $\vec{dr_{\mathcal{A}}}$, there appears a gap $dh$ between the tangent planes of the rescaled ellipsoids with
\begin{equation}
dh = \vec{dr_{\mathcal{A}}}\cdot\vec{n}_{\mathcal{A}}(\vec{r_C})
\label{dh}
\end{equation}
where $\vec{n}_{\mathcal{A}}(\vec{r_C})$ is the outward-facing unitary surface vector of ellipsoid $\mathcal{A}$ in $\vec{r_C}$.\\

To close this gap, we have to rescale the -- yet rescaled -- ellipsoids with a factor $\nu$ so that
\begin{align*}
% &d\nu~(\vec{r_C} - \vec{r_{\mathcal{A}}})\cdot\vec{n}_{\mathcal{A}}(\vec{r_C}) - d\nu~(\vec{r_C} - \vec{r_{\mathcal{B}}})\cdot\vec{n}_{\mathcal{A}}(\vec{r_C}) = dh\\
% \Leftrightarrow~ &d\nu~ (\vec{r_{\mathcal{B}}} - \vec{r_{\mathcal{A}}})\cdot\vec{n}_{\mathcal{A}}(\vec{r_C}) = dh\\
% \Leftrightarrow~ &d\nu = \frac{dh}{(\vec{r_{\mathcal{B}}} - \vec{r_{\mathcal{A}}})\cdot\vec{n}_{\mathcal{A}}(\vec{r_C})}
\left((\vec{r_C} - \vec{r_{\mathcal{A}}}) - \nu (\vec{r_C} - \vec{r_{\mathcal{A}}})\right)\cdot\vec{n}_{\mathcal{A}}(\vec{r_C}) - \left((\vec{r_C} - \vec{r_{\mathcal{B}}}) - \nu (\vec{r_C} - \vec{r_{\mathcal{B}}})\right)\cdot\vec{n}_{\mathcal{A}}(\vec{r_C}) = dh \Rightarrow 1 - \nu = \frac{dh}{(\vec{r_{\mathcal{B}}} - \vec{r_{\mathcal{A}}})\cdot\vec{n}_{\mathcal{A}}(\vec{r_C})}
\end{align*}
and
\begin{align*}
\mu(\vec{r_{\mathcal{A}}} + \vec{dr_{\mathcal{A}}},\vec{r_{\mathcal{B}}}) = \nu\mu(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}}) \Rightarrow \vec{dr_{\mathcal{A}}}\cdot\frac{d\mu}{\vec{dr_{\mathcal{A}}}}(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}}) = -\mu(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}})(1 - \nu)
\end{align*}
which, with equation \ref{dh}, leads to
\begin{align*}
\frac{d\mu}{d\vec{r_{\mathcal{A}}}}(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}}) = -\mu(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}})\frac{\vec{n}_{\mathcal{A}}(\vec{r_C})}{(\vec{r_{\mathcal{B}}} - \vec{r_{\mathcal{A}}})\cdot\vec{n}_{\mathcal{A}}(\vec{r_C})}
\end{align*}
We can then conclude, with equation \ref{surface_vec_reduced}, that
\begin{equation}
\frac{d\mu}{d\vec{r_{\mathcal{A}}}}(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}}) = -\frac{\mu(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}})}{(\vec{r_{\mathcal{B}}} - \vec{r_{\mathcal{A}}})^T\bar{B}_{\mathcal{A}}(\vec{r_C} - \vec{r_{\mathcal{A}}})}\bar{B}_{\mathcal{A}}(\vec{r_C} - \vec{r_{\mathcal{A}}})
\end{equation}
Therefore, with equation \ref{pre_force_el_ellipsoids}, we finally have that
\begin{equation}
\boxed{\vec{f}_{\mathcal{A}\mathcal{B}}^{\text{el}}(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}}) = -k_e \frac{\mu(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}})\left(1 - \mu(\vec{r_{\mathcal{A}}},\vec{r_{\mathcal{B}}})\right)}{(\vec{r_{\mathcal{B}}} - \vec{r_{\mathcal{A}}})^T\bar{B}_{\mathcal{A}}(\vec{r_C} - \vec{r_{\mathcal{A}}})}\bar{B}_{\mathcal{A}}(\vec{r_C} - \vec{r_{\mathcal{A}}})}
\label{fel_ellipsoids}
\end{equation}

% \input{references/biblio}

\end{document}

% \end{cbunit}


\documentclass[aspectratio=1610]{beamer}
\usetheme[sectionpage=progressbar, progressbar=foot]{metropolis}
\usefonttheme{professionalfonts}   % required for mathspec
\usepackage{mathspec}
\usepackage{bm}
\usepackage{color}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{float}

% ALGORITHMIC
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}

% THEME COLORS REDEF.
\definecolor{Magenta}{HTML}{B50B1E}
\definecolor{deBlue}{HTML}{0E2646}
\setbeamercolor{alerted text}{fg=Magenta}
\setbeamercolor{frametitle}{bg=deBlue}

% ENUM ITEM
\usepackage{fontawesome}
\usepackage{enumitem}
\setitemize{label=\usebeamerfont*{itemize item}%
\usebeamercolor[fg]{itemize item}
\usebeamertemplate{itemize item}}
%\SetLabelAlign{center}{\strut\smash{\parbox[t]\labelwidth{\centering#1}}}
\definecolor{ProGreen}{RGB}{56,146,94}
\definecolor{ConRed}{RGB}{209,28,22}
\newcommand*\pro{%
  \item[\color{ProGreen}\scalebox{1.5}{\faThumbsOUp}]}
\newcommand*\con{%
  \item[\color{ConRed}\scalebox{1.5}{\faThumbsODown}]}

% FONT
%\setsansfont[BoldFont={Fira Sans},
%Numbers={OldStyle}]{Fira Sans Light}
%\setmathsfont(Digits)[Numbers={Lining, Proportional}]{FiraSans Light}

% BIBLIO
\usepackage[backend=bibtex,style=authoryear-icomp,maxbibnames=9,maxcitenames=2]{biblatex}
\renewcommand*{\nameyeardelim}{\addcomma\addspace}
\bibliography{3DRegistration.bib}
%\setbeamertemplate{bibliography item}{\insertbiblabel} %Removes icon in bibliography
\renewcommand*{\cite}{\parencite}

% INTRO
\title{3D Rigid Registration}
\subtitle{Algorithms survey}
% \date{\today}
\author{Pasquale Antonante}
%\institute{United Technology Research Center}
%\titlegraphic{\hfill\includegraphics[height=0.8cm]{imgs/logo_utrc.png}}

%% UTILITIES
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\newcommand{\Ealign}{\bm{q}_i-\bm{T}\bm{p}_i}
\DeclareMathOperator*{\argmin}{argmin}
\DeclareMathOperator*{\argmax}{argmax}

\begin{document}
\maketitle

% ===== BEGIN =====

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Introduction                                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Introduction}
%%
\begin{frame}[fragile]{Problem definition}
  \begin{alertblock}{Surface registration}
  Surface registration \textbf{transforms} multiple sets of 3D data points into the same coordinate system so as to \textbf{align overlapping} components of these sets.
\end{alertblock}
\end{frame}

%%
\begin{frame}[allowframebreaks]{Basic notation}
Let's consider two point sets $\bm{P}$ and $\bm{Q}$ we want to find a rigid transformation $\bm{T}$ (rotation $\bm{R}$ and translation $\bm{t}$) that aligns $\bm{Q}$ to $\bm{P}$.

In general we want to minimize the error $E(\bm{T})$
\[
%E(\bm{T})=\sum_i{\norm{q_i-\bm{T}p_i}}+E_{\text{reg}}, \quad \text{where}~
E(\bm{T})=E_{\text{align}}+E_{\text{reg}}, \quad \text{where}
\bm{T} = \begin{bmatrix}
   \bm{R} & \bm{t} \\
   \bm{0}^{T} & 1
\end{bmatrix}
\]
$E_{\text{align}}$ measure the \textbf{alignment error} while $E_{\text{reg}}$ is a \textbf{regularization} term.

\framebreak

There are two main metrics to measure the $E_{\text{align}}$
%\begin{equation}
\begin{align}
E_\text{pt-to-pt} &= \sum_i{\norm{\Ealign}^2} \label{pt2pt} \\
E_\text{pt-to-plane} & = \sum_i{\big((\Ealign)\cdot\bm{n}_{q_i}\big)^2} \label{pt2pl}
\end{align}
%\end{equation}

\framebreak

\begin{figure}[htbp]
\begin{center}
\begin{minipage}[b]{0.45\linewidth}
  \centering
  \includegraphics[width=\textwidth,keepaspectratio]{imgs/pt2pt.png}
  \caption{Point-to-Point Distance}
  \label{fig:pt2pt}
\end{minipage}
\begin{minipage}[b]{0.45\linewidth}
  \centering
  \includegraphics[width=\textwidth,keepaspectratio]{imgs/pt2plane.png}
  \caption{Point-to-Plane Distance}
  \label{fig:pt2pl}
\end{minipage}
\end{center}
\caption{Error metrics \cite{bellekens2014survey}}
\end{figure}

\framebreak

Point-to-plane proved to be more stable and faster to converge but\ldots\textbf{Least Sum of Square Errors} has a closed-form solution!

If we know the \textbf{perfect correspondence} of a subset of points (at least 3) we can compute the rigid transformation
\begin{itemize}
  \item Rotation matrix, e.g. \cite{schonemann1966generalized}, \cite{arun1987least}, \cite{horn1988closed}, \cite{umeyama1991least}
  \item Quaternions, e.g. \cite{horn1987closed}
\end{itemize}

But \textbf{true correspondences} are difficult do be found.
\end{frame}

\begin{frame}[allowframebreaks]{(Non)-Convexity Analysis}
Let's focus on the \textbf{point-to-point} formulation.

Define
\begin{itemize}
\item Transformation function as $T_x(\alpha)$ that \textbf{affinely transforms} a point $x$, according to some parameter $\alpha=(\bm{R},\bm{t})$
\item The \textbf{distance-to-a-set operator} $d(x)=\inf_{y\in\mathcal{Y}}\norm{x-y}$
\end{itemize}

The \textbf{residual function} $E(\alpha)=d(T_x(\alpha))$ is \emph{convex} if
\begin{itemize}
  \item \emph{(Condition 1)}. Domain $D_{\alpha}$ is a convex set
  \item \emph{(Condition 2)}. The set $\mathcal{Y}$ is convex\footnote{Proof in~\cite{olsson2009branch}}
\end{itemize}

\framebreak

In our case
\begin{itemize}
  \item \emph{Condition 1} cannot be fulfilled for registration with rotation (due to the constraint $\bm{R}\bm{R}^T=\bm{I}$)
  \item \emph{Condition 2} is rarely fulfilled because set $\mathcal{Y}$  is a scan of complex surfaces
\end{itemize}
Therefore, $E(\alpha)$ is \textbf{non-convex}.
\end{frame}

%\begin{frame}{Closed-Form Solution}

%\end{frame}

\begin{frame}{Global vs Local}
\begin{alertblock}{Global vs. Local}
3D Rigid Registration can be classified according to the used \textbf{underlying optimization method}~\cite{rusu2009fast}:
\begin{itemize}
\item \textbf{Global}% (e.g. Genetic Algorithms)
\item \textbf{Local} (e.g. Iterative Closest Point (ICP))
\end{itemize}
\end{alertblock}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Iterative Closest Points                          %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Iterative Closest Points (ICP)} %[Besl & McKay 92]
\begin{frame}[shrink=10]{Basic ICP}
\begin{algorithm}[H]
\begin{algorithmic}[1]
%\STATE Estimate initial registration states
%\STATE Apply initial registration
%\WHILE{Alignment MSE greater than threshold}
%\STATE Compute closest points
%\STATE Compute registration $T$
%\STATE Apply registration
%\ENDWHILE
\REQUIRE $\bm{P}$, $\bm{Q}$ and initial estimation $\bm{T}_0$
\ENSURE $\bm{T}$
\STATE $\bm{T}\gets\bm{T}_0$
\WHILE{not converged}
  \FOR{$i\gets 1$ \TO $N$}
    \STATE $\bm{m}_i\gets\text{FindClosestPointInQ}(\bm{T}\bm{p}_i$)
    \IF{$\norm{\bm{m}_i-\bm{T}\bm{p_i}}\leq d_{\text{max}}$}
      \STATE $\omega_i\gets 1$
    \ELSE
      \STATE $\omega_i\gets 0$
    \ENDIF
  \ENDFOR
  \STATE $\bm{T}\gets\argmin\limits_T \sum\limits_i \omega_i \norm{\bm{m}_i-\bm{T}\bm{p}_i}$
\ENDWHILE
\end{algorithmic}
\caption{Iterative Closest Points (ICP)}
\label{alg:ICP}
\end{algorithm}
\end{frame}

\begin{frame}{Considerations}
\begin{itemize}[wide, labelsep=2em]
  \pro Solves the correspondence problem
  \con May get caught in local minima
  \con Require (and depends) an initial registration guess
  \con Computes closest points set each iteration
\end{itemize}
\end{frame}

\begin{frame}{Local Optimization Method}
%ICP is a \textbf{local optimization algorithm} and may get caught in local minima.

There is a lot of work around ICP addressing the local minima issue, some relevant methods are:
\begin{itemize}
	\item \textbf{Robustified Local Methods}
	\item \textbf{Global Methods} (GA, Particle filtering, Simulated Annealing)
	\item \textbf{Globally Optimal Methods} (i.e. BnB)
\end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Global Go-ICP                                     %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{GO-ICP (2016)}
%%
\begin{frame}{Introduction}
Global-ICP (GO-ICP)~\cite{goicp} optimally solves 3D registration by mixing ICP and BnB.
\begin{figure}[htbp]
\begin{center}
  \includegraphics[width=\textwidth,height=0.45\textheight,keepaspectratio]{imgs/GOICP_collaboration.png}
  \caption{Collaboration of BnB and ICP.}
  \label{fig:goicp_collaboration}
\end{center}
\end{figure}
\end{frame}

\begin{frame}[allowframebreaks]{Domain Parametrization}
To parametrize the search space let's consider the \textbf{angle-axis} representation of rotations, obtaining
\begin{itemize}
	\item the rotation space $SO(3)$ is parametrized in a solid radius-$\pi$ ball
	\item the translation is assumed to be within the cube $[-\xi,\xi]^3$ (denoted as $C_t$)
\end{itemize}
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=\textwidth,height=0.3\textheight,keepaspectratio]{imgs/GOICP_parametrization.png}
\caption{$SE(3)$ space parametrization in GO-ICP}
\label{default}
\end{center}
\end{figure}
\end{frame}

%%
\begin{frame}[allowframebreaks]{Bounding Functions}
For ease of manipulation, let's use the minimum cube $[−\pi,\pi]^3$ that encloses the $\pi$-ball centered in $\bm{r}_0$ as $C_r$.

\begin{theorem}[Uncertainty radius]
Given a 3D point $\bm{p}$, a rotation cube $C_r$ of half side-length $\sigma_r$ with $r_0$ as the center and examining the maximum distance from $\bm{R}_{\bm{r}}\bm{p}$ to $\bm{R}_{\bm{r_0}}\bm{p}$, we have $\forall\bm{r}\in C_r$,
\[ \norm{\bm{R}_r\bm{p}-\bm{R}_{r_0}\bm{p}} \leq 2\sin(\min(\sqrt{3}\sigma_r/2,\pi/2))\norm{\bm{p}} = \gamma_r \]
Or similarly, given a translation cube $C_t$ with half side-length $\sigma_t$ centered at $\bm{t_0}$, we have $\forall\bm{t}\in C_t$
\[ \norm{(\bm{p}+\bm{t}) - (\bm{p}-\bm{t}_0)} \leq \sqrt{3}\sigma_t = \gamma_t \]
\end{theorem}
\end{frame}

%%
\begin{frame}{BnB Bounds}
%Instead of direct 6D space exploration, a \textbf{nested BnB} search is proposed:
%\begin{itemize}
%  \item \textbf{Outer BnB} searches the rotation space of $SO(3)$
%  \item \textbf{Inner BnB} called by the outer BnB, solves the translation problem
%\end{itemize}

%The upper $\overline{E}$ bound and the lower bound $\underline{E}$ for both BnB can be derived~\cite{goicp}.

%\framebreak
For a given rotation cube $C_r$
\begin{equation}
  \begin{array}{ll}
  \overline{E}_r &= \min\limits_{\forall\bm{t}\in\mathcal{C}_t} \sum\limits_i e_i (\bm{R}_{\bm{r}_0}, \bm{t})^2 \\
  \underline{E}_r &= \min\limits_{\forall\bm{t}\in\mathcal{C}_t} \sum\limits_i \max \big(e_i(\bm{R}_{\bm{r}_0},t)-\gamma_{r_i},0\big)^2
  \end{array}
\end{equation}
Similarly, for a given translation cube $C_t$
\begin{equation}
\begin{array}{ll}
  \overline{E}_t &= \sum\limits_i \max\big( e_i(\bm{R}_{\bm{r}_0},\bm{t_0})-\gamma_{r_i}, 0 \big)^2 \\
  \underline{E}_t &= \sum\limits_i \max \big( e_i(\bm{R}_{\bm{r}_0},\bm{t_0}) - (\gamma_{r_i} + \gamma_t),0 \big)^2
\end{array}
\label{eq:goicp_outerbound}
\end{equation}
where $e_i(\bm{R},\bm{t})=\norm{\bm{q}_{j^*}-\bm{R}\bm{p}_i}$, with $\bm{q}_{j^*}$ denoted as optimal correspondence of $\bm{p}_i$; $\mathcal{C}_r$ and $\mathcal{C}_t$ are the initial cubes.
\end{frame}

%%
\begin{frame}[shrink=36]{Go-ICP algorithm}
\begin{columns}
\begin{column}{0.5\textwidth}
  \begin{algorithm}[H] %% outer
  \begin{algorithmic}[1]
  \REQUIRE $\bm{P}$, $\bm{Q}$, threshold $\epsilon$, initial cubes $\mathcal{C}_r$, $\mathcal{C}_t$
  \ENSURE Globally minimal error $E^*$ and corresponding $\bm{r}^*$, $\bm{t}^*$
  \STATE Put $\mathcal{C}_r$ into priority queue $Q_r$
  \STATE Set $E^*=+\infty$
  \LOOP
    \STATE Read out a cube with lowest $\underline{E}_r$ from $Q_r$
    \STATE Quit if $E^*-\underline{E}_r<\epsilon$
    \STATE Divide the cube into 8 sub-cubes
    \FORALL{sub-cube $C_r$}
      \STATE Compute $\overline{E}_r$ for $C_r$ and corresponding optimal $\bm{t}$ by calling alg.\ref{alg:goicp_inner} with $\bm{r}_0$, $\gamma_r=0$ and $E^*$
      \IF{$\overline{E}_r<E^*$}
        \STATE Run ICP with initialization $(\bm{r}_0,\bm{t})$
        \STATE Update $E^*$, $r^*$ and $t^*$ with ICP results
      \ENDIF
      \STATE Compute $\underline{E}_r$ for $C_r$ by calling alg.\ref{alg:goicp_inner} with $\bm{r}_0$, $\gamma_r$ and $E^*$
      \IF{$\underline{E}_r \geq E^*$}
        \STATE Discard $C_r$ and continue the loop
      \ENDIF
      \STATE Put $C_r$ into $Q_r$
    \ENDFOR
  \ENDLOOP
  \end{algorithmic}
  \caption{Go-ICP -- Outer BnB}
  \label{alg:goicp_outer}
  \end{algorithm}
\end{column}

\begin{column}{0.5\textwidth}

  \begin{algorithm}[H] %% inner
  \begin{algorithmic}[1]
  \REQUIRE $\bm{P}$, $\bm{Q}$, threshold $\epsilon$, initial cube $\mathcal{C}_t$, rotation $r_0$, rotation uncertainty radii $\gamma_r$, so-far-best-error $E^*$
  \ENSURE Minimal error $E_t^*$ and corresponding $\bm{t}^*$
  \STATE Put $\mathcal{C}_t$ into priority queue $Q_t$
  \STATE Set $E^*_t = E^*$
  \LOOP
    \STATE Read out a cube with lowest $\underline{E}_t$ from $Q_t$
    \STATE Quit the loop if $E_t^*-\underline{E}_t<\epsilon$
    \STATE Divide the the cube into 8 sub-cubes
    \FORALL{sub-cube $C_T$}
      \STATE Compute $\overline{E}_t$ for $C_t$ by~\ref{eq:goicp_outerbound} with $\bm{r}_0$, $\bm{t}_0$ and $\gamma_r$
      \IF{$\overline{E}_t<E_t^*$}
        \STATE Update $E_t^*=\overline{E}_t$, $t^*=t_0$
      \ENDIF
      \STATE Compute $\underline{E}_t$ for $C_t$ by~\ref{eq:goicp_outerbound} with $\bm{r}_0$, $\bm{T}_0$ and $\gamma_t$
      \IF{$\underline{E}_t \geq E_t^*$}
        \STATE Discard $C_t$ and continue the loop
      \ENDIF
      \STATE Put $C_t$ into $Q_r$
    \ENDFOR
  \ENDLOOP
  \end{algorithmic}
  \caption{Go-ICP -- Inner BnB}
  \label{alg:goicp_inner}
  \end{algorithm}

\end{column}
\end{columns}
\end{frame}

%%
\begin{frame}[allowframebreaks]{Experiment}
\begin{figure}[htbp]
\begin{center}
  \includegraphics[width=\textwidth,height=0.5\textheight,keepaspectratio]{imgs/GOICP_eval.png}
  \caption{Running time of the Go-ICP method on the bunny and dragon point-sets with respect to different factors.}
  \label{fig:goicp_evaluation}
\end{center}
\end{figure}
\hspace{2em}
\begin{figure}[htbp]
\begin{center}
  \includegraphics[width=\textwidth,height=0.5\textheight,keepaspectratio]{imgs/GOICP_timehistogram.png}
  \caption{Running time histograms of Go-ICP for the bunny (left) and dragon (right) point-sets.}
  \label{fig:goicp_timehistogram}
\end{center}
\end{figure}
\end{frame}

%%
\begin{frame}{Go-ICP Trimming}
In \cite{goicp} a \textbf{trimmed} version of the algorithm is also proposed. Specifically, in each iteration, only a subset $\bm{S}$ of the data points are used for motion computation.

This is a strategy to obtain a more robust statistic by excluding some of the extreme values.
\end{frame}

\begin{frame}{Considerations}
\begin{itemize}[wide, labelsep=2em]
  \pro Finds the global optimal solution
  \pro Defines upper and lower bound in domain regions
  \pro Not constrained to ICP variants
  \pro Parallelism can speed up computation a lot
  \con Limited to pt-to-pt distance
  \con Computes closest points set each iteration
  \con Computationally demanding
\end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Generalized ICP                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Generalized ICP (2009)}
%%
\begin{frame}[allowframebreaks]{Derivation}
The Generalized-ICP~\cite{gicp} uses \textbf{probabilistic approach} to increase robustness by changing
\[ \bm{T}\gets\argmin\limits_T \sum\limits_i \omega_i \norm{\bm{m}_i-\bm{T}\bm{p}_i} \]
in the basic ICP algorithm (alg.~\ref{alg:ICP}).

\framebreak

For the purpose of this section let's assume that:
\begin{itemize}
  \item $\bm{p}_i$ is a correspondence for $\bm{q}_i$ (and vice versa) - W.L.O.G.
  \item $\hat{\bm{P}}=\{\hat{\bm{p}}_i\}, \quad \bm{p}_i \sim \mathcal{N}(\hat{\bm{p}}_i,\bm{C}_i^P)$
  \item $\hat{\bm{Q}}=\{\hat{\bm{q}}_i\}, \quad \bm{q}_i \sim \mathcal{N}(\hat{\bm{q}}_i,\bm{C}_i^Q)$
\end{itemize}
where $\bm{C}_i^P$ and $\bm{C}_i^Q$ are covariance matrices associated with the measured points.

%\framebreak
%%(geometrically consistent with no errors due to occlusion or sampling)
%Assuming \textbf{perfect correspondences} we have a transformation $\bm{T}^*$ such that
%\[\hat{\bm{q}_i}=\bm{T}^*\hat{\bm{p}_i} \]

%For an arbitrary rigid transformation, $\bm{T}$, define
%\[ d_i^{(\bm{T})}=\bm{q}_i-\bm{T}\bm{p}_i \]

%Consider the distribution from which $d(\bm{T}^*)$ is drawn. Since $\bm{p}_i$ and $\bm{q}_i$ are assumed to be drawn from independent Gaussians,
%\[
%\begin{array}{ll}
%d_i^{(\bm{T}^*)} &\sim \mathcal{N}\Big(\bm{q}_i - (\bm{T}^*)\bm{p}_i,~ \bm{C}_i^Q +(\bm{T}^*)\bm{C}_i^P(\bm{T}^*)^T \Big) \\
%&= \mathcal{N}\Big( 0,~ \bm{C}_i^Q +(\bm{T}^*)\bm{C}_i^P(\bm{T}^*)^T \Big)
%\end{array}
%\]

\framebreak

%We can use \textbf{Maximum likelihood estimation} to iteratively compute $\bm{T}$
%\[ \bm{T} = \argmax\limits_{\bm{T}} \prod\limits_i p\big( d_i^{(\bm{T})} \big)
%     = \argmax\limits_{\bm{T}} \sum\limits_i \log \big(
%     p\big( d_i^{(\bm{T})} \big) \big)
%\]
%that can be simplified to
%\begin{equation}
%\bm{T} = \argmin\limits_{\bm{T}} \sum\limits_i {d_i^{(\bm{T})}}^T ( \bm{C}_i^Q+ \bm{T} \bm{C}_i^P \bm{T}^T)^{-1} d_i^{(\bm{T})}
%\end{equation}
%This defines the \textbf{key step} of the Generalized-ICP algorithm.

We can use \textbf{Maximum likelihood estimation} to iteratively compute $\bm{T}$
\[ \bm{T} = \argmax\limits_{\bm{T}} \prod\limits_i p\big( \Ealign \big)
     = \argmax\limits_{\bm{T}} \sum\limits_i \log \big(
     p\big( \Ealign \big) \big)
\]
that can be simplified to
\begin{equation}
\bm{T} = \argmin\limits_{\bm{T}} \sum\limits_i (\Ealign)^T ( \bm{C}_i^Q+ \bm{T} \bm{C}_i^P \bm{T}^T)^{-1} (\Ealign)
\end{equation}
This defines the \textbf{key step} of the Generalized-ICP algorithm (Mahalanobis distance).
\end{frame}

\begin{frame}{Results}
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=\textwidth,keepaspectratio]{imgs/gicp.png}
\caption{Average error}
\label{fig:gicp}
\end{center}
\end{figure}
\end{frame}

\begin{frame}{Considerations}
\begin{itemize}[wide, labelsep=2em]
  \pro Probabilistic approach
  \pro Covariance matrices give good flexibility
  \con Covariance matrices can be complex to compute
  \con Might get caught in local minima
  \con Still dependent on initial guess
  \con No closed form solution for $\bm{T}$ is available
\end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Learning Anisotropic ICP                          %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Learning Anisotropic ICP (2016)}

\begin{frame}{Principle}
%Within the generalized ICP framework, we need to have some strategies to determine the values of covariances.

\begin{figure}[htbp]
\begin{center}
  \includegraphics[height=0.5\textheight,keepaspectratio]{imgs/LAICP.png}
  %\caption{LA-ICP}
  \label{fig:LAICP}
\end{center}
\end{figure}
\textbf{Idea:} Learning Anisotropic ICP \cite{lee2016learning}, assumes anisotropic Gaussian, and estimates the covariance. The learning scheme does not require manual tuning and the covariance is continually updated from observed data.
\end{frame}

\begin{frame}{Pros and Cons}
\begin{itemize}[wide, labelsep=2em]
\setlength\itemsep{1em}
\pro Assumes anisotropic noise
\pro Reduces computational overhead due to covariance matrices
\con Still local optimization method
\end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Fast Global Registration                          %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Fast Global Registration (2016)}
%%
\begin{frame}{Introduction}
Let $\mathcal{K}=\{(p,q)\}$ be a set of \textbf{correspondences} collected by matching points from $\bm{P}$ and $\bm{Q}$.% as described in slide \ref{fpfh_correspondences}.

We want to minimize:
\begin{equation}
\label{eq:fastgo_obj}
E(\bm{T})=\sum_{(p,q)\in\mathcal{K}}\rho({\norm{q_i-\bm{T}p_i}})
\end{equation}
where $\rho(\cdot)$ is a \textbf{robust penalty function}, i.e. \alert{scaled Geman-McClure estimator}.
\end{frame}

%%
\begin{frame}{Scaled Geman-McClure estimator}
Using this estimator small residuals are penalized in the LS sense:
\begin{equation}
\rho(x)=\frac{\mu x^2}{\mu+x^2}
\end{equation}
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=\textwidth,height=0.5\textheight,keepaspectratio]{imgs/geman_estimator.png}
\caption{Geman-McClure estimator vs. Objective function (\ref{eq:fastgo_obj})}
\label{fig:geman}
\end{center}
\end{figure}
%The parameter $\mu$ controls the range within which residuals have a significant effect on the objective.
\end{frame}

%%
\begin{frame}[allowframebreaks]{Black-Ragarajan duality}
Objective function (\ref{eq:fastgo_obj}) is difficult to optimize directly, so the authors used \textbf{Black-Ragarajan duality} between line process and robust estimation \cite{black1996unification}.

Let's $\mathbb{L}=\{l_{(p,q)}\}$ a line process over the correspondences, we can write a new objective function optimized over $\bm{T}$ and $\mathbb{L}$.
\begin{equation}
\label{eq:fastgo_fullobj}
E(\bm{T},\mathbb{L})=\sum_{(p,q)\in\mathcal{K}}\big(l_{(p,q)}\norm{p-\bm{T}q}^2+\Psi(l_{(p,q)})\big)
\end{equation}
where
\[ \Psi(l_{(p,q)}) = \mu \big( \sqrt{l_{(p,q)}} -1 \big)^2 \]

Minimizing (\ref{eq:fastgo_fullobj}) over $\mathbb{L}$ we have:
\[ \frac{\partial{E}}{\partial{l_{(p,q)}}} = \norm{p-\bm{T}q} +\mu\frac{\sqrt{l_{(p,q)}} -1}{\sqrt{l_{(p,q)}}}  = 0 \]
Solving for $l_{(p,q)}$ yields
\begin{equation}\label{eq:fgr_lattice}
 l_{(p,q)} =  \Bigg( \frac{\mu}{\mu + \norm{p-\bm{T}q}^2}  \Bigg)^2
 \end{equation}

Substituting $l_{(p,q)}$ in (\ref{eq:fastgo_fullobj}) we obtain (\ref{eq:fastgo_obj}). Thus \textbf{optimizing objective (\ref{eq:fastgo_fullobj}) yields a solution $\bm{T}$ that is also optimal for the original objective (\ref{eq:fastgo_obj})}.

\alert{What about the correspondences?}
\end{frame}

%%

\begin{frame}[allowframebreaks]{Fast Point Feature Histogram (FPFH)}
\begin{itemize}
\item The goal of FPFH is to encode a point's \textbf{k-neighborhood geometrical properties}.
\item The complexity is $O(kN)$, where $k$ is the number of neighbors for each point~\cite{rusu2009fast}
\item It is based on the \textbf{Simple Point Feature Histogram (SPFH)}
\end{itemize}

\framebreak

\textbf{Simple Point Feature Histogram (SPFH)}
\par
For each query point $\bm{p}_q$,
\begin{itemize}
\item Compute the $k$-neighborhood set $P_k^q$
\item Compute the tuple $(\alpha,\phi,\theta)$ between $\bm{p}_q$ and each $\bm{p}_k\in P_k^q$
\begin{equation}
\begin{array}{ll}
\bm{u} & = \bm{n}_q \\
\bm{v} & = \bm{u} \times \frac{(\bm{p}_k-\bm{p}_q)}{\norm{\bm{p}_k-\bm{p}_q}} \\
\bm{w} & = \bm{u} \times \bm{v}
\end{array}	\qquad \Rightarrow \qquad
\begin{array}{ll}
\alpha & = \bm{v}\cdot\bm{n}_k \\
\phi & = \bm{u} \cdot \frac{(\bm{p}_k-\bm{p}_q)}{\norm{\bm{p}_k-\bm{p}_q}_2} \\
\theta & = \arctan(\bm{w}\cdot\bm{n}_q, \bm{u}\cdot\bm{n}_k)
\end{array}
\end{equation}
\item Bin all $(\alpha,\phi,\theta)$ into a histogram
\end{itemize}

\framebreak

To compute the FPFH histogram feature:
\begin{itemize}
  \item for each query point $\bm{p}_q$ compute the SPFH
  \item for each point its $k$ neighbors are re-determined, and the neighboring SPFH values are used to weight the final histogram of $\bm{p}_q$ (called FPFH) as in eq.\ref{eq:fpfh}
\end{itemize}

\begin{equation}
\label{eq:fpfh}
\text{FPFH}(\bm{p}_q)=\text{SPFH}(\bm{p}_q)+\frac{1}{k}\sum_{i=1}^{k}\frac{1}{\omega_k}\cdot\text{SPFH}(\bm{p}_k)
\end{equation}
where the weight $\omega_k$ represents a distance between the query point $\bm{p}_q$ and a neighbor point $\bm{p}_k$ in some given metric space.

%\begin{figure}[htbp]
%\begin{center}
%\begin{minipage}[b]{0.45\linewidth}
%            \centering
%            \includegraphics[width=\textwidth,height=0.5\textheight,keepaspectratio]{imgs/DarbouxFrame.png}
%	    \caption{Darboux Frame}
%            \label{fig:DarbouxFrame}
%        \end{minipage}
%        \hspace{0.5cm}
%        \begin{minipage}[b]{0.45\linewidth}
%            \centering
%             \includegraphics[width=\textwidth,height=0.3\textheight,keepaspectratio]{imgs/FPFH_NN.png}
%	    \caption{The influence region diagram for a Point Feature Histogram.}
%            \label{fig:FPFH_NN}
%        \end{minipage}
%\end{center}
%\end{figure}
\end{frame}

%%
\begin{frame}[allowframebreaks]{Correspondences set}\label{fpfh_correspondences}
The correspondence set is build as following, let
\begin{itemize}
\item $F(\bm{P})=\{F(\bm{p}):\bm{p}\in\bm{P}\}$ the FPFH of points in $\bm{P}$
\item $F(\bm{Q})=\{F(\bm{q}):\bm{q}\in\bm{Q}\}$ the FPFH of points in $\bm{Q}$
\end{itemize}

$\mathcal{K}_1$ is the set containing the nearest neighbor of $F(\bm{p})$ among $F(\bm{Q})$, and vice versa.

\framebreak

We can improve the correspondences set by applying:
\begin{description}
\item[Reciprocity test] A correspondence pair $(\bm{p}, \bm{q})$ is selected from $\mathcal{K}_1$ if and only if $F(\bm{p})$ is the nearest neighbor of $F(\bm{q})$ among $F(\bm{P})$ and $F(\bm{q})$ is the nearest neighbor of $F(\bm{p})$ among $F(\bm{Q})$. The resulting correspondence set is denoted by $\mathcal{K}_2$
\item[Tuple test] Randomly pick 3 correspondence pairs $(\bm{p_1}, \bm{q_1})$, $(\bm{p_2}, \bm{q_2})$, $(\bm{p_3}, \bm{q_3})$ from $\mathcal{K}_2$ and check if the tuples $(\bm{p_1}, \bm{p_2}, \bm{p_3})$ and $(\bm{q_1}, \bm{q_2}, \bm{q_3})$ are compatible
\[ \forall i\neq j, \quad \tau \le \frac{\norm{p_i-p_j}}{\norm{q_i-q_j}} \le \frac{1}{\tau}, \quad \tau=0.9 \]
This is the set used by the algorithm $\mathcal{K} = \mathcal{K}_3$
\end{description}
\end{frame}

%%
\begin{frame}{Fast Global Registration Algorithm}
Let $D$ be the diameter of the largest surface and $\delta$ the distance threshold for genuine correspondence
\begin{algorithm}[H]
\begin{algorithmic}[1]
\STATE{Compute normals $\{\bm{n}_p\}$ and $\{\bm{n}_q\}$}
\STATE{Compute $F(\bm{P})$ and $F(\bm{Q})$}
\STATE{Compute $\mathcal{K}=\mathcal{K}_3$}
%\STATE{Build $\mathcal{K}_1$ by computing nearest neighbors between $\bm{F}(\bm{P})$ and $\bm{F}(\bm{Q})$}
%\STATE{Apply reciprocity test on $\mathcal{K}_1$ to get $\mathcal{K}_2$}
%\STATE{Apply tuple test on $\mathcal{K}_2$ to get $\mathcal{K}_3$}
\STATE{$\bm{T}\gets \bm{I},~\mu\gets D^2$}
\WHILE{not converged or $\mu>\delta^2$}
\FOR{$(p,q)\in\mathcal{K}$}
\STATE{Compute $l_{(p,q)}$ using equation~\ref{eq:fgr_lattice}}
\ENDFOR
\STATE{Compute $\bm{T}$ (closed form~\cite{horn1987closed})}
\STATE{Every four iterations $\mu\gets \mu/2$}
\ENDWHILE
\end{algorithmic}
\caption{Fast Global Registration}
\label{alg:fastglobalregistration}
\end{algorithm}
\end{frame}

%%
\begin{frame}[allowframebreaks]{Performance}
\begin{figure}[htbp]
\begin{center}
\centering
\includegraphics[width=1.5\textheight,keepaspectratio]{imgs/RMSE_fgr.png}
\caption{Average and maximal RMSE achieved by global registration algorithms on synthetic range images with noise level $\sigma$}
\label{fig:fastgo_RMSR}
\end{center}
\end{figure}
\begin{figure}[htbp]
\begin{center}
\centering
\includegraphics[width=1.5\textheight,keepaspectratio]{imgs/Time_fgr.png}
\caption{Running times of global registration methods, measured in seconds}
\label{fig:fastgo_time}
\end{center}
\end{figure}

%\framebreak

%\begin{figure}[htbp]
%\begin{center}
%\centering
%\includegraphics[width=1.5\textheight,keepaspectratio]{imgs/LocalRMSE_fgr.png}
%\caption{Controlled comparison with local methods. Perturbation refers to initialization}
%\label{fig:fastgo_lacalRMSE}
%\end{center}
%\end{figure}
\begin{figure}[htbp]
\begin{center}
\centering
\includegraphics[width=1.5\textheight,keepaspectratio]{imgs/LocalTime_fgr.png}
\caption{Timing comparison with local algorithms, measured in seconds}
\label{fig:fastgo_lacalTime}
\end{center}
\end{figure}
\end{frame}

%%
\begin{frame}{Pros and Cons}
\begin{itemize}[wide, labelsep=2em]
\setlength\itemsep{1em}
\pro Global optimization
%\pro Matches ICP performance (both local and global)
\pro One order of magnitude faster
\pro Does not require initialization
\pro Correspondences computed only once but their weight change
\con No proof of global convergence in the paper
\end{itemize}
\end{frame}

% ===== BIB =====

\begin{frame}[allowframebreaks]{References}
\printbibliography
\end{frame}

\end{document}


% MARINA VON STEINKIRCH, SPRING/2013
% http://mysbfiles.stonybrook.edu/~mvonsteinkir/
\documentclass[11pt]{article}

\usepackage{epsfig}
\usepackage{color}
\usepackage{amsmath}    % Package  for subequations
\usepackage{graphicx}   % Package for figures
\usepackage{verbatim}   % Package  for program listings
\usepackage{hyperref}   % Package  for hypertext links, external documents and URLs
\usepackage{amssymb} % For mathematical constructions
\usepackage{latexsym} % Package to generate mathematical symbols
\usepackage{makeidx} % Package to generate an index in the end

\newcommand{\ie}{{\it i.e., }}
\newcommand{\eg}{{\it e.g., }}

\title{CSE 590: Computational Photography\\  Homework \#2: Image Blending }
\author{ \texttt{ Marina von Steinkirch, steinkirch@gmail.com}\\
	   \texttt{State University of New York at Stony Brook}}
\date{\today}

\begin{document}
\maketitle
\numberwithin{equation}{section}

\section{Introduction}

This project explores the gradient-domain processing, a technique with many applications including:
\begin{itemize}
\item blending,
\item tone-mapping,
\item and non-photorealistic rendering.
\end{itemize}

\quad

The  goal of this assignment is to {\it seamlessly blend} an object  from a source image into a target image. If we naively tried a simple cut and paste, we would see noticeable {\it seams}.  However, using the {\it Poisson blending technique} \cite{pois}, we are able  to achieve better results than just cutting and pasting.  The technique consists on finding values for the target pixels that {\it maximally preserve the gradient} of the source region, without changing any of the background pixels. In other words, we preserve the integrity of the gradient at the seams.

\quad

The Poisson blending technique is solved as a {\it least squares problem}, \ie given the pixel intensities of the source image, $s$, and of the target image, $t$, we  solve for {\it new intensity values},  $v$, within the source region $S$:

\begin{equation}
v = \mbox{ argmin} \sum_{i \in S, j \in N_i, S} \Bigg ( \Big ( v_i -v_j\Big) - \Big (s_i - s_j \Big) \Bigg)^2 +  \sum_{i \in S, j \in N_i, -S} \Bigg ( \Big ( v_i -t_j\Big) - \Big (s_i - s_j \Big) \Bigg)^2.
\label{aa}
\end{equation}

\quad

The idea is to recover an image that is best reflected by this edited gradient. Since the gradient provides us with linear constraints for every pixel in every color channel,
$$I_{i,j} - I_{i+1,j} = \frac{\partial}{\partial x},$$
and
$$I_{i,j} - I_{i,j+1} = \frac{\partial}{\partial y},$$
 we can formulate a {\it overdetermined system of linear equations}. Moreover, we set the desired {\it gradient field} $A x$ equals to the constraints defined by the vector field $b$ of the two images. The matrix $A$ can be seen as the representation of the gradient as a  {\it linear transformation} of the original image $x$. The result is a {\it large linear system} for each color channel with {\it one variable per pixel}, $Ax=b$.

\quad

\section{Results}

\quad

\subsection*{Toy Model: Reconstruction of an Image from its Gradient}

We start by showing that an image can be reconstructed by its gradient values, where we:
\begin{itemize}
\item preserve x-y gradients, and
\item preserve intensity of one pixel.
\end{itemize}

\quad

For this objective, we denote the {\it intensity of the source image} at $(x, y)$ as $s(x,y)$ and the value to solve for as $v(x,y)$ and, for each pixel, we had three objectives:
\begin{itemize}
\item minimize $\Bigg (v(x+1,y)-v(x,y)\Big) - \Big(s(x+1,y)-s(x,y)\Big) \Bigg)^2 $,
\item minimize $\Bigg( \Big(v(x,y+1)-v(x,y)\Big) - \Big(s(x,y+1)-s(x,y)\Big) \Bigg)^2 $,
\item minimize $\Big(v(1,1)-s(1,1)\Big)^2 $, \ie adding any constant value to $v$.
\end{itemize}

\quad

Processing the sample image with this recipe return an identical image, with  {\it root square} equal to $2.3631\times 10^{-5}$.

\quad

\subsection*{Poisson Blending}

To solve the Poisson blending for two images, we implement the following steps:
\begin{enumerate}
\item we select source and target regions (Fig. \ref{1}-1 and  \ref{1}-2),
\item we get a mask for the source image, and align the two images and the mask (Fig. \ref{1}-3 and \ref{1}-4),
\item we solve the blending constraints described in the Eq. \ref{aa},
\item we copy the solved values into the target image, where for RGB images each channel is processed separately. The cut and past and the final blending results can be seen in the Fig. \ref{1}-5 and  \ref{1}-6.
\end{enumerate}

\quad

In the Figs. \ref{1}, we see that the Poisson blending worked nicely (no seams). This is due the fact that  the penguin is surrounded by snow in the source image, matching the snow in the background of the target image. We also notice that  the overall intensity of the penguin is darker with the Poisson blending technique. This is due the fact that the intensity of the surrounding snow is slightly darker in the target area.

\quad

The same successful result can be see in the Fig. \ref{2}. The figures also  illustrate the noticeable seam in the naive cut and paste cropping.  In the other hand, in the Figs. \ref{3} and \ref{4} we see some failure examples of the Poisson blending. This is due the fact that the background of the two chosen images do not match even when taking the gradients.

\quad

\begin{figure} [ht]
\begin{center}
\includegraphics[scale=0.44]{results_poisson/set1/im1.png}
\includegraphics[scale=0.44]{results_poisson/set1/im2.png}
\includegraphics[scale=0.44]{results_poisson/set1/im3.png}
\includegraphics[scale=0.44]{results_poisson/set1/im4.png}
\includegraphics[scale=0.44]{results_poisson/set1/im5.png}
\includegraphics[scale=0.44]{results_poisson/set1/im6.png}
\caption{Sample example of Poisson blending. (left, top) Source object, (middle, top) background image, (right, top) aligned source, (left, bottom) user input mask, (middle, bottom) cut and paste result, (right, bottom) Poisson blending final result.}
\label{1}
\end{center}
\end{figure}

\quad

\begin{figure} [ht]
\begin{center}
\includegraphics[scale=0.29]{results_poisson/set4/im1.jpg}
\includegraphics[scale=0.155]{results_poisson/set4/im2.jpg}\\
\includegraphics[scale=0.54]{results_poisson/set4/im4.png}
\includegraphics[scale=0.39]{results_poisson/set4/im5.png}
\caption{My favorite blending result. (left, top) Source object, (right, top) background image,   (left, bottom) cut and paste result, (right, bottom) Poisson blending final result.}
\label{2}
\end{center}
\end{figure}

\quad

\begin{figure} [ht]
\begin{center}
\includegraphics[scale=0.2]{results_poisson/set2/im1.jpg}
\includegraphics[scale=0.2]{results_poisson/set2/im2.jpg}
\includegraphics[scale=0.49]{results_poisson/set2/im4.png}
\includegraphics[scale=0.44]{results_poisson/set2/im5.png}
\caption{An failure example of Poisson example: the texture of the background of the two images are too distant for a simple gradient mixing. (left, top) Source object, (right, top) background image,   (left, bottom) cut and paste result, (right, bottom) Poisson blending final result.}
\label{3}
\end{center}
\end{figure}

\quad

\begin{figure} [ht]
\begin{center}
\includegraphics[scale=0.12]{results_poisson/set5/im1.jpg}
\includegraphics[scale=0.28]{results_poisson/set5/im2.jpg}
\includegraphics[scale=0.54]{results_poisson/set5/im4.png}
\includegraphics[scale=0.47]{results_poisson/set5/im5.png}
\caption{Another failure  example of Poisson example, here the gradient literally changes the color of the Sun, however in the object are not corrected.(left, top) Source object, (right, top) background image,   (left, bottom) cut and paste result, (right, bottom) Poisson blending final result.}
\label{4}
\end{center}
\end{figure}

\quad

\subsection*{Mixed Blending}
To improve cases where we see failure in the Poisson bending,  we try to implement an adaptation of the Eq. \ref{aa},
\begin{equation}
v = \mbox{ argmin} \sum_{i \in S, j \in N_i, S} \Bigg ( \Big ( v_i -v_j\Big) - d_{i,j} \Bigg)^2 +  \sum_{i \in S, j \in N_i, -S} \Bigg ( \Big ( v_i -t_j\Big) - d_{i,j} \Bigg)^2,
\end{equation}
where $d_{i,j}$ is the value of the gradient from the source or the target image with {\it larger magnitude}. However this technique  did not show any improvement in the above examples.

\newpage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%		Ref		%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{thebibliography}{}

\bibitem{mike}{\it Tamara Berg's Class}, {\it http://www.tamaraberg.com/teaching/Spring13/compphotog/3}

\bibitem{pois} {\it Poisson Editing}, Patrick Perez, Michel Gangnet, $\&$ Andrew Blacke, 2003

\end{thebibliography}

\end{document}


\chapter{Small oscillations-solutions}
\begin{abox}
	Practice set 1
\end{abox}
\begin{enumerate}
		\item  A particle of unit mass moves in a potential $V(x)=a x^{2}+\frac{b}{x^{2}}$, where $a$ and $b$ are positive constants. The angular frequency of small oscillations about the minimum of the potential is
		{\exyear{NET JUNE 2011}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $\sqrt{8 b}$
		\task[\textbf{B.}]$\sqrt{8 a}$
		\task[\textbf{C.}] $\sqrt{8 a / b}$
		\task[\textbf{D.}]$\sqrt{8 b / a}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		V(x)&=a x^{2}+\frac{b}{x^{2}} \Rightarrow \frac{\partial V}{\partial x}=0 \Rightarrow 2 a x-\frac{2 b}{x^{3}}=0 \Rightarrow a x^{4}-b=0 \Rightarrow x_{0}=\left(\frac{b}{a}\right)^{\frac{1}{4}}\\
		\text { Since } \omega&=\sqrt{\frac{k}{m}}, m=1\\
		k&=\left.\frac{\partial^{2} V}{\partial x^{2}}\right|_{x=x_{0}} \text { where } x_{0} \text { is stable equilibrium point. }\\
		\text { Hence } k&=\frac{\partial^{2} V}{\partial x^{2}}=2 a+\frac{6 b}{x_{0}^{4}}=2 a+\frac{6 b}{b /}=8 a \text { at } x=x_{0}=\left(\frac{b}{a}\right)^{\frac{1}{4}}\\
		\text { Thus, } \omega&=\sqrt{8 a} \text {. }
		\end{align*}
		The correct option is \textbf{(b)}
	\end{answer}
		\item Consider the motion of a classical particle in a one dimensional double-well potential $V(x)=\frac{1}{4}\left(x^{2}-2\right)^{2} .$ If the particle is displaced infinitesimally from the minimum on the $x$-axis (and friction is neglected), then
		{\exyear{NET JUNE 2012}}
	\begin{tasks}(1)
		\task[\textbf{A.}] the particle will execute simple harmonic motion in the right well with an angular frequency $\omega=\sqrt{2}$
		\task[\textbf{B.}]the particle will execute simple harmonic motion in the right well with an angular frequency $\omega=2$
		\task[\textbf{C.}]the particle will switch between the right and left wells
		\task[\textbf{D.}]the particle will approach the bottom of the right well and settle there
	\end{tasks}
	\begin{answer}
		\begin{align*}
		V(x)&=\frac{1}{4}\left(x^{2}-2\right)^{2} \Rightarrow \frac{\partial V}{\partial x}=\frac{2}{4}\left(x^{2}-2\right) \times 2 x=0 \Rightarrow x=0, x=\pm \sqrt{2}\\
		\frac{\partial^{2} V}{\partial x^{2}}&=3 x^{2}-2\\
		\text { At } x=0, \frac{\partial^{2} V}{\partial x^{2}}&<0 \text { so } V \text { is maximum. Thus it is unstable point }\\
		\left.\frac{\partial^{2} V}{\partial x^{2}}\right|_{x=\pm \sqrt{2}}&=4 \text { and it is stable equilibrium point with } \omega=\sqrt{\frac{\left.\frac{\partial^{2} V}{\partial x^{2}}\right|_{x=x_{0}}}{\mu}}=2 \quad \because \mu=1 \text {. }
		\end{align*}
		The correct option is \textbf{(b)}
	\end{answer}

		\item Three particles of equal mass $(\mathrm{m})$ are connected by two identical massless springs of stiffness constant $(K)$ as shown in the figure\\
		\begin{figure}[H]
			\centering
			\includegraphics[height=1cm,width=5cm]{problem1}
		\end{figure}
		If $x_{1}, x_{2}$ and $x_{3}$ denote the horizontal displacement of the masses from their respective equilibrium positions the potential energy of the system is
		{\exyear{NET DEC 2012}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $\frac{1}{2} K\left[x_{1}^{2}+x_{2}^{2}+x_{3}^{2}\right]$
		\task[\textbf{B.}]$\frac{1}{2} K\left[x_{1}^{2}+x_{2}^{2}+x_{3}^{2}-x_{2}\left(x_{1}+x_{3}\right)\right]$
		\task[\textbf{C.}]$\frac{1}{2} K\left[x_{1}^{2}+2 x_{2}^{2}+x_{3}^{2}-2 x_{2}\left(x_{1}+x_{3}\right)\right]$
		\task[\textbf{D.}]$\frac{1}{2} K\left[x_{1}^{2}+2 x_{2}^{2}-2 x_{2}\left(x_{1}+x_{3}\right)\right]$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		V&=\frac{1}{2} K\left(x_{2}-x_{1}\right)^{2}+\frac{1}{2} K\left(x_{3}-x_{2}\right)^{2}\\
		V&=\frac{1}{2} K\left(x_{2}^{2}+x_{1}^{2}-2 x_{2} x_{1}\right)+\frac{1}{2} K\left(x_{3}^{2}+x_{2}^{2}-2 x_{3} x_{2}\right)\\
		V&=\frac{1}{2} K\left[x_{1}^{2}+2 x_{2}^{2}+x_{3}^{2}-2 x_{2}\left(x_{1}+x_{3}\right)\right]
		\end{align*}
		The correct option is \textbf{(c)}
	\end{answer}
		\item The time period of a simple pendulum under the influence of the acceleration due to gravity $g$ is $T$. The bob is subjected to an additional acceleration of magnitude $\sqrt{3} g$ in the horizontal direction. Assuming small oscillations, the mean position and time period of oscillation, respectively, of the bob will be
		{\exyear{NET JUNE 2014}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $0^{\circ}$ to the vertical and $\sqrt{3} T$
		\task[\textbf{B.}]$30^{\circ}$ to the vertical and $T / 2$
		\task[\textbf{C.}]$60^{\circ}$ to the vertical and $T / \sqrt{2}$
		\task[\textbf{D.}]$0^{\circ}$ to the vertical and $T / \sqrt{3}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		T&=2 \pi \sqrt{\frac{l}{g}}\\
		g^{\prime}&=\sqrt{3 g^{2}+g^{2}}=\sqrt{4 g^{2}}=2 g\\
		T^{\prime}&=2 \pi \sqrt{\frac{l}{2 g}} \Rightarrow T^{\prime}=2 \pi \sqrt{\frac{l}{g}} \cdot \frac{1}{\sqrt{2}} \Rightarrow T^{\prime}=\frac{T}{\sqrt{2}}\\
		T \cos \theta&=m g, T \sin \theta=\sqrt{3} m g \Rightarrow \tan \theta=\sqrt{3} \Rightarrow \theta=60^{\circ}
		\end{align*}
		The correct option is \textbf{(c)}
	\end{answer}
		\item A particle of mass $m$ is moving in the potential $V(x)=-\frac{1}{2} a x^{2}+\frac{1}{4} b x^{4}$ where $a, b$ are positive constants. The frequency of small oscillations about a point of stable equilibrium is
		{\exyear{NET DEC 2014}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $\sqrt{a / m}$
		\task[\textbf{B.}]$\sqrt{2 a / m}$
		\task[\textbf{C.}]$\sqrt{3 a / m}$
		\task[\textbf{D.}]$\sqrt{6 a / m}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		\because V(x)&=-\frac{1}{2} a x^{2}+\frac{1}{4} b x^{4}	\\
		\frac{\partial V}{\partial x}&=0 \Rightarrow-a x+b x^{3}=0 \Rightarrow x\left[-a+b x^{2}\right]=0 \Rightarrow x=\pm\left(\frac{a}{b}\right)^{\frac{1}{2}}, 0\\
		\because \frac{\partial^{2} V}{\partial x^{2}}&=-a+3 b x^{2}\\
		\text { At } x=0, \frac{\partial^{2} V}{\partial x^{2}}&=-a \text { (Negative so it is unstable point) }\\
		\left.\frac{\partial^{2} V}{\partial x^{2}}\right|_{x=\pm\left(\frac{a}{b}\right)^{\frac{1}{2}}}&=-a+3 b \frac{a}{b}=2 a \text { (Positive so it is stable point) }\\
		\Rightarrow \omega&=\sqrt{\frac{\frac{\partial^{2} V}{\partial x^{2}}}{m}}=\sqrt{\frac{2 a}{m}}
		\end{align*}
		The correct option is \textbf{(b)}
	\end{answer}
		\item A particle of mass $m$, kept in potential $V(x)=-\frac{1}{2} k x^{2}+\frac{1}{4} \lambda x^{4}$ (where $k$ and $\lambda$ are positive constants), undergoes small oscillations about an equilibrium point. The frequency of oscillations is
		{\exyear{NET JUNE 2018}}
	\begin{tasks}(2)
		\task[\textbf{A.}] $\frac{1}{2 \pi} \sqrt{\frac{2 \lambda}{m}}$
		\task[\textbf{B.}]$\frac{1}{2 \pi} \sqrt{\frac{k}{m}}$
		\task[\textbf{C.}]$\frac{1}{2 \pi} \sqrt{\frac{2 k}{m}}$
		\task[\textbf{D.}]$\frac{1}{2 \pi} \sqrt{\frac{\lambda}{m}}$
	\end{tasks}
	\begin{answer}
		\begin{align*}
		V&=-\frac{1}{2} k x^{2}+\frac{1}{4} \lambda x^{4}\\
		\frac{d V}{d x}&=0 \quad-k x+\lambda x^{3}=0\\
		x=0, \quad x^{2}&=\frac{k}{\lambda} \Rightarrow x=x_{0}=\sqrt{\frac{k}{\lambda}}\\
		\frac{d^{2} V}{d x^{2}}&=-k \quad \text { at } x=0 \quad \text { so } x=0 \text { is unstable part }\\
		\frac{d^{2} V}{d x^{2}}&=2 k \text { at } x_{0}=\sqrt{\frac{k}{\lambda}} \text { so } x_{0}=\sqrt{\frac{k}{x}} \text { is stable equation point }\\
		\omega&=\sqrt{\frac{\left.\frac{d^{2} V}{d x^{2}}\right|_{x=x_{0}}}{m}}=\sqrt{\frac{2 k}{m}} \quad f=\frac{1}{2 \pi} \sqrt{\frac{2 k}{m}}
		\end{align*}
		The correct option is \textbf{(c)}
	\end{answer}
\end{enumerate}
\newpage
\begin{abox}
Practice set 2 solutions
\end{abox}
\begin{enumerate}
  \item A particle is placed in a region with the potential $V(x)=\frac{1}{2} k x^{2}-\frac{\lambda}{3} x^{3}$, where $k, \lambda>0$.
  Then,
	{\exyear{GATE 2010}}
\begin{tasks}(1)
	\task[\textbf{A.}] $x=0$ and $x=\frac{k}{\lambda}$ are points of stable equilibrium
	\task[\textbf{B.}]$x=0$ is a point of stable equilibrium and $x=\frac{k}{\lambda}$ is a point of unstable equilibrium
	\task[\textbf{C.}]$x=0$ and $x=\frac{k}{\lambda}$ are points of unstable equilibrium
	\task[\textbf{D.}]There are no points of stable or unstable equilibrium
\end{tasks}
\begin{answer}
\begin{align*}
V&=\frac{1}{2} k x^{2}-\frac{\lambda x^{3}}{3} \Rightarrow \frac{\partial V}{\partial x}=k x-\lambda x^{2}=0 \Rightarrow x=0, x=\frac{k}{\lambda}\\
&=\frac{\partial^{2} V}{\partial x^{2}}=k-2 \lambda x\\
A t x&=0, \frac{\partial^{2} V}{\partial x^{2}}=+v e(\text { Stable })\\
\text { at } x&=\frac{k}{\lambda}, \frac{\partial^{2} V}{\partial x^{2}}=-v e \text { (unstable) }
\end{align*}
The correct option is \textbf{(b)}
\end{answer}
	\item Two bodies of mass $m$ and $2 m$ are connected by a spring constant $k$. The frequency of the normal mode is
	{\exyear{GATE 2011}}
\begin{tasks}(2)
	\task[\textbf{A.}] $\sqrt{3 k / 2 m}$
	\task[\textbf{B.}]$\sqrt{k / m}$
	\task[\textbf{C.}] $\sqrt{2 k / 3 m}$
	\task[\textbf{D.}]$\sqrt{k / 2 m}$
\end{tasks}
\begin{answer}
	\begin{align*}
\omega=\sqrt{\frac{k}{\mu}}&=\sqrt{\frac{k}{\frac{2 m}{3}}}=\sqrt{\frac{3 k}{2 m}}\\
\text { where reduce mass } \mu&=\frac{2 m m}{2 m+m}=\frac{2 m}{3} \text {. }
	\end{align*}
The correct option is \textbf{(a)}
\end{answer}
	\item A particle of unit mass moves along the $x$-axis under the influence of a potential, $V(x)=x(x-2)^{2}$. The particle is found to be in stable equilibrium at the point $x=2$. The time period of oscillation of the particle is
{	\exyear{GATE 2012}}
\begin{tasks}(2)
	\task[\textbf{A.}] $\frac{\pi}{2}$
	\task[\textbf{B.}]$\pi$
	\task[\textbf{C.}]$\frac{3 \pi}{2}$
	\task[\textbf{D.}]$2 \pi$
\end{tasks}
\begin{answer}
\begin{align*}
V(x)&=x(x-2)^{2} \Rightarrow \frac{\partial V}{\partial x}=(x-2)^{2}+2 x(x-2)=0 \Rightarrow x=2, x=\frac{2}{3}\\
\frac{\partial^{2} V}{\partial x^{2}}&=2(x-2)+2(x-2)+\left.2 x \Rightarrow \frac{\partial^{2} V}{\partial x^{2}}\right|_{x=2}=2 \times 2=4\\
\omega&=\sqrt{\left.\frac{\partial^{2} V}{\partial x^{2}}\right|_{x=2}} \Rightarrow \omega=\frac{2 \pi}{T}=2 \Rightarrow T=\pi
\end{align*}
The correct option is \textbf{(b)}
\end{answer}
	\item Consider two small blocks, each of mass $M$, attached to two identical springs. One of the springs is attached to the wall, as shown in the figure. The spring constant of each spring is $k$. The masses slide along the surface and the friction is negligible. The frequency of one of the normal modes of the system is,
	{\exyear{GATE 2013}}
	\begin{figure}[H]
		\centering
		\includegraphics[height=3cm,width=5cm]{GATE1}
	\end{figure}
\begin{tasks}(2)
	\task[\textbf{A.}] $\sqrt{\frac{3+\sqrt{2}}{2}} \sqrt{\frac{k}{M}}$
	\task[\textbf{B.}]$\sqrt{\frac{3+\sqrt{3}}{2} \sqrt{\frac{k}{M}}}$
	\task[\textbf{C.}]$\sqrt{\frac{3+\sqrt{5}}{2}} \sqrt{\frac{k}{M}}$
	\task[\textbf{D.}]$\sqrt{\frac{3+\sqrt{6}}{2}} \sqrt{\frac{k}{M}}$
\end{tasks}
\begin{answer}
	\begin{align*}
		T&=\frac{1}{2} m \dot{x}_{1}^{2}+\frac{1}{2} m \dot{x}_{2}^{2}\\
		V&=\frac{1}{2} k x_{1}^{2}+\frac{1}{2} k\left(x_{2}-x_{1}\right)^{2}\\
		&=\frac{1}{2} k x_{1}^{2}+\frac{1}{2} k\left(x_{2}^{2}+x_{1}^{2}-2 x_{2} x_{1}\right)=\frac{1}{2} k\left(2 x_{1}^{2}+x_{2}^{2}-2 x_{2} x_{1}\right)\\
		T&=\left(\begin{array}{cc}
		m & 0 \\
		0 & m
		\end{array}\right) ; \quad V=\left(\begin{array}{cc}
		2 k & -k \\
		-k & k
		\end{array}\right)\\
		\left|\begin{array}{cc}
		2 k-\omega^{2} m & -k \\
		-k & k-\omega^{2} m
		\end{array}\right|&=0 \Rightarrow\left(2 k-\omega^{2} m\right)\left(k-\omega^{2} m\right)-k^{2}=0 \Rightarrow \omega=\sqrt{\frac{3+\sqrt{5}}{2}} \sqrt{\frac{k}{m}}
	\end{align*}
THe correct option is \textbf{(c)}
\end{answer}
	\item Two masses $m$ and $3 m$ are attached to the two ends of a massless spring with force constant $K$. If $m=100 \mathrm{~g}$ and $K=0.3 \mathrm{~N} / \mathrm{m}$, then the natural angular frequency of oscillation is $H z$.
	{\exyear{GATE 2014}}

\begin{answer}
	\begin{align*}
	f&=\frac{1}{2 \pi} \sqrt{\frac{k}{\mu}}\\
	\mu&=\frac{m_{1} \cdot m_{2}}{m_{1}+m_{2}}=\frac{3 m \cdot m}{4 m}=\frac{3 m}{4}\\
	\omega&=\sqrt{\frac{4 k}{3 m}}=2 \Rightarrow f=0.318 \mathrm{~Hz}
	\end{align*}
\end{answer}

	\item A particle of mass $m$ is in a potential given by
	$$
	V(r)=-\frac{a}{r}+\frac{a r_{0}^{2}}{3 r^{3}}
	$$
	where $a$ and $r_{0}$ are positive constants. When disturbed slightly from its stable equilibrium position it undergoes a simple harmonic oscillation. The time period of oscillation is
	{\exyear{GATE 2014}}
\begin{tasks}(2)
	\task[\textbf{A.}] $2 \pi \sqrt{\frac{m r_{0}^{3}}{2 a}}$
	\task[\textbf{B.}]$2 \pi \sqrt{\frac{m r_{0}{ }^{3}}{a}}$
	\task[\textbf{C.}]$2 \pi \sqrt{\frac{2 m r_{0}^{3}}{a}}$
	\task[\textbf{D.}]$4 \pi \sqrt{\frac{m r_{0}^{3}}{a}}$
\end{tasks}
\begin{answer}
\begin{align*}
V(r)&=-\frac{a}{r}+\frac{a r_{0}^{2}}{3 r^{3}}\\
\intertext{For equilibrium}
\frac{\partial V}{\partial r}&=\frac{a}{r^{2}}-\frac{3 a r_{0}^{2}}{3 r^{4}}=0, \quad r=\pm r_{0}\\
\frac{\partial^{2} V}{\partial r^{2}}&=-\frac{2 a}{r^{3}}+\left.\frac{4 a r_{0}^{2}}{r^{5}}\right|_{r_{0}}=-\frac{2 a}{r_{0}^{3}}+\frac{4 a r_{0}^{2}}{r_{0}^{5}}=\frac{2 a}{r_{0}^{3}}\\
\omega&=\sqrt{\frac{\left.\frac{\partial^{2} V}{\partial r^{2}}\right|_{r_{0}}}{m}} \Rightarrow T=2 \pi \sqrt{\frac{m r_{0}^{3}}{2 a}}
\end{align*}
The correct option id \textbf{(a)}
\end{answer}
	\item Two identical masses of $10 \mathrm{gm}$ each are connected by a massless spring of spring constant $1 \mathrm{~N} / \mathrm{m}$. The non-zero angular eigenfrequency of the system is. $. \mathrm{rad} / \mathrm{s} .$ (up to two decimal places)
	{\exyear{GATE 2017}}
\begin{answer}
\begin{align*}
\omega=\sqrt{\frac{k}{\mu}}, \quad \text { where } \mu=\frac{m}{2}=\frac{10}{2 \times 1000}=\frac{1}{200} \text { and } k=1 N / m, \quad \omega=14.14
\end{align*}
\end{answer}
	\item In the context of small oscillations, which one of the following does NOT apply to the normal coordinates?
{	\exyear{GATE 2018}}
\begin{tasks}(1)
	\task[\textbf{A.}] Each normal coordinate has an eigen-frequency associated with it
	\task[\textbf{B.}]The normal coordinates are orthogonal to one another
	\task[\textbf{C.}]The normal coordinates are all independent
	\task[\textbf{D.}]The potential energy of the system is a sum of squares of the normal coordinates with constant coefficients
\end{tasks}
\begin{answer}
 Normal co-ordinate must be independent. It is not necessary that it should orthogonal.\\
 The correct option is \textbf{(b)}
\end{answer}

\end{enumerate}

Classical Mechanics  -CSIR/chapter/small oscillations solutions.tex