With the new flurry of interest in the scaling behavior of CASTRO, we've run some tests on Franklin.
\section{Sod Problem in 3D}
We ran the Sod problem (inputs-test2-x) for 10 time steps with max\_level = 0 on 4, 32, 256, 2048 and 16384 processors. This is a gamma-law gas with no reactions and one species. On 4 processors the base grid was 512x128x128; for each factor of 8 increase in processors we doubled the number of cells in each direction. We set max\_grid\_size = 64 for all cases, resulting in 256 grids per processor. (Thus for perfect scaling we would expect this plot to be flat.)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[h]
\centering
\includegraphics[width=5in]{Scaling/Sod_scaling}
\caption{Scaling behavior of Sod problem on franklin.nersc.gov}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{White Dwarf in 3D}\label{Sec:White Dwarf in 3D}
This test was performed on 6/1/09 using ScalingTest/inputs.nog, inputs.g3, inputs.g5, inputs.g3.2levels, and inputs.g5.2levels on jaguarpf.  Here we interpolated a 1D initial model of a white dwarf onto a 3D Cartesian grid and ran 5 time steps. This problem used the Helmholtz EOS with no reactions, no thermal diffusion, and three species.

We ran this problem on 8, 64, 512, 4096, 13824, 32768, and 64000 processors.  The base grid size, respectively, was $128^3, 256^3, 512^3, 1024^3, 1536^3, 2048^3$, and $2560^3$.  We ran with no gravity (castro.do\_grav = 0), gravity type 3 (Poisson solver using multigrid) and gravity type 5 (1D integration of the averaged radial density to define a monopole approximation for gravity), each with max\_level=0.  We also ran with gravity types 3 and 5 with max\_level=1.  The fine grid structure had the exact same grid structure as the coarse level and was centered in the domain.  For all cases max\_grid\_size = 64, so there was 1 processor per grid per level.  Thus for perfect scaling we would expect this plot to be flat.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{figure}[h]
\centering
\includegraphics[width=5in]{Scaling/scaling_jaguarpf}
\caption{Scaling behavior of ScalingTest problem on jaguarpf.ccs.ornl.gov}
\end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%
%%  chapter06.tex - Obstacle Detection and Planning for Autonomous Vehicles based on Computer Vision Techniques
%%
%%  Copyright 2014 Néstor Morales <nestor@isaatc.ull.es>
%%
%%  This work is licensed under a Creative Commons Attribution 4.0 International License.
%%

\graphicspath{{./images/chapter06/bmps/}{./images/chapter06/vects/}{./images/chapter06/}}

\chapter{Global Planning}\label{ch:chapter06}

Until now, we have seen methods oriented to the detection and, eventually, tracking of objects based on computer vision. However, we still need a strategy that allows an intelligent response when an obstacle is found, while being able to efficiently reach a given point in the map. For this purpose, we implemented a planning schema that, given a map, a localization and information about the obstacles in the neighborhood, will allow us to reach a given target safe and efficiently. We divided this schema into global planning, which will be explained in this chapter; and local planning, explained in chapter \ref{ch:chapter07}.

In the global planning level, given a goal, the algorithm is able to generate a trajectory, which will be then followed by the local planner. Despite of the fact that this level is aimed to perform a background planning in which we do not need to react to the dynamic obstacles, we have implemented our method in such a way in which it would be able to modify its trajectory if a dynamic obstacle intercepts it.

The method we designed for this task uses a \ac{MSVM} for the generation of smooth, safe and short paths. Several approaches have been made in this sense, as those shown in section \ref{ch:chapter00_02_06}, but as far as we are concerned this is the first time that Multiclass \acs{SVM} are used. The idea is that for each class (corresponding to an obstacle in the map), we train a \ac{SVM} so we can use the decision boundary as a path that can be followed to avoid the obstacle. By repeating the same process for all objects, we will get all the paths capable of avoiding an obstacle, which will be crossed with other paths in certain points. Using these points as nodes, it is possible to create a graph which can be used to find a fast way between any two points in the map. Sometimes, some boundaries do not cross each other, even where the area between them is clear. To solve this problem, we use a \ac{RNG}, with the consideration that edges will be only added if they are far enough to an obstacle.

In general, the main advantages of using \ac{SVM}  are listed in \cite{miura2006support}:

\begin{enumerate}
\item With \ac{SVM}, it is possible to generate non-linear hyperplanes which limit areas in the ground, allowing the generation of smooth paths.
\item Margin maximization allows performing a safe search strategy, ensuring that the path will always be at a certain distance the obstacles.
\item By using \acp{SVM}, the uncertainty due to the errors introduced by sensors is reduced, since they try to maximize the distance to the points that define different obstacles. If it is not possible to define a line that clearly divides two different regions, a function that tries to minimize this effect is generated.
\end{enumerate}

In addition to these features, the use of \acl{MSVM} adds another advantage.  By using them, \emph{all} possible routes in a map can be generated ensuring that they will be safe (the distance to the obstacles will be optimal) and smooth.

The method has been implemented and the code\footnote{\url{https://github.com/nestormh/svm_path_planner}}, as well as a set of videos (\url{http://youtu.be/f-tdMnHPhM8}, \url{http://youtu.be/qyqLH1huePw}) showing the performance of the algorithm and some comparisons with other methods, are available. In our implementation, we have developed a set of subroutines based on \acs{CUDA} libraries\footnote{\url{http://www.nvidia.com}}. This allowed us taking advantage of the parallel processing capabilities of the \ac{GPU}, being able to achieve a good performance without the need of expensive hardware.

\section{Method}\label{ch:chapter06_01}

For optimization purposes, the method shows two different behaviors depending on if it is the first execution or not. In the first execution, an initial map of the world is created, as well as the associated initial graph. This map can have a lower resolution than that to be used in successive iterations, as we do not need so much precision in areas far away from the current robot position. In successive executions, the graph will be extended depending on the obstacles found by the robot.

In figure \ref{fig:cp06_pipeline}, the pipeline followed by the method described in this chapter is represented. There, we distinguish between initial execution and successive iterations. In the first execution, we define the base graph, which is based just on the static obstacles shown in the map. Later, graph is updated with the obstacles and the vehicle itself. The graph generation process is composed by a clustering and obstacle inflation process, from which a set of labeled points corresponding to the contour of the safe area around obstacles are obtained. Then, we train a Multiclass \ac{SVM}, from which we will extract the decision boundaries, that will be used for the construction of the decision graph. From it, we will get the final path using graph based techniques.

\begin{figure}[h!]
      \centering
      \includegraphics[width=\textwidth, height=\textwidth]{pipeline}
      \caption{ Pipeline followed in the method described in this chapter. }
      \label{fig:cp06_pipeline}
\end{figure}

In successive iterations, obstacles and the footprint of the vehicle itself will generate a new set of contour points that will be added to the input of the \ac{MSVM}. By doing this, we just compute the boundaries for affected obstacles, avoiding to repeat the whole process for all the map.

\subsection{First execution}\label{ch:chapter06_01_01}

The generation of the initial graph is composed by the following steps:

\begin{figure}[h!]
  \centering
  \includegraphics[width=\textwidth, height=0.75\textwidth]{figure1}
  \caption{Obstacles inflation.}
  \label{fig:cp06_obst_inflation}
\end{figure}

\subsubsection{Obstacles Inflation}\label{ch:chapter06_01_01_01}

In our implementation, we have considered the world map as a grid of a certain resolution in which obstacles are represented using a values from 0 to 255, where 0 represents a free area and 255 is an obstacle. This costmap is better explained in section \ref{ch:chapter07_01_01}, in the next chapter. Using this map, we calculate the cost for each cell $c(x,y)$ of the map using the following function:

\begin{equation}\label{eq:cp06_cell_cost}
 cost(c) = 253 * \exp( -1 \cdot \beta \cdot (\| nearest(c) - c\| - \rho) )
\end{equation}

, where $\beta$ is a scaling factor that increases/decreases the slope of the cost function, $nearest(c)$ is the position of the nearest cell in the map to the cell $c$ marked as obstacle, and $\rho$ is the circumscribed radius of the robot. The function is scaled to $253$ as 254 and 255 are reserved values. Based on the cost map generated, we mark all values over a threshold $\tau$ as obstacle, so the cost map becomes a binary matrix. From this matrix we extract the boundaries using the method in \cite{suzuki1985topological}. In figure \ref{fig:cp06_obst_inflation}, the output after doing this step is shown.

\subsubsection{Obstacles Clustering}\label{ch:chapter06_01_01_02}

The boundaries obtained in the previous step are used as input for the obstacles clustering stage. At this point, we have a cloud of points $\mathcal{P}$ from which we do not know if they belong to the same obstacle or not. This clustering is done using the method described in \cite{rusu2009semantic}. The procedure is described at algorithm \ref{alg:obstacles_clustering}.

\begin{algorithm}[h!]
\caption{Obstacles clustering}
\label{alg:obstacles_clustering}
\begin{algorithmic}
\ForAll{$p_i \in \mathcal{P}$}
  \State add $p_i$ to the queue $\mathcal{Q}$.
  \ForAll{$p_i \in \mathcal{Q}$}
    \State look for the set of neighbors of $p_i$, $\mathcal{P}_i^k$, inside a circle of radius $d_{obst}$.
    \ForAll{$p_i^k \in \mathcal{P}_i^k$}
      \If{\textbf{not} $p_i^k$ is processed}
	\State add $p_i^k$ to $\mathcal{Q}$.
      \EndIf
    \EndFor
    \If {all points in $\mathcal{Q}$ have been processed}
      \State add $\mathcal{Q}$ to the list of clusters $\mathcal{C}$.
      \State reset $\mathcal{Q}$ to an empty list.
    \EndIf
  \EndFor
\EndFor
\end{algorithmic}
\end{algorithm}

In this algorithm, $d_{obst}$ is the maximal distance between a pair of points to consider them to belong to different obstacles.

\subsubsection{\ac{SVM} Training}\label{ch:chapter06_01_01_03}

Once we have clustered the inflated obstacles into different objects, we want to know which is the best path between them in terms of distance to the obstacles and smoothness. The way in which this is done makes the difference with respect to other \ac{SVM} based path planning algorithms. Unlike the methods seen at the Introduction of this thesis (section \ref{ch:chapter00_02_06}), our method uses a Multiclass \acs{SVM} in order to obtain the best path between the obstacles. In general, in classification, generation of a solution for the multiclass classification in a single step is usually avoided. Instead of this, a combination of several binary \ac{SVM} classifiers is used. The most known methods for doing that, based on the review in \cite{hsu2002comparison, duan2005best}, are:

\begin{itemize}
 \item One-versus all using winner-takes-all.
 \item One-versus-one using max-wins voting.
 \item Directed Acyclic Graph SVM (DAGSVM).
\end{itemize}

In our implementation we used a one-versus-all strategy. That is, for each set of points $C_i$ corresponding to a cluster in the set of clusters $\mathcal{C}$, we create two classes, one formed by the point set $C_i$, and the other composed by the points belonging to the remaining clusters $\{\mathcal{C} - C_i\}$. From these two classes, we train a single \ac{SVM}, which will give us the parameters $\alpha_k$ corresponding to the support vectors $x_k$ and their labels $y_k$, which will be later used by the equation \ref{eq:appendixSVM_soft_discriminative_function}. In our implementation, we used a \acs{GPU} based implementation of the \ac{SVM}, described in \cite{athanasopoulos2011gpu}. The use of this implementation improved notably the time required by our implementation for the \ac{SVM} training step.

\subsubsection{Boundary extraction}\label{ch:chapter06_01_01_04}

Once we have obtained the parameters $\alpha_k$, $x_k$ and $y_k$, we need to know where the decision boundary is for each class. That is, based on the equation \ref{eq:appendixSVM_soft_discriminative_function}, we look for the $x$ points that satisfy:

\begin{equation}\label{eq:cp06_decision_boundary}
 y = \sum_{k \in S} \alpha_k y_k K(x_k, x) + b = 0
\end{equation}

These points will allow us obtaining a non-linear decision curve. In figure \ref{fig:cp06_decision_boundary_3d}, we have represented, for each cell $(x,y)$ in a map, the values obtained from equation \ref{eq:cp06_decision_boundary} as their $Z$ coordinate, using the parameters obtained after training a given class. The plane represented in black is $Z=0$, so all cells in which this plane intersects with the named function will belong to a path.
In fact, as solving the equation \ref{eq:cp06_decision_boundary} can be too computationally expensive, we have optimized the implementation of this step as follows: First, we sample the map into a grid of a given resolution. For each cell in the map, we obtain the value given by equation \ref{eq:cp06_decision_boundary}. If positive, we assign $1$ to this cell. Else, we assign $0$. This process is executed over the \ac{GPU} using a \ac{CUDA} function developed for this purpose, so it is fully parallelized, taking a very small amount of time to check all the cells, obtaining even better times than in, for example, other \ac{DP} based approaches.

\begin{figure}[h!]
  \centering
  \includegraphics[width=\textwidth, trim=0 0 0 0,clip]{figure2}
  \caption{Output of \ref{eq:appendixSVM_soft_discriminative_function} for a given class.}
  \label{fig:cp06_decision_boundary_3d}
\end{figure}

Once we created the new map, we extract the decision boundaries. Points are stored in the point set $\mathcal{B}$, which will be shared by all classes. At this point we do not store neighborhood information, but we add to each point $p_i$ a label $l_i$, in order to know the class from which they were initially generated. This information will be used in the graph generation stage.

\subsubsection{Graph generation}\label{ch:chapter06_01_01_05}

The graph generation stage takes as input the points in $\mathcal{B}$ and tries to generate a connectivity graph that will be used later to obtain the shortest paths between points pairs in the map. At a first glance, we could just connect all the points generated by the same class , and join those subgraphs by the points in which the decision boundaries cross each other. Unfortunately, we can not do that because there are situations where there is a big free of obstacles area, which avoids the connections between two classes, making it impossible to travel from the path belonging to one class to the other. This effect can be observed for some of the obstacles represented in figure \ref{fig:cp06_nng}.
To solve this problem, in our method we propose a combination of a \acf{RNG} based on the Delaunay triangulation \citep{lingas1994linear}, and a \acf{NNG} \citep{eppstein1997nearest}.

\paragraph{\acf{NNG}}\label{ch:chapter06_01_01_05_01}

In order to obtain the \ac{NNG}, we calculate a $kd-tree$ for the points in $\mathcal{B}$. For each point in $\mathcal{B}$, we look for the neighbors inside a given radius circle. If there are not obstacles between the point $u$ and a certain neighbor $v$, an edge $e(u,v)$ is added to the graph. By doing this, we allow the robot to go from the path obtained from a class to another if points are close enough and there are not obstacles in the neighborhood. In figure \ref{fig:cp06_nng}, we can see the graph as it would look like at this point of the execution. As can be seen, there are some boundaries that are not connected, despite that there is a free area between them. This problem is solved with the \acf{RNG}.

\begin{figure}[h!]
  \centering
  \includegraphics[width=\textwidth, height=0.75\textwidth]{figure3}
  \caption{\acf{NNG}.}
  \label{fig:cp06_nng}
\end{figure}

\paragraph{\acf{RNG}}\label{ch:chapter06_01_01_05_02}

For the generation of the \ac{RNG}, we use the set of labels $l_i \in \mathcal{L}$ described in section \ref{ch:chapter06_01_01_04}. First, we obtain the Delaunay Triangulation \citep{su1997comparison} using the points in $\mathcal{B}$ as input. In our implementation, we used the method in \cite{rong2008computing} for that. Then, we iterate through the edges $e(u,v)$ of the triangles. For each one of these edges, we check that there are not obstacles between $u$ and $v$. If this condition is true, and $l_u \neq l_v$, the edge $e$ is added to our graph. In our implementation, we process all edges simultaneously over the \acs{GPU}, saving a lot of time. Edges obtained by the \ac{NNG} are tested, too. The obtained graph is depicted in figure \ref{fig:cp06_rng}.

\begin{figure}[h!]
  \centering
  \includegraphics[width=\textwidth, height=0.75\textwidth]{figure4}
  \caption{\acf{RNG}.}
  \label{fig:cp06_rng}
\end{figure}%

At this point, we have a graph that allows us going from any point in the map to another ensuring a safe and smooth path. However, in successive iterations, there could be obstacles that were not there when the initial map was created, so the graph must be updated in the following executions. The process that solves this situation is explained in the following section.

\subsection{Successive executions}\label{ch:chapter06_01_02}

The steps in the successive executions are quite similar to those in the initial execution. However, for optimization purposes, we do not need to recalculate the whole map in each execution, but extend the map we had from the previous one. The steps needed are the following:

\subsubsection{Obstacles Inflation and clustering}\label{ch:chapter06_01_02_01}

This step is similar to that described in section \ref{ch:chapter06_01_01_01}. The only difference is that points from the inflation boundary are compared to those in the original map. To do that, we calculate a $kd-tree$ from the set of points obtained in the first execution, $\mathcal{O}_{old}$. Then, for each point $o_i$ in the new set, $\mathcal{O}_{new}$, we look for the nearest point in $\mathcal{O}_{new}$. If the nearest point of $o_i$ is nearer than a given threshold, it is removed from $\mathcal{O}_{new}$. Then, the clustering step is performed similarly as happened in the first execution, but with the filtered set $\mathcal{O}_{new}$.

\subsubsection{Footprint generation}\label{ch:chapter06_01_02_02}

We want to get the path starting from an initial point (which coincides with the current position of the robot in the map) towards to a goal. To do this, we need to add a pair of fake obstacles that help to generate the trajectory the robot will follow from its current position towards the nearest point in the graph, and from the graph to the goal. These fake obstacles will also prevent the robot from starting the trajectory in an impossible angle given its current orientation. Same applies for the desired goal position and orientation. Before starting all the process, we check that we are not currently in a collision with an obstacle. In this case, the process is aborted and recovery behaviors should be triggered. If everything is right, we generate a set of points ($\mathcal{F}_L$) that go from the position $A(-\rho, +\rho)$ to the position $B(\rho, \rho)$, and another one ($\mathcal{F}_R$) coming from $C(-\rho, -\rho)$ to $D(\rho, -\rho)$, being $\rho$ the circumscribed radius of the robot defined in section \ref{ch:chapter06_01_01_01}.

\begin{figure}[h!]
  \centering
  \includegraphics[width=\textwidth, trim=0 0 0 0,clip]{figure5}
  \caption{Footprint generation.}
  \label{fig:cp06_footprint_generation}
\end{figure}%

In figure \ref{fig:cp06_footprint_generation}, this process is represented, as well as points $A$, $B$, $C$ and $D$. Each point set will be considered as a class in the following. Coordinates of the obtained point sets $\mathcal{F}_L$ and $\mathcal{F}_R$ are relative to the robot position, so we must transform them to map coordinates using the transformation matrix

\begin{equation}\label{eq:cp06_Rt_footprint}
 Rt = \left ( \begin{array}{ ccc }
  \cos(\theta_s) & -\sin(\theta_s) & s_x \\
  \cos(\theta_s) & -\sin(\theta_s) & s_y \\
  0 & 0 & 1
 \end{array} \right )
\end{equation}

, where $s(x,y)$ is the starting point (the current point of the robot), and $\theta_s$ its orientation. Once we have $Rt$, each point $f_{L,i} \in \mathcal{F}_L$ is transformed so its new position $f'_{L,i}$ becomes ${f'}_{L,i}^T = Rt \cdot f_{L,i}^T$. Same applies to the points in $\mathcal{F}_R$.

The same process is performed for the goal point $g(x,y)$ and its orientation $\theta_g$. At this point, we have limited the orientation of the vehicle in the start and goal points, but not its direction. This limitation will be controlled in the process described in section \ref{ch:chapter06_01_02_04_01}. If we would have closed the obstacle by joining the points $A$ and $C$ with a new set of points, we would be in  risk of having imprecise decision boundaries, preventing us from finding a feasible path.

\subsubsection{\ac{SVM} training, boundary extraction and graph generation}\label{ch:chapter06_01_02_03}

Once we have got the classes related to the new points given by the sensors of the robot, and the four classes corresponding to the footprints, the stages of \ac{SVM} training, boundary extraction and graph generation are exactly the same described in section \ref{ch:chapter06_01_01}. The only difference is that we remove the paths that were in the original graph but that are not longer traversable due to the presence of dynamic obstacles. Anyway, as we consider that the initial iteration contains just static obstacles, the original graph is stored for its use in future executions.

\subsubsection{Shortest path calculation}\label{ch:chapter06_01_02_04}

At this point, we have a graph with all the feasible paths in the map completely updated, including the new obstacles. With this graph, it is possible to find a safe and smooth path between the given starting and goal positions and their orientations.

\paragraph{\underline{Looking for the starting and goal points into the graph:}}\label{ch:chapter06_01_02_04_01}

As said in section \ref{ch:chapter06_01_02_02}, we have limited the robot to start with a given orientation, but at this point we are still not taking its direction into account. To solve this, given the current position of the robot and the goal, $s(x,y)$ and $g(x,y)$, and their orientations, $\theta_s$ and $\theta_g$, we obtain the points

\begin{equation}\label{eq:cp06_start_goal_points}
\begin {array}{l}
 s_1 = (s_x + \rho * \cos(\theta_s), s_y + \rho * \sin(\theta_s)) \\
 g_1 = (g_x - \rho * \cos(\theta_g), g_y - \rho * \sin(\theta_g))
\end{array}
\end{equation}

Then, we use the points $s_1$ and $g_1$ to look for the nearest point in the graph, using the kd-tree previously created in the previous sections. These points, $s_2$ and $g_2$, will be the ones used by the Dijkstra shortest path algorithm to find a path. This operation is better described in figure \ref{fig:cp06_findstartgoal}. Using the current position of the robot (starting point $s$), represented in red, and its orientation, we obtain the point $s_1$ (the point in magenta) based on the equation \ref{eq:cp06_start_goal_points}. In the graph, the nearest point to $s_1$ , $s_2$ , is the initial point used by Dijkstra algorithm.

\begin{figure}[h!]
  \centering
  \includegraphics[width=\textwidth, trim=0 0 0 0,clip]{figure6}
  \caption{Starting and goal point selection process.}
  \label{fig:cp06_findstartgoal}
\end{figure}

\paragraph{\underline{Looking for the shortest path:}}\label{ch:chapter06_01_02_04_02}

Before applying Dijkstra, we need to know if the goal is reachable. To do that, we check the graph connectivity. If $s_2$ and $g_2$ are in the same connected component, the goal is reachable. This checking is needed because there will be a graph in every place in which there is a hole between the limits obtained in the obstacles inflation step. This is because it is faster making a connectivity checking than testing whether a graph is in a traversable area or not. We suppose that the robot will always start in a valid area.
Once we have done this verification, Dijkstra is applied and the path is obtained. Points $s$ and $g$ are added to the beginning and the end of the path. The whole implementation of the algorithm has been tested on a PC i7-3630QM with 8GB RAM and a NVIDIA GT 640M, being able to work in a real time navigation application for an autonomous robot.

Some improvements could be incorporated to the current method, like using the extended \ac{SVM} version described in \cite{qingyang2012local}, which would allow satisfying additional restrictions, such as the robot position or heading. Also, the path generated by our method could be smoothed again using a second \ac{SVM} step, as done for the path generated by the Voronoi diagrams in \cite{yang2012safe}.

In figure \ref{fig:cp06_final_path}, the final path obtained by the algorithm is shown. In chapter \ref{ch:chapter08}, some results are shown, demonstrating the good behavior of the method, comparing it with some of the best path planning algorithms based on \ac{SVM}.

\begin{figure}[h!]
  \centering
  \includegraphics[width=\textwidth, height=0.75\textwidth]{figure7}
  \caption{Final path.}
  \label{fig:cp06_final_path}
\end{figure}

\section{Summary}\label{ch:chapter06_03}

In this chapter, we have shown an alternative to classical path planning methods, based on a \acf{MSVM}. Advantages of using this method as a base for our algorithm are that we can generate continuous non-linear separating surfaces between classes that, joined all together, allow the creation of a graph used for the generation of smooth, short and safe paths. The method has been developed taking advantage of the use of a \ac{GPU} in order to reduce the required computational time.

In this method, we have considered an initial graph, which is extended in the following iterations, allowing the inclusion of new obstacles and the influence of the vehicle itself in the generation of trajectories. This method was thought for an early version of the local planner described in the next chapter, in which we needed the trajectory to start just from the current position of the vehicle. However, as we will see in the next chapter, this restriction is not longer needed, since we started using other strategies based on the Frenét space, which makes things even easier.

In the future, the initial graph generation step of this method could be also a good starting point for the generation of a full \ac{RNDF} from the scratch, given an occupancy map in which an unstructured area is represented.


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

\chapter{Interacting field theories}

We have studied free field theories for spin-0, spin-\(1/2\) and spin-1 particles. Now we introduce interaction terms between these, starting from the classical description of interaction.

\section{Interactions in classical field theories}

\marginpar{Thursday\\ 2020-6-11, \\ compiled \\ \today}

\subsection{Scalar field self-interactions}

Scalar fields have acted like systems of decoupled harmonic oscillators up to now. So, we introduce the complication of a self-interaction between the field: we write a Lagrangian density like
%
\begin{align}
\mathscr{L} = \underbrace{\frac{1}{2} \qty(\partial_{\mu }\varphi ) \qty(\partial^{\mu} \varphi ) - \frac{1}{2} m^2 \varphi^2}_{\mathscr{L}_{0}} \underbrace{- V(\varphi )}_{\mathscr{L} _{\text{int}}}
\,.
\end{align}

The added interaction term is a potential in the form
%
\begin{align}
V(\varphi ) = k \varphi^3 + \lambda \varphi^{4} + \mu \varphi^{5} \dots
\,,
\end{align}
%
with an arbitrary number of added positive powers of \(\varphi \).

We require \(V(\varphi )\) to have a stable minimum, which constrains the coefficients.
We will discuss this aspect in more detail later, when we treat Spontaneous Symmetry Breaking \ref{sec:ssb}.

Since the dimensions of the field are those of a mass and the Lagrangian density must be dimensionally a mass to the fourth, the coefficients must have dimensions of decreasing integer powers of \(M\): for the term \(\alpha_{i} \varphi^{i}\), the dimension of \(\alpha_{i}\) will be \(M^{4-i} = M^{D}\).

Terms whose mass dimension has an exponent \(D \geq 0 \) are said to be \textbf{renormalizable}.
So, in our case the only renormalizable terms are the first two, \(k \varphi^{3 } + \lambda \varphi^{4}\).

For a complex field the potential needs to be expressed in terms of \(\varphi^{*} \varphi \) in order to be \(U(1)\) gauge invariant, so the only renormalizable term we can add is \(\lambda (\varphi^{*} \varphi )^2\).

\subsection{Dirac field self-interactions}

The interaction term is added to the Dirac Lagrangian as follows:
%
\begin{align}
\mathscr{L}
= \underbrace{\overline{\psi} \qty(i \slashed{\partial} - m) \psi }_{\mathscr{L}_{0}}
+
\underbrace{G \qty(\overline{\psi} \Gamma \psi ) \qty(\overline{\psi} \Gamma \psi )}_{\mathscr{L} _{\text{int}}}
\,,
\end{align}
%
where \(\Gamma \) is a (1, 1) tensor in spinorial space.

Fermi theory, for example, is given by
%
\begin{align}
\mathscr{L} _{\text{int}} = \frac{G_F}{\sqrt{2}}
\qty(\overline{\psi}_{p} \gamma^{\mu } \psi_{n}) \qty(\overline{\psi}_{e} \gamma_{\mu } \psi_{\nu })
\,,
\end{align}
%
and it gives an effective description of beta decay,
%
\begin{align}
n \to p + e^{-} + \overline{\nu}_{e}
\,.
\end{align}

Since \(\psi \) has dimension \(M^{3/2}\), we find that the coupling constant \(G_F\) must have dimension \(M^{-2}\): so, this interaction is \textbf{not renormalizable}.

\subsection{Scalar - Dirac field interaction (Yukawa)}

We want to describe an interaction between a real scalar field \(\varphi \) and a spinor field \(\psi \). The interaction Lagrangian is:
%
\begin{align}
\mathscr{L} = \frac{1}{2} \qty(\partial_{\mu } \varphi ) \qty(\partial^{\mu} \varphi )
- \frac{1}{2} m^2\varphi^2
+ \overline{\psi} \qty(i \slashed{\partial} - m)\psi
+ y_{s}  \varphi \overline{\psi} \psi
+ y_{p} \varphi \overline{\psi} \gamma_{5} \psi
+ \omega_{1} \varphi^2 \overline{\psi} \psi
\,,
\end{align}
%
where \(y_s\) and \(y_p\) are known as the Yukawa couplings; one is a scalar, the other is a pseudoscalar (because of the presence of \(\gamma_{5}\)); both are renormalizable.

We always require Poincaré invariance, sometimes we do not require invariance under discrete symmetries like parity.

\subsection{Massless vector - Dirac field interaction}

The base Lagrangian is the sum of those describing the fields:
%
\begin{align}
\mathscr{L}_{0}
= - \frac{1}{4} F^{\mu \nu } F_{\mu \nu }
+ \overline{\psi} \qty(i \slashed{\partial} - m ) \psi
\,,
\end{align}
%
while the leading terms in the interaction term will be:
%
\begin{subequations}
\begin{align}
\begin{split}
\mathscr{L} _{\text{int}}
&= g_{v } \qty(\overline{\psi} \gamma^{\mu } \psi ) A_{\mu }
+ g_{A} \qty(\overline{\psi} \gamma^{\mu } \gamma_{5} \psi )A_{\mu }
+ c_{v } \qty(\overline{\psi} \psi ) A^{\mu } A_{\mu }
\\
&\phantom{=}\
+ i c_A \overline{\psi} \gamma_{5} \psi A_{\mu }A^{\mu }
+ d_{v } \qty(\overline{\psi} \sigma^{\mu \nu }\psi )F_{\mu \nu }
+ i d_A  \qty(\overline{\psi} \sigma^{\mu \nu } \gamma_5 \psi) F_{\mu\nu  } + \dots
\,.
\end{split}
\end{align}
\end{subequations}

To find the dimensionality, recall that \([A_{\mu }] = M^{1}\), so we get that \(g_v \) and \(g_A\) have dimension \(M^{0}\), while the other coefficients have dimension \(M^{-1}\).
If we include only the renormalizable terms, we have
%
\begin{subequations}
\begin{align}
\mathscr{L} _{\text{int}}^{\text{ren}}
&= g_{v } \qty(\overline{\psi} \gamma^{\mu } \psi ) A_{\mu }
+ g_{A} \qty(\overline{\psi} \gamma^{\mu } \gamma_{5} \psi )A_{\mu }  \\
&= g_{L } \qty(\overline{\psi} \gamma^{\mu }_{L} \psi ) A_{\mu }+
 g_{R } \qty(\overline{\psi} \gamma^{\mu }_{R} \psi ) A_{\mu }
\,,
\end{align}
\end{subequations}
%
where we defined
%
\begin{align}
\gamma^{\mu }_{L} = \gamma^{\mu } \frac{1 - \gamma_5 }{2}
\qquad \text{and} \qquad
\gamma^{\mu }_{R} = \gamma^{\mu } \frac{1 + \gamma_5 }{2}
\,,
\end{align}
%
so the new coefficients are
%
\begin{align}
g_R = g_{v } + g_A \qquad \text{and} \qquad
g_L = g_{\nu } - g_A
\,.
\end{align}

\(g_v\) is known as the vector coupling, while \(g_A\) is the axial coupling. \(g_L\) and \(g_R\) are the left and right-handed couplings. We distinguish:
\begin{enumerate}
    \item the vector-spinor interaction is \textbf{vector-like} if \(g_A = 0\), or equivalently if \(g_R = g_L\);
    \item the vector-spinor interaction is \textbf{chiral} if \(g_A \neq 0\), or \(g_R \neq g_L\).
\end{enumerate}

In QED, the interactions between the photon and the charged fermions are vector-like.
On the other hand, the weak interaction between the \(W\), \(Z\) bosons and fermions are chiral.

The QED Lagrangian is a vector-spinor interaction Lagrangian:
%
\begin{align}
\mathscr{L} _{\text{QED}} = - \frac{1}{4} F^{\mu \nu } F_{\mu \nu }
+ \overline{\psi} \qty(i \slashed{\partial} - m) \psi
- q \overline{\psi} \gamma^{\mu } \psi A_{\mu }
\,.
\end{align}

\begin{claim}
The QED Lagrangian is invariant under the transformation:
%
\begin{subequations}
\begin{align}
A^{\prime \mu } (x)  &= A_{\mu } (x) + \partial_{\mu } \alpha (x)  \\
\psi^{\prime }(x) &= e^{-iq \alpha (x)} \psi (x)
\,.
\end{align}
\end{subequations}

We can rewrite this Lagrangian with a covariant derivative \(\DD_{\mu } = \partial_{\mu } + i q A_{\mu }\): it then becomes
%
\begin{align}
\mathscr{L} _{\text{QED}} = - \frac{1}{4} F^{\mu \nu } F_{\mu \nu }
+ \overline{\psi} \qty(i \slashed{\DD} - m) \psi
\,.
\end{align}
\end{claim}

\begin{proof}
The kinetic term of the vector and the mass term of the fermion are unaffected by the interaction, and are manifestly gauge invariant.
Let us instead consider the interesting bits:
%
\begin{subequations}
\begin{align}
\overline{\psi} i \slashed{\partial} \psi &\to e^{iq \alpha } \overline{\psi} i \slashed{\partial} \qty(e^{-iq \alpha } \psi )  \\
&= \overline{\psi} i \slashed{\partial} \psi
+ \overline{\psi} i \gamma^{\mu } \qty(-iq \partial_{\mu } \alpha ) \psi  \\
&= \overline{\psi} i \slashed{\partial} \psi
+ \hlc{blue}{q \overline{\psi} \gamma^{\mu } \psi   \partial_{\mu } \alpha }
\,.
\end{align}
\end{subequations}

On the other hand, the interaction term transforms like
%
\begin{subequations}
\begin{align}
- q \overline{\psi} \gamma^{\mu } \psi A_{\mu } &\to -q \overline{\psi} \gamma^{\mu } \psi \qty(A_{\mu } + \partial_{\mu } \alpha )  \\
&= -q \overline{\psi} \gamma^{\mu } \psi A_{\mu } -
\hlc{blue}{q \overline{\psi} \gamma^{\mu } \psi \partial_{\mu } \alpha }
\,,
\end{align}
\end{subequations}
%
which precisely balances the kinetic term of the fermion.
\end{proof}

\subsubsection{Complex scalar - massless vector interaction}

In a similar way we can write the interaction between a complex scalar field and a photon (massless vector): the Lagrangian is
%
\begin{align}
\mathscr{L} _{\text{scalar QED}}
= \frac{1}{4} F^{\mu \nu } F_{\mu \nu }
+ \qty(\DD^{\mu } \varphi )^{*} \qty(\DD_{\mu } \varphi )
\,.
\end{align}

\begin{claim}
This Lagrangian is \(U(1)\) gauge symmetric, and
its Euler-Lagrange equations read:
%
\begin{subequations}
\begin{align}
\DD_{\mu } \DD^{\mu } \varphi &= 0   \\
\square A_{\rho }
+ \partial_\rho \qty(\partial_{\sigma} A^{\sigma})
-iq \qty(\varphi^{*} \partial_{\rho } \varphi - \varphi \partial_{\rho } \varphi^{*})
+ 2 q^2 A_{\rho } \varphi^{*} \varphi
&=0
\,.
\end{align}
\end{subequations}
\end{claim}

\todo[inline]{Might be able to clean up the equation for the EM field?}

\begin{proof}
Let us see how the term \(\DD_{\mu } \varphi \) changes with a \(U(1)\) transformation:
%
\begin{subequations}
\begin{align}
\partial_{\mu } \varphi + i q A_{\mu } \varphi &\to
\partial_{\mu } \qty(e^{-iq \alpha } \varphi )
+ i q \qty(A_{\mu } + \partial_{\mu }\alpha ) e^{-iq \alpha } \varphi  \\
&= e^{-iq \alpha } \partial_{\mu } \varphi
- \hlc{teal}{e^{-iq \alpha } \varphi (iq \partial_{\mu } \alpha )}
+e^{-iq \alpha } i q A_{\mu } \varphi
+ \hlc{teal}{(iq \partial_{\mu }\alpha ) e^{-iq \alpha } \varphi}  \\
&= e^{-iq \alpha } \qty(\partial_{\mu } \varphi + i q A_{\mu } \varphi)
\,.
\end{align}
\end{subequations}

So, this term changes by a global phase: since it is contracted with its conjugate, its appearance in the Lagrangian is invariant.
The kinetic EM term is invariant as usual.

If we write out the Lagrangian explicitly we get:
%
\begin{align}
\mathscr{L}_{\text{scalar - QED}}
= - \frac{1}{4} F^{\mu \nu } F_{\mu \nu }
+ \partial^{\mu } \varphi^{*} \partial_{\mu } \varphi
- iq A_{\mu } \qty(\varphi^{*}\partial^{\mu } \varphi - \varphi \partial^{\mu } \varphi^{*})
+ q^2 A^{\mu }A_{\mu } \varphi^{*} \varphi
\,.
\end{align}

We can write the EL equations differentiating both with respect to \(A_{\sigma }\) and \(\varphi^{*}\). We find
%
\begin{subequations}
\begin{align}
-iq \qty(\varphi^{*} \partial_{\rho } \varphi - \varphi \partial_{\rho } \varphi^{*})
+ 2 q^2 A_{\rho } \varphi^{*} \varphi
+ \partial_{\sigma } \qty(\partial^{\sigma }A_{\rho } - \partial_\rho A^{\sigma })&= 0   \\
-iq A_{\mu } \partial^{\mu } \varphi
+ q^2 A^{\mu } A_{\mu } \varphi
- \partial_{\sigma } \qty(
\partial^{\sigma } \varphi
+ i q A^{ \sigma } \varphi
)
&=0
\,,
\end{align}
\end{subequations}
%
where we have made use of the expression \eqref{eq:derivative-kinetic-term-vector}.
The second equation can we written in a more compact way if we substitute back in the expression for \(\DD_{\mu }\): we get
%
\begin{subequations}
\begin{align}
0 &=
-i q A_{\mu } \qty(\partial^{\mu } + i q A^{\mu } ) \varphi
- \partial_{\sigma } \qty(\partial^{ \sigma } + i q A^{\sigma }) \varphi   \\
&= -iq A_{\mu } \DD^{\mu } \varphi
- \partial_{\sigma } \DD^{\sigma } \varphi  \\
&= - \DD_{\mu } \DD^{\mu } \varphi =0
\,.
\end{align}
\end{subequations}
\end{proof}

\section{Quantizing interactions}

Let us now try to quantize these classical interacting theories.
We start with the self-interacting real scalar field, with \(V(\varphi ) = \lambda \varphi^{4} / 4! \). Its EOM read:
%
\begin{align}
\qty(\square + m^2) \varphi = - \frac{\lambda}{3!} \varphi^3
\,.
\end{align}

The Hamiltonian description is derived as usual, with \(\pi = \partial_0 \varphi \) and
%
\begin{align}
\mathscr{H} =  \pi \partial_0 \varphi
- \mathscr{L} =  \mathscr{H}_{0} + \mathscr{H} _{\text{int}}
= \mathscr{H}_{0} + V(\varphi )
\,.
\end{align}

We also have the usual Poisson brackets and Hamilton equations.
So, since the field is spin-0 we quantize with commutators, imposing
%
\begin{align}
\qty[\varphi (\vec{x}, t) , \pi (\vec{y}, t)] = i \delta^{(3)} (\vec{x}-\vec{y})
\,.
\end{align}

The other commutators vanish.
This is all fine, we encounter no issues.

The problem arises because of the fact that there is \textbf{no analytic solution to the EOM}.
So, we have no way to relate the operators \(\varphi \) and \(\pi \) with \(a\) and \(a ^\dag\). We cannot directly extend the reasoning we did before (finding the harmonic oscillator algebra, defining the number operator\dots) to this case, at least not straightforwardly.

So, we \textbf{perturb}.

\subsection{The interaction picture}

The interaction picture is an alternative to the Schrödinger and Heisenberg ones which is useful when dealing with interacting theories, for which the Hamiltonian can be written as
%
\begin{align}
H = H_0 + H _{\text{int}}
\,,
\end{align}
%
so that we can define a free evolution operator
%
\begin{align}
U_0 = e^{-i H_0 \Delta t}
\,.
\end{align}

Then, in the interaction picture we take the time-evolving Schrödinger state kets, \(\ket{\psi (t)}_{S}\), and evolve them \textbf{back} with the free Hamiltonian:
%
\begin{align}
\ket{\psi (t)}_{I} = U_0 ^\dag \ket{\psi (t)}_{S}
\,,
\end{align}
%
so that the states only evolve with the interaction term.
On the other hand, we have operators (which are stationary in the Schrödinger picture) evolve with the free Hamiltonian:
%
\begin{align}
A_{I}(t) = U_0 ^\dag (t) A U_0 (t)
\,,
\end{align}
%
so that expectation values are preserved:
%
\begin{subequations}
\begin{align}
\expval{A}_{I} &= \bra{\psi (t)}_{I} A_I (t) \ket{\psi (t)}_{I}   \\
&= \bra{\psi (t)}_{S} U_0 (t) U_0 ^\dag(t) A U_0 (t) U_0 ^\dag \ket{\psi (t)}_{S}  \\
&=  \bra{\psi (t)}_{S} A \ket{\psi (t)}_{S} = \expval{A}_{S}
\,.
\end{align}
\end{subequations}

We usually write everything with respect to base kets which are eigenstates of the free Hamiltonian.
This picture allows us to ``factor out'' the uninteresting free evolution, and focus on the interesting interaction part.

Operators obey the evolution law
%
\begin{align}
i \dv{}{t} A_I (t) = \qty[A_I(t), H_0 ]
\,.
\end{align}

Since field operators are operators, they evolve with the free Hamiltonian, we can write them with the free solution:
%
\begin{align}
\varphi_{I} (X) \sim \int a(k) e^{-ikx} + a ^\dag(k) e^{ikx}
\,.
\end{align}

The total evolution of a state can be written as
%
\begin{subequations}
\begin{align}
i \dv{}{t} \ket{\psi (t)}_{I} &= i \dv{}{t} \qty(U_0 U) \ket{\psi (t_0 )} \\
&= U_0 ^\dag H _{\text{int}} U_0 \ket{\psi (t_0 )}_{I}
\,,
\end{align}
\end{subequations}
%
so if we evolve the interaction Hamiltonian as \(H _{\text{int}} (t) = U_0 ^\dag H _{\text{int}} U_0 \) we recover a Schrödinger-like equation:
%
\begin{align}
i \dv{}{t} \ket{\psi (t)}_{I} = H _{\text{int}}^{I} \ket{\psi (t)}_{I}
\,.
\end{align}

\begin{claim}
The evolution operator for states, \(U_I (t)\), can be written as
%
\begin{align}
U_I (t, t_0 ) = U_0^\dag(t,0)  U (t, t_0 ) U_0 (t_0, 0)
\,,
\end{align}
%
and it is unitary, satisfies \(U_{I}(t_2, t_0 ) = U_I (t_2 , t_1 ) U_I (t_1 , t_0 )\) and \(U_I (t, t_0 ) = U ^\dag_I (t_0, t)\).
\end{claim}

% \todo[inline]{The last one looks weird\dots}

\begin{proof}
First of all, we derive the expression for the evolution operator: a state \(\ket{\psi (t)}_{I}\) evolves as
%
\begin{subequations}
\begin{align}
\ket{\psi (t)}_{I} &= U_0 ^\dag (t, 0) \ket{\psi (t)}_{S}  \\
&= U_0 ^\dag (t, 0) U (t, t_0 ) \ket{\psi (t_0 )}_{S}  \\
&= U_0 ^\dag (t, 0) U(t, t_0 ) U_0 (t_0, 0) \ket{\psi (t_0 )}_{I}  \\
&= U_{I} (t, t_0 ) \ket{\psi (t_0 )}_{I}
\,.
\end{align}
\end{subequations}

To show unitarity:
%
\begin{subequations}
\begin{align}
U_I (t, t_0 ) ^\dag U_I (t, t_0 )
&=
U_0 ^\dag(t_0 , 0)
U ^\dag (t, t_0 )
U_0 (t, 0)
U_0 ^\dag (t, 0)
U (t, t_0 )
U_0 (t_0 , 0)  \\
&=
U_0 ^\dag(t_0 , 0)
U ^\dag (t, t_0 )
U (t, t_0 )
U_0 (t_0 , 0)  \\
&=
U_0 ^\dag(t_0 , 0)
U_0 (t_0 , 0)
= \mathbb{1}
\,.
\end{align}
\end{subequations}

To show that it works well with successive times:
%
\begin{subequations}
\begin{align}
U_I (t_2, t_1 ) U_I (t_1 , t_0 )
&= U_0 ^\dag (t_2 , 0) U (t_2, t_1 ) U_0 (t_1, 0)
U_0 ^\dag (t_1, 0) U(t_1, t_0 ) U_0 (t_0, 0)  \\
&= U_0 ^\dag (t_2 , 0) U (t_2, t_1 ) U(t_1, t_0 ) U_0 (t_0, 0)  \\
&= U_0 ^\dag (t_2 , 0) U (t_2, t_0 ) U_0 (t_0, 0)  \\
&= U_I (t_2, t_0 )
\,.
\end{align}
\end{subequations}

The last property can be shown as follows: we have
%
\begin{align}
U_I (t_0, t) = U_0 ^\dag (t_0 , 0) U(t_0, t) U_0 (t ,0 )
\,,
\end{align}
%
so
%
\begin{align}
U_I ^\dag (t_0, t)
= U_0 ^\dag (t, 0) U ^\dag (t_0 , t) U_0 (t_0, 0)
= U_0 ^\dag (t, 0) U (t , t_0 ) U_0 (t_0, 0)
= U_I (t, t_0 )
\,,
\end{align}
%
since \(U(t, t_0 ) = \exp(-i H (t - t_0) )\).
\end{proof}

\subsubsection{Differential equation for the evolution operator}

We know that
%
\begin{align}
i \dv{}{t} U (t, t_0 ) = H U (t, t_0 )
\,,
\end{align}
%
so we can take its conjugate:
%
\begin{align}
- i \dv{}{t} U ^\dag (t, t_0 ) = U ^\dag (t, t_0 ) H
\,.
\end{align}

This allows us to compute the differential equation for the evolution of the evolution operator:
%
\begin{align}
i \dv{}{t} U_I (t, t_0 )
= H _{\text{int}}^{I} (t) U_I (t, t_0 )
\,,
\end{align}
%
where as usual \(H_{\text{int}}^{I} = H - H_0 \).

Now, since the Hamiltonian is not constant this differential equation cannot be solved directly. However, we can cast it into an integral form:
%
\begin{align} \label{eq:integral-expression-evolution-operator-interaction}
U_I (t, t_0 ) = \mathbb{1} - i \int_{t_0 }^{t} \dd{\tau }
H _{\text{int}}^{I} (\tau ) U(\tau , t_0 )
\,.
\end{align}

Crucially, in the interaction picture operators evolve with the free Hamiltonian (which we know well), while states evolve in a complicated way involving the interaction Hamiltonian.

\subsection{Perturbative solution for the evolution operator}

We assume that the interaction term in the Hamiltonian is proportional to some small parameter \(\lambda \ll 1 \), and then we look for solutions of the form
%
\begin{align}
U_I (t, t_0 ) = \sum _{n=0}^{\infty } C_n (t, t_0 )
\,,
\end{align}
%
such that the term \(C_n\) is of order \(\lambda^{n }\).

As long as \(\lambda \) is actually small, this series converges to the true result.

This perturbative approach can be made more explicit with the integral formulation \eqref{eq:integral-expression-evolution-operator-interaction}.
We know that \(H _{\text{int}} \sim \lambda \), so if we take the integral expression and plug the perturbative expression \(\sum _{n} C_n\) for the evolution operator into both sides, we get
%
\begin{align}
\sum _{n} C_n(t, t_0 ) = \mathbb{1} - i \int_{t_0 }^{t} \dd{\tau }
H _{\text{int}}^{I} (\tau ) \qty(\sum _{n} C_n(\tau , t_0 ))
\,,
\end{align}
%
and now, if we set these two expressions to be equal at any order in \(\lambda \), we find that
%
\begin{subequations}
\begin{align}
C_0 (t, t_0 ) &= \mathbb{1}   \\
C_1 (t, t_0 ) &=  - i \int_{t_0 }^{t} H _{\text{int}}^{I} (\tau) \label{eq:first-order-perturbative-evolution} \\
C_2 (t, t_0 ) &=  - i \int_{t_0 }^{t} H _{\text{int}}^{I} (\tau) C_1 (\tau , t_0 ) \label{eq:second-order-perturbative-evolution}
\,
\end{align}
\end{subequations}
%
and so on, in general if we sum these up to an order \(N\) to get the evolution operator to \(N\)-th order we find the recursive expression for \(U^{(N)} = \sum _{n=0}^{N} C_n\):
%
\begin{align}
U^{(N)} (t,  t_0  )
\approx \mathbb{1} - i \int_{t_0 }^{t} \dd{\tau } H _{\text{int}}^{I} U^{(N-1)} (\tau , t_0 ) + \mathcal{O} (\lambda^{N+1})
\,.
\end{align}

So, we can work to ever higher orders in \(\lambda \) to obtain better approximations as we go!
The zeroth order is the \textbf{free theory}, since it is equivalent to setting \(\lambda = 0\). At this order, the interaction picture is equivalent to the Heisenberg picture: states are constant, while operators evolve according to
%
\begin{align}
i \dv{}{t} X_I (t ) = \qty[X_I (t), H_0 ]
\,.
\end{align}

The first order is given by equation \eqref{eq:first-order-perturbative-evolution}, which we can substitute into the next equation \eqref{eq:second-order-perturbative-evolution} to get the explicit integral:
%
\begin{subequations}
\begin{align}
C_2 (t, t_0 ) &=
- i \int_{t_0 }^{t} \dd{\tau } H _{\text{int}}^{I} (\tau ) C_1 (\tau, t_0 )  \\
&= (-i)^2 \int_{t_0}^{t} \dd{\tau_1 } \int_{t_0 }^{\tau_1 } \dd{\tau_2 }
H _{\text{int}}^{I} (\tau_1 )
H _{\text{int}}^{I} (\tau_2 )
\label{eq:second-order-correction-no-time-ordering}
\,,
\end{align}
\end{subequations}
%
which generalizes to
%
\begin{align}
C_N (t, t_0 ) &=
(-i)^{n}
\int_{t_0 }^{t} \dd{\tau_1 }
\prod_{n=1}^{N-1} \qty(\int_{t_0 }^{\tau_{n}} \dd{\tau_{n+1}})
\prod_{n=1}^{N} H _{\text{int}}^{I} (\tau_{n})
\,.
\end{align}

This is a complicated but explicit expression: as \(N\) increases, we are basically evolving linearly with the Hamiltonian for ever decreasing amounts of time, which approaches the actual evolution.

Formally, we can recover the \textbf{exact solution} by summing the series \(\sum _{n} C_n\) (as long as it converges).
This is often impossible to do in practice, but we can compute to any required precision, so we can compute to below the experimental precision and we can make the required prediction.

\begin{claim}
With some manipulations, we can rewrite the general expression for \(C_n\) as:
%
\begin{align}
C_n (t, t_0 ) = \frac{(-i)^{n}}{n!}
\int_{t_0 }^{t} \dd{\tau_1} \dots \dd{\tau_n} T [H _{\text{int}}^{I} (\tau_1 ) \dots H _{\text{int}}^{I}(\tau_{n})]
\,,
\end{align}
%
where \(T\) is the time ordered product, defined by
%
\begin{subequations}
\begin{align}
T[A(t_1 ) B(t_2 )]
= \begin{cases}
    A(t_1 ) B(t_2 ) \qquad \text{if } t_1 > t_2 \\
    \pm B(t_2 ) A(t_1 ) \qquad \text{if } t_1 < t_2 \\
\end{cases}
\,,
\end{align}
\end{subequations}
%
where \(+\) refers to bosonic operators, \(-\) to fermionic operators.
\end{claim}

The \(\pm\) allows the time-ordered product to be consistent with both bosonic and fermionic quantizations.
We can also write this as
%
\begin{align}
T[A(t_1 ) B(t_2 )]
= \theta (t_1 - t_2 ) A(t_1 ) B(t_2 )
\pm \theta (t_2 - t_1 ) B(t_2 ) A(t_1 )
\,.
\end{align}

Note that when time-ordering Hamiltonians we always have a \(+\) sign, even if they describe fermions: fermionic operators always appear in pairs in the Hamiltonian, so we will always make an even number of swaps when we commute two Hamiltonians.

The definition of time-ordering can be generalized to any number of operators recursively: we write them in decreasing order of time, and add a sign \((-)^{\text{\# of fermion operator swaps}}\).

Then, we can write a full expression for the evolution operator:
%
\boxalign{
\begin{subequations}
\begin{align} \label{eq:dyson-series}
U_I (t, t_0 ) &= \sum _{n=0}^{\infty }
\frac{(-i)^{n}}{n!}
\int_{t_0 }^{t} \dd{\tau_1 } \dots \dd{\tau_{n}} T [H _{\text{int}}^{I} (\tau_1 ) \dots H _{\text{int}}^{I}(\tau_{n})]  \\
&= T \qty[\exp(-i \int_{t_0 }^{t} \dd{ \tau } H _{\text{int}}^{I}(\tau ))]
\,.
\end{align}
\end{subequations}}

%

What we have done is basically to bring the expression for the time evolution into a form which is close to the one we have in the free case, in which we can just exponentiate the Hamiltonian:
%
\begin{align}
U_0 (t, t_0 ) = \exp( - i H_0 (t - t_0 ))
\,.
\end{align}

\begin{claim}
The interaction Hamiltonian
%
\begin{align}
H _{\text{int}}^{I} = - q \overline{\psi}_{I} \slashed{A}_{I} \psi_{I}
\,,
\end{align}
%
is a bosonic operator.
\end{claim}

\begin{proof}
Suppose we had to compute the time-ordered product
%
\begin{align}
T \qty[
(\overline{\psi}\slashed{A} \psi )_{t_1 }
(\overline{\psi}\slashed{A} \psi )_{t_2 }
]
\,,
\end{align}
%
where \(t_1 < t_2\): then we would need to bring the \(t_2 \) operators to the left; each of them would need to ``hop over'' two fermionic operators and a bosonic one. So, the total number of fermion-over-fermion hops will be 4: an even number.
\end{proof}

We can show explicitly (and graphically) that
%
\begin{align}
C_2 (t, t_0 ) = \frac{(-i)^2}{2!}
\int_{t_0 }^{t} \dd{\tau_1} \dd{\tau_2 } T \qty[H _{\text{int}}^{I}(\tau_1 ) H _{\text{int}}^{I} (\tau_2 )]
\,.
\end{align}

\begin{proof}
Our integration region in \eqref{eq:second-order-correction-no-time-ordering} is a triangle, the set of \((\tau_1 , \tau_2 )\) such that \(\tau_1 \in [t_0 , t]\) and \(\tau_2 \in [t_0, \tau_1 ]\).

We can also write this region as the set of \((\tau_1 , \tau_2 )\) such that \(\tau_2 \in [t_0 , t]\) and \(\tau_1 \in [\tau_2, t]\). They are the same pairs, so we can split the integral in two equal rewritings (and dividing by two, since we are doubling the integral):
%
\begin{align}
C_2 (t, t_0 )
&= \frac{(-i)^2}{2} \qty(\int_{t_0}^{t} \dd{\tau_1 } \int_{t_0 }^{\tau_1 } \dd{\tau_2 }
+ \int_{t_0 }^{t} \dd{\tau_2 } \int_{\tau_2}^{t} \dd{\tau_1 }
)
H _{\text{int}}^{I} (\tau_1 )
H _{\text{int}}^{I} (\tau_2 )
\,,
\end{align}
%
but now we can change the names of the integration variables in the second integration: then we get
%
\begin{align}
C_2 (t, t_0 )
&= \frac{(-i)^2}{2} \int_{t_0}^{t} \dd{\tau_1 } \int_{t_0 }^{\tau_1 } \dd{\tau_2 }
H _{\text{int}}^{I} (\tau_1 )
H _{\text{int}}^{I} (\tau_2 )
+ \frac{(-i)^2}{2} \int_{t_0 }^{t} \dd{\tau_1 } \int_{\tau_1}^{t} \dd{\tau_2 }
H _{\text{int}}^{I} (\tau_2 )
H _{\text{int}}^{I} (\tau_1 )
\,,
\end{align}
%
which we can write in a simpler way using theta functions (written as Iverson brackets \cite[]{knuthTwoNotesNotation1992}) and enlarging the domain of integration:
%
\begin{subequations}
\begin{align}
C_2 (t, t_0 ) &=
\frac{(-i)^2}{2} \int_{t_0 }^{t} \dd{\tau_1 } \int_{t_0 }^{t} \dd{\tau_2
}
\qty([t_1 > t_2  ] H _{\text{int}}^{I} (\tau_1 )
H _{\text{int}}^{I} (\tau_2 )
+ [t_1 < t_2 ] H _{\text{int}}^{I} (\tau_2 )
H _{\text{int}}^{I} (\tau_1 ) )  \\
&= \frac{(-i)^2}{2} \int_{t_0 }^{t} \dd{\tau_1 } \int_{t_0 }^{t} \dd{\tau_2 }
T \qty[H _{\text{int}}^{I} (\tau_1 )
H _{\text{int}}^{I} (\tau_2 )]
\,.
\end{align}
\end{subequations}
\end{proof}

\end{document}


% This is part of the TFTB Reference Manual.
% Copyright (C) 1996 CNRS (France) and Rice University (US).
% See the file refguide.tex for copying conditions.

\markright{anapulse}
\section*{\hspace*{-1.6cm} anapulse}

\vspace*{-.4cm}
\hspace*{-1.6cm}\rule[0in]{16.5cm}{.02cm}
\vspace*{.2cm}

{\bf \large \sf Purpose}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
Analytic projection of unit amplitude impulse signal.
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf Synopsis}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
\begin{verbatim}
y = anapulse(N)
y = anapulse(N,ti)
\end{verbatim}
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf Description}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
        {\ty anapulse} returns an analytic N-dimensional signal
        whose real part is a Dirac impulse at {\ty t=ti}.\\

\hspace*{-.5cm}\begin{tabular*}{14cm}{p{1.5cm} p{8.5cm} c}
Name & Description & Default value\\
\hline
        {\ty N}  & number of points\\
        {\ty ti} & time position of the impulse   & {\ty round(N/2)}\\
  \hline {\ty y}  & output signal\\
\hline
\end{tabular*}

\end{minipage}
\vspace*{1cm}

{\bf \large \sf Example}
\begin{verbatim}
         signal=2.5*anapulse(512,301);
         plot(real(signal));
\end{verbatim}
\vspace*{.5cm}

{\bf \large \sf See Also}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
\begin{verbatim}
anastep, anasing, anabpsk, anafsk.
\end{verbatim}
\end{minipage}


\documentclass[acmtog]{acmart}
%acmtog if we're feeling a little funky ;)

\usepackage{booktabs, braket} % For formal tables
\usepackage{cleveref}
\usepackage{graphicx}
\usepackage{blkarray}

\settopmatter{printacmref=false} % Removes citation info after abstract
\renewcommand\footnotetextcopyrightpermission[1]{} % removes footnote with conference informat\textbf{}ion in first column
\usepackage{fancyhdr}

\DeclareMathOperator{\X}{\mathbb{X}}		     % expected value
\DeclareMathOperator{\tr}{\text{tr}}		     % trace
\DeclareMathOperator{\Ap}{$A$ ^\prime} 		     % A'
\DeclareMathOperator{\bp}{$b$ ^\prime} 		     % b'
\DeclareMathOperator{\Xb}{\mathcal{X}}		     % big X

\pagestyle{fancy}
\fancyhf{}
\lhead{Czekanski \& Witter, Fall 2019}
\rfoot{\thepage}
\newcommand{\todo}[1]{{\color{red}{[{\bf TODO:} #1]}}}

%\pagestyle{plain} % removes running heades

% Use the "authoryear" citation style, and make sure citations are in [square brackets].
\citestyle{acmauthoryear}
\setcitestyle{square}

% A useful command for controlling the number of authors per row.
% The default value of "authorsperrow" is 2.
\settopmatter{authorsperrow=1}

\begin{document}

% Title.
% If your title is long, consider \title[short title]{full title} - "short title" will be used for running heads.
\title[Optimal Quantum Algorithms via Semidefinite Programming]{Semidefinite Program Solver to
Find the Optimal Quantum Query Complexity
and Query Optimal Quantum Algorithm
of Boolean Functions}

% please leave the subtitle!
\subtitle{Middlebury College, Fall 2019}

% Authors.
\author{Michael Czekanski}
\affiliation{%
  \institution{Middlebury College}}

\author{R. Teal Witter}
 \affiliation{%
   \institution{Middlebury College}}

\maketitle

\graphicspath{{./../figures/}}
% a couple of paragraphs describing your project
\section*{Abstract}

We implement an algorithm that takes in a
Boolean function and outputs the optimal
quantum query complexity of the function
as well as a query optimal span program
for evaluating it on a quantum computer.
Let $f$ be a Boolean function
and $x$ be a bitstring input to $f$.
We consider the query model where
an algorithm evaluates $f(x)$
by asking an oracle about the bits of $x$.
The optimal quantum query complexity of $f$
is the fewest queries any quantum algorithm
takes to determine $f(x)$ over all inputs $x$.
We find the optimal quantum query complexity
of $f$ by solving a semidefinite
programming (SDP) problem.
The SDP solution also provides a span program
that evaluates $f$ in optimal
quantum query complexity. Our numerical results prove to be in line with general analytic understanding, and the span programs we implement are shown to correctly evaluate the given function.

% the other sections
\input{sec/1_introduction.tex}
\input{sec/2_methodology.tex}
\input{sec/3_results.tex}
\input{sec/4_conclusions.tex}

% select the reference format (leave this)
\bibliographystyle{ACM-Reference-Format}

% specify the bibliography (.bib) file
% place your references in this bib file
\bibliography{main}

\end{document}


%!TEX root = ClementiCooperBarba2018.tex

Extending \pygbe to the LSPR biosensing application required considerable code
modifications and added functionality. The results presented in the previous section
offer evidence to build confidence on the suitability of the mathematical model
and the correctness of the code.
The grid-convergence study with a nanosphere under a constant electric field
shows a $1/N$ rate of convergence, consistent with convergence results
in previous work using \pygbe \cite{CooperBardhanBarba2013}.
Further verification of \pygbe's new ability to compute extinction cross-section
of a scatterer in the long-wavelength limit is provided in Figure \ref{fig:verif_sphere}.
The computed extinction cross-section of a silver nanoparticle in a range of frequencies
is within 1\% of the analytical value, with the numerical parameters chosen.
This level of accuracy is likely sufficient, given that experimental uncertainty in
the values of the dielectric constant for silver is in the order of 1\%, also \cite{JohnsonChristy1972}.

%\subsection{LSPR response to BSA}

Figure \ref{fig:2pz_response} shows a red shift of the plasmon resonance frequency peak in presence of the BSA proteins.
Experimental observations of Tang, et al.~\cite{TangETal2010} with silver nanoparticles of approximately 17 nm in diameter and BSA proteins in solution revealed a red shift upon adding the proteins.
Similar to the effect we see with our model, they observed as well a decrement of
the peak amplitude.
Moreover, recent experiments \cite{PuETal2018} report a resonance frequency for a silver nanoparticle in the presence of BSA proteins of between 380 and 400 nm, which is consistent with our results.
Other experiments \cite{RaphaelETal2013} also report a red shift in the resonance frequency in the presence of (different) proteins.
Our boundary element method approach using electrostatic
approximation is thus able to capture the characteristic resonance-frequency
shift of LSPR biosensors.

With the electric field aligned in the $z$-direction, placing the proteins at a distance
in the $x$ or $y$ directions from the nanoparticle shows a negligible shift in the
resonance peak: the shifts in Figure \ref{fig:2pxy_response}
are smaller than the resolution between wavelengths ($< 0.25$ nm).
This finding is consistent with the free electrons oscillating in the $z$ direction
under a $z$-polarized electric field, and not in the $x$ and $y$ directions
(see Figure \ref{fig:lspr}).
The analytes have a marked effect when placed in the $z$ direction, where
they can interfere with the free oscillating electrons.

Figure \ref{fig:dist_response} shows how the  shift in resonance frequency varies
with the distance between the sensor and the analyte. As expected, the shift decays
as the BSA moves away from the sensor, to the point that if the BSA proteins are placed
$d=2$ nm away, the shift is only $0.25$ nm. This result shows the potential of \pygbe
and the electrostatic approach to study biosensor sensitivity with distance.
Note that possible quantum effects (e.g., tunneling) at $d=0.5$nm are ignored with our classical model.
Even if this distance could be close to or in the quantum regime, evidence that classical theory is valid at this distance in similar systems has been reported
\cite{SavageETal2012, EstebanETal2012}.

Even though there is evidence that techniques such as Plasmon Enhanced Raman Scattering are capable of detecting all the way to single molecules \cite{ZhangZhangETal2013},
as far as we know, there is no evidence of purely LSPR approaches that can sense such low concentration of analytes.
These computational studies can shine light on  potential improvements that would enhance sensitivity of LSPR biosensors, for example, by using smaller ligands.

We are not aware of other LSPR simulations where the molecular details of the analyte are considered, however, similar calculations could be performed with other software.
For example, BEM++ \cite{SmigajETal2015} also models the system as a set of boundary integral equations, discretized in flat triangular panels.
This software uses the Galerkin approach and algorithmic acceleration via hierarchical matrices, which is slower and less memory efficient than the treecode and limits the accessible problem sizes.
The Matlab toolbox MNPBEM \cite{HohenesterTrugler2012} is another alternative software designed to simulate scattering of metallic nanoparticles.
Its BEM implementation is similar to \pygbe as it uses a centroid collocation scheme on flat triangular panels, but differs in the algorithmic acceleration technique, which is also based on hierarchical matrices rather than a treecode.
This results in higher memory usage compared to our code, making it harder to simulate large analytes in detail.
Commercial finite-element or finite-difference solvers could also be used in this application, for example, COMSOL.
These volumetric approaches, however, struggle to correctly impose the zero boundary condition at infinity, which is exactly met for a BEM formulation.


\section{Pattern Synonyms}

The developer experience using \texttt{cataMerkle} is difficult, because the developer needs to know the pattern functor of its datatype to define a function and the function definitions are quite verbose. To make the use of \texttt{cataMerkle} easier, we introduce \textit{pattern synonyms}\cite{pickering2016pattern}.

Pattern synonyms add an abstraction over patterns, which allows the user to move additional logic from guards and case expressions into patterns. For example, the pattern functor of the \texttt{Tree} datatype can be represented using a \texttt{pattern}.

\begin{minted}{haskell}
pattern Leaf_ :: a -> PF (Tree a) r
pattern Leaf_ x <- L (C (K x)) where
  Leaf_ x = L (C (K x))

pattern Node_ :: r -> a -> r -> PF (Tree a) r
pattern Node_ l x r <- R (C (I l :*: K x :*: I r)) where
  Node_ l x r = R (C (I l :*: K x :*: I r))
\end{minted}

The previously defined \texttt{pattern}s can then be used to define the \texttt{cataSum} as the original datatype \texttt{Tree}, but the constructor names leading with an additional underscore. However, writing all the patterns for all pattern functors is an arduous task. Luckily, we can use \texttt{TemplateHaskell} to generate the pattern synonyms\footnote{An example of using \texttt{TemplateHaskell} to generate pattern synonyms can be found at \href{https://hackage.haskell.org/package/generics-mrsop-2.3.0/docs/Generics-MRSOP-TH.html}{\textit{Generics-MRSOP-TH}}}.

\begin{minted}{haskell}
cataSum :: Merkle (PF (Tree Int)) -> (Int, M.Map Digest Int)
cataSum = cataMerkle
  (\case
    Leaf_ x     -> x
    Node_ l x r -> l + x + r
  )
\end{minted}


%\section{Formalizing the SNOW Theorem}
{\bf The SNOW Theorem.}
\label{sec:snow}
%This section explains the SNOW properties and the theorem as presented in the original paper.
Consider a transaction processing system with an asynchronous network where a set $\mathcal{O}$ of objects are maintained by individual server processes,  with at least one write client and at least two read clients. Then the SNOW Theorem~\cite{SNOW2016} can be stated as follows.
%Appendix~\ref{app:snow} restates them formally.
%\subsection{The SNOW Properties}
%\label{subsec:properties}

%More formally, a {\sc READ} transaction $R=READ(\{o_i\})$ is said to allow write transactions that conflict if for any execution $E$, given a {\sc WRITE} transaction $W=WRITE(\{o_j\})$ with  $\RESP{R}$ appears after $\INV{W}$ and $\INV{R}$ appears before $\RESP{W}$ in $E$ and $o_i \cap o_j \neq \phi$, there exists an execution $E'$ equivalent to $E$, such that the execution fragment $E'_R$, which starts with $\INV{R}$ and ends with $\RESP{R}$ has no input actions from $\INV{W}$ and vice versa, i.e., the execution fragment $E'_W$, which starts with $\INV{W}$ and ends with $\RESP{W}$ has no input actions from $\INV{R}$.

%\subsection{Existing Impossibility Result}
%\label{subsec:theorem}
%\paragraph{\textbf{The SNOW Theorem~\cite{SNOW2016}.}}
\emph{``For any transaction processing system in an asynchronous setting, with at least one writer and two reader clients, and at least two sharded objects, it is impossible to have an algorithm such that all of its executions guarantee the SNOW properties.''} %\blue{need better phrasing to define the problem}

%\begin{theorem}\label{thm:snow3}
 %The SNOW properties cannot be implemented in a system with at least three clients and one writer, for two servers.
%\end{theorem}

%More formally, given a {\sc READ} transaction $R=READ(\{o_i\})$ and a {\sc WRITE} transaction $W=WRITE(\{o_j\})$ with $o_i \cap o_j \neq \phi$, there does not exist an algorithm $\pi$ executed by automata $A$, such that for any execution $E$ of $A$ satisfies: (1) $\RESP{R}$ appears after $\INV{W}$ and $\INV{R}$ appears before $\RESP{W}$, (2) for any execution fragment $E_R \in E$, which starts with $\INV{R}$ and ends with $\RESP{R}$, $E_R|A_i$ has at most one pair of $\recv{m_i^{r}}{r, s_i}$ and $\send{v_i}{ s_i, r}$ with $m_i^{r}=read(o_i)$ and $c_r$ is $R$'s originating client, and there is no other input action between $\recv{m_i^{r}}{r, s_i}$ and $\send{v_i}{ s_i, r}$, and (3) $E$ has an equivalent execution $E'$, where the execution fragment $E'_R$, which starts with $\INV{R}$ and ends with $\RESP{R}$ has no input actions from $\INV{W}$ and vice versa for $E'_W$, with $E'_R$ appearing before $E'_W$ if $\RESP{R}$ happens before $\INV{W}$ in real time or appearing after $E'_W$ if $\RESP{W}$ happens before $\INV{R}$.

%\hl{The formal re-definitions of snow properties and the theorem are commented out. Do we really not want a more rigorous re-statement of them? One reviewer complained about ``even the snow theorem is not formalized."}


\ifdefined \AddToHook
  % plautopatch/issues/12
  % platex-tools/pull/16
  % [TODO] needs reconsider (ref: pgf/issues/900)
  \RequirePackage{pxpgfrcs}% still needed?
\else
  \RequirePackage{plautopatch}% pxpgfrcs, pxeveryshi
\fi
\documentclass[dvipdfmx,twocolumn]{tarticle}
\setlength\columnseprule{.4pt}
\pagestyle{empty}
\usepackage{tikz}

\usetikzlibrary{shadings,shadows,fadings,calendar}

\begin{document}

\section{Test of \texttt{fadings} library}%%% from http://www.texample.net/tikz/examples/coffee-cup/

\tikzfading[name=fade out,
 inner color=transparent!0, outer color=transparent!100]

\mbox{\yoko
\begin{tikzpicture}
 \foreach \c [count=\i from 0] in {white,red!75!black,blue!25,orange}{

   \tikzset{xshift={mod(\i,2)*3cm}, yshift=-floor(\i/2)*3cm}
   \colorlet{cup}{\c}

   % Saucer
   \begin{scope}[shift={(0,-1-1/16)}]
     \fill [black!87.5, path fading=fade out]
       (0,-2/8) ellipse [x radius=6/4, y radius=3/4];
     \fill [cup, postaction={left color=black, right color=white, opacity=1/3}]
       (0,0) ++(180:5/4) arc (180:360:5/4 and 5/8+1/16);
     \fill [cup, postaction={left color=black!50, right color=white, opacity=1/3}]
       (0,0) ellipse [x radius=5/4, y radius=5/8];
     \fill [cup, postaction={left color=white, right color=black, opacity=1/3}]
       (0,1/16) ellipse [x radius=5/4/2, y radius=5/8/2];
     \fill [cup, postaction={left color=black, right color=white, opacity=1/3}]
       (0,0) ellipse [x radius=5/4/2-1/16, y radius=5/8/2-1/16];
   \end{scope}

   % Handle
   \begin{scope}[shift=(10:7/8), rotate=-30, yslant=1/2, xslant=-1/8]
     \fill [cup, postaction={top color=black, bottom color=white, opacity=1/3}]
       (0,0) arc (130:-100:3/8 and 1/2) -- ++(0,1/4) arc (-100:130:1/8 and 1/4)
       -- cycle;
     \fill [cup, postaction={top color=white, bottom color=black, opacity=1/3}]
       (0,0) arc (130:-100:3/8 and 1/2) -- ++(0,1/32) arc (-100:130:1/4 and 1/3)
       -- cycle;
   \end{scope}

   % Cup
   \fill [cup!25!black, path fading=fade out]
     (0,-1-1/16) ellipse [x radius=3/4, y radius=1/3];
   \fill [cup, postaction={left color=black, right color=white, opacity=1/3/2},
     postaction={bottom color=black, top color=white, opacity=1/3/2}]
     (-1,0) arc (180:360:1 and 5/4);
   \fill [cup, postaction={left color=white, right color=black, opacity=1/3}]
     (0,0) ellipse [x radius=1, y radius=1/2];
   \fill [cup, postaction={left color=black, right color=white, opacity=1/3/2},
     postaction={bottom color=black, top color=white, opacity=1/3/2}]
     (0,0) ellipse [x radius=1-1/16, y radius=1/2-1/16];

   % Coffee
   \begin{scope}
     \clip ellipse [x radius=1-1/16, y radius=1/2-1/16];
     \fill [brown!25!black]
       (0,-1/4) ellipse [x radius=3/4, y radius=3/8];
     \fill [brown!50!black, path fading=fade out]
       (0,-1/4) ellipse [x radius=3/4, y radius=3/8];
   \end{scope}
 }
\end{tikzpicture}}

\section{Test of \texttt{shadows} library}%%% from http://www.texample.net/tikz/examples/overlapping-arrows/

\definecolor{darkblue}{rgb}{0.2,0.2,0.6}
\definecolor{darkred}{rgb}{0.6,0.1,0.1}
\definecolor{darkgreen}{rgb}{0.2,0.6,0.2}

\def\arrow{
 (10.75:1.1) -- (6.5:1) arc (6.25:120:1) [rounded corners=0.5] --
 (120:0.9) [rounded corners=1] -- (130:1.1) [rounded corners=0.5] --
 (120:1.3) [sharp corners] -- (120:1.2) arc (120:5.25:1.2)
 [rounded corners=1] -- (10.75:1.1) -- (6.5:1) -- cycle
}

\tikzset{
 ashadow/.style={opacity=.25, shadow xshift=0.07, shadow yshift=-0.07},
}

\def\arrows[#1]{
 \begin{scope}[scale=#1]
   \draw[color=darkred, %
   drop shadow={ashadow, color=red!60!black}] \arrow;

   \draw[color=darkgreen, bottom color=green!90!black, top color=green!60, %
   drop shadow={ashadow, color=green!60!black}] [rotate=120] \arrow;

   \draw[color=darkblue, right color=blue, left color=blue!60, %
   drop shadow={ashadow, color=blue!60!black}] [rotate=240] \arrow;

   % to hide the green shadow
   \draw[color=darkred, left color=red, right color=red!60] \arrow;
 \end{scope}
}

\mbox{\yoko
\begin{tikzpicture}
 \arrows[2.5];
\end{tikzpicture}}

\section{Test of \texttt{shadings} library}%%% from http://www.texample.net/tikz/examples/calendar-circles/

\colorlet{winter}{blue}
\colorlet{spring}{green!60!black}
\colorlet{summer}{orange}
\colorlet{fall}{red}
\newcount\mycount

\mbox{\yoko
\begin{tikzpicture}[transform shape,
 every day/.style={anchor=mid,font=\tiny}]
 \node[circle,shading=radial,outer color=blue!30,inner color=white,
   minimum width=15cm] {\textcolor{blue!80!black}{\Huge\the\year}};
 \foreach \month/\monthcolor in
   {1/winter,2/winter,3/spring,4/spring,5/spring,6/summer,
   7/summer,8/summer,9/fall,10/fall,11/fall,12/winter} {
     % Computer angle:
     \mycount=\month
     \advance\mycount by -1
     \multiply\mycount by 30
     \advance\mycount by -90
     \shadedraw[shading=radial,outer color=\monthcolor!30,middle color=white,
       inner color=white,draw=none] (\the\mycount:5.4cm) circle(1.4cm);
     % The actual calendar
     \calendar at (\the\mycount:5.4cm) [
         dates=\the\year-\month-01 to \the\year-\month-last]
     if (day of month=1) {\large\color{\monthcolor!50!black}\tikzmonthcode}
     if (Sunday) [red]
     if (all) {
     % Again, compute angle
     \mycount=1
     \advance\mycount by -\pgfcalendarcurrentday
     \multiply\mycount by 11
     \advance\mycount by 90
     \pgftransformshift{\pgfpointpolar{\mycount}{1.2cm}}};}
\end{tikzpicture}}

\end{document}