\documentclass[12pt]{article}
\usepackage{geometry}
\geometry{margin=1in}
\geometry{a4paper}

\usepackage{textcomp}
\usepackage{booktabs}
\usepackage{array}
\usepackage{paralist}
\usepackage{verbatim}
\usepackage{subfigure}
\usepackage{graphicx,caption}
\usepackage{placeins}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{dcolumn}
\usepackage{sectsty}
\allsectionsfont{\sffamily\mdseries\upshape}
\usepackage{gensymb,amsmath,mathtools,amssymb}
\usepackage{flafter}
%\usepackage{parskip}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tocbibind}
\usepackage[toc,page]{appendix}
\captionsetup{width=\linewidth}
\usepackage{bm}
\usepackage{url}
\usepackage{empheq}

\newcommand{\half}{\frac{1}{2}}

\graphicspath{{./figs/}}

\title{Passive Flight Solution}
\author{Devansh Agrawal}
%\date{}

\begin{document}

\maketitle

\section{Problem statement}

The dynamics of a rocket flying along the vertical axis (without thrust) can be written as

\begin{align}
\dot{h} &= v\\
\dot{v} &= -\frac{D}{m} - g = -\beta v^2  - g
\end{align}
where I have defined a modified ballistic coefficient
\begin{equation}
\beta = \frac{1}{2} \rho \frac{C_D A}{m}
\end{equation}

Since there is no thrusting, the mass is constant, and therefore $\beta$ is also constant.

Further we assign the following boundary conditions,

\begin{align}
h(0) &= h_0\\
v(0) &= v_0\\
v(t_f) &= 0
\end{align}

We wish to solve these equations, and determine the coasting distance.

\section{Coasting Distance}

Using Mathematica's DSolve function, we can solve this non-linear coupled ode. Mathematica returns two solutions (which have been simplified here)\footnote{$\log$ here refers to the natural logarithm}:

Solution 1 (invalid):
\begin{align}
h(t) &=h_0 + \frac{\log \left(\cos \left(\sqrt{\beta  g}(t_f-t)\right)\right)}{\beta }-\frac{\log \left(-\sqrt{\frac{g}{g+\beta  v_0^2}}\right)}{\beta }\\
v(t) &=\sqrt{\frac{g}{\beta }} \tan \left(\sqrt{\beta  g}(t_f-t)\right)
\end{align}

and solution 2 (valid):
\begin{align}
h(t) &=h_0 + \frac{\log \left(\sqrt{1+\frac{\beta  v_0^2}{g}} \cos \left(\sqrt{\beta  g}(t_f-t)\right)\right)}{\beta } \label{eqn:h}\\
v(t) &= \sqrt{\frac{g}{\beta }} \tan \left(\sqrt{\beta  g}(t_f-t)\right) \label{eqn:v}
\end{align}

Notice, that due to the second logarithm in solution 1, it must be invalid\footnote{or if you think about expanding the log(negative square root()) into negative half log(), the expression turns out to be same as solution 2}, and that the velocity in both solutions are identical. Therefore, solution 2 is the accurate flight path.

Immediately we can see from eqn~\ref{eqn:h} that the remaining height to go for the rocket is
\begin{equation}
\boxed{\Delta h = h(t_f) - h_0 = \frac{1}{\beta} \log \left(\sqrt{1+\frac{\beta  v_0^2}{g}} \right)}
\end{equation}

In the limit that drag is insignificant $\beta \rightarrow 0$, and the equation correctly approaches the kinematic result,

\begin{equation}
\lim_{\beta\rightarrow0} \Delta h = \frac{1}{2} \frac{v_0^2}{ g}
\end{equation}

The figure shows the results plotted.

%\FloatBarrier
\begin{figure}[htbp]
   \centering
   \includegraphics[width=0.8\linewidth]{coast_regions}
   \caption{This figure shows the combination of height to target and current flight speeds that will allow the rocket to coast to the target height. We see little dependence on the dry mass in the range of masses we are interested in. It is extremely important not to overshoot this line. The red lines shows the limiting case where the drag force can be neglected, and is a nice proxy for the case that drag cannot be accurately modelled.}
   \label{fig:}
\end{figure}
%FloatBarrier

%\FloatBarrier
\begin{figure}[htbp]
   \centering
   \includegraphics[width=0.8\linewidth]{impulsiveCorrection.eps}
   \caption{This figure shows the amount of propellant needed if an impulsive manoeuvre is to be used to get the current (h,v) point onto the coasting line (ie moving sideways on the graph). It is computed for a specific case of 20~kg dry mass, and shows that rather small amounts of propellant are needed (note, the propellant mass needed scales basically linearly with dry mass though). Less propellant should be needed for a non-impulsive manoeuvre. Therefore we could design the open loop trajectory aiming for 40~m/s at 300 m remaining, which gives us on the order 4 seconds to recompute and implement the final thrusting.}
   \label{fig:}
\end{figure}
\FloatBarrier

\section{Full Flight Path}

If we assume $v$ behaves well, we can solve eqn~\ref{eqn:v} for the final time using $t=0$,  and determine the flight profile:

\begin{empheq}[box = \fbox]{align}
t_f &= \frac{1}{\sqrt{\beta g}} \arctan{\left(v_0 \sqrt{\frac{\beta}{g}}\right)}\\
h(t) &= h_0 + \frac{1}{\beta} \log \left[\cos \left(t \sqrt{\beta  g}\right)+\sqrt{\frac{\beta  v_0^2 }{ g}} \sin \left(t \sqrt{\beta  g}\right)\right]\\
v(t) &= \sqrt{\frac{g}{\beta }} \tan \left[\arctan\left(v_0\sqrt{\frac{\beta }{g}}\right) - t \sqrt{\beta  g}\right]
\end{empheq}

While these expressions look complicated, they are in closed form, and therefore are extremely useful!

Note, these derivations ignore the change in drag coefficient with mach number, and the change in air density with altitude.

%\bibliographystyle{unsrt}
%\bibliography{biblio}

\end{document}


\documentclass[main.tex]{subfiles}
\begin{document}

\marginpar{Monday\\ 2020-10-12, \\ compiled \\ \today}

We come back to our noisy dataset \(x_i = \mu + n_i\).
If our noise comes from a Gaussian with a \emph{known}, \emph{constant} \(\sigma \), then we have
%
\begin{align}
\mathscr{L}(x_i | \mu , \sigma )
= \frac{1}{\sigma \sqrt{2 \pi }}
\exp(- \frac{1}{2} \frac{(x_i - \mu )^2}{\sigma^2})
\,.
\end{align}

We also assume that the realizations of the noise are independent.
So, the combined likelihood for all the data is given by
%
\begin{align}
\mathscr{L}(\vec{x} | \mu , \sigma ) = \prod_{i=1}^{N} \mathscr{L}(x_i, \mu , \sigma )
\,.
\end{align}

Now, choosing a prior as we mentioned is difficult in general. Until now we have assumed that our noninformative prior would be constant.
For the type of parameter we have now --- \(\mu \) is a \emph{location} parameter --- works; however we have an issue: a uniform distribution must have a certain range in which it is nonzero, elsewhere it is zero.
This range must be finite.

Zero cannot be updated: this is a problem.
We can, however take a prior that is so wide that it is nonzero in any place the likelihood is measurably nonzero. Practically speaking we only work up to finite precision, so this is not a problem.

We only case about proportionality: the posterior is proportional to the likelihood, so
%
\begin{align}
P \propto \prod_{i=1}^{N} \exp(- \frac{1}{2} \frac{(x_i - \mu )^2}{\sigma^2})
\,,
\end{align}
%
therefore the log-posterior is
%
\begin{align}
L = \log P = - \frac{1}{2 \sigma^2} \sum _{i=1}^{N} (x_i - \mu ) + \const
\,,
\end{align}
%
so if we want to find the maximum (log)-posterior:
%
\begin{align}
\dv{L}{\mu }  = \sum_{i=1}^{N} \frac{x_i- \mu }{\sigma^2}  =0
\,,
\end{align}
%
meaning that
%
\begin{align}
N \mu = \sum_{i=1}^{N} x_i \implies \hat{\mu} = \frac{1}{N} \sum_{i=1}^{N} x_i
\,.
\end{align}

We can also compute the estimate of the error on the estimate:
%
\begin{align}
\dv[2]{L}{\mu } =- \sum_{i=1}^{N} \frac{1}{\sigma^2} = - \frac{N}{\sigma^2}
\,,
\end{align}
%
therefore
%
\begin{align}
\sigma_\mu = \qty(- \dv[2]{L}{\mu })^{-1/2} = \frac{\sigma}{\sqrt{N}}
\,.
\end{align}

The great simplification we made here was that we are dealing with only one parameter.
In any realistic astrophysics scenario we have at least a dozen.

\section{Multiparameter estimation}

\subsection{A two-parameter example}

We consider a photon counting experiment.
We have a diffraction experiment: we can measure light in \(M\) frequency channels, labelled by \(k\), and at different angles.

Our model (we need one for parameter estimation) is that for each frequency channel \(k\) we expect a Gaussian spatial profile centered around \(x_0 \) --- for simplicity we assume \(x_0 \) is known, and that the standard deviation \(w\) is known as well.
We are interested in the amplitude \(A\) of this Gaussian peak.

Also, we will have spatially constant noise with amplitude \(B\).
We need to estimate \(A\) and \(B\) jointly; \(B\) is a \emph{nuisance parameter} we would ideally integrate over later.

We expect that the measured data at a frequency channel will look like
%
\begin{align}
D_k = n_0 \qty[ A\exp(- \frac{(x_k - x_0)^2}{2 w^2} + B)]
\,.
\end{align}

The parameter \(n_0 \) accounts for the fact that if we measure for longer we see more photons.

Photons, both noise and signal, are expected to obey Poissonian statistics:
%
\begin{align}
\mathbb{P}(N_k | D_k) = \frac{D_k^{N_k} e^{- D_k}}{N_k!}
\,,
\end{align}
%
which is the likelihood: the probability of the data, given our model.
Our actual likelihood will be given by \(\mathscr{L} = \prod_k \mathbb{P}(N_k | D_k)\).

What is our prior \(\mathbb{P}(A,B | I)\)? We know that these parameters cannot be negative, so we just take a uniform bivariate prior on \(A\geq 0\),  \(B \geq 0\).
As before, this is just meant to say ``uniform over all representable values''.

We will discuss later that by the nature of \(A\) as a scale parameter it would be more reasonable to take \(\log A\) to be uniform.

The posterior will then be
%
\begin{align}
\mathbb{P}(A, B | N_k, I) \propto
 \prod_k \frac{D_k^{N_k} e^{-D_k}}{N_k!}
\,.
\end{align}

This then depends on two parameters, and we can maximize it numerically. It is a difficult problem computationally, but not conceptually.

How can we model this in order to give an error? We can approximate it as a bivariate Gaussian.

In general, a multivariate Gaussian is given as
%
\begin{align}
\mathbb{P}(\vec{x}) = \frac{1}{(2 \pi )^{n/2} \abs{\Sigma }^{1/2}}
\exp(- \frac{1}{2} (\vec{x} - \vec{\mu})^{\top} \Sigma^{-1} (\vec{x} - \vec{\mu}))
\,,
\end{align}
%
where \(\Sigma \) is the \textbf{covariance matrix} of the two variables.
On the diagonal we have the variance of each variable: \(\Sigma_{ii} = \sigma_i^2\), so \((\Sigma^{-1})_{ii} = 1 / \sigma _i^2\) as long as the covariance (meaning, the nondiagonal elements) is zero.

\end{document}


In this report we have introduced Markov Chain Monte Carlo algorithms, with a particular focus on Langevin Monte Carlo methods. We then tested the performance of the algorithms based on a number of metrics and a broad range of parameters. Our main contribution is extending the work of \cite{Brosse18tULA} and producing a \textsc{Python} package ready for use by other researchers to implement their own methods to be tested against the algorithms we have presented here. As well as implementing their own methods, it is also written in a way that allows easy extension to different potentials and distributions. As well as this, we have extended the visualisation library of Rogozhnikov \cite{rogozhnikov2016hmc} to include LMC methods. This allows students and those newly introduced to the field to get an intuitive look at how these algorithms work, and the differences between them.

We have shown that taming is a viable method of preventing divergence of Langevin-based algorithms and gives insight into a distribution when Metropolised algorithms are unable to, particularly in ill-conditioned problems. It is interesting to note the efficiency of the \texttt{LM} algorithm in particular, despite its relative simplicity. It does however suffer from divergence problems as \texttt{ULA}.

There is no simple answer as to which algorithm is `best'. Depending on the application, and the prior information given on the distribution, one could make the case for any of the algorithms presented here. If the general shape of the distribution is known and computational power is not a restriction, a simple Random Walk Metropolis algorithm may well be the best option, even in the superlinear case.

If very little is known about maxima of the distribution, the taming method is the best choice. It is able to quickly find the modes of the distribution without divergence, however once at the mode it often over estimates the width of the potential well.  This has provoked some investigation into `switching' methods, where the chain is initially started using \texttt{tULA} for a fixed time to find the mode, before switching to the \texttt{RWM} algorithm to better explore the well. This is the rationale behind the \texttt{HPH} algorithm in the package, however it has been omitted from the report due to a lack of theoretical justification. It may well turn out to be similar to existing adaptive time stepping methods, or tempering methods.

Higher order methods seem to come at too great a computational cost, especially in very high dimension, although the theory supporting them suggests that more work is to be done on the numerical implementation of such methods.

If this report has highlighted anything, it is that Metropolisation is not the final word in Langevin Monte Carlo, and other methods of approximating Langevin dynamics should be exploited and explored. Non-asymptotic bounds are of great importance in this area, as it is known that \texttt{MALA} converges in the limit but this is of little practical use.

\subsection{Future Work}\label{subsec:future}
There are many possible ways in which the work presented here could be extended, both from a research and personal perspective. First, there is great scope for the improvement of our program. It is possible to add new analytic distributions to sample from, including those with non-smooth potentials as in \cite{durmus2018efficient}. Another obvious avenue would be to apply all the methods and analysis here to real (large) datasets, when the gradient is not known analytically. This would give the end user a much clearer impression of which algorithm to use in their given case. It would also slow down all gradient based methods as an unbiased estimator for the gradient would have to be calculated at every iteration. It may also be possible to speed up the higher order methods (\texttt{HOLA,tHOLA,tHOLAc}) by implementing a parallelised version, breaking up the complex iteration into smaller easier to manage sections. This in general is highly non-trivial due to the inherent dependence on the previous step in a Markov chain. Another important consideration is that of burn-in time. For the majority of our tests, we started from a minimiser of the potential well however our code is certainly not limited to this case. Doing so effectively removes any burn-in time as the chains are started in approximate stationarity. When started far away from the mode of a distribution, initial tests suggest taming is a highly preferable method to Metropolised algorithms. They take many more steps towards the mode, while Metropolised algorithms waste lots of time rejecting moves. In practice, this would greatly reduce the burn-in time -- a key feature of an effective MCMC method.

It is also important that we test the accuracy of our measures. This is difficult, especially in high dimensions as no methods exist for numerically calculating the 2-Wasserstein metric that many of the theoretical bounds use. Furthermore, using kernel density estimation or histograms with few bins introduces an error that is difficult to quantify and reduce. Here we have only qualitative comparisons between metrics. This is a well known problem in numerical optimal transport and inherent in dealing with high dimensional datasets and problems.

Many other methods exist in MCMC that remain to be tested against the tamed algorithms, or incorporated in to our program. These include Hamiltonian Monte Carlo (HMC), manifold MALA (mMALA), underdamped Langevin Monte Carlo and stochastic gradient Langevin dynamics (SGLD) \cite{betancourt2017conceptual, Girolami2011,cheng2018,pitfalls}. For dealing with stiff problems, specific methods also exist that could be used as benchmarks for taming algorithms \cite{abdulle2013weak}. In the next section SGLD will be expanded on due to its popularity in machine learning and high dimensional problems.

For the wider field, it is important that either `user-friendly' bounds on nonasymptotic error are developed in terms of a numerically implementable metric, or that methods are developed to accurately calculate the 2-Wasserstein metric. Even this will not solve the problem of approximating a high dimensional distribution using samples from a distribution; it is simply infeasible to be able to generate enough samples to get a good representation.


\subsection{Semimodules}\label{subsec:semimodules}

Semimodules are generalizations of monoid actions. Notation and terminology-wise, semimodules are somewhat special in that they are very much influenced by linear algebra and analysis, where vector spaces are crucial.

\begin{definition}\label{def:endomorphism_semiring}
  Let \( X \) be a monoid or, more generally, an object in a \hyperref[def:category]{category} that is \hyperref[def:concrete_category]{concrete} over \hyperref[def:monoid/category]{\( \cat{Mon} \)}.

  Let \( \End(X) \) be the \hyperref[def:endomorphism_monoid]{endomorphism monoid} over \( X \). These are necessarily monoid endomorphisms, however they may carry additional structure like being \hyperref[def:group/homomorphism]{group homomorphisms}, \hyperref[def:semimodule/homomorphism]{semimodule homomorphisms}, \hyperref[def:semilattice/homomorphism]{(semi)lattice homomorphisms} or their \hyperref[rem:topological_first_order_structures]{continuous counterparts}.

  Define addition in \( \End(X) \) pointwise as \( [f + g](x) \coloneqq f(x) + g(x) \). Then \( \End(X) \) with pointwise addition and composition is a \hyperref[def:semiring]{semiring}, which we call the \term{endomorphism semiring} over \( X \).
\end{definition}

\begin{definition}\label{def:semimodule}
  Fix a \hyperref[def:semiring]{semiring} \( R \), whose elements we will call \term{scalars}, and an \hyperref[rem:additive_magma]{additive} \hyperref[def:magma/commutative]{commutative} \hyperref[def:monoid]{monoid} \( M \), whose elements we will call \term{vectors}. See \fullref{rem:vector_etymology} for a discussion of the term \enquote{vector}.

  We say that \( M \) is a \term{semimodule} over \( R \) if they are compatible in any of the equivalent ways listed below. Analogously to \hyperref[def:monoid_action]{monoid actions}, if \( R \) is not commutative, we distinguish between left and right semimodules. Rather than \enquote{\( M \) is a semimodule over \( R \)}, it is often more convenient to say \enquote{\( M \) is an \( R \)-semimodule}.

  \begin{thmenum}[series=def:semimodule]
    \thmitem{def:semimodule/action} A left semimodule is a \hyperref[def:semiring/homomorphism]{homomorphism} from \( R \) to the \hyperref[def:endomorphism_semiring]{endomorphism semiring} \( \End(M) \). A right semimodule is a homomorphism from the \hyperref[def:semiring/opposite]{dual semiring} \( R^{-1} \) to \( \End(M) \).

    This definition is concise and natural, but unfortunately not very useful.

    \thmitem{def:semimodule/operation} The usual way to define a left semimodule is via a binary operation \( \cdot: R \times M \to M \) called \term{scalar multiplication} that satisfies the following conditions:
    \begin{thmenum}
      \thmitem{def:semimodule/operation/scalar_multiplication_action} Scalar multiplication is a \hyperref[def:monoid_action]{monoid action} of the multiplicative monoid \( (R, \cdot_R) \) on \( M \). The following conditions correspond to \eqref{eq:def:monoid_action/family/identity} and \eqref{eq:def:monoid_action/family/compatibility}:
      \begin{align}
        &1_R \cdot x = x, \label{eq:def:semimodule/operation/scalar_multiplication_action/identity} \\
        &(r \cdot_R s) \cdot x = r \cdot (s \cdot x). \label{eq:def:semimodule/operation/scalar_multiplication_action/compatibility}
      \end{align}

      The second condition can be regarded as a form of associativity.

      \thmitem{def:semimodule/operation/scalar_addition_distributivity} Scalar addition distributes over scalar multiplication:
      \begin{equation}\label{eq:def:semimodule/operation/scalar_addition_distributivity}
        (r +_R s) \cdot x = r \cdot x + s \cdot x.
      \end{equation}

      \thmitem{def:semimodule/operation/vector_addition_distributivity} Vector addition distributes over scalar multiplication:
      \begin{equation}\label{eq:def:semimodule/operation/vector_addition_distributivity}
        r \cdot (x + y) = r \cdot x + r \cdot y.
      \end{equation}

      \thmitem{def:semimodule/operation/absorption} The scalar and vector zeros are compatible:
      \begin{equation}\label{eq:def:semimodule/operation/absorption}
        0_R \cdot x = 0_M = r \cdot 0_M.
      \end{equation}
    \end{thmenum}

    In practice, we use the same symbol for both scalar and vector addition, and we denote both scalar and vector multiplication via juxtaposition.
  \end{thmenum}

  Semimodules have the following metamathematical properties:
  \begin{thmenum}[resume=def:semimodule]
    \thmitem{def:semimodule/theory} In order to fit the heterogeneous operation \( \cdot \) into the framework of \hyperref[def:first_order_semantics/satisfiability]{first-order logic models}, we can extend the \hyperref[def:monoid/theory]{theory of monoids} by adding, for every semiring element \( r \), a unary \hyperref[def:first_order_language/func]{functional symbol} \( m_r \). All conditions can then be reformulated via this operation. For example, \eqref{eq:def:semimodule/operation/scalar_multiplication_action/compatibility} corresponds to the axiom schema
    \begin{equation*}
      m_{rs}(\xi) = m_r(m_s(\xi)).
    \end{equation*}

    \thmitem{def:semimodule/homomorphism} A \hyperref[def:first_order_homomorphism]{first-order homomorphism} between two \( R \)-semimodules \( M \) and \( N \) is a function \( \varphi: M \to N \) that is a \hyperref[def:monoid/homomorphism]{monoid homomorphism} and satisfies \( \varphi \bincirc m_r^M = m_r^N \bincirc \varphi \).

    This can be expressed more clearly via the following two conditions, which we call \term{additivity} and \term{homogeneity}:
    \begin{align}
      \varphi(x + y) &= \varphi(x) + \varphi(y) \label{def:semimodule/homomorphism/additive} \\
         \varphi(rx) &= r \varphi(x) \label{def:semimodule/homomorphism/homogeneity}
    \end{align}

    Functions satisfying additivity and homogeneity are commonly called \term{linear}. These are a central object of study in \hyperref[sec:linear_algebra]{linear algebra} and, to a lesser extent, (linear) \hyperref[sec:functional_analysis]{functional analysis}.

    \thmitem{def:semimodule/submodel} The set \( A \subseteq M \) is a \hyperref[thm:substructure_is_model]{submodel} of \( M \) if it is a \hyperref[def:monoid/submodel]{submonoid} of \( M \) that is closed under scalar multiplication, i.e. \( rM = m_r[M] \subseteq M \) for every \( r \in R \). We say that \( A \) is an \( R \)-\term{sub-semimodule} of \( M \). If \( M \) is a module over some semiring extension \( T \) of \( R \), \( A \) may not be a \( T \)-sub-semimodule. For this reason, we should only use the term \enquote{sub-semimodule} of the underlying ring is clear from the context.

    As a consequence of \fullref{thm:positive_formulas_preserved_under_homomorphism}, the \hyperref[def:multi_valued_function/image]{image} of an \( R \)-semimodule homomorphism \( \varphi: M \to N \) is an \( R \)-sub-semimodule of \( M \).

    For an arbitrary set \( A \), we denote the \hyperref[def:first_order_generated_substructure]{generated submodel} by \( \linspan{ A } \) and call it the \term{linear span} of \( A \).

    \Fullref{rem:span_over_different_semirings} shows how it is important to be unambiguous about over which semiring we take the span of \( A \). In case of possible ambiguity, we will use subscripts like \( \linspan_R A \).

    The linear span can be characterized via \hyperref[rem:linear_combinations]{linear combinations} --- see \fullref{ex:def:first_order_substructure/vector_space}.

    \thmitem{def:semimodule/trivial} The \hyperref[thm:substructures_form_complete_lattice/bottom]{trivial} semimodule is the \hyperref[def:pointed_set/trivial]{trivial pointed set} \( \set{ 0 } \).

    \thmitem{def:semimodule/bisemimodule} A \term{bisemimodule} is a triple \( (R, A, B) \), where \( A \) is a left \( R \)-semimodule, \( B \) is a right \( R \)-semimodule, and the following associativity condition holds for \( a \in A \), \( r \in R \) and \( b \in B \):
    \begin{equation}\label{eq:def:semimodule/bimodule/associativity}
      (a \cdot_A r) \cdot_B b = a \cdot_A (r \cdot_B b).
    \end{equation}

    \thmitem{def:semimodule/category} For a fixed semiring \( R \), the \hyperref[def:category_of_small_first_order_models]{category of \( \mscrU \)-small models} \( \ucat{SMod}_R \) of left semimodules is \hyperref[def:concrete_category]{concrete} over \hyperref[def:monoid]{\( \ucat{Mon} \)}.

    Other notations are in use, for example \( R-\cat{Mod} \) in \cite[158]{Aluffi2009}, that better highlight whether we are considering left or right semimodules. We will prefer \( \cat{Mod}_R^{\opcat} \) for the category of right modules.
  \end{thmenum}
\end{definition}
\begin{proof}
  \ImplicationSubProof{def:semimodule/action}{def:semimodule/operation} Fix a semiring homomorphism \( \varphi: R \to \End(M) \) and define the operation \( r \cdot x \coloneqq \varphi(r)(x) \).

  We will verify that all conditions from \fullref{def:semimodule/operation} hold for this operation.

  \begin{itemize}
    \item By definition, \( \varphi \) is a monoid action of \( (R, \cdot) \) on \( (M, \bincirc) \).

    \item Distributivity of scalar addition holds because \( \varphi \) is a \hyperref[def:magma/homomorphism]{magma homomorphism} from \( (R, +) \) to \( (M, +) \).

    \item Distributivity of vector addition holds because, for each \( r \), \( \varphi(r) \) is a magma endomorphism of \( (M, +) \).

    \item Since \( \varphi \) is a monoid homomorphism from \( (R,  +) \) to \( (R, \cdot) \), it preserves identities and hence
    \begin{equation*}
      0_R \cdot x = \varphi(0_R)(x) = [y \mapsto 0_M](x) = 0_M.
    \end{equation*}

    This proves half of \fullref{def:semimodule/operation/absorption}.

    \item Since, for each \( r \), \( \varphi(r) \) is a monoid endomorphism of \( (M, +) \), we have
    \begin{equation*}
      r \cdot 0_M = \varphi(r)(0_M) = 0_M.
    \end{equation*}

    This proves the other half of \fullref{def:semimodule/operation/absorption}.
  \end{itemize}

  \ImplicationSubProof{def:semimodule/operation}{def:semimodule/action} Let \( \cdot: R \times M \to M \) be an operation satisfying all conditions from \fullref{def:semimodule/operation}. Define the function \( \varphi(r) \coloneqq (x \mapsto r \cdot x) \). We will show that this is a semiring homomorphism.

  It preserves both identities because
  \begin{equation*}
    \varphi(0_R) = (x \mapsto 0) = 0_{\End(M)}
  \end{equation*}
  and
  \begin{equation*}
    \varphi(1_R) = (x \mapsto x) = \id_M.
  \end{equation*}

  We must also show that it preserves both binary operations. Clearly
  \begin{equation*}
    \varphi(r + s)
    =
    (x \mapsto (r + s) x)
    \reloset {\eqref{eq:def:semiring/right_distributivity}} =
    (x \mapsto r x + s x)
    =
    (x \mapsto r x) + (x \mapsto s x)
    =
    \varphi(r) + \varphi(s).
  \end{equation*}

  For multiplication, we have
  \begin{equation*}
    \varphi(rs)
    =
    (x \mapsto (rs)x)
    \reloset {\eqref{eq:def:magma/associative}} =
    (x \mapsto r(sx))
    =
    \parens[\Big]{ x \mapsto \varphi(r)\parens[\Big]{ \varphi(s)(x) } }
    =
    \varphi(r) \bincirc \varphi(s).
  \end{equation*}
\end{proof}

\begin{proposition}\label{thm:def:semimodule}
  \hyperref[def:semimodule]{Semimodules} have the following basic properties:
  \begin{thmenum}
    \thmitem{thm:def:semimodule/union} The union of a \hyperref[eq:def:partially_ordered_set/homomorphism/sequence]{monotone sequence}
    \begin{equation*}
      N_1 \subseteq N_2 \subseteq \cdots
    \end{equation*}
    of \( R \)-\hyperref[def:semimodule/submodel]{sub-semimodules} of \( M \) is also an \( R \)-sub-semimodule of \( M \).
  \end{thmenum}
\end{proposition}
\begin{proof}
  \SubProofOf{thm:def:semimodule/union} Trivial.
\end{proof}

\begin{proposition}\label{thm:semiring_is_semimodule}
  Every semiring is a \hyperref[def:semimodule/bisemimodule]{bisemimodule} over itself with scalar multiplication given by the semiring multiplication.

  This result specializes to \fullref{thm:semiring_is_algebra}.
\end{proposition}
\begin{proof}
  Fix a semiring \( R \). We will show that \( \cdot \) satisfied the conditions in \fullref{def:semimodule/operation}.
  \begin{itemize}
    \item The identity law \eqref{eq:def:semimodule/operation/scalar_multiplication_action/identity} holds because \( 1 \) is a multiplicative identity of \( M \).
    \item The associativity-like law \eqref{eq:def:semimodule/operation/scalar_multiplication_action/compatibility} follows from associativity of multiplication.
    \item The two distributivity laws \eqref{eq:def:semimodule/operation/scalar_addition_distributivity} and \eqref{eq:def:semimodule/operation/vector_addition_distributivity} follow from left and right distributivity on \( R \).
    \item The absorption law \eqref{eq:def:semimodule/operation/absorption} follows from absorption on semirings.
  \end{itemize}

  All the above also hold for right semimodules rather than left.
\end{proof}

\begin{proposition}\label{thm:commutative_monoid_is_semimodule}
  The categories \( \hyperref[def:monoid/category]{\cat{CMon}} \) of commutative monoids and \( \hyperref[def:semimodule/category]{\cat{SMod}_\BbbN} \) of natural number semimodules are \hyperref[rem:category_similarity/isomorphism]{isomorphic}.

  More concretely, every commutative monoid \( M \) is a left semimodule over \( \BbbN \) with scalar multiplication given by \hyperref[rem:additive_magma/multiplication]{recursively defined multiplication}
  \begin{equation}\label{eq:thm:commutative_monoid_is_semimodule/operation}
    \begin{aligned}
      &\cdot: \BbbN \times M \to M \\
      &n \cdot x \coloneqq \begin{cases}
        0_M,           &n = 0, \\
        n \cdot x + x, &n > 1.
      \end{cases}
    \end{aligned}
  \end{equation}

  Conversely, in every semimodule over \( \BbbN \), scalar multiplication matches the recursively defined multiplication.

  This result specializes to \fullref{thm:semiring_is_natural_number_algebra} and \fullref{thm:abelian_group_is_module}.
\end{proposition}
\begin{proof}
  \SufficiencySubProof Let \( M \) be a commutative monoid. The operation \( \cdot: \BbbN \times M \to M \) defined in \fullref{thm:semiring_characteristic_homomorphism} satisfies the conditions in \fullref{def:semimodule/operation} as either a direct consequence of the definition or as a consequence of \fullref{thm:monoid_distributivity}.

  The homomorphisms are thus also compatible.

  \NecessitySubProof Let \( M \) be a semimodule over \( \BbbN \). We will use induction to show that \eqref{eq:thm:semiring_is_semimodule/operation} holds.
  \begin{itemize}
    \item For \( n = 0 \), this follows from the absorption law \eqref{eq:def:semimodule/operation/absorption}.
    \item If \( n \cdot x = n \cdot x + x \), then by scalar distributivity, \( (n + 1) \cdot x = n \cdot x + 1 \cdot x \). The multiplicative identity law \eqref{eq:def:semimodule/operation/scalar_multiplication_action/identity} then shows that \( 1 \cdot x = x \), which concludes our proof.
  \end{itemize}

  The homomorphisms are thus also compatible.
\end{proof}

\begin{proposition}\label{thm:functions_over_semimodule}
  For a set \( A \) and an \( R \)-\hyperref[def:semimodule]{semimodule} \( N \), the set \( \fun(A, N) \) of all functions from \( A \) to \( N \) is itself an \( R \)-semimodule with the following operations:
  \begin{thmenum}
    \thmitem{thm:functions_over_semimodule/addition} Pointwise addition
    \begin{equation*}
      [f + g](x) \coloneqq f(x) + g(x)
    \end{equation*}

    \thmitem{thm:functions_over_semimodule/scalar_multiplication} Pointwise scalar multiplication
    \begin{equation*}
      [t \cdot f](x) \coloneqq t \cdot f(x)
    \end{equation*}
  \end{thmenum}

  If \( A \) is also an \( R \)-algebra, we denote the semimodule of all \( R \)-\hyperref[def:semimodule/homomorphism]{linear maps} by \( \hom(A, N) \).

  This extends to \fullref{thm:functions_over_algebra}.
\end{proposition}
\begin{proof}
  By \fullref{thm:functions_over_model_form_model}, \( N \) is an \( R \)-semimodule.
\end{proof}

\begin{definition}\label{def:function_support}
  The \term{support} of a function \( f: S \to R \) from any set \( S \) to a semiring \( R \) is the set
  \begin{equation*}
    \supp(f) \coloneqq \set{ x \in S \given f(x) \neq 0_R }.
  \end{equation*}
\end{definition}

\begin{definition}\label{def:semimodule_direct_product}
  The \term{direct product} of a family of \( R \)-\hyperref[def:semimodule]{semimodules} \( \seq{ M_k }_{k \in \mscrK} \) is their \hyperref[def:monoid_direct_product]{monoid direct product} \( \prod_{k \in \mscrK} M_k \) with the additional componentwise scalar product
  \begin{equation*}
    r \cdot \seq{ x_k }_{k \in \mscrK}
    \coloneqq
    \seq{ r \cdot x_k }_{k \in \mscrK}.
  \end{equation*}

  As in the case of general monoids, the \term{direct sum} \( \bigoplus_{k \in \mscrK} M_k \) is the submonoid of the direct product consisting only of \hyperref[def:cartesian_product/tuple]{tuples} with \hyperref[def:set_finiteness]{finite} \hyperref[def:function_support]{support}. That is, tuples with only finitely many nonzero components.
\end{definition}

\begin{proposition}\label{thm:semimodule_categorical_limits}
  We present a refinement to \fullref{thm:monoid_categorical_limits}.

  \begin{thmenum}
    \thmitem{thm:semimodule_categorical_limits/product} The \hyperref[def:discrete_category_limits]{categorical product} of the family \( \seq{ M_k }_{k \in \mscrK} \) in the category \hyperref[def:semimodule/category]{\( \cat{SMod} \)} of semimodules is their \hyperref[def:semimodule_direct_product]{direct product} \( \prod_{k \in \mscrK} M_k \).

    \thmitem{thm:semimodule_categorical_limits/coproduct} The \hyperref[def:discrete_category_limits]{categorical coproduct} of the family \( \seq{ M_k }_{k \in \mscrK} \) in the category \hyperref[def:semimodule/category]{\( \cat{CSMon} \)} of \hi{commutative} semimodules is their \hyperref[def:semimodule_direct_product]{direct sum} \( \bigoplus_{k \in \mscrK} M_k \).
  \end{thmenum}
\end{proposition}
\begin{proof}
  Simple refinement of \fullref{thm:monoid_categorical_limits}.
\end{proof}

\begin{definition}\label{def:free_semimodule}\mimprovised
  Fix a \hyperref[def:semiring]{semiring} \( R \). We associate with every set \( A \) its \term{free \( R \)-semimodule} \( R^{\oplus A} \) over \( R \) defined as the set
  \begin{equation*}
    R^{\oplus A} \coloneqq \bigoplus_{x \in A} R = \set{ t: A \to R \given t \T{has finite \hyperref[def:function_support]{support}} }.
  \end{equation*}

  In the case when \( R \) is the semiring \( \BbbN \) of natural numbers, \( \BbbN^{\oplus A} \) is the set of finite \hyperref[def:weighted_set/multiset]{multisets} over \( S \).

  We call \( A \) the \term{basis} of \( R \). As with general direct sums, we regard the function \( t \) as the indexed family \( \seq{ t_x }_{x \in A} \), and we call the indexed family a \term{linear combination} over \( R \).

  By \fullref{thm:functions_over_model_form_model}, \( R^{\oplus A} \) inherits addition and multiplication from \( R \) and is actually a semiring. Scalar multiplication can be defined as
  \begin{equation*}
    \begin{aligned}
      &\cdot: R \times R^{\oplus A} \to R^{\oplus A}, \\
      &r \cdot \seq{ t_x }_{x \in A} \coloneqq \seq{ r \cdot t_x }_{x \in A}.
    \end{aligned}
  \end{equation*}

  Finally, define the canonical inclusion.
  \begin{equation*}
    \begin{aligned}
      &\iota_A: A \to R^{\oplus A}, \\
      &\iota_A(x) \coloneqq \parens[\Bigg]
        {
          y \mapsto \begin{rcases}
            \begin{cases}
              1_R, &y = x \\
              0_R, &y \neq x
            \end{cases}
          \end{rcases}
        }
    \end{aligned}
  \end{equation*}

  Free right semimodules require trivial adjustments.
\end{definition}

\begin{theorem}[Free semimodule universal property]\label{thm:free_semimodule_universal_property}
  Fix a semiring \( R \) and a set \( A \). The \hyperref[def:free_semimodule]{free \( R \)-semimodule} \( R^{\oplus A} \) over \( R \) is the unique up to a unique isomorphism semimodule that satisfies the following \hyperref[rem:universal_mapping_property]{universal mapping property}:
  \begin{displayquote}
    For every semimodule \( M \) over \( R \) and every function \( e: A \to M \), there exists a unique \( R \)-semimodule homomorphism \( \Phi_e: R^{\oplus A} \to M \) such that the following diagram commutes:
    \begin{equation}\label{eq:thm:free_semimodule_universal_property/diagram}
      \begin{aligned}
        \includegraphics[page=1]{output/thm__free_semimodule_universal_property.pdf}
      \end{aligned}
    \end{equation}
  \end{displayquote}

  Via \fullref{rem:universal_mapping_property}, \( A \mapsto R^{\oplus A} \) becomes \hyperref[def:category_adjunction]{left adjoint} to the \hyperref[def:concrete_category]{forgetful functor}
  \begin{equation*}
    U: \cat{SMod}_R \to \cat{Set}.
  \end{equation*}

  The function \( e \) assigns a value from \( M \) for each component of a linear combination, while \( \Phi_e \) evaluates the obtained sum. We call \( \Phi_e \) the \term{linear extension} or \term{linear combination evaluation map} corresponding to \( e \).
\end{theorem}
\begin{proof}
  For every function \( e: A \to M \), we want
  \begin{equation*}
    \Phi_e(\iota(x)) = e(x).
  \end{equation*}

  This suggests the definition
  \begin{equation*}
    \begin{aligned}
      &\Phi_e: R^{\oplus A} \to M, \\
      &\Phi_e(\seq{ t_x }_{x \in A}) \coloneqq \sum_{x \in A}^n t_x \cdot e(x).
    \end{aligned}
  \end{equation*}

  We discuss well-definedness of infinitary operations in direct sums in \fullref{rem:binary_operation_syntax_trees/infinite/direct_sum}.
\end{proof}

\begin{remark}\label{rem:linear_combinations}
  The \hyperref[def:free_semimodule]{linear combination} \( \sum_{x \in A} t_x x \) can instead be written as \( \sum_{k=1}^n t_k x_k \), where \( x_1, \ldots, x_n \) are the values in \( A \) for which the scalars \( t_1, \ldots, t_n \) are nonzero (we denote \( t_{x_k} \) by \( t_k \) for brevity). This is actually the dominating convention, although we sometimes use the former notation and. In vector spaces, we utilize the projection functionals from \fullref{def:basis_decomposition}.

  This issue is discussed in more generality in \fullref{rem:binary_operation_syntax_trees/infinite/direct_sum}.
\end{remark}

\begin{proposition}\label{thm:span_via_linear_combinations}
  For a set \( A \) in an \( R \)-\hyperref[def:semimodule]{semimodule} \( M \), the \hyperref[def:semimodule/submodel]{linear span} of \( A \), defined as the \( R \)-submodule generated by \( A \) in the sense of \fullref{def:first_order_generated_substructure}, equals the set of all \hyperref[rem:linear_combinations]{linear combinations} over \( A \).

  We say that \( A \) is a \term{generating set} of \( M \).

  Compare this result to \fullref{thm:generators_via_polynomials} for algebras.
\end{proposition}
\begin{proof}
  \Cref{fig:thm:span_via_linear_combinations} shows a \hyperref[def:concrete_syntax_tree]{syntax tree} for a given linear combination, which can be traversed and evaluated to obtain a vector in \( M \). Furthermore, it must be a member of \( \linspan S \) since the latter is closed under vector addition and scalar multiplication with members of \( S \). Hence, the set \( L \) of all linear combinations over \( S \) is a subset of \( \linspan S \).

  Generalizing the syntax tree construction from \cref{fig:thm:span_via_linear_combinations}, we see that \( L \) satisfies \fullref{def:first_order_substructure/inductive}, and is thus a submodule of \( M \). Since \( \linspan S \) is the smallest module containing \( S \), we have \( \linspan S = L \).

  \begin{figure}[h]
    \hfill
    \includegraphics[page=1]{output/thm__span_via_linear_combinations.pdf}
    \hfill\hfill
    \caption{A linear combination is simply a \hyperref[def:multi_valued_function/superposition]{superposition} of scalar multiplication and binary addition.}
    \label{fig:thm:span_via_linear_combinations}
  \end{figure}
\end{proof}

\begin{remark}\label{rem:span_over_different_semirings}
  If \( M \) is both an \( R \)-semimodule and a \( T \)-semimodule, \fullref{thm:span_via_linear_combinations} highlights a fundamental difference between the generated \( R \)-sub-semimodule and the generated \( T \)-sub-semimodule.

  For example, the \( \BbbN \)-sub-semimodule generated by \( 2 \) is the semiring \( 2\BbbN \) of even natural numbers, while the \( \BbbR_{\geq 0} \)-sub-semimodule generated by \( 2 \) is \( \BbbR_{\geq 0} \) itself.
\end{remark}


\documentclass[a4paper]{article}

\input{../preambles/preamble}
\setdefaultlanguage{english}
%\setotherlanguages{german,greek}

\input{../preambles/mathematics}
\input{../preambles/physics}

%\newcommand{\RomaN}[1]{%
%  \textup{\uppercase\expandafter{\romannumeral#1}}%
%}

%\addbibresource{main.bib}
\title{Complex Harmonic Oscillators and How to Squeeze Them}
\author{YiFan Wang}

\newcommand{\Poibr}[1]{\sbr{#1}_\text{P}}
\newcommand{\Combr}[1]{\sbr{#1}_\text{-}}

\newcommand{\tR}{\Re}
\newcommand{\tI}{\Im}
\newcommand{\tS}{\text{S}}
\newcommand{\tD}{\text{D}}

\begin{document}
\maketitle

%\begin{abstract}
%Your abstract.
%\end{abstract}

\tableofcontents

\section{Single complex oscillator}

\begin{nameddef}{Classical Hamiltonian in canonical coordinates}
Complex phase space
\begin{equation}
H = \frac{1}{2}\pi^+\pi^- + \frac{\Omega^2}{2}\phi^+\phi^-,
\end{equation}
The corresponding Poisson brackets read
\begin{equation}
\Poibr{\rfun{f}{\eta^C}, \rfun{g}{\eta^C}} = \sum_C \rbr{
\frpa{f}{\phi^C}\frpa{g}{\pi^C} - \frpa{f}{\pi^C}\frpa{g}{\phi^C}},
\end{equation}
where $C \in \cbr{+, -}$, $\eta^+ = \rbr{\eta^-}^*$ and $\eta \in \cbr{\pi,
\phi}$, so that
\begin{equation}
\Poibr{\phi^{C_1}, \pi^{C_2}} = \delta^{C_1 C_2},\qquad
\Poibr{\phi^{C_1}, \phi^{C_2}} = \Poibr{\pi^{C_1}, \pi^{C_2}} = 0.
\end{equation}

Real phase space
\begin{equation}
\phi^C = \frac{1}{\sqrt{2}}\rbr{ \phi_\tR - C \ii \phi_\tI},\qquad
\pi^C = \frac{1}{\sqrt{2}}\rbr{ \pi_\tR + C \ii \pi_\tI}.
%\phi^* &= \frac{1}{\sqrt{2}}\rbr{\phi^\tR - \ii \phi^\tI},\qquad
%\pi^* &&= \frac{1}{\sqrt{2}}\rbr{\pi^\tR + \ii \pi^\tI}.
\end{equation}
Inverse transformation
\begin{equation}
\begin{aligned}
\phi_\tR &= \frac{1}{\sqrt{2}}\rbr{\phi^+ + \phi^-},
&\phi_\tI &= \frac{\ii}{\sqrt{2}}\rbr{\phi^+ - \phi^-}, \\
\pi_\tR &= \frac{1}{\sqrt{2}}\rbr{\pi^- + \pi^+},
&\pi_\tI &= \frac{\ii}{\sqrt{2}}\rbr{\pi^- - \pi^+}. \\
\end{aligned}
\end{equation}

One can verify
\begin{equation}
H = \sum_{F} \frac{1}{2} \pi_F^2 + \frac{\Omega^2}{2} \phi_F^2,
\end{equation}
where $F \in \cbr{\tR, \tI}$, and
\begin{equation}
\Poibr{\rfun{f}{\eta_F}, \rfun{g}{\eta_F}} = \sum_F
\frpa{f}{\phi_F}\frpa{g}{\pi_F} - \frpa{f}{\pi_F}\frpa{g}{\phi_F},
\end{equation}
so that
\begin{equation}
\Poibr{\phi_{F_1}, \pi_{F_2}} = \delta_{F_1 F_2},\qquad
\Poibr{\phi_{F_1}, \phi_{F_2}} = \Poibr{\pi_{F_1}, \pi_{F_2}} = 0.
\end{equation}
hold as well.
\end{nameddef} % Classical Hamiltonian in canonical coordinates

\begin{nameddef}{Ladder coordinates}
Ladder coordinates (ladder `numbers', later to be quantised) in complex phase
space
\begin{align}
a_\phi^C &= \frac{1}{\sqrt{2}} \rbr{\Omega^{+\frac{1}{2}}\phi^{C} - C \ii
\Omega^{-\frac{1}{2}} \pi^{-C}}, \\
a_\pi^C &= \frac{1}{\sqrt{2}} \rbr{\Omega^{+\frac{1}{2}}\phi^{-C} - C \ii
\Omega^{-\frac{1}{2}} \pi^{C}},
\end{align}
where $-- = +$, $-+ = -$.
Poisson brackets? Inverse transformation
\begin{equation}
\phi^- = \frac{\Omega^{-\frac{1}{2}}}{\sqrt{2}}\rbr{a_\pi^+ + a_\phi^-},\qquad
\pi^- = \frac{\ii\Omega^{+\frac{1}{2}}}{\sqrt{2}}\rbr{a_\phi^+ - a_\pi^-}.
\end{equation}

Ladder coordinates in real phase space
\begin{equation}
a_F^C = \frac{1}{\sqrt{2}} \rbr{\Omega^{+\frac{1}{2}}\phi_F - C \ii
\Omega^{-\frac{1}{2}} \pi_F}.
\end{equation}
Poisson brackets? Inverse transformation
\begin{equation}
\phi_F = \frac{\Omega^{-\frac{1}{2}}}{\sqrt{2}}\rbr{a_F^+ + a_F^-},\qquad
\pi_F = \frac{\ii\Omega^{+\frac{1}{2}}}{\sqrt{2}}\rbr{a_F^+ - a_F^-}.
\end{equation}

One can check that
\begin{equation}
a_\phi^C = \frac{1}{\sqrt{2}}\rbr{a_\tR^C - C \ii a_\tI^C},\qquad
a_\pi^C = \frac{1}{\sqrt{2}}\rbr{a_\tR^C + C \ii a_\tI^C}.
\end{equation}
%Inverse transformation
%\begin{equation}
%a_\phi^C = \frac{1}{\sqrt{2}}\rbr{a_\tR^C - C \ii a_\tI^C},\qquad
%a_\pi^C = \frac{1}{\sqrt{2}}\rbr{a_\tR^C + C \ii a_\tI^C}.
%\end{equation}

\end{nameddef} % Ladder coordinates

\begin{nameddef}{Quantisation}
Quantisation in complex canonical coordinates
\begin{equation}
f \mapsto \what{f};\qquad
\Poibr{f,g} \mapsto \Combr{\what{f},\what{g}} = \ii \what{\Poibr{f,g}}.
\end{equation}
All classical equations listed above can be immediately quantised, since no
product of non-commuting operators appears.

%Quantum Hamiltonian in canonical coordinates
%\begin{align}
%\what{H} &= \frac{1}{2} \what{\pi}^ + \what{\pi}^- +
%\frac{\Omega^2}{2} \what{\phi}^+ \what{\phi}^-
%\\
%&= \sum_{F} \frac{1}{2} \what{\pi}_F^2 + \frac{\Omega^2}{2} \what{\phi}_F^2.
%\end{align}

Commutators of the ladder operators
\begin{align}
\Combr{\what{a}_{\eta_1}^{-C_1}, \what{a}_{\eta_2}^{C_2}} &=
\delta_{\eta_1 \eta_2} \delta^{C_1 C_2} \what{1}; \\
\Combr{\what{a}_{F_1}^{-C_1}, \what{a}_{F_2}^{C_2}}
&= \delta_{F_1 F_2} \delta^{C_1 C_2} \what{1}. \\
\end{align}

Number operators
\begin{equation}
\what{n}_\eta \coloneqq \what{a}_\eta^+ \what{a}_\eta^-,\qquad
\what{n}_F \coloneqq \what{a}_F^+ \what{a}_F^-.
\end{equation}

Angular momentum operator
\begin{align}
\what{L} &\coloneqq
\what{\phi}_\tR\what{\pi}_\tI - \what{\phi}_\tI\what{\pi}_\tR \nonumber \\
&= \ii\rbr{\what{a}_\tI^+\what{a}_\tR^- - \what{a}_\tR^+\what{a}_\tI^-}
\nonumber \\
&= \ii\rbr{\what{\phi}^-\what{\pi}^- - \what{\phi}^+\what{\pi}^+}
= \ii\rbr{\what{\pi}^-\what{\phi}^- - \what{\pi}^+\what{\phi}^+}
\nonumber \\
&= \what{n}_\pi - \what{n}_\phi.
\label{eq:angular-momentum}
\end{align}
$\what{L} = \what{L}^\dagger$.

\begin{align}
\what{n}_\phi &= \frac{1}{2}
\rbr{\Omega^{+\frac{1}{2}}\what{\phi}^+ - \ii\Omega^{-\frac{1}{2}}\what{\pi}^-}
\rbr{\Omega^{+\frac{1}{2}}\what{\phi}^- + \ii\Omega^{-\frac{1}{2}}\what{\pi}^+}
\nonumber \\
&= \frac{1}{2} \rbr{\Omega^{+1} \what{\phi}^+\what{\phi}^- +
\ii\rbr{\what{\phi}^+\what{\pi}^+ - \what{\pi}^-\what{\phi}^-}
+ \Omega^{-1} \what{\pi}^-\what{\pi}^+} \nonumber \\
&= \Omega^{-1}\what{H} - \frac{1}{2}\rbr{1+\what{L}}.
\end{align}
Substituting \eqref{eq:angular-momentum} yields the quantum Hamiltonian
\begin{empheq}[box=\fbox]{equation}
\what{H} = \frac{\Omega}{2}\rbr{\what{n}_\phi + \what{n}_\pi + 1}.
\end{empheq} % equation
%Luckily,
%\begin{equation}
%\Combr{\what{L},\what{H}} = 0
%\end{equation}
%so that
%\begin{equation}
%\Omega \Combr{\what{n},\what{L}} = \Combr{\what{n},\what{H}} = 0
%\end{equation}
%as well.

%\begin{equation}
%H = \frac{1}{2}\what{\pi}^+\what{\pi}^- + \frac{\Omega^2}{2}\phi^+\phi^-,
%\end{equation}
\end{nameddef}

\begin{nameddef}{Wave function}
One may choose the
\end{nameddef}

\section{Rotating}

\section{Cohering}

\section{Single--mode squeezing}

\section{Double--mode squeezing}

\

% Let's print the overall heading of the bibliography first:
%\printbibheading
%\printbibliography

\end{document}


\section{Monte Carlo Methods}

\subsection{Requirement}

\begin{itemize}
	\item need episode, so need to terminate
	\item start only when episode ends
	\item do not need model
\end{itemize}

Note: Monte Carlo Method is not a online method because it is not step-by-step method.

\subsection{Prediction}

\subsubsection{First Visit MC}

\cindex{Monte Carlo} prediction has \cindex{first visit} and \cindex{every visit} methods.

The \cindex{first visit} Algorithm (\ref{algo:fvmc}) is an unbiased estimate.

\begin{algorithm}
	\caption{First visit MC, estimate $v_\pi$}\label{algo:fvmc}

	\begin{algorithmic}[1]
		\State $\forall s \in \mathcal{S}, V(s) \gets random$
		\State $\text{Returns}(s) \gets []$

		\Statex

		\Loop
			\State generate an episode $\pi: S_0, A_0, R_1, S_1, A_1, R_2, \dots, S_{T-1}, A_{T-1}, R_T$
			\State $G \gets 0$
			\For{$t \gets T-1, T-2, \dots, 0$}
				\State $G \gets \gamma G + R_{t+1}$

				\Comment{loop backward to find first appearance}
				\If{$S_t \notin \{S_0, S_1, \dots, S_{t-1}\}$}
					\State $\text{Returns}(S_t) \gets \text{Returns}(S_t) + G$
					\State $V(S_t) \gets \text{average}(\text{Returns}(S_t))$
				\EndIf
			\EndFor
		\EndLoop
	\end{algorithmic}
\end{algorithm}

\subsection{Explore All State-Action Pair}

In Monte Carlo control, the policy at $S_t$ need to explore all $q(S_t,A_t)$, which means the MC algorithm needs to cover all $\langle S_t, A_t \rangle$ pairs. There are two ways to achieve this:

\begin{itemize}
	\item exploring start. It might not be possible to enumerate all start.
	\item $\varepsilon$-soft policy.
\end{itemize}

\subsubsection{Exploring Starts}

It tries all $\langle S_t, A_t \rangle$ pairs as the first action. See Algorithm (\ref{algo:estart}) for detail.

If model is not available, $q_\pi$ is preferred than $V_\pi$ because it does not need transition probability when calculating optimal policy.

\begin{algorithm}
	\caption{first visit MCES (Exploring Starts), estimate $\pi_*$}\label{algo:estart}

	\begin{algorithmic}[1]
		\State $\pi(s) \in \mathcal{A}(s)$
		\State $q(s,a) \in \mathbb{R}$
		\State $\text{Returns}(s,a) \gets []$

		\Statex

		\Loop
			\State choose $S_0$ and $A_0$ so all pairs will appear \Comment{exploring starts}
			\State generate episode from $\langle S_0,A_0 \rangle$: $\pi: S_0, A_0, R_1,\dots, S_{T-1}, A_{T-1}, R_T$
			\State $G \gets 0$

			\For{$t \gets T-1, T-2, \dots, 0$}
				\State $G \gets \gamma G + R_{t+1}$

				\If{$\langle S_t, A_t \rangle \notin \{\langle S_0,A_0 \rangle,\langle S_1,A_1 \rangle, \dots,\langle S_{t-1}, A_{t-1} \rangle \}$}
					\State $\text{Returns}(S_t, A_t) \gets \text{Returns}(S_t, A_t) + G$
					\State $q(S_t, A_t) \gets \text{average}(\text{Returns}(S_t, A_t))$
					\State $\pi (S_t) \gets \underset{a \in \mathcal{A}(S_t)}{\text{argmax}}\ q(S_t, a) $
				\EndIf
			\EndFor
		\EndLoop
	\end{algorithmic}
\end{algorithm}

\subsubsection{$\varepsilon$-soft Policy}

In $\varepsilon$-soft policy, all $\langle S_t, A_t \rangle$ pairs are tried in the middle with non-zero probability:

\begin{itemize}
	\item \cindex{$\varepsilon$-soft} : $\pi(a|s) >\displaystyle \frac{\varepsilon}{\mathcal{A}(s)}$.
	\item \cindex{$\varepsilon$-greedy} : see Algorithm (\ref{algo:fvmcsoft}) for detail.
\begin{equation*}
	\pi(a|s) =
		\begin{cases}
				\displaystyle \frac{\varepsilon}{\mathcal{A}(s)} & \text{, if } a \text{ is not the greedy choice} \\
				1 - \varepsilon + \displaystyle \frac{\varepsilon}{\mathcal{A}(s)} & \text{, if } a  \text{ is the greedy choice}
		\end{cases}
\end{equation*}
\end{itemize}

\begin{algorithm}
	\caption{first visit MC control ($\varepsilon$-greedy), estimate $\pi_*$}\label{algo:fvmcsoft}

	\begin{algorithmic}[1]
		\State $\pi \gets $ random $\varepsilon$-greedy policy
		\State $q(s,a) \in \mathbb{R}$
		\State $\text{Returns}(s,a) \gets []$

		\Statex

		\Loop
			\State choose $S_0$ and $A_0$ \Comment{non-exploring start}
			\State generate episode from $\langle S_0,A_0 \rangle$: $\pi: S_0, A_0, R_1, \dots, S_{T-1}, A_{T-1}, R_T$
			\State $G \gets 0$

			\For{$t \gets T-1, T-2, \dots, 0$}
				\State $G \gets \gamma G + R_{t+1}$

				\If{$\langle S_t, A_t \rangle \notin \{\langle S_0,A_0 \rangle,\langle S_1,A_1 \rangle, \dots,\langle S_{t-1}, A_{t-1} \rangle \}$}
					\State $\text{Returns}(S_t, A_t) \gets \text{Returns}(S_t, A_t) + G$
					\State $q(S_t, A_t) \gets \text{average}(\text{Returns}(S_t, A_t))$
					\State $A^* \gets \underset{a \in \mathcal{A}(S_t)}{\text{argmax }} q(S_t, a) $

					\For{$a \in \mathcal{A}(S_t)$}   \Comment{$\varepsilon$-greedy}
						\State \begin{equation*}
							\pi(a|S_t) \gets \begin{cases}
								\displaystyle 1 - \varepsilon + \frac{\varepsilon}{\mathcal{A}(s)} & \text{,if } a = A^* \\
								\displaystyle \frac{\varepsilon}{\mathcal{A}(s)} & \text{,if } a \neq A^*
							\end{cases}
						\end{equation*}
					\EndFor
				\EndIf
			\EndFor
		\EndLoop
	\end{algorithmic}
\end{algorithm}

\subsection{Off-policy prediction via Importance Sampling}

\subsubsection{Target Policy}

\begin{description}
	\item[behavior policy] the policy $b$ used to generate behavior
	\item[target policy] the policy $\pi$ being learned
\end{description}

It has the assumption of \cindex{coverage}:
\begin{equation}
	\pi(a|s) > 0 \Rightarrow b(a|s) >0
\end{equation}

\subsubsection{Importance Sampling}

The probability of $\{ A_t, S_{t+1},A_{t+1},\dots,S_T  \}$ under policy $\pi$ is (using Monte Carlo property):
\begin{equation}
	\mathbb{P} \{ A_t, S_{t+1},A_{t+1},\dots,S_T | S_t, A_{t:T-1} \sim \pi \} = \prod_{k=t}^{T-1} \pi(A_k|S_k)p(S_{k+1}|S_k,A_k)
\end{equation}

The \cindex{importance-sampling ratio} is:
\begin{equation}\label{importancsamplingratio}
	\rho_{t:T-1}^{\pi / b} = \frac{\prod\limits_{k=t}^{T-1} \pi(A_k|S_k)p(S_{k+1}|S_k,A_k)}{\prod\limits_{k=t}^{T-1} b(A_k|S_k)p(S_{k+1}|S_k,A_k)} = \prod_{k=t}^{T-1} \frac{\pi(A_k|S_k)}{b(A_k|S_k)}
\end{equation}

Let $\mathcal{T}$ denotes the set of all timestamps that $s$ is visited, $T(t)$ is the timestamp that the episode terminate following timestamp $t$, $G_t$ is the return between timestamp $t$ and $T(t)$. There are two different importance sampling:
\begin{description}
	\item [ordinary importance sampling] \begin{equation}
		V(s) = \frac{\sum\limits_{t \in \mathcal{T}} \rho_{t:T-1}^{\pi/b} G_t}{|\mathcal{T}|}
	\end{equation}
	\item [weighted importance sampling] \begin{equation}
		V(s) = \frac{\sum\limits_{t \in \mathcal{T}} \rho_{t:T-1}^{\pi/b} G_t}{\sum\limits_{t \in \mathcal{T}} \rho_{t:T-1}^{\pi/b}}
	\end{equation}
\end{description}

For \cindex{first visit} method, \cindex{Ordinary importance sampling} is unbiased, with unlimited variance. So \cindex{weighted importance sampling} is preferred in practice.

For \cindex{every visit} method, both sampling is biased which reduces to near zero when the number of sampling increases.

In practice, \cindex{every visit} is preferred because it does not need to keep trace of which states have been visited.

\subsection{Incremental Policy Evaluation}

Incremental implementation need the following background. If we want to estimate
\begin{equation}
	V_n = \frac{\sum\limits_{k=1}^{n-1} W_k G_k}{\sum\limits_{k=1}^{n-1} W_k}, n \geq 2
\end{equation}

$V_n$ could be incrementally updated by:
\begin{equation}
	V_{n+1} = V_n + \frac{W_n}{C_n} \Big( G_n - V_n \Big), n \geq 1
\end{equation}

where
\begin{equation*}
	C_{n+1} = C_n + W_{n+1}
\end{equation*}

Algorithm (\ref{algo:opmcp}) implements incremental solution of weighted importance sampling:

\begin{algorithm}
	\caption{off-policy MC policy evaluation, estimate $q_\pi$}\label{algo:opmcp}

	\begin{algorithmic}[1]
		\State $Q(s,a) \in \mathbb{R}$
		\State $C(s,a) \in 0$

		\Statex

		\Loop
			\State $b \gets $ any policy with coverage of $\pi$
			\State generate episode following $b$: $S_0, A_0,R_1, \dots, S_{T-1},A_{T-1},R_T$
			\State $G \gets 0$
			\State $W \gets 1$
			\For{$t \gets T-1, T-2, \dots, 0$}
				\State $G \gets \gamma G + R_{t+1}$
				\State $C(S_t,A_t) \gets C(S_t,A_t) + W$
				\State $\displaystyle Q(S_t,A_t) \gets Q(S_t,A_t) + \frac{W}{C(S_t,A_t)} \Big ( G - Q(S_t,A_t) \Big)$
				\State $\displaystyle W \gets W \frac{\pi(A_t|S_t)}{b(A_t|S_t)}$

				\If{$W = 0$} \Comment{$\pi(A_t|S_t) = 0$}, $b$ does not cover $\pi$
					\State exit  For loop
				\EndIf
			\EndFor
		\EndLoop
	\end{algorithmic}
\end{algorithm}

\subsection{Incremental Policy Control}

The behavior policy $b$ need to be $\varepsilon$-soft.

Algorithm (\ref{algo:opmcpc}) implements incremental control of weighted importance sampling:

\begin{algorithm}
	\caption{off-policy MC policy control, estimate $q_*$}\label{algo:opmcpc}

	\begin{algorithmic}[1]
		\State $Q(s,a) \in \mathbb{R}$
		\State $C(s,a) \in 0$
		\State $\pi(s) \gets \underset{a}{\text{argmax}} Q(s,a)$

		\Statex

		\Loop
			\State $b \gets $ any $\varepsilon$-soft policy
			\State generate episode following $b$: $S_0, A_0,R_1, \dots, S_{T-1},A_{T-1},R_T$
			\State $G \gets 0$
			\State $W \gets 1$
			\For{$t \gets T-1, T-2, \dots, 0$}
				\State $G \gets \gamma G + R_{t+1}$
				\State $C(S_t,A_t) \gets C(S_t,A_t) + W$
				\State $\displaystyle Q(S_t,A_t) \gets Q(S_t,A_t) + \frac{W}{C(S_t,A_t)} \Big( G - Q(S_t,A_t) \Big)$
				\State $\pi(S_t) \gets \underset{a}{\text{argmax}}\  Q(S_t,a)$

				\If{$A_t \neq \pi(S_t)$}
					\State exit  For loop
				\EndIf

				\State $\displaystyle W \gets W \frac{1}{b(A_t|S_t)}$ \Comment{$\pi(A_t|S_t) = 1$ because it is greedy}
			\EndFor
		\EndLoop
	\end{algorithmic}
\end{algorithm}


\section{Parametric Equations}\label{sec:Parametric Equations}
When we computed the derivative $dy/dx$ using polar coordinates, we
used the expressions $x=f(\theta)\cos\theta$ and
$y=f(\theta)\sin\theta$. These two equations completely specify the
curve, though the form $r=f(\theta)$ is simpler. The expanded form has
the virtue that it can easily be generalized to describe a wider range
of curves than can be specified in rectangular or polar coordinates.

Suppose $f(t)$ and $g(t)$ are functions. Then the equations
$x=f(t)$ and $y=g(t)$ describe a curve in the plane. In the case of
the polar coordinates equations, the variable $t$ is replaced by
$\theta$ which has a natural geometric interpretation. In general, $t$
is simply an arbitrary variable, often called in this case a
\dfont{parameter}\index{parameter}, and this method of specifying a curve is known as
\dfont{parametric equations}\index{parametric equations}\index{polar coordinates!parametric equations}. One
important interpretation of $t$ is {\it time}. In this interpretation,
the equations $x=f(t)$ and $y=g(t)$ give the position of an object at
time $t$.

\begin{example}{Position of a Path}{positionofapath}
 Describe the path of an object that moves so that its
position at time $t$ is given by $x=\cos t$, $\ds y=\cos^2 t$.
\end{example}

\begin{solution}
We see immediately that $\ds y=x^2$, so the path lies on this parabola. The path
is not the entire parabola, however, since $x=\cos t$ is always
between $-1$ and $1$. It is now easy to see that the object oscillates
back and forth on the parabola between the endpoints $(1,1)$ and
$(-1,1)$, and is at point $(1,1)$ at time $t=0$.
\end{solution}

It is sometimes quite easy to describe a complicated path in
parametric equations when rectangular and polar coordinate expressions
are difficult or impossible to devise.

\begin{example}{Wheel}{wheelexample}
 A wheel of radius 1 rolls along a straight line, say the
$x$-axis. A point on the rim of the wheel will trace out a curve, called a
cycloid. Assume the point starts at the origin; find
parametric equations for the curve.
\end{example}

\begin{solution}
Figure~\ref{fig:cycloid} illustrates the generation of the curve. The wheel is shown at its
starting point, and again after it has rolled through about 490
degrees. We take as our parameter $t$ the angle through which the
wheel has turned, measured as shown clockwise from the line connecting
the center of the wheel to the ground. Since the radius is 1, the
center of the wheel has coordinates $(t,1)$. We seek to write the
coordinates of the point on the rim as $(t+\Delta x,1+\Delta y)$,
where $\Delta x$ and $\Delta y$ are as shown in figure~\ref{fig:blow
  up of wheel}. These values are nearly the sine and cosine of the
angle $t$, from the unit circle definition of sine and
cosine. However, some care is required because we are measuring $t$
from a nonstandard starting line and in a clockwise direction, as
opposed to the usual counterclockwise direction. A bit of thought
reveals that $\Delta x=-\sin t$ and $\Delta y=-\cos t$. Thus the
parametric equations for the cycloid are $x=t-\sin t$, $y=1-\cos t$.
\end{solution}

%
%\figure[!ht]
%\centerline{\vbox{\beginpicture
%\normalgraphs
%%\sevenpoint
%\setcoordinatesystem units <7truemm,7truemm>
%\setplotarea x from 0 to 20, y from 0  to 2.2
%\axis left shiftedto x=0 /
%\axis bottom shiftedto y=0 /
%\setquadratic
%\textRed
%\plot 0.000 0.000 0.001 0.018 0.009 0.070 0.030 0.156 0.069 0.271
%0.133 0.412 0.226 0.574 0.351 0.751 0.510 0.937 0.704 1.125
%0.934 1.309 1.197 1.482 1.491 1.637 1.813 1.771 2.157 1.876
%2.518 1.951 2.891 1.992 3.267 1.998 3.642 1.969 4.007 1.905
%4.358 1.809 4.687 1.685 4.991 1.536 5.265 1.368 5.506 1.187
%5.712 1.000 5.883 0.813 6.019 0.632 6.122 0.464 6.195 0.315
%6.243 0.191 6.269 0.095 6.281 0.031 6.283 0.002 6.284 0.008
%6.288 0.049 6.304 0.124 6.337 0.229 6.392 0.363 6.475 0.518
%6.589 0.691 6.736 0.875 6.919 1.063 7.137 1.249 7.389 1.426
%7.673 1.588 7.986 1.729 8.323 1.844 8.680 1.930 9.049 1.982
%9.425 2.000 9.801 1.982 10.170 1.930 10.526 1.844 10.863 1.729
%11.176 1.588 11.461 1.426 11.713 1.249 11.931 1.063 12.113 0.875
%12.261 0.691 12.375 0.518 12.457 0.363 12.513 0.229 12.545 0.124
%12.561 0.049 12.566 0.008 12.566 0.002 12.569 0.031 12.580 0.095
%12.607 0.191 12.654 0.315 12.727 0.464 12.830 0.632 12.966 0.813
%13.137 1.000 13.343 1.187 13.584 1.368 13.858 1.536 14.162 1.685
%14.492 1.809 14.842 1.905 15.208 1.969 15.582 1.998 15.959 1.992
%16.331 1.951 16.692 1.876 17.037 1.771 17.358 1.637 17.652 1.482
%17.916 1.309 18.145 1.125 18.340 0.937 18.499 0.751 18.623 0.574
%18.716 0.412 18.780 0.271 18.820 0.156 18.841 0.070 18.848 0.018
%18.850 0.000 /
%\textBlack
%\plot 8.500 0.800 8.442 0.799 8.383 0.816 8.329 0.850 8.286 0.900
%8.258 0.962 8.248 1.033 8.259 1.105 8.291 1.174 8.343 1.233
%8.412 1.277 8.493 1.299 8.579 1.298 8.664 1.272 8.740 1.221
%8.800 1.150 8.839 1.061 8.851 0.963 8.835 0.863 8.791 0.769
%8.720 0.690 8.627 0.632 8.520 0.602 8.406 0.604 8.294 0.638
%8.195 0.704 8.116 0.797 8.066 0.910 8.049 1.036 8.068 1.164
%8.124 1.283 /
%\multiput {$\bullet$} at 0 0 7.70 1.602 /
%\put {$t$} [bl] <2pt,2pt> at 8.73 1.23
%\setlinear
%\plot 7.70 1.602 8.5 1 8.5 0 /
%\circulararc 360 degrees from 0 0 center at 0 1
%\circulararc 360 degrees from 8.5 0 center at 8.5 1
%\endpicture}}
%\caption{{A cycloid.} \label{fig:cycloid}}
%\endfigure

\figure[H]
\[
\includegraphics[width=4.5in]{images/7-cycloid}
\]
\caption{{A cycloid.} \label{fig:cycloid}}
\endfigure

\figure[H]
\centerline{\vbox{\beginpicture
\normalgraphs
%\sevenpoint
\setcoordinatesystem units <15truemm,15truemm>
\setplotarea x from -1 to 1, y from 0 to 2
\multiput {$\bullet$} at -0.8 1.602 /
%\plot 0.000 0.800 -0.058 0.799 -0.117 0.816 -0.171 0.850 -0.214 0.900
%-0.242 0.962 -0.252 1.033 -0.241 1.105 -0.209 1.174 -0.157 1.233
%-0.088 1.277 -0.007 1.299 0.079 1.298 0.164 1.272 0.240 1.221
%0.300 1.150 0.339 1.061 0.351 0.963 0.335 0.863 0.291 0.769
%0.220 0.690 0.127 0.632 0.020 0.602 -0.094 0.604 -0.206 0.638
%-0.305 0.704 -0.384 0.797 -0.434 0.910 -0.451 1.036 -0.432 1.164
%-0.376 1.283 /
\putrule from -0.8 1.602 to -0.8 1
\putrule from -0.8 1 to 0 1
\put {$\Delta x$} [t] <0pt,-2pt> at -0.4 1
\put {$\Delta y$} [l] <2pt,0pt> at -0.8 1.2
\setlinear
\plot -0.8 1.602 0 1 0 0 /
\circulararc 360 degrees from 0 0 center at 0 1
\endpicture}}
\caption{{The wheel.} \label{fig:blow up of wheel}}
\endfigure

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Opensolutionfile{solutions}[ex]
\section*{Exercises for \ref{sec:Parametric Equations}}

\begin{enumialphparenastyle}

%%%%%%%%%%
\begin{ex}
 What curve is described by $\ds x=t^2$, $\ds y=t^4$? If $t$ is
interpreted as time, describe how the object moves on the curve.
\end{ex}

%%%%%%%%%%
\begin{ex}
 What curve is described by $x=3\cos t$, $y=3\sin t$? If $t$ is
interpreted as time, describe how the object moves on the curve.
\end{ex}

%%%%%%%%%%
\begin{ex}
 What curve is described by $x=3\cos t$, $y=2\sin t$? If $t$ is
interpreted as time, describe how the object moves on the curve.
\end{ex}

%%%%%%%%%%
\begin{ex}
 What curve is described by $x=3\sin t$, $y=3\cos t$? If $t$ is
interpreted as time, describe how the object moves on the curve.
\end{ex}

%%%%%%%%%%
\begin{ex}
 Sketch the curve described by $\ds x=t^3-t$, $\ds y=t^2$. If $t$ is
interpreted as time, describe how the object moves on the curve.
\end{ex}

%%%%%%%%%%%
\begin{ex}\label{exer:pseudo cycloid}
 A wheel of radius 1 rolls along a straight line, say the
$x$-axis. A point $P$ is located halfway between the center of the
wheel and the rim; assume $P$ starts at the point $(0,1/2)$. As the
wheel rolls, $P$ traces a curve; find parametric equations for the
curve.
\begin{sol}
 $\ds x=t-{\sin(t)\over2}$, $\ds t=1-{\cos(t)\over2}$
\end{sol}
\end{ex}

%%%%%%%%%%%
%\\begin{ex}
% A wheel of radius 1 rolls around the outside of a circle of
%radius 3. A point $P$ on the rim of the wheel traces out a curve
%called a \dfont{hypercycloid}, as indicated in
%figure~\ref{fig:hypercycloid and hypocycloid}.  Assuming $P$
%starts at the point $(3,0)$, find parametric equations for the curve.
%\begin{sol}
% $x=4\cos t-\cos(4t)$,\hfill\break  $y=4\sin t-\sin(4t)$
%\end{sol}
%\end{ex}
%\exrdef{exer:hypercycloid}
%
%\figure
%\vbox{\beginpicture
%\normalgraphs
%\sevenpoint
%\setcoordinatesystem units <7truemm,7truemm>
%\setplotarea x from -5 to 5, y from -5  to 5
%\axis left shiftedto x=0 /
%\axis bottom shiftedto y=0 /
%\multiput {$\bullet$} at 2.81 4.12 3 0 /
%\circulararc 360 degrees from 2.81 4.12 center at 2.16 3.366
%\circulararc 360 degrees from 0 3 center at 0 0
%\circulararc 360 degrees from 5 0 center at 4 0
%\textRed
%\setquadratic
%\plot 3.000 0.000 3.024 0.002 3.092 0.020 3.200 0.065 3.339 0.150
%3.495 0.285 3.656 0.474 3.807 0.721 3.931 1.022 4.015 1.373
%4.045 1.763 4.012 2.182 3.908 2.613 3.730 3.041 3.479 3.450
%3.160 3.824 2.781 4.148 2.353 4.410 1.890 4.602 1.410 4.717
%0.927 4.755 0.459 4.719 0.021 4.614 -0.375 4.450 -0.717 4.241
%-1.000 4.000 -1.220 3.743 -1.378 3.487 -1.478 3.245 -1.531 3.030
%-1.545 2.853 -1.535 2.721 -1.516 2.637 -1.501 2.600 -1.506 2.607
%-1.542 2.648 -1.620 2.714 -1.746 2.791 -1.924 2.864 -2.152 2.918
%-2.427 2.939 -2.740 2.914 -3.079 2.832 -3.432 2.685 -3.782 2.471
%-4.113 2.187 -4.410 1.839 -4.658 1.434 -4.845 0.983 -4.961 0.500
%-5.000 0.000 -4.961 -0.500 -4.845 -0.983 -4.658 -1.434 -4.410 -1.839
%-4.113 -2.187 -3.782 -2.471 -3.432 -2.685 -3.079 -2.832 -2.740 -2.914
%-2.427 -2.939 -2.152 -2.918 -1.924 -2.864 -1.746 -2.791 -1.620 -2.714
%-1.542 -2.648 -1.506 -2.607 -1.501 -2.600 -1.516 -2.637 -1.535 -2.721
%-1.545 -2.853 -1.531 -3.030 -1.478 -3.245 -1.378 -3.487 -1.220 -3.743
%-1.000 -4.000 -0.717 -4.241 -0.375 -4.450 0.021 -4.614 0.459 -4.719
%0.927 -4.755 1.410 -4.717 1.890 -4.602 2.353 -4.410 2.781 -4.148
%3.160 -3.824 3.479 -3.450 3.730 -3.041 3.908 -2.613 4.012 -2.182
%4.045 -1.763 4.015 -1.373 3.931 -1.022 3.807 -0.721 3.656 -0.474
%3.495 -0.285 3.339 -0.150 3.200 -0.065 3.092 -0.020 3.024 -0.002
%3.000 0.000 /
%\textBlack
%\setcoordinatesystem units <7truemm,7truemm> point at -12 0
%\setplotarea x from -3.5 to 3.5, y from -3.5  to 3.5
%\axis left shiftedto x=0 /
%\axis bottom shiftedto y=0 /
%\multiput {$\bullet$} at 3 0 /
%%\circulararc 360 degrees from 2.81 4.12 center at 2.16 3.366
%\circulararc 360 degrees from 0 3 center at 0 0
%\circulararc 360 degrees from 3 0 center at 2 0
%\textRed
%\setquadratic
%\plot 3.000 0.000 2.985 0.000 2.942 0.003 2.870 0.009 2.771 0.021
%2.645 0.041 2.496 0.070 2.325 0.110 2.134 0.161 1.927 0.225
%1.706 0.301 1.474 0.390 1.234 0.492 0.989 0.606 0.744 0.731
%0.500 0.866 0.261 1.010 0.030 1.160 -0.191 1.314 -0.399 1.471
%-0.592 1.628 -0.769 1.781 -0.928 1.929 -1.067 2.069 -1.187 2.197
%-1.287 2.312 -1.367 2.410 -1.427 2.490 -1.469 2.549 -1.492 2.586
%-1.500 2.598 -1.493 2.585 -1.473 2.546 -1.443 2.481 -1.404 2.389
%-1.358 2.270 -1.309 2.127 -1.258 1.959 -1.207 1.768 -1.158 1.557
%-1.113 1.327 -1.074 1.081 -1.043 0.823 -1.019 0.554 -1.005 0.279
%-1.000 0.000 -1.005 -0.279 -1.019 -0.554 -1.043 -0.823 -1.074 -1.081
%-1.113 -1.327 -1.158 -1.557 -1.207 -1.768 -1.258 -1.959 -1.309 -2.127
%-1.358 -2.270 -1.404 -2.389 -1.443 -2.481 -1.473 -2.546 -1.493 -2.585
%-1.500 -2.598 -1.492 -2.586 -1.469 -2.549 -1.427 -2.490 -1.367 -2.410
%-1.287 -2.312 -1.187 -2.197 -1.067 -2.069 -0.928 -1.929 -0.769 -1.781
%-0.592 -1.628 -0.399 -1.471 -0.191 -1.314 0.030 -1.160 0.261 -1.010
%0.500 -0.866 0.744 -0.731 0.989 -0.606 1.234 -0.492 1.474 -0.390
%1.706 -0.301 1.927 -0.225 2.134 -0.161 2.325 -0.110 2.496 -0.070
%2.645 -0.041 2.771 -0.021 2.870 -0.009 2.942 -0.003 2.985 -0.000
%3.000 0.000 /
%\textBlack
%\endpicture}
%\label{fig:hypercycloid and hypocycloid}
%\endfigure{A hypercycloid and a hypocycloid.}
%
%
%%%%%%%%%%%
%\\begin{ex}
% A wheel of radius 1 rolls around the inside of
%a circle of radius 3. A point $P$ on the rim of the wheel traces out a
%curve called a \dfont{hypocycloid}, as indicated in
%figure~\ref{fig:hypercycloid and hypocycloid}. Assuming $P$
%starts at the point $(3,0)$, find parametric equations for the curve.
%\begin{sol}
% $x=2\cos t+\cos(2t)$,\hfill\break $y=2\sin t-\sin(2t)$
%\end{sol}
%\end{ex}
%\exrdef{exer:hypocycloid}
%
%%%%%%%%%%%
%\\begin{ex}
% An \dfont{involute\index{involute}} of a circle is formed
%as follows: Imagine that a long (that is, infinite) string is wound tightly
%around a circle, and that you grasp the end of the string and begin to
%unwind it, keeping the string taut. The end of the string traces out
%the involute. Find parametric equations for this curve, using a circle
%of radius 1, and assuming that the string unwinds counter-clockwise
%and the end of the string is initially at $(1,0)$.
%Figure~\ref{fig:involute} shows part of the curve; the
%dotted lines represent the string at a few different times.
%\begin{sol}
% $x=\cos t+t\sin t$,\hfill\break  $y=\sin t-t\cos t$
%\end{sol}
%\end{ex}
%\exrdef{exer:involute of a circle}
%
%\figure
%\vbox{\beginpicture
%\normalgraphs
%\sevenpoint
%\setcoordinatesystem units <7truemm,7truemm>
%\setplotarea x from -5 to 2, y from -4  to 3.5
%\axis left shiftedto x=0 /
%\axis bottom shiftedto y=0 /
%\circulararc 360 degrees from 0 1 center at 0 0
%\setquadratic
%\textRed
%\plot 1.000 0.000 1.002 0.000 1.008 0.001 1.018 0.002 1.031 0.005
%1.048 0.010 1.069 0.018 1.092 0.028 1.118 0.041 1.147 0.058
%1.178 0.079 1.211 0.105 1.245 0.135 1.280 0.170 1.315 0.210
%1.350 0.255 1.385 0.306 1.418 0.362 1.449 0.423 1.478 0.490
%1.504 0.563 1.527 0.640 1.545 0.723 1.559 0.811 1.568 0.903
%1.571 1.000 1.568 1.101 1.558 1.205 1.541 1.312 1.516 1.422
%1.484 1.534 1.443 1.647 1.393 1.761 1.335 1.875 1.268 1.989
%1.191 2.102 1.105 2.212 1.010 2.320 0.905 2.425 0.791 2.526
%0.668 2.621 0.536 2.711 0.395 2.794 0.246 2.870 0.088 2.939
%-0.077 2.998 -0.250 3.048 -0.429 3.088 -0.614 3.117 -0.805 3.135
%-1.000 3.142 -1.199 3.135 -1.402 3.116 -1.606 3.084 -1.812 3.038
%-2.019 2.978 -2.225 2.903 -2.430 2.815 -2.632 2.712 -2.831 2.594
%-3.025 2.462 -3.214 2.316 -3.396 2.155 -3.570 1.981 -3.736 1.793
%-3.892 1.592 -4.037 1.378 -4.171 1.152 -4.292 0.914 -4.399 0.666
%-4.492 0.408 -4.570 0.141 -4.631 -0.135 -4.676 -0.417 -4.703 -0.706
%-4.712 -1.000 -4.703 -1.298 -4.675 -1.598 -4.627 -1.901 -4.559 -2.203
%-4.472 -2.504 -4.364 -2.803 -4.236 -3.099 -4.088 -3.389 -3.920 -3.672 /
%%-3.733 -3.948
%%-3.526 -4.215 -3.300 -4.471 -3.056 -4.715 -2.794 -4.946
%%-2.515 -5.163 -2.219 -5.363 -1.908 -5.547 -1.583 -5.713 -1.244 -5.860
%%-0.893 -5.986 -0.531 -6.091 -0.160 -6.174 0.220 -6.234 0.607 -6.271
%%1.000 -6.283 /
%\textBlack
%\setlinear\setdashes <2pt>
%\plot 0.54 0.84 1.38 0.3 /
%\plot -0.65 -0.757 -3.68 1.86 /
%\plot -0.42 0.91 1.4 1.74 /
%\endpicture}
%\label{fig:involute}
%\endfigure{An involute of a circle.}
%
%\end%%%%%%%%%%
%\\begin{ex}
%s

\end{enumialphparenastyle}