\documentclass[../ising_model.tex]{subfiles}

\begin{document}
\appendix
\section{Ising model system states}\label{sec:system_states}
Units 
\begin{table}[H]
    \centering
    \begin{tabular}[c]{cc} % @{\extracolsep{\fill}}
        \hline
        Value & Unit \\
        \hline 
        $[ E ]$ & $J$ \\
        $[ T ]$ & $J / k_{\text{B}}$ \\ 
        $[ M ]$ & $\dots$ \\
        $[ C_{\text{V}} ]$ & $k_{\text{B}}$ \\
        $[ \chi ]$ & $1 / J$ \\
        \hline
    \end{tabular}
    \caption{Units, given by the coupling constant $J$ and the Boltzmann constant $k_{\text{B}}$.}
    \label{tab:units}
\end{table}

To avoid counting duplicates, we used 
\begin{figure}\label{fig:tikz_counting}
    \centering
    \begin{tikzpicture}
        \draw (0, 0) grid (2, 2);
        % \node[inner] (s1) at (0.5, 0.5) {s};
        \node (s1) at (0.5, 1.5) {$s_1$};
        \node (s2) at (1.5, 1.5) {$s_2$};
        \node (s3) at (0.5, 0.5) {$s_3$};
        \node (s4) at (1.5, 0.5) {$s_4$};
        \node[gray] (s12) at (2.5, 1.5) {$s_1$};
        \node[gray] (s34) at (2.5, 0.5) {$s_3$};
        \node[gray] (s13) at (0.5, -0.5) {$s_1$};
        \node[gray] (s24) at (1.5, -0.5) {$s_2$};
    
        \draw[red, ->] (s1.east) -- (s2.west);
        \draw[red, ->] (s2.east) -- (s12.west);
        \draw[red, ->] (s1.south) -- (s3.north);
        \draw[red, ->] (s2.south) -- (s4.north);
        \draw[red, ->] (s3.east) -- (s4.west);
        \draw[red, ->] (s4.east) -- (s34.west);
        \draw[red, ->] (s3.south) -- (s13.north);
        \draw[red, ->] (s4.south) -- (s24.north);
      \end{tikzpicture}
      \caption{Rules for multiplying spin pairs.}
\end{figure}

\begin{figure}\label{fig:tikz_neighbor}
    \centering
    \begin{subfigure}{0.4\linewidth}
        \begin{tikzpicture}
            \draw (0, 0) grid (2, 2);
            \node (s1) at (0.5, 1.5) {$\uparrow$};
            \node (s2) at (1.5, 1.5) {$\uparrow$};
            \node (s3) at (0.5, 0.5) {$\downarrow$};
            \node (s4) at (1.5, 0.5) {$\downarrow$};
        \end{tikzpicture}
        \caption{}
        \label{fig:sub_tikz_neighbor_a}
    \end{subfigure}
    \
    \begin{subfigure}{0.4\linewidth}
        \begin{tikzpicture}
            \draw (0, 0) grid (2, 2);
            \node (s1) at (0.5, 1.5) {$\uparrow$};
            \node (s2) at (1.5, 1.5) {$\downarrow$};
            \node (s3) at (0.5, 0.5) {$\downarrow$};
            \node (s4) at (1.5, 0.5) {$\uparrow$};
        \end{tikzpicture}
        \caption{}
        \label{fig:sub_tikz_neighbor_b}
    \end{subfigure}
    \caption{Possible spin configurations for two spins up.}
\end{figure}


\section{Analytical expressions}\label{sec:analytical_expressions}
The Boltzmann distribution is normalized using a partition function $Z$, given by
\begin{equation}\label{eq:partition}
    Z = \sum_{\text{all possible } \mathbf{s}}^{N}
\end{equation}
We use the values estimated for the $2 \times 2$ case, found in \ref{tab:lattice_config}, 
and find the partition function
\begin{align*}
	Z &= 1 \cdot e^{-\beta (-8J)} + 4 \cdot e^{-\beta (0)} + 4 \cdot e^{-\beta (0)} + 2 \cdot e^{-\beta (8J)} \\
    & \quad + 4 \cdot e^{-\beta (0)} 1 \cdot e^{-\beta (-8J)} \\
    &= 2e^{8 \beta J} + 2e^{-8 \beta J} + 12.
\end{align*}
We rewrite the expression using $\cosh(8 \beta J) = 1/2 \big( e^{8 \beta J} + e^{-8 \beta J})$, and get
\begin{align*}
    z &= 4 \cosh (8 \beta J) + 12 
\end{align*}
The Boltzmann distribution is given by 
\begin{equation}\label{eq:boltzmann}
    p(\mathbf{s} \ | \ T) = \frac{1}{Z} e^{-\beta E(\mathbf{s})},
\end{equation}
for a given temperature $T$. With our expression for the partition function, we 
get the probability distribution
\begin{align*}
    p(\mathbf{s} \ | \ T) &= \frac{1}{4 \cosh (8 \beta J) + 12} e^{-\beta E(\mathbf{s})}
\end{align*}

For discrete random variables $X$, with a known probability distribution, the 
expected value of $x$ is given by 
\begin{align*}
    \mathbb{E}(x) &= \sum_{x \in D} x \cdot p(x) & \text{\cite[p. 127]{springer:2012:modernstat}}.
\end{align*}
For a function of a stochastic random variable, the expected value of $x$ is
\begin{align*}
    \mathbb{E}(h(X)) &= \sum_{x \in D} h(x) \cdot p(x) 
\end{align*}
And in the case of a linear function we have
\begin{align*}
    \mathbb{E}(aX + b) &= a \cdot \mathbb{E}(X) + b & \text{\cite[p. 131]{springer:2012:modernstat}}
\end{align*}
In our case the discrete random variable is the spin configuration, and we want 
to find the expected value of the function $E(\mathbf{s})$. In addition, we use 
$\langle E \rangle$ as notation for expexted value of a given variable, since $\mathbf{s}$ is the stochastic
random variable.

The expression for total energy and total magnetization is given in eq. \eqref{eq:energy} and \eqref{eq:magnetization}. 
The expected values for these is given by
\begin{equation*}
    \langle E(\mathbf{s}) \rangle = \sum_{i=1}^{N} E(s_{i}) p(s_{i} \ | \ T)
\end{equation*}

\begin{equation*}
    \langle |M(\mathbf{s})| \rangle = \sum_{i=1}^{N} |M(s_{i})| p(s_{i} \ | \ T)
\end{equation*}

Since we want to compare expected values for different lattice sizes, we have to 
find the expected values per spin. We normalize the total expressions for total 
energy \eqref{eq:energy} and magnetizaation \eqref{eq:magnetization} by the 
number of spins to get 
\begin{equation}\label{eq:spin_energy}
    \epsilon(\mathbf{s}) = \frac{E(\mathbf{s})}{N}
\end{equation}

\begin{equation}\label{eq:spin_magnetization}
    m(\mathbf{s}) = \frac{M(\mathbf{s})}{N}
\end{equation}

Both energy per spin and magnetization per spin are functions of $\mathbf{s}$, 
we will use the short hand notation $\langle \epsilon \rangle$ and $\langle |m| \rangle$. 
In addition, the number of spins are given as a constant for each lattice. We can 
rewrite and use this when we find the expectation values per spin, for energy per spin 
\begin{align*}
    \langle \epsilon \rangle &= \sum_{i=1}^{N} \epsilon(s_{i}) p(s_{i} \ | \ T) \\
    &= \sum_{i=1}^{N} \frac{E(\mathbf{s})}{N} p(s_{i} \ | \ T) \\
    &= \frac{1}{N} \sum_{i=1}^{N} E(\mathbf{s}) p(s_{i} \ | \ T)
\end{align*}
The same applies for magnetization per spin
\begin{align*}
    \langle |m| \rangle = \frac{1}{N} \sum_{i=1}^{N} |M(s_{i})| p(s_{i} \ | \ T)
\end{align*}
Continuing with the expectation values for a $2 \times 2$ lattice, excluding the terms which give zero we get
\begin{align*}
    \langle E \rangle &= (-8J) \cdot \frac{1}{Z} e^{8 \beta J} + 2 \cdot (8J) \cdot \frac{1}{Z} e^{-8 \beta J} + (-8J) \cdot \frac{1}{Z} e^{8 \beta J} \\
    &= \frac{16J}{Z} \big(e^{-8 \beta J} - e^{8 \beta J}) \\
    &= -\frac{32J \sinh(8 \beta J)}{4(\cosh(8 \beta J) + 3)} \\
    &= -\frac{8J \sinh(8 \beta J)}{\cosh(8 \beta J) + 3},
\end{align*}
and
\begin{align*}
    \langle |M| \rangle &= 4 \cdot \frac{1}{Z} \cdot e^{8 \beta J} + 4 \cdot 2 \cdot \frac{1}{Z} \cdot e^{0} \\
    & \quad + 4 \cdot | -2| \cdot \frac{1}{Z} \cdot e^{0} + | -4| \cdot e^{8 \beta J} \\
    &= \frac{8 e^{8 \beta J} + 16}{Z} \\
    &= \frac{4 (2e^{8 \beta J} + 4)}{4(\cosh(8 \beta J) + 3)} \\
    &= \frac{2(e^{8 \beta J} + 2)}{\cosh(8 \beta J) + 3}
\end{align*}
The squared function 
\begin{align*}
    \langle E^{2} \rangle &= (-8J)^{2} \cdot \frac{1}{Z} e^{8 \beta J} + 2 \cdot (8J)^{2} \cdot \frac{1}{Z} e^{-8 \beta J} + (-8J)^{2} \cdot \frac{1}{Z} e^{8 \beta J} \\
    &= \frac{128J^{2}}{Z} \big(e^{8 \beta J} + e^{-8 \beta J} \big) \\
    &= \frac{128J^{2} \cosh(8 \beta J)}{4(\cosh(8 \beta J) + 3)} \\
    &= \frac{64J^{2} \cosh(8 \beta J)}{\cosh(8 \beta J) + 3},
\end{align*}
and
\begin{align*}
    \langle M^{2} \rangle &= 4^{2} \cdot \frac{1}{Z} \cdot e^{8 \beta J} + 4 \cdot 2^{2} \cdot \frac{1}{Z} \cdot e^{0} \\
    & \quad + 4 \cdot (-2)^{2} \cdot \frac{1}{Z} \cdot e^{0} + (-4)^{2}\cdot e^{8 \beta J} \\
    &= \frac{32e^{8 \beta J} + 32}{Z} \\
    &= \frac{4 (8e^{8 \beta J} + 8)}{4(\cosh(8 \beta J) + 3)} \\
    &= \frac{8e^{8 \beta J} + 8}{\cosh(8 \beta J) + 3} 
\end{align*}
The squared expectation value is given by 
\begin{align*}
    \langle E \rangle^{2} &= \bigg(-\frac{8J \sinh(8 \beta J)}{\cosh(8 \beta J) + 3} \bigg)^{2} \\
    &= \frac{64J^{2} \sinh^{2}(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}},
\end{align*}
and
\begin{align*}
    \langle |M| \rangle^{2} &= \Big( \frac{2(e^{8 \beta J} + 2)}{\cosh(8 \beta J) + 3} \Big)^{2} \\
    &= \frac{4(e^{8 \beta J} + 2)^{2}}{(\cosh(8 \beta J) + 3)^{2}}
\end{align*}
Calculating the heat capacity and susceptibility, we need the variance of both total 
energy and total magnetizaation. We obtain this using the definition 
\begin{align*}
    \mathbb{V}(X) &= \sum_{x \in D} [(x - \mathbb{E}(x))^2 \cdot p(x)] & \text{\cite[p. 132]{springer:2012:modernstat}}. \\
    &= \mathbb{E}(X^{2}) - [\mathbb{E}(X)]^{2}
\end{align*}
The variance of total energy is given by
\begin{align*}
    \mathbb{V}(E) &= \mathbb{E}(E^{2}) - [\mathbb{E}(E)]^{2} \\
    &= \frac{64J^{2} \cosh(8 \beta J)}{\cosh(8 \beta J) + 3} - \frac{64J^{2} \sinh^{2}(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}} \\
    &= 64J^{2} \bigg( \frac{\cosh(8 \beta J)}{\cosh(8 \beta J) + 3} - \frac{\sinh^{2}(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}} \bigg) \\
    &= 64J^{2} \bigg( \frac{(\cosh(8 \beta J)) \cdot (\cosh(8 \beta J) + 3)}{(\cosh(8 \beta J) + 3)^{2}} \\
    & \quad - \frac{\sinh^{2}(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}} \bigg) \\
    &= 64J^{2} \bigg( \frac{\cosh^{2}(8 \beta J) + 3\cosh(8 \beta J) - \sinh^{2}(8 \beta J)}{(\cosh(8 \beta J) + 3)^{2}} \bigg) \\
    &= 64J^{2} \bigg( \frac{3\cosh(8 \beta J) + 1}{(\cosh(8 \beta J) + 3)^{2}} \bigg)
\end{align*}
\begin{align*}
    \mathbb{V}(M) &= \mathbb{E}(M^{2}) - [\mathbb{E}(|M|)]^{2} \\
    &= \frac{8e^{8 \beta J} + 8}{\cosh(8 \beta J) + 3} - \frac{4(e^{8 \beta J} + 2)^{2}}{(\cosh(8 \beta J) + 3)^{2}} \\
    &= \frac{(8(e^{8 \beta J} + 1)) \cdot (\cosh(8 \beta J) + 3) - 4(e^{8 \beta J} + 2)^{2}}{(\cosh(8 \beta J) + 3)^{2}} \\
    &= \frac{4(e^{8 \beta J} + 1) \cdot (e^{8 \beta J} + e^{-8 \beta J}) + 24(e^{8 \beta J} + 1) - 4(e^{8 \beta J} + 1)^{2}}{(\cosh(8 \beta J) + 3)^{2}} \\
    &= \frac{4e^{2(8 \beta J)} + 4e^{8 \beta J} 4e^{0} + 4e^{-8 \beta J} 24e^{8 \beta J} + 24 - 4e^{2(8 \beta J)} - 16e^{8 \beta J} - 16}{(\cosh(8 \beta J) + 3)^{2}} \\
    &= \frac{4(3e^{8 \beta J} + e^{-8 \beta J} + 3)}{(\cosh(8 \beta J) + 3)^{2}}
\end{align*}

\begin{align*}
    C_{\text{V}} &= \frac{1}{N} \frac{1}{k_{\text{B} T^{2}}} (\mathbb{E}(E^{2}) - [\mathbb{E}(E)]^{2}) \\
    &= \frac{1}{N k_{\text{B} T^{2}}} \mathbb{V}(E) \\
    &= \frac{64J^{2} }{N k_{\text{B}} T^{2}} \bigg( \frac{3\cosh(8 \beta J) + 1}{(\cosh(8 \beta J) + 3)^{2}} \bigg)
\end{align*}

\begin{align*}
    \chi &= \frac{1}{N} \frac{1}{k_{\text{B} T}} (\mathbb{E}(M^{2}) - [\mathbb{E}(M)]^{2}) \\
    &= \frac{1}{N k_{\text{B} T}} \mathbb{V}(M) \\
    &= \frac{4}{N k_{\text{B} T}} \bigg( \frac{3e^{8 \beta J} + e^{-8 \beta J} + 3}{(\cosh(8 \beta J) + 3)^{2}} \bigg)
\end{align*}
\begin{align*}
    \langle \epsilon^{2} \rangle &= \frac{1}{N^{2}} \sum_{i=1}^{N} E(\mathbf{s})^{2} p(s_{i} \ | \ T) \\
    &=
\end{align*}
The same applies for magnetization per spin
\begin{align*}
    \langle |m| \rangle = \frac{1}{N} \sum_{i=1}^{N} |M(s_{i})| p(s_{i} \ | \ T)
\end{align*}
\end{document}