\newcommand{\pKa}{\text{p}K_{\text{a}}}
\newcommand{\pKaX}[1]{\text{p}K_{\text{a}}^{\text{#1}}}

\section{
Constant-pH Simulations
\footnote[1]{
The features described in this section were implemented by Brian K. Radak
  (Argonne National Laboratory, Argonne, IL USA) with considerable technical
  support from James C. Phillips (University of Illinois, Urbana, IL USA) and
  Wei Jiang (Argonne National Laboratory).
The algorithm draws heavily from earlier work by Yunjie Chen and Beno{\^i}t
  Roux and later by Donghyuk Suh (University of Chicago, Chicago, IL USA), as
  well as time spent as a postdoctoral scholar at University of Chicago.
Testing and validation were also aided by Christophe Chipot
  (Universit\'{e} de Lorraine, Vand{\oe}uvre-l\`{e}s-Nancy cedex France and
  University of Illinois).
}
}
\label{section:constantph}

Constant-pH MD in NAMD is based on the scheme first proposed by
  Stern~\cite{Stern_JChemPhys_2007_v126_p164112} and later revised and extended
  by Chen and Roux~\cite{Chen_JChemTheoryComput_2015_v11_p3919}.
A detailed description of the modifications and improvements made in the NAMD
  implementation has been presented elsewhere by Radak,
  \textit{et al.}~\cite{Radak_JChemTheoryComput_2017_v13_p5933} and this is likely the
  best comprehensive description of the method, its uses, and its limitations/pitfalls.
Herein the goal is to provide a working understanding of how the implementation
  works and what kinds of data it produces.

\subsection{Overview and Theoretical Background}

Constant-pH MD is a simulation methodology specially formulated for the
  treatment of variable protonation states.
This is to be contrasted with conventional force-field based MD simulations,
  which generally treat protonation states by assuming they are fixed.
Consider, for example, a protein with two titratable residues which may both be
  either protonated or deprotonated (Figure~\ref{fig:cphStateCycle});
the system has four possible protonation states.
In the conventional route, the user must enumerate these possibilities,
  construct distinct topologies, and then simulate the cases individually.
The simulations for each state must then be connected by either asserting
  knowledge about the system (\textit{e.g.},~by assuming that only certain
  states are of biological importance) or by performing additional simulations
  to probe transitions between states directly (\textit{e.g.},~by performing
  free energy calculations).
In a constant-pH MD simulation, knowledge of the transformations is not
  assumed and is instead actively explored by interconverting between the
  various protonation states.
This is especially useful when the number of protonation states is extremely
  large and/or prior information on the importance of particular states is
  not available.

\begin{figure}[h]\center{
  \includegraphics[width=\textwidth]{figures/namdcph_cycle}
  \caption{\label{fig:cphStateCycle}
    The core difference between conventional and constant-pH MD can be
      illustrated by a simple enzyme $E$ with four protonation states
      describing the occupancy of two titratable residues, $R_1$ and $R_2$.
    A conventional MD simulation handles the states \emph{separately} (left
      panel).
    The relative importance of the states must be known beforehand or computed
      by other means.
    Conversely, a constant-pH MD simulation handles the states
      \emph{collectively} and actively simulates interconversion (right panel).
    Determining the relative importance of the states is a direct result of the
      simulation.
  }
}\end{figure}

In formal terms, conventional MD samples from a canonical ensemble, whereas
  constant-pH MD samples from a semi-grand canonical ensemble.
The new partition function,
\begin{equation}\label{eqn:semigrand}
  \Xi(\text{pH})
  =
  \sum_{\text{$\bm \lambda$} \in \mathcal{S}}
    Q_{\text{$\bm \lambda$}}
    10^{-n_{\text{$\bm \lambda$}} \text{pH}},
\end{equation}
  is essentially a weighted summation of canonical partition functions,
  $Q_{\text{$\bm \lambda$}}$, each of which are defined by an occupancy vector,
  ${\bm \lambda}$.
The elements of ${\bm \lambda}$ are either one or zero depending on whether a
  given protonation site is or is not occupied, respectively.
For a vector of length $m$, the set of all protonation states, $\mathcal{S}$,
  has at most $2^m$ members.
In order to sample from the corresponding semi-grand canonical distribution
  function, a simulation must explore \emph{both} the phase space defined by
  the canonical paritition functions and the state space defined by the
  different occupancy vectors.
The fraction of simulation time spent in each state is dictated by the weights
  in the summation and these depend on the pH and the number of protons,
  $n_{\text{$\bm \lambda$}}$, in the system (\textit{i.e.},~the sum of the
  elements in ${\bm \lambda}$).

Although a constant-pH MD system may contain any number of titratable protons,
  the base transformation is always the movement of \emph{one} proton from a
  molecule into a bath of non-interacting protons ``in solution.''
For a generic chemical species A, this corresponds to the usual deprotonation
  reaction definition, except with fixed pH:
\begin{equation*}
 \mathrm{
  HA
  \underset{\text{pH fixed}}{\stackrel{-H^{+}}{\rightleftharpoons}}
  A^{-}
 }.
\end{equation*}
In the language of statistical mechanics the species HA and A$^{-}$ refer to
  all terms in Eq.~\eqref{eqn:semigrand} which do and do not, respectively,
  contain the specific proton in question (\textit{i.e.},~the particular
  element of ${\bm \lambda}$ is one or zero).
By taking out a factor of $10^{-\text{pH}}$, this can be re-written as
\begin{equation*}
  \Xi(\text{pH})
  =
  \Xi_{\text{A}^{-}}(\text{pH})
  +
  \Xi_{\text{HA}}(\text{pH}) 10^{-\text{pH}}
\end{equation*}
  and then recast as a statistical mechanical analog of the
  Henderson-Hasselbalch equation by recognizing that
  $\Xi_{\text{A}^{-}}(\text{pH}) / \Xi_{\text{HA}}(\text{pH})$ is just the
  ratio of deprotonated / protonated fractions of species A.
The \emph{protonated} fraction is then
\begin{equation}\label{eqn:HH}
  P_{\text{HA}}(\text{pH})
  =
  \frac{1}{1 + 10^{\text{pH} - \pKa(\text{pH})}};
  \qquad
  \pKa(\text{pH})
  \equiv
  -\log{
    \frac{
      \Xi_{\text{A}^{-}}(\text{pH})
    }{
      \Xi_{\text{HA}}(\text{pH})
    }
  }.
\end{equation}
In practice, $P_{\text{HA}}(\text{pH})$ can be calculated from a simulation by
  simply counting the fraction of time spent in state HA (\textit{e.g.},~the
  fraction of time a specific element of ${\bm \lambda}$ is one).
Note also that $\pKa(\text{pH})$ is formally a pH dependent function
  unless the system only contains one proton (or type of proton).

In most experimental contexts, a different form of Eq.~\eqref{eqn:HH} is used
  which is often referred to as a ``generalized'' Hill equation.
This corresponds to a specific choice of pH dependence such that
\begin{equation*}
  \pKa(\text{pH})
  \approx
  \pKaX{(a)}
  +
  (1 - n)\left(\text{pH} - \pKaX{(a)}\right).
\end{equation*}
The constant $n$ is then known as the Hill coefficient and the so-called
  apparent $\pKa$, $\pKaX{(a)}$, generally corresponds to the inflection point
  of a plot of $P_{\text{HA}}(\text{pH})$.
Both quantities are usually determined by non-linear regression after
  $P_{\text{HA}}$ has been determined at different pH values.

\subsection{Implementation Details}

In NAMD, each canonical partition function is represented by a specific force
  field description embodied in a PSF -- in order to change the protonation
  state the underlying PSF must also be modified.
This is accomplished by a close coupling to \texttt{psfgen}.
The models that can be used with constant-pH MD are thus limited to only those
  which can be completely implemented within \texttt{psfgen}.
This also means that NAMD requires access to residue topology files (RTFs)
  during the course of a simulation.
These must be specified with the \texttt{psfgen} \texttt{topology} command.

For consistency between topological descriptions, NAMD uses ``dummy'' atoms to
  represent non-interacting protons.
These atoms have the same mass as protons but only interact with the system
  via a minimal number of force field bonded terms.
This formalism guarantees that:
  1) the number of atoms/coordinates during the simulation remains fixed
  and
  2) the thermodynamics of the model is unchanged.
The latter point is subtle and warrants comment.
As implemented in NAMD, constant-pH MD only captures the thermodynamics of
  the semi-grand canonical ensemble.
There is no active description of proton dissociation events.
However, this is more of a limitation of classical MD than a particular
  shortcoming of NAMD.
A useful analogy may be the use of Langevin dynamics as a thermostat as
  opposed to a phenomonological model for Brownian motion.

\begin{figure}[h]\center{
  \includegraphics[width=0.6\textwidth]{figures/namdcph_nemdmc_scheme}
  \caption{\label{fig:namdcph_nemdmc}
    The basic constant-pH MD scheme in NAMD is to alternate equilibrium
      sampling in a fixed protonation state followed by a nonequilibrium MD
      Monte Carlo move to sample other protonation states.
    The latter move can be accepted or rejected.
    If accepted, the simulation continues in the new protonation state.
    If the move is rejected, sampling continues as if the move were never
      attempted at all.
  }
}\end{figure}

The basic scheme in NAMD is to alternately sample the protonation state and
  then the configuration space within that state.
Protonation state sampling is accomplished by an alchemical coupling scheme
  that forcibly turns off interactions with the current protonation state and
  turns on interactions with a candidate protonation state.
This nonequilibrium ``switching'' is accomplished with the alchemy code
  (specifically the thermodynamic integration code branch) and necessarily has
  lower performance (by about 30\%) than regular MD due to the added
  electrostatic calculations in the reciprocal space (\textit{i.e.}, when
  using PME).
However, the configuration space sampling should still have normal performance.
The switching process exerts work on the system and thus drives the system out
  of equilibrium.
However, an appropriately designed Monte Carlo (MC) move using an accept/reject
  criterion can recover the correct semi-grand canonical equilibrium
  distribution in both the state and configuration
  spaces~\cite{Nilmeier_ProcNatlAcadSci_2011_v108_pE1009,
    Chen_JChemPhys_2015_v142_p024101}.
The resulting scheme is a hybrid nonequilibrium MD/MC (neMD/MC) algorithm.
The most important conceptual change from conventional MD is that, rather than
  being a continuous trajectory, the simulation now becomes a series of cycles
  composed of an MD and neMD/MC step.
This means that the length of the simulation is no longer simply determined by
  the number of steps (\texttt{numsteps}) but rather the number of cycles.
The length of a cycle is also determined by two parts -- the amount of time on
  equilibrium sampling and the amount of time executing the switch.

It may be profitable/necessary to vary the switch time depending on the type of
  protonation change that is being effected.
Indeed, this is a critical factor in the efficiency of the method.
That is, if the switch is too short, then moves are unlikely to be accepted and
  effort will be wasted when the move is rejected.
However, if the switch is too long, then an inordinate amount of effort will be
  spent sampling the state space and there will be fewer resources left for
  exploring the configuration space.
Some basic qualities of the system that affect sampling have been determined
  using nonequilibrium linear response
  theory~\cite{Radak_JChemPhys_2016_v145_p134109}.
In short, there are intrinsic limits based on:
  1) the extent that differing interactions between each state fluctuate
  (according to some variance, $\sigma_0^2$)
  and
  2) the ``molecular'' time scale, $\tau_{\text{m}}$, on which these
  fluctuations change.
These effects are roughly captured by the
  expression~\cite{Radak_JChemPhys_2016_v145_p134109,
    Radak_JChemTheoryComput_2017_v13_p5933}:
\begin{equation*}
  \tau_{\text{opt}}
  \le
  \frac{\sigma_0^2 \tau_{\text{m}}}{2.83475},
\end{equation*}
  where $\tau_{\text{opt}}$ is some optimal switching time, in the sense of
  maximizing the rate at which protonation states interconvert.
Overall, switching times on the order of tens of picoseconds tend to be optimal
  in that they balance the high cost of switching versus the high acceptance
  rate at longer switching times (in the infinite time limit the perturbation
  is adiabatic and exerts zero work).
For titratable groups exposed primarily to aqueous solvent, a switch on the
  order of 10-20~ps appears to give near optimal
  results~\cite{Radak_JChemPhys_2016_v145_p134109,
    Radak_JChemTheoryComput_2017_v13_p5933}.
An equivalent formulation of the above expression is that mean acceptance rates
  around 20-25\% are likely near optimal.

\fbox{
  \begin{minipage}[ht!]{15.3cm}
    \addtolength{\baselineskip}{0.225\baselineskip}
    \textbf{Important Limitations:}\\
    For various reasons concerning the implementation, constant-pH simulations
      are currently \emph{incompatible} with the following NAMD
      functionalities in all or most situations:
    \begin{itemize}
    \item Any system using GPUs/CUDA
    \item Generalized Born implict solvent (\texttt{GBIS})
    \item Alchemical free energy calculations, \textit{e.g.},~ligand binding
      (\texttt{alch})
    \item Drude polarizable force fields
    \item Hybrid quantum mechanical/molecular mechanical simulations
    \item Collective variables (\texttt{colvars})
    \item \texttt{extraBonds}
    \end{itemize}
    This list is neither exhaustive nor definitive.
    In many instances the problem may be overcome by modest additional
      developments. %(see Notes for Developers).
  \end{minipage}
}

\newpage
\begin{center}
  \includegraphics[width=0.9\textwidth]{figures/namdcph_flowchart}
\end{center}

\newpage
\subsection{New Commands and Keywords}

The constant-pH implementation is largely implemented in Tcl and can be found
  in \texttt{/lib/namdcph/namdcph.tcl}, where the base directory is the NAMD
  source home directory.
When that file has been loaded with a suitable \texttt{source} command, the
  following commands and keywords are available and appear to the user in a way
  similar to NAMD syntax.
The most significant change from normal NAMD usage is that there is generally
  no need to use the \texttt{run} command.
One should instead use the new \icommand{{\tt cphRun}} command;
this can only be used \emph{once} per script for now.
\textit{NB}, all commands and keywords are currently case sensitive!
\\[11pt]
\noindent
\icommand{{\tt cphRun}} $<$ Run constant-pH MD $>$
\\
\textbf{Arguments:} {\ARG{numsteps} \OARG{numcycles}}
\\
\textbf{Defaults:} {{\tt numcycles} = 1}
\\
\textbf{Description:}
Execute {\tt numcycles} cycles of constant-pH MD with the current settings.
Each cycle consists of 1) a neMD/MC move in both configuration and protonation
  space and 2) MD based sampling in configuration space.
By default, configuration space sampling simply consists of {\tt numsteps}
  dynamics, as in conventional MD.
The nature of the neMD/MC moves, however, is more elaborate and controlled by
  other keywords, \emph{many of which are required} (see below).
%\\[11pt]
%\noindent
%\icommand{{\tt testResidue}} $<$ Test a constant-pH residue definition $>$
%\\
%\textbf{Arguments:} {\ARG{resname list} \OARG{verbose}}
%\\
%\textbf{Defaults:} {{\tt verbose} = 0}
%\\
%\textbf{Description:}
%THIS IS AN ADVANCED OPTION, USE WITH CARE!
%This is meant to be a convenience command for verifying that RTF, PRM, and
%  configuration file definitions are complete and consistent.
%The \texttt{resname list} argument should be a Tcl list containing the names
%  of one or more residue definitions described in the configuration file.
%Accompanying \texttt{parameter} and \texttt{topology} information is also
%  required, as in normal simulations.
%The command will iterate through all possible protonation state transitions and
%  check that the energy of each state does not depend on the pathway by which
%  it is reached.
%Setting {\tt verbose} $\ne$ 0 will also show decomposition of energy terms
%  (\textit{e.g.}, ELEC and VDW).

\subsubsection{Required Keywords}
\begin{itemize}
\item \NAMDCONF{pH}
{pH value that the system is in contact with}
{decimal (usually between 0 and 14)}
{
The \KEY{pH} is effectively a chemical potential applied to protons
  \emph{only}.
This value affects the details of neMD/MC moves but otherwise has no effect
  on the system dynamics.
}

\item \NAMDCONF{cphConfigFile}
{File defining titratable residues}
{filename}
{
The \KEY{cphConfigFile} contains definitions for the available titratable
  residues.
This is essentially meta information regarding the RTF contents, but also
  includes experimental references and additional force field parameterization.
}

\item \NAMDCONF{cphNumstepsPerSwitch}
{Number of steps during nonequilibrium switching}
{
  \OARG{integer \OARG{\ARG{move label} \ARG{integer}} \ldots}
}
{
Each move must have an associated number of steps per switch.
If an odd number number of arguments is specified, then the first such argument
  is assumed to be a default number for all such moves.
After this (or if an even number of arguments is specified) all remaining
  arguments are assumed to be specific assignments for a given move label
  of the form \ARG{segid}:\ARG{resid}:\ARG{resname}/\ARG{segid}:\ARG{resid}:\ARG{resname}/\ldots.
}
\end{itemize}

\subsubsection{Commonly Used Options}
\begin{itemize}
\item \NAMDCONF{cphSetResidueState}
{Set the initial state of one or more titratable residues.}
{
\ARG{segid}:\ARG{resid}:\ARG{resname} \ARG{state} \OARG{\ldots}
}
{
Initial residue states can be assigned in three ways (in descending order of
  precedence): 1) via this command, 2) from a \KEY{cphRestartFile}, and 3)
  randomly from the assigned \KEY{pH} and the current inherent pKa of each
  residue.
}

\item \NAMDCONF{cphSetResiduepKai}
{Set the inherent pKa of one or more titratable residues.}
{
\ARG{segid}:\ARG{resid}:\ARG{resname} \ARG{pKai} \OARG{\ldots}
}
{
The two step inherent pKa algorithm implemented here permits on-the-fly update
  of an estimate for the pKa(s) of each residue.
These can either be guessed at the outset (the default is to use the reference
  pKa) or updated as the simulation progresses.
A more accurate estimate of the inherent pKa increases the statistical
  efficiency of the method, but the long time result is formally unbiased
  regardless of the value.
If an extremely large or extremely small value is assigned, then the residue
  will be assigned the most probable protonation state at the given pH and
  likely remain fixed in that state.
}

\item \NAMDCONF{cphExcludeResidue}
{Exclude one or more residues from being titratable}
{
\ARG{segid}:\ARG{resid}:\ARG{resname} \OARG{\ldots}
}
{
By default, any residue that matches a titratable residue type will be allowed
  to change protonation state.
This command permits specific residues to be excluded from consideration in a
  manner that is similar to assigning an extreme inherent pKa (see
  \texttt{cphSetResiduepKai}).
The main differences are that 1) the protonation state will not be modified and
  remain as it is in the original PSF and 2) the protons in the residue will
  \emph{not} be tracked in the \texttt{cphlog} file.
This command is not always recommended, but is currently necessary for handling
  disulfide linkages.
}

\item \NAMDCONF{cphRestartFile}
{Restart file for constant-pH}
{filename}
{
Constant pH requires additional checkpoint information regarding the state of
  the titratable residues and the nature of the neMD/MC moves.
This (optional) information is read from the file specified here.
After/during a simulation, this information is written to
  \KEY{[outputname]}.cphrst.
}

\item \NAMDCONFWDEF{cphRestartFreq}
{Frequency at which constant-pH checkpoint files are written}
{Non-negative integer}
{0}
{
Checkpoint information is written to \KEY{[outputname]}.cphrst every
  \KEY{cphRestartFreq} cycles (\emph{not} MD steps).
A checkpoint file is \emph{always} written at the end of the last cycle.
}

\item \NAMDCONFWDEF{cphOutFile}
{Log file for constant-pH}
{filename}
{\KEY{[outputname]}.cphlog}
{Titratable residue state information is logged here after every cycle.}

\item \NAMDCONF{cphProposalWeight}
{MC move label and weight specifications}
{
\ARG{move label} \ARG{weight}
  \OARG{\OARG{\ARG{move label} \ARG{weight}} \ldots}
}
{
During each cycle, MC moves are selected from the move set and then
  accepted/rejected according to a Metropolis criterion based on the combined
  inherent pKa information and pH.
The move weight affects the probability that such a move is selected.
Note that \emph{this does not affect the probability that any given proposal
  is accepted}, it merely increases the number of attempts at the given
  proposal.
This may be useful in a system where one desires specific attention on a given
  process, such as proton transfer or the exchange of a given residue, but one
  does not want to assume that all other residue protonation states are
  nominally fixed.
By default all moves are assigned equal weights of 1.0.
During the simulation these are automatically normalized to a discrete
  probability mass function.
}

\item \NAMDCONFWDEF{cphMaxProposalAttempts}
{Maximum number of switch proposal attempts per cycle}
{integer}
{0}
{
During each cycle, MC moves are selected from the move set and then
  accepted/rejected according to a Metropolis criterion based on the combined
  inherent pKa information and pH.
This process stops when either a switch move is accepted or a maximum limit is
  reached.
Any value less than one defaults to the number of titratable residues in the
  system.
}

\item \NAMDCONFWDEF{cphNumMinSteps}
{Number of steps of minimization before dynamics}
{integer}
{0}
{
This is a replacement for the normal minimize command, which is not compatible
  with constant-pH due to PSF modifications during initialization.
Setting this option to a modest number (100--200, say) might be necessary when
  randomizing protonation states based on pH, since in that case it cannot be
  assumed that the starting structure is representative of the initial
  protonation state.
}

\end{itemize}

\subsubsection{Specialized Options}
\begin{itemize}
\item \NAMDCONFWDEF{cphForceConstant}
{force constant for alchemical switches (in kcal/mol-\AA$^2$)}
{Non-negative decimal}
{100.0}
{
During ``dual-topology'' alchemical switches, a harmonic bond is formed between
  analogous atoms in each alchemical region.
This rigorously leaves all static thermodynamic quantities intact and is
  generally expected to improve the stability of dynamic quantities.
}

\item \NAMDCONFWDEF{cphMDBasename}
{basename of intermediate files for equilibrium MD}
{string}
{namdcph.md}
{
PSF/coordinate modifications are currently done via the file system and utilize
  intermediate files.
It may be advantageous to direct this I/O to a fast temporary directory.
}

\item \NAMDCONFWDEF{cphSWBasename}
{basename of intermediate files for nonequilibrium (switch) MD}
{string}
{namdcph.sw}
{
PSF/coordinate modifications are currently done via the file system and utilize
  intermediate files.
It may be advantageous to direct this I/O to a fast temporary directory.
}
\end{itemize}

\fbox{
  \begin{minipage}[ht!]{15.3cm}
    \addtolength{\baselineskip}{0.225\baselineskip}
    \textbf{Undocumented Features:}\\
    The constant-pH code is actively under development, although future work
      will almost exclusively be in adding new features and capabilities as
      well as improving performance.
    Because the code is fairly lightweight and available in \texttt{Tcl}, the
      intrepid user may discover ``easter egg'' features which are not listed
      in the documentation.
    \textbf{USE UNDOCUMENTED FEATURES AT YOUR OWN RISK.}
    Such undocumented features may work (and even be advisable) for specific
      problems, but have not undergone as rigorous of testing and may be prone
      to unintended consequences.
  \end{minipage}
}

\subsection{Minimal Examples}

Constant-pH simulations can be carried out with largely the same options as
  conventional MD simulations (with some exceptions, see previous sections).
The follwing examples assume that: 1) PSF and PDB files for the
  system of interest have already been constructed and 2) appropriate
  simulation keywords have already been chosen (\textit{e.g.},~for PME,
  Langevin dynamics, \textit{etc.}).
\begin{verbatim}
# End conventional settings...
source .../namd/lib/namdcph/namdcph.tcl
# Constant-pH MD requires additional force field files _during_ the simulation.
# In general, all RTFs used to construct the system need to be included with
# the ``topology'' command (just as in psfgen). Additional constant-pH specific
# RTF and PRM files are also necessary, as well as an accompanying
# configuration file in JSON format.
#
cphConfigFile <path to JSON config file>
topology <path to RTF>
topology <path to another RTF>
pH 7.0
# The following defaults all nonequilibrium switches to 5000 steps and then
# increases the time for residue 5 of segid PROA to 7500 steps -- multiple
# residues can be specified
#
cphNumStepsPerSwitch 5000 PROA:5:ASP 7500
# Run 100 minimization cycles before starting dynamics.
cphNumMinSteps 100
# Run 2500 steps of MD between attempted protonation state changes. Run 10
# cycles of MD and neMD/MC. The _upper_ bound of the simulation is thus:
#
# 10*(2500 + 7500) = 100000 steps
#
# but the actual simulation may be shorter in length.
#
cphRun 2500 10
\end{verbatim}

\newpage
\noindent
\textbf{Restarting a simulation}

\noindent
The following assumes that a simulation has already been run (as in the example
  above).
For clarity we shall assume that \texttt{outputname} was set to "foo" such that
  restart files have been written to foo.coor and foo.vel (normal output) as
  well as foo.psf, foo.pdb, and foo.cphrst (constant-pH specific output).

\begin{verbatim}
# End conventional settings...
source .../namd/lib/namdcph/namdcph.tcl
# Constant-pH MD requires additional force field files _during_ the simulation.
# In general, all RTFs used to construct the system need to be included with
# the ``topology'' command (just as in psfgen). Additional constant-pH specific
# RTF and PRM files are also necessary, as well as an accompanying
# configuration file in JSON format.
#
cphConfigFile <path to JSON config file>
topology <path to RTF>
topology <path to another RTF>
pH 7.0

structure foo.psf
coordinates foo.pdb
binCoordinates foo.coor
binVelocities foo.vel
cphRestartFile foo.cphrst
# NB: switch times and inherent pKa values are read here and no longer need to
# be specified as during initialization

cphRun 2500 10
\end{verbatim}

%% COMING SOON
%\newpage
%\subsection{Notes for Developers}
%
%This section of the user's guide is likely not necessary reading for those
%  who simply want to perform constant-pH simulations.
%Rather, it is a companion guide for the code and comments so that furthur
%  developments can be made as a community.


%---------------------------------------------------
% Exponential (& Logarithmic) Functions
%---------------------------------------------------
\chapter[Exponential Functions]{Exponential \& Logarithmic \\Functions}
We defined the polynomial $a^{x}$ in Chapter 1 (page~\pageref{sec:polynomials}), however $x$ was restricted to rational numbers. (Recall rational numbers can be expressed as a fraction: $\frac{a}{b}$.) We now want to explore $a^{x}$ where and $x$ is any real number. Consider $y =2^{x}$. This is an \textit{exponential} function because the variable, $x$, is in the exponent. The graph is shown below. Notice it will never go below $y=0$.

\begin{multicols}{2}
	\begin{center}{\renewcommand{\arraystretch}{1.25}%
		\begin{tabular}{clr}
			\toprule
			variable&function&\\
			$x$&$f(x)=2^x$& \\
			\midrule
			$-4$    & $f(-4)=2^{-4}$&$=0.0625$\\
			$-3$    & $f(-3)=2^{-3}$&$=0.125$\\
			$-2$    & $f(-2)=2^{-2}$&$=0.25$\\
			$-1$ & $f(-1)=2^{-1}$&$=0.5$ \\
			$0$ & $f(0)=2^0$&$=1$ \\
			$1$ & $f(1)=2^1$&$=2$ \\
			$2$ & $f(2)=2^2$&$=4$ \\
			\bottomrule
		\end{tabular}}
		\captionof*{tabular}{A \textbf{table of values} for the function $f(x)=2^x$}
	\end{center}
	\columnbreak
	\begin{center}
		\begin{tikzpicture}\label{fig:y2x}
			\begin{axis}[
				scale=1,
				axis lines=center,
				ymax=4.5,ymin=0,
				xmax=4.5,xmin=-4.5,
				xlabel=$x$,ylabel=$y$,
				]
				\addplot [<->,domain=-4.5:2.1,thick, samples=100, black] {2^x};
				\node[anchor=south] at (axis cs:1.8,0.5) {$f(x)=2^x$};
				\addplot[mark=*] coordinates {(-4,0.0625)};
				\addplot[mark=*] coordinates {(-3,0.125)};
				\addplot[mark=*] coordinates {(-2,0.25)};
				\addplot[mark=*] coordinates {(-1,0.5)};
				\addplot[mark=*] coordinates {(0,1)};
				\addplot[mark=*] coordinates {(1,2)};
				\addplot[mark=*] coordinates {(2,4)};
			\end{axis}
		\end{tikzpicture}
		\captionof*{tikzpicture}{A \textbf{plot of the points} showing an exponential relationship}
	\end{center}
\end{multicols}

\subsection*{The Exponential Function $f(x)=a^x$}
Let $y =a^{x}$ where $a >0$. Here, $f(x) =a^{x}$ is called an \emph{exponential} function where $a$ is called the \emph{base}. The domain is the set of real numbers, $\mathbb{R}$. The range is $\left (0 ,\infty \right )$. The $x$-axis forms an asymptote.
\begin{multicols}{2}
	\begin{center}
		\begin{tikzpicture}\pgfplotsset{ticks=none}
			\begin{axis}[
				scale=0.8,
				axis lines=center,
				ymax=10,ymin=-0.5,
				xmax=6,xmin=-4,
				xlabel=$x$,ylabel=$y$,
				]
				\addplot [->,domain=-3.2:5,thick, samples=100, black] {(0.5)^x};
				\node[anchor=south] at (axis cs:2,2) {decay};
			\end{axis}
		\end{tikzpicture}\end{center}\captionof*{tikzpicture}{When $0<a<1$, $y=a^{x}$ `decays' as $x$ gets big}\columnbreak
	\begin{center}
		\begin{tikzpicture}\pgfplotsset{ticks=none}
			\begin{axis}[
				scale=0.8,
				axis lines=center,
				ymax=10,ymin=-0.5,
				xmax=5,xmin=-5,
				xlabel=$x$,ylabel=$y$,
				]
				\addplot [->,domain=-5:3.2,thick, samples=100, black] {2^x};
				\node[anchor=south] at (axis cs:3,1) {growth};
			\end{axis}
		\end{tikzpicture}\end{center}
	\captionof*{tikzpicture}{When $a>1$, $y=a^{x}$ `grows' as $x$ gets big}
\end{multicols}

\example Find the equation of the exponential function that passes through $\left (0 ,1\right )$ and $\left (3 ,125\right )$.

\solution An exponential function that passes through $\left (0 ,1\right )$ is of the form $f (x) =a^{x}$. As $f (3) =125$ we substitute $x =3$ and get
\begin{align*}a^{3} &  = 125 \\
a &  = \sqrt[{3}]{125} =5\\
\therefore f(x)&=5^x \text{ satisfies the conditions.}
\end{align*}

\subsection*{Transformations of Exponential Functions}
Recall the transformations we have met so far:
\begin{center}{\renewcommand{\arraystretch}{1.3}
\begin{tabular}{ll}Vertical stretch of $a$  & $y =f (x) \leadsto y =a f (x)$  \\
	Horizontal stretch of $\frac{1}{b}$  & $y =f (x) \leadsto y =f (b x)$  \\
	Vertical shift of $c$ $\uparrow $  & $y =f (x) \leadsto y =f (x) +c$  \\
	Horizontal shift of $d$ $ \longrightarrow $  & $y =f (x) \leadsto y =f (x -d)$  \\
	Reflection in $x$-axis  & $y =f (x) \leadsto y = -f (x)$  \\
	Reflection in $y$-axis  & $y =f (x) \leadsto y =f ( -x)$
\end{tabular}}
\end{center}
Each of these transformations can be applied to an exponential function. Horizontal shifts are `attached' to the $x$ with brackets and opposite to convention. A shift to the right is represented by negative, e.g., $y=2^(x-3)$. Vertical shifts are positive to shift up and negative to shift down.
\begin{center}\includegraphics[width=14cm]{expTrans1}\end{center}
Reflections are accomplished by multiplying by negative one. To reflect in the $x$-axis, multiply the whole function by $-1$, e.g., $y=-2^x$. And for a reflection in the $y$-axis multiply the $x$ variable by $-1$, e.g., $y=2^{-x}$.
\begin{center}\includegraphics[width=14cm]{expTrans2}\end{center}
See the lecture notes for more examples.\\

\exercise Use Desmos to verify that $y =2^{-x}$ and $y =\left(\frac{1}{2}\right)^x$ are equivalent.
%---------------------------------------------------
% the natural exponential function e^x
%---------------------------------------------------
%\section{\texorpdfstring{$e^x$}{}}
\section[$e^x$]{The Natural Exponential Function}\label{sec:naturalExponential}
The \emph{natural exponential function} has wide application in mathematics engineering. It arises naturally and crops up in applications such as finance, population, radioactivity, charge on a capacitor, and more. We have defined $f (x) =a^x$ and there is a particular value of $a$ that we denote by the letter $e$. It is an irrational number (like $\pi $, $\sqrt{2}$ etc.) and has a button on your calculator. To 10 decimal places it is
\[e \approx 2.7182818285\dots\]
The natural exponential function $f (x) =e^x$ is often simply referred to as \textit{the} exponential function.

Compound interest can demonstrate an example of  how the value above is found. Imagine a bank that pays 100\% interest on your money. Given an initial deposit of \$1, at the end of year you will receive \$1 in interest payment and have a total of \$2. Compounded interest allows this to happen at intervals smaller than 1 year. If the interest is compounded twice per year, then after 6 months, you will receive 50\% interest and have \$1.50. In the second half of the year you now have an additional \$0.50 available to earn the second half interest. Now, $\$1.50\times50\%=\$0.75$, so at the end of the year you have \$1.50+\$0.75=\$2.25.

Lets say the interest is compounded monthly, then after 1 month you will receive $\frac{1}{12}\times 100\%=8.33\%$ interest for \$1+\$0.0833=\$1.0833. The second month will earn the same rate (8.33\%) on \$1.0833, for a total of \$1.1736. After 12 months, your dollar will now be worth $\$1.00\times\left(1+\frac{1}{12}\right)^{12}=\$2.6130$.

Repeat this process for shorter and shorter time intervals. What is the most money you can have? Compounding every second would get close to the maximum but there would still be gaps \textit{between} the seconds. Closing these gaps yields a \textit{continuous} function.
\begin{center}
\begin{tabular}{cll}
	\toprule
	compounding periods&interest (\$)&total (\$)\\
	\midrule
	1 (yearly)&1.00&2.00\\
	2&1.25&2.25\\
	3&1.3704 &2.3704\\
	4 (quarterly)& 1.4414 & 2.4414 \\
	5& 1.48832 & 2.48832 \\
	6& 1.521626&2.521626\\\midrule
	12 (monthly)& 1.613035&2.613035 \\\midrule
	52 (weekly)&1.692597 &2.692597\\\midrule
	365 (daily)&1.714567 &2.714567\\\midrule
	continuous& 1.718282&\textbf{2.7182818}$...=$\textit{\textbf{e}}\\
	\bottomrule
\end{tabular}
\end{center}
\clearpage
\begin{multicols}{2}
As a function, $f(x)=e^x$, is plotted. Note the similarity to $y=2^x$ (page~\pageref{fig:y2x}).

The exponential function, $e$, is naturally occurring, and useful mathematically as we will see in the next chapter on differentiation.

Replacing the $x$ axis with time we can imagine the compounding benefits (or detriments) of the exponential function as time increases.
\columnbreak
\begin{center}
	\begin{tikzpicture}\pgfplotsset{ticks=none}
		\begin{axis}[
			scale=1,
			axis lines=center,
			ymax=9.5,ymin=-0.5,
			xmax=5,xmin=-5,
			xlabel=$x$,ylabel=$y$,
			]
			\addplot [<->,domain=-5:2.2,thick, samples=100, black] {e^x};
			\node[anchor=south] at (axis cs:3,5) {$y=e^x$};
			\addplot[mark=*] coordinates {(0,1)};
			\node[anchor=south] at (axis cs:-1,1) {$(0,1)$};
			\addplot[mark=*] coordinates {(1,2.718)};
			\node[anchor=south] at (axis cs:2,2.5) {$(1,e)$};
		\end{axis}
\end{tikzpicture}\end{center}
\end{multicols}
%---------------------------------------------------
% Logarithmic Functions
%---------------------------------------------------
\section{Logarithmic Functions}
The \emph{logarithmic function} is the inverse of the function $f (x) =a^{x}$. Recall the inverse of a function is the reflection of the function in the line $y =x$. Mathematically this is equivalent to swapping the $x$ and the y in $y =a^{x}$. So $x =a^{y}$ is the inverse of $y =a^{x}$. We have another notation for the inverse of a function, which is a little more complicated. Let $y =f (x)$ be a function of $x$ then $y =f^{ -1} (x)$ is the inverse of this function.

Sometimes the inverse of the function is also a function. For example the inverse of $y =x^{2}$ is $x =y^{2}$. $y =x^{2}$ is a function (vertical line test always applies), whereas $x =y^{2}$ is not a function (vertical line test is broken).

\begin{multicols}{2}
\includegraphics[ width=3.032in, height=2.4275in,]{L4SZ2832}
\includegraphics[ width=2.3419in, height=2.4267in,]{L4SZ2833}
\end{multicols}

The inverse of $y =10^{x}$ is $x =10^{y}$. $y =10^{x}$ is a function (vertical line test always applies) and so is $x =10^{y}$.

Another useful fact to remember about inverses concerns the domain and range. The \emph{domain}
of $f$ is the \emph{range} of $f^{ -1}$ and the \emph{range} of $f$ is the \emph{domain} of $f^{ -1}$.

We have a notation for $x =a^{y}$ it is $y =\log _{a} x$:
\begin{tcolorbox}
\[y =\log _{a} x \Leftrightarrow x =a^y
\]
\end{tcolorbox}

In $x =a^{y}$ substitute $y =\log _{a} x$ and we get $x =a^{\log _{a} x}$. This means that given a base of $a$ the power (or exponent) to which $a$ must be raised to get $x$ is $\log _{a} x$.

Problems involving logarithms will often require us to switch back and forth between $y =\log _{a} x$ and $x =a^{y}$, however it is also helpful if you can remember to substitute for $y$ and write $x =a^{\log _{a} x}$ so that you can say ``the logarithm is the power".

\example
\begin{description}
	\item [(a)] $\log _{10} 100 =2$ because $10^{2} =100$

	\item [(b)] $\log _{3} 81 =4$ because $3^{4} =81$

	\item [(c)] $\log _{10} 0.01 = -2$ because $10^{ -2} =0.01$ \end{description}

\subsection*{The graph of $y =\log _{a} x$}
The exponential function $y =a^{x}$ where $a >0$ is now known and its domain is $\mathbb{R}$ and its range is the positive real numbers. We can write $\mathbb{R}^{ +}$, meaning the positive real numbers, instead of $(0 ,\infty)$.

The graph of $f (x) =a^{x}$ can be reflected in the line $y =x$ and the result is $f^{ -1} (x) =\log _{a} x$.

\textbf{Graphing Exercise} On the same set of axes draw:
\begin{tasks}(4)
	\task $y =10^{x}$
	\task $y =\log _{10} x$
	\task $y =x$
	\task $x =10^{y}$
\end{tasks}

Make a comment about each statement below.
\begin{tasks}
	\task[1.] Check the graphs in (a), (b) and (c) are you confident that $y =\log _{10} x$ is the reflection of $y =10^{x}$ in the line $y =x$?
	\task[2.] When you enter $x =10^{y}$ describe what takes place.
	\end{tasks}

\textbf{Graphing Exercise Solution} Using \desmos we can see the different plots. Plots (b) and (d) are equivalent, so are on top of each other.\\
\begin{center}
\includegraphics[width=14cm]{logGraph1}\\
\end{center}

\textbf{Graphing Exercise} On the same set of axes draw:
\begin{tasks}(4)
	\task $y =\log _{2} x$
	\task $y =\log _{3} x$
	\task $y =\log _{4} x$
	\task $y =\log _{10} x$ \end{tasks}
\textbf{Graphing Exercise Solution} Using \desmos we can see the relationship between the different bases in the log equation:\\
\begin{center}\includegraphics[width=14cm]{logGraph2}\end{center}
Notice the point that is common to all curves and the behaviour of the family of curves for $x >1$ and for $0 <x <1$.

\textbf{Property 1}: A property of logarithms is $\log _{a} 1 =0$ and this can be seen on the graphs where every graph goes through $\left (1 ,0\right )$.

The pattern you observe as the base gets bigger might not be evident for values of the base between $0$ and $1$. On the same set of axes draw the following:

\begin{tasks}(4)
	\task $y =\log _{\frac{1}{2}} x$
\task $y =\log _{\frac{1}{3}} x$
	\task $y =\log _{\frac{1}{4}} x$
	\task $y =\log _{\frac{1}{5}} x$ \end{tasks}
\begin{center}\includegraphics[width=14cm]{logGraph3}\end{center}
To say the pattern is the same you have to be careful to describe the base. Explain how changing the base gives the same pattern as for (a) to (d).

\textbf{Property 2:} A second property of logarithms is $\log _{a} a =1$. That is $a^{1} =a$ or the power to which you have to raise $a$ to get $a$ is $1$. On your curves above locate a point on each curve that shows this. You
should in each case be looking for the point $\left (a ,1\right )$.

\textbf{Property 3:} A third property
of logarithms is $\log _{a} a^{x} =x$. This useful property must be understood if logarithm problems are to be mastered.
\ You should understand what $\log _{a} a^{x}$ is saying. $a$ is the base so $\log _{a} a^{x} =x$ says ``The power to which $a$ must be raised to get $a^{x}$ is $x$."

\subsection*{Base-10}
When the base is $10$ we write $y =\log  x$ which \textit{implies} that $y=\log _{10} x$. If you see no base you assume it is base $10$. \Desmos and other mathematics programs recognise ``$\log $'' as being ``logarithm of base $10$.'' The $\log $ key on the calculator gives the base-10 logarithm of any positive number.
\begin{tcolorbox}
\begin{equation*}y =\log  x \Leftrightarrow 10^{y} =x
\end{equation*}
\end{tcolorbox}

\subsection*{Natural Logarithms}
When the base is $e$ we write $y =\log _{e} x =\ln  x$. If you see $\ln  x$ you can assume it is $\log _{e} x$. This is sometimes called the \emph{natural} logarithm of $x$. Software should recognise ``$\ln $'' as meaning ``logarithm to the base $e$.'' The $\ln $ key on the calculator gives the natural logarithm of any positive number.
\begin{tcolorbox}\begin{equation*}y =\ln  x \Leftrightarrow e^{y} =x
\end{equation*}\end{tcolorbox}

\textbf{Graphing Exercise}
Use Desmos to sketch the following. Describe in words how each curve is related to $y =\ln  x$.

\begin{tasks}(3)
	\task $y =\ln  x$
\task  $y =\ln  ( -x)$
\task  $y = -\ln  x$
	\task  $y =\ln  (x -1)$
	\task  $y =\ln  (x) -1$
	\task $y =\ln  ( -1 -x)$ \end{tasks}

\section{The Laws of Logarithms}

The logarithmic laws are listed beside their equivalent exponent laws (see Section~\ref{sec:introAlgebra} Exponents) to show the symmetry between the two. The terms \textit{logarithm} and \textit{exponent} are very similar.
\begin{tcolorbox}
\begin{center}
\renewcommand{\arraystretch}{1.2}
\begin{tabular}{lrclcrcl}
	%\toprule
	\multicolumn{4}{c}{Logarithms}& &\multicolumn{3}{c}{Exponents}\\
	\cmidrule{1-4}\cmidrule{6-8}
	Law 1: &$ \log_x(ab) $&$=$&$ \log_x(a)+\log_x(b)  $&\hspace{1cm} &$x^a x^b$&$=$&$x^{a+b} $\\
	Law 2: &$ \log_x\left(\frac{a}{b}\right) $&$=$&$  \log_x(a)-\log_x(b) $& &$\dfrac{x^a}{x^b}$&$=$&$x^{a-b}  $\\
	Law 3: &$ \log_x(a^b) $&$=$&$ b\cdot\log_x(a)   $& &$(x^a)^b $&$=$&$x^{ab} $\\
	\cmidrule{1-4}\cmidrule{6-8}
	&$  \log_{x}\left(\frac{1}{x^a}\right) $&$=$&$-a   $& &$x^{-a} $&$=$&$\frac{1}{x^a} $\\
	&$ \log_{x}1  $&$=$&$ 0  $& &$x^0 $&$=$&$1 $\\
	&$ \log_x(x) $&$=$&$  1 $& &$x^1 $&$=$&$x $\\
	\bottomrule
	recall:&$ \log_a(x) $&$=$&$y$\hspace{0.5cm} converts to& $\Leftrightarrow$ &$x $&$=$&$a^y $\\
	\bottomrule
\end{tabular}
\end{center}
For all of the above logarithms, $\log_x$ can be replaced with the natural logarithm, $\log_e$,  or $\ln$. So for example:
\begin{center}
	\renewcommand{\arraystretch}{1.2}
	\begin{tabular}{lrcl}
		%\toprule
		Law 1: &$ \ln(ab) $&$=$&$ \ln(a)+\ln(b)  $\\
		Law 2: &$ \ln\left(\frac{a}{b}\right) $&$=$&$  \ln(a)-\ln(b) $\\
		Law 3: &$ \ln(a^b) $&$=$&$ b\cdot\ln(a)$ \\
		%\bottomrule
	\end{tabular}
\end{center}
\end{tcolorbox}
\example
Expand using the logarithm laws
\begin{description}
	\item [(a)] $\log  \sqrt{3} =\log  3^{\frac{1}{2}} =\frac{1}{2} \log  3$

	\item [(b)] $\ln  \genfrac{(}{)}{}{}{a \sqrt{b}}{\sqrt[{3}]{c}} =\ln  \left (a b^{\frac{1}{2}} c^{ -\frac{1}{3}}\right ) =\ln  a +\ln  b^{\frac{1}{2}} +\ln  c^{ -\frac{1}{3}} =\ln  a +\frac{1}{2} \ln  b -\frac{1}{3} \ln  c$ \end{description}

\example Evaluate
\begin{description}
	\item [(a)] $\log _{2} 112 -\log _{2} 7 =\log _{2} \frac{112}{7} =\log _{2} 16 =\log _{2} 2^{4} =4 \log _{2} 2 =4$

	\item [(b)] $\log _{2} 8^{23} =\log _{2} \left (2^{3}\right )^{23} =\log _{2} \left (2^{69}\right ) =69 \log _{2} 2 =69$

	\item [(c)] $\log  \sqrt{0.001} =\log  \left (0.001\right )^{\frac{1}{2}} =\frac{1}{2} \log  0.001 =\frac{1}{2} \log  10^{ -3} =\frac{1}{2} \times  -3 = -\frac{3}{2} = -1\frac{1}{2}$

	\item [(d)] $e^{2 \ln  4} =\left (e^{\ln  4}\right )^{2} =4^{2} =16\text{\quad \quad }($Let $\ln  4 =x$ then $e^{x} =4$ so $e^{\ln  x} =4)$ \end{description}

\example Rewrite as a single logarithm term using the logarithm laws
\begin{description}
	\item [(a)] $\log  12 +\frac{1}{2} \log  5 -\log  3 =\log  \frac{12 \sqrt{5}}{3} =\log  4 \sqrt{5}$

	\item [(b)] $\log _{3} \left (x^{2} -1\right ) -\log _{3} \left (x -1\right ) =\log _{3} \frac{x^{2} -1}{x -1} =\log _{3} \frac{\left (x +1\right ) \left (x -1\right )}{x -1} =\log _{3} \left (x +1\right )$ \end{description}

%---------------------------------------------------
% Exponential and Logarithmic Equations
%---------------------------------------------------
\section{Exponential and Logarithmic Equations}
The types of problems we meet in this section will be able to be rearranged so that they look like
\begin{equation*}a^{f (x)} =b
\end{equation*}
Where $a$ and $b$ are real numbers, $x$ is the unknown variable we are trying to find and $f (x)$ is an expression in $x$. The technique we will use will be the same for every problem we solve.

\begin{description}
	\item [Step 1] Our first step is to inspect the problem to see if the unknown
	variable is in the exponent.

	\item [Step 2] Now that we have
	established that we are solving an exponential equation we rearrange it until it is in the form $a^{f (x)} =b$

	\item [Step 3] Take the logarithm
	of both sides. In most practical situations we either take logarithms to the base $10$ or logarithms to the base $e$. there are three situations

	\item [Case
	1] The problem has reduced to $10^{f (x)} =b$. Take logarithms to the base $10$.

	\item [Case 2] The problem has
	reduced to $e^{f (x)} =b$. Take logarithms to the base $e$.

	\item [Case 3] The problem has
	reduced to $a^{f (x)} =b$ where $a$ is neither $10$ nor $e$. You can take logarithms to the base $10$ or $e$ as you wish, either is correct.

	\item [Step 4]
	Solve the equation you obtain. \end{description}

\textbf{Example 1} Solve $3^{x} =5$. This is an example of case $3$ above.\medskip\\
\solution Two methods will be explored below:
\begin{multicols}{2}
Method 1: Take logarithms to the base $10$
\begin{align*}\log  3^{x} &  = \log  5 \\
x \log  3 &  = \log  5 \\
x &  = \frac{\log  5}{\log  3} \\
&  \approx 1.46497\end{align*}\\

% multicols is so frustrating!
\columnbreak{Method 2: Take logarithms to the base $e$ \begin{align*}\ln  3^{x} &  = \ln  5 \\
x \ln  3 &  = \ln  5 \\
x &  = \frac{\ln  5}{\ln  3} \\
&  \approx 1.46497\end{align*}}
\end{multicols}
This shows the same result whether you take logarithms to base $10$ or logarithms to base $e$.
\begin{multicols}{2}
\textbf{Example 2}\medskip
\phantom{1}Solve $3^{2 x +1} =5$\\
\solution Take logarithms to base 10:
\begin{align*}\log  3^{2 x +1} &  = \log  5 \\
\left (2 x +1\right ) \log  3 &  = \log  5 \\
2 x +1 &  = \frac{\log  5}{\log  3} \\
2 x &  = \frac{\log  5}{\log  3} -1 \\
x &  = \frac{1}{2} \left (\frac{\log  5}{\log  3} -1\right ) \\
&  \approx 0.2325 \end{align*}

\textbf{Example 3}\medskip
\phantom{1}Solve $4 \left (1 +10^{5 x}\right ) =9$\\
\solution This must first be rearranged:
\begin{align*}1 +10^{5 x} &  = \frac{9}{4} =2.25 \\
10^{5 x} &  = 2.25 -1 =1.25 \\
\log  10^{5 x} &  = \log  1.25 \\
5 x &  = \log  1.25 \\
x &  = \frac{1}{5} \log  1.25 \\
&  \approx 0.01938 \end{align*}
\end{multicols}
\clearpage
\textbf{Example 4} Solve \[\frac{10}{1 +e^{ -x}} =3\]
\solution
\begin{align*}1 +e^{ -x} &  = \frac{10}{3} \\
e^{ -x} &  = \frac{10}{3} -1 \\
&  = \frac{10 -3}{3} =\frac{7}{3} \\
-x &  = \ln  7 -\ln  3 \\
x &  \approx  -0.85\text{ (2 dp)}\end{align*}

\subsection*{Solving Logarithmic Equations}
Whereas exponential equations have the unknown variable in an exponent, logarithmic equations are equations containing the logarithm of an unknown variable.
\begin{tcolorbox}
\begin{description}
	\item [Step 1] Recognise you are dealing with a logarithmic equation by inspecting the problem to see if you have a logarithm of a term containing the unknown variable.
	\item [Step	2] Rearrange the equation until it is in the form $\log _{a} \left (\text{unknown}\right ) =b$.
	\item [Step 3] Take	`antilogarithms.' That is, use the conversion: $\log _{a}x=b$ then $a^b=x$.
	\item [Step 4] Solve the equation for the unknown variable.
\end{description}
\end{tcolorbox}

\textbf{Example 1} Solve $\ln  x =5$\medskip\\
\solution Take antilogarithms with base $e$:
\begin{align*}e^{5} &  = x \\
x &  \approx 148.4131\end{align*}

\textbf{Example 2} Solve $5 +4 \log  \left (5 x\right ) =17$
\begin{multicols}{2}\solution Isolate the log and solve:
\begin{align*}4 \log  \left (5 x\right ) &  = 17 -5 =12 \\
\log  5 x &  = 3 \\
\text{}10^{3} &  = 5 x \\
x &  = \frac{1000}{5} =200\end{align*}

Check: Substitute $x =200$
\begin{align*}\text{LHS} &  = 5 +4 \log  \left (5 \times 200\right ) \\
&  = 5 +4 \log  1000 =5 +4 \log  10^{3} \\
&  = 5 +4 \times 3 =5 +12 =17 =\text{RHS}\end{align*}
\end{multicols}
\clearpage
\begin{multicols}{2}
\textbf{Example 3} Solve $\log  x +\log  \left (x -1\right ) =\log  4 x$\\ \solution
\begin{align*}\log  x +\log  \left (x -1\right ) -\log  4 x &  = 0 \\
\log  \frac{x \left (x -1\right )}{4 x} &  = 0 \\
\log  \frac{1}{4} \left (x -1\right ) &  = 0 \\
\text{}10^{0} &  = \frac{1}{4} \left (x -1\right ) =1 \\
x -1 &  = 4;\, x=5\end{align*}
Check:
\begin{align*}\text{LHS} &  = \log  5 +\log  4 =\log  \left (5 \times 4\right ) =\log  20 \\
\text{RHS} &  = \log  4 \times 5 =\log  20 =\text{LHS}\end{align*}
\columnbreak

\textbf{Example 4} The velocity of a sky diver $t$ seconds after jumping is given by
\begin{equation*}v \left (t\right ) =80 \left (1 -e^{ -0.2 t}\right )
\end{equation*}
After how many seconds is the velocity $70$ $\mbox{ft}$/$\mbox{s}$?\\
\solution\begin{align*}70 &  = 80 \left (1 -e^{ -0.2 t}\right ) \\
\frac{70}{80} &  = 1 -e^{ -0.2 t} \\
e^{ -0.2 t} &  = 1 -\frac{70}{80} \\
&  = 1 -\frac{7}{8} =\frac{1}{8} =0.125 \\
\text{} -0.2 t &  = \ln  0.125 \\
t &  = \frac{\ln  0.125}{ -0.2} \approx 10.39\text{}\mbox{s}\end{align*}
\end{multicols}

%---------------------------------------------------
% Exponential Modelling
%---------------------------------------------------
\section{Exponential Modelling}
The natural exponential function, $e^x$, is used in a variety of situations where there is exponential growth or decay.

\example The exponential function can be used to model the way populations grow and diseases spread. The following
example is about the spread of an infectious disease in a small city whose population is $10,000$. After $t$ days the number of people who have caught the disease is modelled by the function
\begin{equation*}f (t) =\frac{10000}{5 +2495 e^{ -0.84 t}}
\end{equation*}

\begin{tasks}
	\task How many people had the disease initially?
	\textit{Initially} in this sense means right at the beginning, or when the clock is still at zero. Substitute $t=0$ into the function:
	\[f(0)=\frac{10000}{5+2495e^0}=\frac{10000}{2500}=4\text{ people}\]
	\task How many people have the disease after 1 day?
	Substitute $t=1$ into the function:
	\[f(1)=\frac{10000}{5+2495e^{-0.84}}=\frac{10000}{5+2495(0.4317)}=\frac{10000}{1082.1}\approx 9.24;\text{ 9 people}\]
	\task How many people have the disease after 5 days?
	Following from part (b), find $f(5)$:\\
	\[f(5)=\frac{10000}{5+2495e^{-0.84(5)}}=\frac{10000}{42.41}\approx 235.77;\text{ 236 people}\]
	\task Use desmos to graph the function and describe its behaviour. \\
	\includegraphics[width=\textwidth]{modelling1}
\end{tasks}

The graph has distinctive characteristics. It starts at a particular non-zero value (when $t =0$) and increases slowly at first then more rapidly. It slows down after a time and levels off because the exponential function in the denominator $ \leadsto 0$ when $t \leadsto \infty $. Graphs with these characteristics are called logistic curves. The particular model is called a logistic growth model.

\examq\medskip \\In the winter of 2019 the number of people contracting the measles virus grew substantially in the Auckland region. The plot shows the number of confirmed cases with data indicating 546 cases as of August 20, 2019.
\begin{center}
	\includegraphics[width=11cm]{measles}
\end{center}
\begin{tasks}
	\task What type of mathematical model (function) would you expect to fit the data?\\
	\[\text{This data most closely resembles an exponential function.}\]
	\task Using Excel, a mathematical formula has been fit to the data:	$\displaystyle f(t)=8.06e^{0.0272t}$ where $t$ is measured in days. How many cases were originally reported?\\
	\[\text{Sub in $t=0$ to find the initial number of cases in the data.}\]
	\[f(0)=8.06e^0=8.06 \text{ cases}\]
	Remember the model is an approximation of the data so it is likely that there were 8 cases to start with.

	\task How many days have passed between the initial data point and August 20?\\
	\begin{align*}\text{Solve for \textit{t} knowing that }f(t)&=546\\
	546&=8.06e^{0.0272t}\\
	\frac{546}{8.06}&=e^{0.0272t}\\
	\ln\left(\frac{546}{8.06}\right)&=0.0272t\\
	t&=\frac{4.2157}{0.0272}=154.989\approx 155\text{ days}\\
	\end{align*}
\end{tasks}

%---------------------------------------------------
% Chapter Exercises in a separate file
%---------------------------------------------------
\section{Chapter Exercises}
\subimport{}{3ExpExercises}

% END ----------------------------------------------


\documentclass[11pt,a4paper]{article}
\renewcommand{\baselinestretch}{1.05}

\usepackage{amsbsy,amstext,amsmath,graphicx}

\usepackage[dvipdfm]{color}
\definecolor{darkred}{rgb}{0.8,0,0}

\newcommand{\bs}{\boldsymbol}
\newcommand{\nuc}[2]{\mbox{$^{#1}$#2}}

\addtolength{\textwidth}{3cm}
\addtolength{\oddsidemargin}{-1.5cm}
\addtolength{\evensidemargin}{-1.5cm}
\addtolength{\textheight}{2\baselineskip}
\addtolength{\topmargin}{-\baselineskip}

\renewcommand{\descriptionlabel}[1]{\hspace\labelsep\normalfont\ttfamily #1}
\newcommand{\sys}{{\tt spin\_system}}
\newcommand{\cmx}{{\tt cmatrix}}
\newcommand{\rmx}{{\tt rmatrix}}
\newcommand{\llist}{{\tt ListList<T>}}
\newcommand{\spacet}{{\tt space\_T}}
\newcommand{\cvector}{{\tt List<complex>}}
\newcommand{\rvector}{{\tt List<double>}}
\newcommand{\libname}{{\tt libcmatrix}}
\newcommand{\ket}[1]{\ensuremath{\langle #1 \rangle}}
\newcommand{\eq}[1]{Eqn.~(\ref{#1})}
\newcommand{\lp}{\hspace{2em}}
\newcommand{\indexheader}[2]{{\tt #1}\index{#2@{\tt #1}}}

\usepackage[colorlinks=true,linkcolor=darkred,dvipdfm]{hyperref}
%\usepackage[colorlinks=true]{hyperref}

\begin{document}

\begin{center}
\Large {\tt crystal} module of {\tt libcmatrix}\\
\large (experimental version)
\end{center}

This code provides a way to generate Hamiltonians and spin operators
for spin systems with permutation symmetry, in particular resulting
from translational symmetry.

Existing \libname\ functions can be used
to calculate operators in the conventional Zeeman eigenbasis that can then be
block-diagonalised by unitary transformations by matrices of the form
\begin{equation}
\begin{pmatrix}
1 & 1 & 1 & \dots \\
1 & e^{2\pi i/n} & e^{4\pi i/n} & \dots \\
\vdots & \vdots & \ddots &
\end{pmatrix}
\label{Vmatrix}
\end{equation}
where $n$ is the number of states in a set linked by permutation.
$n$ is necessarily a factor of $N$---the number of spins being permuted.
This approach is adequate for small problems, but is unsuited to large
problems.  Most importantly, it doesn't allow larger spin systems
to be studied.

A better solution is to calculate the spin operators etc.\
directly in the symmetrised basis.  The resulting matrices are smaller
by a factor of $\sim N$, allowing for much more efficient calculation
(by a factor of $N^2$) for a given $N$, or larger problems
to be solved.  Although only an extra $\log_2 N$ spin-1/2 spins can
be added, the efficiency savings do make calculations on large
(say $>10$) spins a realistic possibility.

There are limitations to the current implementation:
\begin{itemize}
\item Limited to spin-1/2.  Extension to other spin quantum numbers
or mixed spin systems would not be too difficult, but is of relatively
little interest.  Large spin systems are only relevant to strongly
coupled systems, which is rarely an issue outside of spin-1/2 NMR\@.
The existing {\tt libcmatrix} functions can be used here in any case.

\item Limited to cyclic permutations of all spins, corresponding
to one-dimensional translational symmetry (with periodic boundary).
The restriction to one dimension of translational symmetry
is a major one.  Adding additional \emph{point} group symmetries
e.g.\ mirror planes, is not particularly useful since additional
block diagonalisation is restricted to ``special'' values of the
translational eigenvalue, $k$, notably $k=0$.
Adding ``independent'' symmetries such as additional translational
axes would be useful.  This would require some major addition to the
code (effectively all the functions would take on forms that
handled two, three etc.\ $k$ eigenvalues), but is not impossible.
Unfortunately the size of problem that
could be considered is small, even for just 2 dimensions, and may not be sufficient to be
convincing.

\item Only one level of ``$m_z$ blocking'' is supported.  Under free precession,
$m_z$ is a good quantum number for each nucleus type (high-field approximation).
In this case, blocking is limited to the \emph{total} $m_z$, or to one nucleus
type.

\item Although the functions are intended to resemble existing
functions closely, a perfect match
(e.g.\ having a {\tt periodicspin\_system} that ``looked''
like a {\tt spin\_system}) is impossible.  Code that uses
these functions will always be signficantly more involved.

\end{itemize}

\section{Setting up the problem}

Two data objects are declared in {\tt crystal.h}; {\tt CrystalSpec}
``specifies'' the symmetry by declaring which spin states are
related by symmetry.  Adding different permutation symmetries
other than 1D translational is a matter of generating the correct
{\tt CrystalSpec}, but is still restricted to a single ``eigenvalue''.
{\tt CrystalSystem} then uses the information from a {\tt CrystalSpec} object to
create spin operators.  A {\tt CrystalSpec} is initialised using
\begin{description}
\item[CrystalSpec(spinhalf\_system {\it sys},$N$,bool {\it mzblock},{\it neigs})] creates
the ``symmetry specification'' for $N$ cells of a given system of spin-1/2 spins.  The {\it mzblock}
flag should be {\tt true} if the states will be blocked by $m_z$ quantum
number i.e.\ free-precession problems, or not.  {\it neigs} is the number
of ``active'' eigenvalues; typical values are $N$ (also the default if omitted),
or $(N+1)/2$ which corresponds to positive values of $k$ only (the translational
eigenstates are numbered 0 to $N-1$ where $N-1$ corresponds to $k=-2\pi/N$ etc.).
Note that the optional $m_z$ blocking is via the {\emph total} $m_z$ quantum number
which will not be appropriate for all heteronuclear problems.
\item[CrystalSpec(spinhalf\_system {\it sys},$N$,char* {\it label},{\it neigs})] allows a system
to be blocked by $m_z$ of a chosen nucleus e.g. {\tt "13C"} etc.  This is necessary
if $m_z$ is only a good quantum number for one set of spins in a heteronuclear system.
\end{description}

\begin{center}
\centerline{\includegraphics[width=5.5in]{eigsfig.eps}}
\end{center}

As can be seen in the diagram above, the eigenvalues can be divided
into ``general'' values of $k$ which occur in pairs ($k$ and $-k$)
and ``special'' values $k=0$ plus $k=\pi$ if $N$ is even.
If the original Hamiltonian is symmetric (i.e.\ purely real),
then $H_{k}=H_{-k}$.  In favourable cases, the evolution can
then be calculated using only the postive values of $k$
(remembering to double the weighting of signals from general $k$),
halving the calculation time for large $N$.  This relationship breaks down
for sample spinning; presumably because the directionality of the rotation
breaks the relationship between $k$ and $-k$.  There may also be some
possible speedups using the relations between $k$ and $k+\pi$ ($N$ even only).

At the special values of $k$, $H_k$ is real for real starting Hamiltonians
(at general values of $k$ the symmetrised Hamiltonian is necessarily complex,
albeit hermitian).  Since operations such as diagonalisation are typically
a factor of 3 faster for purely real matrices, this is a useful efficiency
gain, albeit one that becomes less important as $N$ increases.

Although the contents of {\tt CrystalSpec} are generally only
accessible to {\tt CrystalSystem}, there are a couple of member functions
that can be used to interrogate the object:
\begin{description}
\item[List<size\_t> permutation\_vectorH()] returns the permutation
that ``translates'' states by one unit cell.
\item[ListList<state\_t> linkedstates()] returns the states broken
down into sets linked by the (translation) symmetry.
\end{description}

The convention  $j=Mc+j'$ is used to relate the ``spatial'' definition
of a spin in terms of unit cell number, $c$, and index within the cell, $j'$
to spin index
within the spin system, $j'$ (the spin system is always ``flat''). The
function {\tt cell\_to\_spin($M$,$c$,$j'$)} should be used to
return $j$ for a given cell and spin index.

Most NMR parameters are defined over the $M$ spins in the unit cell.
Dipolar couplings, however, are defined between the couplings within cell 0
and between cell 0 and the other cells.  The translational symmetry dictates
that the couplings between cells $c_1$ and $c_2$, for example, are identical
to those between cell 0 and cell $c_2-c_1$.  The coupling network must be
cyclic, so cell $N-1$ can be considered as cell $-1$ etc.

\section{Using the {\tt CrystalSystem} object}

The {\tt CrystalSystem} is initialised from a {\tt CrystalSpec}:
\begin{description}
\item[CrystalSystem(CrystalSpec {\it defin})] creates a {\tt CrystalSpec} object for
the complete space of {\it defin} (no $m_z$ blocking).
\item[CrystalSystem(CrystalSpec {\it defin}, {\it bra $m_z$}, {\it ket $m_z$})]
creates a {\tt CrystalSpec} object spanning a given coherence block, specified
in terms of the $m_z$ values of bra and ket sub-spaces.  A {\tt Failed}
exception thrown if the {\tt CrystalSpec} does not use $m_z$ blocking.
\end{description}

Once the object is defined, it can then be used to generate spin
operators.  Its use differs from typical
spin-operator generators such as {\tt spin\_system} and {\tt spinhalf\_system}
in the following ways:
\begin{itemize}
\item Rather than return a single matrix, most functions return
the complete manifold for the $k$ states under consideration (as set up
in the {\tt CrystalSpec}).  This is the most efficient way to generate
the spin operators, but other functions allow operators to be calculated
for specific values of $k$, which is useful if memory is tight.

\item Special attention is required when there are less than two states
in the relevant $k$ subspace.  In normal calculations, these cases are
generally obvious and easily accounted for.  In periodic calculations
using $m_z$ blocking, however, small subspaces occur quite frequently and it is useful
to handle them efficiently.  For example, the single state of maximum (or
minimum) $m_z$ generates trivially one state of $k=0$ only.

\item The homonuclear dipolar coupling Hamiltonian requires special attention.
Normally this is constructed by summing product operator expressions
for all the spin pairs.  This is not practical for large (or even medium)
sized problems.  Instead special functions construct the symmetrised
dipolar coupling Hamiltonian from a specification of the coupling network.
The other spin Hamiltonians do not require special treatment and
can be constructed from spin operators relatively efficiently.

\end{itemize}

The simple spin operator functions are
\begin{description}
\item[I(List<cmatrix>\&, $n$, {\it op})] calculates the symmetrised
operator, where $n$ is the spin index $0$ to $MN-1$ (although only
the index modulo $N$ is significant), and {\it op} is {\tt 'x'}, {\tt 'y'}
etc.  The destination is a list of complex matrices, where matrix 0
corresponds to $k=0$ etc.  If a particular $k$ value is not represented
in the selected sub-space, the corresponding matrix will be ``undefined''.
Sub-spaces of size 1 are not treated specially.
\item[I(cmatrix\&,$n$,{\it op},$k$)] returns the spin operator for the specified $k$.
The function above should be used whenever all the eigenvalue blocks are
needed; this function is useful for large problems where there is insufficient
memory to work with all the $k$ states at the same time.
\item[F(List<cmatrix>\&, {\it op})] calculates a symmetrised sum operator (over all spins).
\item[F(List<cmatrix>\&, char* {\it label},{\it op})] restricts the summation to a particular nucleus type.
\item[F(cmatrix\&, {\it op}, $k$) {\rm and} F(cmatrix\&, char* {\it label}, {\it op}, $k$)] calculate a symmetrised sum operators for a given $k$ eigenvalue.
\item[ListList<double> diag\_Iz($n$)] returns a $z$ operator in
``diagonal form''.  The result is a {\tt ListList} rather than the
less efficient {\tt List< List<double> >}.  {\tt result(0)}, for example,
is a {\tt BaseList<double>} corresponding to $k=0$.
\end{description}
There are also more basic {\tt mla} functions that can be used to
accumulate (scaled) spin operators efficiently.
N.B.\ The spin operator functions use temporary workspace within the {\tt CrystalSystem}
object, hence a multi-threaded calculation should not share
{\tt CrystalSystem} objects, but rather each thread should use its own (the overhead
is tiny).

Because the $z$ operators can be stored compactly, it makes sense
to calculate these once at the start of the calculation.  Full spin operators
are generally too large to be kept around and must be generated as needed.

The following functions calculate symmetrised (homonuclear) dipolar Hamiltonians.
In static problems, the coupling network is specified by a $M \times MN$  \rmx\, $\bs{d}$,
where $d_{ij}$ is the dipolar coupling between spin $i$ of unit cell``zero'' and
spin $j= M c + j'$ ($c$ is the unit cell, $j'$ is the index within the unit cell).
Note that the coupling network defined by $\bs{d}$ must be cyclic (as explained above).  Couplings that are identically zero are ignored.
%Functions that deal with Hamiltonians treat singly-degenerate matrix blocks
%separately, since $1 \times 1$ matrices are extremely inefficient to handle
%and they are usually special cases.

In spinning problems, it is necessary to provide a rank 2 tensor (as a {\tt space\_T}) to define the strength and orientation of the dipolar interaction.
Rather than return a {\tt List<cmatrix>}, the functions create a {\tt List< Tensor<cmatrix> >} i.e.\ for each value of $k$, the Hamiltonian is defined in terms
of components $H^{(l)}_m$ which transform as rank $l$ spherical tensors ($l$ is always 2).
Note that the functions also take the $\bs{d}$ matrix in addition to the spatial
tensor information, where the $d_{ij}$ are just used to determine whether a
particular interaction is to be included or not.

\begin{description}
\item[sym\_Hdipolar(List<cmatrix>\& $H$, List<double>\& $h$, rmatrix $\bs{d}$)] creates
the symmetrised dipolar coupling Hamiltonian defined by coupling network $\bs{d}$.
If the coupling is heteronuclear (as defined by the initial {\tt spinhalf\_system}), only the
secular components of the dipolar Hamiltonian are used.
\emph{If the $k$ block contains a
single state, the symmetrised element is stored in $h(k)$ of the $h$ vector
and the corresponding $H$ matrix will be undefined.}

\item[sym\_Hdipolar(cmatrix\& $H$, double\& $h$, $\bs{d}$, $k$)] stores the dipolar Hamiltonian for a particular $k$ value in $H$ or $h$.  This function is for large
problems where memory is insufficient to handle all $k$ values at the same time.
\item[double sym\_Hdipolar\_element($\bs{d}$)] handles the special case where the Hilbert space contains
a single state (i.e.\ {\tt rows()} is 1).  It returns the single element of the dipolar Hamiltonian.
\item[sym\_Hdipolar(List< Tensor<cmatrix> >\& $H$, List<space\_T>\& $h$,$\bs{d}$, Matrix<space\_T> $\bs{D}$)] calculates the Fourier components $H^{l}_m$ of the dipolar
Hamiltonian under spinning\footnote{By default, magic angle spinning is assumed for the sake of efficiency, but this can be easily changed}.  Single-element $k$ blocks are stored in the simple {\tt space\_T}, $h$.
\item[sym\_Hdipolar(Tensor<cmatrix>\& $H$, space\_T\& $h$,$\bs{d}$,$\bs{D}$,$k$)] calculates the Fourier components for a single value of $k$.
\item[complex sym\_Hdipolar\_element($\bs{d}$,$\bs{D}$,$k$)] return the single element of
the dipolar Hamiltonian for the special case of a Hilbert space consisting of a single state.
\end{description}

Other member functions of {\tt CrystalSystem}
\begin{description}
\item[isdiagonal()] returns {\tt true} if the Hilbert space is diagonal (always true
if no $m_z$ blocking).
\item[rows() \& cols()] return the dimensions of the Hilbert space.
\item[rows($k$) \& cols($k$)] return the dimensions of a particular eigenvalue block
of the symmetrised space.
\end{description}

\section{How it works}

The mathematics of the symmetrisation is essentially limited to
Equation~(\ref{Vmatrix}).  The complications lie in the book-keeping of
combining the right states and putting the result in the right place.
The spin operator generating functions use a {\tt CrystalSystem\_iterator} to
iterate over each set
of symmetry-linked states, generating elements of the symmetrised operators.
For instance, if sets $i$ and $j$ both contain $N$ states, the $N \times N$
block of the original operator is first calculated and then transformed
(by the {\tt symmetrise} internal functions)
to generate a diagonal vector containing $N$ elements corresponding to the
$N$ values of $k$.  These are then placed into the $i,j$ elements of the
output matrix blocks (by the {\tt place} functions).  Things are complicated somewhat by the presence (for
non-prime $N$) of sets that contain less than $N$ states, but this is
essentially book-keeping.

Various special cases are considered to make the whole thing go faster:
\begin{itemize}
\item Diagonal spin operators: only diagonal $i,i$ blocks need be considered
and the maths can be further simplified.
\item For simple spin operators, it is more efficient to calculate the symmetrised
matrix elements directly rather than transform a fairly sparse matrix.
\item In the dipolar coupling Hamiltonian, it is not necessary to consider
all the $MN(MN+1)/2$ couplings.  The symmetry allows us to consider
just the couplings from (and within) cell 0 ($\sim M^2N$) and simply multiply the
symmetrised Hamiltonian by $N$.
\item $k=0$ can be handled specially.  If the original matrix is real, the $k=0$ block is also real.  In this implementation, the results are always stored
in complex matrices which need to be turned into real versions before
functions such as {\tt symmetric\_eigensystem} can be used.
The is somewhat wasteful, but the wastage is $O(n^2)$ compared to $O(n^3)$
for the major time-takers.
\end{itemize}

Profiling a program that uses {\tt crystal.h} shows
the vast majority of the time is spent in diagonalisation, matrix multiplication etc.,
i.e.\ the overhead of symmetrisation is not significant.

\end{document}


% !TEX root = main.tex
% !TEX spellcheck = en-US
\section{Introduction}
Zero-knowledge proof systems that allow a prover to convince a verifier of a statement without revealing anything beyond the truth of the statement have applications in cryptography and theory of computation~\cite{FOCS:GolMicWig86,STOC:Fortnow87,C:BGGHKMR88}.
When restricted to computationally sound proofs, called \emph{argument systems}, proof length can be shorter than the length of the witness~\cite{brassard1988minimum}.
Zero-knowledge Succinct Non-interactive ARguments of Knowledge (zkSNARKs) are zero-knowledge argument systems that additionally have a succinctness property -- small proof sizes and fast verification.
Since their introduction in~\cite{micali1994cs}, zk-SNARKs have been a powerful and versatile design tool for secure cryptographic protocols. They became particularly relevant for blockchain applications that demand short proofs and fast verification, such as privacy-preserving cryptocurrencies~\cite{SP:BCGGMT14} in Zcash and scalable and private smart contracts in Ethereum\footnote{\url{https://z.cash/}, \url{https://ethereum.org}}.

The work of~\cite{EC:GGPR13} proposed a preprocessing zk-SNARK for general NP statements phrased in the language of Quadratic Span Programs (QSP) and Quadratic Arithmetic Programs (QAP) for Boolean and arithmetic circuits respectively. This built on previous works of~\cite{IKO07,AC:Groth10a,TCC:Lipmaa12} and led to several works~\cite{TCC:BCIOP13,SP:PHGR13,C:BCGTV13,AC:Lipmaa13,USENIX:BCTV14,EC:Groth16} with very short proof sizes and fast verification.
The line of work on pre-processing zkSNARKs has seen rapid progress with many works proposing significant improvements in efficiency of different parameters like proof size, verifier efficiency, complexity of setup etc.
Most modern zkSNARK constructions follow a modular blueprint that involves the design of an information theoretic interactive protocol, e.g. an Interactive Oracle Proof (IOP), that is then compiled via cryptographic tools to obtain an interactive argument system.  This is then turned into a zkSNARK using the Fiat-Shamir transformation in the Random Oracle Model (ROM).
In particular, several schemes such as
$\sonic$~in \cite{CCS:MBKM19}, $\plonk$~\cite{EPRINT:GabWilCio19}, $\textsf{Marlin}$~\cite{EC:CHMMVW20}
follow this approach where the information theoretic object is an algebraic variant of IOP, and the cryptographic primitive in the compiler is a polynomial commitment scheme (PC).

\paragraph{Simulation extractability.}

Most zkSNARKs are shown to satisfy a standard knowledge soundness property. Intuitively, this guarantees that
a prover that creates a valid proof knew a valid witness. However, deployments of zkSNARKs in real-world applications require a stronger property -- \textit{simulation-extractability} (SE).
This is because, in practice, an adversary against the zkSNARK has access to proofs provided by other parties using the same
zkSNARK. The definition of knowledge soundness ignores the ability of an adversary to see other valid proofs that may occur in real-world applications.  For instance, in applications of
zkSNARKs in privacy-preserving blockchains, proofs are posted on the chain for all
blockchain-participants to see. Therefore, it is necessary for a zero-knowledge proof system to be \emph{non-malleable}, that is, resilient against adversaries that additionally get to see proofs generated by different parties before trying to forge.
Therefore, it is necessary for a zero-knowledge proof system to be \emph{simulation-extractable}, that is, resilient against adversaries that additionally get to see proofs generated by different parties before trying to forge.
This captures the more general scenario where an adversary against the zkSNARK has access to proofs provided by other parties as it is in applications of zkSNARKs in privacy-preserving blockchains, where proofs are posted on the chain for all
participants in the network to verify.

\paragraph{zkSNARKs in the updatable setting.}
One of the downsides of efficient zkSNARKs like~\cite{AC:Groth10a,TCC:Lipmaa12,EC:GGPR13,SP:PHGR13,AC:Lipmaa13,AC:DFGK14,EC:Groth16} is that they rely on a \textit{trusted setup}, where there is a structured reference string (SRS) that is assumed to be generated by a trusted party. In practice, however, this assumption is not well founded; if the party that generates the SRS is not honest, then they can produce proofs of false statement. That is, if the trusted setup assumption does not hold, knowledge soundness breaks down.
Groth et al~\cite{C:GKMMM18} propose a setting to tackle this challenge which allows parties -- provers and verifiers -- to \emph{update} the SRS, that is, take a current SRS and contribute to it randomness in a verifiable way to obtain a new SRS. The guarantee in this \textit{updatable setting} is that knowledge soundness holds as long as one of the parties who updates the SRS is honest. The SRS is also \emph{universal}, in that it does not depend on the relation to be proved but only an upper bound on the size of the statements.
Although inefficient, as the SRS length is quadratic to the size of the statement,~\cite{C:GKMMM18} set a new
paradigm of universal updatable setting for designing zkSNARKs.

The first universal zkSNARK with updatable and linear size SRS was
$\sonic$ proposed by Maller et al.~in \cite{CCS:MBKM19}. Subsequently, Gabizon et
al.~designed $\plonk$~\cite{EPRINT:GabWilCio19} which currently is the
most efficient updatable universal zkSNARK. Independently, Chiesa et
al.~\cite{EC:CHMMVW20} proposed $\textsf{Marlin}$ with comparable efficiency to
$\plonk$.

\paragraph{The challenge of SE in the updatable setting.}

The notion of simulation-extractability for zkSNARKs which is well motivated in practice has not been studied in this updatable setting.
Consider the following scenario: an instance proof pair with respect to some SRS is available for public verification, $(\srs,x,\pi)$. Now, if there is a new purported proof $(\srs',x,\pi')$ with respect to an updated $\srs'$, we would like the guarantee that the prover must have known a witness corresponding to $x$, and therefore computed $\pi'$. Since everybody is allowed to update an SRS, the ability for an adversary to perform an update $\srs$ to $\srs'$, and ``move" the proof $\pi$ from the old SRS to a proof $\pi'$ for the new SRS without knowing a witness clearly violates security. That is, even an adversary who knows the trapdoor for the update from $\srs$ to $\srs'$ should not be able to break SE as long as there was at least one honest update to $\srs$.

As it turns out, defining SE for updatable SRS zkSNARKs requires some care.
Since the SRS is being continually updated, there are proofs with respect to \textit{different} SRSs available for the adversary to see before attempting to forge a proof with respect to a current SRS.
That is, each SRS in the update chain spawns a simulation oracle. Intuitively, the updatability of the SRS allows an adversarial prover to contribute to updating, and see proofs with respect to different updated SRSs before attempting to provide a proof for a false statement (potentially output a proof wrt a SRS that is different from the SRSs corresponding to all the simulated proofs seen). A definition of SE in the updatable setting should take into account this additional power of the adversary, which is not captured by existing definitions of SE.
While generic lifting techniques/compilers~\cite{EPRINT:KZMQCP15,CCS:AbdRamSla20} can be applied to updatable SRS SNARKs to obtain SE, not only do they inevitably incur overheads and lead to efficiency loss, we contend that the standard definition of SE does not suffice in the updatable setting.

\paragraph{Fiat--Shamir.}
The Fiat--Shamir (FS) transform takes a public-coin interactive protocol and
makes it interactive by hashing the current protocol transcript to compute the
verifier's public coins. While in principle justifiable in the random oracle
model (ROM)~\cite{CCS:BelRog93}, it is theoretically
unsound~\cite{FOCS:GolKal03} and so only a heuristic that should be used with
care.
%
The FS transform is a now popular design tool in constructing
zkSNARKs. In the updatable universal SRS setting, works like \sonic{}~\cite{CCS:MBKM19}
\plonk{}~\cite{EPRINT:GabWilCio19}, and \marlin~\cite{EC:CHMMVW20} are designed
and proven secure as multi-round interactive protocols. Security is then only
\emph{conjectured} for their non-interactive variants by employing the FS
transform.

We investigate the non-malleability properties of a class of zkSNARK protocols obtained by FS-compiling multi-round protocols in the updatable SRS setting and give a modular approach to analyze non-malleablilty of zkSNARKs.

\subsection{Our Contributions}
\begin{itemize}
\item
\emph{Updatable simulation extractability (USE)}.
We propose a definition of simulation extractability in the updatable SRS setting called USE, that captures the additional power the adversary gets by having access to updating the SRS and seeing proofs with respect to different SRSs.

\item
\emph{General theorem for USE of FS-compiled interactive protocols.}
We then show that a class of interactive proofs of knowledge that are honest-verifier zero-knowledge,
have a unique response property, and satisfy a property we define called forking soundness \emph{are USE out-of-the box} in the random oracle model when the Fiat--Shamir transformation is applied to them.
Informally, our notion of forking soundness is a variant of special soundness where the transcripts provided to the extractor are
obtained through interaction with an honest verifier, and the extraction guarantee is computational instead of unconditional.
Our extractor only needs oracle access to the adversary, it does not depend on the adversary’s code, nor relies on knowledge
assumptions.

\item
\emph{USE for concrete zkSNARKs.}
We then prove that the most efficient updatable SRS SNARKS -- Plonk/Sonic/Marlin -- satisfy the notions necessary to invoke our general theorem, thus showing that these zkSNARKs are updatable simulation extractable.
Proving that these protocols satisfy the required properties is done in the algebraic group model (AGM).

%\item
%We make several technical contributions along the way. Our generalized forking lemma is of independent interest.
\end{itemize}

\subsection{Technical Overview}
%unique response, forking soundness. general theorem without additional assumptions. to apply the theorem to concrete schemes like plonk, we show it satisfies unique response, forking soundness, in AGM.

The proof of our general theorem for USE is, at a high level, along the lines of the proof of SE for FS-compiled sigma protocol
from~\cite{INDOCRYPT:FKMV12}. However, we need new and stronger notions as we consider proof systems that are
richer than simple sigma protocols. We discuss some of the technical challenges below.

\plonk~\cite{EPRINT:GabWilCio19} and \sonic~\cite{CCS:MBKM19} were originally presented
as interactive proofs of knowledge that are made non-interactive by the Fiat--Shamir transform. In the following,
we denote the underlying interactive protocols by $\plonkprot$ (for $\plonk$)
and $\sonicprot$ (for $\sonic$) and the resulting non-interactive proof systems by
$\plonkprotfs$ and $\sonicprotfs$, respectively.

\oursubsub{Forking soundness.}
Following~\cite{INDOCRYPT:FKMV12}, one would have to show that for the protocols we consider, a witness can be extracted from sufficiently many valid transcripts with a common prefix. However, many protocols
do not meet the standard definition of special soundness for sigma protocols, that requires extraction of a witness from any two transcripts, with the same first message. We put forth a notion analogous to special soundness, that is more general and applicable to a wider class of protocols -- protocols that are more than three rounds, and rely on an SRS. For $\plonkprot$ and
$\sonicprot$ that are not three move protocols, the definition needs to be adapted. Furthermore, the number of transcripts
required for extraction is more than two. Concretely, $(3 \noofc + 1)$---where $\noofc$ is the
number of constraints in the proven circuit---for $\plonkprot$ and
$(\multconstr + \linconstr + 1)$---where $\multconstr$ and $\linconstr$ are the
numbers of multiplicative and linear constraints---for $\sonicprot$. Hence, we
do not have a pair of transcripts, but a \emph{tree of transcripts}.

In protocols that rely on SRS that come with a
trapdoors, an adversary in posession of the trapdoor can produce multiple
valid proof transcripts without knowing the witness and potentially for false
statements. This is true even in the updatable setting, where there exists a trapdoor for any updated SRS.
Recall that the standard special soundness definition requires
witness extraction from \emph{any} tree of acceptable transcripts that share a
common root. This means that there are no such trees for false
statements. We define a different, forking lemma-related, version
of soundness that we call \emph{forking soundness}. Forking soundness guarantees that it is
possible to extract a witness from all (but negligibly many) trees of accepting
transcripts produced by probabilistic polynomial time (PPT) adversaries, given
that the trees are generated as interactions between a (possibly malicious)
prover and an honest verifier. That is, if extraction from such a tree fails, then we break an
underlying computational assumption.

\oursubsub{Unique response property.}
Another property required to show USE is the unique response property~\cite{C:Fischlin05} which
says that for $3$-messages sigma
protocols, all but the first message sent by the prover are
deterministic (intuitively, the prover can only employ fresh randomness in the
first message of the protocol). We cannot use this definition as is since the protocols we consider have other rounds where the prover messages are randomized. In $\plonkprotfs$, both the first and the second prover's messages are randomized. Although $\sonicprot$ prover is deterministic after it picks its first message, the protocol has more than $3$ rounds. We propose a generalisation of the
definition which states that a protocol is $\ur{i}$ if the prover is
deterministic starting from its $(i + 1)$-th message. For our proof it is
sufficient that this property is met by $\plonkprot$ for $i = 2$. Since
\sonic{}'s prover is deterministic from the second message on, it is $\ur{1}$.

\oursubsub{HVZK.}  In order to invoke our main theorem on $\plonkprotfs$ and
$\sonicprotfs$ to conclude USE, we also need to show that (interactive)
$\plonkprot$ and $\sonicprot$ are HVZK in the standard model. Although both
$\sonic$ and $\plonk$ are zero-knowledge, their simulators utilize
trapdoors. However, for our reduction, we need simulators that rely only on
reordering the messages and picking suitable verifier challenges, without
knowing the SRS trapdoor.  That is, any PPT party should be able to produce a
simulated proof by its own in a trapdoor-less way. (Note that this property does
not necessary break soundness of the protocol as the simulator is required only
to produce a transcript and is not involved in a real conversation with a real
verifier). We show simulators for $\plonkprotfs$ and $\sonicprotfs$ that rely
only on the programmability of the RO, where programmability is only needed from
some round $i$ onwards.  \chaya{revisit this. is HVZK for the interactive
  protocol? then why programming? it might be a good idea to elaborate on why a
  trapdoor-based simulator does not work in the reduction. I am not sure I have
  clarity on this.}
\michals{16.09}{maybe we should just define Trapdoor-less simulatable (TLZK) protocols?}

\oursubsub{Generalisation of the general forking lemma.}
Consider an interactive $3$-message special-sound protocol $\ps$ and its
non-interactive version $\ps_\fs$ obtained by the Fiat--Shamir transform. The
general forking lemma provides an instrumental lower bound for the probability
of extracting a witness from an adversary who provides two proofs for the same
statement that share the first message. Since $\plonkprot$ and $\sonicprot$ have
more than $3$ messages and are not special-sound, the forking lemma of Bellare
and Neven~\cite{CCS:BelNev06}, cannot be used directly. We propose a
generalization that covers multi-message protocols where witness extraction
requires more transcripts than merely two.  Unfortunately, we also observe that
the security gap grows with the number of transcripts and the probability that
the extractor succeeds diminishes significantly; the security loss, albeit big, is polynomial.

Most modern zkSNARKs~\cite{SP:BBBPWM18,CCS:MBKM19} heavily
rely on the Fiat--Shamir transform and thus potentially the forking lemma. First, an interactive
protocol is proposed and its security and forking soundness analysed. Second,
one uses an argument that the Fiat--Shamir transform can be used to get a
protocol that is non-interactive and shares the same security properties.

We see our generalized forking lemma as contributing to a critical assessment of
this approach. The analysis of the interactive protocol is not enough and one
has to consider the security loss implied by the Fiat-Shamir transform for the target security notion. Thus one has to either rely on our generalisation of the forking
lemma or disclose a transformation that does not suffer this loss. We note that
the security loss may also apply when knowledge soundness is proven. That is the
case for the original $\sonic$ paper, whose security proof relies on so-called witness-extended
emulation. The authors of $\plonk$ and recent work on $\sonic$~\cite{cryptoeprint:2020:1351} work around this problem by proving
knowledge soundness directly in the AGM.

\subsection{Related Work}

\ourpar{Simulation extractability.}
There are many results on simulation extractability for
non-interactive zero-knowledge proofs (NIZKs). First, Groth \cite{AC:Groth07}
noticed that a (black-box) SE NIZK is
universally-composable (UC)~\cite{EPRINT:Canetti00}. Then Dodis et al.~\cite{AC:DHLW10} introduced a
notion of (black-box) \emph{true simulation extractability} and showed that no
NIZK can be UC-secure if it does not have this property.

In the context of zkSNARKs, the first
SE zkSNARK was proposed by Groth and Maller~\cite{C:GroMal17} and SE
zkSNARK for QAP by Lipmaa~\cite{EPRINT:Lipmaa19a}.
Kosba's et
al.~\cite{EPRINT:KZMQCP15} give a general transformation from a NIZK to a
black-box SE NIZK. Although their transformation works for zkSNARKs as well,
succinctness of the proof system is not preserved by the transformation.
Recently, Abdolmaleki et al.~\cite{CCS:AbdRamSla20} showed another transformation that
obtains non-black-box simulation extractability but also preserves
succinctness of the argument.
The zkSNARK of~\cite{EC:Groth16} has been shown to be SE by introducing minor modifications to the construction and making
stronger assumptions \cite{EPRINT:BowGab18,EPRINT:AtaBag19}. Recently,~\cite{EPRINT:BKSV20} showed that the
original Groth's proof system from~\cite{EC:Groth16} is weakly SE and
randomizable. None of these results are for zkSNARKs in the updatable SRS setting.

\ourpar{Forking lemma generalizations.}
There are several task specific variants, e.g.,~\cite{INDOCRYPT:HerSae03,CCS:BagCheJar08,AC:BelDaiLi19}, of the general forking lemma~\cite{JC:PoiSte00,CCS:BelNev06} for analyzing the forking behavior of random-oracle based executions.
In~\cite{EC:BCCGP16}, Bootle et al.~proposed a novel inner-product argument which
security relies on, so-called, witness-extended emulation. To show that
property, the authors proposed a new version of forking lemma, which gives a
lower bound on probability that a tree finding algorithm is able to produce a
tree of acceptable transcripts by rewinding a conversation between a
(potentially malicious) prover and verifier.

Although the result in that paper is dubbed a ``forking lemma'' it
differs from forking lemmas known from e.g.~\cite{JC:PoiSte00,CCS:BelNev06}.
First of all, the forking lemmas in these papers analyse the probability of building
a tree of acceptable transcripts for Fiat--Shamir based non-interactive proof
systems, while the protocol presented by Bootle et al.~is intended to work for
interactive proof systems.

Importantly, it is not obvious how the result of Bootle et al.~can be used to
show security of non-interactive protocols as it relies on interactive provers
whose proving strategies are more limited than proving strategies of
non-interactive provers. For example, if a challenge given by the verifier does not
suit an interactive prover, it can only try to finish a proof with it or
abort. On the other hand, a non-interactive prover has far wider scope of
possible actions--when the protocol is non-interactive the prover may
adapt its strategy based on the random oracle outputs.
This is reminiscent of \emph{state restoration} security~\cite{TCC:BenChiSpo16,EPRINT:Holmgren19} which is also about the security loss incurred by FS transformation for knowledge soundness from witness extended emulation.

Here, we directly capture the state restoration capability of the prover in the forking lemma instead of defining an interactive game where the prover can rewind the verifier to an earlier state as is done in~\cite{C:GhoTes21}.
The work of~\cite{C:GhoTes21} further shows that state restoration security gives tight security guarantees for the
non-interactive versions of Bulletproof~\cite{SP:BBBPWM18} and \sonic~.
Our work differs from~\cite{C:GhoTes21} in the following ways. First, they
focus on showing security of concrete proof systems, while we show
a general theorem about the security of a wide class of protocols.
Second, they only consider knowledge soundness, while we focus on the stronger notion of simulation extractability. Third, the proof of~\cite{C:GhoTes21} is in the AGM which allows for online extraction, whereas we aim to minimize our reliance on the AGM. In particular, our main theorem does not rely on AGM and we tackle technical challenges arising from extraction by rewinding.
However, note that we show that concrete protocols satisfy the preconditions of our main theorem in the AGM.


\documentclass[12pt]{article}
\usepackage{graphics}
\begin{document}

\section*{NYU Physics 1---Final Exam}

\vfill

\paragraph{Name:} ~

\paragraph{email:} ~

\paragraph{recitation:} ~

\vfill

This exam consists of six problems.  Write only in this booklet.  Be
sure to show your work.

\vfill

\emph{You must ensure that the proctor checks off your name on the
attendence sheet when you hand in your exam.  Your exam will
\textbf{not} be graded if your name is not checked off.}

\clearpage

\section*{Problem 1}

(a) A block of mass $M$ slides down a plane inclined at an angle
$\theta$ to the horizontal.  There is a coefficient of sliding
friction $\mu$ between block and plane.  What is the magnitude of the
acceleration $a$ of the block down the plane?  Be sure to draw a
free-body diagram.

\vfill

(b) A \emph{different} block of mass $M$ sits on the same plane.  In
this case, the frictional force is so great that the block does not
slide down the plane.  What is the magnitude $f$ and direction of the
frictional force?  Try to give your answer in terms of $M$, $g$ and
$\theta$ only.

\vfill ~

\clearpage

\section*{Problem 2}

A block of mass $M$, initially at rest, hangs from a massless string.
A bullet of mass $m$ travelling at speed $v$ lodges in the block.  The
block (now of mass $M+m$) recoils and swings on the string.  To what
maximum height $h_\mathrm{max}$ does the block swing, relative to its
starting position?

\clearpage

\section*{Problem 3}

A Japanese Shinkansen (bullet train) (of mass $M=2\times
10^5~\mathrm{kg}$), moving at $v_S=250~\mathrm{km\,h^{-1}}$ with
respect to the tracks, hits and collides elastically with a superball
(of mass $m=4~\mathrm{g}$), which is initially at rest.  The front
face of the train is inclined at an angle of $\theta=45~\mathrm{deg}$
to the horizontal, as shown.
\\ \rule{0.1\textwidth}{0pt}
\resizebox{0.8\textwidth}{!}{\includegraphics{../mp/shinkansen.eps}}

(a) Draw a diagram of the ball--train system, just before the
collision, in the center-of-mass rest frame, ie, as observed by an
observer at rest with respect to the center of mass.  Clearly show the
velocities of the ball and train in this frame.

\vfill

(b) What is the final speed and direction of the ball, immediately
after the collision, in the rest frame of the tracks (ie, \emph{not}
in the center-of-mass frame)?

\vfill ~

\clearpage

\section*{Problem 4}

(a) Why does a ball roll down an inclined ramp more slowly than a
frictionless block would slide down the same ramp?  Give a concise,
verbal, physical explanation.

\vfill

(b) Imagine rolling a solid spherical wooden ball and a thin steel
hoop down a plane inclined at an angle of 25~deg to the horizontal.
The wooden ball has mass $m=1~\mathrm{kg}$ and radius
$R=7~\mathrm{cm}$ and the steel hoop has mass $m=5~\mathrm{kg}$ and
radius $R=15~\mathrm{cm}$.  Assume that they both roll without
slipping.  In the absence of air resistance, which will roll down the
plane with greater acceleration?  Explain your answer with a concise,
verbal, physical explanation, backed-up with formulae \emph{only if
necessary.}  (It shouldn't be necessary.)

\vfill ~

\clearpage

\section*{Problem 5}

A ``seconds'' pendulum has a period of exactly 2.0 seconds.

(a) If $g=9.793~\mathrm{m\,s^{-2}}$ in Austin Texas, how long should a
Texan make her or his seconds pendulum?

\vfill

(b) If $g$ is 0.1~percent larger in Paris, France, than in Austin, how
different, in percent, should the length of a Parisian's seconds
pendulum be than a Texan's?  Should it be longer or shorter?
\emph{Note:} You can answer this question without getting part (a)
correct.

\vfill ~

\clearpage

\section*{Problem 6}

Consider the following attractive radial force law, which is
\emph{very different} from Newton's law of gravity:
\begin{equation}
F = \frac{k\,M\,m}{r^3}
\end{equation}
Where $k$ is a constant.  Consider a body of mass $m$ orbiting in a
circular orbit of radius $R$ around another body of mass $M$, with
$m\ll M$, according to the above force law.

(a) What are the dimensions of the constant $k$, in terms of kg, m and
s?

\vfill

(b) What is the period of the orbit $T$ as a function of radius $R$?

\vfill

(c) What is the potential energy of the mass $m$ at radius $R$,
relative to the potential energy at infinity?

\vfill ~

\clearpage

[This page intentionally left blank for calculations or other work.]

\end{document}