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

\begin{document}
\appendix
\section{Total energy}\label{sec:energy_special}
When two spins have the orientation up, the total magnetization is zero. However, 
the total energy of the system have two possible values, due to the location of 
the spin up as visualized in Figure \ref{fig:tikz_neighbor}.
\begin{figure}
    \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.}
    \label{fig:tikz_neighbor}
\end{figure}


\section{Partition function}\label{sec:partition_function}
Using the values estimated for the $2 \times 2$ case, found in \ref{tab:lattice_config}, 
we find the partition function
\begin{align*}
	Z &= 1 \cdot e^{-\beta (-8J)} + 4 \cdot e^{-\beta (0)} + 4 \cdot e^{-\beta (0)} \\
    & \quad + 2 \cdot e^{-\beta (8J)} + 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 the identity 
\begin{align*}
    \cosh(8 \beta J) &= 1/2 \big( e^{8 \beta J} + e^{-8 \beta J})
\end{align*}
and find 
\begin{align*}
    z &= 4 \cosh (8 \beta J) + 12 \ .
\end{align*}


\section{Expectation values}\label{sec:expectation_values}
For a linear function of a stochastic random variable $X$, with a known probability 
distribution, the expected value of $x$ is given by
\begin{align*}
    \langle aX + b \rangle &= a \cdot \langle X \rangle + 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})$.

Both energy per spin and magnetization per spin are functions of $\mathbf{s}$. 
In addition, the number of spins is given as a constant for each lattice. We can 
use the expression for $\langle E \rangle$ and $\langle M \rangle$ to 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 to 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 result in 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} \\
    & \quad + (-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 energy 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} \\
    & \quad + (-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*}


\section{Heat capacity and magnetic susceptibility}\label{sec:heat_susceptibility}
To find the heat capacity in Eq. \ref{eq:heat_capacity}, we normalize to heat 
capacity per spin
\begin{align*}
    \frac{C_{V}}{N} &= \frac{1}{N} \frac{1}{k_{B} T^{2}} (\mathbb{E}(E^{2}) - [\mathbb{E}(E)]^{2}) \\
    &= \frac{1}{N k_{B} T^{2}} \mathbb{V}(E) \ .
\end{align*}
Using Eq. \eqref{eq:susceptibility}, we find he susceptibility per spin
\begin{align*}
    \frac{\chi}{N} &= \frac{1}{N} \frac{1}{k_{B} T} (\mathbb{E}(M^{2}) - [\mathbb{E}(M)]^{2}) \\
    &= \frac{1}{N k_{B} T} \mathbb{V}(M) \ .
\end{align*}
We now have to find 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 the total energy is then 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*}
and the variance of the total magnetization is given by
\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})}{(\cosh(8 \beta J) + 3)^{2}} \\
    & \quad + \frac{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*}
We find the heat capacity 
\begin{align*}
    \frac{C_{V}}{N} &= \frac{64J^{2} }{N k_{B} T^{2}} \bigg( \frac{3\cosh(8 \beta J) + 1}{(\cosh(8 \beta J) + 3)^{2}} \bigg) \ ,
\end{align*}
and susceptibility
\begin{align*}
    \frac{\chi}{N} &= \frac{4}{N k_{B} T} \bigg( \frac{3e^{8 \beta J} + e^{-8 \beta J} + 3}{(\cosh(8 \beta J) + 3)^{2}} \bigg) \ .
\end{align*}


\section{Change in total system energy}\label{sec:delta_energy}
When we consider the change in energy after flipping a single spin, we evaluate 
$\Delta E = E_{\text{after}} - E_{\text{before}}$. We find the $3^{2}$ values as
\begin{align*}
    \Delta E = -8J - (-8J) = 0 \\
    \Delta E = -8J - 0 = -8J \\
    \Delta E = -8J - 8J = -16J \\
    \Delta E = 0 - (-8J) = 8J \\
    \Delta E = 0 - 0 = 0 \\
    \Delta E = 0 - 8J = -8J \\
    \Delta E = 8J - (-8J) = 16J \\
    \Delta E = 8J - 0 = 8J \\
    \Delta E = 8J - 8J = 0,
\end{align*}
where the five distinct values are $\Delta E = \{-16J, -8J, 0, 8J, 16J\}$.


\section{Additional results}\label{sec:additional_results}
We also did the phase transition experiment using 1 million MC cycles. In Figure \ref{fig:phase_energy_1M} 
we show expected energy per spin, and in Figure \ref{fig:phase_magnetization_1M} 
expected magnetization per spin.
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/phase_transition/fox/wide/10M/energy.pdf}
    \caption{$\langle \epsilon \rangle$ for $T \in [2.1, 2.4]$, $10^{6}$ MC cycles.}
    \label{fig:phase_energy_1M}
\end{figure} %
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/phase_transition/fox/wide/10M/magnetization.pdf}
    \caption{$\langle |m| \rangle$ for $T \in [2.1, 2.4]$, $10^{6}$ MC cycles.}
    \label{fig:phase_magnetization_1M}
\end{figure} %
In Figure \ref{fig:phase_heat_1M} we show heat capacity, and in Figure \ref{fig:phase_susceptibility_1M} 
the magnetic susceptibility.
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/phase_transition/fox/wide/10M/heat_capacity.pdf}
    \caption{$C_{V}$ for $T \in [2.1, 2.4]$, $10^{6}$ MC cycles.}
    \label{fig:phase_heat_1M}
\end{figure} %
\begin{figure}[H]
    \centering
    \includegraphics[width=\linewidth]{../images/phase_transition/fox/wide/10M/susceptibility.pdf}
    \caption{$\chi$ for $T \in [2.1, 2.4]$, $10^{6}$ MC cycles.}
    \label{fig:phase_susceptibility_1M}
\end{figure}

\end{document}