\documentclass[aps,notitlepage,nofootinbib,10pt]{revtex4-1}

% linking references
\usepackage{hyperref}
\hypersetup{
  breaklinks=true,
  colorlinks=true,
  linkcolor=blue,
  filecolor=magenta,
  urlcolor=cyan,
}

%%% standard header
% \usepackage[margin=1in]{geometry} % one inch margins
\usepackage{fancyhdr} % easier header and footer management
\pagestyle{fancyplain} % page formatting style
\setlength{\parindent}{0cm} % don't indent new paragraphs...
\parskip 6pt % ... place a space between paragraphs instead
\usepackage[inline]{enumitem} % include for \setlist{}, use below
%\setlist{nolistsep} % more compact spacing between environments
\setlist[itemize]{leftmargin=*} % nice margins for itemize ...
\setlist[enumerate]{leftmargin=*} % ... and enumerate environments
\frenchspacing % add a single space after a period
\usepackage{lastpage} % for referencing last page
\cfoot{\thepage~of \pageref{LastPage}} % "x of y" page labeling

%%% symbols, notations, etc.
\usepackage{physics,braket,bm,commath,amssymb} % physics and math
\renewcommand{\t}{\text} % text in math mode
\newcommand{\f}[2]{\dfrac{#1}{#2}} % shorthand for fractions
\newcommand{\p}[1]{\left(#1\right)} % parenthesis
\renewcommand{\sp}[1]{\left[#1\right]} % square parenthesis
\renewcommand{\set}[1]{\left\{#1\right\}} % curly parenthesis
\renewcommand{\v}{\bm} % bold vectors
\newcommand{\uv}[1]{\hat{\v{#1}}} % unit vectors
\renewcommand{\d}{\partial} % partial d
\renewcommand{\c}{\cdot} % inner product
\newcommand{\bk}{\Braket} % shorthand for braket notation
\let\vepsilon\epsilon % remap normal epsilon to vepsilon
\let\vphi\phi % remap normal phi to vphi

%%% figures
\usepackage{graphicx,grffile,float,subcaption} % floats, etc.
\usepackage{multirow} % multirow entries in tables
\usepackage{footnote} % footnotes in floats
\usepackage[font=small,labelfont=bf]{caption} % caption text options

\usepackage{dsfont}
\newcommand{\1}{\mathds{1}}

\newcommand{\up}{\uparrow}
\newcommand{\dn}{\downarrow}
\newcommand{\E}{\mathcal{E}}
\renewcommand{\H}{\mathcal{H}}
\newcommand{\K}{\mathcal{K}}
\newcommand{\Z}{\mathbb{Z}}

\usepackage{accents}
\newcommand{\utilde}[1]{\underaccent{\tilde}{#1}}

\newcommand{\g}{\text{g}}
\newcommand{\e}{\text{e}}

\renewcommand{\headrulewidth}{0.5pt} % horizontal line in header
\lhead{Michael A. Perlin}

\begin{document}
% \titlespacing{\section}{0pt}{6pt}{0pt} % section title placement
% \titlespacing{\subsection}{5mm}{6pt}{0pt} % subsection title placement

\section{Particle in a lattice}

In a periodic potential $V\p{x}=V\p{x+a}$, Bloch's theorem states
that the energy eigenstates $\phi^{\p n}_q\p{x}$ take the form
\begin{align}
  \phi^{\p n}_q\p{x} = e^{iqx} u^{\p n}_q\p{x},
\end{align}
where $u^{\p n}_q\p{x}=u^{\p n}_q\p{x+a}$ has the same periodicity as
$V$ and $\abs{q}\le\pi/a$. We can then find that
\begin{multline}
  \d_x^2\phi^{\p n}_q
  = \d_x^2\p{e^{iqx} u^{\p n}_q}
  = \d_x\sp{iqe^{iqx} u^{\p n}_q + e^{iqx}\d_xu^{\p n}_q} \\
  = -q^2e^{iqx}u^{\p n}_q + iqe^{iqx} \d_xu^{\p n}_q
  + iqe^{iqx} \d_xu^{\p n}_q + e^{iqx}\d_x^2u^{\p n}_q \\
  = -\p{q^2 + 2qp + p^2}\phi^{\p n}_q
  = -\p{q+p}^2\phi^{\p n}_q,
\end{multline}
which implies that the Schroedinger equation is
\begin{align}
  \p{-\f{\p{p+q}^2}{2m} + V - E_q^{\p n}}\phi^{\p n}_q = 0.
\end{align}
Alternately, letting $y=kx$ we can expand the Schroedinger equation as
\begin{align}
  \p{-\f{k^2}{2m}\d_y^2 + V - E_q^{\p n}}\phi^{\p n}_q = 0.
\end{align}
Defining the recoil energy $E_R=k^2/\p{2m}$ and using the notation
$\tilde X\equiv X/E_R$, the Schroedinger equation becomes
\begin{align}
  \p{\d_y^2 - \tilde V + \tilde E_q^{\p n}}\phi^{\p n}_q = 0.
\end{align}
If $V=V_0\sin^2\p{kx}$, then
\begin{align}
  \p{\d_y^2 - \f{\tilde V_0}{2}\sp{1-\cos\p{2kx}}
  + \tilde E_q^{\p n}}\phi^{\p n}_q
  = \p{\d_y^2 + \sp{\tilde E_q^{\p n} - \f{\tilde V_0}{2}} -
  2\sp{-\f{\tilde V_0}{4}}\cos\p{2y}}\phi^{\p n}_q = 0,
\end{align}
which is the Mathieu equation.

\subsection{Wannier orbitals and tight-binding approximation}

We can define the Wannier orbitals
\begin{align}
  w_i^{\p n}\p{x} = w_n\p{x-x_i}
  = \f1{\sqrt{L}}\sum_q e^{-iqx_i}\phi_q^{\p n}\p{x},
\end{align}
which describe a localized orbital at site $x_i$ (of $L$) with
electronic state indexed by $n$. General wavefunctions can then be
expanded as
\begin{align}
  \psi\p{x,t} = \sum_{n,i}z_i^{\p n}\p{t}w_n\p{x-x_i}.
\end{align}
As the Wannier orbitals are orthonormal, we can project out a single
coefficient as
\begin{align}
  \int dx~ \bar w_m\p{x-x_j}\psi\p{x,t} = z_j^{\p m}.
\end{align}
The energy eigenvalue equation for a Hamiltonian $H=H_0+V$ for the
background periodic potential $H_0$ and perturbation $V$ is
\begin{align}
  i\d_t\psi = \p{H_0+V}\psi,
\end{align}
where we can project onto the orbital $w_j^{\p m}$ to get
\begin{align}
  i\d_t z_j^{\p m}
  = \sum_{n,i}\p{\int dx~\bar w_j^{\p m} \p{H_0 + V} w_i^{\p n}}z_i^{\p n}.
\end{align}
Defining
\begin{align}
  J_{j,i}^{m,n} \equiv \int dx~\bar w_j^{\p m} H_0 w_i^{\p n}
  && V_{j,i}^{m,n} \equiv \int dx~\bar w_j^{\p m} V w_i^{\p n},
\end{align}
we can express
\begin{align}
  i\d_t z_j^{\p m}
  = \sum_{n,i}\p{J_{j,i}^{m,n} + V_{j,i}^{m,n}}z_i^{\p n}.
\end{align}
We can expand
\begin{multline}
  J_{j,i}^{m,n}
  = \int dx~\f1L\sum_{p,q}
  \p{e^{ipx_j}\bar \phi_p^{\p m}}H_0\p{e^{-iqx_i}\phi_q^{\p n}}
  = \f1L\sum_{p,q}E_q^{\p n}e^{i\p{px_j-qx_i}}
  \int dx~ \bar \phi_p^{\p m}\phi_q^{\p n} \\
  = \f{E_q^{\p n}}{L}\sum_{p,q}e^{i\p{px_j-qx_i}}\delta_{m,n}
  \equiv J_{j,i}^{\p n}\delta_{m,n},
\end{multline}
which means
\begin{align}
  i\d_t z_j^{\p m}
  = \sum_i\p{J_{j,i}^{\p m}z_i^{\p m} + \sum_nV_{j,i}^{m,n}}z_i^{\p n}.
\end{align}
If the interband transitions induced by $V$ are sufficiently slow,
i.e.
\begin{align}
  \sum_{n\ne m}V_{j,i}^{m,n}\ll J_{j,i}^{\p m}+V_{j,i}^{m,m},
\end{align}
we can make a single-band approximation by fixing $m$ and neglecting
all $n\ne m$ to yield
\begin{align}
  i\d_t z_j = \sum_i \p{J_{j,i} + V_{j,i}}z_i.
\end{align}
Furthermore, if the lattice in $H_0$ is sufficiently deep to neglect
tunneling induced by $J_{j,i}$ beyond nearest-neighbor and the
perturbation $V_{j,i}$ is slowly varying enough to be considered
constant at each lattice site and weak enough to neglect all
$V$-induced tunneling, i.e. $V_{j,i}=V_j\delta_{j,i}$, then
\begin{align}
  i\d_t z_j
  = J_{j,j-1}z_{j-1} + J_{j,j+1}z_{j+1} + V_jz_j + J_{j,j}z_j.
\end{align}
We can now define
\begin{align}
  \varepsilon_0
  = \int dx~ \bar w_j H_0 w_j
  = \int dx~ \bar w_0 H_0 w_0
\end{align}
and observe that by parity symmetry $J_{j,j-1}=J_{j,j+1}\equiv J$ to
arrive at the discrete Schoeringer equation (DSE)
\begin{align}
  i\d_t z_i
  = J\p{z_{i-1} + z_{i+1}} + V_i z_i + \varepsilon_0 z_i.
\end{align}

\newpage
\section{Spin-orbit coupling in a Harmonic oscillator}

Consider a two-level atom with energy splitting $\omega_0$ in a laser
cavity with frequency $\omega$. The Hamiltonian for this system is
\begin{align}
  H = \omega_0S_z + \omega\p{a^\dag a+\f12} - \v d\c\v E,
\end{align}
where $S_z=\sigma_z/2=\p{\op e - \op g}/2$;
\begin{align}
  \v E\p{x,t}
  = \sqrt{\f{\omega\bk N}{2V}} \sp{u\p{x}a^\dag+u^*\p{x}a} \uv E
\end{align}
with photon occupation $a^\dag a=\bk N$, cavity volume $V$, and field
mode $u\p{x}$ (e.g. $e^{ikx}$); and
\begin{align}
  \v d = d_0\sigma_x\uv d = \p{\sigma_++\sigma_-}d_0\uv d.
\end{align}
Moving into the frame of the atom,
\begin{align}
  \sigma_+ \to e^{i\omega_0t}\sigma_+,
  && \sigma_- \to e^{-i\omega_0t}\sigma_-,
\end{align}
which means
\begin{align}
  \v d \to \p{e^{i\omega_0t}\sigma_++e^{-i\omega_0t}\sigma_-}d_0\uv d.
\end{align}
Similarly, in the frame of the field Hamiltonian
\begin{align}
  a^\dag \to e^{i\omega t}a^\dag, && a \to e^{-i\omega t} a,
\end{align}
which means
\begin{align}
  \v E \to \sqrt{\f{\omega\bk N}{2V}}
  \p{e^{i\omega t} u a^\dag + e^{-i\omega t} u^* a}u\uv E.
\end{align}
In the interaction picture of the atom and field, then, we have the
Hamiltonian
\begin{multline}
  H_I
  = -\tilde{\v d}\c\tilde{\v E}
  = -d_0\p{e^{i\omega_0t}\sigma_++e^{-i\omega_0t}\sigma_-}
  \sqrt{\f{\omega\bk N}{2V}}
  \p{e^{i\omega t} u a^\dag + e^{-i\omega t} u^* a}\uv d\c\uv E \\
  \equiv
  \p{e^{i\omega_0t}\sigma_+ + e^{-i\omega_0t}\sigma_-}
  \p{\f{\Omega}{2}e^{i\omega t}a^\dag + \f{\Omega^*}{2}e^{-i\omega t}a}
\end{multline}
with
\begin{align}
  \Omega\p{x} = -2d_0\sqrt{\f{\omega\bk N}{2V}}~u\p{x}\uv d\c\uv E.
\end{align}
If the detuning $\Delta=\omega-\omega_0$ is small
(i.e. $\abs\Delta\ll\omega,\omega_0$) and
$\abs\Omega\ll\omega+\omega_0$, then by the secular approximation
\begin{align}
  H_I
  \approx \f{\Omega}{2}e^{i\Delta}\sigma_-a^\dag
  + \f{\Omega^*}{2}e^{-i\Delta}\sigma_+a
\end{align}

\newpage
\section{Periodically-driven QHO}

We start with the Hamiltonian for a a periodically driven QHO,
\begin{align}
  H
  = \nu\p{a^\dag a + \f12} + F_0\cos\p{ft}x
  = \nu\p{a^\dag a + \f12} + F_0x_0\cos\p{ft}\p{a^\dag + a}.
\end{align}
In the interaction picture of the QHO, we have
\begin{align}
  H_I
  = F_0x_0\cos\p{ft}\p{e^{i\nu t}a^\dag + e^{-i\nu t}a}
  = \f12F_0x_0\p{e^{ift}+e^{-ift}}\p{e^{i\nu t}a^\dag + e^{-i\nu t}a}.
\end{align}
Defining
\begin{align}
  g = \f12 F_0x_0, && \xi = \nu - f,
\end{align}
we make the secular
approximation ($\nu+f\gg g$) to neglect fast-oscillating terms,
yielding
\begin{align}
  H_I = g\p{e^{i\xi t}a^\dag + e^{-i\xi t}a}.
\end{align}
The time-evolution operator for infinitesimal time $\Delta t$ is then
\begin{align}
  D
  = \exp\p{iH_I\Delta t}
  = \exp\sp{ig\p{e^{i\xi t}a^\dag + e^{-i\xi t}a}\Delta t}
  \equiv \exp\p{\alpha a^\dag - \alpha^*a}
  \equiv D\p\alpha,
\end{align}
where
\begin{align}
  \alpha = ige^{i\xi t}\Delta t = \f{i}2F_0x_0e^{i\p{\nu-f}t}\Delta t.
\end{align}
Using the identity $e^Ae^B = e^{A+B}e^{\sp{A,B}/2}$ for operators $A$
an $B$ that commute with their commutator, we then get that
\begin{multline}
  D\p\beta D\p\alpha
  = \exp\p{\p{\beta+\alpha} a^\dag - \p{\beta^*+\alpha^*}a}
  \exp\p{\f12\sp{\beta a^\dag - \beta^*a,
      \alpha a^\dag - \alpha^*a}} \\
  = D\p{\beta+\alpha}
  \exp\p{-\f12\p{\beta\alpha^*+\beta^*\alpha}}
  = D\p{\beta+\alpha}\exp\p{i\Re\sp{\beta\alpha^*}}.
\end{multline}
The propagator is then
\begin{align}
  U\p{t} = D\p{\alpha_N}\cdots D\p{\alpha_2}D\p{\alpha_1},
\end{align}
where we take the limit as $N\to\infty$ and
\begin{align}
  \alpha_n \equiv ge^{i\xi n\Delta t}\Delta t, && \Delta t = t/N.
\end{align}
We thus contract as infinitesimal displacement operators to find
\begin{multline}
  U\p{t}
  = D\p{\alpha_N}\cdots D\p{\alpha_3}D\p{\alpha_1+\alpha_2}
  \exp\p{i\Re\sp{\alpha_2\alpha_1^*}} \\
  = D\p{\alpha_N}\cdots D\p{\alpha_4}D\p{\alpha_1+\alpha_2+\alpha_3}
  \exp\p{i\Re\sp{\alpha_3\p{\alpha_1+\alpha_2}^*}}
  \exp\p{i\Re\sp{\alpha_2\alpha_1^*}} \\
  = D\p{\sum_{n=1}^N\alpha_n} \prod_{n=1}^{N-1}
  \exp\p{i\Re\sp{\alpha_{n+1}\p{\sum_{m=1}^n\alpha_m}^*}}.
\end{multline}
Knowing that
\begin{align}
  \sum_{k=1}^K x^k = x~\f{1-x^K}{1-x} = \f{1-x^K}{x^{-1}-1},
\end{align}
we can compute
\begin{align}
  \sum_{n=1}^N\alpha_n
  = g\Delta t\sum_{n=1}^N e^{i\xi n\Delta t}
  = g\Delta t~\f{1-e^{i\xi N\Delta t}}{e^{-i\xi\Delta t}-1}
  = \f{ig}{\xi}\p{1-e^{i\xi t}}
  \equiv \alpha\p{t}.
\end{align}
We will also need
\begin{align}
  \alpha_{n+1}\p{\sum_{m=1}^n\alpha_m}^*
  = g^2\Delta t^2~e^{i\xi\p{n+1}\Delta t}\sum_{m=1}^ne^{-i\xi m\Delta t}
  = g^2\Delta t^2~e^{i\xi n\Delta t}~
  \f{1-e^{-i\xi n\Delta t}}{1-e^{-i\xi\Delta t}}
  = \f{ig^2}{\xi}\Delta t\p{1-e^{-i\xi n\Delta t}},
\end{align}
which we can use to find
\begin{align}
  \sum_{n=1}^{N-1}\alpha_{n+1}\p{\sum_{m=1}^n\alpha_m}^*
  = \f{ig^2}{\xi}\Delta t\sum_{n=1}^{N-1}\p{1-e^{i\xi n\Delta t}}
  = \f{ig^2}{\xi}\int_0^t dt'~\p{1-e^{i\xi t'}}
  = g\int_0^t dt~\alpha\p{t}
\end{align}
Observing that
\begin{align}
  d\alpha\p{t} = \f{ig}{\xi}\p{-i\xi dt} = g~dt,
\end{align}
we can say
\begin{align}
  \sum_{n=1}^{N-1}\alpha_{n+1}\p{\sum_{m=1}^n\alpha_m}^*
  = \int_0^{\alpha\p{t}} d\alpha'~\alpha'
  = \f12\alpha\p{t}^2,
\end{align}
and so
\begin{align}
  U\p{t} = D\sp{\alpha\p{t}} \exp\p{\f{i}{2}\Re\sp{\alpha\p{t}^2}}.
\end{align}

\newpage

\section{Lattice Modulation}

We begin with a ``background'' 1-D optical lattice clock Hamiltonian
after diagonalization in quasi-momentum:
\begin{align}
  H_B
  = \sum_{q,n,s}\p{E_{qns}-\f12s\delta} b_{qns}^\dag b_{qns}
  - \f12\sum_{q,n,s,m} \Omega_{nm}^{qs} b_{qm\bar s}^\dag b_{qns}.
  \label{eq:H_B}
\end{align}
If the lattice $V_0\sin^2\p{k_Lz}$ is modulated as
$V_0\to V_0+\tilde V\cos\p{\nu t}$, then we pick up a modulation
Hamiltonian $\tilde H = \tilde\H \cos\p{\nu t}$, where
\begin{align}
  \tilde\H
  = \tilde V \sum_{\substack{q,n,s\\g,m}}
  \bk{gms|\sin^2\p{k_Lz}|qns} b_{gms}^\dag b_{qns}
  = \f12\tilde V\sp{1 - \sum_{\substack{q,n,s\\g,m}}
  \bk{gms|\cos\p{2k_Lz}|qns} b_{gms}^\dag b_{qns}}.
\end{align}
Recalling that, due to the gauge transformation performed to get to
\eqref{eq:H_B},
\begin{align}
  \bk{zs|qns} = \bk{z|q+sk/2,n}
  = e^{i\p{q+sk/2}z} \sum_\kappa c_{q+sk/2,n}^{(\kappa)} e^{i2k_Lz\kappa},
\end{align}
we can expand
\begin{multline}
  \bk{gms|\cos\p{2k_Lz}|qns}
  = \f12 \int dz~ \p{e^{i2k_Lz}+e^{-i2k_Lz}} e^{i\p{q-g}z}
  \sum_{\kappa,\ell} e^{i2k_Lz\p{\kappa-\ell}}
  c_{g+sk/2,m}^{(\ell)} c_{q+sk/2,n}^{(\kappa)} \\
  = \f12 \sum_{\kappa,\ell} \int dz~ e^{i\p{q-g}z}
  \p{e^{i2k_Lz\p{\kappa+1-\ell}} + e^{i2k_Lz\p{\kappa-1-\ell}}}
  c_{g+sk/2,m}^{(\ell)} c_{q+sk/2,n}^{(\kappa)}.
\end{multline}
This integral is vanishes unless $g=q$ and $\ell=\kappa\pm1$, so
\begin{align}
  \bk{gms|\cos\p{2k_Lz}|qns}
  \approx \delta_{gq}
  \f12 \sum_\kappa
  \p{c_{q+sk/2,m}^{(\kappa+1)} c_{q+sk/2,n}^{(\kappa)}
    + c_{q+sk/2,m}^{(\kappa-1)} c_{q+sk/2,n}^{(\kappa)}}.
\end{align}
Letting
\begin{align}
  V^{qs}_{nm}
  \equiv -\f12 \tilde V \bk{qms|\cos\p{2k_Lz}|qns}
  = -\f14 \tilde V  \sum_\kappa
  \p{c_{q+sk/2,m}^{(\kappa+1)} c_{q+sk/2,n}^{(\kappa)}
    + c_{q+sk/2,m}^{(\kappa-1)} c_{q+sk/2,n}^{(\kappa)}},
\end{align}
the modulated Hamiltonian is thus, up to a global shift in energy,
\begin{align}
  \tilde\H
  = \sum_{q,n,s,m} V^{qs}_{nm} b_{qms}^\dag b_{qns}.
\end{align}

\subsection{Aside: Fourier expansions}

We can expand, to first Fourier order,
\begin{align}
  E_{qns} \approx E_n + \tilde E_n \cos\p{q + sk/2},
\end{align}
\begin{align}
  \Omega^{qs}_{nm}
  \approx \Omega_{nms} + \tilde\Omega_{nms}^C\cos q
  + \tilde\Omega_{nm}^S\sin q,
\end{align}
\begin{align}
  V^{qs}_{nm} \approx V_{nm} + \tilde V_{nm}
  \f12\sp{e^{i\p{q+sk/2}}+\p{-1}^{n+m}e^{-i\p{q+sk/2}}},
\end{align}
where $X_{nms}\in\set{\Omega_{nms},\tilde\Omega_{nms}^C}$ satisfies
\begin{align}
  X_{nms} = \p{-1}^{n+m} X_{mns} = \p{-1}^{n+m} X_{nm\bar s} = X_{mn\bar s},
\end{align}
and
\begin{align}
  \tilde\Omega_{nm}^S = \tilde\Omega_{mn}^S,
  && V_{nm} = V_{mn}, && \tilde V_{nm} = \tilde V_{mn}.
\end{align}
Observing that $\tilde\Omega_{nn}^S=0$, we can say that
\begin{align}
  \Omega^{qs}_{nn} \approx \Omega_n + \tilde\Omega_n\cos q.
\end{align}
Finally, we note that $V_{nm}=0$ when $n+m$ is odd, which means that
\begin{align}
  V^{qs}_{nm} \approx \left\{
    \begin{array}{ll}
      V_{nm} + \tilde V_{nm}\cos\p{q+sk/2} & n+m~\t{even} \\
      \tilde V_{nm}\sin\p{q+sk/2} & n+m~\t{odd}
    \end{array}\right..
\end{align}

\subsection{Interaction picture}

The full Hamiltonian is now
\begin{multline}
  H = \sum_{q,n,s}\p{E_{qns}-\f12s\delta} b_{qns}^\dag b_{qns}
  + \sum_{q,n,s,m} V^{qs}_{nm} \cos\p{\nu t} b_{qms}^\dag b_{qns}
  - \f12\sum_{q,n,s,m} \Omega_{nm}^{qs} b_{qm\bar s}^\dag b_{qns} \\
  = \sum_{q,n,s}
  \p{E_{qns}-\f12s\delta+V^{qs}_{nn}\cos\p{\nu t}} b_{qns}^\dag b_{qns}
  + \sum_{\substack{q,n,s\\m\ne n}}
  V^{qs}_{nm} \cos\p{\nu t} b_{qms}^\dag b_{qns}
  - \f12\sum_{q,n,s,m} \Omega_{nm}^{qs} b_{qm\bar s}^\dag b_{qns},
\end{multline}
and can be written in the interaction picture of the single-particle
state energies as
\begin{multline}
  H_I = \sum_{\substack{q,n,s\\m\ne n}} V^{qs}_{nm} \cos\p{\nu t}
  \exp\sp{i\p{E_{qms}-E_{qns}}t
    + i\p{V^{qs}_{mm}-V^{qs}_{nn}}\sin\p{\nu t}/\nu}
  b_{qms}^\dag b_{qns} \\
  -\f12\sum_{q,n,s,m} \Omega_{nm}^{qs}
  \exp\sp{i\p{E_{qm\bar s}-E_{qns}+s\delta}t
    + i\p{V^{q\bar s}_{mm}-V^{qs}_{nn}}\sin\p{\nu t}/\nu}
  b_{qm\bar s}^\dag b_{qns}.
\end{multline}
We can expand
\begin{align}
  \exp\p{i\beta\sin\tau}
  = \sum_\kappa \exp\p{i\kappa\tau} \f1{2\pi}\int_{-\pi}^\pi dx~
  \exp\p{-i\kappa x+i\beta\sin x}
  = \sum_\kappa J_\kappa\p{\beta} \exp\p{i\kappa\tau},
\end{align}
where $J_n\p{x}$ is the $n$-th order Bessel function of the first
kind. Defining
\begin{align}
  W^{qs}_{nm} \equiv \p{V^{qs}_{mm} - V^{qs}_{nn}}/\nu,
  &&
  \bar W^{qs}_{nm} \equiv \p{V^{q\bar s}_{mm} - V^{qs}_{nn}}/\nu,
\end{align}
the Hamiltonian is therefore
\begin{multline}
  H_I = \f12 \sum_{\substack{q,n,s,\\m\ne n\\\kappa,r}} V^{qs}_{nm}
  J_\kappa\p{W^{qs}_{nm}}
  \exp\sp{i\p{E_{qms}-E_{qns}+\sp{\kappa+r}\nu}t}
  b_{qms}^\dag b_{qns} \\
  -\f12\sum_{\substack{q,n,s\\m,\kappa}} \Omega_{nm}^{qs}
  J_\kappa\p{\bar W^{qs}_{nm}}
  \exp\sp{i\p{E_{qm\bar s}-E_{qns}+s\delta+\kappa\nu}t}
  b_{qm\bar s}^\dag b_{qns},
\end{multline}
where $r=\pm1$.

\subsection{Nontrivial topology: example}

We now restrict ourselves to considering only the first two bands, set
$\nu=\p{E_1-E_0}/2$, and $\delta=\sp{E_1-E_0}/4$. The spin-flipping
$\Omega^{qs}_{nm}$ terms can then be neglected by the secular
approximation, and we are left with
\begin{align}
  H_I = \f12 \sum_{q,s,\kappa,r}
  \utilde V^{qs}_{0,1} J_\kappa\p{\utilde W^{qs}_{0,1}}
  \exp\sp{i\p{\sp{E_1-E_0}\sp{1+\kappa/2+r/2}
      + \sp{\tilde E_1-\tilde E_0}\cos q}t}
  c_{q,1,s}^\dag c_{q,0,s} + \t{h.c.},
\end{align}
where for $X^{qs}_{nm}\in\set{V^{qs}_{nm},W^{qs}_{nm}}$ we define
$\utilde X^{qs}_{nm}\equiv X^{q-sk/2,s}_{nm}$. The only nonvanishing
terms (from the secular approximation) are those with $\kappa=r=-1$,
so
\begin{align}
  H_I = -\f12 \sum_{q,s}
  \utilde V^{qs}_{0,1} J_1\p{\utilde W^{qs}_{0,1}}
  \exp\sp{i\p{\tilde E_1-\tilde E_0}\cos q~ t}
  c_{q,1,s}^\dag c_{q,0,s} + \t{h.c.}.
\end{align}
With appropriate choice of interaction picture, this Hamiltonian is
equivalently
\begin{align}
  H_I^{\t{eff}}
  = \sum_{q,n,s}\tilde E_n\cos q~ c_{qns}^\dag c_{qns}
  - \f12\sum_{q,n,s}
  \utilde V^{qs}_{n\bar n} J_1\p{\abs{\utilde W^{qs}_{n\bar n}}}
  c_{q\bar ns}^\dag c_{qns}.
\end{align}
Here
$\utilde V^{qs}_{n\bar n} J_1\p{\utilde W^{qs}_{n\bar n}} \sim \sin
q$, which implies that the energy bands of this Hamiltonian have Chern
number $\pm1$.

If we instead set $\delta=0$, we would get the effective Hamiltonian
$H_I^{\t{eff}} = \sum_{q,n,s} h_{qns}$, where
\begin{align}
  h_{qns}
  = \tilde E_{qns} b_{qns}^\dag b_{qns}
  - \f12 V^{qs}_{n\bar n} J_1\p{\abs{W^{qs}_{n\bar n}}}
  b_{q\bar ns}^\dag b_{qns}
  - \f12 \Omega^{qs}_{nn} J_0\p{\bar W^{qs}_{nn}}
  b_{qn\bar s}^\dag b_{qns}
  + \f12 \Omega^{qs}_{nn} J_1\p{\abs{\bar W^{qs}_{n\bar n}}}
  b_{q\bar n\bar s}^\dag b_{qns}
\end{align}
and $\tilde E_{qns}\equiv \tilde E_n \cos\p{q+sk/2}$.

\newpage

\subsection{Wannier basis}

In terms of the field operators $\tilde a_{xns}$ for atoms localized
on lattice sites $x\in a\Z_L$ (with $L$ sites total and lattice
constant $a$) in bands $n\in\mathbb N_0$ with clock states
$s\in\set{\pm 1}$, we can expand
\begin{align}
  b_{qns}^\dag = c_{q+sk/2,ns}^\dag
  = \f1{\sqrt L}\sum_x e^{i\p{q+sk/2}x} \tilde a_{xns}^\dag
  = \f1{\sqrt L}\sum_x e^{iqx} a_{xns}^\dag,
\end{align}
where $a_{xns}^\dag\equiv e^{iskx/2}\tilde a_{xns}^\dag$. We can also
expand, to first Fourier order in $q$,
\begin{align}
  E_{qns} \approx E_n + \tilde E_n \cos\p{q+sk/2},
\end{align}
\begin{align}
  \Omega^{qs}_{nm} \approx
  \Omega^s_{nm} + \tilde\Omega^s_{nm} \cos\p{q+\alpha^s_{nm}}
  &&
  V^{qs}_{nm} \approx V_{nm} + \tilde V_{nm} \cos\p{q+sk/2+\beta_{nm}}
\end{align}
where we work in momentum units of $k_L/\pi$, such that
$q\in\sp{-\pi,\pi}$ in the first Brillouin zone. The background
Hamiltonian is then
\begin{multline}
  H_B = \sum_{x,n,s}\p{E_n - \f12s\delta} a_{xns}^\dag a_{xns}
  - \f12 \sum_{x,n,s,m} \Omega^s_{nm} a_{xm\bar s}^\dag a_{xns} \\
  + \f1{2L} \sum_{\substack{q,n,s\\x,y}} \tilde E_n \p{e^{isk/2}e^{iq} +
    e^{-isk/2}e^{-iq}}
  e^{iq\p{y-x}} a_{yns}^\dag a_{xns} \\
  - \f1{4L} \sum_{\substack{q,n,s\\m,x,y}} \tilde\Omega^s_{nm}
  \p{e^{i\alpha^s_{nm}}e^{iq} + e^{-i\alpha^s_{nm}}e^{-iq}}
  e^{iq\p{y-x}} a_{ym\bar s}^\dag a_{xns},
\end{multline}
which simplifies to
\begin{multline}
  H_B = \sum_{x,n,s}\p{E_n - \f12s\delta} a_{xns}^\dag a_{xns}
  - \f12 \sum_{x,n,s,m} \Omega^s_{nm} a_{xns}^\dag a_{xm\bar s} \\
  + \f12 \sum_{x,n,s} \tilde E_n
  \p{e^{-isk/2} a_{x+1,ns}^\dag a_{xns} + \t{h.c.}}
  - \f14 \sum_{x,n,s,m} \tilde\Omega^s_{nm}
  \p{e^{-i\alpha^s_{nm}} a_{x+1,m\bar s}^\dag a_{xns} + \t{h.c.}}.
\end{multline}
The modulated Hamiltonian is similarly
\begin{align}
  \tilde\H
  = \sum_{x,n,s,m} V_{nm} a_{xms}^\dag a_{xns}
  + \f12\sum_{\substack{q,n,s\\m,x,y}} \tilde V_{nm}
  \p{e^{i\p{sk/2+\beta_{nm}}}e^{iq} + e^{-i\p{sk/2+\beta_{nm}}}e^{-iq}}
  e^{iq\p{y-x}} a_{yms}^\dag a_{xns},
\end{align}
which simplifies to
\begin{align}
  \tilde\H
  = \sum_{x,n,s,m}\sp{V_{nm} a_{xns}^\dag a_{xms}
  + \f12 \tilde V_{nm}
  \p{e^{-i\p{sk/2+\beta_{nm}}} a_{x+1,ms}^\dag a_{xns} + \t{h.c.}}}.
\end{align}

\newpage
\section{Clock laser modulation}

Our full 1-D OLC Hamiltonian after diagonalization in quasimomentum is
\begin{align}
  H = \sum_{q,n,s}\sp{E_{qns} - \f12 s\delta\p{t}} b_{qns}^\dag b_{qns}
  - \f12 \sum_{q,n,s,m} \Omega^{qs}_{nm} b_{qm\bar s}^\dag b_{qns}.
\end{align}
If we expand, for $N$ drive frequencies
\begin{align}
  \delta\p{t} = -\sum_{j=1}^N \delta_j \cos\p{\nu_j t + \phi_j}
  = -\sum_j \beta_j \nu_j \cos\p{\nu_j t + \phi_j},
  &&
  \beta_j \equiv \delta_j/\nu_j,
\end{align}
then we can write the Hamiltonian in the interaction picture of its diagonal elements to get
\begin{align}
  H_I
  &= -\f12 \sum \Omega^{qs}_{nm}
  \exp\sp{i\p{E_{qm\bar s} - E_{qns}} t
    - is\sum_j\beta_j\sin\p{\nu_j t+\phi_j}
    + is\sum_j\beta_j\sin\phi_j} b_{qm\bar s}^\dag b_{qns}.
\end{align}
Using the Jacobi-Anger identity, we can expand
\begin{align}
  \exp\sp{-is\sum_j\beta_j\sin\tau_j}
  = \prod_j \exp\p{-is\beta_j\sin\tau_j}
  = \prod_j \sum_{k_j} J\p{k_j,s\beta_j}
  \exp\p{-ik_j\tau_j}
  = \sum_{\v k} \prod_j J\p{k_j,s\beta_j}
  \exp\p{-ik_j\tau_j},
\end{align}
where $J\p{n,x}$ is the first Bessel function of the first kind of
order $n$ evaluated at $x$.  We then have that
\begin{align}
  H_I
  &= -\f12\sum_{q,n,s,m,\v k} \Omega^{qs}_{nm}
  \sp{\prod_j J\p{k_j,s\beta_j}}
  \exp\sp{i\p{E_{qm\bar s}-E_{qns}} t
    - i\sum_jk_j\p{\nu_jt+\phi_j}
    + is\sum_j\beta_j\sin\phi_j}
  b_{qm\bar s}^\dag b_{qns} \\
  &= -\f12\sum_{q,n,s,m,\v k} f\p{\v k,\v\beta,\v\phi}
  \Omega^{qs}_{nm}
  \exp\sp{i\p{E_{qm\bar s}-E_{qns}-\v k\c\v\nu}t}
  b_{qm\bar s}^\dag b_{qns},
\end{align}
where
\begin{align}
  f\p{\v k,\v\beta,\v\phi}
  \equiv \sp{\prod_j J\p{k_j,s\beta_j}}
  \exp\p{-i\v k\c\v\phi + is\v\beta\c\sin\v\phi}.
\end{align}
If we now assume that
\begin{enumerate*}[label=(\roman*)]
\item all drive frequencies are much larger than the clock laser Rabi
  frequency $\Omega$, i.e. $\nu_j\gg\Omega$ for all $j$, and
\item the difference between any two drive frequencies is much larger
  than the Rabi frequency $\Omega$, i.e. $\abs{\nu_j-\nu_k}\gg\Omega$
  for all $j$ and $k$,
\end{enumerate*}
then we can define the vector $\v k^{qs}_{nm}\in\Z^N$ which
minimizes $\abs{E_{qm\bar s}-E_{qns}-\v k^{qs}_{nm}\c\v\nu}$, and
by the secular approximation say that
\begin{align}
  H_I = -\f12\sum_{q,n,s,m} f\p{\v k^{qs}_{nm},\v\beta,\v\phi}
  \Omega^{qs}_{nm}
  \exp\sp{i\p{E_{qm\bar s}-E_{qns}-\v k^{qs}_{nm}\c\v\nu}t}
  b_{qm\bar s}^\dag b_{qns}.
\end{align}
Fixing some initial state $\ket\phi=\ket{q_0n_0s_0}$, we now define
the vector $\v\ell^\phi_{qns}\in\Z^N$ which minimizes
$\abs{E_{qns}-E_\phi-\v\ell^\phi_{qns}\c\v\nu}$, and define the reduced
energy
\begin{align}
  \epsilon_{qns}^\phi \equiv E_{qns} - E_\phi - \v\ell^\phi_{qns}\c\v\nu,
  &&
  \t{such that}
  &&
  E_{qns} = E_\phi + \v\ell^\phi_{qns}\c\v\nu + \epsilon_{qns}^\phi.
\end{align}
We can then expand
\begin{align}
  E_{qm\bar s} - E_{qns} - \v k^{qs}_{nm}\c\v\nu
  = \p{\v\ell^\phi_{qm\bar s} - \v\ell^\phi_{qns}
    - \v k^{qs}_{nm}}\c\v\nu
  + \epsilon_{qm\bar s}^\phi - \epsilon_{qns}^\phi.
  \label{eq:k_min}
\end{align}
From their definition, the reduced energies satisfy
$\abs{\epsilon_{qm\bar s}^\phi}, \abs{\epsilon_{qns}^\phi} <
\min_j\nu_j/2$.  If we make a stronger assumption that
$\abs{\epsilon_{qm\bar s}^\phi}, \abs{\epsilon_{qns}^\phi} <
\min_j\nu_j/4$, then
$\abs{\epsilon_{qm\bar s}^\phi - \epsilon_{qns}^\phi} <
\min_j\nu_j/2$, so minimizing the quantity in \eqref{eq:k_min} forces
$\v k^{qs}_{nm} = \v\ell^\phi_{qm\bar s} - \v\ell^\phi_{qns}$,
which implies
\begin{align}
  H_I = -\f12\sum_{q,n,s,m} f\p{\v k^{qs}_{nm},\v\beta,\v\phi}
  \Omega^{qs}_{nm}
  \exp\sp{i\p{\epsilon_{qm\bar s}^\phi-\epsilon_{qns}^\phi}t}
  b_{qm\bar s}^\dag b_{qns}.
\end{align}
In an appropriate interaction picture this Hamiltonian is equivalent to
\begin{align}
  H_I^{\t{eff}} =
  \sum_{q,n,s} \epsilon_{qns}^\phi b_{qns}^\dag b_{qns}
  - \f12\sum_{q,n,s,m} f\p{\v k^{qs}_{nm},\v\beta,\v\phi}
  \Omega^{qs}_{nm} b_{qm\bar s}^\dag b_{qns}.
\end{align}

\section{Interactions}

The interaction Hamiltonian for fermionic AEAs on a lattice is
\begin{align}
  H_{\t{int}} = G \int d^3x~
  \psi_\e^\dag\p{x} \psi_\g^\dag\p{x} \psi_\g\p{x} \psi_\e\p{x},
  &&
  G \equiv \f{4\pi a_{\e\g^-}}{m_A}.
\end{align}
Expanding the field operators for atoms in clock state $\sigma$ as
\begin{align}
  \psi_\sigma\p{x} = \sum_{q,n} \phi_{qn}\p{x} c_{qn\sigma},
\end{align}
for quasimomenta $q$ and band indices $n$, we can write
\begin{align}
  H_{\t{int}} = G \sum K^{pk;q\ell}_{rm;sn}
  c_{rm,\e}^\dag c_{sn,\g}^\dag c_{q\ell,\g} c_{pk,\e},
  &&
  K^{pk;q\ell}_{rm;sn} \equiv \int d^3x~
  \phi_{rm}\p{x}^* \phi_{sn}\p{x}^* \phi_{q\ell}\p{x} \phi_{pk}\p{x}.
\end{align}
By conservation of momentum, we know that $K^{pk;q\ell}_{rm;sn}=0$
unless $p+q+r+s=0$ ($\t{mod}~2$ in units of the lattice wavenumber),
so we can write
\begin{align}
  H_{\t{int}} = G \sum K^{pk;q\ell}_{p+r,m;q-r,n}
  c_{p+r,m,\e}^\dag c_{q-r,n,\g}^\dag c_{q\ell,\g} c_{pk,\e}
  \approx G \sum K^{k\ell}_{mn}
  c_{p+r,m,\e}^\dag c_{q-r,n,\g}^\dag c_{q\ell,\g} c_{pk,\e},
\end{align}
where we made the approximation that $K^{pk;q\ell}_{p+r,m;q-r,n}$ only
weakly depends on the quasi-momenta $\p{p,q,r}$.

\subsection{Single-band spin model}

We now restrict ourselves to considering only the lowest band, such
that $K^{k\ell}_{mn}\to K$ and the single-particle energy takes the
form $E_q=-4J\cos\p{\pi q}$.  If $J \gg G K$, then by the secular
approximation we can neglect terms in $H_{\t{int}}$ which do not
conserve the sum of single-particle energies.  By solving the
single-particle energy conservation condition, one can find that this
approximation amounts to neglecting terms with $r\notin\set{0,q-p}$,
such that
\begin{align}
  H_{\t{int}}
  = G K \sum \p{n_{q,\g} n_{p,\e}
    + c_{q,\e}^\dag c_{p,\g}^\dag c_{q,\g} c_{p,\e}}
  = G K \sum \p{n_{q,\g} n_{p,\e}
    - c_{q,\e}^\dag c_{q,\g} c_{p,\g}^\dag c_{p,\e}}.
\end{align}
Defining
\begin{align}
  \1_p \equiv c_{p,\e}^\dag c_{p,\e} + c_{p,\g}^\dag c_{p,\g},
  &&
  \sigma_p^j \equiv \sum_{\alpha,\beta}
  c_{p\alpha}^\dag \sigma^j_{\alpha\beta} \sigma_{p\beta},
\end{align}
for Pauli matrices $\sigma^j$, we can therefore write
\begin{align}
  H_{\t{int}} = G K \sum
  \sp{\p{\f{\1_q+\sigma_q^z}{2}} \p{\f{\1_p-\sigma_p^z}{2}}
    - \sigma_q^- \sigma_p^+}.
\end{align}
Up to a global shift in energy, this result is equivalently
\begin{align}
  H_{\t{int}}
  = - \f14 G K \sum \v\sigma_q\c\v\sigma_p
  = - \f14 G K \v\sigma \c \v\sigma
  = - G K \v S \c \v S,
  &&
  \v S \equiv \f12 \v\sigma.
\end{align}
Expanding
\begin{align}
  K = \int d^3x \abs{\phi_0}^4
  = \int d^3x \abs{\f1{\sqrt{N}}\sum_j\tilde\phi_j}^4
  \approx \f1{N^2} \sum_j \int d^3x \abs{\tilde\phi_j}^4
  = \f1N \int d^3x \abs{\tilde\phi_0}^4
  = \f1N \tilde K,
\end{align}
we therefore arrive at the Hamiltonian
\begin{align}
  H_{\t{int}}
  = - \f{G\tilde K}{N} \v S\c\v S
  = -\f{\xi}{N} \v S\c\v S,
  &&
  \xi \equiv G \tilde K.
\end{align}

\subsection{Inter-band pair hopping}

We now consider pair hopping between the lowest two bands, and define
$a_{p\sigma} \equiv c_{p,0,\sigma}$ and
$b_{p\sigma} \equiv c_{p,1,\sigma}$.  The relevant terms in the
Hamiltonian are
\begin{align}
  H_{\t{int}}^{(0,1)} = G K^{0,0}_{1,1}
  \sum \p{b_{p+r,\e}^\dag b_{q-r,\g}^\dag a_{q,\g} a_{p,\e} + \t{h.c.}}.
\end{align}
Using driving schemes, we can make the single-particle energies in the
first two bands respectively $E_{q,0}=-4J_0\cos\p{\pi q}$ and
$E_{q,1}=4J_1\cos\p{\pi q}$.

As in the single-band case, we now assume that we can neglect hopping
terms in $H_{\t{int}}^{(0,1)}$ which do not conserve single-particle
energy.  By solving this energy conservation condition in the limit
$\abs{J_1}\gg\abs{J_0}$, we find that the only terms which survive are
those with $r=r_\pm\equiv-\p{p-q}/2\pm1/2$.  Defining
\begin{align}
  s \equiv \f{p+q}{2},
  &&
  d \equiv \f{p-q}{2},
\end{align}
in terms of which
\begin{align}
  p = s + d,
  &&
  q = s - d,
  &&
  r_\pm = -d \pm 1/2,
\end{align}
we can write
\begin{align}
  H_{\t{int}}^{(0,1)}
  = \sqrt{2} G K^{0,0}_{1,1} \sum
  \p{f_s^\dag a_{s-d,\g} a_{s+d,\e} + \t{h.c.}}
  = \sqrt{2} G K^{0,0}_{1,1} \sum
  \p{f_{\p{p+q}/2}^\dag a_{q,\g} a_{p,\e} + \t{h.c.}},
\end{align}
where
\begin{align}
  f_s^\dag \equiv \f1{\sqrt2}
  \p{b_{s-1/2,\e}^\dag b_{s+1/2,\g}^\dag
    + b_{s+1/2,\e}^\dag b_{s-1/2,\g}^\dag}.
\end{align}
For $r\ne s$, these operators satisfy the commutation relations
\begin{align}
  \sp{f_r, f_s} = \sp{f_r^\dag, f_s^\dag} = \sp{f_r, f_s^\dag} = 0,
\end{align}
\begin{align}
  \sp{f_s, f_s^\dag}
  = 1 - \f12 \p{\tilde n_{s+1/2,\e}^\dag + \tilde n_{s-1/2,\e}^\dag
    + \tilde n_{s+1/2,\g}^\dag + \tilde n_{s-1/2,\g}^\dag},
  &&
  \tilde n_{p\sigma} \equiv b_{p\sigma}^\dag b_{p\sigma}.
\end{align}

\end{document}


\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{graphicx,caption}
\graphicspath{ {./images/} }
\usepackage{float}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[unicode]{hyperref}
\usepackage{amsmath}
\usepackage[shortlabels]{enumitem}

\usepackage{listings}
\usepackage{xcolor}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
 \lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},
    commentstyle=\color{codegreen},
    keywordstyle=\color{black},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,
    breaklines=true,
    captionpos=b,
    keepspaces=true,
    numbers=left,
    numbersep=5pt,
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=2
}
\lstset{style=mystyle}

\title{Homework 5 - Theory/Laboratory}
\author{Dainese Fabio, 857661}
\date{April 12, 2020}

\begin{document}

\maketitle

\section{The Watts and Strogatz’s Model}
    \begin{itemize}
        \item The local \textit{clustering coefficient} (CC),  provided in the \textit{Watts and Strogatz} paper, measures the cliquishness of a neighbourhood (you can see this feature also as how likely 2 nodes that are connected are part of some larger highly connected group of node - i.e. clique).\newline

        \par\noindent This statistic can assume values between 0 and 1, indicating the fraction of possible interconnections between the neighbours of a node (visually you can consider that 0 indicate a start topology graph, meanwhile 1 means a clique).\newline

        \par\noindent To compute the CC of a graph you just need to consider the average value between all the CC of each node belonging to the graph.

        \item Considering the scenario of having \(n = 400\) nodes, \(K = 10\) and the re-wiring probability \(q = 0.01 + 0.01j\), for \(j = 1,...,99\). \newline

        \par\noindent The average clustering coefficient (CC(q)) and the average path length (APL(q)) for each \(q\) has been calculated using the following \textit{MatLab} code:\newline

        \begin{lstlisting}[language=Matlab]
clear all;
clc;

n = 400;
K = 10;

q_cumulative = (0.02:0.01:1)';
q_length = size(q_cumulative,1);
storage = zeros(q_length,2);

for j=1:q_length
    q = q_cumulative(j,1);
    WS = WattsStrogatz(n,K,q);
    cc = clustering_coef_bu(WS.adjacency);

    storage(j,1) = mean(cc);
    storage(j,2) = mean(distances(WS),'all');
end

figure(1)
plot(q_cumulative,storage(:,1),'k-');
title('CC(q)');
xlabel('Re-wiring probability');
ylabel('Clustering coefficient');

figure(2)
plot(q_cumulative,storage(:,2),'k-');
title('APL(q)');
xlabel('Re-wiring probability');
ylabel('Average path length');
\end{lstlisting}

        \noindent Which generates the following two graphs:

        \begin{figure}[H]
            \centering
            \includegraphics[width=0.9\textwidth]{1.png}
            \caption{Average clustering coefficient}
            \label{fig:figure-1}
        \end{figure}
        \begin{figure}[H]
            \centering

            \includegraphics[width=0.9\textwidth]{2.png}
            \caption{Average path length}
            \label{fig:figure-2}
        \end{figure}

        \item By setting the logarithmic horizontal scale to the previous graphs it has been more clear that the \(APL(q)\) drops very quickly (meaning that thanks to the re-wiring process the distance between the nodes in the network decreased), meanwhile the \(CC(q)\) at the beginning (regular lattice 'state') decrease very slowly, indicating that the transition to a small world is almost undetectable at the local level.

    \end{itemize}

\end{document}


\documentclass[jou]{apa6}

\usepackage[american]{babel}

\usepackage{csquotes}
\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\addbibresource{bibliography.bib}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Discrete Structures
%% The start of RBS stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Working internal and external links in PDF
\usepackage{hyperref}
% Extra math symbols in LaTeX
\usepackage{amsmath}
\usepackage{gensymb}
\usepackage{amssymb}
% Enumerations with (a), (b), etc.
\usepackage{enumerate}
\usepackage{xcolor}

\let\OLDitemize\itemize
\renewcommand\itemize{\OLDitemize\addtolength{\itemsep}{-6pt}}

\usepackage{etoolbox}
\makeatletter
\preto{\@verbatim}{\topsep=3pt \partopsep=3pt }
\makeatother

% These sizes redefine APA for A4 paper size
\oddsidemargin 0.0in
\evensidemargin 0.0in
\textwidth 6.27in
\headheight 1.0in
\topmargin -24pt
\headheight 12pt
\headsep 12pt
\textheight 9.19in

\title{Sample Quiz 4}
\author{Discrete Structures, Spring 2020}
\affiliation{RBS}

\leftheader{Discrete Quiz 7}

\abstract{%
}

%\keywords{}

\setlength\parindent{0pt}

\begin{document}

%\thispagestyle{empty}

\twocolumn
\section{Quiz 7: Counting}

% P1: 4+4

\vspace{10pt}
{\bf Question 1 (Placing 8 rooks).} Somebody has an $8 \times 8$ chessboard and
$8$ rooks ($4$ of them black, $4$ of them white).
In how many ways one can place these $8$ rooks on the chessboard so that
no rook shares the same horizontal or vertical with any other rook.
Assume that the rooks of the same color are not distinguishable (but the chessboard itself cannot be rotated
or flipped - i.e.\ we count symmetric positions multiple times).
\begin{figure}[!htb]
\center{\includegraphics[width=2in]{quiz-07/chessboard.png}}
\caption{\label{fig:chessboard} Chessboard $8 \times 8$.}
\end{figure}

Write a positive integer.

\vspace{6pt}
{\bf Question 2 (Finding a higher order derivative).}\\
There is a formula to compute the 1st derivative of a product:
$$(uv)' = u'v + v'u.$$
Assume that you need to compute the 4th derivative of a product of two functions $u\cdot v$.
Enter the formula to compute $(uv)''''$.

Your answer can use letters $u$, $v$,
apostrophes (denoting the derivatives of the 1st, 2nd, 3rd and 4th degree),
asterisk {\tt *} denoting multiplication and integer numbers.

\vspace{6pt}
{\bf Question 3 (Multinomial formula).}\\
As a generalization to the Newton's binomial theorem (the expression for $(a+b)^n$), there
is also a more general {\em multinomial theorem}:
$$(x_1 + x_2  + \cdots + x_m)^n
 = \sum\limits_{k_1+k_2+\cdots+k_m=n} {n \choose k_1, k_2, \ldots, k_m}
  \prod_{t=1}^m x_t^{k_t}\,,$$
where the {\em multinomial coefficients} are computed like this:
$${n \choose k_1, k_2, \ldots, k_m}
 = \frac{n!}{k_1!\, k_2! \cdots k_m!}$$

Assume that you use the multinomial formula to open parentheses in the following expression $(a+b+c)^9$.\\
{\bf (A)} How many {\em terms} are added in this expression?  (A term is a product
of some number with the powers: $k\cdot a^x b^y c^z$, where $k$ is a positive number, but
$x,y,z$ are nonnegative integers.)\\
{\bf (B)} What is the coefficient for the term $a^3b^3c^3$ in this expansion?

Write two numbers separated by a comma.

\vspace{6pt}
{\bf Question 4 (Permutations of ANNA).} Create a list of all permutations
of the letters in the word {\tt ANNA}. Assume that both copies of "A" and "N" are indistinguishable.

Write an alphabetically sorted list separated by commas.

\vspace{6pt}
{\bf Question 5 (Pennies in jars).}
Somebody has 5 pennies and 4 jars. All pennies are distinguishable and each penny should go into some jar.
All the jars are placed in the vertices of a square $ABCD$; jar locations that differ only by rotations of that
square are considered indistinguishable. (For example, if all the pennies from the vertex $A$ would go to $B$;
all pennies from $B$ would go to $C$, from $C$ to $D$, and from $D$ to $A$, then it would be the same way to distribute pennies.)

Find the number of ways how the pennies can be distributed among these jars. Write your answer as an integer.

\vspace{6pt}
{\bf Question 6 (Odd binomial coefficients).} Assume the following Kummer's theorem (\url{https://bit.ly/38Bak99}):\\
The binomial coefficient ${n \choose k} = C_n^k = \frac{n!}{k!(n-k)!}$ is odd iff
adding the binary notations of $k$ and $n-k$ there are no carries.\\
For example, the binomial coefficients ${10 \choose k}$ where $k=0,\ldots,10$ are the following:
$$\textcolor{red}{1},10,\textcolor{red}{45},120,210,252,210,120,\textcolor{red}{45},10,\textcolor{red}{1}.$$
The only odd numbers are ${10 \choose 0}$, ${10 \choose 2}$, ${10 \choose 8}$, ${10 \choose 10}$,
since $0_{2} + 1010_{2}$ and also $10_{2} + 1000_{2}$ can be added without any carries (i.e.\
adding these we won't run into situation where we need to add $1+1$ or $1+1+1$ anywhere: Every situation
where some digit is ``carried over'' from a smaller position of the binary number to a larger one is called a ``carry''.)

Find the number of odd numbers ${2020 \choose k}$, where $k = 0,1,\ldots,2020$.
Express your answer as an integer number in decimal notation.

\vspace{6pt}
{\bf Question 7 (Sorted permutations).} As we know there are $5! = 120$ ways how to write the 5-letter word
{\tt ABCDE} (using every letter exactly once). Find the word that is written in the 100th position (assuming that
all the 120 permutations are sorted alphabetically).

Write your answer as 5-letter word.

\newpage

\subsection{Answers}

\vspace{4pt}
{\bf Question 1.} Answer: {\tt 2822400}\\
{\bf Statement 1:} If rooks would be the same color (so that the ``individuality'' of a rook
does not matter), then we could have $8! = 40320$ different placements.\\
On the first horizontal you can place a rook in $8$ different ways (choose any vertical),
on the second horizontal you can place a rook in $7$ different ways (one vertical is already taken) and so on.
Finally, you multiply all these numbers together.\\
{\bf Statement 2:} You can pick the four horizontals containing white rooks in ${8 \choose 4} = 70$ different ways.\\
This follows immediately from the definition of a combination of $k=4$ elements out of an $n=8$ element set.

The total can be obtained, if we multiply $8!$ (placements of indistinguishable rooks) by ${8 \choose 4}$.
The product is $40320 \cdot 70 = 2822400$.

\vspace{10pt}
{\bf Question 2.} Answer:\\
$\mathtt{u''''*v+4*u'''*v'+6*u''*v''+4*u'*v'''+v''''}$\\
{\em (In your responses the multiplication could be omitted, and also the
order of summation can be different.)}\\
Let us verify, why expanding the expression $(uv)''''$ leads to the same binomial coefficients
as Newton's binom $(a+b)^4$. We express successive derivatives:
\begin{align}
(uv)' & = u'v + uv'. \\
(uv)'' & = (u'v + uv')' = (u'v)' + (uv')' = \nonumber \\
 & = (u''v + u'v') + (u'v' + uv'') = \nonumber \\
 & = u''v + 2u'v' + uv''.\\
(uv)''' & = (u''v + 2u'v' + uv'')' = \nonumber \\
 & = (u''v)' + 2(u'v')' + (uv'')' = \nonumber \\
 & = (u'''v + u''v') + 2(u''v' + u'v'') + (u'v'' + uv''') = \nonumber \\
 & = u'''v + 3u''v' + 3u'v'' + uv'''.\\
(uv)'''' & = (u'''v + 3u''v' + 3u'v'' + uv''')' = \nonumber \\
 & = u''''v+4u'''v'+6u''v''+4u'v'''+v''''.
\end{align}

\vspace{10pt}
{\bf Question 3.} Answer: {\tt 55,1680}\\
To see, how many terms there are in the expansion of $(a+b+c)^9$,
notice that each term is in form $a^xb^yc^z$, where $x,y,z$ are nonnegative
integers satisfying $x+y+z=9$. To count the ways how $n=9$ can be expressed
as a sum of $k=3$ nonnegative numbers, we compute the {\em combination with
repetitions}. The formula for combination with repetitions is this:
$${n+k-1 \choose k-1} = {9+3-1 \choose 3-1} = {11 \choose 2} = \frac{11 \cdot 10}{2 \cdot 1} = 55.$$

By multinomial formula, the coefficient for $a^3b^3c^3$ is $\frac{9!}{3!3!3!} = 1680$.

\vspace{10pt}
{\bf Question 4.}\\ Answer: {\tt AANN,ANAN,ANNA,NAAN,NANA,NNAA}\\
The number of permutations with repetitions equals $\frac{4!}{2!}{2!} = \frac{24}{2 \cdot 2} = 6$.
We have four letters (and two of them repeat twice each).
Once we sort all the permutations alphabetically, we get the answer:
the first three permutations start by ``A'', the next three start by ``N''.

\vspace{10pt}
{\bf Question 5.} Answer: {\tt 256}\\
Each penny can be placed in any of the four jars. We make this choice five times, so the
total number of ways is $4^5 = 1024$. Moreover, you can rotate the four jars in four different ways (getting
essentially identical ways to distribute pennies, which have been counted four times each).
So the final answer can be obtained by dividing $1024/4 = 256$.

Another solution: Place the first penny in one of the jars.
Since the pennies are all distinguishable, this jar is very special.
Place that jar in the North position, then the remaining jars are facing East, South and West.
And then you can make four choices with four outcomes each. So the result is still $4^4 = 256$.

\vspace{10pt}
{\bf Question 6.} Answer: {\tt 128}\\
We have this equality:
$$2020 = 1024 + 512 + 256 + 128 + 64 + 32 + 4,$$
So $2020_{10} = 11111100100_2$. The binary notation for $2020$
contains digit $1$ in $7$ positions.

There are altogether
$2^7 = 128$ how you can split these seven digits $1$ between
$k$ and $2020-k$ so that when you add $k$ and $2020-k$ (in binary notation)
you do not get any carries. Here are some of these ways:\\
{\small
$\mathtt{11111100100}_2 = \mathtt{11111100100}_2 + \mathtt{0}_2 = 2020_{10}+0_{10}$,\\
$\mathtt{11111100100}_2 = \mathtt{11111100000}_2 + \mathtt{100}_2 = 2016_{10} + 4_{10}$,\\
$\mathtt{11111100100}_2 = \mathtt{11111000100}_2 + \mathtt{100000}_2 = 1988_{10} + 32_{10}$,\\
$\mathtt{11111100100}_2 = \mathtt{11111000000}_2 + \mathtt{100100}_2 = 1984_{10} + 36_{10},\ldots$\\
$\mathtt{11111100100}_2 = + \mathtt{0}_2 + \mathtt{11111100100}_2  = 0_{10} + 2020_{10}$.\\
}
So, all ${2020 \choose 0}$,  ${2020 \choose 4}$,  ${2020 \choose 32}$,  ${2020 \choose 36}$, etc. are odd.

\vspace{10pt}
{\bf Question 7.} Answer: {\tt EACDB}.\\
There are $24$ permutations of {\tt ABCDE} starting with each
letter (A,B,C,D and E). The first $24+24+24+24=96$ of them start by A,B,C,D respectively.
So the 100th permutation would start by ``E'', and it will be the 4th out of them.
We can create a sequence of the (alphabetically) first four permutations starting by ``E'':
$$\mathtt{EABCD},\mathtt{EABDC},\mathtt{EACBD},\mathtt{EACDB},\ldots$$
We see that the 100th permutation (or the 4th among those starting by ``E'') is
{\tt EACDB}.

\end{document}


% This is a comment. It doesn't show in the final pdf.

%%%%% Preamble %%%%%
\documentclass[11pt]{article} % Font Size and Document type (article is the standard type)

\usepackage{amsmath} % use the package amsmath, which lets us do mathy things
\usepackage{graphicx} % use graphicx, which lets us insert images
\usepackage{multicol} % use multicol, which lets us split things into multiple columns
\usepackage{biblatex}
\addbibresource{bibliography.bib}
% title info
\title{\textbf{A Simple \LaTeX{} Document}}
\author{Your name goes here\\}
\date{\today}

%%%%% Body of Document %%%%%
\begin{document}

\maketitle % this command gets the title info from above and puts it all together

\section{Formatting} % this is a section header
%--------------------------------------------------

\subsection{Basic} % this is a subsection header
%--------------------------------------------------
\begin{itemize} % start an unordered list
\begin{multicols}{2} % break the list into two columns
	\item \textit{Italic}
	\item \textbf{Bold}
	\item \textbf{\textit{Italic and Bold}}
	\item \underline{Underlined}
	\item `Single Quotes'
	\item``Double Quotes''
\end{multicols}
\end{itemize}

\subsection{Paragraphs}
%--------------------------------------------------
\subsubsection{Alignment}
\begin{flushleft} % try changing 'flushleft' to 'center' or 'flushright'
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{flushleft}

\subsection{Math}
%--------------------------------------------------
To write a bunch of math all on its own, do it like this:
\[ax^2 + bx + c = 0\] % '\[' and '\]' mark the start and end of the math figure

To write math in the middle of a bunch of words, do it like this: $e=\lim_{n\to\infty}\left(1+\frac{1}{n}\right)^n$ See? Easy!

\section{Tables}
%--------------------------------------------------
\begin{center}
\begin{tabular}{|r|c l|} % format the columns
	\hline % horizontal line
	a1 & b1 & c1 \\ % '\\' ends the current line
	a2 & b2 & c2 \\
	a3 & b3 & c3 \\
	\hline
	a4 & b4 & c4 \\
	\hline
\end{tabular}
\end{center}

\section*{Images and Figures} % use '*' to suppress the section numbering
%--------------------------------------------------
\begin{figure}[h] % google what h does
\begin{center}
	\includegraphics[scale=0.1]{beaker} % we shrink the picture so it's not too big
\end{center}
\caption{Here's a picture of a beaker}
\end{figure}

\section{Other Stuff}
%--------------------------------------------------
\begin{enumerate} % start an ordered list
	\item This is an ordered list
	\item Break one line \\ into two.
\end{enumerate}

%--------------------------------------------------
% this is the simplest way to make a bibliography
\begin{thebibliography}{1}
	\bibitem{Wikibook} The LaTeX wikibook: {\em https://en.wikibooks.org/wiki/LaTeX}
\end{thebibliography}
%--------------------------------------------------

\end{document} % all documents must come to an end


\chapter{Idea of Photometry}

\section{The Point-Spread Function (PSF)}

Stars must be point sources. But from our experience, we know that they are never a point, but a usually nearly circular extended sources on the CCD. The image on the CCD when a single perfect point source is imaged, is called the \textbf{point spread function (PSF)}. There are basically two mechanisms responsible for this: diffraction and seeing. Although diffraction can also be a part of seeing, it is somewhat special than others: It is just impossible to eliminate the diffraction, while other sources of seeing can be removed (see below).

\subsection{Diffraction}
When a light ray passes through a finite-sized aperture, diffraction must occur. Due to this, a point source is blurred to a finite size after it passed through an aperture (e.g., telescope or DSLR camera aperture).

\begin{ex}[Diffraction]
	For $ D = \SI{1}{m} $ in visible ($ \SI{550}{nm} $ wavelength), the diffraction limit is $ 1.22 \frac{\lambda}{D} = \SI{0.14}{arcsec}$. You may be familiar with this formula. Using the proportionality, you can memorize it as $ \theta_\mathrm{min}^{(\SI{550}{nm})} = \frac{0.14}{D\mathrm{[m]}} \mathrm{arcsec}$.
\end{ex}

It is more complicated in reality: the mirrors and other optical instruments located in the optical path affect the final shape of a point source by diffractions. See \cref{fig:psftelescopes} for the examples of simulated PSFs from optics, i.e., when the seeing effects are neglected.

\begin{figure} [htb!]
	\centering
	\includegraphics[width=0.9\linewidth]{figs/psf_telescopes}
	\caption{Example of PSFs. For circular aperture, the PSF shows concentric diffraction pattern as we learned in general physics course. For JWST case, you can see the secondary mirror and the mirror holding pipe (black things) makes the PSF different compared to the 2-ring case. The bottom row is not just a zoom-in of the PSF, but also the stretch (contrast) is different from the mid row (DR means the dynamic range). Direct excerpt from Figure 2 of FordKES+, 2014, ApJ, 783, 73.}
	\label{fig:psftelescopes}
\end{figure}

As you can see in \cref{fig:psftelescopes}, although the detailed PSF are different (mid row), the long-range features are weaker compared to the central nearly circular features (bottom row) in cases except for the last column, which is not of our interest.

\subsection{Seeing}

Even if we ignore the diffraction, a point source is blurred due to two main reasons: (1) air turbulence and (2) discontinuous movement of the telescope since the telescope gear is not a perfectly smooth continuous ideal machine. The blurring caused by these are called \textit{natural (atmospheric)} and \textit{telescopic seeing}, respectively. The atmospheric seeing makes a point source an extended circular source (for details, search for the theory of, e.g., Andrei Kolmogorov), while the telescope seeing \textit{may} make it very elongated or irregular depending on the quality of the tracking system. If the tracking system is well established on a telescope, the final telescope seeing effect is quite circular.

All these effects can be removed if we move our telescope in space. The atmospheric turbulence is now gone, and the telescope can be very stable such that the telescopic seeing is ignorable. This is what is called the diffraction-limited case.

\subsection{Summary of PSF}

To summarize:
\begin{align*}
  \mathrm{PSF} &= \mathrm{diffraction} + \mathrm{seeing} \\
  \mathrm{seeing} &= \mathrm{atmospheric~seeing} + \mathrm{telescopic~seeing}
\end{align*}
and practically speaking,
\begin{equation*}
  \mathrm{PSF~shape} \approx \mathrm{circular} ~.
\end{equation*}
This is why we can talk about the circular aperture photometry. Also
\begin{align*}
  &\mathrm{diffraction} \ll \mathrm{other~sources~of~seeing} \\ &\mathrm{(unless~adaptive~optics~or~space~telescope~used)} ~.
\end{align*}

Actually, for many ground-based observations, it is not necessarily important to distinguish diffraction from other seeing effects. I feel like people tend to use the word ``PSF'' when the PSF is measured rather accurately (e.g., PSF photometry), and use the word ``seeing'' when we assumed circular PSF (e.g., aperture photometry).

\subsection{Seeing Disc Size}
As mentioned above, when we assume circular PSF (as we will do frequently in aperture photometry), we use the word ``seeing'' for the PSF. \textit{Seeing disc} is the word for the circular shape of the PSF, and the \textit{seeing disc size} is a measure of the size of that circle. The definition of the ``size'' is not trivial, but many people use the FWHM of the stellar radial profile\footnote{Radial profile means the pixel values of the star image as a function of the distance from the center of the star: $ I(r) $. From many free/commercial products, it is rather easily drawn, such as \texttt{ginga}, \texttt{SAO ds9}, or \texttt{Maxim DL 6}. They also automatically calculates FWHM for you. The details on how to find the ``center'' will be studied later. Here, just think about something like Gaussian curve.}. This seeing disc size measurement is used to find the focal position and give a sense to the data quality.

The seeing disc FWHM is dependent on wavelength, weather, airmass, etc. At Seoul National University observatories in Seoul, it is roughly 1 to 3 arcsec at Bldg. 46 and 3 to 6 arcsec at Bldg. 45. For Subaru telescope at Hawai'i, for example, it is less than 1 arcsec\footnote{\url{https://www.naoj.org/Observing/Telescope/ImageQuality/Seeing/}}. Compared to the diffraction size $ \theta_\mathrm{min} $, these are much larger. It can go even below if we use adaptive optics (then $ \mathrm{diffraction} \approx \mathrm{total~seeing} $ and non-circular PSF may be important).

The fact that the seeing disc size (i.e., size of the circular PSF) on the CCD is normally much larger than the diffraction scale hint that atmospheric and telescope seeing are very important. Since the telescope seeing is roughly constant over time for continuous tracking of a good telescope, the change in seeing can also strongly dependent on the weather condition. So astronomers use seeing disk size (usually rough estimate of FWHM) as a proxy of the weather condition.

It can also be used as a data-quality-indicator.

\begin{ex}[Contamination by Other Object]
If you have your faint target near a bright stellar source with 1 arcsec separation and if the seeing disc FWHM is roughly 1 arcsec, your faint target is contaminated by the nearby bright star. A possibility is to do photometry of ``your target $ + $ bright star'' and subtract the flux of the ``bright star'' from catalog or future/previous observations. In this case, although you can get the flux of the target, its uncertainty may increase significantly.
\end{ex}

\begin{ex}[Slit Width Determination]
For spectroscopy, seeing disc size may determine the slit width you have to use to collect the target's light into the slit. It will be dealt in the spectroscopy chapter.
\end{ex}

\begin{ex}[Finding Focal Position from Seeing FWHM]
First find a random bright star that do not vary over short period of time (e.g., about 1 hour). You then expose and check the FWHM of the PSF (assuming it is circular). Now tune the focal position, e.g., by moving the position of the secondary mirror, and expose again, and check the FWHM again. Doing this repeatedly, you can get the FWHM as a function of the focal position. When the FWHM becomes the minimum, that is \textit{the} focal position (\cref{fig:focusing}). Normally this curve is roughly second order polynomial.
\end{ex}

\begin{figure}[ht!]
  \centering
  \includegraphics[width=0.7\linewidth]{figs/focusing}
  \caption{Finding focal position. While tuning the focal position value (x-axis), check the FWHM of the stellar profile. In this fake simulation, it is found that the focal position of 52.0 is \textit{the} focal position with FWHM $ \sim 4 $ pixels. Multiplying with the pixel scale will give the FWHM in angular units (e.g., if the pixel scale is $ \SI{0.8}{arcsec/pixel} $, FWHM after the focusing is $ \SI{4}{pixel} \times \SI{0.8}{arcsec/pixel} = \SI{3.2}{arcsec} $)}
\label{fig:focusing}
\end{figure}

Our goal in observation is to ``gather all the photons from the target''. For a faint source, you have to tune the focal position very accurately, so that the signal from the source gathers to as small number of pixels as possible. Otherwise, the signal will be buried in sky values or other noise sources (dark current or readnoise) and our goal may not be achieved. The non-circular PSFs for high-quality data shares this same philosophy: the ``sprays'' of PSF should be analyzed. But for a very bright source, you may even intentionally defocus before the exposure. This is because we can avoid saturation and blooming from the central pixels while the signal is so strong that the noise is overwhelmed by the source signal. Then our goal is achieved even if we forget about the accurate focal position or accurate PSF.

\section{Centroid}
Even though we know the accurate PSF, we cannot use it for photometry if we cannot determine the center or the origin. There are various ways to determine this ``origin'', but the most widely used one is centroiding (center of mass).

%but most of them have one or more of the following drawbacks: (1) no analytic solution but numerical calculation needed, (2) computationally heavy, (3) formulated only by empirically. One of the useful analytical centroiding is given here.

Let $ I_i $ for $ i = 1, 2, \cdots , N $ means the $ i $-th pixel with $ (x, y) = (x_i, y_i) $ of the original $ N_x \times N_y $ 2-D pixel array so that $ N = N_x N_y $. Say we set a threshold $ I_0 $ (e.g., background value, signal-to-noise ratio of 3, etc). Then change $ I_i = 0 $ if $ I_i < I_0 $. For $ \xi = x $ or $ y $, the centroid is by definition
\begin{equation} \label{eq: centroid}
  \xi_c = \frac{\sum_i I_i \xi_i}{\sum_i I_i} ~.
\end{equation}
By using the error-propagation, the uncertainty of $ \xi_c $ is, considering $ \xi_i $'s are fixed with no uncertainty,
\begin{equation}
  \qty (\Delta \xi_c)^2
    = \qty(\pdv{\xi_c}{I_1})^2 \qty(\Delta I_1)^2
      + \cdots + \qty(\pdv{\xi_c}{I_N})^2 \qty(\Delta I_N)^2 ~.
\end{equation}
But
\begin{equation}
  \pdv{\xi_c}{I_k}
    = \pdv{I_k} \qty( \frac{I_1 \xi_1 + \cdots + I_N \xi_N}{I_1 + \cdots + I_N} )
    = \frac{\xi_k}{\sum_i I_i} - \xi_c ~,
\end{equation}
so
\begin{equation}
  \qty (\Delta \xi_c)^2
  = \sum_k \qty(\frac{\xi_k}{\sum_i I_i} - \xi_c)^2 \qty(\Delta I_k)^2
  = \frac{\sum_k (\xi_i - \xi_c)^2 \qty(\Delta I_k)^2}{\sum_i I_i} ~.
\end{equation}
Pixels near the object are likely to have high pixel values, so we approximate the uncertainty $ \Delta I_i $ is just the Poisson noise of the pixel value (which is source $ + $ sky $ + $ read noise), i.e., \cref{eq: Pois mean std}, $ \Delta I_i = \sqrt{I_i} $. Then expanding the square and using the definition of $ \xi_c $, we get
\begin{equation} \label{eq: centroid err}
  \Delta \xi_c
  = \sqrt{\frac{\sum_k (\xi_i - \xi_c)^2 I_k }{\sum_i I_i} }
  = \sqrt{\frac{s_c^2}{\sum_i I_i}}
\end{equation}
where
\begin{equation}
  s_c^2 = \frac{\sum_k \xi_k^2 I_k}{\sum_i I_i} - \xi_c^2 ~.
\end{equation}

There are some other techniques which involves Gaussian fitting: marginalize the image onto the $ x $- and $ y $-axes, and do the 1-D Gaussian fitting to each of them. Also the sigma-clipping inside the centroiding box (cbox) can be used (e.g., Ma+ 2009, Opt.Exp., 17, 8525).

\section{Aperture Sum}
We need first to find the total flux inside the aperture. The sky subtraction will be done later. Consider a very simple case in \cref{fig:photapex01}: The centroid is calculated following \cref{eq: centroid}, and it is trivial that the centroid is at the center of the shown image. If we put circular aperture of radius 1 pixel (middle panel), the pixel contribution from the pixel with value 10 (right panel) is
\begin{equation}
  \mathrm{pixel~value} \times \frac{\mathrm{area~in~aperture}}{\mathrm{total~area}}
  = 10 \times \frac{\pi / 4}{1}
  = 7.854 ~.
\end{equation}
Doing the same calculation for all the 4 pixels inside the aperture, you will get $ N_\mathrm{apsum} = 47.12 $, where apsum means the ``aperture sum''.

\begin{figure} [ht!]
\centering
\includegraphics[width=0.7\linewidth]{figs/phot_ap_ex01}
\caption{Left: An example pixel values near the source. Middle: An aperture of radius 1 pixel shown as green circle. Right: A zoom in of one pixel with pixel value 10.}
\label{fig:photapex01}
\end{figure}

One thing to note is the uncertainty in position. In this 4 by 4 pixel example, $ \sum_i I_i = 84 $ and $ \xi_c = (x_c, y_c) = (1.5, 1.5) $ under the 0-indexing. For $ \Delta x_c $, we consider only the $ x $-coordinate for \cref{eq: centroid err} caluclation. Note that in that case, $ \sum_k (x_k^2 I_k) $ for all the $ \num{4 x 4} = 16 $ pixels is nothing but $ \sum_{k=1}^{4} (x_k^2 I'_k) $ where $ I' = [8,\, 34,\, 34,\, 8] $ is the marginalized intensity along the $ x $ direction from \cref{fig:photapex01}. Then $ \Delta x_c = 0^2 \times 8 + 1^2 \times 34 + 2^2 \times 34 + 3^2 \times 8 = 242 $. This must be the same for the $ y $-axis, and thus $ s_c^2 = 242 / 84 - 1.5^2 = 0.63 $, so $ \Delta x_c = \Delta y_c = \sqrt{0.63 / 84} = 0.087 $ pixel.

Here, I did not touch the topics such as (1) how to select the aperture radius, $ r_\mathrm{ap} $ and (2) in reality, we need to fit some function to the radial profile, but which function should we use? These will be dealt in the next chapter.

Since this aperture sum includes not only the source but also the sky values (sky value is always non-zero for ground-based observations), we need to subtract the sky.

\section{Sky Estimation}
Estimation of the sky is one of the most trickest part in observational astronomy. There are two most widely used methods: annulus and 2D interpolation. I will first explain few formulae, and then explain these two methods.

\subsection{Simple Parametric Sky Estimation}
There have been some parametric methods to estimate correct sky value. The most widely used ones include the ``MMM'' relation, or the ``mean-median-mode'' relation, and regard the mode (most frequent value) as the constant sky value. This has been used by virtually all astronomical softwares, including IRAF, IDL, SExtractor, and python packages. It is the simplest and does not require much computational speed, while gives reasonable results in many cases.

Why mode? The mission in determining the \textit{constant} sky value is to find a \textit{robust}, i.e., trustful constant value. Average (mean) is very vulnerable to few outliers even though we did sigma-clipping, and the median is less robust than mode, because if faint object with $ S/N $ ratio $ \sim 1 $ is in the sky region, the median can also be overestimate the sky. Thus, mode is the most widely used simple statistic for sky estimation.

The determination of the modal value is very difficult, because the it is not simple to define it for the \textit{sampled data}. If the distribution is not a mathematically continuous one, i.e., if it is discrete as we always encounter after sampling process, the mode is the largest value when we draw a \textit{histogram}. The histograms are basically sensitive to the subjective selection of bins, and you can change the modal value to an unexpected value depending on the bin you choose (see \cref{fig:phottestsky01}). %It gets very complicated because the pre-processed image can have real number values, not integers. Hence, the histogram may look like a comb with only 1 count at each comb, if the bins are set to be infinitesimally small.

\begin{figure}[ht!]
\centering
\includegraphics[width=\linewidth]{figs/phot_testsky01}
\caption{Left: A fake sky of 20 by 20 pixels generated by $ 100 + \mathcal{N}(0, 5^2) + 5 \chi^2_2 + 3 \mathcal{U}(0, 1) $ (normal distribution, chi-squared distribution, and uniform distribution, respectively). Others: The histogram of the pixel values with different bin numbers with fixed bin width. The black dotted lines is the median, and the red and blue solid lines are the mode estimation from \cref{eq: mmm 3 2,eq: mmm sex}, respectively (almost indistinguishable). As can be seen, the mode value does not lie at the same position, and it even become bimodal when the number of bins is 80.}
\label{fig:phottestsky01}
\end{figure}

Since 1800s, people empirically knew that the mode has the following relationship which holds for a moderetely asymmetric distribution:
\begin{equation}\label{eq: mmm 3 2}
  \mathrm{mode} \approx 3 \times \mathrm{median} - 2 \times \mathrm{mean} ~,
\end{equation}
or equivalently, \textit{the distance between the mode and median is two-thirds of that between mode and mean}. DoodsonAT (1917, Biometrika Trust, 11, 425) first gave mathematical proof of it using some mathematical tricks including Laplace's and De Morgan's (1836), and it is recognized by many statisticians including KendallMG (1943; or the second edition of it in 1945, The Advanced Theory of Statistics 2e, Vol 1, p.35). People now refer to more recent references like KendallMG+StuartK (1977, The Advanced Theory of Statistics, Vol. 1. Charles Griffin \& Co., London).

SExtractor (BertinE+ArnoutsS, 1996, A\&AS, 117, 393) uses a variant of this:
\begin{equation}\label{eq: mmm sex}
  \mathrm{mode} \approx 2.5 \times \mathrm{median} - 1.5 \times \mathrm{mean} ~.
\end{equation}
There is no clear reason provided in the original paper nor the SEx user manual, but it is just descibed that it was found to be more accurate when they tested. The estimation process works like this: Get the mean, median, and sample standard deviation (mean, med, std, respectively) from the sky pixel values after sigma-clipping. If $ \frac{\mathrm{mean} - \mathrm{med}}{\mathrm{std}} > 0.3 $, use $ \mathrm{mode} \approx \mathrm{med} $\footnote{Although the publication and SEx manual says they use mean if $ \frac{\mathrm{mean} - \mathrm{med}}{\mathrm{std}} > 0.3 $, but the SEx software actually returns med, not mean (described in photutils v0.6, Background Estimation (photutils.background))}. Otherwise, use \cref{eq: mmm sex}.

IDL MMM uses \cref{eq: mmm 3 2}. IRAF also uses \cref{eq: mmm 3 2} internally, but it gives the mean value if $ \mathrm{mean} < \mathrm{med} $. In astropy-related packages (e.g., \texttt{photutils}), it is the user's choice. In all cases, you can set the sigma-clipping factors, e.g., $ a $ such that data outside $ \mathrm{med} \pm a \times \mathrm{std} $ can be rejected, and $ n $, the maximum iterations this process should be done until no more data are rejected. Whether to use $ \mathrm{med} \pm a \times \mathrm{std} $ or $ \mathrm{mean} \pm a \times \mathrm{std} $, whether to give asymmetric $ a $ values (upper and lower sigma-clipping), etc are up to the user.

I recommend to follow what SEx does, with sigma-clipping of $ a \sim 3 $ and $ n \ge 5 $, because that became a virtual standard in parametric sky estimation.

\subsection{Other Ways for Sky Estimation}
As can be seen from \cref{fig:phottestsky01}, the sky histogram is mostly skewed towards right. Because of this, BijaouiA (1980, A\&A, 84, 81) first introduced to fit the sky histogram with Gaussian multiplied by Laplace:
\begin{equation}
  p(I) = \frac{e^{\sigma^2 / 2 a^2}}{a} e^{-(I - s) / a} \mathrm{erf}_c \qty(\frac{\sigma}{a} - \frac{I - s}{\sigma})
\end{equation}
where
\begin{equation}
  \mathrm{erf}_c(x) := \frac{1}{\sqrt{2\pi}} \int_x^{+\infty} e^{-t^2/2} dt ~.
\end{equation}
IrwinMJ (1985, MNRAS, 214, 575) argued that this method for modal estimation (Bayesian maximum likelihood is used) is better compared to mean, median, and Gaussian fitting. But because of the complexity of the calculation, Irwin used simpler method, i.e., get the smoothed histogram near the estimated mode and fit a Gaussian. BeardSM+ (1990, MNRAS, 247, 311) used slightly different method: smooth the (sky pixel) frequency histogram with moving box filter, find the mode estimate with it, sample the pixels nearby it which has pixel values larger than half of it. Then it does a cubic polynomial fit to the unsmoothed original histogram and finds the peak from this polynomial as the mode estimate.

For more, you may refer to Appendix A of AkhlaghiM and IchikawaT (2015, ApJS, 220, 1) and section 3.1 of MasiasM+ (2012, MNRAS, 422, 1674).

\subsection{Annulus Sky}
The simplest way is to use circular annulus. This method assumes the sky is nearly constant near the terget of interest, PSF is circular, and there is no nearby celestial object. Under these simplifying assumptions, the sky must be azimuthally symmetric and a function of radius centered on the centroid of the target. If we set the inner and outer radii $ r_\mathrm{in} $ and $ r_\mathrm{out} $ much larger than the seeing disc size to define the circular annulus, the pixel values within that annulus are now the ``sample'' of sky values, and should not have clear tendency along the radial and azimuthal direction. \cref{fig:photapex02} shows the result of centroiding and sky estimation.

\begin{figure} [ht!]
\centering
\includegraphics[width=\linewidth]{figs/phot_ap_ex02}
\caption{Left: The test image. Centroid is determined by \cref{eq: centroid} and annulus is defined as $ r_\mathrm{in} = 5 $ and $ r_\mathrm{out} = 10 $ pixels, respectively. Middle: Plotting the sky annulus region only, to just visualize the random fluctuations in the sky region. Clearly, there is no radial trend and it seems quite symmetric along the azimuth. Right: The histogram of the sky pixel values in the annulus. The red/black markers are the median and sample standard deviation of the sky values after and before sigma-clipping, respectively. The sigma clip was done with 3-sigma 50-iterations.}
\label{fig:photapex02}
\end{figure}

Consider we obtained the sky value $ m_\mathrm{sky} $ somehow, e.g., median of sky, \cref{eq: mmm sex} after sigma-clipping, etc. There can be many ways to estimate the uncertainties of this $ m_\mathrm{sky} $. Let me call this $ \Delta m_\mathrm{sky} $. The fluctuation of sky value can critically affect the final result of the photometry. But once a robust way to estimate the sky is set and if the target is bright enough, the uncertainty due to the sky value is not so large. Thus, people do not care too much about the accurate pdf of the $ m_\mathrm{sky} $ value. The most widely used way is to use the practical CLT (Thm \ref{thm: practical clt}) to $ m_\mathrm{sky} $, treating as if it is the mean of the sky samples (although we almost never use the mean for $ m_\mathrm{sky} $). Then
\begin{equation}\label{eq: err m_sky}
  \Delta m_\mathrm{sky} = \frac{s_\mathrm{sky}}{\sqrt{n_\mathrm{sky}}} ~.
\end{equation}
Here, $ s_\mathrm{sky} $ and $ n_\mathrm{sky} $ are the sample standard deviation and the number of the sky pixels survived after the sigma-clipping, respectively. So we are assuming here that the mode has similar uncertainty as the mean.

\subsection{Source Extractor Sky}
We will not cover Source Extractor (SE or SEx or SExtractor) deeply. But simply put, it works like the description below. Say we have the image of 1000 by 1000 pixel.

\begin{enumerate}
\item \textbf{Meshing}: Chop the image by given box size. For example, if you set the box size as $ (50, 25) $, 20 by 40 (in total 800) ``pads'' or ``meshes'' will be made. Each pad will of course have 50 by 25 (in total 1250) pixels.
\item \textbf{Filtering}: Determine the size of the median filter. If the size is $ (3, 3) $, for instance, a 3 by 3 median filter will be used to reduce sharp noised pixels in each pad (similar to Gaussian convolution). The filter size should be determined as a function of seeing disc size.
\item \textbf{Rejecting Meshes}: In this median-filtered pad, the sigma-clipping is done. If too many pixels inside a pad is rejected, that pad is rejected for the next background estimation step. Such a threshold, say exclusion percentile, must be given by the user. For example, if that percentile is 10 \%, any of the 800 mesh which rejected more than 10 \% of its pixels from sigma-clipping (10 \% out of 1250 pixels, i.e., 125 pixels) will be regarded as ``bad region'' for the sky estimation.
\item \textbf{Sky at each Mesh} (bottom middle panel of \cref{fig:sexbkg01}): Now come back to the original un-filtered meshes. From the pixel values, estimate the sky value and its uncertainty following \cref{eq: mmm sex} and the description below the equation. For the meshes which are flagged as ``bad'' from previous step are not used for this process. As a result, you will have 20 by 40 array of sky values, while some elements may be empty or NaN, if some meshes are flagged ad ``bad''.
\item \textbf{Interpolation} (top middle panel of \cref{fig:sexbkg01}): From the estimated single sky value at each mesh, i.e., the 20 by 40 array, we do interpolation to estimate the sky at all the 1000 by 1000 pixels. The estimation uncertainties should also be calculated for each pixel.
\end{enumerate}

\begin{figure}[ht!]
\centering
\includegraphics[width=\linewidth]{figs/sex_bkg_01}
\caption{Example of the SExtractor background estimation usage. The original data is the targeto-centric combined image from 13 KMTNet images from SAAO observatory. The pixels with value 1154.1, which is the $ \mathrm{med} + 3\mathrm{std} $ after the sigma-clipping (3-sigma, 5-iter clipping) are masked because those can be stars (bottom left). The background meshes with the estimated sky values (\cref{eq: mmm sex}) are shown in bottom center, and the interpolated one is given in top middle. Note that the sky level changes at maximum around 12 ADU out of the pixel value 1000+. Normally this should be smaller like 5 ADU or 2 ADU within this small region (200 by 200 pixel). The background sigma shown in bottom right is around 4 ADU (note the figure is 10 times the sigma), but many times the sky sigma is smaller than this.}
\label{fig:sexbkg01}
\end{figure}

After the sky subtraction, I plotted the Box plot of the image with x-axis 70 to 90 and y-axis 50 to 150 (python indexing) in \cref{fig:sexbkg02skyhist}.

\begin{figure}[ht!]
\centering
\includegraphics[width=\linewidth]{figs/sex_bkg_02_skyhist}
\caption{The Box plot and pixel value histogram of before/after the sky subtraction, of a region defined by \texttt{data[50:150, 70:90]} (python indexing). The horizontal axes of Box plots correspond to the ``row'' or the y index. Blue horizontal lines are the median of all the pixels in that region, and red solid lines are the medians }
\label{fig:sexbkg02skyhist}
\end{figure}

As can be noticed, SEx background estimation\footnote{We tend to call ``background'' rather than ``sky'' when we are dealing with SExtractor.}, unlike the annulus sky estimation technique, is estimating the sky values at all the pixels, not for each source. Thus, it takes much longer time. Also you can see that lots of parameters (rejection percentile, box size, filter size, interpolation method and related parameters, etc) should be set for SEx to work! In some cases, astronomers run SExtractor again and again to do get expected results, and find best combination of such parameters. But these parameters of course depend on the instruments, sky conditions, etc, so if the results are suspicious, some fine tuning must be made or you have to find different ways to do photometry than SExtractor.

\section{Aperture Shape in Real Reduction}
We most frequently use circular aperture photometry. To determine how large the aperture should be, we need information about the radial profile of the PSF. Historically, there are three important radial profiles: Gaussian, Moffat, and Penny:
\begin{enumerate}
\item \href{https://en.wikipedia.org/wiki/Gaussian_function}{Gaussian}. The Gaussian function.
\item \href{https://en.wikipedia.org/wiki/Moffat_distribution}{Moffat}. A purely empirical function.
\item Penny. A purely empirical function.
\end{enumerate}
(links to Wikipedia)

Among parameters for PSFs, one that is very widely used in astronomy is the FWHM (full width at half-maximum), as described before. FWHM is defined as the distance between the two points which have the value $\frac{1}{2} f_\mathrm{max}$, i.e., $ f(r = \mathrm{HWHM}) = \frac{1}{2} f_\mathrm{max} $ for $ \mathrm{HWHM} = \mathrm{FWHM}/2 $. FWHM is also used for Lorenzian profile, which has infinite standard deviation (the second centered moment diverges, so the standard deviation is not defined, but FWHM can). The profiles of PSFs and their FWHMs are described below.

In the descriptions below, I will assume the center $ \textbf{r}_0 $ is clearly fixed and the PSF is azimuthally symmetric (circular) and thus $ r = \abs{\textbf{r} - \textbf{r}_0} $ is the only free parameter except for other parameters described in the model.

\subsection{Gaussian}
The circular, i.e., azimuthally symmetric Gaussian PSF is like this:
\begin{equation}\label{eq: profile gauss}
  f_\mathrm{Gauss}(r|A, \sigma) = A e^{ -r^2 / 2\sigma^2 }
\end{equation}
Here, $r$ is the distance from the center ($r_0$), and $\sigma$ is the standard deviation of the profile. This is the most famous form when it comes to numerical calculation, because all the normalization constants are not so important in PSF fitting.

The normalization constant $A = \qty( \frac{1}{\sqrt{2 \pi \sigma^2}} )^N$ for an $ N $-D Gaussian, such that the integration is normalized, i.e., $ \int_{-\infty}^{+\infty} f_\mathrm{Gauss}(r) 2\pi r dr = 1$. The 2-D Gaussian of integrated flux $ I $ is, therefore,
\begin{equation}\label{eq: profile gauss flux}
  f_\mathrm{Gauss}(r|I, \sigma) = \frac{I}{2 \pi \sigma^2} e^{ -r^2 / 2\sigma^2 }
\end{equation}
This is useful because the total integrated flux is an input parameter. Conversion between this and \cref{eq: profile gauss} is very easy.

The FWHM is calculated by setting $f_{\rm Gauss}(r = \mathrm{HWHM}) = \frac{A}{2}$. First we obtain $ (\mathrm{HWHM})^2 = (2 \ln 2) \sigma^2 $ and thus,
\begin{equation}\label{eq: FWHM gauss}
  \mathrm{FWHM (circ Gauss)} := 2 \sqrt{2 \ln 2} \sigma ~.
\end{equation}

Re-formulating \cref{eq: profile gauss flux} with FWHM ($ F $ for brevity):
\begin{equation}\label{eq: profile gauss fwhm}
  f_{\rm Gauss}(r|I, F) = I \frac{4\ln 2}{\pi F^2} e^{ - (4 \ln 2) r^2 / F^2 } ~.
\end{equation}
This is not widely used, although both $ I $ and $ F $ are what we're most interested in. Rather, people tend to convert $ F $ to $ \sigma $ and use \cref{eq: profile gauss} or \cref{eq: profile gauss flux}.

\subsection{Moffat}
The first suggestion of using Moffat profile was made in 1969 by A. F. J. Moffat in \href{https://ui.adsabs.harvard.edu/abs/1969A\%26A.....3..455M}{Moffat AFJ 1969, A\&A, 3, 455}. It is purely an empirical function, and is one of the most widely accepted form, because of its simple form yet powerful in fitting many circular profiles. Comparison of notations is given in \cref{tab: Moffat}.

\begin{table}
\label{tab: Moffat}
\caption{Moffat profile comparison. \texttt{astropy}'s notation is strikingly confusing, because of its \texttt{alpha} notation, which completely goes against the original Moffat paper and other software implementations (e.g., IRAF). Note: \texttt{AsPyLib} is developed by J. Caron in Python 2 and the development is halted since 2013.}
\centering
\begin{tabular}{cccl}
  \hline
  Symbol &
  \href{http://docs.astropy.org/en/stable/api/astropy.modeling.functional_models.Moffat2D.html\#astropy.modeling.functional_models.Moffat2D}{astropy} &
  \href{https://iraf.net/irafhelp.php?val=psfmeasure&help=Help+Page}{IRAF}, \href{http://www.aspylib.com/doc/aspylib_fitting.html}{AsPyLib} &
  Description \\
  \hline
  $ r $ & & & radial distance from the center ($ r_0 = (x_0, y_0) $) \\
  $ R $ & \texttt{gamma} & \texttt{alpha} & core width \\
  $ \beta $& \texttt{alpha} & \texttt{beta} & power \\
  \hline
\end{tabular}
\end{table}

The circular, i.e., azimuthally symmetric Moffat PSF is:
\begin{equation}\label{eq: profile moffat}
  f_\mathrm{Moffat} (r|A, R, \beta) = A \left [ 1 + \left ( \frac{r}{R} \right )^2 \right ]^{-\beta} ~.
\end{equation}
The parameter $R$ is called the core width and $\beta$ is called the power. As in Gaussian case, this is the most widely used form in numerical calculation.

Normalizing as we did for Gaussian, $ \int_{-\infty}^{+\infty} f_\mathrm{Moffat}(r) 2\pi r dr = 1 $, we have the constant $ A = \frac{\beta - 1}{\pi R^2} $. Therefore, Moffat profile has a restriction that $ \beta > 1 $. The Moffat profile for the integrated flux $ I $ is, similar to Gaussian,
\begin{equation}\label{eq: profile moffat flux}
  f_\mathrm{Moffat}(r|I, R, \beta) = I \frac{\beta - 1}{\pi R^2} \left [ 1 + \left ( \frac{r}{R} \right )^2 \right ]^{-\beta}
\end{equation}
Similar to Gaussian, this is also widely used.

The FWHM is calculated by setting $f_\mathrm{Moffat}(\mathrm{HWHM}) = \frac{A}{2}$. As we did in Gauss example, we obtain $ \mathrm{HWHM}^2 = R^2 (2^{1/\beta}-1) $,
\begin{equation}\label{eq: FWHM moffat}
  \mathrm{FWHM}(\mathrm{circMoffat}) = 2 R \sqrt{2^{1/\beta}-1} ~.
\end{equation}

Using FWHM ($ F $ for brevity), we re-formulate Moffat profile \cref{eq: profile moffat flux}\footnote{\href{https://ui.adsabs.harvard.edu/abs/2001MNRAS.328..977T/abstract}{Trujillo+2001, MNRAS, 328, 977}}:
\begin{equation}\label{eq: profile moffat fwhm}
  f_\mathrm{Moffat}(r|I, F, \beta)
    = I \frac{4(2^{1/\beta} - 1) (\beta - 1)}{\pi F^2}
      \left [ 1 + 4(2^{1/\beta} - 1) \left ( \frac{r}{F} \right )^2 \right ]^{-\beta} ~.
\end{equation}

\begin{thm}[High power Moffat is Gaussian]
For $ \beta \rightarrow \infty $,
\begin{equation}
  f_{\rm Moffat} (r|I, F, \infty) = f_{\rm Gauss}(r|I, F) ~.
\end{equation}
Practically $ \beta \gtrsim 100 $ is enough for this approximation.
\end{thm}
\begin{proof}[of Thm]
For $ \beta \rightarrow \infty $, we approximate $ 2^{1/\beta} - 1 \approx \frac{\ln 2}{\beta} $, so
\begin{equation*}
  f_\mathrm{Moffat}(r|I, F, \infty)
    \approx I \frac{\tilde{A}}{\pi}
      \lim_{\beta \rightarrow \infty} \frac{\beta-1}{\beta}
      \left [ 1 + \frac{\tilde{A} r^2}{\beta} \right ]^{-\beta} ~,
\end{equation*}
for $ \tilde{A} = \frac{4 \ln 2}{F^2} $. Note that $ \lim_{\beta \rightarrow \infty} \left [ 1 + \frac{\tilde{A}}{\beta} \right ]^{-\beta} \equiv e^{-\tilde{A}} $ and $ \frac{\beta-1}{\beta} $ becomes unity. Substituting these, we get the approximated formula identical to \cref{eq: profile gauss fwhm}, or to \cref{eq: profile gauss} with \cref{eq: FWHM gauss}. Q.E.D.
\end{proof}

Also, if you look at the pdf of the Students' $ t $-distribution, Moffat is a special case of the $ t $-distribution, but with a simpler re-parameterization (original $ t $-distribution has a clear mathematical reason why it appeared, but it has normalization constants including the Gamma functions, etc, so computationally a bit more complicated).

\subsection{Penny}
It was Franz\footnote{ \href {https://ui.adsabs.harvard.edu/abs/1973JRASC..67...81F/abstract} {FranzOG 1973, JRASC, 67, 81}}, who first used Lorenzian-like profile for stars. Then Penny\footnote{ \href {https://ui.adsabs.harvard.edu/abs/1979MNRAS.187..829P/abstract} {PennyAJ 1979, MNRAS, 187, 829}} used it with linear interpolation in sky level to do the UBV photometry for visual binaries close to each other. After that, Penny and Dickens\footnote{ \href {https://ui.adsabs.harvard.edu/abs/1986MNRAS.220..845P/abstract} {PennyAJ \& DickensRJ, 1986, MNRAS, 220, 845}, which is cited for more than 110 times as of Oct 2019}, using their own package (\texttt{STARMAN}), introduced Gaussian and Lorentzian mixed model\footnote{Unfortunately, however, both the original Penny \& Dickens paper and \href{https://ui.adsabs.harvard.edu/abs/1995StaUN.141.....P/abstract}{Penny (1995, StaUN 141)} pp.44--45 have so many typos in the star profile formulae...}.

The original profile suggested by Penny is a sum of a circular Gaussian and elliptical modified-Lorentzian:
\begin{equation}\label{eq: profile penny}
  \begin{aligned}
    f(r &| A, Q, \sigma_1, \sigma_2, \sigma_3, \sigma_4, P, \theta, P_Q, R_Q)  \\
    &= A
      \left \{
        \frac{1}
        {1 + \left[
          \left( \frac{x'}{\sigma_1} \right)^2
          + \left( \frac{y'}{\sigma_2} \right)^2
          \right ]
          ^{\frac{P}{2}
            \left( 1 + \sqrt{\left( \frac{x'}{\sigma_3} \right)^2
              + \left( \frac{y'}{\sigma_4} \right)^2 } \right)
           }}
        + Q \exp \left [ - \left ( \frac{r}{R_Q} \right )^{P_Q} \right ]
      \right \}
  \end{aligned} ~,
\end{equation}
for
\begin{equation*}
  \binom{x'}{y'} = \binom{x_0}{y_0}
  + \mqty(\cos \theta & \sin \theta \\ -\cos \theta & \sin \theta) \binom{x}{y}
\end{equation*}
where $ \textbf{r}_0 = (x_0, y_0) $ is the center, and $ \theta $ is the tilting angle of the Lorentzian. The notation $ \sigma_{1,2,3,4} $ are $ R_\mathrm{maj} $ (\texttt{RX}), $ R_\mathrm{min} $ (\texttt{RY}), $ RP_\mathrm{maj} $ (\texttt{PRX}), and $ RP_\mathrm{min} $ (\texttt{PRY}) in the \texttt{POORMAN}'s notations. It is no more widely used, because of the large number of free parameters.

In IRAF, it is implemented\footnote{The source code is at \href {https://github.com/iraf-community/iraf/blob/master/noao/digiphot/daophot/daolib/profile.x} {\texttt{noao.digiphot.daophot.dailib.profile.x}}.} in two ways: \texttt{penny1} and \texttt{penny2}.

\footnote{Although there is no reference, ``Photometry using IRAF v. 2.5.1'' (2012-03-25) by Keunhong Park, Jinhyuk Ryu, Insung Jang, and Ho Seong Hwang notes that (p. 8): ``\texttt{penny1} or \texttt{penny2} of IRAF fits the analytical stellar profiles well, while \texttt{moffat15} or \texttt{moffat25} fits the stellar profiles well if observed on cloudy nights.'' I cannot even understand the meaning of it...}

Simple way of using it is, assuming $ Q = 0 $, $ P = 2 $, and $ \sigma_3, \sigma_4 \rightarrow \infty $, so that
\begin{equation}\label{eq: profile penny12}
  f(r|A, \theta, \sigma_1, \sigma_2,
\end{equation}

\subsection{IRAF}
Here I describe how IRAF does centroiding in its \href{https://iraf.net/irafhelp.php?val=imexam&help=Help+Page}{IRAF \texttt{imexamine} task}. It is crude but always works decently, so I thought it's a good idea to summarize it for benchmark purpose\footnote{The description below is the description of IRAF \texttt{imexamine} when you hit \texttt{a} key on IRAF. Since \texttt{imexamine} is not only for the 2-D analysis, it consists of parameters for the 1-D extraction (when you hit \texttt{j} or \texttt{k}), for instance. You may want to fit a Gaussian to the pixels along a vertical line (i.e., $ N \times 1 $ array). For those purposes, \texttt{imexamine} has more parameters like \texttt{sigma}, etc. Please don't be confused when you read the doc.
}.

First, set $ r $, the circular aperture radius (default \texttt{radius=5}). Then the sky level is determined from an annulus with the inner radius \texttt{radius+buffer} (default \texttt{buffer=5}) and the outer radius \texttt{radius+buffer+width} (default \texttt{width=5}), centered at the initial center position. By default (\texttt{xorder=0}, \texttt{yorder=0}), the sky value is set as the median value in this annulus. If both of \texttt{xorder} and \texttt{yorder} are larger than 0, then the 2-D polynomial of these orders is fitted to the pixel values from the annulus. Mathematically speaking, \texttt{xorder=yorder=1} means a constant value (the weighted average value).

Then the centering is done by fitting 1-D Gaussian or Moffat to the marginalized pixel values (default is Moffat by \texttt{fittype="moffat"}), for the square box with $ \mathrm{width} = \mathrm{height} = 2r $.  In pythonic way, you are fitting 1-D profile to \pyth{np.sum(data, axis=0)} and \pyth{np.sum(data, axis=1)} to get the y and x centers, respectively. The pixels below the average value in this box are masked in the centering process\footnote{Not clear from the doc: How are the weighting scheme applied in this 1-D profile fittings? As in the 2-D profile fit? Or no error-bars?}.

It is repeated for certain times (default \texttt{iterations=3}), until the updated center position resides in the same pixel as the previous step\footnote{Not clear from the doc: I worried what if the center position is at the edge of the pixel. I guess, maybe, even though the center position is updated from the right edge of the $ i $-th to the left edge of the $ (i+1) $-th pixel, the centering box will remain the same in the upcoming iterations, so the centering process will be halted (converged) at the left edge of the $ (i+1) $-th pixel.}. In every iteration, the aperture radius $ r $ is updated to $ 3\, \mathrm{FWHM} $ using the FWHM obtained from the last iteration (from this definition, $ r $ remains as the initial value if \texttt{iterations=1}). Any pixel outside the image will be assumed to have a constant value (default \texttt{constant=0}).

The weighting for each pixel is calculated by
\begin{equation}\label{eq: imexam weighting}
  w (r_{\texttt{i,j}}) = \left \{
  \begin{array}{cr}
    r_\mathtt{i,j}^{-2} & r_\mathtt{i,j} \le \mathrm{FWHM}/2 \\
    e^{-\left ( \frac{r_\mathtt{i,j}}{\mathrm{FWHM}/2} - 1 \right )^2} & r_\mathtt{i,j} > \mathrm{FWHM}/2
  \end{array}
  \right . ~,
\end{equation}
where $ \mathrm{FWHM}/2 $ is also called $ \mathrm{HWHM} $ or $ r_\mathrm{half} $ and $ r_\mathtt{i,j} $ is the distance in pixel unit to the \texttt{(i, j)}-th pixel from the center\footnote{Not clear from the doc: Center of the last iteration?}. This weighting scheme is different from usual least square statistic (which uses $ w = 1/\sigma^2 $).

Once this fitting is done, put a circular aperture with radius $ r $. Because the purpose of \texttt{imexamine} is not an accurate photometry, it crudely estimates the flux by summing the pixel values for pixels which has its center within the aperture (same as putting \pyth{method="center"} to photutils aperture).

Two more parameters are calculated, namely, ellipticity $ e $ and angle $ \mathrm{pa} $:
\begin{equation}
  e = \sqrt{\frac{ (M_{xx} - M_{yy})^2 + 4 M_{xy}^2}{M_{xx} + M_{yy}}}
  \quad;\quad
  \mathrm{pa}
    = \frac{1}{2} \atan(\frac{2 M_{xy}}{M_{xx} - M_{yy}}) ~,
\end{equation}
where the moments
\begin{equation}
  M_\mathtt{ij} = \frac{\sum I \times i \times j}{\sum I}
\end{equation}
for pixel value $ I $ and $ i, j \in [x, y] $.

In realistic photometry, such as \href{https://iraf.net/irafhelp.php?val=psfmeasure&help=Help+Page}{IRAF \texttt{psfmeasure} task}, we must use $ I - \mathrm{sky} $ instead of $ I $.

Some old packages including \texttt{ROMAFOT}, \texttt{STARMAN}, \texttt{DAOPHOT}, \texttt{DoPHOT}, \texttt{WOLF}, \texttt{LUND}, \texttt{CAPELLA} are summarized in \href{http://web.ipac.caltech.edu/staff/fmasci/home/astro_refs/WhyPSFfit.pdf}{this lecture note} and \href{https://ui.adsabs.harvard.edu/abs/1992ASPC...25..297S/abstract}{StetsonPB 1992, ASPC, 25, 297}

\subsubsection*{Note}
The shape of circular apetures were briefly discussed. In reality, you may encounter apertures of ellipse, box, pill-box, or any other scientifically meaningful ones. Now what you have to understand more is the aperture \emph{size}.

\section{Aperture Size in Real Reduction}
We will stick to the circular apertures here, too. Any other compilcated apertures may have to be used depending on the scientific reasons. Here I will describe three \emph{ideas} of finding the aperture size. When you have to apply aperture size in professional research, these should not be used blindly, but you have to find your own way which is both mathematically robust and scientifically meaningful for your specific purpose.

\subsection{Maximum SNR (not recommeneded)}
The singal-to-noise ratio is a

\subsection{Growth Curve (mathematically robust)}
Stetson 1988 PASP


\documentclass[11pt]{article}
\usepackage{fullpage}

\title{Your title}
\author{Your name}

\begin{document}

\maketitle

\section{Basic LaTex}

The basic things you need to know are math mode.  Inline math mode is given by dollar
signs, e.g., let $a(n) = \sum_{n=1}^r f(r)$.  And set off equations are given by
\[ x^2 + Dy^2 = n \]
(unnumbered)
or
\begin{equation}
  \alpha \bar \alpha = (1+\sqrt{-5})(1-\sqrt{-5}) = 2 \cdot 3 = 6
\end{equation}
(numbered).

Can reference bibliography with cite.  E.g., In \cite{Hej}, it was shown that \dots.
Typically, you have to typset twice to get the reference references correct.

You can also make subsections

\subsection{Subsection}

and do {\bf bold} and {\em italics}.

\medskip
\noindent
There are many latex references on the web, so you should have no trouble finding other
things you need to know.  If you have trouble, ask me.

\section*{References}

\begin{enumerate}

\bibitem[H]{Hej} Hejhal, Dennis A. The Selberg trace formula for ${\rm PSL}(2,R)$. Vol. I. Lecture Notes in Mathematics, Vol. 548. {\em Springer-Verlag, Berlin-New York,} 1976.

\end{enumerate}

\end{document}

Xyrus/Olympiad Articles/Number Theory/Kimball Martin/NT 1 (Intro to NT)/Class Paper template.tex