\clearemptydoublepage
\chapter{Theory}
\label{cha:theory}

\section{Basis Functions and Interpolation}
\label{sec:basisfunctions}

Both the finite element method (FEM) and the boundary element method (BEM) use
interpolation in finding a field solution \ie the methods find the solution at
a number of points in the domain of interest and then approximate the solution
between these points using interpolation. The points at which the solution is
found are known as \emph{nodes}. \emph{Basis functions} are used to
interpolate the field between nodes within a subregion of the domain known as
an \emph{element}. Interpolation is achieved by mapping the field coordinate
onto a \emph{local parametric}, or $\xi$, coordinate (which varies from $0$ to
$1$) within each element. The global nodes which make up each element are also
mapped onto local element nodes and the basis functions are chosen (in terms
of polynomials of the local parametric coordinate) such that the interpolated
field is equal to the known nodal values at each node and is thus continuous
between elements. A schematic of this
scheme is shown in \figref{fig:nodesandelements}.

\epstexfigure{svgs/Theory/nodesandelements.eps_tex}{A schematic of the
  relationship between local and global nodes, elements and the parametric
  elemental $\xi$ coordinate.} {A schematic of the relationship between local
  and global nodes, elements and the parametric elemental $\xi$
  coordinate.}{fig:nodesandelements}{0.3}

\subsection{Summation Notation}
\label{subsec:summation notation}

The following (Einstein) summation notation will be used throughout these notes. In order to
eliminate summation symbols repeated ``dummy'' indices will be used \ie
\begin{equation}
  \gsum{i=1}{n}{a^{i}b_{i}}=a^{i}b_{i}
\end{equation}

To indicate an index that is not summed, parentheses will be used
\ie $a^{(i)}b_{(i)}$ is talking about the singular expression for $i$ \eg
$a^{1}b_{1}$, $a^{2}b_{2}$ \etc

In order to indicate a summation the sum must occur over indices that are
different sub/super-script \ie the sum must be over an ``upper'' and a
``lower'' index or a ``lower'' and an ``upper'' index. Note that it may be
useful to remember that if an index appears in the denominator of a fractional
expression then the index upper- or lower- ness is ``reversed''.

For some quantities with both upper and lower indices a dot will be used to
indicate the ``second'' index \eg in the expression $A^{i}_{.j}$ then $i$ can
be considered the first index and $j$ the second index.

\subsection{Lagrangian Basis Functions}
\label{sec:lagrangebasisfunctions}

One important family of basis functions are the Lagrange basis functions. This
family has one basis function for each of the local element nodes and are
defined such that, at a particular node, only one basis function is non-zero
and has the value of one. In this sense a basis function can be thought of as
being associated with a local node and serves to weight the interpolated
solution in terms of the field value at that node. Lagrange basis functions
hence provide only $C^{0}$ continuity of the field variable across element
boundaries.

\subsubsection{Linear Lagrange basis functions}

The simplest basis functions of the Lagrange family are the \onedal linear
Lagrange basis functions. These basis functions involve two local nodes and
are defined as
\begin{equation}
  \begin{split}
    \lbfn{1}{\xi}&=1-\xi \\
    \lbfn{2}{\xi}&=\xi
  \end{split}
  \label{eqn:linearlbfuns}
\end{equation}

The two \onedal linear Lagrange basis functions are gshown in \figref{fig:linlagrangebfuns}.

\pstexfigure{plots/Theory/linlagrangebfuns.pstex}{Linear Lagrange basis functions.}
{Linear Lagrange basis functions.}{fig:linlagrangebfuns}

The interpolation of a field variable, $u$, using these basis functions is
given by
\begin{equation}
  \begin{split}
    \fnof{u}{\xi}&=\lbfn{1}{\xi}\nodept{u}{1}+\lbfn{2}{\xi}\nodept{u}{2} \\
    &=\pbrac{1-\xi}\nodept{u}{1}+\xi\nodept{u}{2}
  \end{split}
\end{equation}
where $\nodept{u}{1}$ and $\nodept{u}{2}$ are the values of the field variable at
the first and second local nodes respectively. These basis functions hence
provide a linear variation between the local nodal values with the local
element coordinate, $\xi$.

\subsubsection{Quadratic Lagrange basis functions}

Lagrange basis functions can also be used to provide higher order variations,
for example the one-dimensional quadratic Lagrange basis functions involve
three local nodes and can provide a quadratic variation of field parameter
with $\xi$. They are defined as
\begin{equation}
  \begin{split}
    \lbfn{1}{\xi}&=2\pbrac{\xi-\frac12}\pbrac{\xi-1} \\
    \lbfn{2}{\xi}&=4\xi\pbrac{1-\xi} \\
    \lbfn{3}{\xi}&=2\xi\pbrac{\xi-\frac12}
  \end{split}
  \label{eqn:quadraticlbfuns}
\end{equation}

The three \onedal quadratic Lagrange basis functions are shown in \figref{fig:quadlagrangebfuns}.

\pstexfigure{plots/Theory/quadlagrangebfuns.pstex}{Quadratic Lagrange basis functions.}
{Quadratic Lagrange basis functions.}{fig:quadlagrangebfuns}

The interpolation formula is
\begin{equation}
  \begin{split}
    \fnof{u}{\xi}&=\lbfn{1}{\xi}\nodept{u}{1}+\lbfn{2}{\xi}\nodept{u}{2}+
    \lbfn{3}{\xi}\nodept{u}{3}\\
    &=2\pbrac{\xi-\frac12}\pbrac{\xi-1}\nodept{u}{1}+
    4\xi\pbrac{1-\xi}\nodept{u}{2}+2\xi\pbrac{\xi-\frac12}\nodept{u}{3}
  \end{split}
\end{equation}

\subsubsection{Cubic Lagrange basis functions}

One-dimensional cubic Lagrange basis functions involve
four local nodes and can provide a cubic variation of field parameter
with $\xi$. They are defined as
\begin{equation}
  \begin{split}
    \lbfn{1}{\xi}&=\frac12\pbrac{3\xi-1}\pbrac{3\xi-2}\pbrac{1-\xi} \\
    \lbfn{2}{\xi}&=\frac92\xi\pbrac{3\xi-2}\pbrac{\xi-1} \\
    \lbfn{3}{\xi}&=\frac92\xi\pbrac{3\xi-1}\pbrac{1-\xi} \\
    \lbfn{4}{\xi}&=\frac12\xi\pbrac{3\xi-1}\pbrac{3\xi-2}
  \end{split}
  \label{eqn:cubiclbfuns}
\end{equation}

The four \onedal cubic Lagrange basis functions are shown in \figref{fig:cublagrangebfuns}.

\pstexfigure{plots/Theory/cublagrangebfuns.pstex}{Cubic Lagrange basis functions.}
{Cubic Lagrange basis functions.}{fig:cublagrangebfuns}

The interpolation formula is
\begin{equation}
  \begin{split}
    \fnof{u}{\xi}&=\lbfn{1}{\xi}\nodept{u}{1}+\lbfn{2}{\xi}\nodept{u}{2}+
    \lbfn{3}{\xi}\nodept{u}{3}+\lbfn{4}{\xi}\nodept{u}{4}\\
    &=\frac12\pbrac{3\xi-1}\pbrac{3\xi-2}\pbrac{1-\xi}\nodept{u}{1}+
    \frac92\xi\pbrac{3\xi-2}\pbrac{\xi-1}\nodept{u}{2} \\
    &\quad+\frac92\xi\pbrac{3\xi-1}\pbrac{1-\xi}\nodept{u}{3}+
    \frac12\xi\pbrac{3\xi-1}\pbrac{3\xi-2}\nodept{u}{4}
  \end{split}
\end{equation}

\subsubsection{General Lagrange basis functions}

In general the interpolation formula for the Lagrange family of basis
functions is, using \index{Einstein summation notation}\emph{Einstein
  summation notation}, given by
\begin{equation}
  \fnof{u}{\xi}=\lbfn{\alpha}{\xi}\nodept{u}{\alpha}\quad \alpha=1,\ldots,n_{e}
  \label{eqn:lagrangeinterpolation}
\end{equation}
where $n_{e}$ is the number of local nodes in the element. Einstein summation
notation uses a repeated index in a product expression to imply summation. For
example \eqnref{eqn:lagrangeinterpolation} is equivalent to
\begin{equation}
  \fnof{u}{\xi}=\gsum{\alpha=1}{n_{e}}{\lbfn{\alpha}{\xi}\nodept{u}{\alpha}}
\end{equation}

\subsubsection{Bilinear Lagrange basis functions}

Multi-dimensional Lagrange basis functions can be constructed from the tensor,
or outer, products of the one-dimensional Lagrange basis functions. For
example the two-dimensional bilinear Lagrange basis functions have four local
nodes with the basis functions given by
\begin{equation}
  \begin{split}
    \lbfn{1}{\xione,\xitwo}&=\lbfn{1}{\xione}\lbfn{1}{\xitwo}=
    \pbrac{1-\xione}\pbrac{1-\xitwo}\\
    \lbfn{2}{\xione,\xitwo}&=\lbfn{2}{\xione}\lbfn{1}{\xitwo}=
    \xione\pbrac{1-\xitwo}\\
    \lbfn{3}{\xione,\xitwo}&=\lbfn{1}{\xione}\lbfn{2}{\xitwo}=
    \pbrac{1-\xione}\xitwo \\
    \lbfn{4}{\xione,\xitwo}&=\lbfn{2}{\xione}\lbfn{2}{\xitwo}=
    \xione\xitwo
  \end{split}
\end{equation}

The four \twodal bilinear Lagrange basis functions are shown in \figref{fig:bilinlagrangebfuns}.

\pstexfigure{plots/Theory/bilinlagrangebfuns.pstex}{Bilinear Lagrange basis functions.}
            {Bilinear Lagrange basis functions.}{fig:bilinlagrangebfuns}

The multi-dimensional interpolation formula is still a sum of the products of
the nodal basis function and the field value at the node. For example the
interpolated geometric position vector within an element is given by
\begin{equation}
  \begin{split}
    \fnof{\vect{x}}{\xione,\xitwo}&=\lbfn{\alpha}{\xione,\xitwo}
    \nodept{\vect{x}}{\alpha}\\
    &=\lbfn{1}{\xione,\xitwo}\nodept{\vect{x}}{1}+\lbfn{2}{\xione,\xitwo}
    \nodept{\vect{x}}{2}+\lbfn{3}{\xione,\xitwo}\nodept{\vect{x}}{3}+
    \lbfn{4}{\xione,\xitwo}\nodept{\vect{x}}{4}
  \end{split}
\end{equation}
where, for the vector field, each component is interpolated separately using
the given basis functions.

\subsection{Hermitian Basis Functions}
\label{sec:Hermitianbasisfunctions}

Hermitian basis functions preserve continuity of the derivative of the
interpolating variable \ie $C^{1}$ continuity, with respect to $\xi$ across
element boundaries by defining additional nodal derivative parameters. Like
Lagrange bases, Hermitian basis functions are also chosen so that, at a
particular node, only one basis function is non-zero and equal to one. They
also are chosen so that, at a particular node, the \emph{derivative} of only
one of four basis functions is non-zero and is equal to one. Hermitian basis
functions hence serve to weight the interpolated solution in terms of the
field value and derivative of the field value at nodes.

\subsubsection{Cubic Hermite basis functions}

\Cubicherm basis functions are the simplest of the Hermitian family and
involve two local nodes per element. The interpolation within each element is
in terms of $\nodept{\vect{x}}{\alpha}$ and \evalat{\dby{\vect{x}}{\xi}}{\alpha}
and is given by \index{cubic Hermite basis!$\xi$ interpolation formula}
\begin{equation}
  \fnof{\vect{x}}{\xi}=\chbfn{1}{0}{\xi}\nodept{\vect{x}}{1}+\chbfn{1}{1}{\xi}
  \evalat{\dby{\vect{x}}{\xi}}{1}+\chbfn{2}{0}{\xi}\nodept{\vect{x}}{2}+
  \chbfn{2}{1}{\xi}\evalat{\dby{\vect{x}}{\xi}}{2}
  \label{eqn:chxiinterpolation}
\end{equation}
where the four \onedal \cubicherm basis functions are given in
\eqnref{eqn:chbfuns} and shown in \figref{fig:chbfuns}.
\index{cubic Hermite basis!basis functions formulae}
\begin{equation}
  \begin{split}
    \chbfn{1}{0}{\xi} &= 1-3\xi^{2}+2\xi^{3} \\
    \chbfn{1}{1}{\xi} &= \xi(\xi-1)^{2} \\
    \chbfn{2}{0}{\xi} &= \xi^{2}(3-2\xi) \\
    \chbfn{2}{1}{\xi} &= \xi^{2}(\xi-1)
  \end{split}
  \label{eqn:chbfuns}
\end{equation}
\pstexfigure{plots/Theory/chbfuns.pstex}{Cubic Hermite basis functions.}
{Cubic Hermite basis functions.}{fig:chbfuns}

\subsubsection{Scaling}

One further step is required to make \cubicherm basis functions useful in
practice.  Consider the two \cubicherm elements shown in
\figref{fig:chelements}.

\epstexfigure{svgs/Theory/cubichermiteelem.eps_tex}{Two
  cubic Hermite elements formed from three nodes.}{Two cubic Hermite elements
  (denoted by $\mathit{1}$ and $\mathit{2}$) formed from three nodes (shown as
  a $\bullet$ and denoted by $\mathbf{1}, \mathbf{2}$ and $\mathbf{3}$) and
  having \arclens $s_{1}$ and $s_{2}$ respectively.}{fig:chelements}{0.35}

The derivative $\evalat{\dby{\vect{x}}{\xi}}{\alpha}$ defined at local node
$\alpha$ is dependent upon the local element \xicoord and is therefore, in
general, different in the two adjacent elements. Interpretation of the
derivative is hence difficult as two derivatives with the same magnitude in
different parts of the mesh might represent two completely different physical
derivatives. This is problematic for modelling and computation if the interpretation of the
magnitude of the derivative (or \emph{scaling}) is unknown \eg we cannot
assign physical units. If the scaling varies throughout the mesh then a
derivative at a node that has a magnitude of, say, 5 will be different from
another derivative at another node that also has the magnitude of 5. Thus, a
numerical solver that is given a vector of derivative values would assume that
the scalings are the same and interpret the magnitudes identically. This would
mean that algorithms may fail \eg if, say, we needed to compute the
norm of a vector of derivatives then by assuming the same scaling the wrong
result would be computed.

In order to the have a consistent interpretation of the derivative
throughout the mesh it is better to base the interpolation on a physical
coordinate. Whilst we are free to choose the physical coordinate to be
anything the optimum choice is arc length as this is what physical processes
are based on. However, arc-length is extremely difficult to use as an
interpolation parameter as the inherent nonlinearity involved in its
calculation makes conversion to and from coordinates non trivial.
The solution is to find a parameter that scales
in the same way as arc-length or as close to it as we can.

Consider then basing the derivatives on an \arclen coordinate at nodes,
$\dby{\nodept{\vect{x}}{\alpha}}{s}$, with
\begin{equation}
  \begin{split}
    \evalat{\dby{\vect{x}}{\xi}}{\alpha}&=\dby{\nodept{\vect{x}}{
        \fnof{\Delta}{\alpha,e}}}{s}\pbrac{\dby{s}{\xi}}_{e} \\ &=
    \dby{\nodept{\vect{x}}{\fnof{\Delta}{\alpha,e}}}{s}\esfone{e}
  \end{split}
  \label{eqn:xitosch}
\end{equation}
used to determine $\evalat{\dby{\vect{x}}{\xi}}{\alpha}$. Here
$\dby{\vect{x}}{s}$ is a physical \arclen derivative,
$\fnof{\Delta}{\alpha,e}$ is the global node number of local node $\alpha$ in
element $e$, $\pbrac{\dby{s}{\xi}}_{e}$ is an \index{element scale
  factor}element \emph{scale factor}, denoted by $\esfone{e}$, which scales
the \arclen derivative to the \xicoord derivative.  Thus $\dby{\vect{x}}{s}$
is constrained to be continuous across element boundaries rather than
$\dby{\vect{x}}{\xi}$. The \cubicherm interpolation formula now becomes
\begin{equation}
  \fnof{\vect{x}}{\xi}=\chbfn{1}{0}{\xi}\nodept{\vect{x}}{1}+\chbfn{1}{1}{\xi}
  \dby{\nodept{\vect{x}}{1}}{s}\esfone{e}+\chbfn{2}{0}{\xi}\nodept{\vect{x}}{2}+
  \chbfn{2}{1}{\xi}\dby{\nodept{\vect{x}}{2}}{s}\esfone{e}
  \label{eqn:chseinterpolation}
\end{equation}

By interpolating with respect to $s$ rather than with respect to $\xi$ there is some
liberty as to the choice of the element scale factor, $\esfone{e}$. The choice
of the scale factor will, however, affect how $\xi$ changes with $s$.  It is
computationally desirable to have a relatively uniform change of $\xi$ with
$s$ (for example not biasing the Gaussian quadrature -- see later -- scheme to
one end of the element). For this reason the element scale factor is chosen as
some function of the \arclen of the element, $s_{e}$. The simplest linear
function that can be chosen is the \arclen itself. This type of scaling is
called \index{arc-length scaling}\emph{\arclen scaling}.

To calculate the \arclen for a particular element an iterative process is
needed. The \arclen for a \onedal element in \twods is defined as
\index{arc-length definition}
\begin{equation}
  \text{\arclen, }s_{e}=\gint{0}{1}{\norm{\dby{\fnof{\vect{x}}{\xi}}{\xi}}}
  {\xi}=\gint{0}{1}{\sqrt{\pbrac{\dby{\fnof{x}{\xi}}{\xi}}^{2}+
      \pbrac{\dby{\fnof{y}{\xi}}{\xi}}^{2}}}{\xi}
  \label{eqn:arclendef}
\end{equation}

However, since the interpolation of $\fnof{\vect{x}}{\xi}$, as defined in
\eqnref{eqn:chseinterpolation}, uses the \arclen in the calculation of the
scaling factor, an iterative root finding technique is needed to obtain the
\arclen.

Thus, for an element $e$, the \onedal \cubicherm interpolation
formula in \eqnref{eqn:chseinterpolation} becomes
\begin{equation}
  \fnof{\vect{x}}{\xi}=\chbfn{\alpha}{u}{\xi}\nodept{\vect{x}}{\alpha}_{,u}
  \esftwo{e}{u}
  \label{eqn:chsfinterpolation}
\end{equation}
where $\alpha$ varies from $1$ to $2$, $u$ varies from $0$ to $1$,
$\nodept{\vect{x}}{\alpha}_{,0}=\nodept{\vect{x}}{\alpha}$,
$\nodept{\vect{x}}{\alpha}_{,1}= \dby{\nodept{\vect{x}}{\alpha}}{s}$,
$\esftwo{e}{0}=1$ and $\esftwo{e}{1}=\esfone{e}=s_{e}$. \Eqnref{eqn:chsfinterpolation} is equivalent to
\begin{equation}
  \fnof{\vect{x}}{\xi}=\chbfn{1}{0}{\xi}\nodept{\vect{x}}{1}_{,0}\esftwo{e}{0}
  +\chbfn{1}{1}{\xi}\nodept{\vect{x}}{1}_{,1}\esftwo{e}{1}+
  \chbfn{2}{0}{\xi}\nodept{\vect{x}}{2}_{,0}\esftwo{e}{0}
  +\chbfn{2}{1}{\xi}\nodept{\vect{x}}{2}_{,1}\esftwo{e}{1}
\end{equation}
\ie there is an implied sum with $\alpha$ and $u$ for $\chbfn{\alpha}{u}{\xi}$
and $\nodept{\vect{x}}{\alpha}_{,u}$ but not for $\esftwo{e}{u}$.

There is one final condition that must be placed on the $\xi$ to \arclen
transformation to ensure \arclen derivatives. This condition is based on the
geometric defintion of \arclen which is given by Pythagorus \ie for \twods in
rectangular cartesian coordinate we have
\begin{equation}
  ds^{2}=dx^{2}+dy^{2}
  \label{eqn:arclengthpythagorus}
\end{equation}
or, in general coordinates,
\begin{equation}
  ds^{2}=g_{ij}dx^{i}dx^{j}
  \label{eqn:genarclengthpythagorus}
\end{equation}
where $g_{ij}$ are the components of the metric tensor.

Rearranging \eqnref{eqn:arclengthpythagorus} we find that the \arclen derivative vector at a
node for geometric like fields, for rectangular cartesian coordinates, must
have unit magnitude. Thus for global node $A$ we have
\begin{equation}
  \norm{\dby{\nodept{\vect{x}}{A}}{s}}=1
  \label{eqn:chnormconstraint}
\end{equation}

In general coordinates this condition becomes
\begin{equation}
  \norm{\delby{\nodept{\vect{x}}{A}}{s_{k}}}=\sqrt{\det{\tensor{g}}}
  \label{eqn:genchnormconstraint}
\end{equation}
where $s_{k}$ is the \nth{k} global arc-length direction and $\tensor{g}$ is the metric tensor.

The use of this constraint on \arclen derivative magnitude ensures that there is continuity with respect to a physical parameter,
$s$, rather than with respect to a mathematical parameter $\xi$. The set of
mesh parameters, $\vect{u}$, for \cubicherm interpolation hence contains the
set of nodal values (or positions), the set of nodal \arclen derivatives and
the set of scale factors.

\subsubsection{Extension to higher orders}

\Bicubicherm basis functions are the \twodal extension of the \onedal
\cubicherm basis functions. They are formed from the tensor (or outer) product
of two of the \onedal cubic Hermite basis functions defined in
\eqnref{eqn:chbfuns}.  The interpolation formula for the point
$\fnof{\vect{x}}{\xione,\xitwo}$ within an element is obtained from the
\bicubicherm interpolation formula \cite{nielsen:1991a}, \index{bicubic
  Hermite basis!$\xi$ interpolation formula}
\begin{equation}
  \begin{split}
    \fnof{\vect{x}}{\xione,\xitwo} &=
    \chbfn{1}{0}{\xione}\chbfn{1}{0}{\xitwo}\nodept{\vect{x}}{1} +
    \chbfn{2}{0}{\xione}\chbfn{1}{0}{\xitwo}\nodept{\vect{x}}{2} + \\
    & \chbfn{1}{0}{\xione}\chbfn{2}{0}{\xitwo}\nodept{\vect{x}}{3} +
    \chbfn{2}{0}{\xione}\chbfn{2}{0}{\xitwo}\nodept{\vect{x}}{4} + \\
    & \chbfn{1}{1}{\xione}\chbfn{1}{0}{\xitwo}\evalat{\delby{\vect{x}}{\xione}}
    {1}+
    \chbfn{2}{1}{\xione}\chbfn{1}{0}{\xitwo}\evalat{\delby{\vect{x}}{\xione}}
    {2}+ \\
    & \chbfn{1}{1}{\xione}\chbfn{2}{0}{\xitwo}\evalat{\delby{\vect{x}}{\xione}}
    {3}+
    \chbfn{2}{1}{\xione}\chbfn{2}{0}{\xitwo}\evalat{\delby{\vect{x}}{\xione}}
    {4} + \\
    & \chbfn{1}{0}{\xione}\chbfn{1}{1}{\xitwo}\evalat{\delby{\vect{x}}{\xitwo}}
    {1}+
    \chbfn{2}{0}{\xione}\chbfn{1}{1}{\xitwo}\evalat{\delby{\vect{x}}{\xitwo}}
    {2} + \\
    & \chbfn{1}{0}{\xione}\chbfn{2}{1}{\xitwo}\evalat{\delby{\vect{x}}{\xitwo}}
    {3}+
    \chbfn{2}{0}{\xione}\chbfn{2}{1}{\xitwo}\evalat{\delby{\vect{x}}{\xitwo}}
    {4} + \\
    & \chbfn{1}{1}{\xione}\chbfn{1}{1}{\xitwo}\evalat{\deltwoby{\vect{x}}
      {\xione}{\xitwo}}{1} +
    \chbfn{2}{1}{\xione}\chbfn{1}{1}{\xitwo}\evalat{\deltwoby{\vect{x}}
      {\xione}{\xitwo}}{2} + \\
    & \chbfn{1}{1}{\xione}\chbfn{2}{1}{\xitwo}\evalat{\deltwoby{\vect{x}}
      {\xione}{\xitwo}}{3} +
    \chbfn{2}{1}{\xione}\chbfn{2}{1}{\xitwo}\evalat{ \deltwoby{\vect{x}}
      {\xione}{\xitwo}}{4}
  \end{split}
  \label{eqn:bichxiinterp}
\end{equation}

As with \onedal \cubicherm elements, the derivatives with respect to $\xi$ in
the \twodal interpolation formula above are expressed as the product of a
nodal \arclen derivative and a scale factor. This is, however, complicated by
the fact that there are now multiple $\xi$ directions at each node. From the
product rule the transformation from an $\xi$ based derivative to an \arclen
based derivative is given by,
\begin{equation}
  \delby{\vect{x}}{\xi_{l}}=\delby{\vect{x}}{s_{1}}\delby{s_{1}}{\xi_{l}}+
  \delby{\vect{x}}{s_{2}}\delby{s_{2}}{\xi_{l}}
  \label{eqn:xitosproductrule}
\end{equation}

Now, by definition, the $\nth{l}$ \arclen direction is only a function of the
$\nth{l}$ $\xi$ direction, hence the derivative at local node $\alpha$ is
\begin{equation}
  \evalat{\delby{\vect{x}}{\xi_{l}}}{\alpha}=\delby{\nodept{\vect{x}}{
      \fnof{\Delta}{\alpha,e}}}{s_{l}}\esftwo{e}{l}
  \label{eqn:xitosbich}
\end{equation}
and the cross-derivative is
\begin{equation}
  \evalat{\deltwoby{\vect{x}}{\xione}{\xitwo}}{\alpha}=
  \deltwoby{\nodept{\vect{x}}{\fnof{\Delta}{\alpha,e}}}{s_{1}}{s_{2}}\esftwo{e}{1}
  \esftwo{e}{2}
  \label{eqn:xitosbichcd}
\end{equation}

Unlike the \onedal \cubicherm case a condition must be placed on
this transformation in order to maintain $C^{1}$ continuity across element
boundaries.

Consider the line between global nodes $\mathbf{1}$ and $\mathbf{2}$ in the
two \bicubicherm elements shown in \figref{fig:bichelementcont}.
\epstexfigure{svgs/Theory/C1bicubicHermite.eps_tex}{Continuity of two bicubic
  Hermite elements.}{Two bicubic Hermite elements (denoted by $\mathit{1}$ and
  $\mathit{2}$). The global node numbers are given in boldface, the local node
  numbers in normal text and the element scale factors used along each line
  are denoted by $\esfone{l}$.}{fig:bichelementcont}{0.35}

For $C^{1}$ continuity, as opposed to $G^{1}$ continuity, between these
elements the derivative with respect to $\xione$, that is
\delby{\fnof{\vect{x}}{\xitwo}}{\xione}, must be continuous\footnote{For
  $C^{1}$ continuity the normals either side of an element boundary must be in
  the same direction \emph{and} have the same magnitude. For $G^{1}$
  continuity the normals must only have the same direction.}. The formula for
this derivative in element $\mathit{1}$ along the boundary between elements
$\mathit{1}$ and $\mathit{2}$ is
\begin{equation}
  \delby{\fnof{\vect{x}}{1,\xitwo}}{\xione}=\chbfn{0}{1}{\xitwo}\evalat{
    \delby{\vect{x}}{\xione}}{2}+\chbfn{0}{2}{\xitwo}\evalat{
    \delby{\vect{x}}{\xione}}{4}+\chbfn{1}{1}{\xitwo}\evalat{
    \deltwoby{\vect{x}}{\xione}{\xitwo}}{2}+\chbfn{1}{2}{\xitwo}\evalat{
    \deltwoby{\vect{x}}{\xione}{\xitwo}}{4}
  \label{eqn:c1contelem1}
\end{equation}
and for element $\mathit{2}$ is
\begin{equation}
  \delby{\fnof{\vect{x}}{0,\xitwo}}{\xione}=\chbfn{0}{1}{\xitwo}\evalat{
    \delby{\vect{x}}{\xione}}{1}+\chbfn{0}{2}{\xitwo}\evalat{
    \delby{\vect{x}}{\xione}}{3}+\chbfn{1}{1}{\xitwo}\evalat{
    \deltwoby{\vect{x}}{\xione}{\xitwo}}{1}+\chbfn{1}{2}{\xitwo}\evalat{
    \deltwoby{\vect{x}}{\xione}{\xitwo}}{3}
  \label{eqn:c1contelem2}
\end{equation}

Now substituting \eqnrefs{eqn:xitosbich}{eqn:xitosbichcd} into the
above equations yields for element $\mathit{1}$
\begin{equation}
  \begin{split}
    \delby{\fnof{\vect{x}}{1,\xitwo}}{\xione} &=
    \chbfn{0}{1}{\xitwo}\delby{\nodept{\vect{x}}{2}}{s_{1}}\esfone{2}+
    \chbfn{0}{2}{\xitwo}\delby{\nodept{\vect{x}}{4}}{s_{1}}\esfone{5}+ \\
    &\quad\chbfn{1}{1}{\xitwo}\deltwoby{\nodept{\vect{x}}{2}}{s_{1}}{s_{2}}
    \esfone{2}\esfone{4}+
    \chbfn{1}{2}{\xitwo}\deltwoby{\nodept{\vect{x}}{4}}{s_{1}}{s_{2}}
    \esfone{5}\esfone{4}
  \end{split}
\end{equation}
and for element $\mathit{2}$
\begin{equation}
  \begin{split}
    \delby{\fnof{\vect{x}}{0,\xitwo}}{\xione} &=
    \chbfn{0}{1}{\xione}\delby{\nodept{\vect{x}}{1}}{s_{1}}\esfone{3}+
    \chbfn{0}{2}{\xitwo}\delby{\nodept{\vect{x}}{3}}{s_{1}}\esfone{6}+ \\
    &\quad\chbfn{1}{1}{\xitwo}\deltwoby{\nodept{\vect{x}}{1}}{s_{1}}{s_{2}}
    \esfone{3}\esfone{4}+
    \chbfn{1}{2}{\xitwo}\deltwoby{\nodept{\vect{x}}{3}}{s_{1}}{s_{2}}
    \esfone{6}\esfone{4}
  \end{split}
\end{equation}

Now local node $2$ in element $\mathit{1}$ and local node $1$ in element
$\mathit{2}$ is the same as global node $\mathbf{1}$ and local node $4$ in
element $\mathit{1}$ and local node $3$ in element $\mathit{2}$ is the same as
global node $\mathbf{2}$. Hence for a given $\xitwo$ the condition for $C^{1}$
continuity across the element boundary is
\begin{multline}
  \chbfn{0}{1}{\xitwo}\delby{\nodept{\vect{x}}{\mathbf{1}}}{s_{1}}\esfone{2}+
  \chbfn{0}{2}{\xitwo}\delby{\nodept{\vect{x}}{\mathbf{2}}}{s_{1}}\esfone{5}+
  \chbfn{1}{1}{\xitwo}\deltwoby{\nodept{\vect{x}}{\mathbf{1}}}{s_{1}}{s_{2}}
  \esfone{2}\esfone{4} \\
  +\chbfn{1}{2}{\xitwo}\deltwoby{\nodept{\vect{x}}{\mathbf{2}}}{s_{1}}{s_{2}}
  \esfone{5}\esfone{4} = \chbfn{0}{1}{\xitwo}\delby{\nodept{\vect{x}}
    {\mathbf{1}}}{s_{1}}\esfone{3}+\chbfn{0}{2}{\xitwo}\delby{\nodept{\vect{x}}
    {\mathbf{2}}}{s_{1}}\esfone{6} \\
  +\chbfn{1}{1}{\xitwo}\deltwoby{\nodept{\vect{x}}{\mathbf{1}}}{s_{1}}{s_{2}}
  \esfone{3}\esfone{4}+\chbfn{1}{2}{\xitwo}\deltwoby{\nodept{\vect{x}}
    {\mathbf{2}}}{s_{1}}{s_{2}}\esfone{6}\esfone{4}
\end{multline}
or
\begin{multline}
  \pbrac{\esfone{2}-\esfone{3}}\pbrac{\chbfn{0}{1}{\xitwo}
    \delby{\nodept{\vect{x}}{\mathbf{1}}}{s_{1}}+\chbfn{1}{1}{\xitwo}
    \deltwoby{\nodept{\vect{x}}{\mathbf{1}}}{s_{1}}{s_{2}}\esfone{4}} = \\
  \pbrac{\esfone{6}-\esfone{5}}\pbrac{\chbfn{0}{2}{\xitwo}
    \delby{\nodept{\vect{x}}{\mathbf{2}}}{s_{1}}+\chbfn{1}{2}{\xitwo}
    \deltwoby{\nodept{\vect{x}}{\mathbf{2}}}{s_{1}}{s_{2}}\esfone{4}}
  \label{eqn:bchc1condition}
\end{multline}

Now by choosing the scale factors to be equal on either side of node
$\mathbf{1}$ and $\mathbf{2}$ (\ie $\esfone{2}=\esfone{3}=\nsfone{\mathbf{1}}$
and $\esfone{5}=\esfone{6}=\nsfone{\mathbf{2}}$), that is nodal based scale
factors, \eqnref{eqn:bchc1condition} is satisfied for any choice of the scale
factors.  Hence nodal scale factors are a sufficient condition to ensure
$C^{1}$ continuity. If it is desired that the scale factors be different
either side of the node then \eqnref{eqn:bchc1condition} must be satisfied to
ensure continuity.

The choice of the scale factors again determines the $\xi$
to $s$ spacing. We have a number of choices for the scale factor depending on
whether or not the $\xi$ to $s$ spacing should favour bigger or smaller
elements. One choice which equally favours both elements either side of the
node is for the scale factors to be chosen to be nodally based and equal to the average \arclen on either side
of the node for each $\xi$ direction \ie for the $\nth{l}$ direction
\begin{equation}
  \nsftwo{A}{l}=\dfrac{\fnof{s_{l}}{\fnof{A_{\ominus}}{l}}+
    \fnof{s_{l}}{\fnof{A_{\oplus}}{l}}}{2}
  \label{eqn:arithmeanarclenscale}
\end{equation}
where $\nsftwo{A}{l}$ is the nodal scale factor in the $\nth{l}$ $\xi$
direction at global node $A$, $\fnof{A_{\ominus}}{l}$ is the element
immediately preceding (in the \nth{l} direction) node $A$, and
$\fnof{A_{\oplus}}{l}$ is the element immediately after (in the \nth{l}
direction) node $A$ and $\fnof{s_{l}}{e}$ is the \arclen in the \nth{l} $\xi$
direction from node $A$ in element $e$. This type of scaling is known as
\emph{arithmetic mean \arclen scaling}.

Other means can be used \ie \emph{geometric mean \arclen scaling}
\begin{equation}
  \nsftwo{A}{l}=\sqrt{\fnof{s_{l}}{\fnof{A_{\ominus}}{l}}
    \fnof{s_{l}}{\fnof{A_{\oplus}}{l}}}
  \label{eqn:geomeanarclenscale}
\end{equation}
or \emph{harmonic mean \arclen scaling}
\begin{equation}
  \nsftwo{A}{l}=\dfrac{\fnof{s_{l}}{\fnof{A_{\ominus}}{l}}
    \fnof{s_{l}}{\fnof{A_{\oplus}}{l}}}{\fnof{s_{l}}{\fnof{A_{\ominus}}{l}}+
    \fnof{s_{l}}{\fnof{A_{\oplus}}{l}}}
  \label{eqn:harmonicmeanarclenscale}
\end{equation}

\pstexfigure{plots/Theory/funcscaling.pstex}{Function scaling.}
{Function scaling.}{fig:functionscaling}{1.5}

\pstexfigure{plots/Theory/firstdscaling.pstex}{First derivative scaling.}
{First derivative scaling.}{fig:firstdscaling}{1.5}

\pstexfigure{plots/Theory/seconddscaling.pstex}{Second derivative scaling.}
{Second derivative scaling.}{fig:seconddscaling}{1.5}

\subsubsection{Hermite-sector elements}
\label{sec:hselements}

One problem that arises when using quadrilateral elements (such as
\bicubicherm elements) to describe a surface is that it is impossible to
'close the surface' in three-dimensions whilst maintaining consistent $\xione$
and $\xitwo$ directions throughout the mesh. This is important as $C^{1}$
continuity requires either consistent $\xi$ directions or a transformation at
each node to take into account the inconsistent directions \cite{petera:1994}.

One solution to this problem is to \emph{collapse} a \bicubicherm element.
This entails placing one of the four local nodes of the element at the same
geometric location as another local node of the element and results in a
triangular element from which it is possible to close the surface. There are
two main problems with this solution.  The first is that one of the two $\xi$
directions at the collapsed node is undefined.  The second is that the
distance between the two nodes at the same location is zero.  Numerical
problems can result from this zero distance.  An alternative strategy has
been developed in which special elements, called ``Hermite-sector''
elements\index{Hermite-sector elements}, are used to close a \bicubicherm
surface in three-dimensions. There are two types of elements depending on
whether the $\xi$ (or $s$) directions come together at local node one or local
node three.  These two elements are shown in \figref{fig:hermitesectors}.

\epstexfigure{svgs/Theory/hermitesectors.eps_tex}{Hermite-sector elements.}
{Hermite-sector elements. (a) Apex node one element. (b) Apex node three
  element.}{fig:hermitesectors}{0.3}

From \figref{fig:hermitesectors} it can be seen that the $s_{2}$ direction is
not unique at the apex nodes. This gives us two choices for the interpolation
within the element: ignore the $s_{2}$ derivative when interpolating or set
the $s_{2}$ derivative identically to zero.

\textbf{Ignore $s_{2}$ apex derivative}: For this case it can be seen from
\figref{fig:hermitesectors} that the interpolation in the $\xione$ direction
is just the standard cubic Hermite interpolation. The interpolation in the
$\xitwo$ direction is now a little different in that the nodal \arclen
derivative has been dropped as it is no longer defined at the apex node.  For
an apex node one element shown in \figref{fig:hermitesectors}(a) the
interpolation for the line between local node one and local node $n$ is now
quadratic and is given by
\begin{equation}
  \fnof{\vect{x}}{\xitwo}=\hsonebfn{1}{\xitwo}\nodept{\vect{x}}{1}+
  \hsonebfn{2}{\xitwo}\nodept{\vect{x}}{n}+
  \hsonebfn{3}{\xitwo}\evalat{\delby{\vect{x}}{\xitwo}}{n}
  \label{eqn:hsapex1xiinterp}
\end{equation}
with the basis functions given by
\index{quadratic Hermite basis!apex node one!basis functions formulae}
\begin{equation}
  \begin{split}
    \hsonebfn{1}{\xi}&=\pbrac{\xi-1}^{2} \\
    \hsonebfn{2}{\xi}&=2\xi-\xi^{2} \\
    \hsonebfn{3}{\xi}&=\xi^{2}-\xi
  \end{split}
  \label{eqn:hsapex1bfuns}
\end{equation}

For the apex node three element shown in \figref{fig:hermitesectors}(b) the
interpolation for the line connecting local node $n$ with local node three is
given by
\begin{equation}
  \fnof{\vect{x}}{\xitwo}=\hsthreebfn{1}{\xitwo}\nodept{\vect{x}}{3}+
  \hsthreebfn{2}{\xitwo}\nodept{\vect{x}}{n}+
  \hsthreebfn{3}{\xitwo}\evalat{\delby{\vect{x}}{\xitwo}}{n}
  \label{eqn:hsapex3xiinterp}
\end{equation}
with the basis functions given by
\index{quadratic Hermite basis!apex node three!basis functions formulae}
\begin{equation}
  \begin{split}
    \hsthreebfn{1}{\xi}&=\xi^{2} \\
    \hsthreebfn{2}{\xi}&=1-\xi^{2} \\
    \hsthreebfn{3}{\xi}&=\xi-\xi^{2}
  \end{split}
  \label{eqn:hsapex3Bfuns}
\end{equation}

The full interpolation formula for the sector element can then be found by
taking the tensor product of the interpolation in the $\xione$ direction,
given in \eqnref{eqn:chxiinterpolation}, with the interpolation in the
$\xitwo$ direction (given by either Equations \bref{eqn:hsapex1xiinterp} or
\bref{eqn:hsapex3xiinterp}). The interpolation formula can be converted from
nodal $\xi$ derivatives to nodal \arclen derivatives using the procedure
outlined for the \bicubicherm case. For example, the interpolation formulae for
an apex node one element is \index{Hermite-sector basis!apex node one!\arclen
  interpolation formula}
\begin{equation}
  \begin{split}
    \fnof{\vect{x}}{\xione,\xitwo} &=
    \hsonebfn{1}{\xitwo}\nodept{\vect{x}}{1}+\chbfn{1}{0}{\xione}\hsonebfn{2}
    {\xitwo}\nodept{\vect{x}}{2}+\chbfn{2}{0}{\xione}\hsonebfn{2}{\xitwo}
    \nodept{\vect{x}}{3} + \\
    & \chbfn{1}{1}{\xione}\hsonebfn{2}{\xitwo}\delby{\nodept{\vect{x}}{2}}{s_{1}}
    \nsftwo{2}{1}+\chbfn{2}{1}{\xione}\hsonebfn{2}{\xitwo}\delby{\nodept{\vect{x}}
      {3}}{s_{1}}\nsftwo{3}{1} + \\
    & \chbfn{1}{0}{\xione}\hsonebfn{3}{\xitwo}\delby{\nodept{\vect{x}}{2}}{s_{2}}
    \nsftwo{2}{2} + \chbfn{2}{0}{\xione}\hsonebfn{3}{\xitwo}
    \delby{\nodept{\vect{x}}{3}}{s_{2}}\nsftwo{3}{2} + \\
    & \chbfn{1}{1}{\xione}\hsonebfn{3}{\xitwo}\deltwoby{\nodept{\vect{x}}{2}}
    {s_{1}}{s_{2}}\nsftwo{2}{1}\nsftwo{2}{2} +
    \chbfn{2}{1}{\xione}\hsonebfn{3}{\xitwo}\deltwoby{\nodept{\vect{x}}{3}}
    {s_{1}}{s_{2}}\nsftwo{3}{1}\nsftwo{3}{2}
  \end{split}
  \label{eqn:hsapex1sinterp}
\end{equation}

Care must be taken when using Hermite-sector elements for rapidly changing
surfaces. Consider an apex node one element with undefined $s_{2}$ apex
derivatives. The rate of change of $\vect{x}$ with respect to
$\xione$ along the line from node one to node three (\ie $\xione=1$) is
\begin{equation}
  \begin{split}
    \delby{\fnof{\vect{x}}{1,\xitwo}}{\xione} &= \hsonebfn{2}{\xitwo}\delby{
      \nodept{\vect{x}}{3}}{s_{1}}\nsftwo{3}{1}+\hsonebfn{3}{\xitwo}\deltwoby{
      \nodept{\vect{x}}{3}}{s_{1}}{s_{2}}\nsftwo{3}{1}\nsftwo{3}{2} \\
    &= \nsftwo{3}{1}\pbrac{\pbrac{2\xitwo-\xitwo^{2}}\delby{\nodept{\vect{x}}{3}}
      {s_{1}}+\pbrac{\xitwo^{2}-\xitwo}\deltwoby{\nodept{\vect{x}}{3}}{s_{1}}{s_{2}}
      \nsftwo{3}{2}}
  \end{split}
\end{equation}

Taking the dot product of $\delby{\fnof{\vect{x}}{1,\xitwo}}{\xione}$ with
$\delby{\nodept{\vect{x}}{3}}{s_{1}}$ gives
\begin{equation}
  \dotprod{\delby{\fnof{\vect{x}}{1,\xitwo}}{\xione}}{\delby{\nodept{\vect{x}}{3}}
    {s_{1}}} = \nsftwo{3}{1}
  \pbrac{\pbrac{2\xitwo-\xitwo^{2}}\dotprod{\delby{\nodept{\vect{x}}{3}}{s_{1}}}
    {\delby{\nodept{\vect{x}}{3}}{s_{1}}}+\pbrac{\xitwo^{2}-\xitwo}\nsftwo{3}{2}
    \dotprod{\deltwoby{\nodept{\vect{x}}{3}}{s_{1}}{s_{2}}}
    {\delby{\nodept{\vect{x}}{3}}{s_{1}}}}
  \label{eqn:hsonedirectiondotprod}
\end{equation}

The normality constraint for \arclen derivatives means that
$\dotprod{\delby{\nodept{\vect{x}}{3}}{s_{1}}}{\delby{\nodept{\vect{x}}{3}}
  {s_{1}}}=1$ and thus the right hand side of
\eqnref{eqn:hsonedirectiondotprod} divided by $\nsftwo{3}{1}$ (\ie normalised
by $\nsftwo{3}{1}$) is the quadratic
\begin{equation*}
  \pbrac{2\xitwo-\xitwo^{2}}+\pbrac{\xitwo^{2}-\xitwo}\nsftwo{3}{2}
  \dotprod{\deltwoby{\nodept{\vect{x}}{3}}{s_{1}}{s_{2}}}{\delby{\nodept{\vect{x}}
      {3}}{s_{1}}}
\end{equation*}
or
\begin{equation*}
  \pbrac{\nsftwo{3}{2}\dotprod{\deltwoby{\nodept{\vect{x}}{3}}{s_{1}}{s_{2}}}
    {\delby{\nodept{\vect{x}}{3}}{s_{1}}} -1}\xitwo^{2}+
  \pbrac{2-\nsftwo{3}{2}\dotprod{\deltwoby{\nodept{\vect{x}}{3}}{s_{1}}{s_{2}}}
    {\delby{\nodept{\vect{x}}{3}}{s_{1}}}}\xitwo
  \label{eqn:hsonedirectionpolynomial}
\end{equation*}

This quadratic is $1$ at $\xitwo=1$ and always has a root at $\xitwo=0$.
Consider the case of this quadratic having its second root in the interval
$(0,1)$. This would mean that at some point in the interval $(0,1)$ the dot
product of \delby{\fnof{\vect{x}}{1,\xitwo}}{\xione} and
\delby{\nodept{\vect{x}}{3}}{s_{1}} would go from zero to negative and then
positive as $\xitwo$ changed from $0$ to $1$ \ie the angle between
$\delby{\fnof{\vect{x}}{1,\xitwo}}{\xione}$ and
$\delby{\nodept{\vect{x}}{3}}{s_{1}}$ would, at some stage, be greater than
ninety degrees. As the direction of the normal to the surface along the line
between local node one and three is given by the cross product of
$\delby{\fnof{\vect{x}}{1,\xitwo}}{\xione}$ and
$\delby{\fnof{\vect{x}}{1,\xitwo}}{\xitwo}$ then, if the quadratic became
sufficiently negative, the normal to the surface could reverse direction from
an outward to an inward normal as $\xitwo$ changed from $0$ to $1$. This is
clearly undesirable. In fact even if the quadratic is only slightly negative
the resulting surface would be grossly deformed.

To avoid these effects the second root of the quadratic must be outside the
interval $(0,1)$. From the quadratic formula the conditions for this are
\begin{equation}
  \dfrac{\nsftwo{3}{2}\dotprod{\deltwoby{\nodept{\vect{x}}{3}}{s_{1}}{s_{2}}}
    {\delby{\nodept{\vect{x}}{3}}{s_{1}}}-2}{\nsftwo{3}{2}\dotprod{
      \deltwoby{\nodept{\vect{x}}{3}}{s_{1}}{s_{2}}}{\delby{\nodept{\vect{x}}{3}}
      {s_{1}}}-1}<0
\end{equation}
and
\begin{equation}
  \dfrac{\nsftwo{3}{2}\dotprod{\deltwoby{\nodept{\vect{x}}{3}}{s_{1}}{s_{2}}}
    {\delby{\nodept{\vect{x}}{3}}{s_{1}}}-2}{\nsftwo{3}{2}\dotprod{
      \deltwoby{\nodept{\vect{x}}{3}}{s_{1}}{s_{2}}}{\delby{\nodept{\vect{x}}{3}}
      {s_{1}}}-1}>1
\end{equation}
that is (for the line from local node one to local node $n$)
\index{Hermite-sector basis!apex node one!cross-derivative condition}
\begin{equation}
  \dotprod{\deltwoby{\nodept{\vect{x}}{n}}{s_{1}}{s_{2}}}{\delby{\nodept{\vect{x}}
      {n}}{s_{1}}}<\dfrac{2}{\nsftwo{n}{2}}
\end{equation}

The simplest way to interpret this constraint is that if the element is large
(\ie $\nsftwo{n}{2}$ is large) then $\dotprod{\deltwoby{\nodept{\vect{x}}{n}}
  {s_{1}}{s_{2}}}{\delby{\nodept{\vect{x}}{n}}{s_{1}}}$ must be small. The
simplest way for this to happen is to ensure the magnitude of the components of
$\deltwoby{\nodept{\vect{x}}{n}}{s_{1}}{s_{2}}$ are small (or of opposite sign to
the comparable components of $\delby{\nodept{\vect{x}}{n}}{s_{1}}$).

The equivalent interpolation formula to \eqnref{eqn:hsapex1sinterp} for an
apex node three Hermite-sector element is
\index{Hermite-sector basis!apex node three!\arclen interpolation formula}
\begin{equation}
  \begin{split}
    \fnof{\vect{x}}{\xione,\xitwo} &=
    \chbfn{1}{0}{\xione}\hsthreebfn{2}{\xitwo}\nodept{\vect{x}}{1}+
    \chbfn{2}{0}{\xione}\hsthreebfn{2}{\xitwo}\nodept{\vect{x}}{2}+
    \hsthreebfn{1}{\xitwo}\nodept{\vect{x}}{3}+ \\
    & \chbfn{1}{1}{\xione}\hsthreebfn{2}{\xitwo}\delby{\nodept{\vect{x}}{1}}
    {s_{1}}\nsftwo{1}{1}+\chbfn{2}{1}{\xione}\hsthreebfn{2}{\xitwo}
    \delby{\nodept{\vect{x}}{2}}{s_{1}}\nsftwo{2}{1} + \\
    & \chbfn{1}{0}{\xione}\hsthreebfn{3}{\xitwo}\delby{\nodept{\vect{x}}{1}}
    {s_{2}}\nsftwo{1}{2}+\chbfn{2}{0}{\xione}\hsthreebfn{3}{\xitwo}
    \delby{\nodept{\vect{x}}{2}}{s_{2}}\nsftwo{2}{2} + \\
    & \chbfn{1}{1}{\xione}\hsthreebfn{3}{\xitwo}\deltwoby{\nodept{\vect{x}}{1}}
    {s_{1}}{s_{2}}\nsftwo{1}{1}\nsftwo{1}{2} +
    \chbfn{2}{1}{\xione}\hsthreebfn{3}{\xitwo}\deltwoby{\nodept{\vect{x}}{2}}
    {s_{1}}{s_{2}}\nsftwo{2}{1}\nsftwo{2}{2}
  \end{split}
  \label{eqn:hsapex3sinterp}
\end{equation}
and the equivalent constraint for apex node three Hermite-sector elements (for
the line from local node $n$ to local node three) is
\index{Hermite-sector basis!apex node three!cross-derivative condition}
\begin{equation}
  \dotprod{\deltwoby{\nodept{\vect{x}}{n}}{s_{1}}{s_{2}}}{\delby{\nodept{\vect{x}}
      {n}}{s_{1}}}>\dfrac{-2}{\nsftwo{n}{2}}
\end{equation}

\textbf{Zero $s_{2}$ apex derivative}: For this case the sector basis
functions are just the cubic Hermite basis functions. The corresponding
interpolation formulae for an apex node one element is hence
\begin{equation}
  \begin{split}
    \fnof{\vect{x}}{\xione,\xitwo} &= \chbfn{1}{0}{\xitwo}
    \nodept{\vect{x}}{1} +
     \chbfn{1}{0}{\xione}\chbfn{2}{0}{\xitwo}\nodept{\vect{x}}{2} +
    \chbfn{2}{0}{\xione}\chbfn{2}{0}{\xitwo}\nodept{\vect{x}}{3} + \\
    & \chbfn{1}{1}{\xione}\chbfn{2}{0}{\xitwo}\delby{\nodept{\vect{x}}{2}}{s_{1}}
    \nsftwo{2}{1}+
    \chbfn{2}{1}{\xione}\chbfn{2}{0}{\xitwo}\delby{\nodept{\vect{x}}{3}}{s_{1}}
    \nsftwo{3}{1} + \\
    & \chbfn{1}{0}{\xione}\chbfn{2}{1}{\xitwo}\delby{\nodept{\vect{x}}{2}}{s_{2}}
    \nsftwo{2}{2}+
    \chbfn{2}{0}{\xione}\chbfn{2}{1}{\xitwo}\delby{\nodept{\vect{x}}{2}}{s_{2}}
    \nsftwo{3}{2} + \\
    & \chbfn{1}{1}{\xione}\chbfn{2}{1}{\xitwo}\deltwoby{\nodept{\vect{x}}{2}}
      {s_{1}}{s_{2}}\nsftwo{2}{1}\nsftwo{2}{2} +
    \chbfn{2}{1}{\xione}\chbfn{2}{1}{\xitwo}\deltwoby{\nodept{\vect{x}}{3}}
      {s_{1}}{s_{2}}\nsftwo{3}{1}\nsftwo{3}{2}
  \end{split}
\end{equation}
and the condition to avoid reversal of the normal is
\begin{equation}
  \dotprod{\deltwoby{\nodept{\vect{x}}{n}}{s_{1}}{s_{2}}}{\delby{\nodept{\vect{x}}
      {n}}{s_{1}}}<\dfrac{3}{\nsftwo{n}{2}}
\end{equation}
and for the apex node three element the interpolation formula is
\begin{equation}
  \begin{split}
    \fnof{\vect{x}}{\xione,\xitwo} &=
    \chbfn{1}{0}{\xione}\chbfn{2}{0}{\xitwo}\nodept{\vect{x}}{1} +
    \chbfn{2}{0}{\xione}\chbfn{2}{0}{\xitwo}\nodept{\vect{x}}{2} +
    \chbfn{2}{0}{\xitwo}\nodept{\vect{x}}{3} + \\
    & \chbfn{1}{1}{\xione}\chbfn{1}{0}{\xitwo}\delby{\nodept{\vect{x}}{1}}{s_{1}}
    \nsftwo{1}{1}+
    \chbfn{2}{1}{\xione}\chbfn{1}{0}{\xitwo}\delby{\nodept{\vect{x}}{2}}{s_{1}}
    \nsftwo{2}{1} + \\
    & \chbfn{1}{0}{\xione}\chbfn{1}{1}{\xitwo}\delby{\nodept{\vect{x}}{1}}{s_{2}}
    \nsftwo{1}{2}+
    \chbfn{2}{0}{\xione}\chbfn{1}{1}{\xitwo}\delby{\nodept{\vect{x}}{2}}{s_{2}}
    \nsftwo{2}{2} + \\
    & \chbfn{1}{1}{\xione}\chbfn{1}{1}{\xitwo}\deltwoby{\nodept{\vect{x}}{1}}
      {s_{1}}{s_{2}}\nsftwo{1}{1}\nsftwo{1}{2} +
    \chbfn{2}{1}{\xione}\chbfn{1}{1}{\xitwo}\deltwoby{\nodept{\vect{x}}{2}}
      {s_{1}}{s_{2}}\nsftwo{2}{1}\nsftwo{2}{2}
  \end{split}
\end{equation}
with a condition of
\begin{equation}
  \dotprod{\deltwoby{\nodept{\vect{x}}{n}}{s_{1}}{s_{2}}}{\delby{\nodept{\vect{x}}
      {n}}{s_{1}}}>\dfrac{-3}{\nsftwo{n}{2}}
\end{equation}

Although the Hermite-sector basis function in which the $s_{2}$ apex node
derivatives are identically zero have an increased limit on the
cross-derivative constraints (a right hand side numerator of $\pm 3$ instead
of $\pm 2$) they have the problem that as all derivatives vanish at the apex
any interpolated function has a zero Hessian at the apex. As this can cause
numerical problems the Hermite-sector basis functions which have an undefined
$s_{2}$ derivative are prefered.

\subsection{Simplex Basis Functions}

Simplex basis function and its derivatives are evaluated with respect to external $\vect{\xi}$ coordinates.

For Simplex line elements there are two area coordinates which are a function of $\xi_{1}$ \ie
\begin{align}
  L_{1} &= 1 - \xi_{1} \\
  L_{2} &= \xi_{1} - 1
\end{align}

The derivatives wrt to external coordinates are then given by
\begin{align}
  \delby{\vect{\sbfnsymb{}}}{\xi_{1}} &= \delby{\vect{\sbfnsymb{}}}{L_{2}}-\delby{\vect{\sbfnsymb{}}}{L_{1}} \\
  \deltwosqby{\vect{\sbfnsymb{}}}{\xi_{1}} &= \deltwosqby{\vect{\sbfnsymb{}}}{L_{1}}-
  2\deltwoby{\vect{\sbfnsymb{}}}{L_{1}}{L_{2}}+\deltwosqby{\vect{\sbfnsymb{}}}{L_{2}}
\end{align}

For Simplex triangle elements there are three area coordinates which are a function of $\xi_{1}$ and
$\xi_{2}$ \ie
\begin{align}
  L_{1} &= 1 - \xi_{1} \\
  L_{2} &= 1 - \xi_{2} \\
  L_{3} &= \xi_{1} + \xi_{2} - 1
\end{align}

The derivatives wrt to external coordinates are then given by
\begin{align}
  \delby{\vect{\sbfnsymb{}}}{\xi_{1}} &= \delby{\vect{\sbfnsymb{}}}{L_{3}}-\delby{\vect{\sbfnsymb{}}}{L_{1}} \\
  \delby{\vect{\sbfnsymb{}}}{\xi_{2}} &= \delby{\vect{\sbfnsymb{}}}{L_{3}}-\delby{\vect{\sbfnsymb{}}}{L_{2}} \\
  \deltwosqby{\vect{\sbfnsymb{}}}{\xi_{1}} &= \deltwosqby{\vect{\sbfnsymb{}}}{L_{1}}-
  2\deltwoby{\vect{\sbfnsymb{}}}{L_{1}}{L_{3}}+\deltwosqby{\vect{\sbfnsymb{}}}{L_{3}} \\
  \deltwosqby{\vect{\sbfnsymb{}}}{\xi_{2}} &= \deltwosqby{\vect{\sbfnsymb{}}}{L_{2}}-
  2\deltwoby{\vect{\sbfnsymb{}}}{L_{2}}{L_{3}}+\deltwosqby{\vect{\sbfnsymb{}}}{L_{3}} \\
  \deltwoby{\vect{\sbfnsymb{}}}{\xi_{1}}{\xi_{2}} &= \deltwosqby{\vect{\sbfnsymb{}}}{L_{3}}-
  \deltwoby{\vect{\sbfnsymb{}}}{L_{1}}{L_{3}}-\deltwoby{\vect{\sbfnsymb{}}}{L_{2}}{L_{3}}+
  \deltwoby{\vect{\sbfnsymb{}}}{L_{1}}{L_{2}}
\end{align}

For Simplex tetrahedral elements there are four area coordinates which are a
function of $\xi_{1}$, $\xi_{2}$ and $\xi_{3}$ \ie
\begin{align}
  L_{1} &= 1 - \xi_{1} \\
  L_{2} &= 1 - \xi_{2} \\
  L_{3} &= 1 - \xi_{3} \\
  L_{4} &= \xi_{1} + \xi_{2} + \xi_{3} - 2
\end{align}

The derivatives wrt to external coordinates are then given by
\begin{align}
  \delby{\vect{\sbfnsymb{}}}{\xi_{1}} &= \delby{\vect{\sbfnsymb{}}}{L_{4}}-\delby{\vect{\sbfnsymb{}}}{L_{1}} \\
  \delby{\vect{\sbfnsymb{}}}{\xi_{2}} &= \delby{\vect{\sbfnsymb{}}}{L_{4}}-\delby{\vect{\sbfnsymb{}}}{L_{2}} \\
  \delby{\vect{\sbfnsymb{}}}{\xi_{3}} &= \delby{\vect{\sbfnsymb{}}}{L_{4}}-\delby{\vect{\sbfnsymb{}}}{L_{3}} \\
  \deltwosqby{\vect{\sbfnsymb{}}}{\xi_{1}} &= \deltwosqby{\vect{\sbfnsymb{}}}{L_{1}}-
  2\deltwoby{\vect{\sbfnsymb{}}}{L_{1}}{L_{4}}+\deltwosqby{\vect{\sbfnsymb{}}}{L_{4}} \\
  \deltwosqby{\vect{\sbfnsymb{}}}{\xi_{2}} &= \deltwosqby{\vect{\sbfnsymb{}}}{L_{2}}-
  2\deltwoby{\vect{\sbfnsymb{}}}{L_{2}}{L_{4}}+\deltwosqby{\vect{\sbfnsymb{}}}{L_{4}} \\
  \deltwosqby{\vect{\sbfnsymb{}}}{\xi_{3}} &= \deltwosqby{\vect{\sbfnsymb{}}}{L_{3}}-
  2\deltwoby{\vect{\sbfnsymb{}}}{L_{3}}{L_{4}}+\deltwosqby{\vect{\sbfnsymb{}}}{L_{4}} \\
  \deltwoby{\vect{\sbfnsymb{}}}{\xi_{1}}{\xi_{2}} &= \deltwosqby{\vect{\sbfnsymb{}}}{L_{4}}-
  \deltwoby{\vect{\sbfnsymb{}}}{L_{1}}{L_{4}}-\deltwoby{\vect{\sbfnsymb{}}}{L_{2}}{L_{4}}+
  \deltwoby{\vect{\sbfnsymb{}}}{L_{1}}{L_{2}} \\
  \deltwoby{\vect{\sbfnsymb{}}}{\xi_{1}}{\xi_{3}} &= \deltwosqby{\vect{\sbfnsymb{}}}{L_{4}}-
  \deltwoby{\vect{\sbfnsymb{}}}{L_{1}}{L_{4}}-\deltwoby{\vect{\sbfnsymb{}}}{L_{3}}{L_{4}}+
  \deltwoby{\vect{\sbfnsymb{}}}{L_{1}}{L_{3}} \\
  \deltwoby{\vect{\sbfnsymb{}}}{\xi_{2}}{\xi_{3}} &= \deltwosqby{\vect{\sbfnsymb{}}}{L_{4}}-
  \deltwoby{\vect{\sbfnsymb{}}}{L_{2}}{L_{4}}-\deltwoby{\vect{\sbfnsymb{}}}{L_{3}}{L_{4}}+
  \deltwoby{\vect{\sbfnsymb{}}}{L_{2}}{L_{3}} \\
  \delthreeby{\vect{\sbfnsymb{}}}{\xi_{1}}{\xi_{2}}{\xi_{3}} &= \delthreecuby{\vect{\sbfnsymb{}}}{L_{4}}-
  \deldeltwoby{\vect{\sbfnsymb{}}}{L_{1}}{L_{4}}-\deldeltwoby{\vect{\sbfnsymb{}}}{L_{2}}{L_{4}}-
  \deldeltwoby{\vect{\sbfnsymb{}}}{L_{3}}{L_{4}}+ \\
  &\delthreeby{\vect{\sbfnsymb{}}}{L_{1}}{L_{2}}{L_{4}}+\delthreeby{\vect{\sbfnsymb{}}}{L_{1}}{L_{3}}{L_{4}}+
  \delthreeby{\vect{\sbfnsymb{}}}{L_{2}}{L_{3}}{L_{4}}-\delthreeby{\vect{\sbfnsymb{}}}{L_{1}}{L_{2}}{L_{3}}
\end{align}

\section{Tensor Analysis}
\subsection{Base vectors}

Now, if we have a vector, $\vect{v}$ we can write
\begin{equation}
  \vect{v}=v^{i}\vect{g}_{i}
\end{equation}
where $v^{i}$ are the components of the contravariant vector, and
$\vect{g}_{i}$ are the covariant base vectors.

Similarly, the vector $\vect{v}$ can also be written as
\begin{equation}
  \vect{v}=v_{i}\vect{g}^{i}
\end{equation}
where $v_{i}$ are the components of the covariant vector, and
$\vect{g}^{i}$ are the contravariant base vectors.

We now note that
\begin{equation}
  \vect{v}=v^{i}\vect{g}_{i}=v^{i}\sqrt{g_{ii}}\hat{\vect{g}_{i}}
\end{equation}
where $v^{i}\sqrt{g_{ii}}$ are the physical components of the vector and
$\hat{\vect{g}_{i}}$ are the unit vectors given by
\begin{equation}
  \hat{\vect{g}_{i}}=\dfrac{\vect{g}_{i}}{\sqrt{g_{ii}}}
\end{equation}

\subsection{Metric Tensors}
\label{sec:metric tensors}

Metric tensors are the inner product of base vectors. If $\vect{g}_{i}$ are the
covariant base vectors then the covariant metric tensor is given by
\begin{equation}
  g_{ij}=\dotprod{\vect{g}_{i}}{\vect{g}_{j}}
\end{equation}

Similarily if $\vect{g}^{i}$ are the contravariant base vectors then the
contravariant metric tensor is given by
\begin{equation}
  g^{ij}=\dotprod{\vect{g}^{i}}{\vect{g}^{j}}
\end{equation}

We can also form a mixed metric tensor from the dot product of a contravariant
and a covariant base vector \ie
\begin{equation}
  g^{i}_{.j}=\dotprod{\vect{g}^{i}}{\vect{g}_{j}}
\end{equation}
and
\begin{equation}
  g_{i}^{.j}=\dotprod{\vect{g}_{i}}{\vect{g}^{j}}
\end{equation}

Note that for mixed tensors the ``.'' indicates the order of the index \ie
$g^{i}_{.j}$ indicates that the first index is contravariant and the second
index is covariant whereas $g_{i}^{.j}$ indicates that the first index is
covariant and the second index is contravariant.

If the base vectors are all mutually orthogonal and constant then
$\vect{g}_{i}=\vect{g}^{i}$ and $g_{ij}=g^{ij}$.

The metric tensors generalise (Euclidean) distance \ie
\begin{equation}
  ds^{2}=g_{ij}dx^{i}dx^{j}
\end{equation}

Note that multiplying by the covariant metric tensor lowers indices \ie
\begin{equation}
  \begin{split}
    \vect{A}_{i} &= g_{ij}\vect{A}^{j} \\
    A_{ij} &= g_{ik}g_{jl}A^{kl} = g_{jk}A_{i}^{.k} = g_{ik}A^{k}_{.j}
  \end{split}
\end{equation}
and that multiplying by the contravariant metric tensor raises indices \ie
\begin{equation}
  \begin{split}
  \vect{A}^{i} &=  g^{ij}\vect{A}_{j} \\
   A^{ij} &= g^{ik}g^{jl}A_{kl} = g^{ik}A_{k}^{.j} = g^{jk}A^{i}_{.k}
  \end{split}
\end{equation}
and for the mixed tensors
\begin{equation}
  \begin{split}
  A_{i}^{.j} &= g^{jk}A_{ik} = g_{ik}A^{kj} \\
  A^{i}_{.j} &= g^{ik}A_{kj} = g_{jk}A^{ik} \\
  \end{split}
\end{equation}

\subsection{Transformations}

The transformation rules for tensors in going from a $\vect{\nu}$ coordinate
system to a $\vect{\xi}$ coordinate system are as follows:

For a covariant vector (a rank (0,1) tensor)
\begin{equation}
  {\tilde{a}}_{i}=\delby{\nu^{a}}{\xi^{i}}a_{a}
\end{equation}

For a contravariant vector (a rank (1,0) tensor)
\begin{equation}
  {\tilde{a}}^{i}=\delby{\xi^{i}}{\nu^{a}}a^{a}
\end{equation}

For a covariant tensor (a rank (0,2) tensor)
\begin{equation}
  {\tilde{A}}_{ij}=\delby{\nu^{a}}{\xi^{i}}\delby{\nu^{b}}{\xi^{j}}A_{ab}
\end{equation}

For a contravariant tensor (a rank (2,0) tensor)
\begin{equation}
  {\tilde{A}}^{ij}=\delby{\xi^{i}}{\nu^{a}}\delby{\xi^{j}}{\nu^{b}}A^{ab}
\end{equation}

and for Mixed tensors (rank (1,1) tensors)
\begin{equation}
  {\tilde{A}}^{i}_{.j}=\delby{\xi^{i}}{\nu^{a}}\delby{\nu^{b}}{\xi^{j}}A^{a}_{.b}
\end{equation}
and
\begin{equation}
  {\tilde{A}}_{i}^{.j}=\delby{\nu^{a}}{\xi^{i}}\delby{\xi^{j}}{\nu^{b}}A_{a}^{.b}
\end{equation}

\subsection{Derivatives}
\label{subsec:function derivatives}

\subsubsection{Scalars}

We note that a scalar quantity $\fnof{u}{\vect{\xi}}$ has derivatives
\begin{equation}
  \delby{u}{\xi^{i}}=\partialderiv{u}{i}
\end{equation}

Or more formally, the covariant derivative ($\covarderiv{\cdot}{\cdot}$) of a
rank 0 tensor $u$ is
\begin{equation}
  \covarderiv{u}{i}=\delby{u}{\xi^{i}}=\partialderiv{u}{i}
\end{equation}

\subsubsection{Vectors}

The derivatives of a vector $\vect{v}$ are given by
\begin{equation}
  \begin{split}
    \delby{\vect{v}}{\xi^{i}} &=
    \delby{}{\xi^{i}}\pbrac{v^{k}\vect{g}_{k}} \\
    &= \delby{v^{k}}{\xi^{i}}\vect{g}_{k}+v^{k}\delby{\vect{g}_{k}}{\xi^{i}} \\
    &= \partialderiv{v^{k}}{i}\vect{g}_{k}+v^{k}\partialderiv{\vect{g}_{k}}{i}
  \end{split}
\end{equation}

Now introducing the notation
\begin{equation}
  \christoffelsecond{i}{j}{k} = \dotprod{\vect{g}^{i}}{\delby{\vect{g}_{j}}{x^{k}}}
\end{equation}
where $\christoffelsecond{i}{j}{k}$ are the Christoffel symbols of the second
kind.

Note that the Christoffel symbols of the first kind are given by
\begin{equation}
  \christoffelfirst{i}{j}{k} = \dotprod{\vect{g}_{i}}{\delby{\vect{g}_{j}}{x^{k}}}
\end{equation}

Note that
\begin{equation}
  \begin{split}
    \christoffel{i}{j}{k} &= \dotprod{\vect{g}^{i}}{\partialderiv{\vect{g}_{j}}{k}} \\
    &=\dotprod{\vect{g}^{i}}{\christoffelsecond{l}{j}{k}\vect{g}_{l}} \\
    &= \christoffel{i}{j}{l}g^{i}_{.l}
  \end{split}
\end{equation}

The Christoffel symbols of the first kind are also given by
\begin{equation}
  \christoffelfirst{i}{j}{k}=\frac{1}{2}\pbrac{\delby{g_{ij}}{\xi^{k}}+\delby{g_{ik}}{\xi^{j}}-\delby{g_{jk}}{\xi^{i}}}
\end{equation}
and that Christoffel symbols of the second kind are given by
\begin{equation}
  \begin{split}
    \christoffelsecond{i}{j}{k} &= g^{il}\christoffelfirst{l}{j}{k} \\
    &= \frac{1}{2}g^{il}\pbrac{\delby{g_{lj}}{\xi^{k}}+\delby{g_{lk}}{\xi^{j}}-\delby{g_{jk}}{\xi^{l}}}
  \end{split}
\end{equation}

Note that Christoffel symbols are not tensors and the have the following
transformation laws from $\vect{\nu}$ to $\vect{\xi}$ coordinates
\begin{align}
  \christoffelfirst{i}{j}{k} &=
  \christoffelfirst{a}{b}{c}\delby{\nu^{b}}{\xi^{j}}\delby{\nu^{c}}{\xi^{k}}\delby{\nu^{a}}{\xi^{i}}+
  g_{ab}\delby{\nu^{c}}{\xi^{i}}\deltwoby{\nu^{c}}{\xi^{j}}{\xi^{k}} \\
  \christoffelsecond{i}{j}{k} &= \christoffelsecond{a}{b}{c}\delby{\xi^{i}}{\nu^{a}}\delby{\nu^{b}}{\xi^{k}}\delby{\nu^{c}}{\xi^{j}}+
  \delby{\xi^{i}}{\nu^{a}}\deltwoby{\nu^{a}}{\xi^{j}}{\xi^{k}} \\
\end{align}

We can now write (BELOW SEEMS WRONG - CHECK)
\begin{equation}
  \begin{split}
    \partialderiv{\vect{v}}{i}&=\partialderiv{v^{k}}{i}\vect{g}_{k}+\christoffel{k}{i}{j}v^{j}\vect{g}_{j}\\
    &=\partialderiv{v^{k}}{i}\vect{g}_{k}+\christoffel{j}{i}{k}v^{k}\vect{g}_{k}\\
    &=\pbrac{\partialderiv{v^{k}}{i}+\christoffel{j}{i}{k}v^{k}}\vect{g}_{k}\\
    &=\covarderiv{v^{k}}{i}\vect{g}_{k}
  \end{split}
\end{equation}
where $\covarderiv{v^{k}}{i}$ is the covariant derivative of $v^{k}$ .

The covariant derivative of a contravariant (rank (0,1)) tensor $v^{k}$ is
\begin{equation}
  \covarderiv{v^{k}}{i} =\partialderiv{v^{k}}{i}+\christoffel{k}{i}{j}v^{j}
\end{equation}
and the covariant derivative of a covariant tensor  (rank (1,0)) $v_{k}$ is
\begin{equation}
  \covarderiv{v_{k}}{i} =\partialderiv{v_{k}}{i}-\christoffel{j}{k}{i}v_{j}
\end{equation}

\subsubsection{Tensors}

The covariant derivative of a contravariant (rank (0,2)) tensor $W^{mn}$ is
\begin{equation}
  \covarderiv{W^{mn}}{i}=\partialderiv{W^{mn}}{i}+\christoffel{m}{j}{i}W^{jn}+\christoffel{n}{j}{i}W^{mj}
\end{equation}
and the covariant derivative of a covariant (rank (2,0)) tensor $W_{mn}$ is
\begin{equation}
  \covarderiv{W_{mn}}{i}=\partialderiv{W_{mn}}{i}-\christoffel{j}{m}{i}W_{jn}-\christoffel{j}{n}{i}W_{mj}
\end{equation}
and the covariant derivative of a mixed (rank (1,1)) tensor $W^{m}_{.n}$ is
\begin{equation}
  \covarderiv{W^{m}_{.n}}{i}=\partialderiv{W^{m}_{.n}}{i}+\christoffel{m}{j}{i}W^{j}_{.n}-\christoffel{j}{n}{i}W^{m}_{.j}
\end{equation}

\subsection{Common Operators}

For tensor equations to hold in any coordinate system the equations must
involve tensor quantities \ie covariant derivatives rather than partial derivatives.

\subsubsection{Gradient}

As the covariant derivative of a scalar is just the partial derivative the
gradient of a scalar function $\phi$ using covariant derivatives is
\begin{equation}
  \text{grad } \phi = \gradient{\phi}=\covarderiv{\phi}{i}\vect{g}^{i}=\partialderiv{\phi}{i}\vect{g}^{i}
\end{equation}
and
\begin{equation}
  \gradient{\phi}=\partialderiv{\phi}{i}\vect{g}^{i}=\partialderiv{\phi}{i}g^{ij}\vect{g}_{j}
\end{equation}

\subsubsection{Divergence}

The divergence of a vector using covariant derivatives is
\begin{equation}
  \text{div } \vect{\phi} = \diverg{\vect{\phi}}=\covarderiv{\phi^{i}}{i}=\frac{1}{\sqrt{\abs{g}}}\partialderiv{\pbrac{\sqrt{\abs{g}}\phi^{i}}}{i}
\end{equation}
where $g$ is the determinant of the covariant metric tensor $g_{ij}$.

\subsubsection{Curl}

The curl of a vector using covariant derivatives is
\begin{equation}
  \text{curl } \vect{\phi} = \curl{\vect{\phi}}=\frac{1}{\sqrt{g}}\pbrac{\covarderiv{\phi_{j}}{i}-\covarderiv{\phi_{i}}{j}}\vect{g}_{k}
\end{equation}
where $g$ is the determinant of the covariant metric tensor $g_{ij}$.

\subsubsection{Laplacian}

The Laplacian of a scalar using covariant derivatives is
\begin{equation}
  \laplacian{\phi}=\text{div}\pbrac{\text{grad }\phi}=\diverg{\gradient{\phi}}=\mixedderiv{\phi}{i}{i}=\frac{1}{\sqrt{g}}\partialderiv{\pbrac{\sqrt{g}g^{ij}\partialderiv{\phi}{j}}}{i}
\end{equation}
where $g$ is the determinant of the covariant metric tensor $g_{ij}$.

The Laplacian of a vector using covariant derivatives is
\begin{equation}
  \laplacian{\vect{\phi}}=\text{grad }\pbrac{\text{div }\vect{\phi}}-\text{curl } \pbrac{\text{curl }\vect{\phi}}==\mixedderiv{\vect{\phi}}{i}{i}
\end{equation}

The Laplacian of a contravariant (rank (0,1)) tensor $\phi^{k}$ is
\begin{equation}
  \laplacian{\vect{\phi}}=\pbrac{\laplacian{\phi_{k}}-2g^{ij}\christoffel{K}{j}{H}\delby{\phi^{h}}{x^{i}}+\phi^{h}\delby{g^{ij}\christoffel{K}{i}{j}}{x^{h}}}\vect{e}^{k}
\end{equation}
and the covariant derivative of a covariant tensor  (rank (1,0)) $\phi_{k}$ is
\begin{equation}
  \laplacian{\vect{\phi}}=\pbrac{\laplacian{\phi_{k}}-2g^{ij}\christoffel{h}{j}{k}\delby{\phi_{h}}{x^{i}}+\phi_{h}g^{ij}\delby{\christoffel{h}{i}{j}}{x^{i}}}\vect{e}_{k}
\end{equation}

\subsection{Coordinate Systems}
\label{sec:coordinate systems}

\subsubsection{Rectangular Cartesian}

The base vectors with respect to the global coordinate system are
\begin{equation}
  \vect{g}_{i}=\begin{bmatrix}
    \vect{i}_{1} \\
    \vect{i}_{2} \\
    \vect{i}_{3}
  \end{bmatrix}
\end{equation}

The covariant metric tensor is
\begin{equation}
  g_{ij}=\begin{bmatrix}
    1 & 0 & 0 \\
    0 & 1 & 0 \\
    0 & 0 & 1
  \end{bmatrix}
\end{equation}
and the contravariant metric tensor is
\begin{equation}
  g^{ij}=\begin{bmatrix}
    1 & 0 & 0 \\
    0 & 1 & 0 \\
    0 & 0 & 1
  \end{bmatrix}
\end{equation}

The Christoffel symbols of the second kind are all zero.

\subsubsection{Cylindrical Polar}

The global coordinates  $\pbrac{x,y,z}$ with respect to the cylindrical polar
coordinates $\pbrac{r,\theta,z}$ are defined by
\begin{equation}
  \begin{aligned}
    x = r\cos\theta  & \qquad r \ge0 \\
    y = r\sin\theta & \qquad 0 \le\theta\le2\pi \\
    z = z          & \qquad -\infty < z < \infty
  \end{aligned}
\end{equation}

The base vectors with respect to the global coordinate system are
\begin{equation}
  \vect{g}_{i}=\begin{bmatrix}
    \cos\theta\vect{i}_{1} + \sin\theta\vect{i}_{2} \\
    -r\sin\theta\vect{i}_{1}+ r\cos\theta\vect{i}_{2} \\
    \vect{i}_{3}
  \end{bmatrix}
\end{equation}

The covariant metric tensor is
\begin{equation}
  g_{ij}=\begin{bmatrix}
    1 & 0 & 0 \\
    0 & r^{2} & 0 \\
    0 & 0 & 1
  \end{bmatrix}
\end{equation}
and the contravariant metric tensor is
\begin{equation}
  g^{ij}=\begin{bmatrix}
    1 & 0 & 0 \\
    0 & \frac{1}{r^{2}} & 0 \\
    0 & 0 & 1
  \end{bmatrix}
\end{equation}

The Christoffell symbols of the second kind are
\begin{align}
  \christoffelsecond{r}{\theta}{\theta}&=-r \\
  \christoffelsecond{\theta}{r}{\theta}=\christoffelsecond{\theta}{\theta}{r}&=\frac{1}{r}
\end{align}
with all other Christoffell symbols zero.

\subsubsection{Spherical Polar}

The global coordinates $\pbrac{x,y,z}$ with respect to the cylindrical polar
coordinates $\pbrac{r,\theta,\phi}$ are defined by
\begin{equation}
  \begin{aligned}
    x = r\cos\theta\sin\phi & \qquad r \ge 0 \\
    y = r\sin\theta\sin\phi & \qquad 0 \le \theta \le 2\pi \\
    z = r\cos\phi & \qquad 0 \le \phi \le \pi
  \end{aligned}
\end{equation}

The base vectors with respect to the spherical polar coordinate system are
\begin{equation}
  \vect{g}_{i}=\begin{bmatrix}
    \cos\theta\sin\phi\vect{i}_{1}+\sin\theta\sin\phi\vect{i}_{2}+\cos\phi\vect{i}_{3} \\
    -r\sin\theta\sin\phi\vect{i}_{1}+r\cos\theta\sin\phi\vect{i}_{2} \\
    r\cos\theta\cos\phi\vect{i}_{1}+r\sin\theta\cos\phi\vect{i}_{2}-r\sin\phi\vect{i}_{3}
  \end{bmatrix}
\end{equation}

The covariant metric tensor is
\begin{equation}
  g_{ij}=\begin{bmatrix}
    1 & 0 & 0 \\
    0 & r^{2}\sin^{2}\phi & 0 \\
    0 & 0 & r^{2}
  \end{bmatrix}
\end{equation}
and the contravariant metric tensor is
\begin{equation}
  g^{ij}=\begin{bmatrix}
    1 & 0 & 0 \\
    0 &  \frac{1}{r^{2}\sin^{2}\phi} & 0 \\
    0 & 0 & \frac{1}{r^{2}}
  \end{bmatrix}
\end{equation}

The Christoffell symbols of the second kind are
\begin{align}
  \christoffelsecond{r}{\theta}{\theta}&=-r\sin^{2}\phi \\
  \christoffelsecond{r}{\phi}{\phi}&=-r \\
  \christoffelsecond{\phi}{\theta}{\theta}&=-\sin\phi\cos\phi \\
  \christoffelsecond{\theta}{r}{\theta}=\christoffelsecond{\theta}{\theta}{r}&=\frac{1}{r} \\
  \christoffelsecond{\phi}{r}{\phi}=\christoffelsecond{\phi}{\phi}{r}&=\frac{1}{r} \\
  \christoffelsecond{\theta}{\theta}{\phi}=\christoffelsecond{\theta}{\phi}{\theta}&=\cot\phi
\end{align}
with all other Christofell symbols zero.

\subsubsection{Prolate Spheroidal}

The global coordinates $\pbrac{x,y,z}$ with respect to the prolate spheroidal
coordinates $\pbrac{\lambda,\mu,\theta}$ are defined by
\begin{equation}
  \begin{aligned}
    x = a\sinh\lambda\sin\mu\cos\theta & \qquad \lambda \ge 0 \\
    y = a\sinh\lambda\sin\mu\sin\theta & \qquad 0 \le \mu \le \pi \\
    z = a\cosh\lambda\cos\mu & \qquad 0 \le \theta \le 2\pi
  \end{aligned}
\end{equation}
where $a\ge0$ is the focus.

The base vectors with respect to the global coordinate system are
\begin{equation}
  \vect{g}_{i}=\begin{bmatrix}
    a\cosh\lambda\sin\mu\cos\theta\vect{i}_{1}+a\cosh\lambda\sin\mu\sin\theta\vect{i}_{2}+a\sinh\lambda\cos\mu\vect{i}_{3}\\
    a\sinh\lambda\cos\mu\cos\theta\vect{i}_{1}+a\sinh\lambda\cos\mu\sin\theta\vect{i}_{2}-a\cosh\lambda\sin\mu\vect{i}_{3}\\
    -a\sinh\lambda\sin\mu\sin\theta\vect{i}_{1}+a\sinh\lambda\sin\mu\cos\theta\vect{i}_{2}
  \end{bmatrix}
\end{equation}

The covariant metric tensor is
\begin{equation}
  g_{ij}=\begin{bmatrix}
    a^{2}\pbrac{\sinh^{2}\lambda+\sin^{2}\mu} & 0 & 0 \\
    0 & a^{2}\pbrac{\sinh^{2}\lambda+\sin^{2}\mu} & 0 \\
    0 & 0 & a^{2}\sinh^{2}\lambda\sin^{2}\mu
  \end{bmatrix}
\end{equation}
and the contravariant metric tensor is
\begin{equation}
  g^{ij}=\begin{bmatrix}
    \frac{1}{a^{2}\pbrac{\sinh^{2}\lambda+\sin^{2}\mu}}& 0 & 0 \\
    0 & \frac{1}{a^{2}\pbrac{\sinh^{2}\lambda+\sin^{2}\mu}} & 0 \\
    0 & 0 & \frac{1}{a^{2}\sinh^{2}\lambda\sin^{2}\mu}
  \end{bmatrix}
\end{equation}

The Christoffell symbols of the second kind are
\begin{align}
  \christoffelsecond{\lambda}{\lambda}{\lambda}&=\frac{\sinh\lambda\cosh\lambda}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\lambda}{\mu}{\mu}&=\frac{-\sinh\lambda\cosh\lambda}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\lambda}{\theta}{\theta}&=\frac{-\sinh\lambda\cosh\lambda\sin^{2}\mu}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\lambda}{\lambda}{\mu}&=\frac{\sin\mu\cos\mu}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\mu}{\mu}{\mu}&=\frac{\sin\mu\cos\mu}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\mu}{\lambda}{\lambda}&=\frac{-\sin\mu\cos\mu}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\mu}{\theta}{\theta}&=\frac{-\sinh^{2}\lambda\sin\mu\cos\mu}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\mu}{\mu}{\lambda}&=\frac{\sinh\lambda\cosh\lambda}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\theta}{\theta}{\lambda}&=\frac{\cosh\lambda}{\sinh\lambda} \\
  \christoffelsecond{\theta}{\theta}{\mu}&=\frac{\cos\mu}{\sin\mu} \\
 \end{align}
with all other Christofell symbols zero.

\subsubsection{Oblate Spheroidal}

The global coordinates $\pbrac{x,y,z}$ with respect to the oblate spheroidal
coordinates $\pbrac{\lambda,\mu,\theta}$  are defined by
\begin{equation}
  \begin{aligned}
    x = a\cosh\lambda\cos\mu\cos\theta & \qquad \lambda \ge 0 \\
    y = a\cosh\lambda\cos\mu\sin\theta & \qquad \frac{-\pi}{2} \le \mu \le \frac{\pi}{2} \\
    z = a\sinh\lambda\sin\mu & \qquad 0 \le \theta \le 2\pi
  \end{aligned}
\end{equation}
where $a\ge0$ is the focus.

The base vectors with respect to the global coordinate system are
\begin{equation}
  \vect{g}_{i}=\begin{bmatrix}
    a\sinh\lambda\cos\mu\cos\theta\vect{i}_{1}+a\sinh\lambda\cos\mu\sin\theta\vect{i}_{2}+a\cosh\lambda\sin\mu\vect{i}_{3}\\
    -a\cosh\lambda\sin\mu\cos\theta\vect{i}_{1}-a\cosh\lambda\sin\mu\sin\theta\vect{i}_{2}+a\sinh\lambda\cos\mu\vect{i}_{3}\\
    -a\cosh\lambda\cos\mu\sin\theta\vect{i}_{1}+a\cosh\lambda\cos\mu\cos\theta\vect{i}_{2}
  \end{bmatrix}
\end{equation}

The covariant metric tensor is
\begin{equation}
  g_{ij}=\begin{bmatrix}
    a^{2}\pbrac{\sinh^{2}\lambda+\sin^{2}\mu} & 0 & 0 \\
    0 & a^{2}\pbrac{\sinh^{2}\lambda+\sin^{2}\mu} & 0 \\
    0 & 0 & a^{2}\cosh^{2}\lambda\cos^{2}\mu
  \end{bmatrix}
\end{equation}
and the contravariant metric tensor is
\begin{equation}
  g^{ij}=\begin{bmatrix}
    \frac{1}{a^{2}\pbrac{\sinh^{2}\lambda+\sin^{2}\mu}}& 0 & 0 \\
    0 & \frac{1}{a^{2}\pbrac{\sinh^{2}\lambda+\sin^{2}\mu}} & 0 \\
    0 & 0 & \frac{1}{a^{2}\cosh^{2}\lambda\cos^{2}\mu}
  \end{bmatrix}
\end{equation}

The Christoffell symbols of the second kind are
\begin{align}
  \christoffelsecond{\lambda}{\lambda}{\lambda}&=\frac{\sinh\lambda\cosh\lambda}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\lambda}{\mu}{\mu}&=\frac{-\sinh\lambda\cosh\lambda}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\lambda}{\theta}{\theta}&=\frac{-\sinh\lambda\cosh\lambda\cos^{2}\mu}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\lambda}{\lambda}{\mu}&=\frac{\sin\mu\cos\mu}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\mu}{\mu}{\mu}&=\frac{\sin\mu\cos\mu}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\mu}{\lambda}{\lambda}&=\frac{-\sin\mu\cos\mu}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\mu}{\theta}{\theta}&=\frac{\cosh^{2}\lambda\sin\mu\cos\mu}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\mu}{\mu}{\lambda}&=\frac{\sinh\lambda\cosh\lambda}{\sinh^{2}\lambda+\sin^{2}\mu} \\
  \christoffelsecond{\theta}{\theta}{\lambda}&=\frac{\sinh\lambda}{\cosh\lambda} \\
  \christoffelsecond{\theta}{\theta}{\mu}&=\frac{-\sin\mu}{\cos\mu} \\
\end{align}
with all other Christofell symbols zero.

\subsubsection{Cylindrical parabolic}

The global coordinates $\pbrac{x,y,z}$ with respect to the cylindrical parabolic
coordinates $\pbrac{\xi,\eta,z}$  are defined by
\begin{equation}
  \begin{aligned}
    x = \xi\eta & \qquad -\infty < \xi < \infty \\
    y = \frac{1}{2}\pbrac{\xi^{2}-\eta^{2}} & \qquad \eta \ge 0 \\
    z =  z & \qquad -\infty < z < \infty
  \end{aligned}
\end{equation}

The base vectors with respect to the global coordinate system are
\begin{equation}
  \vect{g}_{i}=\begin{bmatrix}
    \eta\vect{i}_{1}+\xi\vect{i}_{2}\\
    \xi\vect{i}_{1}-\eta\vect{i}_{2}\\
    \vect{i}_{3}
  \end{bmatrix}
\end{equation}

The covariant metric tensor is
\begin{equation}
  g_{ij}=\begin{bmatrix}
    \xi^{2}+\eta^{2} & 0 & 0 \\
    0 & \xi^{2}+\eta^{2} & 0 \\
    0 & 0 & 1
  \end{bmatrix}
\end{equation}
and the contravariant metric tensor is
\begin{equation}
  g^{ij}=\begin{bmatrix}
    \frac{1}{\xi^{2}+\eta^{2}}& 0 & 0 \\
    0 & \frac{1}{\xi^{2}+\eta^{2}} & 0 \\
    0 & 0 & 1
  \end{bmatrix}
\end{equation}

The Christoffell symbols of the second kind are
\begin{align}
  \christoffelsecond{\xi}{\xi}{\xi}&=\frac{\xi}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\eta}{\eta}{\eta}&=\frac{\eta}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\eta}{\xi}{\xi}&=\frac{-\eta}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\xi}{\eta}{\eta}&=\frac{-\xi}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\xi}{\xi}{\eta}=\christoffelsecond{\xi}{\eta}{\xi}&=\frac{\eta}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\eta}{\xi}{\eta}=\christoffelsecond{\eta}{\eta}{\xi}&=\frac{\xi}{\xi^{2}+\eta^{2}} \\
\end{align}
with all other Christofell symbols zero.

\subsubsection{Parabolic polar}

The global coordinates $\pbrac{x,y,z}$ with respect to the cylindrical parabolic
coordinates $\pbrac{\xi,\eta,\theta}$  are defined by
\begin{equation}
  \begin{aligned}
    x = \xi\eta\cos\theta & \qquad \xi \ge 0 \\
    y = \xi\eta\sin\theta & \qquad \eta \ge 0 \\
    z = \frac{1}{2}\pbrac{\xi^{2}-\eta^{2}} & \qquad 0 \le \theta < 2\pi
  \end{aligned}
\end{equation}

The base vectors with respect to the global coordinate system are
\begin{equation}
  \vect{g}_{i}=\begin{bmatrix}
    \eta\cos\theta\vect{i}_{1}+\eta\sin\theta\vect{i}_{3}+\xi\vect{i}_{3}\\
    \xi\cos\theta\vect{i}_{1}+\xi\sin\theta\vect{i}_{3}-\eta\vect{i}_{3}\\
    -\xi\eta\sin\theta\vect{i}_{1}+\xi\eta\cos\theta\vect{i}_{2}
  \end{bmatrix}
\end{equation}

The covariant metric tensor is
\begin{equation}
  g_{ij}=\begin{bmatrix}
    \xi^{2}+\eta^{2} & 0 & 0 \\
    0 & \xi^{2}+\eta^{2} & 0 \\
    0 & 0 & \xi\eta
  \end{bmatrix}
\end{equation}
and the contravariant metric tensor is
\begin{equation}
  g^{ij}=\begin{bmatrix}
    \frac{1}{\xi^{2}+\eta^{2}}& 0 & 0 \\
    0 & \frac{1}{\xi^{2}+\eta^{2}} & 0 \\
    0 & 0 & \frac{1}{\xi\eta}
  \end{bmatrix}
\end{equation}

The Christoffell symbols of the second kind are
\begin{align}
  \christoffelsecond{\xi}{\xi}{\xi}&=\frac{\xi}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\eta}{\eta}{\eta}&=\frac{\eta}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\xi}{\eta}{\eta}&=\frac{-\xi}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\eta}{\xi}{\xi}&=\frac{-\eta}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\eta}{\theta}{\theta}&=\frac{-\xi^{2}\eta}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\xi}{\theta}{\theta}&=\frac{-\xi\eta^{2}}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\xi}{\xi}{\eta}=\christoffelsecond{\xi}{\eta}{\xi}&=\frac{\eta}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\eta}{\xi}{\eta}=\christoffelsecond{\eta}{\eta}{\xi}&=\frac{\xi}{\xi^{2}+\eta^{2}} \\
  \christoffelsecond{\theta}{\xi}{\theta}=\christoffelsecond{\theta}{\theta}{\xi}&=\frac{1}{\xi} \\
  \christoffelsecond{\theta}{\eta}{\theta}=\christoffelsecond{\theta}{\theta}{\eta}&=\frac{1}{\eta} \\
\end{align}
with all other Christofell symbols zero.

\section{Equation set types}

\subsection{Static Equations}

The general form for static equations is

\subsection{Dynamic Equations}

The general form for dynamic equations is
\begin{equation}
  \matr{M}\fnof{\ddot{\vect{u}}}{t}+\matr{C}\fnof{\dot{\vect{u}}}{t}+\matr{K}\fnof{\vect{u}}{t}+
  \fnof{\vect{g}}{\fnof{\vect{u}}{t}}+\fnof{\vect{f}}{t}=\vect{0}
  \label{eqn:generaldynamicnonlinear}
\end{equation}
where $\fnof{\vect{u}}{t}$ is the unknown ``displacement vector'', $\matr{M}$
is the mass matrix, $\matr{C}$ is the damping matrix, $\matr{K}$ is the
stiffness matrix, $\fnof{\vect{g}}{\fnof{\vect{u}}{t}}$ a non-linear vector
function and $\fnof{\vect{f}}{t}$ the forcing vector.

From \cite{zienkiewicz:2006_1} we now expand the unknown vector $\fnof{\vect{u}}{t}$ in terms of a polynomial of degree
$p$. With the known values of $\vect{u}_{n}$, $\dot{\vect{u}}_{n}$,
$\ddot{\vect{u}}_{n}$ up to $\symover{p-1}{\vect{u}}_{n}$ at the beginning of
the time step $\Delta t$ we can write the polynomial expansion as
\begin{equation}
  \fnof{\vect{u}}{t_{n}+\tau}\approx\fnof{\tilde{\vect{u}}}{t_{n}+\tau}=\vect{u}_{n}+\tau\dot{\vect{u}}_{n}+
  \frac{1}{2!}\tau^{2}\ddot{\vect{u}}_{n}+\cdots+\dfrac{1}{\factorial{p-1}}\tau^{p-1}\symover{p-1}{\vect{u}}_{n}+
  \dfrac{1}{p!}\tau^{p}\vect{\alpha}^{p}_{n}
  \label{eqn:timepolyexpansion}
\end{equation}
where the only unknown is the the vector $\vect{\alpha}^{p}_{n}$,
\begin{equation}
  \vect{\alpha}^{p}_{n}\approx\symover{p}{\vect{u}}\equiv\dnby{p}{\vect{u}}{t}
\end{equation}

A recurrance relationship can be established by substituting
\eqnref{eqn:timepolyexpansion} into \eqnref{eqn:generaldynamicnonlinear} and
taking a weighted residual approach \ie
\begin{multline}
  \dintl{0}{\Delta
    t}\fnof{W}{\tau}\left[\matr{M}\pbrac{\ddot{\vect{u}}_{n}+\tau\dddot{\vect{u}}_{n}+\cdots+
    \dfrac{1}{\factorial{p-2}}\tau^{p-2}\vect{\alpha}^{p}_{n}} \right.\\
  +\matr{C}\pbrac{\dot{\vect{u}}_{n}+\tau\ddot{\vect{u}}_{n}+\cdots+
    \dfrac{1}{\factorial{p-1}}\tau^{p-1}\vect{\alpha}^{p}_{n}} \\
  +\matr{K}\pbrac{\vect{u}_{n}+\tau\dot{\vect{u}}_{n}+\cdots+
    \dfrac{1}{p!}\tau^{p}\vect{\alpha}^{p}_{n}} \\
  +\left.\fnof{\vect{g}}{\vect{u}_{n}+\tau\dot{\vect{u}}_{n}+\cdots+
    \dfrac{1}{p!}\tau^{p}\vect{\alpha}^{p}_{n}}+\fnof{\vect{f}}{t_{n}+\tau}\right] d\tau = \vect{0}
\end{multline}
where $\fnof{W}{\tau}$ is some weight function, $\tau=t-t_{n}$ and $\Delta
t=t_{n+1}-t_{n}$. Dividing by $\gint{0}{\Delta t}{\fnof{W}{\tau}}{\tau}$ we obtain
\begin{multline}
  \dfrac{\gint{0}{\Delta t}{\fnof{W}{\tau}\matr{M}\pbrac{\ddot{\vect{u}}_{n}+\tau\dddot{\vect{u}}_{n}+\cdots+
        \dfrac{1}{\factorial{p-2}}\tau^{p-2}\vect{\alpha}^{p}_{n}}}{\tau}}{\gint{0}{\Delta
      t}{\fnof{W}{\tau}}{\tau}} \\
  + \dfrac{\gint{0}{\Delta t}{\fnof{W}{\tau}\matr{C}\pbrac{\dot{\vect{u}}_{n}+\tau\ddot{\vect{u}}_{n}+\cdots+
        \dfrac{1}{\factorial{p-1}}\tau^{p-1}\vect{\alpha}^{p}_{n}}}{\tau}}{\gint{0}{\Delta
      t}{\fnof{W}{\tau}}{\tau}} \\
  + \dfrac{\gint{0}{\Delta t}{\fnof{W}{\tau}\matr{K}\pbrac{\vect{u}_{n}+\tau\dot{\vect{u}}_{n}+\cdots+
        \dfrac{1}{p!}\tau^{p}\vect{\alpha}^{p}_{n}}}{\tau}}{\gint{0}{\Delta
      t}{\fnof{W}{\tau}}{\tau}} \\
  + \dfrac{\gint{0}{\Delta t}{\fnof{W}{\tau}\fnof{\vect{g}}{\vect{u}_{n}+\tau\dot{\vect{u}}_{n}+\cdots+
        \dfrac{1}{p!}\tau^{p}\vect{\alpha}^{p}_{n}}}{\tau}}{\gint{0}{\Delta
      t}{\fnof{W}{\tau}}{\tau}}
  + \dfrac{\gint{0}{\Delta t}{\fnof{W}{\tau}\fnof{\vect{f}}{t_{n}+
        \tau}}{\tau}}{\gint{0}{\Delta t}{\fnof{W}{\tau}}{\tau}}=\vect{0}
\end{multline}

Now if
\begin{equation}
  \theta_{k}=\dfrac{\gint{0}{\Delta t}{\fnof{W}{\tau}\tau^{k}}{\tau}}{{\Delta
      t}^{k}\gint{0}{\Delta t}{\fnof{W}{\tau}}{\tau}} \text{  for  } k=0,1,\ldots,p
\end{equation}
and
\begin{equation}
  \bar{\vect{f}}=\dfrac{\gint{0}{\Delta
      t}{\fnof{W}{\tau}\fnof{\vect{f}}{t_{n}+\tau}}{\tau}}{
    \gint{0}{\Delta t}{\fnof{W}{\tau}}{\tau}}
  \label{eqn:meanweightedloadvector}
\end{equation}
we can write
\begin{multline}
  \matr{M}\pbrac{\ddot{\bar{\vect{u}}}_{n+1}+\dfrac{\theta_{p-2}{\Delta
        t}^{p-2}}{\factorial{p-2}}\vect{\alpha}^{p}_{n}}+
  \matr{C}\pbrac{\dot{\bar{\vect{u}}}_{n+1}+\dfrac{\theta_{p-1}{\Delta
        t}^{p-1}}{\factorial{p-1}}\vect{\alpha}^{p}_{n}}+
  \matr{K}\pbrac{\bar{\vect{u}}_{n+1}+\dfrac{\theta_{p}{\Delta
        t}^{p}}{p!}\vect{\alpha}^{p}_{n}}+ \\
  + \dfrac{\gint{0}{\Delta t}{\fnof{W}{\tau}\fnof{\vect{g}}{\vect{u}_{n}+\tau\dot{\vect{u}}_{n}+\cdots+
        \dfrac{1}{p!}\tau^{p}\vect{\alpha}^{p}_{n}}}{\tau}}{\gint{0}{\Delta
      t}{\fnof{W}{\tau}}{\tau}}+\bar{\vect{f}}=\vect{0}
  \label{eqn:dynamic1}
\end{multline}
where
\begin{equation}
  \begin{split}
    \bar{\vect{u}}_{n+1} &= \gsum{q=0}{p-1}{\dfrac{\theta_{q}{\Delta
            t}^{q}}{q!}\symover{q}{\vect{u}}_{n}} \\
    \dot{\bar{\vect{u}}}_{n+1} &= \gsum{q=1}{p-1}{\dfrac{\theta_{q-1}{\Delta
            t}^{q-1}}{\factorial{q-1}}\symover{q}{\vect{u}}_{n}} \\
    \ddot{\bar{\vect{u}}}_{n+1} &= \gsum{q=2}{p-1}{\dfrac{\theta_{q-2}{\Delta
            t}^{q-2}}{\factorial{q-2}}\symover{q}{\vect{u}}_{n}}
  \end{split}
\end{equation}

We note that as $\fnof{\vect{g}}{\fnof{\vect{u}}{t}}$ is nonlinear we need to
evaluate an integral of the form
\begin{equation}
  \gint{0}{\Delta t}{\fnof{W}{\tau}\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n}+\tau}}}{\tau}
\end{equation}

To do this we form Taylor's series expansions for
$\fnof{\vect{g}}{\fnof{\vect{u}}{t}}$ about the point $\fnof{\vect{u}}{t_{n}+\tau}$ \ie
\begin{equation}
  \fnof{\vect{g}}{\fnof{\vect{u}}{t_{n}}}=\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n}+\tau}}-
  \tau\delby{\fnof{\vect{g}}{\fnof{\vect{u}}{t}}}{\vect{u}}\evalat{\delby{\fnof{\vect{u}}{t}}{t}}{t_{n}+\tau}
  + \orderof{\tau^{2}}
  \label{eqn:firstTaylorexpansion}
\end{equation}
and
\begin{equation}
  \fnof{\vect{g}}{\fnof{\vect{u}}{t_{n+1}}}=\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n}+\tau}}+
  \pbrac{t_{n+1}-t_{n}-\tau}\delby{\fnof{\vect{g}}{\fnof{\vect{u}}{t}}}{\vect{u}}
  \evalat{\delby{\fnof{\vect{u}}{t}}{t}}{t_{n}+\tau}+ \orderof{\tau^{2}}
  \label{eqn:secondTaylorexpansion}
\end{equation}

Now if we add $\dfrac{1}{\tau}$ times \eqnref{eqn:firstTaylorexpansion} and
$\dfrac{1}{t_{n+1}-t_{n}-\tau}=\dfrac{1}{\Delta t-\tau}$ times
\eqnref{eqn:secondTaylorexpansion} we obtain
\begin{equation}
  \dfrac{\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n}}}}{\tau}+\dfrac{\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n+1}}}}{\Delta
    t-\tau}=\pbrac{\dfrac{\Delta t}{\tau\pbrac{\Delta t-\tau}}}\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n}+\tau}}+
  \pbrac{\dfrac{\Delta t}{\tau\pbrac{\Delta t-\tau}}}\orderof{\tau^{2}}
\end{equation}

Multiplying through by $\dfrac{\tau\pbrac{\Delta t-\tau}}{\Delta t}$ gives
\begin{equation}
  \dfrac{\Delta t-\tau}{\Delta t}\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n}}}+
  \dfrac{\tau}{\Delta t}\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n+1}}}=
  \fnof{\vect{g}}{\fnof{\vect{u}}{t_{n}+\tau}}+\orderof{\tau^{2}}
\end{equation}

Therefore
\begin{equation}
  \dfrac{\gint{0}{\Delta t}{\fnof{W}{\tau}\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n}+\tau}}}{\tau}}
  {\gint{0}{\Delta t}{\fnof{W}{\tau}}{\tau}}=\dfrac{\gint{0}{\Delta t}{\fnof{W}{\tau}
      \pbrac{\dfrac{\Delta t-\tau}{\Delta t}\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n}}}+
        \dfrac{\tau}{\Delta t}\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n+1}}}+\orderof{\tau^{2}}}}{\tau}}
  {\gint{0}{\Delta t}{\fnof{W}{\tau}}{\tau}}
\end{equation}

Now if we recall that
\begin{equation}
\theta_{1}=\dfrac{\gint{0}{\Delta t}{\fnof{W}{\tau}\tau}{\tau}}{\Delta t\gint{0}{\Delta t}{\fnof{W}{\tau}}{\tau}}
\end{equation}
we can write
\begin{equation}
  \dfrac{\gint{0}{\Delta t}{\fnof{W}{\tau}\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n+1}}}}{\tau}}
  {\gint{0}{\Delta t}{\fnof{W}{\tau}}{\tau}}=\pbrac{1-\theta_{1}}\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n}}}+
  \theta_{1}\fnof{\vect{g}}{\fnof{\vect{u}}{t_{n+1}}}+\text{Error}
\end{equation}
where
\begin{equation}
  \text{Error}=\dfrac{\gint{0}{\Delta t}{\fnof{W}{\tau}\orderof{\tau^{2}}}{\tau}}{
    \gint{0}{\Delta t}{\fnof{W}{\tau}}{\tau}}
\end{equation}

\Eqnref{eqn:dynamic1} now becomes
\begin{multline}
  \matr{M}\pbrac{\ddot{\bar{\vect{u}}}_{n+1}+\dfrac{\theta_{p-2}{\Delta
        t}^{p-2}}{\factorial{p-2}}\vect{\alpha}^{p}_{n}}+
  \matr{C}\pbrac{\dot{\bar{\vect{u}}}_{n+1}+\dfrac{\theta_{p-1}{\Delta
        t}^{p-1}}{\factorial{p-1}}\vect{\alpha}^{p}_{n}}\\
  +\matr{K}\pbrac{\bar{\vect{u}}_{n+1}+\dfrac{\theta_{p}{\Delta
        t}^{p}}{p!}\vect{\alpha}^{p}_{n}}+
  \pbrac{1-\theta_{1}}\fnof{\vect{g}}{\vect{u}_{n}}+\theta_{1}\fnof{\vect{g}}{\vect{u}_{n+1}}+\bar{\vect{f}}+
  \text{Error}=\vect{0}
  \label{eqn:dynamic2}
\end{multline}
as $\fnof{\vect{u}}{t_{n}}=\vect{u}_{n}$ and
$\fnof{\vect{u}}{t_{n+1}}=\vect{u}_{n+1}=\hat{\vect{u}}_{n+1}+
\dfrac{{\Delta t}^{p}}{p!}\vect{\alpha}^{p}_{n}$ where $\hat{\vect{u}}_{n+1}$
is the \emph{predicted displacement} at the new time step and is given by
\begin{equation}
  \hat{\vect{u}}_{n+1}=\gsum{q=0}{p-1}{\dfrac{{\Delta
        t}^{q}}{q!}\symover{q}{\vect{u}}_{n}}
\end{equation}

Rearranging gives
\begin{multline}
  \fnof{\vect{\psi}}{\vect{\alpha}^{p}_{n}}=\pbrac{\dfrac{\theta_{p-2}{\Delta
        t}^{p-2}}{\factorial{p-2}}\matr{M}+\dfrac{\theta_{p-1}{\Delta
        t}^{p-1}}{\factorial{p-1}}\matr{C}+\dfrac{\theta_{p}{\Delta
        t}^{p}}{p!}\matr{K}}\vect{\alpha}^{p}_{n}+\theta_{1}\fnof{\vect{g}}{\hat{\vect{u}}_{n+1}+
    \dfrac{{\Delta t}^{p}}{p!}\vect{\alpha}^{p}_{n}} \\
  +\pbrac{1-\theta_{1}}\fnof{\vect{g}}{\vect{u}_{n}}+
  \pbrac{\matr{M}\ddot{\bar{\vect{u}}}_{n+1}+\matr{C}\dot{\bar{\vect{u}}}_{n+1}+\matr{K}\bar{\vect{u}}_{n+1}+
    \bar{\vect{f}}}= \vect{0}
  \label{eqn:dynamic}
\end{multline}
or
\begin{equation}
\fnof{\vect{\psi}}{\vect{\alpha}^{p}_{n}}=\matr{A}\vect{\alpha}^{p}_{n}+
\theta_{1}\fnof{\vect{g}}{\hat{\vect{u}}_{n+1}+ \dfrac{{\Delta
      t}^{p}}{p!}\vect{\alpha}^{p}_{n}}+\pbrac{1-\theta_{1}}\fnof{\vect{g}}{\vect{u}_{n}}+\vect{b}= \vect{0}
\end{equation}
where $\matr{A}$ is the \emph{Amplification matrix} given by
\begin{equation}
  \matr{A}=\dfrac{\theta_{p-2}{\Delta t}^{p-2}}{\factorial{p-2}}\matr{M}+
  \dfrac{\theta_{p-1}{\Delta t}^{p-1}}{\factorial{p-1}}\matr{C}+
  \dfrac{\theta_{p}{\Delta t}^{p}}{p!}\matr{K}
\end{equation}
and $\vect{b}$ is the right hand side vector given by
\begin{equation}
  \vect{b}=\matr{M}\ddot{\bar{\vect{u}}}_{n+1}+\matr{C}\dot{\bar{\vect{u}}}_{n+1}+
  \matr{K}\bar{\vect{u}}_{n+1}+\bar{\vect{f}}
\end{equation}

If $\fnof{\vect{g}}{\vect{u}}\equiv\vect{0}$ then \eqnref{eqn:dynamic} is linear in
$\vect{\alpha}^{p}_{n}$ and $\vect{\alpha}^{p}_{n}$ can be found by solving
the linear equation
\begin{equation}
  \vect{\alpha}^{p}_{n} =-\inverse{\pbrac{\dfrac{\theta_{p-2}{\Delta t}^{p-2}}{\factorial{p-2}}\matr{M}+
      \dfrac{\theta_{p-1}{\Delta t}^{p-1}}{\factorial{p-1}}\matr{C}+
      \dfrac{\theta_{p}{\Delta
          t}^{p}}{p!}\matr{K}}}\pbrac{\matr{M}\ddot{\bar{\vect{u}}}_{n+1}+
    \matr{C}\dot{\bar{\vect{u}}}_{n+1}+\matr{K}\bar{\vect{u}}_{n+1}+\bar{\vect{f}}}
\end{equation}
or
\begin{equation}
  \vect{\alpha}^{p}_{n} =-\inverse{\matr{A}}\vect{b}
\end{equation}

If $\fnof{\vect{g}}{\vect{u}}$ is not $\equiv\vect{0}$ then
\eqnref{eqn:dynamic} is nonlinear in $\vect{\alpha}^{p}_{n}$. To solve this
equation we use Newton's method \ie
\begin{equation}
  \begin{split}
    \text{1.  } & \fnof{\matr{J}}{\vect{\alpha}^{p}_{n(i)}}.\delta
    \vect{\alpha}^{p}_{n(i)} =
    -\fnof{\vect{\psi}}{\vect{\alpha}^{p}_{n(i)}} \\
    \text{2.  } & \vect{\alpha}^{p}_{n(i+1)}=\vect{\alpha}^{p}_{n(i)}+\delta
    \vect{\alpha}^{p}_{n(i)}
  \end{split}
\end{equation}
where $\fnof{\matr{J}}{\vect{\alpha}^{p}_{n}}$ is the Jacobian and is given by
\begin{equation}
  \fnof{\matr{J}}{\vect{\alpha}^{p}_{n}}=\dfrac{\theta_{p-2}{\Delta t}^{p-2}}{\factorial{p-2}}\matr{M}+
  \dfrac{\theta_{p-1}{\Delta
      t}^{p-1}}{\factorial{p-1}}\matr{C}+\dfrac{\theta_{p}{\Delta t}^{p}}{p!}\matr{K}+
  \dfrac{\theta_{1}{\Delta t}^{p}}{p!}
  \delby{\fnof{\vect{g}}{\hat{\vect{u}}_{n+1}+\dfrac{{\Delta
          t}^{p}}{p!}
      \vect{\alpha}^{p}_{n}}}{\vect{\alpha}^{p}_{n}}
\end{equation}
or
\begin{equation}
  \fnof{\matr{J}}{\vect{\alpha}^{p}_{n}}=\matr{A}+\dfrac{\theta_{1}{\Delta
      t}^{p}}{p!}
  \delby{\fnof{\vect{g}}{\hat{\vect{u}}_{n+1}+\dfrac{{\Delta t}^{p}}{p!}\vect{\alpha}^{p}_{n}}}{\vect{\alpha}^{p}_{n}}
\end{equation}

Once $\vect{\alpha}^{p}_{n}$ has been obtained the values at the next time step can be obtained from
\begin{equation}
  \begin{split}
    \vect{u}_{n+1} &= \vect{u}_{n}+\Delta t
    \dot{\vect{u}}_{n}+\cdots+\dfrac{{\Delta
        t}^{p}}{p!}\vect{\alpha}^{p}_{n}=\hat{\vect{u}}_{n+1}+
    \dfrac{{\Delta t}^{p}}{p!}\vect{\alpha}^{p}_{n}\\
    \dot{\vect{u}}_{n+1} &= \dot{\vect{u}}_{n}+\Delta t
    \ddot{\vect{u}}_{n}+\cdots+\dfrac{{\Delta
        t}^{p-1}}{\factorial{p-1}}\vect{\alpha}^{p}_{n}=\dot{\hat{\vect{u}}}_{n+1}+\dfrac{{\Delta
        t}^{p-1}}{\factorial{p-1}}\vect{\alpha}^{p}_{n} \\
    &\vdots \\
    \symover{p-1}{\vect{u}}_{n+1} &= \symover{p-1}{\vect{u}}_{n}+\Delta t\vect{\alpha}^{p}_{n}
  \end{split}
\end{equation}

For algorithms in which the degree of the polynomial, $p$, is higher than the
order we require the algorithm to be initialised so that the initial velocity
or acceleration can be computed. The initial velocity or acceleration values
can be obtained by substituting the initial displacement or initial
displacement and velocity values into \eqnref{eqn:generaldynamicnonlinear},
rearranging and solving. For example consider an the case of a second degree
polynomial and a first order system. Substituing the initial displacement
$\vect{u}_{0}$ into \eqnref{eqn:generaldynamicnonlinear} gives
\begin{equation}
  \matr{C}\dot{\vect{u}}_{0}+\matr{K}\vect{u}_{0}+\fnof{\vect{g}}{\vect{u}_{0}}+\bar{\vect{f}}_{0}=\vect{0}
\end{equation}
and therefore an approximation to the initial velocity can be found from
\begin{equation}
  \dot{\vect{u}}_{0}=-\inverse{\matr{C}}\pbrac{\matr{K}\vect{u}_{0}+\fnof{\vect{g}}{\vect{u}_{0}}+\bar{\vect{f}}_{0}}
\end{equation}

Similarily for a third degree polynomial and a second order system the initial
acceleration can be found from
\begin{equation}
  \ddot{\vect{u}}_{0}=-\inverse{\matr{M}}\pbrac{\matr{C}\dot{\vect{u}}_{0}+\matr{K}\vect{u}_{0}+
    \fnof{\vect{g}}{\vect{u}_{0}}+\bar{\vect{f}}_{0}}
\end{equation}

To evaluate the mean weighted load vector, $\bar{\vect{f}}$, we need to
evaluate the integral in \eqnref{eqn:meanweightedloadvector}. In some cases,
however, we can make the assumption that the load vector varies linearly
during the time step. In these cases the mean weighted load vector can be
computed from
\begin{equation}
  \bar{\vect{f}}=\theta_{1}\vect{f}_{n+1}+\pbrac{1-\theta_{1}}\vect{f}_{n}
\end{equation}

\subsubsection{Special SN11 case, p=1}

For this special case, the mean predicited values are given by
\begin{equation}
   \bar{\vect{u}}_{n+1} = \vect{u}_{n}
\end{equation}

The predicted displacement values are given by
\begin{equation}
   \hat{\vect{u}}_{n+1} = \vect{u}_{n}
\end{equation}

The amplification matrix is given by
\begin{equation}
  \matr{A}=\matr{C}+\theta_{1}\Delta t \matr{K}
\end{equation}

The right hand side vector is given by
\begin{equation}
  \vect{b}=\matr{K}\bar{\vect{u}}_{n+1}+\bar{\vect{f}}
\end{equation}

The nonlinear function is given by
\begin{equation}
  \fnof{\vect{\psi}}{\vect{\alpha}^{1}_{n}}=\matr{A}\vect{\alpha}^{1}_{n}+\theta_{1}\fnof{\vect{g}}{\hat{\vect{u}}_{n+1}+
    \Delta t\vect{\alpha}^{1}_{n}}+\pbrac{1-\theta_{1}}\fnof{\vect{g}}{\vect{u}_{n}}+\vect{b}=\vect{0}
\end{equation}

The Jacobian matrix is given by
\begin{equation}
  \fnof{\matr{J}}{\vect{\alpha}^{1}_{n}}=\matr{A}+\theta_{1}\Delta t
  \delby{\fnof{\vect{g}}{\hat{\vect{u}}_{n+1}+\Delta t\vect{\alpha}^{1}_{n}}}{\vect{\alpha}^{1}_{n}}
\end{equation}

And the time step update is given by
\begin{equation}
    \vect{u}_{n+1} = \vect{u}_{n}+\Delta t\vect{\alpha}^{1}_{n}
\end{equation}

\subsubsection{Special SN21 case, p=2}

For this special case, the mean predicited values are given by
\begin{equation}
  \begin{split}
    \bar{\vect{u}}_{n+1} &= \vect{u}_{n}+\theta_{1}\Delta t\dot{\vect{u}}_{n}\\
    \dot{\bar{\vect{u}}}_{n+1} &= \dot{\vect{u}}_{n}
  \end{split}
\end{equation}
where
\begin{equation}
  \dot{\vect{u}}_{0}=-\inverse{\matr{C}}\pbrac{\matr{K}\vect{u}_{0}+\fnof{\vect{g}}{\vect{u}_{0}}+\bar{\vect{f}}_{0}}
\end{equation}

The predicted displacement values are given by
\begin{equation}
   \hat{\vect{u}}_{n+1} = \vect{u}_{n}+\Delta t\dot{\vect{u}}_{n}
\end{equation}

The amplification matrix is given by
\begin{equation}
  \matr{A}=\theta_{1}\Delta t\matr{C}+\dfrac{\theta_{2}{\Delta t}^{2}}{2}\matr{K}
\end{equation}

The right hand side vector is given by
\begin{equation}
  \vect{b}=\matr{C}\dot{\bar{\vect{u}}}_{n+1}+\matr{K}\bar{\vect{u}}_{n+1}+\bar{\vect{f}}
\end{equation}

The nonlinear function is given by
\begin{equation}
  \fnof{\vect{\psi}}{\vect{\alpha}^{2}_{n}}=\matr{A}\vect{\alpha}^{2}_{n}+\theta_{1}\fnof{\vect{g}}{\hat{\vect{u}}_{n+1}+
    \dfrac{{\Delta t}^{2}}{2}\vect{\alpha}^{2}_{n}}+\pbrac{1-\theta_{1}}\fnof{\vect{g}}{\vect{u}_{n}}+\vect{b}=\vect{0}
\end{equation}

The Jacobian matrix is given by
\begin{equation}
  \fnof{\matr{J}}{\vect{\alpha}^{2}_{n}}=\matr{A}+\dfrac{\theta_{1}{\Delta t}^{2}}{2}
  \delby{\fnof{\vect{g}}{\hat{\vect{u}}_{n+1}+\dfrac{{\Delta t}^{2}}{2}\vect{\alpha}^{2}_{n}}}{\vect{\alpha}^{2}_{n}}
\end{equation}

And the time step update is given by
\begin{equation}
  \begin{split}
    \vect{u}_{n+1} &= \vect{u}_{n}+\Delta t\dot{\vect{u}}_{n} +\dfrac{{\Delta t}^{2}}{2}\vect{\alpha}^{2}_{n} \\
    \dot{\vect{u}}_{n+1} &= \dot{\vect{u}}_{n}+\Delta t\vect{\alpha}^{2}_{n}
  \end{split}
\end{equation}

\subsubsection{Special SN22 case, p=2}

For this special case, the mean predicited values are given by
\begin{equation}
  \begin{split}
    \bar{\vect{u}}_{n+1} &= \vect{u}_{n}+\theta_{1}\Delta t\dot{\vect{u}}_{n}\\
    \dot{\bar{\vect{u}}}_{n+1} &= \dot{\vect{u}}_{n}
  \end{split}
\end{equation}

The predicted displacement values are given by
\begin{equation}
   \hat{\vect{u}}_{n+1} = \vect{u}_{n}+\Delta t\dot{\vect{u}}_{n}
\end{equation}

The amplification matrix is given by
\begin{equation}
  \matr{A}=\matr{M}+\theta_{1}\Delta t\matr{C}+\dfrac{\theta_{2}{\Delta t}^{2}}{2}\matr{K}
\end{equation}

The right hand side vector is given by
\begin{equation}
  \vect{b}=\matr{C}\dot{\bar{\vect{u}}}_{n+1}+\matr{K}\bar{\vect{u}}_{n+1}+\bar{\vect{f}}
\end{equation}

The nonlinear function is given by
\begin{equation}
  \fnof{\vect{\psi}}{\vect{\alpha}^{2}_{n}}=\matr{A}\vect{\alpha}^{2}_{n}+\theta_{1}\fnof{\vect{g}}{\hat{\vect{u}}_{n+1}+
    \dfrac{{\Delta t}^{2}}{2}\vect{\alpha}^{2}_{n}}+\pbrac{1-\theta_{1}}\fnof{\vect{g}}{\vect{u}_{n}}+\vect{b}=\vect{0}
\end{equation}

The Jacobian matrix is given by
\begin{equation}
  \fnof{\matr{J}}{\vect{\alpha}^{2}_{n}}=\matr{A}+\dfrac{\theta_{1}{\Delta t}^{2}}{2}
  \delby{\fnof{\vect{g}}{{\hat{\vect{u}}_{n+1}+\dfrac{{\Delta t}^{2}}{2}\vect{\alpha}^{2}_{n}}}}{\vect{\alpha}^{2}_{n}}
\end{equation}

And the time step update is given by
\begin{equation}
  \begin{split}
    \vect{u}_{n+1} &= \vect{u}_{n}+\Delta t\dot{\vect{u}}_{n} +\dfrac{{\Delta t}^{2}}{2}\vect{\alpha}^{2}_{n} \\
    \dot{\vect{u}}_{n+1} &= \dot{\vect{u}}_{n}+\Delta t\vect{\alpha}^{2}_{n}
  \end{split}
\end{equation}

\section{Interface Conditions}

\subsection{Variational principles}

The branch of mathematics concerned with the problem of finding a function for
which a certain integral of that function is either at its largest or smallest
value is called the \emph{calculus of variations}. When scientific laws are formulated in terms of the principles of the calculus
of variations they are termed \emph{variational principles}.

\subsection{Lagrange Multipliers}


\documentclass{article}
\usepackage{mathtools}
\usepackage{pgfplots}
\usepackage[utf8]{inputenc}

\title{CSE546 HW0 B}
\author{Bobby Deng | 1663039 | dengy7 }
\date{March 2020}

\usepackage{natbib}
\usepackage{graphicx}

\begin{document}
\maketitle

\section*{B.1}
PDF is:\newline
\[
f(x) = \begin{cases}
1, & \text{for $0 < x < 1$} \\
0, & \text{otherwise.}
\end{cases}
\]
CDF is:
\[ F_x(x)=\int_{-\infty}^{x}f(x)dx=x \]
Let me calculate the PDF of: $Y=Max(X_1,X_2,....,X_n)$, and here we need to use joint probability to compute.
\[ P(Max(X_1,X_2,....,X_n) = P(X_1\le X,X_2\le X,...,X_{n-1}\le X) \]
So we have:
\[ f_Y(x)=n[F_x(x)]^{n-1}f(x)=n(x)^{n-1}*1=n(x)^{n-1} \]
\[
=\begin{cases}
nx^{n-1}, & \text{for $0 < x < 1$} \\
0, & \text{otherwise.}
\end{cases}
\]
Now we need $E[Y]$, we use mean equation for continuous random variable.
\[ E[Y]=\int_0^1xf_M(x)dx=\int_0^1xnx^{n-1}dx=n\int_0^1x^ndx=\frac{n}{n+1} \]

\section*{B.2}
Since, $A\in \rm I\!R^{n \times m}$, and $B\in \rm I\!R^{m \times n}$
So,
\begin{equation}
\begin{split}
tr(AB) = & \sum_{i=1}^m (AB)_{ii} \\
& = \sum_{i=1}^m \sum_{j=q}^n A_{i,j}B_{j,i} \\
& = \sum_{j=1}^n \sum_{i=1}^m B_{j,i}A_{i,j} \\
& = \sum_{j=1}^n (BA)_{j,j} \\
& = tr(BA)
\end{split}
\end{equation}

\section*{B.3}
\subsection*{a.}
When we consider a matrix of d by d, so, \newline
Max rank: d and Min rank: 1;
\subsection*{b.}
Because V is a b by n matrix, and $v_i$ is none zero vectors, so, \newline
Max rank: $min(d,n)$, Min rank: 1;
\subsection*{c.}
Since A is D by d and $v_i$ is d by 1, so $Av_i$ is D by 1. So, we could know that $(Av_i)^T$ is 1 by D. \newline

So $(Av_i)(Av_i)^T$ is D by D. Then, \newline
Max rank: D, Min rank: 0.
\subsection*{d.}
Since V is d by n, so AV is D by n, so\newline
For AV, Max: min(d,n), Min is 0.\newline
If V is rank d, Max: d, Min: 0.

\end{document}