%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                          Thesis Appendix A                          %
%                       Numerical Optimization                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter{Numerical Optimization: Introduction}
\label{chapter:optimization}

\graphicspath{{Appendix1-Optim/Figs/}}

%{{{SECTION: LIST OF CONTRIBUTIONS
%\section{List of contributions}
%\begin{itemize}
  %\item \sout{Introduction to optimization}
  %\item \sout{Notions of unconstrained optimization}
  %\item \sout{Notions of Constrained Optimization}
  %\item \sout{KKT}
  %\item Line Search
  %\item Trust Region
  %\item Filter
  %\item Merit function
  %\item SQP
  %\item Restoration phase
  %\item \sout{Hessian Approximation: BFGS, SR1}
%\end{itemize}
%}}}
\section{Introduction}
In modern science, optimization has an important place.
Mechanical engineers optimize the shape of structural parts.
Investors optimize the profit of a portfolio while minimizing the risks of loss.
Chemists optimize the efficiency and speed of reactions.
When it comes to robotics, optimization is widely used.
From the design of a robot to its actuation.
Any positioning of a robot requires the computation of the articular parameters of each joint of the robot, finding such parameters might be possible by using analytical methods for simple robots, but for robots as complex as humanoid robots, it is not possible.
Most often, an optimization process is used.

The goal of an optimization algorithm is to find an optimal solution $x^*$ to a problem.
Optimal in the sense that the solution is an optimum of a given objective function $f$.
And solution of a problem in the sense that it satisfies a set of $m$ constraints $\{c_i,\ i\in [1,m]\}$.
Both the constraints and the objective function are defined on the variable space $\mathit{S}$, which is the space in which the variable $x$ lives and in which we search a solution $x^*$ to our problem.

In order to present the principles of optimization, in this chapter, we will always consider that the variable space is $\mathit{S}=\mathbb{R}^n$.
We first consider unconstrained problems.
That type of problem will not be used in the rest of our dissertation, therefore, we will just present them shortly.
We will then focus on constrained optimization problems and the numerous methods used in their resolution.
We will particularly detail one specific constrained problem resolution algorithm that is the Sequential Quadratic Program (SQP).
The extension of those methods to solving problems on more complex variable spaces that are the non-Euclidean manifolds is the topic of Chapter~\ref{chapter:optimization_on_noneuclidean_manifolds}.

This Appendix does not pretend to give a fully detailed overview of numerical optimization methods, it gives the reader a quick overview of some key principles.
For more detailed information, we invite the reader to refer to the excellent books that we took inspiration from to write this chapter~\cite{nocedal:book:2006, bonnans:book:2003, boyd2004convex}.

\section{Unconstrained Optimization}

An unconstrained optimization problem consists of an objective function to minimize, without any constraint.
This problem, denoted $\mathcal{P}$, can be formulated as follows:

\begin{equation}
  \minimize_{x\in\mathbb{R}^n}\ {f(x)}
\label{eq:unconstrainedOptim}
\end{equation}

The classical approach to solve $\mathcal{P}$ is to use an iterative algorithm, starting from an initial guess $x_0$, and converging toward the solution $x^*$.
A very basic optimization scheme is presented in Algorithm~\ref{alg:basic_optim}.

\begin{algorithm}
\begin{algorithmic}
  \State{Starting from an initial guess $x_0$}
  \While{Convergence condition not met}
  \State{Compute descent direction $p_k$}
  \State{Update $x_{k+1}\leftarrow x_k + p_k$}
  \EndWhile{}
  \caption{Basic optimization scheme}
\label{alg:basic_optim}
\end{algorithmic}
\end{algorithm}

The objective function is not necessarily completely known, in the sense that we cannot always have an explicit formula. Often, the function $f$ is computed by another program that is able to compute $f(x)$, $\nabla_x f(x)$ and sometimes $\nabla_{xx} f(x)$ for a given value of $x$.
In order to have an efficient algorithm, we need to avoid any unnecessary computation of $f(x)$ and its derivatives.
We denote the values taken by $x$ along the iterations as $x_0$, $x_1$, $x_2$,\ldots $x_i$.
And $f(x_i)$ is denoted $f_i$.

Since our knowledge of the objective function is only partial, without further assumptions, it is not possible to guarantee that a point $x^*$ is a global solution:

\begin{equation}
  \text{$x^*$ is a global solution of $\mathcal{P}$ on $\mathit{S}$ } \equiv \forall x \in \mathit{S}, f(x^*) \leq f(x)
\end{equation}

Though, we can find a local solution $x^*$ of $\mathcal{P}$ (a local minimizer of $f$): such that there exist a neighborhood $\mathit{N}$ of $x^*$ where $\forall x\in \mathit{N}$, $f(x^*) \leq f(x)$.
Or even a strict local minimizer of $f$: such that there exist a neighborhood $\mathit{N}$ of $x^*$ where $\forall x\in \mathit{N}$, $f(x^*) < f(x)$.
That is the kind of solution that we are looking for and that our algorithms should find.

Under the assumption that the objective function is smooth and sufficiently continuous ($\mathcal{C}^2$), we have the following sufficient conditions for the optimality of $x^*$:

\begin{theorem}
  If $\nabla^2f$ is continuous in an open neighborhood of $x^*$, $\nabla f(x^*)=0$ and $\nabla^2 f(x^*)$ is positive definite.
  Then $x^*$ is a strict local minimizer of $f$.
\label{optimalityTheorem}
\end{theorem}

The same definition can be given for a local minimizer with $\nabla^2f(x^*)$ positive semi-definite.

There are several ways to choose a descent direction $p_k$ from an iterate $x_k$. The
most obvious one is probably the steepest descent direction $-\nabla f_k$. This
method provides the direction along which f decreases most rapidly and only
requires the evaluation of the first derivative of $f$, but that method can
become extremely slow on complicated problems. Another popular approach is the
Newton method, in which the objective function is approximated to the second
order

\begin{equation}
  f(x_k+p) = f_k + p^T\nabla f_k + p^T\nabla^2f_k p
\end{equation}

Then the chosen descent direction is the optimum of that approximated function,
the Newton direction.
\begin{equation}
  p^N_k = -{(\nabla^2 f_k)}^{-1} \nabla f_k
\end{equation}
The choice of this descent direction implies that the $\nabla^2f_k$ is positive
definite, in which case an adaptation of the definition of $p_k$ is required. Or
an approximation $B_k$ of $\nabla^2f_k$ that guarantees definite positiveness can be
used. %For example, the symmetric-rank-one (SR1) formula and the BFGS (Broyden,
%Fletcher, Goldfarb, Shanno) formula. Then the step becomes

\begin{equation}
  p_k = -B_k^{-1}\nabla f_k
\end{equation}

$p_k$ is then added to $x_k$ to compute $x_{k+1} \leftarrow x_k + p_k$ and the process is repeated until convergence is reached.

Many methods and refinements exist to solve this problem and some are presented in~\cite{nocedal:book:2006}.
Our main focus here is on methods to solve constrained problem as they arise in robotics.

%\subsection{Globalization methods (Section NEEDS TO BE REWRITTEN)}

%During the resolution of an optimization problem, the algorithm will generate a
%sequence of iterates $x_k$ starting from the initial iterate $x_0$ (Which is
%usually provided by the user). During the step $k$ of the optimization process,
%the solver, the current point is $x_k$ and we try to find $x_{k+1}$ such that
%$f(x_{k+1}) < f(x_k)$. There are several strategies to do that but we will only focus
%on 2 of them that are the most popular, the line-search and trust-region
%methods.

%\subsubsection{The Line-Search Strategy}
%In the Line-Search strategy, given a point $x_k$, a descent direction $p_k$ from this
%point is chosen and then a length of step is calculated to minimize the
%following 1-dimensional problem:
%\begin{align}
  %\minimize_{\alpha \in \mathbb{R}^+} f(x_k + \alpha.p_k)
%\label{eq:lineSearchNLP}
%\end{align}

%Once the best value of $\alpha$ has been found, the next iterate is computed:
%$x_{k+1} = x_{k} + \alpha p_k$ and the same process is repeated until a
%satisfying solution is found.

%It is not always necessary to find the optimal value of $\alpha$, especially if
%that is expensive. Indeed, $\alpha$ is only used to calculate the next iterate,
%from which another $p_k$ and $\alpha$ will be calculated. And in the end, the
%imprecision on the computation of $\alpha$ will be erased in the other steps of
%the resolution.

%There are several ways to choose a descent direction from an iterate $x_k$. The
%most obvious one is probably the steepest descent direction $-\nabla f_k$. This
%method provides the direction along which f decreases most rapidly and only
%requires the evaluation of the first derivative of $f$, but that method can
%become extremely slow on complicated problems. Another popular approach is the
%Newton method, in which the objective function is approximated to the second
%order

%\begin{equation}
  %f(x_k+p) = f_k + p^T\nabla f_k + p^T\nabla^2f_k p
%\end{equation}

%Then the chosen descent direction is the optimum of that approximated function,
%the Newton direction.
%\begin{equation}
  %p^N_k = -{(\nabla^2 f_k)}^{-1} \nabla f_k
%\end{equation}
%The choice of this descent direction implies that the $\nabla^2f_k$ is positive
%definite, in which case an adaptation of the definition of $p_k$ is required. Or
%an approximation $B_k$ of $\nabla^2f_k$ that guaranties definite positiveness can be
%used. For example, the symmetric-rank-one (SR1) formula and the BFGS (Broyden,
%Fletcher, Goldfarb, Shanno) formula. Then the step becomes

%\begin{equation}
  %p_k = -B_k^{-1}\nabla f_k
%\end{equation}

%\subsubsection{The Trust-Region Strategy}
%\label{ssec:the_trust_region_strategy}
%The Trust-Region Strategy works in an opposite way than the line-search one in
%the sense that during a line-search step, a direction is chosen, and based on
%that direction, a step-length is chosen. Whereas with a Trust-Region approach, a
%maximum step-length is chosen, and based on it, the descent direction and length
%are chosen.
%The principle of the trust region is that along the optimization process, a
%model of the problem is constructed and enriched at every step and at each step,
%the next iterate is the optimum of the model, with the constraint that the step
%to get there lies inside the trust-region. For example, let us consider that
%the trust region is a sphere of center $x_k$ and radius $\rho_k$, then the
%constraint on $p_k$ is $\|p_k\| \leq \rho_k$. A usual model to take for the
%objective function is the quadratic model with approximated Hessian
%\begin{equation}
  %m_k(p) = f(x_k+p) = f_k + p^T \nabla f_k + p^T B_k p
%\end{equation}
%And the optimization problem to solve at each step of the optimization is

%\begin{align}
  %\minimize_{p} & \quad f_k + p^T \nabla f_k + p^T B_k p \nonumber\\
%\text{s.t.}&
%\quad \|p\| \leq \rho_k
%\label{eq:trustRegionNLP}
%\end{align}

%Once the solution $p_k$ to this quadratic problem is found, its quality is
%estimated by evaluating the value of $f(x_k+p_k)$. If the actual decrease of $f$
%is satisfying (compared to the decrease predicted by the model) then the step is
%accepted and the size of the trust-region can be increased. Otherwise, the step
%is refused, the trust-region radius is reduced and a new step from $x_k$ is
%computed on that smaller trust region.

\section{Constrained Optimization}

Solving a constrained optimization problem consists in minimizing a cost function while satisfying a set of constraints.

A general formulation for such problems (that we denote $\mathcal{P}$) is:

\begin{equation}
  \label{formulation_NLCP}
  \mathcal{P} \equiv
  \left\{
  \begin{array}{l}
    \minimize\limits_{x\in\mathbb{R}^n}{f(x)}\\
    \text{ s.t. }
    \left\{
    \begin{array}{l}
      c_i(x) = 0,\ \forall i\in{E}\\
      c_i(x) \geq 0,\ \forall i\in{I}\\
    \end{array}
    \right.
  \end{array}
  \right.
\end{equation}

Where $f$ and $c_i$ are real-valued functions on a subset of $\mathbb{R}^n$.
$f$ is the objective function, and the $c_i$ are the constraint functions.
${I}$ and ${E}$ are sets of index such that $c_i,\ i\in{E}$ are the equality constraints, and $c_i,\ i\in{I}$ are the inequality constraints.

We define the feasible set $\Omega$ that contains all the feasible points (points satisfying the constraints) of $\mathcal{P}$.

\begin{equation}
  \Omega = \left\{ x\in \mathbb{R}^n:\ \forall i\in {E},\ c_i=0,\ \forall i\in{I},\ c_i \geq0\right\}
\end{equation}

The formulation~\ref{formulation_NLCP} can then be rewritten as:
\begin{equation}
  \label{formulation_NLCP_compact}
  \mathcal{P} \equiv \minimize_{x\in\Omega}{f(x)}
\end{equation}

In the general case, the problem~\ref{formulation_NLCP_compact} has multiple local solutions.
And finding the global minimizer of $f$ in $\Omega$ is a difficult problem that we do not treat in this thesis.
Our goal is to find a local minimizer $x^*$ of $f$ in $\Omega$.

\subsection{Optimality conditions}
\label{sub:optimality_conditions}

\paragraph{First-Order Optimality Conditions}

The First Order Optimality Condition (Karush-Kuhn-Tucker Condition) is a necessary condition verified by all solutions of problem~\ref{formulation_NLCP}.

We introduce the Lagrangian function of~\ref{formulation_NLCP}:
\begin{equation}
  \mathcal{L}(x,\lambda) = f(x) + \sum_{i\in E\cup I}\lambda_i c_i(x)
\end{equation}

Any given constraint $c_i$ is said to be active at $x$ if $c_i(x)=0$.
In particular, for any feasible point $x$, all equality constraints $c_i,\ i\in E$ are active.
An inequality constraint $c_i,\ i\in I$ is inactive if $c_i(x)>0$ and active if $c_i(x) = 0$

\begin{definition}
\label{active_set}
  The active set $\mathit{A}(x)$ at a feasible point $x$ is the set of all the indexes of active constraint.
  \begin{equation}
    \mathit{A}(x)=E\cup\{i\in I: c_i(x) = 0\}
  \end{equation}
\end{definition}

Most optimization algorithms make the assumption that at the solution, the constraints satisfy the following Linear Independence Constraints' Qualification (LICQ) definition:

\begin{definition}
  Given a point $x$ and an active set $\mathit{A}(x)$, we say that the LICQ holds if the set of active constraint gradient $\{\nabla c_i(x),\ i\in \mathit{A}(x)\}$ is linearly independent
\end{definition}

In general, if LICQ holds, none of the active constraints gradients can be zero.
%In particular, if any gradient of a constraint is null, then the LICQ does not hold.
%The LICQ should be taken into account during the formulation of a problem.

\begin{theorem}{First-Order Necessary Conditions}\\
\label{KKT_conditions}
  Suppose that $x^*$ is a local solution of~\ref{formulation_NLCP}, that the functions $f$ and $c_i$ are continuously differentiable, and that the LICQ holds at $x^*$.
  Then there is a Lagrange multiplier vector $\lambda^*$, with components $\lambda_i^*$, $i\in E\cup I$, such that the following conditions are satisfied at $(x^*,\lambda^*)$
  \begin{equation}
  \begin{array}{ll}
    \nabla_x\mathcal{L}(x^*,\lambda^*) = 0 &, \\
    c_i(x^*) = 0 &,\ \forall i\in E\\
    c_i(x^*) \geq 0 &,\ \forall i\in I\\
    \lambda_i^* \geq 0 &,\ \forall i\in I\\
    \lambda_i^* c_i(x^*)=0 &,\ \forall i \in E\cup I\\
  \end{array}
  \end{equation}
\end{theorem}

In many cases, the main goal of an optimization algorithm is to find a point that satisfies the KKT conditions.

\paragraph{Second-Order Optimality Conditions}

\begin{definition}
  Given a feasible point $x$, and the active set $\mathit{A}(x)$, the  set of linearized feasible directions $F(x)$ is:
  \begin{equation}
    F(x)=\left\{d\left|
        \begin{array}{ll}
          d^T\nabla c_i(x) = 0&,\ \forall i\in E \\
          d^T\nabla c_i(x) \geq 0&,\ \forall i\in \mathit{A}(x)\cap I \\
        \end{array}
        \right.
    \right\}
  \end{equation}
\end{definition}

And at a KKT solution $(x^*,\lambda^*)$, the critical cone $C(x^*, \lambda^*)$ is:

\begin{equation}
  C(x^*,\lambda^*) = \{w\in F(x^*)|{\nabla c_i(x^*)}^T w=0, \forall i\in\mathit{A}(x^*)\cap I\ \text{with } \lambda_i^*>0\}
\end{equation}

%The critical cone contains the linearly feasible directions for which it is not clear from first derivative information alone if $f$ will increase or decrease.

Once the KKT condition is reached for a point $(x^*, \lambda^*)$, for a direction $w$ of $F(x^*)$ for which $w^T\nabla f(x^*)=0$, it is impossible to tell from first derivative information only, if an increment in this direction will have a positive effect on the problem resolution.
Thus it is possible that the KKT constraint is not enough to determine if a point is a solution or just a stationary point.

The Second-Order Sufficient Conditions allow to discriminate local solutions from stationary points:

\begin{theorem}
  Suppose that for some feasible point $x^*\in \mathbb{R}^n$ there is a Lagrange multiplier vector $\lambda^*$ such that the KKT conditions are satisfied. Suppose also that
  \begin{equation}
    w^T\nabla_{xx}^2\mathcal{L}(x^*,\lambda^*)w>0,\ \forall w\in C(x^*,\lambda^*),\ w\neq 0
  \end{equation}
  Then $x^*$ is a strict local solution for~\ref{formulation_NLCP}
\end{theorem}

In particular, this condition is always verified if $\nabla_{xx}^2\mathcal{L}(x^*,\lambda^*)$ is positive definite.

\section{Resolution of a NonLinear Constrained Optimization Problem}
\label{sec:resolution_of_a_non_linear_constrained_optimization_problem}

%In the previous section, we presented some theoretical tools to describe the solution of a nonlinear constrained optimization problem that only use the derivative terms of order one and two of the problem's functions.
In the previous section, we presented some theoretical tools to decide if a point is a solution to a nonlinear constrained optimization problem based on the values of the first and second order derivatives of its functions.
Here we present some methods for actually solving such problems.
There exist many different algorithms to solve a nonlinear constrained optimization problem.
But all have in common to be iterative processes that follow the model of Algorithm~\ref{alg:basic_optim_nlcp}.
%From the first and (sometimes) second-order informations on the functions $f$ and $c_i$ that constitute the problem~\ref{formulation_NLCP}, we find a suitable increment $z$ such that $x_k+z$ is closer to the solution than $x_k$.
%And we iterate that operation until a point $x_k$ sufficiently close to a solution is found.
%By sufficiently close to a solution we mean that this point satisfies the optimality conditions with a good enough precision.

\begin{algorithm}
\begin{algorithmic}
  \State{Starting from an initial guess $x_0$}
  \Repeat
  \State{Compute an increment $z_k$ such that $x_k+z_k$ is closer to the solution }
  \State{Update $x_{k+1}\leftarrow x_k + z_k$}
  \Until{Optimality conditions are met with a precision $\epsilon$}
\caption{Basic scheme for solving a nonlinear constrained optimization problem}
\label{alg:basic_optim_nlcp}
\end{algorithmic}
\end{algorithm}

The resolutions algorithms differ mostly by the method chosen to generate a satisfactory increment $z$. We will list here some of the most popular methods:

\paragraph{The penalty method} combines the cost and constraints function in a penalty function that, as its name indicates, penalizes the violation of constraints, without completely proscribing it.
The penalty function can be written as follows, using the notation ${[y]}^- = \max\{0, -y\}$:

\begin{equation}
  \label{penalty_function}
  p(\mu, x) = f(x) + \mu \sum_{i\in E}|c_i(x)| + \mu \sum_{i\in I} {[c_i(x)]}^-
\end{equation}

With this approach, an unconstrained optimization approach can be used.
The minimum of $p(\mu,x)$ varies with the penalty parameter $\mu$.
By increasing $\mu$ to $\infty$, we penalize the violation of the constraints with increasing severity until reaching a solution $x^*$.

\paragraph{The interior point method} generates steps by solving a relaxed constrained problem where slack variables are introduced to relax inequality constraints.
The problem solved is the following:
%The problem to solve only contains equality, boundary constraints and a cost function that prevents the slack variables from getting too close to 0:

\begin{equation}
\label{eq:interior_point}
\begin{aligned}
  \minimize_{x,s}{} & f(x)\\
  \text{subject to }&
  \left\{
    \begin{array}{l}
     c_i = 0,\ i\in E\\
     c_i - s_i = 0,\ i\in I\\
     s_i \geq 0,\ i\in I
  \end{array}
  \right.
\end{aligned}
\end{equation}

One way to solve this problem is to consider the following associated barrier problem:

\begin{equation}
\begin{aligned}
\label{eq:barrier_question}
  \minimize_{x,s}{} & f(x)- \mu\sum_{i\in I} \log(s_i)\\
  \text{subject to } &
  \left\{
    \begin{array}{l}
     c_i = 0,\ i\in E\\
     c_i - s_i = 0,\ i\in I\\
  \end{array}
  \right.
\end{aligned}
\end{equation}

and to find its approximate solutions for a sequence of positive barrier parameters $\{\mu_k\}$ that converges to zero.
The minimization of the barrier term $-\mu\sum_{i\in I} \log(s_i)$ prevents the terms of $s$ from becoming too close to zero.
The solution for a given $\{\mu_k\}$ is obtained by applying Newton's method to the nonlinear system that represents the KKT conditions for the barrier problem.
The solution is reached once the optimality conditions of~\ref{eq:interior_point} are met.

\paragraph{The Sequential Quadratic Programming (SQP)} is an approach in which the Newton's method is used to solve the nonlinear problem raised by the KKT conditions of problem~\ref{formulation_NLCP}.
Basically, it comes down to finding the increment $z^*$ that solves the Quadratic Programming (QP) associated with the problem~\ref{approx_QP}, at each iterate $(x_k, \lambda_k)$.
%The QP is an approximation of the KKT conditions~\ref{KKT_conditions} of the actual problem~\ref{formulation_NLCP} to the first order:

\begin{equation}
\label{approx_QP}
  \begin{array}{ll}
    \minimize\limits_{z\in \mathbb{R}^n}{} & \frac{1}{2}z^T \nabla_{xx}^2\mathcal{L}(x_k, \lambda_k)z + \nabla {f(x_k)}^T z \\
    \text{subject to } & {\nabla c_i(x_k)}^T z+c_i(x_k)=0,\ i\in E \\
                       & {\nabla c_i(x_k)}^T z+c_i(x_k)\geq 0,\ i\in I
  \end{array}
\end{equation}

Given $z^*$ the solution of~\ref{approx_QP}, it can be tempting to directly take the next iterate as $x_{k+1} = x_k + z^*$.
But using that method as is can be problematic as the length of the iterate needs not be bounded.
Thus it is possible to generate a very large step that satisfies the QP\@.
The QP only approximates the original problem locally.
So taking a too big step can get us further from the solution than we previously were.
To palliate to that issue, mainly two methods are used:
\begin{itemize}
  \item The line-search method: The solution $z$ of~\ref{approx_QP} is viewed as a direction and we search a parameter $\alpha\in [0;1]$ so that the next iterate $x_k + \alpha z$ is optimal for the original problem.
  \item The trust-region method adds a set of bound constraints to the QP~\ref{approx_QP}. So that the length of the step is limited by the trust-region. The size $\rho$ of the trust region is modified along the iterations based on the estimated quality of the QP approximation. In that case, the QP becomes:
\begin{equation}
  \begin{array}{ll}
    \minimize\limits_{z\in \mathbb{R}^n}{} & \frac{1}{2}z^T \nabla_{xx}^2 \mathcal{L}(x_k, \lambda_k)z + {\nabla f(x_k)}^T z \\
    \text{subject to } & {\nabla c_i(x_k)}^T z+c_i(x_k)=0,\ i\in E \\
                       & {\nabla c_i(x_k)}^T z+c_i(x_k)\geq 0,\ i\in I\\
                       & |z|<\rho
  \end{array}
\end{equation}
\end{itemize}

\section{Sequential Quadratic Programming}
\label{sec:sequential_quadratic_programming}

The Sequential Quadratic Programming (SQP) method is one of the most effective methods to solve small and large scale nonlinear constrained optimization problems.
Together with the interior point method, they are currently considered to be the most powerful algorithms for large-scale nonlinear programming.
The SQP methods show their strength when solving problems with nonlinearities in the constraints~\cite{nocedal:book:2006}.

\subsection{Principle}
\label{sub:principle}

As we stated before, the main idea behind the SQP approach it to use the Newton's method to solve the nonlinear problem raised by the KKT conditions.
For simplicity, we consider a problem without inequality constraints.
We denote $C$ the vector of equality constraints.
We denote $z_x$ and $z_\lambda$ the increments on $x$ and $\lambda$ respectively.
\begin{equation}
  \begin{array}{l}
    x_{k+1} = x_k + z_x\\
    \lambda_{k+1} = \lambda_k+z_\lambda\\
  \end{array}
\end{equation}

The problem is the following:
\begin{equation}
  \begin{array}{l}
    \minimize\limits_{x\in\mathbb{R}^n}{f(x)} \\
    \text{ subject to } C(x) = 0
  \end{array}
\end{equation}

Its KKT conditions are:
\begin{equation}
  \label{KKT_equ}
  \left\{
\begin{array}{ll}
  \nabla_x\mathcal{L}(x^*,\lambda^*) = 0\\
  C(x^*) = 0\\
\end{array}
\right.
\end{equation}

We denote with a subscript $y_k$ the value of the quantity $y$ evaluated at point $(x_k, \lambda_k)$.

The first order linearization of~\ref{KKT_equ} gives:

\begin{equation}
  \label{KKT_1st_order}
  \left\{
\begin{array}{l}
  \nabla_{xx}^2\mathcal{L}_k z_x + \nabla_{x\lambda}^2\mathcal{L}_k z_\lambda + \nabla_x\mathcal{L}_k  = 0\\
  \nabla_x C_k z_x + C_k = 0\\
\end{array}
\right. \\
\end{equation}
which is equivalent to:
\begin{equation}
  \left\{
\begin{array}{l}
  \nabla_{xx}^2\mathcal{L}_k z_x + \nabla_{x}C_k (\lambda_k + z_\lambda) = - \nabla_{x}f_k\\
  \nabla_x C_k z_x = - C_k \\
\end{array}
\right. \\
\end{equation}
Or in matrix form:
\begin{equation}
  \begin{pmatrix}
      \nabla_{xx}^2\mathcal{L}_k & \nabla_x C_k\\
      \nabla_x C_k & 0\\
  \end{pmatrix}
  \begin{pmatrix}
      z_x\\
      \lambda_{k+1}\\
  \end{pmatrix}
  =
  \begin{pmatrix}
      -\nabla_{x}f_k\\
      -C_k\\
  \end{pmatrix}
\end{equation}

Solving this problem is equivalent to solving a QP problem of the following form:

\begin{equation}
  \begin{array}{ll}
    \minimize\limits_{z_x} &f_k + \nabla_x f_k ^T z_x + \frac{1}{2} z_x^T\nabla_{xx}^2\mathcal{L}_k z_x \\
    \text{s.t.} & \nabla_x C_k^T z_x + C_k = 0\\
  \end{array}
\end{equation}

The solution of this problem satisfies the following matrix equality:

\begin{equation}
  \begin{pmatrix}
      \nabla_{xx}^2\mathcal{L}_k & -\nabla_x C_k\\
      \nabla_x C_k & 0\\
  \end{pmatrix}
  \begin{pmatrix}
      z_x\\
      l_k\\
  \end{pmatrix}
  =
  \begin{pmatrix}
      - \nabla_{x}f_k\\
      - C_k\\
  \end{pmatrix}
\end{equation}

%Note that this problem has a solution if the following assumptions hold:
%\begin{itemize}
  %\item The constraint Jacobian $\nabla_x C_k$ has full rank.
  %\item The matrix $\nabla_{xx}^2\mathcal{L}_k$ is positive definite on the tangent space of the constraints:\\ $d^T\nabla_{xx}^2\mathcal{L}_k d \geq 0,\ \forall d\neq 0$ such that ${\nabla_x C_k}^T d = 0$.
%\end{itemize}

Therefore, the problem raised by the linearization of the KKT conditions to the first order can be solved as a QP problem.
Denoting the solution of the QP problem $(z_x, l_k)$, the solution to~\ref{KKT_1st_order} is given by

\begin{equation}
  \begin{pmatrix}
      z_x\\
      \lambda_{k+1}\\
  \end{pmatrix}
  \leftarrow
  \begin{pmatrix}
      z_x\\
      -l_k\\
  \end{pmatrix}
\end{equation}

This development can easily be extended to treat the case of problems constrained with inequality constraints:

\begin{equation}
\label{eq:prob_with_ineq}
\begin{aligned}
  \minimize_{x\in\mathbb{R}^n}{}&{f(x)}\\
  \text{s.t.}&
  \left\{
  \begin{array}{l}
    c_i(x) = 0,\ \forall i\in{E}\\
    c_i(x) \geq 0,\ \forall i\in{I}\\
  \end{array}
  \right.
\end{aligned}
\end{equation}

By solving the following Inequality-constrained Quadratic Problem (IQP) system at each iteration:

\begin{equation}
\label{IQP}
  \begin{aligned}
    \minimize\limits_{z_x} &f_k + \nabla_x f_k ^T z_x + \frac{1}{2} z_x^T\nabla_{xx}^2\mathcal{L}_k z_x \\
    \text{s.t.} &
  \left\{
  \begin{array}{l}
    \nabla_x {c_i}_k z_x + {c_i}_k = 0 ,\ \forall i\in E\\
    \nabla_x {c_i}_k z_x + {c_i}_k \geq 0 ,\ \forall i\in I\\
  \end{array}
  \right.
  \end{aligned}
\end{equation}

The main difficulty in solving that QP~\ref{IQP} comes from finding the optimal active set $\mathit{A}_k$.
It is a necessary but costly operation, especially when starting from an initial active set $\mathit{A}_0$.
The process is mostly based on a try and guess approach guided by heuristics (that may vary with different resolution algorithms).

To find the optimal active set, the QP starts from an initial active set $\mathit{A}_0$ ignore the non-active constraints and try to solve the QP with the remaining active constraints.
At a step $k$ of the resolution of the IQP, all the constraints in the active set $\mathit{A}$ are treated as equality constraints and the others are simply ignored, the QP to solve becomes:

\begin{equation}
  \text{EQP} \equiv \left\{
  \begin{array}{ll}
    \minimize\limits_{z_x} &f_k + \nabla_x f_k ^T z_x + \frac{1}{2} z_x^T\nabla_{xx}^2\mathcal{L}_k z_x \\
    \text{s.t.} & \nabla_x {c_i}_k z_x + {c_i}_k = 0 ,\ \forall i\in \mathit{A}_k\\
  \end{array}
  \right.
\end{equation}

This EQP is solved, and its solution is checked against the constraints that were previously ignored.
If some of them are violated then the solution is not satisfactory and the active set is updated by adding one or several of the violated constraints to it.
This operation is repeated until there are no more constraints to be added.
Once all the constraints have been added as active constraints to the EQP, the problem may be over-constrained.
To detect that, the Lagrange multipliers are computed and if some of them do not agree with the KKT conditions of the IQP~\ref{IQP}, then one of them is removed from the active set and the resulting EQP is solved, and the process continues until a satisfactory solution is found.
The heuristics used to choose which constraints to add or remove from the active set and to avoid cycling between active sets are out of the scope of this dissertation.

Once the SQP gets close to the solution, the set of active constraints should not change much from one iterate $x_k$ to the next one.
It is often useful to initialize the IQP's active set with the optimal active set of the previous iterate: $\mathit{A}_0(x_{k+1})\leftarrow\mathit{A}^*(x_k)$. Then the ${(k+1)}^{th}$ QP starts from an active set close to optimal and can be solved much faster.
That method is called the \textit{warm-start}.

The SQP approach to solving the problem~\ref{formulation_NLCP} as presented above leans on the assumption that at each step, the QP generated is feasible.
If it is not, a restoration phase is entered and finds a feasible point, see Section~\ref{sub:restoration_phase}.
%which requires that the Hessian $\nabla_{xx}^2\mathcal{L}$ is positive definite on the tangent space of the active constraints.

Solving the QP problem~\ref{IQP} gives a solution step to a linearized problem, which in general is not the solution to the original nonlinear problem.
Thus, taking that step without further verification can be dangerous and lead to bad iterates.
To cope with that issue, several methods exist.
In the next few sections, we present the globalization methods that are the Line Search and Trust Region approaches.
They are used alongside methods to choose whether to accept or reject a step like the merit function and filters in order to monitor the length and direction of the step with regards to the nonlinear problem.
And finally, we discuss some Hessian approximation methods.

\subsection{Globalization methods}
\label{sub:globalization_methods}

The globalization phase of an SQP algorithm is meant to modify the steps generated by the QP resolution in order to improve the global convergence of the algorithm, either by multiplying them with a coefficient $\alpha$ in the Line-Search approach, or by bounding the norm of the step found in the QP by adding to the QP a boundary constraint on $z$ that reflects our trust in the quality of the approximated problem.

\subsubsection{The Line-Search Strategy}
\label{ssub:line_search}

Given a step $z_k$ generated by the resolution of the QP, the goal of the line-search is to find a coefficient $\alpha$ (typically in $[0,1]$) such that $x_{k+1}=x_k + \alpha z_k$ makes the violation of the constraints and the value of the cost function decrease sufficiently.
To decide whether those decreases are sufficient, a merit function and a criterion are used.
A merit function is a function of $\alpha$ that transcribes the value of the objective function penalized by the violation of the constraints.
%We define the operator $[.]^-$ that computes the violation of inequality constraints as follows:
%\begin{equation}
  %[c]^- = \sum -c
%\end{equation}
For a problem described by the system~\ref{eq:prob_with_ineq}, with a penalty parameter $\mu$, a typical expression of the merit function $M$ is:
\begin{equation}
  M(\alpha) = f(x_k +\alpha z_k) + \mu \sum_{i\in E} \left| c_i(x_k+\alpha z_k) \right| + \mu \sum_{i\in I} \max \left(0,-c_i(x_k + \alpha z_k)\right)
\end{equation}

Although finding the optimal value of $\alpha$ to minimize the 1-dimensional function $M$ is possible, it can prove costly, and is not necessary, because the only thing that we want is an optimal solution to the problem~\ref{eq:prob_with_ineq}, thus the exact value of each iterate does not matter much.
Instead, we use a criterion to decide when the value of $\alpha$ gives a satisfactory decrease.
Various methods and criterion can be used to find a satisfactory value of $\alpha$.
For example, the Wolfe line-search:

%In the Line-Search strategy, starting from a current iterate $x_k$ with a QP generated step $z$ solution of the linearized problem~\ref{IQP}.
%We search a coefficient $\alpha$ such that $x_{k+1}=x_k+\alpha z$ is satisfactory.
%A usual way to decide if a point is satisfactory is to use a Merit function.
%A Merit function is somewhat similar to a penalty function in the sense that it estimates the quality of a point from the value of the cost function, penalized by the violation of the constraints.
%A typical merit function for a problem with only equality constraints can be written as:
%\begin{equation}
  %M(x,\mu) = f(x)+\mu \|c(x)\|_1
%\end{equation}

%The goal of the line-search is to find a value $\alpha^*$ of $\alpha$ that minimizes the merit function: $M(\alpha^*) < M(0)$ and $M'(\alpha^*)=0$.
%Many simple and efficient methods exist to minimize a 1-dimensional function but most work better if the function to minimize is smooth.
%If inequality constraints are present, a simple penalty function like~\ref{penalty_function} would not be satisfactory because of the non-smoothness of the operator ${[.]}^-$.
%To avoid that problem, slack variables can come in handy to replace the inequality constraints in the problem as follows:

%\begin{equation}
  %c_i(x)\geq 0\ \equiv
  %\left\{
  %\begin{array}{l}
    %c_i(x)-s_i=0\\
    %s_i\geq 0
  %\end{array}
  %\right.
%\end{equation}

%Once the Merit function is chosen, it is time to minimize it.
%But in fact, finding the optimal value of $\alpha$ is not necessary, not only because it can be an expensive.
%But also because, $\alpha$ is only used to calculate the next iterate, from which another $p_k$ and $\alpha$ will be calculated.
%And in the end, the imprecision on the computation of $\alpha$ will be erased in the other steps of the resolution.
%Ultimately, the optimality of the result of the line-search does not matter much because our goal is only to solve the SQP problem in its totality.
%Therefore, for the sake of devising a time efficient algorithm, finding an $\alpha$ that generates a `sufficient' decrease of the merit function is enough.

Let $\mu_1$ and $\mu_2$ be 2 real numbers such that: $0<\mu_1<\mu_2<1$.
A sufficient decrease of the merit function can be depicted by the condition $M(\alpha) \leq M(0) + \mu_1 \alpha M'(0)$.
A sufficient increase of its derivative by $M'(\alpha)\geq\mu_2 M'(0)$.
The Wolfe Line-Search proceeds by narrowing iteratively an interval $[\alpha_L,\ \alpha_R]$ by trying a value $\alpha$ in this interval against some tests and based on their results, decide to narrow it by the right or the left and repeat that operation with the new interval until a satisfying value is found.
Note that the Wolfe line-search is guaranteed to terminate if $M$ is $\mathcal{C}^1$ and bounded below.

The Wolfe Line-Search can be schematically described by algorithm:~\ref{alg:Wolfe} and illustrated by~\Figref{fig:Wolfe}.

\begin{algorithm}
\begin{algorithmic}
  \State{Init $[\alpha_L,\alpha_R]\leftarrow[0\ ,1]$}
  \Loop{Choose $\alpha\in[\alpha_L,\alpha_R]$\\
  Evaluate $M(\alpha)$ and $M'(\alpha)$
  {\renewcommand\labelenumi{(\theenumi)}
  \begin{enumerate}
    \item {$M(\alpha) \leq M(0) + \mu_1 \alpha M'(0)\text{ and } M'(\alpha)<\mu_2 M'(0)$}: $\alpha$ is too small, $\alpha_L\leftarrow a$
    \item {$M(\alpha) \leq M(0) + \mu_1 \alpha M'(0) \text{ and } M'(\alpha)\geq\mu_2 M'(0)$}: Terminate, \Return$\alpha$
    \item {$M(\alpha) > M(0) + \mu_1 \alpha M'(0)$}: $\alpha$ is too big, $\alpha_R\leftarrow \alpha$
  \end{enumerate}
  }}
  \EndLoop{}
  \caption{The Wolfe line-search}
\label{alg:Wolfe}
\end{algorithmic}
\end{algorithm}

\begin{figure}
  \centering
  \includegraphics[width=0.7\textwidth]{line-search.pdf}
  \caption{Illustration of the choice made by the Wolfe line-search for values of $\alpha$}
\label{fig:Wolfe}
\end{figure}

The Wolfe line-search is popular, but it requires the computation of the derivative of the merit function, which can be prohibitively expensive in some cases, including in posture generation for robotics problems, where the derivatives are usually expensive.
Other line-search methods exist that do not require the derivative of $M$ for $\alpha\neq0$. For example the Goldstein and Price, or the Armijo methods.

\subsubsection{The filter method}
\label{ssub:the_filter_method}
The decision to accept on not a step generated by the QP can be made using a Filter approach instead of the Wolfe line search, as introduced by Fletcher in~\cite{fletcher:mathprog:2000}.
The goal of that method is to minimize the cost function $f(x)$ and the constraint violation $h(x)$ separately.
A step is accepted if it improves at least one of the function or the constraint violation.
\begin{equation}
  h(x) = \sum\limits_{k\in E} |c_k(x)| + \sum\limits_{k\in I} \max(0, -c_k(x))
\end{equation}

Denoting $h_i = h(x_i)$ and $f_i = f(x_i)$, we define the notion of domination as follows:
\begin{definition}
  \begin{equation}
    p_i\ \text{dominates }p_j \Leftrightarrow \left\{
        \begin{array}{l}
    f_i < f_j \\
    h_i < h_j
  \end{array}  \right.
  \end{equation}
\end{definition}

The filter maintains a list of pairs $p_i=\{f_i, h_i\}$ such that no pair dominates any other pair.
When a new point $x$ is submitted to the filter for acceptance, the values $f(x)$ and $h(x)$ are computed and the pair $p = \{f(x), h(x)\}$ is compared to every pair $p_i$.
If there is at least one pair $p_i$ in the filter that dominates $p$, the point is refused.
Otherwise, no pair of the filter dominates $p$, then $p$ is accepted and added to the filter.
Once $p$ is added to the filter, any pair in the filter that is dominated by $p$ is removed from it to ensure to keep a list of pairs non-dominated by each other in the filter.
In order to ensure global convergence, this method requires several refinements as explained in~\cite{fletcher:mathprog:2000}.
First, it needs to avoid accepting pairs that are excessively close to each other. For that, the domination criterion is modified with a sloping envelope, as proposed in Chin~\cite{chin:mathprog:2003}.
The sloping envelope definition takes user defined parameters $\beta$ and $\gamma$ in $[0,\ 1]$.

\begin{definition}
  \begin{equation}
    p_i\ \text{dominates }p_j \Leftrightarrow \left\{
        \begin{array}{l}
    f_i < f_j - \gamma h\ \\
    h_i < \beta h_j
  \end{array}  \right.
  \end{equation}
\end{definition}

\begin{figure}
  \centering
  \includegraphics[width=0.7\textwidth]{filter.pdf}
  \caption{Representation of a filter with sloping envelope}
\label{fig:Filter}
\end{figure}

Another basic necessary improvement is to set an upper bound to the constraint violation, to avoid having the algorithm generate points that minimize the cost function while completely violating the constraints.

A representation of the filter method is given in~\Figref{fig:Filter}

The filter method is convenient because it does not require the same complicated updates as can be found in penalty based methods where the penalty parameter needs to be updated regularly.
Also, with the filter method, no derivative computation is required.
That method is generally more permissive than merit-based method in the sense that it refuses fewer points.

The filter method, as well as the merit function based methods, can be used in line-search and trust-region algorithms.

\subsubsection{The Trust-Region Strategy}
\label{ssub:the_trust_region_strategy}
The Trust Region strategy is based on the idea that at any iterate $x_k$ the quadratic model made of the problem and fed to the QP solver can only be trusted to be relevant is a finite region around the iterate.
That region is called the trust region and its size is usually governed by a single positive parameter $\rho_k$ that can evolve along the optimization process.
This translates in a modified QP to solve at each iteration.
A boundary constraint describing the trust region is added to the problem.
At each step, the modified problem writes as:

\begin{equation}
  \begin{array}{ll}
    \minimize\limits_{z\in \mathbb{R}^n}{} & \frac{1}{2}z^T\nabla_{xx}^2Hz + \sum_{i\in\mathcal{U}}{\nabla c_i(x_k)}^T z \\
    \text{subject to } & {\nabla c_i(x_k)}^T z+c_i(x_k)=0,\ i\in E \\
                       & {\nabla c_i(x_k)}^T z+c_i(x_k)\geq 0,\ i\in I\\
                       & |z|<\rho_k
  \end{array}
\label{approx_QP_TR}
\end{equation}

Once a solution $z$ of~\ref{approx_QP_TR} is found, the potential next iterate $x_{k+1} = x_k + z$ is checked against the acceptance criterion (should it be a merit function or a filter or other).
If it is accepted, that means that our current model is good, we move to the next step with $x_{k+1} \leftarrow x_k + z$, and the size of the trust region can be augmented based on some heuristics.
Otherwise, the iterate is refused, the model is less good than expected, the size of the trust region is reduced based on some heuristics (e.g. $\rho_{k+1}\leftarrow\rho_k /2$) and the problem~\ref{approx_QP_TR} is solved again with the new value of $\rho_{k+1}$.
This is repeated until a satisfying point is found, or until an unfeasible problem is found.

\begin{figure}
  \centering
  \includegraphics[width=0.4\textwidth]{trust_region_incompatible.pdf}
  \caption{Constraint incompatibility generated by trust region approach}
\label{fig:TR_incompatible}
\end{figure}

With this approach, a problem that often arises is the generation of unfeasible problems.
The reduction of the size of the trust region can lead to an incompatible set of constraints.
For example, with a single constraint, as illustrated in~\Figref{fig:TR_incompatible}.
The linearisation of the constraint is represented by the green line, and the trust region by the black rectangle.
If $\rho$ is too small, there is no intersection between the linearization of the constraint and the trust region.
The QP is then unfeasible.
An obvious solution for that would be to increase the size of the trust region, but that goes against the core idea of the trust region strategy and it would harm the convergence properties of the algorithm.
A more appropriate solution is to enter a restoration phase when that event occurs.
The purpose of a restoration phase is to reduce the unfeasibility of a problem by relaxing unfeasible constraints without regards for the cost function.
The restoration phase is exited once a feasible point is found, and the course of the SQP is continued from that point.

\subsection{Restoration phase}
\label{sub:restoration_phase}

As we stated previously, a restoration phase is entered when an unfeasible problem is found by the trust region strategy.
The goal of the restoration is to find a solution to the following problem:

\begin{equation}
    \text{Find $x\in\mathbb{R}^n$ such that }
    \left\{
    \begin{array}{l}
      c_i(x)=0,\ i\in E \\
      c_i(x)\geq 0,\ i\in I\\
      |z|<\rho_k
    \end{array}
    \right.
\label{eq:resto_NL}
\end{equation}

The restoration phase proceeds in a similar way to the original SQP algorithm described earlier.
At each step, an approximated QP is solved, then its result is compared to an acceptance criterion, if it is accepted, the trust region can be increased and the algorithm continues.
Otherwise, the trust region is reduced and the problem is solved again.
The acceptance criterion must be tailored for the restoration problem, meaning that it is based on the values of the cost function of the restoration problem and of its constraints.
The big difference comes from the way the quadratic problem is constructed during this phase.

During a restoration phase step, the first action is to estimate the sets $\mathcal{F}$ and $\mathcal{U}$ of feasible  and unfeasible constraints.
This is done by solving the linearization of problem~\Eqref{eq:resto_NL} as presented in~\Eqref{eq:FP}.
Each equality constraint is cut in 2 inequality constraints.

\begin{equation}
  \text{Find $z\in\mathbb{R}^n$ such that }
  \left\{
  \begin{array}{l}
    {\nabla c_i(x_k)}^T z+c_i(x_k)\geq 0,\ i\in E \\
    -{\nabla c_i(x_k)}^T z-c_i(x_k)\geq 0,\ i\in E \\
    {\nabla c_i(x_k)}^T z+c_i(x_k)\geq 0,\ i\in I\\
    |z|<\rho_k
  \end{array}
  \right.
\label{eq:FP}
\end{equation}

The resolution of that FP gives the lists $\mathcal{F}$ and $\mathcal{U}$.
If the list of unfeasible constraints is empty, the problem is feasible, so the restoration phase is exited to return to the main SQP algorithm.
The restoration QP to solve is built based on those lists.
The unfeasible constraints are removed from the constraint set and the expression of their violation is added to the cost function, while the feasible constraints remain in the constraint list.
This results in a problem like~\ref{rest_SQP} to solve.
(Note that the indexes of the constraints are modified to account for the duplication of the equality constraints)

\begin{equation}
  \begin{array}{ll}
    \minimize\limits_{z\in \mathbb{R}^n}{} & \frac{1}{2} z^T Hz - \sum\limits_{i\in\mathcal{U}}{\nabla c_i(x_k)}^T z \\
    \text{subject to } & {\nabla c_i(x_k)}^T z+c_i(x_k)\geq 0,\ i \in \mathcal{F} \\
                       & |z|<\rho_k
  \end{array}
\label{rest_SQP}
\end{equation}

This problem is solved by a QP solver, its result is checked against an acceptance criterion, based on that, the trust region is enlarged or reduced, and we go back to solving the FP\@.

In the restoration phase, special care must be taken in the computation of the matrix H, that represents the Hessian of the Lagrangian of a problem that changes at each iteration.
One possible approach is to compute it as the sum of the Hessians of all the individual constraints, and those can be computed exactly or with a quasi-newton approximation.

\subsection{Quasi-Newton Approximation}
\label{sub:quasi_newton_approximation}

In the SPQ algorithm, it is necessary to have access to the Hessian of the Lagrangian $\nabla_{xx}^2\mathcal{L}$ to be able to devise the QP subproblem to solve.
%For some strategies like the Line-Search, it is necessary that $\nabla_{xx}^2\mathcal{L}$ is definite positive.
Sometimes the exact Hessian of the problem is not positive definite.
Also, it is often difficult or computationally expensive to compute an exact Hessian of the Lagrangian.
Since we are following an iterative process, it is not necessary to have an exact knowledge of the Hessian and using an approximation of it is usually enough.
Also, an approximate Hessian is in most cases less expensive to compute than the exact one.

The idea behind computing an approximate Hessian is that, starting from an initial approximate Hessian $B_0$, we compute at each iteration an update to the approximate Hessian based on the values and first order derivatives of the Lagrangian.
This update aims at capturing some curvature information about the Hessian by evaluating the evolution of the gradient along the latest step.
At step $k$, the Hessian update is a function of $s_k$ and $y_k$:
\begin{equation}
  s_k = x_{k+1}-x_k,\ \ \ \
  y_k = \nabla_x\mathcal{L}(x_{k+1}, \lambda_{k+1}) - \nabla_x\mathcal{L}(x_{k}, \lambda_{k+1})
\end{equation}

The two most famous Hessian update strategies are called the BFGS (Broyden–Fletcher– Goldfarb–Shanno) and the SR1(Symmetric Rank 1) updates.
BFGS is a rank 2 update while SR1 is rank 1.

The most basic formulas for the BFGS update is the following:

\begin{equation}
\label{BFGS}
  B_{k+1} = B_k - \frac{B_k s_k s_k^T B_k}{s_k^T B_k s_k} + \frac{y_k y_k^T}{s_k^T y_k}
\end{equation}

Note that using a BFGS update requires that $s_k$ and $y_k$ satisfy the curvature condition: $s_k^T y_k>0$.
If that condition does not hold, then the value of $y_k$ is modified, which gives rise to the Damped BFGS update, which guarantees to keep $B_k$ definite positive:

\begin{equation}
\label{damped_BFGS}
\begin{split}
  \theta_k =
  \left\{
      \begin{array}{ll}
      1 & \text{if } s_k^T y_k \geq 0.2 s_k^T B_k s_k \\
      \frac{0.8 s_k^T B_k s_k}{s_k^T B_k s_k-s_k^T y_k} & \text{if } s_k^T y_k \geq 0.2s_k^T B_k s_k \\
      \end{array}
      \right.\\
      r_k = \theta_k y_k + (1-\theta_k) B_k s_k\\
      B_{k+1} = B_k-\frac{B_k s_k s_k^T B_k}{s_k^T B_k s_k} + \frac{r_k r_k^T}{s_k^T r_k}
\end{split}
\end{equation}

The SR1 update is computed with the following formula:

\begin{equation}
\label{SR1}
B_{k+1} = B_k + \frac{(y_k-B_k s_k){(y_k-B_k s_k)}^T}{{(y_k-B_k s_k)}^T s_k}
\end{equation}

Both those formulas proved to be efficient in some cases. It is not yet clear in which cases one is better than the other.

\section{Conclusion}
This section gives a general introduction to nonlinear constrained optimization without regards for specificities of robotics problem or formulations on manifolds, which are topics considered in the core of this thesis.


%%-----------List of Symbols, Nomenclature or Abbreviation--------

%% Please note: a list of Symbols, terms, acronyms, etc. is not usually the best practice.
%% More often you should simply define an abbreviation the first time it is used.
%% If you DO need to include a list like this please notice that it must be paginated manually
%% by breaking it up into page size tables. Longtable will not wrap the definition properly if
%% it extends to a second line and a similar issue is encountered when the tabbing environment
%% is used. If you have a better way of meeting the Editorial Office requirements I'd love to hear about it.

\chapter*{LIST OF SYMBOLS, NOMENCLATURE, OR ABBREVIATIONS} \addcontentsline{toc}{chapter}{LIST OF SYMBOLS} %Start
%writing here. This is optional.
\singlespacing
\begin{tabular}{l p{5in}} %if the terms in the first column are longer than 1.4 inches reduce the number 5 appropriately
$\sum$ & Denotes the summation of a series of terms\\
\\%This adds the single space between definitions (required)
$\bigcap$ & A really big bigcap\\
\\
fractal & A geometric pattern that is repeated at ever smaller
scales to produce irregular shapes and surfaces that cannot be represented by classical
geometry. Fractals are used especially in computer modeling of irregular patterns and structures in nature.}\\
\\
polynomial & (in one variable) an expression consisting of the sum of two
or more terms each of which is the product of a constant and a
variable raised to an integral power: $ax^2 + bx + c$ is a
polynomial, where $a, b,$ and $c$ are constants and $x$ is a
variable.}\\
\\
$\sum$ & Denotes the summation of a series of terms\\
\\
$\bigcap$ & A really big bigcap\\
\\
fractal & A geometric pattern that is repeated at ever smaller
scales to produce irregular shapes and surfaces that cannot be represented by classical
geometry. Fractals are used especially in computer modeling of irregular patterns and structures in nature.}\\
\\
polynomial & (in one variable) an expression consisting of the sum of two
or more terms each of which is the product of a constant and a
variable raised to an integral power: $ax^2 + bx + c$ is a
polynomial, where $a, b,$ and $c$ are constants and $x$ is a
variable.}\\
\\
$\sum$ & Denotes the summation of a series of terms\\
\\
$\bigcap$ & A really big bigcap\\
\\
fractal & A geometric pattern that is repeated at ever smaller
scales to produce irregular shapes and surfaces that cannot be represented by classical
geometry. Fractals are used especially in computer modeling of irregular patterns and structures in nature.}\\
\\
polynomial & (in one variable) an expression consisting of the sum of two
or more terms each of which is the product of a constant and a
variable raised to an integral power: $ax^2 + bx + c$ is a
polynomial, where $a, b,$ and $c$ are constants and $x$ is a
variable.}\\

\end{tabular}

\begin{tabular}{lp{5in}}
$\sum$ & Denotes the summation of a series of terms\\
\\
$\bigcap$ & A really big bigcap\\
\\
fractal & A geometric pattern that is repeated at ever smaller
scales to produce irregular shapes and surfaces that cannot be represented by classical
geometry. Fractals are used especially in computer modeling of irregular patterns and structures in nature.}\\
\\
polynomial & (in one variable) an expression consisting of the sum of two
or more terms each of which is the product of a constant and a
variable raised to an integral power: $ax^2 + bx + c$ is a
polynomial, where $a, b,$ and $c$ are constants and $x$ is a
variable.}\\
\\
$\sum$ & Denotes the summation of a series of terms\\
\\
$\bigcap$ & A really big bigcap\\
\\
fractal & A geometric pattern that is repeated at ever smaller
scales to produce irregular shapes and surfaces that cannot be represented by classical
geometry. Fractals are used especially in computer modeling of irregular patterns and structures in nature.}\\
\\
polynomial & (in one variable) an expression consisting of the sum of two
or more terms each of which is the product of a constant and a
variable raised to an integral power: $ax^2 + bx + c$ is a
polynomial, where $a, b,$ and $c$ are constants and $x$ is a
variable.}\\
\\
$\sum$ & Denotes the summation of a series of terms\\
\\
$\bigcap$ & A really big bigcap\\
\\
fractal & A geometric pattern that is repeated at ever smaller
scales to produce irregular shapes and surfaces that cannot be represented by classical
geometry. Fractals are used especially in computer modeling of irregular patterns and structures in nature.}\\
\\
polynomial & (in one variable) an expression consisting of the sum of two
or more terms each of which is the product of a constant and a
variable raised to an integral power: $ax^2 + bx + c$ is a
polynomial, where $a, b,$ and $c$ are constants and $x$ is a
variable.}\\
\\
\end{tabular}
\doublespacing


\chapter{Set Theory III}

\epigraph{No one shall expel us from the paradise that Cantor has created for us.}{David Hilbert}

I wasn't able to find many good videos on this (since this is usually something covered in functions), but it's easy. I found something entertaining about infinity from \href{https://www.youtube.com/watch?v=SrU9YDoXE88}{Vsauce} though.

Sets can have a finite or infinite number of elements. Beleive it or not, we can still determine wether or not two infinite sets have the same cardinality using the following definition.

\begin{boxdefine}{Equipotent}{}
	A {\bf one-to-one correspondence} between sets $A$ and $B$ is a pairing of each object in $A$ with one and only one object in $B$, and each object in $B$ paired with one and only one object in $A$. If such a correspondence exists, than we say $A$ and $B$ are {\bf equipotent}, or have the same cardinality.
\end{boxdefine}

\begin{boxexample}{}{}
	Suppose $A=\{1,2,3,4,\dots\}$ and $B=\{1,4,9,16,\dots\}$. We can say that the one-to-one correspondence is $a=b^2$ where $a \in A, b \in B$. Thus the two sets are equipotent, and $|A|=|B|$.
\end{boxexample}

Another good definition to know is when an set is {\bf countably infinite}. Of course you can't literally count an infinite set. But it is used to distinguish smaller infinities (countable), and larger infinities (uncountable).

\begin{boxdefine}{Countable Set}{}
	An infinite set is {\bf countable} if it is equipotent to the natural numbers.
\end{boxdefine}

\begin{boxexample}{}{}
	The odd numbers are countably infinite, and the real numbers are uncountably infinite.
\end{boxexample}

We can also determine if one infinite set is a {\bf proper subset} of another infinite set. If each member of $A$ is within $B$, but not every member of $B$ is within $A$, then $A$ is a proper subset of $B$, and $|A| < |B|$.

\begin{boxexample}{}{}
	If $A=\{2,3,4,5,\dots\}$ and $B=\{1,2,3,4,5,\dots\}$, than $A$ is a proper subset of $B$.
\end{boxexample}

\begin{boxexample}{}{}
	$\mathbb{W} \subset \mathbb{N} \subset \mathbb{Z} \subset \mathbb{Q} \subset \mathbb{R} \subset \mathbb{C}$.
\end{boxexample}

\chapter{Logic I}

\epigraph{Pure mathematics is, in its way, the poetry of logical ideas.}{Albert Einstein}

If you like watching videos, I think \href{https://www.youtube.com/watch?v=q2eyZZK-OIk&t}{Dr. Trefor Bazett} and \href{https://www.youtube.com/watch?v=wRMC-ttjhwM}{Emily S} have great videos for this.

\begin{boxdefine}{Logical Statement}{}
A {\bf logical statement} is an expression that has a definite state of being either true or false.
\end{boxdefine}

Logic is the language of mathematics. We use logic to express (and prove!) ideas to another who speaks the language. When written, we aim to leave no doubt about our meaning. Of course, logic can also used to arrive at the correct results.

\begin{boxremark*}{}{}
	A {\bf paradox} is a statement that is both true and false, but can only exist within an inconsistant system of logic (and is not considered a statement within a consistem system of logic). For example, ``This statement is false.''
\end{boxremark*}

\begin{boxexample}{}{}
	Here are some examples of logical statements
	\begin{itemize}
		\item A triangle has three sides. (a true statement)
		\item $\sqrt 2$ is a rational number. (a false statement)
		\item $\pi + 2 \leq 5$. (a true statement)
	\end{itemize}
\end{boxexample}

\begin{boxexample}{}{}
	Here are some examples of non-logical statements
	\begin{itemize}
		\item Find the smallest natural number. (instruction, not statment)
		\item Does 3=9? (question, not statement)
		\item This statement is false. (cannot be true or false)
	\end{itemize}
\end{boxexample}

\section{Logical Connectors}

This is a list of the logical connectors. They work as you would use them in English.

\medskip
\begin{tabular}{r|c|c|l}
	\hline
	Connector & Symbol & Name & Example\\
	\hline
	Not & $\neg$ & Negative & $\neg \text{False} = \text{True}$\\
	And & $\land$ & Conjunction & $\text{True} \land \text{True} = \text{True} $\\
	Or & $\lor$ & Disjunction & $\text{True} \lor \text{False} = \text{True}$\\
	Implies (If...Then) & $\implies$ & Conditional & $\text{True} \implies \text{True} = \text{True}$\\
	Iff (If and only if) & $\iff$ & Biconditional & $\text{True} \iff \text{False} = \text{False}$\\
\hline
\end{tabular}
\medskip

\begin{boxnotation*}{}{}
	It is \emph{very} uncommon to use the set operations ``$\cup$'' for OR and ``$\cap$'' for AND, but the instructor sometimes uses these. The negative is sometimes written as ``$\sim A$'' or ``$\overline A$''.
\end{boxnotation*}

Lets define how these resolve using truth tables. The first truth table we will look at is {\bf not}:

\medskip
\begin{tabular}{c|c}
	\hline
	\multicolumn{2}{c}{NOT Truth Table}\\
	\hline
	$A$ & $\neg A$\\
	\hline
	True & False\\
	False & True\\
	\hline
\end{tabular}
\medskip

\begin{boxexample}{}{}
	If $A=\text{True}$, what is $\neg A$?

	$\neg A=\text{False}$.
\end{boxexample}

Then we have the AND logical connector. Again, this works how you'd expect in english.

\medskip
\begin{tabular}{c|c|c}
	\hline
	\multicolumn{3}{c}{AND Truth Table}\\
	\hline
	$A$ & $B$ & $A \land B$\\
	\hline
	True & True & True\\
	False & True & False\\
	True & False & False\\
	False & False & False\\
	\hline
\end{tabular}
\medskip

\begin{boxexample}{}{}
	If $A=\text{True}$ and $B=\text{False}$, what is $A \land B$?

	$A \land B = \text{False}$.
\end{boxexample}

Then the OR logical connector. This one is also works how you'd expect it in english.

\medskip
\begin{tabular}{c|c|c}
	\hline
	\multicolumn{3}{c}{OR Truth Table}\\
	\hline
	$A$ & $B$ & $A \lor B$\\
	\hline
	True & True & True\\
	False & True & True\\
	True & False & True\\
	False & False & False\\
	\hline
\end{tabular}
\medskip

\begin{boxexample}{}{}
	If $A=\text{True}$ and $B=\text{False}$, what is $A \lor B$?

	$A \lor B = \text{True}$.
\end{boxexample}

Implies works a little differently. You can see implies also written as ``if...then'' statements. Pay attention to how this truth table works, this one can be confusing. I'll also give you an example of why these values make sense.

\medskip
\begin{tabular}{c|c|c}
	\hline
	\multicolumn{3}{c}{Implies Truth Table}\\
	\hline
	$A$ & $B$ & $A \implies B$\\
	\hline
	True & True & True\\
	False & True & True\\
	True & False & False\\
	False & False & True\\
	\hline
\end{tabular}
\medskip

\begin{boxexample}{}{}
	Consider this example: ``If it's raining, then I will bring an unbrella.'' That means the following statements are also true:
	\begin{itemize}
		\item It is raining, so I brought an unbrella.
		\item It is not raining, but I brought an unbrella.
		\item It is not raining, so I didn't being an unbrella.
	\end{itemize}
	But, the statement ``It is raining, but I didn't bring an unbrella'', means that I am lieing.
\end{boxexample}

\begin{boxexample}{}{}
	If $A=\text{True}$ and $B=\text{False}$, what is $A \implies B$?

	$A \implies B = \text{False}$.
\end{boxexample}

Finally, iff (or if any only if) works simularly to above, but it works both ways.

\medskip
\begin{tabular}{c|c|c}
	\hline
	\multicolumn{3}{c}{Iff Truth Table}\\
	\hline
	$A$ & $B$ & $A \iff B$\\
	\hline
	True & True & True\\
	False & True & False\\
	True & False & False\\
	False & False & True\\
	\hline
\end{tabular}
\medskip

I will use the same example as above to illistrate the difference.

\begin{boxexample}{}{}
	Consider this example: ``I will bring an unbrella if and only if it is raining.'' That means the following statements are also true:
	\begin{itemize}
		\item It is raining, so I brought an unbrella.
		\item It is not raining, so I didn't being an unbrella.
	\end{itemize}
	But the following statements mean that I am lieing:
	\begin{itemize}
		\item It is raining, but I didn't bring an unbrella.
		\item It is not raining, but I brought an umbrella.
	\end{itemize}
\end{boxexample}

\begin{boxexample}{}{}
	If $A=\text{False}$ and $B=\text{True}$, what is $A \iff B$?

	$A \iff B = \text{False}$.
\end{boxexample}

{\bf Simple statements} are single ideas. They often express compairison, like ``is'', ``equals'', ``less than'', etc. They are the \emph{nouns} of logic. {\bf Logical connectors} are the \emph{verbs} of logic, and connect simple statements togeather to form {\bf compound statements}

\begin{boxdefine}{Logical Connector, Simple \& Compound Statements}{}
	A {\bf simple statement} is a ``single idea'' statement that does not use a {\bf logical connector} like ``and'', ``or'', ``not'', ``implies'', and ``iff''.
	A {\bf compound statement} contains two or more simple statements connected by {\bf logical connectors}.
\end{boxdefine}

\begin{boxexample}{}{}
	An example of a {\bf simple statement} is: $a^2=49$. An example of a {\bf compound statement} is: if $a=7$ then $a^2=49$ (also: $a=7 \implies a^2=49$).
\end{boxexample}

Two important definitions for creating logical statements are {\bf tautologies}, and {\bf contradictions}.

\begin{boxdefine}{Tautology and Contradictions}{}
	A {\bf tautology} is a statement that is always true. A {\bf contradiction} is a statement that is always false.
\end{boxdefine}

\section{Applications of Truth Tables}

\begin{boxdefine}{Logical Equivalence}{}
	If two statements $P$ and $Q$ have the same truth values, they are {\bf equivalent} denoted as $P \iff Q$.
\end{boxdefine}

So suppose we have two statements and we want to see if they're equivalent. One way to do this would be to try every single True/False combination and see if the statements evaluate to the same value.

\begin{boxexample}{}{}
	Are the statements $\neg (A \lor B)$ and $\neg A \land \neg B$ equal?

	\medskip
	\newcolumntype{g}{>{\columncolor{skyblue}}c}
	\begin{tabular}{g|g|c|c|c|g|g}
		\hline
		$A$ & $B$ & $\neg A$ & $\neg B$ & $A \lor B$ & $\neg (A \lor B)$ & $\neg A \land \neg B$\\
		\hline
		F & F & T & T & F & T & T\\
		F & T & T & F & T & F & F\\
		T & F & F & T & T & F & F\\
		T & T & F & F & T & F & F\\
		\hline
	\end{tabular}
	\medskip

	And, we see that $\neg (A \lor B) = \neg A \land \neg B$.
\end{boxexample}

Now lets try a harder one.

\begin{boxexample}{}{}
	Are the statements $\neg P \land (Q \lor R)$ and $(\neg Q \lor P) \land (Q \lor \neg R)$ equal?

	\medskip
	\begin{tabular}{r|c c c c c c c c}
		\hline
		\rowcolor{skyblue}
		$P$ & F & T & F & T & F & T & F & T\\
		\rowcolor{skyblue}
		$Q$ & F & F & T & T & F & F & T & T\\
		\rowcolor{skyblue}
		$R$ & F & F & F & F & T & T & T & T\\
		$\neg P$ & T & F & T & F & T & F & T & F\\
		$\neg Q$ & T & T & F & F & T & T & F & F\\
		$\neg R$ & T & T & T & T & F & F & F & F\\
		$Q \lor R$ & F & F & T & T & T & T & T & T\\
		\rowcolor{skyblue}
		$\neg P \land (Q \lor R)$ & F & F & T & F & T & F & T & F\\
		$\neg Q \lor P$ & T & T & F & T & T & T & F & T\\
		$Q \lor \neg R$ & T & T & T & T & F & F & T & T\\
		\rowcolor{skyblue}
		$(\neg Q \lor P) \land (Q \lor \neg R)$ & T & T & F & T & F & F & F & T\\
		\hline
	\end{tabular}
	\medskip

	Imagine that, the two expressions I made up aren't equal!
\end{boxexample}


\section{Summary and Conclusions}
\label{sec:conclusions}

We have developed a realizability-preserving DG-IMEX scheme for a two-moment model of fermion transport.
The scheme employs algebraic closures based on Fermi-Dirac statistics and combines a time step restriction (CFL condition), a realizability-enforcing limiter, and a convex-invariant time integrator to maintain point-wise realizability of the moments.
Since the realizable domain is a convex set, the realizability-preserving property is obtained from convexity arguments, building on the framework in \cite{zhangShu_2010a}.

In the applications motivating this work, the collision term is stiff in regions of the computational domain, and we have considered IMEX schemes to avoid treating the transport operator implicitly.
We have considered two recently proposed second-order accurate, convex-invariant IMEX schemes \cite{chertock_etal_2015,hu_etal_2018}, that restore second-order accuracy with an implicit correction step.
However, we are unable to prove realizability (without invoking a very small time step) with the approach in \cite{chertock_etal_2015}, and we have demonstrated that the approach in \cite{hu_etal_2018} does not perform well in the diffusion limit.
For these reasons, we have resorted to first-order, convex-invariant IMEX schemes.
While the proposed scheme (dubbed PD-ARS) is formally only first-order accurate, it works well in the diffusion limit, is convex-invariant with a reasonable time step, and reduces to the optimal second-order accurate explicit SSP-RK scheme in the streaming limit.

For each stage of the IMEX scheme, the update of the cell-averaged moments can be written as a convex combination of forward Euler steps (implying the Shu-Osher form for the explicit part), followed by a backward Euler step.
Realizability of the cell-averaged moments due to the explicit part requires the DG solution to be realizable in a finite number of quadrature points in each element and the time step to satisfy a CFL condition.
For the backward Euler step, realizability of the cell-averages follows easily from the simple form of the collision operator (which includes emission, absorption, and isotropic scattering without energy exchange), and is independent of the time step.
The CFL condition is then solely due to the transport operator, and the time step can be as large as that of the forward Euler scheme applied to the explicit part of the cell-average update.
After each stage update, the limiter enforces moment realizability point-wise by damping towards the realizable cell average.
Numerical experiments are presented to demonstrate the accuracy and realizability-preserving property of the DG-IMEX scheme.
The applicability of the PD-ARS scheme is not restricted to the fermionic two-moment model.
It may therefore be a useful option in other applications of kinetic theory where physical constraints confine solutions to a convex set and capturing the diffusion limit is important.

Realizability of the fermionic two-moment model depends sensitively on the closure procedure.
For the algebraic closures adapted in this work, realizability of the scheme demands that lower and upper bounds on the Eddington factor are satisfied \cite{levermore_1984,lareckiBanach_2011}.
The Eddington factors deriving from the maximum entropy closures of Cernohorsky \& Bludman \cite{cernohorskyBludman_1994} and Larecki \& Banach \cite{lareckiBanach_2011}, and the Kershaw-type closure of Larecki \& Banach \cite{banachLarecki_2017a} all satisfy these bounds and are suitable for the fermionic two-moment model.
Further approximations of the closure procedure (e.g., employing the low occupancy limit, which results in the Minerbo closure \cite{minerbo_1978} when starting with the maximum entropy closure of \cite{cernohorskyBludman_1994}) is not compatible with realizability of the fermionic two-moment model, and we caution against this approach to modeling particle systems governed by Fermi-Dirac statistics; particularly if the low occupancy approximation is unlikely to hold (e.g., when modeling neutrino transport in core-collapse supernovae).

In this work, we started with a relatively simple kinetic model.
In particular, we adopted Cartesian coordinates, and assumed a linear collision operator and a fixed material background.
Scattering with energy exchange and relativistic effects (e.g., due to a moving material and the presence of a strong gravitational field) were not included.
To solve more realistic problems of scientific interest, some or all of these physical effects will have to be included.
In the context of developing realizability-preserving schemes, these extensions will provide significant challenges suitable for future investigations, for which the scheme presented here may serve as a foundation.


\chapter{Quantum Computing Overview }
\graphicspath{ {./images/} }

\[ \boxed {\mbox{i\textbf{h}}\dfrac{\partial}{\partial t}|\psi(t)\rangle = \bm{\hat{\textnormal{\bfseries H}}} |\psi(t)\rangle }
\]

Quantum Computing \cite{QCQI} is doing computation using quantum-mechanical phenomena like superposition and entanglement. A Quantum computer performs such computing and is very different from a classical computer that depends on digital logics and transistors. Quantum computation uses Quantum bits also called \textit{Qubits} which align in different ways to produce variations of not just 1 or 0 (as in classical computing) but many others. An approximation based on probability of outcome which depends on solving governing physics equations, theoretically allows us to construct subsequent logic of state or data changes.\\

A Quantum Turing Machine is theoretical accepted model of quantum computer which has been made possible by the initial works of \textbf{Richard Feynman}, \textbf{David Deutsch}  and \textbf{Yuri Manin}. The actual implemtation model of the quantum computer however is still in a very basic phase because of very absurd Temperature-Pressure conditions required to maintain a very less stable qubit state. The current research in quantum computing hardware focuses on precisely maintaining qubit's state and reducing data loss during state transition. The implementational software aspect of quantum computer is explored even smaller much because of less compatible quantum hardware and the inability of classical computers to simulate large qubit quantum computer.\\

\section{Qubits}
Quantum bits or Qubits are quantum version of classical binary bit. It is the basic unit of quantum information. Unlike the classical bits the Qubit can maintain information in unique states or in a superposition of states or may be  entangled states. The possiblity of having so many states improves the parallelism of data computaion and hence speed. A very good example is often potrayed by finding the card in which given 4 cards with one card different, we need to find the odd one out. The classical computer takes a maximum of 4 steps but a quantum computer will take always only 1 step to figure it out.

\subsection{Representation}
Quantum State refers to the state of isolated quantum system. It gives a basic idea of possibility of different observable outcomes. A Qubit state can be represented by conventional "Dirac" or "bra-ket" notation, written as $|0\rangle$ or $|0\rangle$ and read as "ket-0" or "ket-1". two orthonormal \textit{Basis States} \{ $|0\rangle$ , $|1\rangle$ \} form 2-D linear vector space of qubit. Qubit basis states combine together to form \textit{Product Basis Space} like,

\[ |00\rangle = \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix} \quad \\
   |01\rangle = \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix} \quad \\
   |10\rangle = \begin{bmatrix} 0 \\ 0 \\ 1 \\ 0 \end{bmatrix} \quad \\
   |11\rangle = \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix} \quad \\
\]

A pure qubit state is a coherent superposition of the basis states. This means that a single qubit can be described by a linear combination of $|0\rangle$ \& $|1\rangle$.

\[|\psi\rangle = \alpha|0\rangle \quad +\quad \beta|1\rangle\]

with condition that

\[\alpha^2 + \beta^2 = 1\ \cdots (i) \].

The probabilities of finding states of values $|0\rangle$ \& $|1\rangle$ is proportional to $|\alpha|^2$ and $|\beta|^2$ respectively.\\

The other type of representation is called \textbf{Bloch Sphere Representation} in which $\alpha$ and $\beta$ are considered as complex numbers with two degrees of freedom and a normalization constraint of equation (i).

\begin{figure}[!htb]
\centering
  \includegraphics[scale=0.5]{bloch}
  \caption{Bloch Sphere Representation of a Qubit (source : The Quantum Computing \& Quantum Information book)}
\end{figure}

\[\alpha =  e^{i\psi}cos\dfrac{\theta}{2} \quad \& \quad \beta = e^{i(\psi + \phi)}sin\dfrac{\theta}{2} \].

\subsection{Quantum Superposition}
Superposition is essentially the ability of a quantum system to be in multiple states at the same time — that is, something can be “here” and “there,” or “up” and “down” at the same time.

\subsection{Quantum Entanglement}
It is a physical phenomena which that is said to occur when pairs or groups of particles are generated or they interact or share same spatial proximity such that behaviour of any one of the particles can not be defined independently of the state of others. Entanglement is an extremely strong correlation that exists between quantum particles — so strong, in fact, that two or more quantum particles can be inextricably linked in perfect unison, even if separated by great distances. The particles remain perfectly correlated even if separated by great distances. The particles are so intrinsically connected, they can be said to “dance” in instantaneous, perfect unison, even when placed at opposite ends of the universe. This seemingly impossible connection inspired Einstein to describe entanglement as "\underline{spooky action at a distance}".

\section{Quantum Gates \& Circuits}
A quantum gate or quantum logic gate is a rudimentary quantum circuit operating on a small number of qubits. They are the analogues for quantum computers to classical logic gates for conventional digital computers. \underline{Quantum logic gates are reversible}, unlike many classical logic gates. Some universal classical logic gates, such as the Toffoli gate, provide reversibility and can be directly mapped onto quantum logic gates. Quantum logic gates are represented by unitary matrices. The action of the gate on a specific quantum state is found by multiplying the vector which represents the state by the matrix representing the gate.\\

\begin{figure}[!htb]
\centering
  \includegraphics[scale=0.4]{qgates}
  \caption{Some common Quantum Logic gates (source: wikipedia)}
\end{figure}

A \textbf{Quantum Circuit} is an ordered logical combination of quantum gates and some initial Qubits. The quantum circuits are reversible transformations on a quantum mechanical analog of an n-bit register. It is very important for any logic circuit to be reversible to return n bit data output for a n bit data input. In other words the reversible logic gates are bijective mappings from a n bit data set to itself. \textbf{Kitaev} mentioned that irreversible circuits increase the physical entropy of the system. Theoretical advancements showed that \textbf{Toffoli Gate} is a Universal reversible Gate. this basically mean that we can easily consruct a large sizes circuit by simply adding more gates (Toffoli gates as example here) to it.

\begin{figure}[!htb]
\centering
  \includegraphics{qcircuit}
  \caption{An example of a quantum circuit (source : The Quantum Computing \& Quantum Information book) }
\end{figure}

\subsection{Error Correction}
Error Corection is very important for scalibility of a quantum computer. An error correction of $10^{-2}$ means we can add atmost 100 logic gates before running into complete mess and even destroying the qubit chip. Research going on is trying to reduce this error correction to as low as possible.


\subsection{Bonus: Noether's Theorem}
If a system of differential equations admits a (translational, rotational, etc.) symmetry, then something is conserved.
It is a very pure theorem but has significant physical meanings.
So the conservation laws in mathematical physics arises naturally from the time independence, spacial independence or directional independence of a physical law.
People who are interested can consult the book \textit{Applications of Lie Groups to Differential Equations} by Peter Oliver.


% Created: Enze Chen, June 2017
% Last edited: Enze Chen, February 2018
%
% Appendix C of the MSE 142 coursereader. This chapter steps through some of the trickier derivations that were left out of the main body for clarity. Also a place for Enze to jot notes down.

% Uncomment the following three lines and last line to individually compile this chapter
%\documentclass[12pt, english]{book}
%\usepackage{142crstyle}
%\begin{document}

\chapter{Derivations} \label{ch:deriv}
\section{Tunneling probability}  \label{sec:tunnel-deriv}
In Section~\ref{sec:tunnel-barrier}, we derived the tunneling probability for the finite potential barrier, but left out the more tedious steps. Here, we will derive the tunneling probability in its entirety for the case $E < V_0$. \par

To start, recall that we have the following three wave function solutions:
\begin{align}
\Psi_{\text{I}} &= Ae^{ikx} + Be^{-ikx} \label{der:twf-1} \\
\Psi_{\text{II}} &= Ce^{k'x} + De^{-k'x} \label{der:twf-2} \\
\Psi_{\text{III}} &= Fe^{ikx} \label{der:twf-3}
\end{align}

By the continuity of the wave function and its first derivative at $x=0$, we can use Equation~\ref{der:twf-1} and~\ref{der:twf-2} to obtain
\begin{align}
	A + B &= C + D \label{der:tb-1} \\
	A - B &= (C - D)\frac{k'}{ik} \label{der:tb-2}
\end{align}

Similarly, we can use Equation~\ref{der:twf-2} and~\ref{der:twf-3} to obtain two more equations thanks to the continuity condition at $x=L$.
\begin{align}
	Ce^{k'L} + De^{k'L} &= Fe^{ikL} \label{der:tb-3} \\
	Ce^{k'L} - De^{k'L} &= Fe^{ikL}\frac{ik}{k'} \label{der:tb-4}
\end{align}

Now we add Equation~\ref{der:tb-1} and~\ref{der:tb-2} to eliminate $B$ as follows.
\begin{align}
	2A &= C \left(1 + \frac{k'}{ik}\right) + D\left(1 - \frac{k'}{ik}\right) \nonumber \\
	&= C \left(1 - \frac{ik'}{k}\right) + D\left(1 + \frac{ik'}{k}\right) \label{der:ta}
\end{align}

Next, we add and subtract Equation~\ref{der:tb-3} and~\ref{der:tb-4} to isolate $C$ and $D$:
\begin{align}
	\text{Add:}\quad 2Ce^{k'L} &= F \left(1 + \frac{ik}{k'}\right)e^{ikL} \nonumber \\
	C &= \frac{F}{2}\left(1 + \frac{ik}{k'}\right)e^{ikL}e^{-k'L} \label{der:tc} \\
	\text{Subtract:}\quad 2De^{-k'L} &= F \left(1 - \frac{ik}{k'}\right)e^{ikL} \nonumber \\
	D &= \frac{F}{2} \left(1 - \frac{ik}{k'}\right)e^{ikL}e^{k'L} \label{der:td}
\end{align}

This allows us to plug Equation~\ref{der:tc} and~\ref{der:td} into Equation~\ref{der:ta} to obtain
\begin{align*}
	2A &= C \left(1 - \frac{ik'}{k}\right) + D  \\
	2A &= \frac{F}{2}\left(1 - \frac{ik'}{k}\right)\left(1 + \frac{ik}{k'}\right)e^{ikL}e^{-k'L} + \frac{F}{2} \left(1 + \frac{ik'}{k}\right)\left(1 - \frac{ik}{k'}\right)e^{ikL}e^{k'L} \\
	4Akk' &= F(k-ik')(k'+ik)e^{ikL}e^{-k'L} + F(k+ik')(k'-ik)e^{ikL}e^{k'L} \\
	4Aikk' &= F(ik-i^2k')(k'+ik)e^{ikL}e^{-k'L} + F(ik+i^2k')(k'-ik)e^{ikL}e^{k'L} \\
	4Aikk' &= F(ik+k')(k'+ik)e^{ikL}e^{-k'L} + F(ik-k')(k'-ik)e^{ikL}e^{k'L} \\
	4Aikk' &= F(ik+k')^2e^{ikL}e^{-k'L} - F(ik-k')^2e^{ikL}e^{k'L} \\
	4Aikk'e^{-ikL} &= F \left[(ik+k')^2e^{-k'L} - (ik-k')^2e^{k'L}\right] \numberthis \label{der:taf}
\end{align*}

which is how we arrived at Equation~\ref{eq:tunnel-fa} in Section~\ref{sec:tunnel-barrier}. To solve for the tunneling probability $T = \abs{\frac{F}{A}}^2$, we'll actually solve for $\abs{\frac{A}{F}}^2$ first using Equation~\ref{der:taf} and then invert the result.
\begin{align*}
	4Aikk'e^{-ikL} &= F \left[(ik+k')^2e^{-k'L} - (ik-k')^2e^{k'L}\right] \\
	\frac{Ae^{-ikL}}{F} &= \frac{(ik+k')^2e^{-k'L} - (ik-k')^2e^{k'L}}{4ikk'} \\
	\frac{Ae^{-ikL}}{F} &= \frac{(k^{\prime 2}-k^2 + 2ikk')e^{-k'L} - (k^{\prime 2} - k^2 - 2ikk')e^{k'L}}{4ikk'} \\
	\frac{Ae^{-ikL}}{F} &= \frac{2ikk'e^{-k'L} - (-2ikk'e^{k'L}) + (k^{\prime 2}-k^2)e^{-k'L} - (k^{\prime 2} - k^2)e^{k'L}}{4ikk'} \\
	\frac{Ae^{-ikL}}{F} &= \frac{e^{-k'L} + e^{k'L}}{2} + \frac{k^{\prime 2}-k^2}{2kk'}\frac{e^{k'L} - e^{-k'L}}{2}i \\
	\frac{Ae^{-ikL}}{F} &= \cosh(k'L) + \left(\frac{k^{\prime 2}-k^2}{2kk'}\right)i\sinh(k'L) \\
	\abs{\frac{Ae^{-ikL}}{F}}^2 &= \abs{\cosh(k'L) + \left(\frac{k^{\prime 2}-k^2}{2kk'}\right)i\sinh(k'L)}^2 \\
	\abs{\frac{A}{F}}^2 &= \cosh^2(k'L) + \left(\frac{k^{\prime 2}-k^2}{2kk'}\right)^2\sinh^2(k'L) \\
	\abs{\frac{A}{F}}^2 &= 1 + \sinh^2(k'L) + \left(\frac{k^{\prime 2}-k^2}{2kk'}\right)^2\sinh^2(k'L) \\
	\abs{\frac{A}{F}}^2 &= 1 + \left[ \frac{(2kk')^2}{(2kk')^2} + \left(\frac{k^{\prime 2}-k^2}{2kk'}\right)^2\right]\sinh^2(k'L) \\
	\abs{\frac{A}{F}}^2 &= 1 + \left(\frac{k^{\prime 2}+k^2}{2kk'}\right)^2\sinh^2(k'L)
\end{align*}

Inverting this gives us our final result,
\begin{equation}
	T = \abs{\frac{F}{A}}^2  = \frac{1}{1 + \left(\frac{k^2+k^{\prime 2}}{2kk'}\right)^2 \sinh^2(k'L)}
\end{equation}
which matches what we claimed in Equation~\ref{eq:tunnel-prob-full}.

\section{Casimir Force} \label{sec:casimir-deriv}
We already showed in Chapter~\ref{ch:qft} that the energy on the outside of two conducting plates is given by
\begin{equation}
	E_{\text{out}} = \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \frac{1}{s^2}  \label{eq:casimir-out-app}
\end{equation}

Here we will walk through the derivation for $E_{\text{in}}$ as the quantum confinement makes the math a little more tricky. Just as we did in the derivation for $E_{\text{out}}$, we will also apply regularization to the expression we obtained for $E_{\text{in}}$. Starting from the summation, we proceed as follows:

\begin{align*}
E_{\text{in}} &= \frac{\hbar \pi c}{2d} \sum_{n=1}^{\infty} n \\
&= \frac{\hbar \pi c}{2d} \sum_{n=0}^{\infty} n \tag{adding 0 doesn't matter} \\
&= \frac{\hbar \pi c}{2d} \sum_{n=0}^{\infty} \lim\limits_{s \rightarrow 0} ne^{-sn} \tag{regularization} \\
&= \frac{\hbar \pi c}{2d} \sum_{n=0}^{\infty} \dv{s} \int \lim\limits_{s \rightarrow 0} ne^{-sn} \dd{s} \\
&= \frac{\hbar \pi c}{2d} \left( - \lim\limits_{s \rightarrow 0} \dv{s} \sum_{n=0}^{\infty} e^{-sn} \right)
\end{align*}

In the last line we evaluate the integral with respect to $s$ first and then swap the order of the derivative and summation since they are both linear operators. We then expand the summation as follows:

\begin{align*}
E_{\text{in}} &= \frac{\hbar \pi c}{2d} \left( - \lim\limits_{s \rightarrow 0} \dv{s} \sum_{n=0}^{\infty} e^{-sn} \right) \\
&= \frac{\hbar \pi c}{2d} \left( - \lim\limits_{s \rightarrow 0} \dv{s} \left[ 1 + e^{-s} + e^{-2s} + \cdots \right] \right) \\
&= \frac{\hbar \pi c}{2d} \left( - \lim\limits_{s \rightarrow 0} \dv{s} \frac{1}{1-e^{-s}} \right)
\end{align*}

In the last line above we used the formula for the sum of an infinite geometric series:
\begin{equation*}
	a + ar + ar^2 + ar^3 + \cdots = \frac{a}{1-r}\quad \abs{r} < 1
\end{equation*}

Now we can evaluate the derivative to obtain
\begin{align*}
E_{\text{in}} &= \frac{\hbar \pi c}{2d} \left( - \lim\limits_{s \rightarrow 0} \dv{s} \frac{1}{1-e^{-s}} \right) \\
&= \frac{\hbar \pi c}{2d} \left( \lim\limits_{s \rightarrow 0} \frac{1}{(1-e^{-s})^2} \cdot \dv{s} (1-e^{-s}) \right) \\
&= \frac{\hbar \pi c}{2d} \left( \lim\limits_{s \rightarrow 0} \frac{e^{-s}}{(1-e^{-s})^2} \right) \\
&= \frac{\hbar \pi c}{2d} \left( \lim\limits_{s \rightarrow 0} \frac{e^{-s}}{(1-e^{-s})^2} \cdot \frac{e^{2s}}{e^{2s}} \right) \\
&= \frac{\hbar \pi c}{2d} \left( \lim\limits_{s \rightarrow 0} \frac{e^{s}}{[e^s(1-e^{-s})]^2} \right) \\
&= \frac{\hbar \pi c}{2d} \left( \lim\limits_{s \rightarrow 0} \frac{e^{s}}{(e^s-1)^2} \right)
\end{align*}

Now if we rewrite the last line using the Taylor series expansion around $s=0$, we get
\begin{align*}
E_{\text{in}} &= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \left( \frac{1 + s + s^2/2 + s^3/6 + \cdots}{(s + s^2/2 + s^3/6 + \cdots)^2} \right) \\
&= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \left( \frac{1 + s + s^2/2 + s^3/6 + \cdots}{s^2 (1 + s/2 + s^2/6 + \cdots)^2} \right) \\
&= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \left( \frac{1 + s + s^2/2 + s^3/6 + \cdots}{s^2 (1 + s + 7s^2/12 + 3s^3/12 + \cdots )} \right)
\end{align*}

Here we employ a clever factorization of the bottom sum as follows:
\begin{align*}
	1 + s + \frac{7s^2}{12} + \frac{3s^3}{12} + \cdots &= \left( 1 + s + \frac{6s^2}{12} + \frac{2s^3}{12} + \cdots \right) + \left( \frac{s^2}{12} + \frac{s^3}{12} + \cdots \right) + \cdots \\
	&= \left( 1 + s + \frac{s^2}{2} + \frac{s^3}{6} + \cdots \right) + \frac{1}{12}s^2 \bigg( 1 + s + \cdots \bigg) + \cdots \\
\end{align*}

Now the large sum has been divided into separate chunks that each contain a multiple of the numerator! I used ellipses here for brevity, but if you fully expand the Taylor series you will find that this pattern continues ad infinitum. This means we can take our previous expression for $E_{\text{in}}$ and divide through by the numerator to obtain:
\begin{align*}
	E_{\text{in}} &= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \left( \frac{\overbrace{1 + s + s^2/2 + s^3/6 + \cdots}^{\phi}}{s^2 (1 + s + 7s^2/12 + 3s^3/12 + \cdots )} \right) \\
	&= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \left( \frac{\phi}{s^2 (\phi + \phi \cdot s^2/12 - \phi \cdot s^4/240 + \cdots)} \right) \\
	&= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \left( \frac{1}{s^2 \left(1 + s^2/12 - s^4/240 + \cdots \right)} \right) \\
	&= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \bigg( s^{-2} \left(1 + \frac{s^2}{12} + \mathcal{O}(s^4) \right)^{-1}  \bigg)
\end{align*}

Finally, we use the approximation
\begin{equation*}
	(1 \pm k)^p \approx 1 \pm pk + \frac{p(p-1)}{2} k^2 + \cdots \quad \text{for small } k
\end{equation*}

in order to obtain the final result
\begin{align*}
E_{\text{in}} &= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \left( \frac{1}{s^2} \left(1 - \frac{s^2}{12} + \mathcal{O}(s^4) \right) \right) \\
&= \frac{\hbar \pi c}{2d} \lim\limits_{s \rightarrow 0} \left( \frac{1}{s^2} - \frac{1}{12} + \mathcal{O}(s^2) \right) \numberthis
\end{align*}
%\tag{$(1 \pm u)^p \approx 1 \pm pu$ for small $u$} \right)
which matches our expression in Equation~\ref{eq:casimir-in2}.

%\end{document}


\subsection{Verification of the Parameter Estimation Module}

Using a PSO algorithm followed by an LMA optimization, the Drucker-Prager plasticity model with ductile damage is then fitted to the homogenized DEM simulation data in order to obtain an optimal parameter set. Each simulation is fit to 50 points defining the homogenized stress-strain curve resulting in a total of 200 data points for all four DEM simulations at different confining stresses. The PSO algorithm uses a swarm size of 24 for 100 generations which is found to be sufficient to converge to a consistent solution.

Here, the CDM model is confined laterally by the homogenized horizontal DEM stress and vertical displacements are prescribed by the homogenized vertical DEM strain with the parameter estimation algorithms programmed to match the horizontal strain and the veritcal stress. Because of the large variation in observation magnitudes (between stress/strain and from different confining stresses), each curve is weighted with a normalization factor to prevent the large stress values from dominating parameter estimation. In addition, a linear weighting scheme is applied to each curve to give larger influence to the loading section and lesser influence to the post-damage section.

Parameter bounding limits are required by the optimization algorithms in order to limit the search space in these optimization algorithms. These limits are chosen based on two criteria: physical limitations and numerical stability. If there exist physical limitations that prevent parameters from exceeding certain values or if there exists a range of realistic values that the parameter should not deviate from, then those physical limitations are specified as the bounds. In other cases, the parameter bounds come from numerical limitations such that beyond a certain capacity, certain parameter values would cause the simulations to become unstable. In these cases, a combination of the two bounding methods is used. The specified bounding limits for each parameter results can be seen in Table \ref{tab:paramDrucker}.

\begin{table}[!htbp]
\centering
\caption{Parameter Estimation Results for Drucker-Prager Model with Ductile Damage}
\label{tab:paramDrucker}
\begin{tabular}{@{}cccccc@{}}
\toprule
\textbf{Parameter}                 & \textbf{Symbol}                  & \textbf{Units} & \textbf{\begin{tabular}[c]{@{}c@{}}Lower \\ Bound\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Upper \\ Bound\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Optimal \\ Value\end{tabular}} \\ \midrule
Young's Modulus                    & $E$                              & $GPa$          & $1$                                                             & $25$                                                            & $1.8$                                                             \\
Poisson's Ratio                    & $\nu$                            &                & $0.1$                                                           & $0.4$                                                           & $0.15$                                                            \\
Dilation Angle                     & $\psi$                           & $^{\circ}$     & $5$                                                             & $15$                                                            & $22$                                                              \\
Flow Stress Ratio                  & $K$                              &                & $0.78$                                                          & $1$                                                             & $0.81$                                                            \\
Friction Angle                     & $\beta$                          & $^{\circ}$     & $45$                                                            & $60$                                                            & $56$                                                              \\
Initial Compressive Yield Strength & $\sigma_c^{iy}$                  & $kPa$          & $1$                                                             & $100$                                                           & $52$                                                              \\
Peak Compressive Yield Strength    & $\sigma_c^{p}$                   & $MPa$          & $0.5$                                                           & $5$                                                             & $3.1$                                                             \\
Strain at Peak Compressive Yield   & $\epsilon_c^{p}$                 & $\%$           & $0.5$                                                           & $5$                                                             & $1.7$                                                             \\
Yield Strain at -0.5 Triaxiality   & $\bar{\epsilon}^{pl}_{f_{-0.5}}$ & $\%$           & $0.01$                                                          & $0.1$                                                           & $0.0078$                                                          \\
Yield Strain at -0.6 Triaxiality   & $\bar{\epsilon}^{pl}_{f_{-0.6}}$ & $\%$           & $0.1$                                                           & $10$                                                            & $0.30$                                                            \\
Plastic Displacement at Failure    & $\bar{u}^{pl}_f$                 & $m$            & $0.01$                                                          & $1$                                                             & $0.12$                                                            \\ \bottomrule
\end{tabular}
\end{table}

The stress-strain curves from the DEM simulations used for the parameter estimation and the stress-strain curves of the CDM simulations using the optimal parameter set are presented in Figure \ref{fig:fitted1}. The CDM fit is good with a Root-Mean-Square Error (RMSE) of $1.03MPa$ and the pressure dependent yield function works well with this model as the error is not biased to curves of a certain confining stress. This fit implies a strong likelihood that the model will be valid under confining stresses outside of the range fitted. Also, the damage initiation points at the peak of the curve are well correlated and indicate that the triaxiality based damage initiation criterion is a good model for this problem. The majority of the error in the curves is found in the post-yield behaviour. This error results from limitations in the continuum constitutive model because the post-yield behaviour of the DEM simulations is discontinuous in nature (stick-slip response). The CDM model cannot accommodate for such oscillations and thus represents the post-yield response as an average.