\section{Computational Co-Ordinates Transformation}

	Having phrased the Navier-Stokes equations in matrix form (Eqs. \ref{eqn:final}-\ref{eqn:finalHv}),
the next step is to cast these equations in a form suitable for numerical simulation.  To do this, two things
are required to make this transformation as useful as possible.  The first, and most involved
step, is to transform the equations onto computational co-ordinates.  This will allow
for the fact that the orthogonal computational grid need not necessarily be aligned with the space
physical co-ordinates
of the system under consideration, and thus cannot be applied directly to an arbitrary physical gridding.  However,
by using computational co-ordinates one can easily allow for any type of grid (i.e.
clustered along given directions or in specified areas) through the incorporation of metric
terms in the governing equations.

	The second step is to phrase the variables in a language suitable for computation, which
involves only direct substitution and is hence fairly straightforward.  However one would like to
have indices that match those used by the programming language, as although in reality the number of
species goes from 1 to $n_s$, for a programming language such as \emph{C} the indices would vary
from 0 to $n_s - 1$.  As well, common variables differentiated by subscripts alone rather than distinct
Greek or arithmetic symbols are easier to program, as these can be represented by arrays of various dimensions.

%---------------------------------------------------------------------------------------------------------
\subsection{Metric Derivatives}

	In order to properly transform the governing equations from the Cartesian to the computational
co-ordinate system metric derivatives will be needed, as it is these terms that describe the geometrical
relationship between the two domains.  Thus before tackling the main set of equations, it is helpful to
derive relations for the metric terms and have them at the ready for substitution into the governing
equations when needed.   We can make use of the fact that there are only two independent space variables,
$x$ and $r$, (in axisymmetric flow) and one variable in time, $t$, which allows a slight simplification from
a fully three dimensional transformation.  Making use of the relationship between differential quantities as
defined by the Calculus one can write,

\begin{displaymath}
	\begin{array}{c}
		dt=\frac{\partial t}{\partial \tau}d\tau + \frac{\partial t}{\partial \xi}d\xi +
		\frac{\partial t}{\partial \eta}d\eta \\
		dx=\frac{\partial x}{\partial \tau}d\tau + \frac{\partial x}{\partial \xi}d\xi +
		\frac{\partial x}{\partial \eta}d\eta \\
		dr=\frac{\partial r}{\partial \tau}d\tau + \frac{\partial r}{\partial \xi}d\xi +
		\frac{\partial r}{\partial \eta}d\eta
	\end{array}
\end{displaymath}

	Now since real time is independent of the physical grid location (and hence independent of the computational
grid location as there is a one to one correspondence between points in the two domains) then one can write
$\frac{\partial t}{\partial \xi}$ =
$\frac{\partial t}{\partial \eta}$ = 0, and if one further assumes that computational time is identical to
real time then $\frac{\partial t}{\partial \tau}$ = 1, the above relations can be expressed in matrix form
as,

\begin{equation}
	\begin{array}{cccc}
		\left\{
		\begin{array}{c}
		dt \\ dx \\ dr
		\end{array}
		\right\}
		& = &
		\left[
		\begin{array}{ccc}
		1 & 0 & 0 \\ x_{t} & x_{\xi} & x_{\eta} \\ r_{t} & r_{\xi} & r_{\eta}
		\end{array}
		\right]
		&
		\left\{
		\begin{array}{c}
		d\tau \\ d\xi \\ d\eta
		\end{array}
		\right\}
	\end{array}
\label{eqn:matrix1}
\end{equation}

	Using the Calculus again, one can express these relations from the opposite point of view
expressing the differential computational quantities in terms of derivatives with respect to the
original Cartesian co-ordinates,

\begin{displaymath}
	\begin{array}{c}
		d\tau=\frac{\partial \tau}{\partial t}dt + \frac{\partial \tau}{\partial x}dx +
		\frac{\partial \tau}{\partial r}dr \\
		d\xi=\frac{\partial \xi}{\partial t}dt + \frac{\partial \xi}{\partial x}dx +
		\frac{\partial \xi}{\partial r}dr \\
		d\eta=\frac{\partial \eta}{\partial t}dt + \frac{\partial \eta}{\partial x}dx +
		\frac{\partial \eta}{\partial r}dr
	\end{array}
\end{displaymath}

	which again, after applying the same logic as before, can be simplified and rewritten as

\begin{equation}
	\begin{array}{cccc}
		\left\{
		\begin{array}{c}
		d\tau \\ d\xi \\ d\eta
		\end{array}
		\right\}
		& = &
		\left[
		\begin{array}{ccc}
		1 & 0 & 0 \\ \xi_t & \xi_x & \xi_r \\ \eta_t & \eta_x & \eta_r
		\end{array}
		\right]
		&
		\left\{
		\begin{array}{c}
		dt \\ dx \\ dr
		\end{array}
		\right\}
	\end{array}
\label{eqn:matrix2}
\end{equation}

	Examining Eqs. \ref{eqn:matrix1} and \ref{eqn:matrix2} it can be seen that the square matrices in
each equation are inverses of each other, thus using the property of inverse matrices that states $AA^{-1} = I$ one can
write

\begin{equation}
\begin{array}{ccccc}
	\begin{array}{c}
		\left[
		\begin{array}{ccc}
		1 & 0 & 0 \\ x_{\tau} & x_{\xi} & x_{\eta} \\ r_{\tau} & r_{\xi} & r_{\eta}
		\end{array}
		\right]
	\end{array}
& \cdot  &
	\begin{array}{c}
		\left[
		\begin{array}{ccc}
		1 & 0 & 0 \\ \xi_t & \xi_x & \xi_r \\ \eta_t & \eta_x & \eta_r
		\end{array}
		\right]
	\end{array}
& = &
	\begin{array}{c}
		\left[
		\begin{array}{ccc}
		1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1
		\end{array}
		\right]
	\end{array}
\end{array}
\label{eqn:identity}
\end{equation}

	Eq. \ref{eqn:identity} yields nine equations when multiplied out, three of which provide no useful
relations (i.e. 0 = 0), two provide relations for the metric derivatives with respect to time (which in the case of a grid
that is constant in time reduce to zero) and the remaining four express relations for the pertinent metric derivatives

\begin{displaymath}
	\begin{array}{c}
	\xi_t = -x_t \xi_x - r_t \xi_r \\
	\eta_t = -x_t \eta_x - r_t \eta_r \\
	\xi_x = \frac{1}{x_\xi}(1 - r_\xi \xi_r) \\
	\xi_x = -\frac{1}{x_\eta}(r_\eta \xi_r) \\
	\eta_r = -\frac{1}{r_\xi}(x_\xi \eta_x) \\
	\eta_r = \frac{1}{r_\eta}(1 - x_\eta \eta_x)
	\end{array}
\end{displaymath}

	After suitable manipulations of the last four equations above (eliminating one of the metric derivatives,
solving for the remaining metric derivative, and then substituting this result back into the equations to solve
for the eliminated variable) one arrives at the following results,

\begin{displaymath}
	\begin{array}{c}
	\xi_x = J r_\eta \\
	\xi_r = -J x_\eta \\
	\eta_x = -J r_\xi \\
	\eta_r = J x_\xi
	\end{array}
\end{displaymath}

	where is J is the Jacobian of transformation (also known as the metric Jacobian) and is defined as,

\begin{equation}
	J = \frac{1}{x_\xi r_\eta - x_\eta r_{\xi}}
\label{eqn:J}
\end{equation}

	Substituting the above results in the previous expressions for $\xi_t$ and $\eta_t$ also yields

\begin{equation}
	\xi_t = J(-x_t r_\eta + r_t x_\eta)
\label{eqn:xit}
\end{equation}

\begin{equation}
	\eta_t = J(x_t r_\xi - r_t x_\xi)
\label{eqn:etat}
\end{equation}

	Going one step further and rephrasing the above relations (except for Eqs. \ref{eqn:xit} and \ref{eqn:etat})
in variables more suited to a programming
language, we will let the Cartesian co-ordinates be represented as $x$ = $x_0$ and $r$ = $x_1$ while the
computational co-ordinates as $\xi$ = $X_0$, $\eta$ = $X_1$.  Therefore,

\begin{displaymath}
	\begin{array}{c}
	\xi_x = \frac{\partial \xi}{\partial x} = \frac{\partial X_0}{\partial x_0} = X_{0,0} =
		J \frac{\partial x_1}{\partial X_1} \\
	\xi_r = \frac{\partial \xi}{\partial r} = \frac{\partial X_0}{\partial x_1} = X_{0,1} =
		-J \frac{\partial x_0}{\partial X_1} \\
	\eta_x = \frac{\partial \eta}{\partial x} = \frac{\partial X_1}{\partial x_0} = X_{1,0} =
		-J \frac{\partial x_1}{\partial X_0} \\
	\eta_r = \frac{\partial \eta}{\partial r} = \frac{\partial X_1}{\partial x_1} = X_{1,1} =
		J \frac{\partial x_0}{\partial X_0}
	\end{array}
\end{displaymath}

	These relations can be succinctly described by a single formula

\begin{equation}
	X_{i,j} = J(2\delta_{i,j} -1)\frac{\partial x_{j+1}}{\partial X_{i+1}}
\label{eqn:metrics}
\end{equation}

	where $\delta_{i,j}$ is the Kronecker delta which is equal to 1 if $i = j$ and 0
otherwise (i.e. $i \neq j$).  Also note that when the index goes higher than the number of dimensions
minus one, it cycles back to its lowest value (i.e. for two dimensions $i$ = 0,1 thus $i+1$ = 1,0 and
similarly for $j$).

%--------------------------------------------------------------------------------------------------------------
\subsection{Governing Equations}

	Starting with the axisymmetric, multi-species, viscous, turbulent Navier-Stokes equations as
shown in Eqs. \ref{eqn:final}-\ref{eqn:finalHv}, it is desired to transform these
equations onto the general computational co-ordinates $\xi$ and $\eta$, as well as the computational time
$\tau$.  In the following derivations, the Euler equations will be considered (i.e. the viscous terms will be
neglected) however the analysis applies equally as well to these terms and hence the results will be simply be
extended to include the full set of equations.  Thus the axisymmetric Euler equations can be written as

\begin{equation}
	\frac{\partial Q}{\partial t} + \frac{\partial E}{\partial x} + \frac{\partial F}{\partial r} + S_{be3D} = 0
\label{eqn:euler}
\end{equation}

	Now if we divide each term in Eq. \ref{eqn:euler} by the metric Jacobian $J$ (as defined by Eq. \ref{eqn:J})
one can write

\begin{displaymath}
	\frac{1}{J}\frac{\partial Q}{\partial t} + \frac{1}{J}\frac{\partial E}{\partial x}
	+ \frac{1}{J}\frac{\partial F}{\partial r} + \frac{1}{J}S_{be3D} = 0
\end{displaymath}

	Taking a closer look at the first term, the conservative variables vector, one can express the
derivative with respect to time using the Calculus as

\begin{displaymath}
	\frac{1}{J}\frac{\partial Q}{\partial t} = \frac{1}{J}\Big[\frac{\partial \tau}{\partial t}
	\frac{\partial Q}{\partial \tau} + \frac{\partial \xi}{\partial t}
	\frac{\partial Q}{\partial \xi} + \frac{\partial \eta}{\partial t} \frac{\partial Q}{\partial \eta}\Big]
\end{displaymath}

	Now if one adds groups of terms which in and of themselves sum to zero (these terms are shown in curly braces $\{\}$)
one can write for the conservative variables vector

\begin{displaymath}
	\frac{\tau_t}{J}\frac{\partial Q}{\partial \tau} +
	\frac{\xi_t}{J} \frac{\partial Q}{\partial \xi} + \frac{\eta_t}{J} \frac{\partial Q}{\partial \eta}
	+ \{ Q\frac{\partial}{\partial \tau}(\frac{\tau_t}{J}) - Q\frac{\partial}{\partial \tau}(\frac{\tau_t}{J}) \}
	+ \{ Q\frac{\partial}{\partial \xi}(\frac{\xi_t}{J}) - Q\frac{\partial}{\partial \xi}(\frac{\xi_t}{J}) \}
	+ \{ Q\frac{\partial}{\partial \eta}(\frac{\eta_t}{J}) - Q\frac{\partial}{\partial \eta}(\frac{\eta_t}{J}) \}
\end{displaymath}

	which can be regrouped as

\begin{equation}
	\Big[\frac{\tau_t}{J}\frac{\partial Q}{\partial \tau} + Q\frac{\partial}{\partial \tau}(\frac{\tau_t}{J})\Big] +
	\Big[\frac{\xi_t}{J}\frac{\partial Q}{\partial \xi} + Q\frac{\partial}{\partial \xi}(\frac{\xi_t}{J})\Big] +
	\Big[\frac{\eta_t}{J}\frac{\partial Q}{\partial \eta} + Q\frac{\partial}{\partial \eta}(\frac{\eta_t}{J})\Big]
	-Q \Big\{\frac{\partial}{\partial \tau}(\frac{\tau_t}{J}) + \frac{\partial}{\partial \xi}(\frac{\xi_t}{J})
	+ \frac{\partial}{\partial \eta}(\frac{\eta_t}{J}) \Big\}
\label{eqn:Qbig}
\end{equation}

	In this form it can be seen that the terms in the square brackets can be combined into a single derivative
using the inverse of the chain rule from the Calculus, while the last term in curly braces sums to zero as follows.
Since time in both Cartesian and computational co-ordinates is the same (as was specified in the derivation of the
metric terms) then $\tau$ = $t$ and thus $\tau_t$ = 1.  Now if the
relation between the Cartesian and computational co-ordinates is held constant in time, then the derivative of the metric
Jacobian with respect to time must be zero which eliminates the first term in the curly braces (note however, that
this assumption does not require a grid that is constant in time, only that the relation between the physical and
computational domains remains fixed).  Substitution of Eqs. \ref{eqn:xit} and \ref{eqn:etat} into the last two terms
in the curly braces yields,

\begin{displaymath}
	\frac{\partial}{\partial \xi}J^{-1}\Big\{J(-x_t r_\eta + r_t x_\eta)\Big\}
	+ \frac{\partial}{\partial \eta}J^{-1}\Big\{J(x_t r_\xi - r_t x_\xi)\Big\}
\end{displaymath}

	If we further assume that the derivatives with respect to time are independent of grid location (i.e. changes
in gridding with time are applied uniformly over the entire grid), then $x_t$ and $r_t$
can be pulled outside of the derivatives.  Also, using Clairaut's Theorem which states that

\begin{equation}
	\frac{\partial r^2}{\partial \eta \partial \xi} = \frac{\partial r^2}{\partial \xi \partial \eta}
\label{eqn:clairaut}
\end{equation}

	then the above equation sums to zero.  It should be noted that although restrictions
were placed on the manner in which the grid may change in time, it was not stated that the grid must stay constant in time
(although in most circumstances this will indeed be the case).  Thus Eq. \ref{eqn:Qbig} can be written

\begin{displaymath}
	\frac{1}{J}\frac{\partial Q}{\partial t} = \frac{\partial}{\partial t}(\frac{Q}{J})
	+ \frac{\partial}{\partial \xi}(\xi_t \frac{Q}{J}) + \frac{\partial}{\partial \eta}(\eta_t \frac{Q}{J})
\end{displaymath}

	which when combined with the assertion that the grid spacing is constant in time reduces to

\begin{equation}
	\frac{1}{J}\frac{\partial Q}{\partial t} = \frac{\partial}{\partial t}(\frac{Q}{J})
\label{eqn:Q}
\end{equation}

	It is worth noting here that the above expression in Eq. \ref{eqn:Q} could have been arrived at quite
easily by specifying at the outset a physical domain that remains constant in time, and that time in both the Cartesian
and computational domains is equivalent.

	Considering next the flux vector along the $x$ direction and remembering that one has already divided by the
metric Jacobian, one can write

\begin{displaymath}
	\frac{1}{J}\frac{\partial E}{\partial x} = \frac{1}{J}\Big[\frac{\partial \xi}{\partial x}\frac{\partial E}{\partial \xi}
	+ \frac{\partial \eta}{\partial x}\frac{\partial E}{\partial \eta}\Big]
\end{displaymath}

	Adding terms that sum to zero in a fashion similar to that done for the $Q$ vector

\begin{displaymath}
	\frac{1}{J}\frac{\partial E}{\partial x} = \frac{\xi_x}{J}\frac{\partial E}{\partial \xi}
	+\frac{\eta_x}{J}\frac{\partial E}{\partial \eta} + \Big\{E \frac{\partial}{\partial \xi}
	(\frac{\xi_x}{J}) - E\frac{\partial}{\partial \xi}(\frac{\xi_x}{J})\Big\}
	+ \Big\{E\frac{\partial}{\partial \eta}(\frac{\eta_x}{J}) - E\frac{\partial}{\partial \eta}(\frac{\eta_x}{J})\Big\}
\end{displaymath}

	Regrouping terms yields

\begin{displaymath}
	\frac{1}{J}\frac{\partial E}{\partial x} =
	\Big[\frac{\xi_x}{J}\frac{\partial E}{\partial \xi}
	+ E \frac{\partial}{\partial \xi}(\frac{\xi_x}{J})\Big]
	+ \Big[\frac{\eta_x}{J}\frac{\partial E}{\partial \eta}
	+ E \frac{\partial}{\partial \eta}(\frac{\eta_x}{J}) \Big]
	-E \Big\{\frac{\partial}{\partial \xi}(\frac{\xi_x}{J})
	+ \frac{\partial}{\partial \eta}(\frac{\eta_x}{J})\Big\}
\end{displaymath}

	The first two groups of terms in square brackets can be combined into a single derivative while the last
term in the curly braces sums to zero by substituting for the definitions of the metric derivatives as follows,

\begin{displaymath}
	-E \Big\{\frac{\partial}{\partial \xi}(\frac{\xi_x}{J})
	+ \frac{\partial}{\partial \eta}(\frac{\eta_x}{J})\Big\} =
	-E \Big\{\frac{\partial}{\partial \xi}J^{-1}(J r_\eta)
	+ \frac{\partial}{\partial \eta}J^{-1}(J r_\xi)\Big\}
\end{displaymath}

	Again applying Clairaut's Theorem (Eq. \ref{eqn:clairaut}) the above relation reduces to zero.  Therefore, the
derivative of the flux vector $E$ can be expressed as,

\begin{equation}
	\frac{1}{J}\frac{\partial E}{\partial x} =
	\frac{\partial}{\partial \xi} (\xi_x \frac{E}{J})
	+ \frac{\partial}{\partial \eta} (\eta_x \frac{E}{J})
\label{eqn:E}
\end{equation}

	The exact same procedure is followed for the $F$ flux vector resulting in

\begin{equation}
	\frac{1}{J}\frac{\partial F}{\partial r} =
	\frac{\partial}{\partial \xi} (\xi_r \frac{F}{J})
	+ \frac{\partial}{\partial \eta} (\eta_r \frac{F}{J})
\label{eqn:F}
\end{equation}

	Combining the results of Eqs. \ref{eqn:Q}, \ref{eqn:E}, and \ref{eqn:F} into Eq. \ref{eqn:euler} and
realizing that since the axisymmetric source term $S_{be3D}$ is not differentiated it can be left as is yields the
result

\begin{displaymath}
	\frac{\partial}{\partial t}(\frac{Q}{J}) + \frac{\partial}{\partial \xi} \Big[\frac{1}{J}(\xi_x E
	+ \xi_r F)\Big] + \frac{\partial}{\partial \eta}\Big[\frac{1}{J} (\eta_x E
	+ \eta_r F)\Big] + \frac{1}{J}S_{be3D} = 0
\end{displaymath}

	As a final step, one would like to substitute computational variables for those above, thus following the
conventions established when deriving the metric terms ($x$ = $x_0$, $r$ = $x_1$, $\xi$ = $X_0$, and $\eta$ = $X_1$)
and defining a new variable

\begin{equation}
	\Omega = J^{-1}
\label{eqn:omega}
\end{equation}

	one can write

\begin{equation}
	\frac{\partial \bar{Q}}{\partial t} + \frac{\partial \bar{E}}{\partial \xi}
	+ \frac{\partial \bar{F}}{\partial \eta} + \bar{S}_{be3D} = 0
\label{eqn:eulerbar}
\end{equation}

	where

\begin{equation}
	\begin{array}{ccc}
		\bar{Q} &=& \Omega Q \\
		\bar{E} &=& \Omega (X_{0,0}E + X_{0,1}F) \\
		\bar{F} &=& \Omega (X_{1,0}E + X_{1,1}F) \\
		\bar{S}_{be3D} &=& \Omega S_{be3D}
	\end{array}
\label{eqn:eulerbars}
\end{equation}

	with $Q$, $E$, $F$, and $S_{be3D}$ defined by Eqs. \ref{eqn:finalQ}, \ref{eqn:finalEF}, and \ref{eqn:finalH}
respectively.  Extending the same logic to the viscous terms yields the desired form of the governing equations,

\begin{equation}
	\frac{\partial \bar{Q}}{\partial t} + \frac{\partial \bar{E}}{\partial \xi}
	+ \frac{\partial \bar{F}}{\partial \eta} + \bar{S}_{be3D} -\frac{\partial \bar{E}_v}{\partial \xi}
	- \frac{\partial \bar{F}_v}{\partial \eta} - \bar{S}_{be3D_v} = 0
\label{eqn:finalbar}
\end{equation}

	with

\begin{equation}
	\begin{array}{ccc}
		\bar{Q} &=& \Omega Q \\
		\bar{E}_v &=& \Omega (X_{0,0}E_v + X_{0,1}F_v) \\
		\bar{F}_v &=& \Omega (X_{1,0}E_v + X_{1,1}F_v) \\
		\bar{S}_{be3D_v} &=& \Omega S_{be3D_v}
	\end{array}
\label{eqn:viscousbars}
\end{equation}

	However, it must be noted here that the viscous terms themselves contain derivatives and hence
Eqs. \ref{eqn:finalEvFv} and \ref{eqn:finalHv} must be modified to account for the transformation
as well.

%-------------------------------------------------------------------------------------------------------------------
\subsection{Axisymmetric Source Term Transformation}

	Given that without the axisymmetric source terms, the governing equations are simply those for
normal two-dimensional flow, the transformation of the viscous flux vectors will not be demonstrated as these can
be found in other sources.  However of particular interest here are the source terms, which will be transformed
explicitly given that there exist numerous ways in which these terms can be expressed depending on the
form of the computational governing equations used (i.e. definition of $\Omega$ or  $Q$).

\subsubsection{Inviscid Axisymmetric Source Term}

	Although this term contains no derivatives, it is useful to cast the variables in ones similar in form
to the computational space variables, i.e., similar terms differentiated by subscripts alone.  This would also
apply to the conservative variable vector $Q$ and to the inviscid flux vectors $E$ and $F$ although the process
will not be shown here.  If we let the physical space velocities $u$ and $v$ be represented by $v_o$ and $v_1$
respectively then one can write

\begin{equation}
	\bar{S}_{be3D} = \frac{\Omega}{x_1}\left[ \begin{array}{c}
		\rho_1 v_1 \\
		\vdots \\
		\rho_k v_1 \\
		\rho v_0v_1 \\
		\rho {v_1}^2 \\
		(\rho E + p)v_1 \\
		\rho k v_1 \\
		\rho \omega v_1
		   \end{array}
	    \right]
\label{eqn:finalHbar}
\end{equation}

\subsubsection{Viscous Axisymmetric Source Term}

	Since this term contains derivatives in the Cartesian domain, these quantities must be appropriately
transformed in addition to substituting computational variables for Cartesian ones as was done for the inviscid source
term.  Although the viscous flux vectors require the appropriate transformations as well, given that these vectors
are exactly the same as those for two-dimensional flow, their transformation will not be shown here.  Rewriting the
viscous source term here for clarity,

\begin{displaymath}
	S_{be3D_v} = \frac{1}{r}\left[ \begin{array}{c}
		\nu_1 \frac{\partial c_1}{\partial r} \\
		\vdots \\
		\nu_k \frac{\partial c_k}{\partial r} \\
		\tau_{rx} - r\frac{2}{3}\frac{\partial}{\partial x}(\mu \frac{v}{r}) \\
		\hat{ \tau}_{rr} -\tau_{\theta \theta} - \frac{2}{3}\mu \frac{v}{r}
		- r\frac{2}{3}\frac{\partial}{\partial r}(\mu \frac{v}{r}) \\
		\sum_k (\nu_k \frac{\partial c_k}{\partial r}h_k) - q_{c_r} + \tau_{rx}u
		+ \hat{ \tau}_{rr}v + {\mu_k}^* \frac{\partial k}{\partial r} - \frac{2}{3} \mu \frac{v^2}{r}
			- r\frac{2}{3} \frac{\partial}{\partial x}(\mu \frac{uv}{r})
			- r\frac{2}{3} \frac{\partial}{\partial r}(\mu \frac{v^2}{r}) \\
		{\mu_k}^* \frac{\partial k}{\partial r} + rS_k\\
		{\mu_\omega}^* \frac{\partial \omega}{\partial r} + rS_\omega
		   \end{array}
	    \right]
\end{displaymath}

	Remembering that $r$ = $x_1$ and that $\bar{S}_{be3D_v}$ = $\Omega S_{be3D_v}$ one can immediately
rewrite the above as

\begin{equation}
	\bar{S}_{be3D_v} = \frac{\Omega}{x_1}\left[ \begin{array}{c}
		\nu_1 \frac{\partial c_1}{\partial r} \\
		\vdots \\
		\nu_k \frac{\partial c_k}{\partial r} \\
		\tau_{rx} - x_1\frac{2}{3}\frac{\partial}{\partial x}(\mu \frac{v}{r}) \\
		\hat{ \tau}_{rr} -\tau_{\theta \theta} - \frac{2}{3}\mu \frac{v}{r}
		- x_1\frac{2}{3}\frac{\partial}{\partial r}(\mu \frac{v}{r}) \\
		\sum_k (\nu_k \frac{\partial c_k}{\partial r}h_k) - q_{c_r} + \tau_{rx}u
		+ \hat{ \tau}_{rr}v + {\mu_k}^* \frac{\partial k}{\partial r} - \frac{2}{3} \mu \frac{v^2}{r}
			- x_1\frac{2}{3} \frac{\partial}{\partial x}(\mu \frac{uv}{r})
			- x_1\frac{2}{3} \frac{\partial}{\partial r}(\mu \frac{v^2}{r}) \\
		{\mu_k}^* \frac{\partial k}{\partial r} + x_1S_k\\
		{\mu_\omega}^* \frac{\partial \omega}{\partial r} + x_1S_\omega
		   \end{array}
	    \right]
\label{eqn:beginHvbar}
\end{equation}

%---------------------------------------------------------------------------------------------------------------
\subsubsection{Species Continuity Source Term}

	For the remaining transformations, each equation will be considered separately.  Starting with the
species conservation source terms, and letting the number of species vary between 0 and $n_s -1 = \bar{n}_s$
one can write for the first species

\begin{displaymath}
	\nu_0 \frac{\partial}{\partial r}(c_0) = \nu_0 \Big\{\xi_r \frac{\partial c_0}{\partial \xi}
	+ \eta_r \frac{\partial c_0}{\partial \eta}\Big\} = \nu_0 \Big\{X_{0,1} \frac{\partial c_0}{\partial X_0}
	+ X_{1,1} \frac{\partial c_0}{\partial X_1} \Big\}
\end{displaymath}

	Thus for a general species \emph{i} one can write

\begin{equation}
	\nu_i \frac{\partial c_i}{\partial r} = \nu_i \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
	\frac{\partial c_i}{\partial X_\theta}
\label{eqn:speciescomp}
\end{equation}

	where $\bar{n}_d$ is the number of dimensions minus one, which for axisymmetric flow has a value equal
to 1.  Therefore combining Eq. \ref{eqn:speciescomp} and Eq. \ref{eqn:beginHvbar} yields

\begin{displaymath}
	\bar{S}_{be3D_v} = \frac{\Omega}{x_1}\left[ \begin{array}{c}
		\nu_0 \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
		\frac{\partial c_0}{\partial X_\theta} \\
		\vdots \\
		\nu_{\bar{n}_s} \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
		\frac{\partial c_{\bar{n}_s}}{\partial X_\theta} \\
		\vdots
		   \end{array}
	    \right]
\end{displaymath}

%----------------------------------------------------------------------------------------------------------------------
\subsubsection{$x$ Momentum Source Term}

	Considering next the equation of motion along the first physical co-ordinate, by substitution
of Eq. \ref{eqn:taurx} and replacing Cartesian variables one can write

\begin{displaymath}
	\tau_{rx} - x_1\frac{2}{3}\frac{\partial}{\partial x}(\mu \frac{v}{r}) = \mu\Big[\frac{\partial}{\partial x}(v_1)
	+ \frac{\partial}{\partial r}(v_0)\Big] - x_1\frac{2}{3} \frac{\partial}{\partial x}(\mu \frac{v_1}{x_1})
\end{displaymath}

	Rewriting the Cartesian derivatives using the Calculus as functions of metrics and derivatives along
computational co-ordinate directions yields

\begin{displaymath}
  \begin{array}{c}
	\mu \Big\{\xi_x \frac{\partial v_1}{\partial \xi} + \eta_x \frac{\partial v_1}{\partial \eta}
	+ \xi_r \frac{\partial v_0}{\partial \xi} + \eta_r \frac{\partial v_0}{\partial \eta}\Big\}
	- x_1 \frac{2}{3} \Big\{\xi_x \frac{\partial}{\partial \xi}(\mu \frac{v_1}{x_1})
	+ \eta_x \frac{\partial}{\partial \eta}(\mu \frac{v_1}{x_1}) \Big\}
	\\
	\mu \Big\{X_{0,0} \frac{\partial v_1}{\partial X_0} + X_{1,0} \frac{\partial v_1}{\partial X_1}
	+ X_{0,1} \frac{\partial v_0}{\partial X_0} + X_{1,1} \frac{\partial v_0}{\partial X_1}\Big\}
	- x_1 \frac{2}{3} \Big\{X_{0,0} \frac{\partial}{\partial X_0}(\mu \frac{v_1}{x_1})
	+ X_{1,0} \frac{\partial}{\partial X_1}(\mu \frac{v_1}{x_1}) \Big\}
	\\
	\mu \Big\{ \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,1}\frac{\partial v_0}{\partial X_\theta}
	+ \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,0} \frac{\partial v_1}{\partial X_\theta} \Big\}
	- x_1 \frac{2}{3} \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,0} \frac{\partial}{\partial X_\theta}
	(\mu \frac{v_1}{x_1})
  \end{array}
\end{displaymath}

	which can be simplified to

\begin{equation}
	\tau_{rx} - x_1\frac{2}{3}\frac{\partial}{\partial x}(\mu \frac{v}{r}) =
	\mu \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,1}\frac{\partial v_0}{\partial X_\theta}
	+ \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,0} \Big\{\mu \frac{\partial v_1}{\partial X_\theta}
	- x_1 \frac{2}{3} \frac{\partial}{\partial X_\theta}(\mu \frac{v_1}{x_1}) \Big\}
\label{eqn:xmomcomp}
\end{equation}

	which when combined with Eqs. \ref{eqn:speciescomp} and Eq. \ref{eqn:beginHvbar} yields

\begin{displaymath}
	\bar{S}_{be3D_v} = \frac{\Omega}{x_1}\left[ \begin{array}{c}
		\nu_0 \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
		\frac{\partial c_0}{\partial X_\theta} \\
		\vdots \\
		\nu_{\bar{n}_s} \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
		\frac{\partial c_{\bar{n}_s}}{\partial X_\theta} \\
		\mu \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,1}\frac{\partial v_0}{\partial X_\theta}
		+ \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,0} \Big\{\mu \frac{\partial v_1}{\partial X_\theta}
		- x_1 \frac{2}{3} \frac{\partial}{\partial X_\theta}(\mu \frac{v_1}{x_1}) \Big\} \\
		\vdots
		   \end{array}
	    \right]
\end{displaymath}

%--------------------------------------------------------------------------------------------------------------
\subsubsection{$r$ Momentum Source Term}

	Considering the momentum equation source term along the second co-ordinate direction and
substituting the results of Eqs. \ref{eqn:taurrhat} and \ref{eqn:tauthetatheta} in for
the viscous stress terms yields,

\begin{displaymath}
	\hat{ \tau}_{rr} -\tau_{\theta \theta} - \frac{2}{3}\mu \frac{v}{r}
	- x_1\frac{2}{3}\frac{\partial}{\partial r}(\mu \frac{v}{r}) =
	\mu ( - \frac{2}{3} \frac{\partial u}{\partial x} + \frac{4}{3} \frac{\partial v}{\partial r})
	- \mu \Big\{- \frac{2}{3} (\frac{\partial u}{\partial x} + \frac{\partial v}{\partial r})
	+ \frac{4}{3} \frac{v}{r} \Big\} - \frac{2}{3}\mu \frac{v}{r}
	- x_1\frac{2}{3}\frac{\partial}{\partial r}(\mu \frac{v}{r})
\end{displaymath}

	Rearranging and simplifying results in

\begin{displaymath}
	\mu \Big\{\frac{4}{3}\frac{\partial v}{\partial r} + \frac{2}{3}\frac{\partial v}{\partial r}
	- \frac{2}{3}\frac{\partial u}{\partial x} + \frac{2}{3}\frac{\partial u}{\partial x}  \Big\}
	-\frac{4}{3}(\mu \frac{v}{r}) - \frac{2}{3}(\mu \frac{v}{r}) - x_1\frac{2}{3}\frac{\partial}{\partial r}
	(\mu \frac{v}{r})
\end{displaymath}

\begin{displaymath}
	2\mu \frac{\partial}{\partial r}(v) - x_1\frac{2}{3}\frac{\partial}{\partial r}(\mu \frac{v}{r})
	-2\mu \frac{v}{r}
\end{displaymath}

	Rewriting the derivatives and substituting for the computational variables

\begin{displaymath}
  \begin{array}{c}
	2\mu\Big\{\xi_r \frac{\partial v_1}{\partial \xi} + \eta_r \frac{\partial v_1}{\partial \eta} \Big\}
	-x_1\frac{2}{3}\Big\{\xi_r\frac{\partial}{\partial \xi}(\mu\frac{v_1}{x_1}) + \eta_r\frac{\partial}
	{\partial \eta}(\mu\frac{v_1}{x_1})\Big\} - 2\mu \frac{v_1}{x_1}
	\\
	2\mu\Big\{X_{0,1} \frac{\partial v_1}{\partial X_0} + X_{1,1} \frac{\partial v_1}{\partial X_1} \Big\}
	-x_1\frac{2}{3}\Big\{X_{0,1}\frac{\partial}{\partial X_0}(\mu\frac{v_1}{x_1}) + X_{1,1}\frac{\partial}
	{\partial X_1}(\mu\frac{v_1}{x_1})\Big\} - 2\mu \frac{v_1}{x_1}
	\\
	2\mu\Big\{\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}\frac{\partial v_1}{\partial X_\theta}
	-\frac{v_1}{x_1} \Big\}
	-x_1\frac{2}{3}\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}\frac{\partial}{\partial X_\theta}(\mu\frac{v_1}{x_1})
  \end{array}
\end{displaymath}

	and thus one can finally write

\begin{equation}
	\hat{ \tau}_{rr} -\tau_{\theta \theta} - \frac{2}{3}\mu \frac{v}{r}
	- x_1\frac{2}{3}\frac{\partial}{\partial r}(\mu \frac{v}{r}) =
	\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}\Big\{2\mu\frac{\partial v_1}{\partial X_\theta}
	-x_1\frac{2}{3}\frac{\partial}{\partial X_\theta}(\mu\frac{v_1}{x_1})\Big\} - 2\mu\frac{v_1}{x_1}
\label{eqn:rmomcomp}
\end{equation}

	which when combined with Eqs. \ref{eqn:speciescomp}, \ref{eqn:xmomcomp}, \ref{eqn:rmomcomp},
and \ref{eqn:beginHvbar} yields

\begin{displaymath}
	\bar{S}_{be3D_v} = \frac{\Omega}{x_1}\left[ \begin{array}{c}
		\nu_0 \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
		\frac{\partial c_0}{\partial X_\theta} \\
		\vdots \\
		\nu_{\bar{n}_s} \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
		\frac{\partial c_{\bar{n}_s}}{\partial X_\theta} \\
		\mu \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,1}\frac{\partial v_0}{\partial X_\theta}
		+ \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,0} \Big\{\mu \frac{\partial v_1}{\partial X_\theta}
		- x_1 \frac{2}{3} \frac{\partial}{\partial X_\theta}(\mu \frac{v_1}{x_1}) \Big\} \\
		\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}\Big\{2\mu\frac{\partial v_1}{\partial X_\theta}
		-x_1\frac{2}{3}\frac{\partial}{\partial X_\theta}(\mu\frac{v_1}{x_1})\Big\} - 2\mu\frac{v_1}{x_1} \\
		\vdots
		   \end{array}
	    \right]
\end{displaymath}

%----------------------------------------------------------------------------------------------------------------------
\subsubsection{Energy Equation Source Term}

	The next term to be considered is the energy equation source term, which will be broken down into its
individual components given the number of terms that need to be rewritten.  Starting with the species diffusion
contribution and setting $k$ equal to  0 to $\bar{n}_s$

\begin{displaymath}
	\sum_{k = 0}^{\bar{n}_s}(\nu_k \frac{\partial c_k}{\partial r}h_k) =
	\sum_{k = 0}^{\bar{n}_s}\nu_k h_k \Big\{\xi_r \frac{\partial c_k}{\partial \xi} +
	\eta_r \frac{\partial c_k}{\partial \eta}\Big\} =
	\sum_{k = 0}^{\bar{n}_s}\nu_k h_k \Big\{X_{0,1}\frac{\partial c_k}{\partial X_0} +
	X_{1,1} \frac{\partial c_k}{\partial X_1}\Big\}
\end{displaymath}

	which can be simplified to

\begin{equation}
	\sum_{k = 0}^{\bar{n}_s}(\nu_k \frac{\partial c_k}{\partial r}h_k) =
	\sum_{k = 0}^{\bar{n}_s}\nu_k h_k \Big\{\sum_{\theta = 0}^{\bar{n}_d} X_{\theta,1}
	\frac{\partial c_k}{\partial X_\theta}\Big\}
\label{eqn:energyA}
\end{equation}

	Next is the heat transfer term, where we will let $k^*$ represent the turbulent coefficient of
thermal conductivity, so as not to confuse it with $k$, the specific turbulent kinetic energy

\begin{displaymath}
	- q_{c_r} = -(-k^* \frac{\partial T}{\partial r}) = k^* \Big\{\xi_r \frac{\partial T}{\partial \xi}
	+ \eta_r \frac{\partial T}{\partial \eta}\Big\} = k^*\Big\{X_{0,1} \frac{\partial T}{\partial X_0}
	+ X_{1,1} \frac{\partial T}{\partial X_1}\Big\}
\end{displaymath}

	where it is noted that Eq. \ref{eqn:rheatflux} was used to describe the heat flux term.  Simplifying
the above yields,

\begin{equation}
	- q_{c_r} = k^*\sum_{\theta = 0}^{\bar{n}_d} X_{\theta,1} \frac{\partial T}{\partial X_\theta}
\label{eqn:energyB}
\end{equation}

	Considering next the first stress term $\tau_{rx}$ and using the results of Eq. \ref{eqn:taurx}

\begin{displaymath}
	\tau_{rx}u = u\Big\{\mu\Big[\frac{\partial}{\partial x}(v) + \frac{\partial}{\partial r}(u)\Big]\Big\} =
	u\mu\Big\{\xi_x \frac{\partial v}{\partial \xi} + \eta_x \frac{\partial v}{\partial \eta} +
	\xi_r \frac{\partial u}{\partial \xi} + \eta_r \frac{\partial u}{\partial \eta} \Big\}
\end{displaymath}

\begin{displaymath}
	\tau_{rx}u =
	v_0 \mu \Big\{X_{0,0} \frac{\partial v_1}{\partial X_0} + X_{1,0} \frac{\partial v_1}{\partial X_1} +
	X_{0,1} \frac{\partial v_0}{\partial X_0} + X_{1,1} \frac{\partial v_0}{\partial X_1} \Big\}
\end{displaymath}

	which can be simplified to

\begin{equation}
	\tau_{rx}u = v_0\mu
	\Big\{\sum_{\theta = 0}^{\bar{n}_d} X_{\theta,1}\frac{\partial v_0}{\partial X_\theta} +
	\sum_{\theta = 0}^{\bar{n}_d} X_{\theta,0}\frac{\partial v_1}{\partial X_\theta}\Big\}
\label{eqn:energyC}
\end{equation}

	The second stress term can be written with the help of Eq. \ref{eqn:taurrhat} as

\begin{displaymath}
	\hat{ \tau}_{rr}v = v\Big\{\mu\Big[ -\frac{2}{3} \frac{\partial}{\partial x}(u)
	+ \frac{4}{3} \frac{\partial}{\partial r}(v)\Big]\Big\} = v\mu\Big\{-\frac{2}{3}\Big[
	\xi_x\frac{\partial u}{\partial \xi} + \eta_x\frac{\partial u}{\partial \eta}\Big] + \frac{4}{3}\Big[
	\xi_r\frac{\partial v}{\partial \eta} + \eta_r\frac{\partial v}{\partial \eta}\Big] \Big\}
\end{displaymath}

\begin{displaymath}
	\hat{ \tau}_{rr}v = v_1\mu\Big\{-\frac{2}{3}\Big[
	X_{0,0}\frac{\partial v_0}{\partial X_0} + X_{1,0}\frac{\partial v_0}{\partial X_1}\Big] + \frac{4}{3}\Big[
	X_{0,1}\frac{\partial v_1}{\partial X_0} + X_{1,1}\frac{\partial v_1}{\partial X_1}\Big] \Big\}
\end{displaymath}

	which can be simplified to

\begin{equation}
	\hat{ \tau}_{rr}v = v_1\mu\Big\{-\frac{2}{3}\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,0}
	\frac{\partial v_0}{\partial X_\theta} + \frac{4}{3}\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
	\frac{\partial v_1}{\partial X_\theta} \Big\}
\label{eqn:energyD}
\end{equation}

	The turbulent energy diffusion term is similar to the heat transfer term

\begin{displaymath}
	{\mu_k}^* \frac{\partial k}{\partial r} = {\mu_k}^* \Big\{\xi_r\frac{\partial k}{\partial \xi}
	+ \eta_r\frac{\partial k}{\partial \eta}\Big\} = {\mu_k}^* \Big\{X_{0,1}\frac{\partial k}{\partial X_0}
	+ X_{1,1}\frac{\partial k}{\partial X_1}\Big\}
\end{displaymath}

	which is simplified to

\begin{equation}
	{\mu_k}^* \frac{\partial k}{\partial r} = {\mu_k}^* \Big\{\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
	\frac{\partial k}{\partial X_\theta}\Big\}
\label{eqn:energyE}
\end{equation}

	The next term has no derivative terms and hence requires only direct substitution for the computational
variables

\begin{equation}
	- \frac{2}{3}\mu\frac{v^2}{r} = - \frac{2}{3}\mu\frac{{v_1}^2}{x_1}
\label{eqn:energyF}
\end{equation}

	The last two terms are treated as follows

\begin{displaymath}
	- x_1\frac{2}{3}\frac{\partial}{\partial x}(\mu \frac{uv}{r}) = -x_1\frac{2}{3}\Big\{\xi_x
	\frac{\partial}{\partial \xi}(\mu\frac{v_0 v_1}{x_1}) + \eta_x\frac{\partial}{\partial \eta}
	(\mu\frac{v_0 v_1}{x_1})\Big\} = -x_1\frac{2}{3}\Big\{X_{0,0}
	\frac{\partial}{\partial X_0}(\mu\frac{v_0 v_1}{x_1}) + X_{1,0}\frac{\partial}{\partial X_1}
	(\mu\frac{v_0 v_1}{x_1})\Big\}
\end{displaymath}

\begin{displaymath}
	- x_1\frac{2}{3}\frac{\partial}{\partial r}(\mu \frac{v^2}{r}) = -x_1\frac{2}{3}\Big\{\xi_r
	\frac{\partial}{\partial \xi}(\mu\frac{{v_1}^2}{x_1}) + \eta_r\frac{\partial}{\partial \eta}(\mu\frac{{v_1}^2}{x_1})\Big\}
	= -x_1\frac{2}{3}\Big\{X_{0,1}
	\frac{\partial}{\partial X_0}(\mu\frac{{v_1}^2}{x_1}) + X_{1,1}\frac{\partial}{\partial X_1}(\mu\frac{{v_1}^2}{x_1})\Big\}
\end{displaymath}

	which can combined and rewritten as

\begin{equation}
	- x_1\frac{2}{3}\frac{\partial}{\partial x}(\mu \frac{uv}{r}) - x_1\frac{2}{3}\frac{\partial}{\partial r}
	(\mu \frac{v^2}{r}) = -x_1\frac{2}{3}\Big\{\sum_{\theta = 0}^{\bar{n}_d} \sum_{\vartheta = 0}^{\bar{n}_d}
	X_{\theta,\vartheta}\frac{\partial}{\partial X_\theta}(\mu\frac{v_\vartheta v_1}{x_1}) \Big\}
\label{eqn:energyG}
\end{equation}

	At this point all the individual terms have been rewritten using the appropriate metric terms and hence the
axisymmetric energy equation source term can be expressed as a combination of Eqs. \ref{eqn:energyA} - \ref{eqn:energyG}

\begin{equation}
  \begin{array}{c}
	\sum_{k = 0}^{\bar{n}_s}\nu_k h_k \Big\{\sum_{\theta = 0}^{\bar{n}_d} X_{\theta,1}
	\frac{\partial c_k}{\partial X_\theta}\Big\} + k^*\sum_{\theta = 0}^{\bar{n}_d} X_{\theta,1}
	\frac{\partial T}{\partial X_\theta} + v_0\mu\Big\{\sum_{\theta = 0}^{\bar{n}_d} X_{\theta,1}
	\frac{\partial v_0}{\partial X_\theta} + \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,0}
	\frac{\partial v_1}{\partial X_\theta}\Big\} \\
	+ v_1\mu\Big\{-\frac{2}{3}\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,0}
	\frac{\partial v_0}{\partial X_\theta} + \frac{4}{3}\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
	\frac{\partial v_1}{\partial X_\theta} \Big\}
	+ {\mu_k}^* \Big\{\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
	\frac{\partial k}{\partial X_\theta}\Big\} \\
	- \frac{2}{3}\mu\frac{{v_1}^2}{x_1}
	 -x_1\frac{2}{3}\Big\{\sum_{\theta = 0}^{\bar{n}_d} \sum_{\vartheta = 0}^{\bar{n}_d}
	X_{\theta,\vartheta}\frac{\partial}{\partial X_\theta}(\mu\frac{v_\vartheta v_1}{x_1}) \Big\}
  \end{array}
\label{eqn:energycomp}
\end{equation}

	which when combined with Eqs. \ref{eqn:speciescomp}, \ref{eqn:xmomcomp}, \ref{eqn:rmomcomp},
and \ref{eqn:beginHvbar} yields

\begin{displaymath}
	\bar{S}_{be3D_v} = \frac{\Omega}{x_1}\left[ \begin{array}{c}
		\nu_0 \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
		\frac{\partial c_0}{\partial X_\theta} \\
		\vdots \\
		\nu_{\bar{n}_s} \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
		\frac{\partial c_{\bar{n}_s}}{\partial X_\theta}
		\\
		\mu \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,1}\frac{\partial v_0}{\partial X_\theta}
		+ \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,0} \Big\{\mu \frac{\partial v_1}{\partial X_\theta}
		- x_1 \frac{2}{3} \frac{\partial}{\partial X_\theta}(\mu \frac{v_1}{x_1}) \Big\}
		\\
		\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}\Big\{2\mu\frac{\partial v_1}{\partial X_\theta}
		-x_1\frac{2}{3}\frac{\partial}{\partial X_\theta}(\mu\frac{v_1}{x_1})\Big\} - 2\mu\frac{v_1}{x_1}
		\\
	\left(\begin{array}{c}
		\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,0} \Big\{v_0\mu\frac{\partial v_1}{\partial X_\theta} -\frac{2}{3}
		v_1\mu\frac{\partial v_0}{\partial X_\theta} \Big\} + \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}\Big\{
		\sum_{k = 0}^{\bar{n}_s}\nu_k h_k \frac{\partial c_k}{\partial X_\theta} +
		k^*\frac{\partial T}{\partial X_\theta} + {\mu_k}^*\frac{\partial k}{\partial X_\theta} \\
		+ v_0 \mu \frac{\partial v_0}{\partial X_\theta} + \frac{4}{3}v_1 \mu \frac{\partial v_1}{\partial X_\theta}
		\Big\} -\frac{2}{3}\Big\{\mu\frac{{v_1}^2}{x_1} + x_1\sum_{\theta = 0}^{\bar{n}_d}\sum_{\vartheta = 0}^{\bar{n}_d}
		X_{\theta,\vartheta}(\mu\frac{v_\vartheta v_1}{x_1})\Big\}
	\end{array}\right)
		\\
		\vdots
		   \end{array}
	    \right]
\end{displaymath}

%--------------------------------------------------------------------------------------------------------------------------
\subsubsection{Turbulent Source Terms}

	Examining the remaining source terms for the turbulence quantities one can write

\begin{displaymath}
	{\mu_k}^* \frac{\partial k}{\partial r} + x_1S_k = {\mu_k}^* \Big\{\xi_r \frac{\partial k}{\partial \xi}
	+\eta_r \frac{\partial k}{\partial \eta}\Big\} + x_1S_k = {\mu_k}^* \Big\{X_{0,1} \frac{\partial k}{\partial X_0}
	+ X_{1,1} \frac{\partial k}{\partial X_1}\Big\} + x_1S_k
\end{displaymath}

\begin{displaymath}
	{\mu_\omega}^* \frac{\partial \omega}{\partial r} + x_1S_\omega = {\mu_\omega}^*
	\Big\{\xi_r \frac{\partial \omega}{\partial \xi}
	+\eta_r \frac{\partial \omega}{\partial \eta}\Big\} + x_1S_\omega = {\mu_\omega}^*
	\Big\{X_{0,1} \frac{\partial \omega}{\partial X_0}
	+ X_{1,1} \frac{\partial \omega}{\partial X_1}\Big\} + x_1S_\omega
\end{displaymath}

	both of which can be simplified similarly to

\begin{equation}
	{\mu_k}^*\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}\frac{\partial k}{\partial X_\theta} + x_1S_k
\label{eqn:kcomp}
\end{equation}

\begin{equation}
	{\mu_\omega}^*\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}\frac{\partial \omega}{\partial X_\theta} + x_1S_\omega
\label{eqn:omegacomp}
\end{equation}

	As a last step, since both $S_k$ and $S_\omega$ contain the variable $P_k$ which itself contains an axisymmetric
term (Eq. \ref{eqn:pkbe3d}), this term must be transformed as well.  Starting from the definition of $P_{k_be3D}$ (where
the $\tilde v$ has been removed for simplicity but is still understood),

\begin{displaymath}
	P_{k_{be3D}} = -\mu_T\frac{2}{3}\frac{v}{r}(\frac{\partial u}{\partial x} + \frac{\partial v}{\partial r})
\end{displaymath}

	Making the substitution for $u$ and $v$ into the computational space variables $v_0$ and $v_1$ respectively while at the
same time replacing the physical space variables in a similar fashion yields,

\begin{displaymath}
	P_{k_{be3D}} = -\mu_T\frac{2}{3}\frac{v_1}{x_1}(\frac{\partial v_0}{\partial x_0} + \frac{\partial v_1}{\partial x_1})
\end{displaymath}

	Using the Calculus to rewrite the Cartesian derivatives in terms of metrics and derivatives along the computational
co-ordinates,

\begin{displaymath}
	P_{k_{be3D}} = -\mu_T\frac{2}{3}\frac{v_1}{x_1}\Big\{\xi_x \frac{\partial v_o}{\partial \xi} +
	\eta_x \frac{\partial v_o}{\partial \eta} + \xi_r \frac{\partial v_1}{\partial \xi} + \eta_r
	\frac{\partial v_1}{\partial \eta}\Big\}
\end{displaymath}

\begin{displaymath}
	= -\mu_T\frac{2}{3}\frac{v_1}{x_1}\Big\{X_{0,0} \frac{\partial v_o}{\partial X_O} +
	X_{1,0} \frac{\partial v_o}{\partial X_1} + X_{0,1} \frac{\partial v_1}{\partial X_0} + X_{1,1}
	\frac{\partial v_1}{\partial X_1}\Big\}
\end{displaymath}

	which can be simplified in summation form to,

\begin{equation}
	P_{k_{be3D}}= -\mu_T\frac{2}{3}\frac{v_1}{x_1}\sum_{\theta=0}^{\theta=1}\sum_{\vartheta=0}^{\vartheta=1}
	X_{\theta,\vartheta}\frac{\partial v_{\vartheta}}{\partial X_{\theta}}
\label{eqn:pkbe3dtrans}
\end{equation}

%----------------------------------------------------------------------------------------------------------------------
\subsubsection{Summary of Axisymmetric Source Terms}

	Therefore the final form of the axisymmetric, multi-species, viscous, turbulent source term can be written as
the combination of Eqs. \ref{eqn:speciescomp}, \ref{eqn:xmomcomp}, \ref{eqn:rmomcomp}, \ref{eqn:kcomp}, and
\ref{eqn:omegacomp}

\begin{equation}
	\bar{S}_{be3D_v} = \frac{\Omega}{x_1}\left[ \begin{array}{c}
		\nu_0 \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
		\frac{\partial c_0}{\partial X_\theta} \\
		\vdots \\
		\nu_{\bar{n}_s} \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}
		\frac{\partial c_{\bar{n}_s}}{\partial X_\theta}
		\\
		\mu \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,1}\frac{\partial v_0}{\partial X_\theta}
		+ \sum_{\theta = 0}^{\bar{n}_d} X_{\theta,0} \Big\{\mu \frac{\partial v_1}{\partial X_\theta}
		- x_1 \frac{2}{3} \frac{\partial}{\partial X_\theta}(\mu \frac{v_1}{x_1}) \Big\}
		\\
		\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}\Big\{2\mu\frac{\partial v_1}{\partial X_\theta}
		-x_1\frac{2}{3}\frac{\partial}{\partial X_\theta}(\mu\frac{v_1}{x_1})\Big\} - 2\mu\frac{v_1}{x_1}
		\\
	\left(\begin{array}{c}
		\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,0} \Big\{v_0\mu\frac{\partial v_1}{\partial X_\theta} -\frac{2}{3}
		v_1\mu\frac{\partial v_0}{\partial X_\theta} \Big\} + \sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}\Big\{
		\sum_{k = 0}^{\bar{n}_s}\nu_k h_k \frac{\partial c_k}{\partial X_\theta} +
		k^*\frac{\partial T}{\partial X_\theta} + {\mu_k}^*\frac{\partial k}{\partial X_\theta} \\
		+ v_0 \mu \frac{\partial v_0}{\partial X_\theta} + \frac{4}{3}v_1 \mu \frac{\partial v_1}{\partial X_\theta}
		\Big\} -\frac{2}{3}\Big\{\mu\frac{{v_1}^2}{x_1} + x_1\sum_{\theta = 0}^{\bar{n}_d}\sum_{\vartheta = 0}^{\bar{n}_d}
		X_{\theta,\vartheta}(\mu\frac{v_\vartheta v_1}{x_1})\Big\}
	\end{array}\right)
		\\
		{\mu_k}^*\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}\frac{\partial k}{\partial X_\theta} + x_1S_k
		\\
		{\mu_\omega}^*\sum_{\theta = 0}^{\bar{n}_d}X_{\theta,1}\frac{\partial \omega}{\partial X_\theta} + x_1S_\omega
		   \end{array}
	    \right]
\label{finalHvbar}
\end{equation}

	while the inviscid source term is defined by Eq. \ref{eqn:finalHbar}

\begin{displaymath}
	\bar{S}_{be3D} = \frac{\Omega}{x_1}\left[ \begin{array}{c}
		\rho_1 v_1 \\
		\vdots \\
		\rho_k v_1 \\
		\rho v_0v_1 \\
		\rho {v_1}^2 \\
		(\rho E + p)v_1 \\
		\rho k v_1 \\
		\rho \omega v_1
		   \end{array}
	    \right]
\end{displaymath}


\documentclass[]{article}
\usepackage{graphicx}
\usepackage{caption}
\graphicspath{ {./images/} }

% Minted
\usepackage[cache=false]{minted}
	\usemintedstyle{vs}
	\usepackage{xcolor}
		\definecolor{light-gray}{gray}{0.97}

% Subsubsection header run along with text.
\usepackage{titlesec}
\titleformat{\subsubsection}[runin]% runin puts it in the same paragraph
	{\normalfont\bfseries}% formatting commands to apply to the whole heading
	{\thesubsection}% the label and number
	{0.5em}% space between label/number and subsection title
	{}% formatting commands applied just to subsection title
	[]% punctuation or other commands following subsection title

\usepackage{enumitem}
\usepackage{hyperref}

\usepackage[normalem]{ulem}

\title{Big Data Analytics: Exercise 4-2}
\author{Brandon Hosley}
\date{\today}

\begin{document}
\maketitle

\section*{Pre-Assignment}
\begin{minted}[breaklines,bgcolor=light-gray]{shell-session}
from pyspark.ml.linalg import Vectors
from pyspark.ml.classification import LogisticRegression
training = spark.createDataFrame([
	(1.0, Vectors.dense([0.0, 1.1, 0.1])),
	(0.0, Vectors.dense([2.0, 1.0, -1.0])),
	(0.0, Vectors.dense([2.0, 1.3, 1.0])),
	(1.0, Vectors.dense([0.0, 1.2, -0.5]))], ["label", "features"])
\end{minted}

\section*{Assignment 1}
\emph{ Do the exercise in section 2.2.1.2 and 2.2.1.3 }

\begin{minted}[breaklines,bgcolor=light-gray]{shell-session}
lr = LogisticRegression(maxIter=10, regParam=0.01)
print("LogisticRegression parameters:\n" + lr.explainParams() + "\n")
model1 = lr.fit(training)

print("Model 1 was fit using parameters: ")
print(model1.extractParamMap())
\end{minted}
\includegraphics[width=\linewidth]{image1} %\vspace{-1.5em}

\section*{Assignment 2}
\emph{ Do the exercise in section 2.2.1.4 and 2.2.1.5 }

\begin{minted}[breaklines,bgcolor=light-gray]{shell-session}
paramMap = {lr.maxIter: 20}
paramMap[lr.maxIter] = 30 # Specify 1 Param, overwriting the original maxIter.
paramMap.update({lr.regParam: 0.1, lr.threshold: 0.55}) # Specify multiple Params.

paramMap2 = {lr.probabilityCol: "myProbability"} # Change output column name
paramMapCombined = paramMap.copy()
paramMapCombined.update(paramMap2)

model2 = lr.fit(training, paramMapCombined)
print("Model 2 was fit using parameters: ")
print(model2.extractParamMap())
\end{minted}
\includegraphics[width=\linewidth]{image2} %\vspace{-1.5em}

\section*{Assignment 3}
\emph{ Do the exercise in section 2.2.1.7 and 2.2.1.8 }

\begin{minted}[breaklines,bgcolor=light-gray]{shell-session}
test = spark.createDataFrame([
	(1.0, Vectors.dense([-1.0, 1.5, 1.3])),
	(0.0, Vectors.dense([3.0, 2.0, -0.1])),
	(1.0, Vectors.dense([0.0, 2.2, -1.5]))], ["label", "features"])

prediction = model2.transform(test)
result = prediction.select("features", "label", "myProbability", "prediction").collect()

for row in result:
	print("features=%s, label=%s -> prob=%s, prediction=%s"
		% (row.features, row.label, row.myProbability, row.prediction))
\end{minted}
\includegraphics[width=\linewidth]{image3} %\vspace{-1.5em}

\section*{Assignment 4}

\emph{ Do the exercise to learn ML pipeline in }
\href{https://spark.apache.org/docs/2.4.0/ml-pipeline.html#example-pipeline
}{Apache Docs}.

\begin{minted}[breaklines,bgcolor=light-gray]{shell-session}
from pyspark.ml import Pipeline
from pyspark.ml.feature import HashingTF, Tokenizer

training = spark.createDataFrame([
	(0, "a b c d e spark", 1.0),
	(1, "b d", 0.0),
	(2, "spark f g h", 1.0),
	(3, "hadoop mapreduce", 0.0)
], ["id", "text", "label"])

tokenizer = Tokenizer(inputCol="text", outputCol="words")
hashingTF = HashingTF(inputCol=tokenizer.getOutputCol(), outputCol="features")
lr = LogisticRegression(maxIter=10, regParam=0.001)
pipeline = Pipeline(stages=[tokenizer, hashingTF, lr])
\end{minted}
\includegraphics[width=\linewidth]{image4.1} %\vspace{-1.5em}

\begin{minted}[breaklines,bgcolor=light-gray]{shell-session}
model = pipeline.fit(training)

test = spark.createDataFrame([
	(4, "spark i j k"),
	(5, "l m n"),
	(6, "spark hadoop spark"),
	(7, "apache hadoop")
], ["id", "text"])

prediction = model.transform(test)
selected = prediction.select("id", "text", "probability", "prediction")
for row in selected.collect():
	rid, text, prob, prediction = row
	print("(%d, %s) --> prob=%s, prediction=%f" % (rid, text, str(prob), prediction))
\end{minted}
\includegraphics[width=\linewidth]{image4.2} %\vspace{-1.5em}

\clearpage

\section*{Assignment 5}
\emph{ Learn a model using the ML pipeline and then test it and show the results. We will use
	\hyperref{CIKM2020 AnalytiCup COVID-19 Retweet}{}
	Prediction Challenge dataset. The CIKM is one of
	the best conferences in Machine Learning world.
 }

\begin{minted}[breaklines,bgcolor=light-gray,fontsize=\scriptsize]{python}
from pyspark.ml.linalg import Vectors
from pyspark.ml.evaluation import RegressionEvaluator
from pyspark.ml.classification import LogisticRegression
from pyspark.ml import Pipeline
from pyspark.ml.feature import HashingTF, Tokenizer, VectorAssembler, VectorIndexer
from pyspark.sql.functions import split

schema = 'TweetId LONG, Username STRING, Timestamp TIMESTAMP, Followers INT, Friends INT, Retweets INT, Favorites INT, Entities STRING, Sentiment STRING, Mentions STRING, Hashtags STRING, URLs STRING'

df = spark.read.schema(schema) \
  .option("delimiter", "\t") \
  .option("timestampFormat","EEE MMM dd HH:mm:ss Z yyyy") \
  .csv("/user/data/CSC534BDA/COVID19-Retweet/TweetsCOV19-train.tsv")
df.printSchema()

sent_col = split(df['Sentiment'], ' ')
df = df.withColumn('Positivity', sent_col.getItem(0).cast('INT'))
df = df.withColumn('Negativity', sent_col.getItem(1).cast('INT'))

(trainingData, testData) = df.randomSplit([0.8, 0.2])

tokenizer = Tokenizer(inputCol="Entities", outputCol="words")
hashingTF = HashingTF(inputCol=tokenizer.getOutputCol(), outputCol="Words")
assembler = VectorAssembler(outputCol='features', \
  inputCols=['Followers', 'Friends', 'Favorites', 'Positivity', 'Negativity'])

estimator = LogisticRegression(labelCol='Retweets', featuresCol='features', maxIter=10, regParam=0.001)

pipeline = Pipeline(stages=[tokenizer, hashingTF, assembler, lr])
model = pipeline.fit(trainingData)

# Test

predictions = model.transform(testData)
evaluator = RegressionEvaluator(predictionCol="prediction", \
  labelCol="Retweets",metricName="r2")
print("R Squared (R2) on test data = %g" % \
  evaluator.evaluate(predictions))
predictions.select("prediction","Retweets","features").show(5)
\end{minted}
\includegraphics[width=\linewidth]{image5.5} \vspace{1.5em}

For this model we achieve a
($R^2 = 0.251982$)
which, while still a weak performer,
is a somewhat significant predictor.

Unfortunately we were unable to utilize some of the other metrics as the hashing of the tokenized versions of both Entities and Mentions caused heap overflow.

While the small sample of the data set suggested that the retweets numbers fit a Tweedie distribution, the logistic regression ended up out-performing all of the other models tested.

\clearpage

\section*{Appendix:}
The following are all of the models that were used to explore the provided data before the final selection was made.

\begin{minted}[breaklines,bgcolor=light-gray]{shell-session}
from pyspark.ml.linalg import Vectors
from pyspark.ml.classification import LogisticRegression
from pyspark.ml import Pipeline
from pyspark.ml.feature import HashingTF, Tokenizer

schema = 'TweetId LONG, Username STRING, Timestamp TIMESTAMP, Followers INT, Friends INT, Retweets INT, Favorites INT, Entities STRING, Sentiment STRING, Mentions STRING, Hashtags STRING, URLs STRING'

# Define the Schema

df = spark.read.schema(schema) \
	.option("delimiter", "\t") \
	.option("timestampFormat","EEE MMM dd HH:mm:ss Z yyyy") \
	.csv("/user/data/CSC534BDA/COVID19-Retweet/TweetsCOV19-train.tsv")
df.printSchema()

# Fix Sentiment

sent_col = split(df['Sentiment'], ' ')
df = df.withColumn('Positivity', sent_col.getItem(0).cast('INT'))
df = df.withColumn('Negativity', sent_col.getItem(1).cast('INT'))

# Split Data

assembler = VectorAssembler( \
	outputCol='features', \
	inputCols=['Followers', 'Friends', 'Positivity', 'Negativity'])
features_df = assembler.transform(df)

(trainingData, testData) = features_df.randomSplit([0.8, 0.2])
\end{minted}
\includegraphics[width=\linewidth]{image5.1} %\vspace{-1.5em}

\begin{minted}[breaklines,bgcolor=light-gray]{shell-session}
from pyspark.ml.regression import GeneralizedLinearRegression

glr = GeneralizedLinearRegression(labelCol='Retweets', featuresCol='features', \
family="gaussian", link="identity", maxIter=10, regParam=0.3)
glr_model = glr.fit(trainingData)

glr_predictions = glr_model.transform(testData)
glr_evaluator = RegressionEvaluator(predictionCol="prediction", \
labelCol="Retweets",metricName="r2")
print("R Squared (R2) on test data = %g" % \
glr_evaluator.evaluate(glr_predictions))
glr_predictions.select("prediction","Retweets","features").show(5)
\end{minted}
\includegraphics[width=\linewidth]{image5.2} %\vspace{-1.5em}

Logistic regression was performed and did not give very good results.
($R^2 = -0.0098882$)
Slightly worse than a fixed predictor.
Next we will try a decision tree regression to compensate for the highly irregular distribution of retweets.

\begin{minted}[breaklines,bgcolor=light-gray]{shell-session}
from pyspark.ml.regression import DecisionTreeRegressor

dt_model = DecisionTreeRegressor(labelCol='Retweets', featuresCol='features').fit(trainingData)

dt_predictions = dt_model.transform(testData)
dt_evaluator = RegressionEvaluator(predictionCol="prediction", \
	labelCol="Retweets",metricName="r2")
print("R Squared (R2) on test data = %g" % \
	dt_evaluator.evaluate(dt_predictions))
dt_predictions.select("prediction","Retweets","features").show(5)
\end{minted}
\includegraphics[width=\linewidth]{image5.3} %\vspace{-1.5em}

This model performs worse than the linear regression.
($R^2 = -0.0693814$)

\begin{minted}[breaklines,bgcolor=light-gray]{shell-session}
from pyspark.ml.regression import IsotonicRegression

ir = IsotonicRegression(labelCol='Retweets', featuresCol='features', regParam=0.3)
ir_model = ir.fit(trainingData)

ir_predictions = ir_model.transform(testData)
ir_evaluator = RegressionEvaluator(predictionCol="prediction", \
	labelCol="Retweets",metricName="r2")
print("R Squared (R2) on test data = %g" % \
	ir_evaluator.evaluate(ir_predictions))
ir_predictions.select("prediction","Retweets","features").show(5)
\end{minted}
\includegraphics[width=\linewidth]{image5.4} %\vspace{-1.5em}

The piece-wise fit of an isotonic regression provides
us with the first model to perform better than a fixed model
($R^2 = 0.0224688$)
but is still essentially an insignificant predictor.

\end{document}

\begin{minted}[breaklines,bgcolor=light-gray]{shell-session}

\end{minted}
\includegraphics[width=\linewidth]{image1} %\vspace{-1.5em}

\includegraphics[width=\linewidth]{image1} %\vspace{-1.5em}
\begin{minted}[breaklines,bgcolor=light-gray,fontsize=\scriptsize]{shell-session}
\end{minted}
\mintinline[bgcolor=light-gray]{bash}{} \begin{enumerate}[before=\itshape,font=\normalfont,label=\alph*.]
\end{enumerate}

2021-Spr Big Data Analytics/Ex4-2/Hosley_Ex4-2.tex


%!TEX program = xelatex

\documentclass[a4paper]{article}

\usepackage{polyglossia}
\setdefaultlanguage{english}

\usepackage{amsmath}
\usepackage[backend=biber]{biblatex}
\usepackage[autostyle]{csquotes}
\usepackage{fontenc}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{parskip}

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\addbibresource{./Internal_Assessment.bib}
\everymath{\displaystyle}

\title{Investigating Fourier's Solution to the Heat Equation\\$\frac{\partial{u}}{\partial{t}}-\alpha\nabla^{2}u=0$}
\date{June 2015}
\author{Tarik Onalan}

\begin{document}
    \input{./Internal_Assessment.title.tex}

    %--------------------------------------------------------------------------------------------------%

    \maketitle

    %--------------------------------------------------------------------------------------------------%

    \tableofcontents

    %--------------------------------------------------------------------------------------------------%

    \section{Introduction}

        The heat equation is used to describe the distribution of heat in an object over time. While
        not introduced by Fourier, it is a method for solving the equation proposed by Fourier in
        his \textit{Théorie analytique de la chaleur}---translated as ``an analytical theory of
        heat''---that we will be investigating. I chose to investigate Fourier's solution to the heat
        equation because it is through his solution that the Fourier Transform, a popular tool in signal
        processing, was defined. I frequently use the Fourier Transform while doing data analysis, and I
        wanted to learn how and why it was created.

        \begin{center}
            \includegraphics{./heat_eq.png}
        \end{center}

    %--------------------------------------------------------------------------------------------------%

    \section{Solution}
        \subsection{Defining the heat equation}
            The heat equation (as defined in a rod) is as follows:
            \begin{equation}
                u_{t} = \alpha u_{xx}
            \end{equation}
            where $u = u\left(x,t\right)$ is a function of two variables $x$ and $t$.
            \begin{itemize}
                \item $x$: position, where $x \in [0,L]$ and $L$ is the length of the rod
                \item $t$: time, where $t\geq0$
            \end{itemize}
            assuming the initial condition
            \begin{equation}
                u\left(x,0\right) = f\left(x\right) \quad \forall x \in [0,L]
            \end{equation}
            and the following boundary conditions
            \begin{equation}
                u\left(0,t\right) = 0 = u\left(L,t\right) \quad \forall t > 0
            \end{equation}

            \begin{center}
                \includegraphics{./temp_dist.png}
            \end{center}

        \subsection{Our objective}
            We are looking for nontrivial solutions to to $\left(1\right)$ that satisfy the conditions defined by
            equations $\left(2\right)$ and $\left(3\right)$. We still need more information, however. Let us look at equation
            $\left(1\right)$ again:
            \[
                u_{t} = \alpha u_{xx}
            \]
            We can rearrange this equation so that it appears as follows:
            \[
                u_{t} - \alpha u_{xx} = 0
            \]
            What does this mean? The equation is a linear homogeneous partial differential equation,
            meaning that $u$ can be written as the product
            \begin{equation}
                u\left(x,t\right)=X\left(x\right)T\left(t\right)
            \end{equation}
            through separation of variables.

        \subsection{Solving the constituent equations $T\left(t\right)$ and $X\left(x\right)$}
            \[
                \begin{cases}
                    u_{t} = X\left(x\right)T'\left(t\right) \\
                    u_{xx} = X''\left(x\right)T\left(t\right) \\
                \end{cases}
            \]
            \\
            \[
                X\left(x\right)T'\left(t\right) = \alpha X''\left(x\right)T\left(t\right) \\
            \]
            \[
                \frac{T'\left(t\right)}{\alpha T\left(t\right)} = \frac{X''\left(x\right)}{X\left(x\right)}
            \]
            One thing to notice at this point is that both sides, though dependent on two independent
            variables, are equivalent. This means that both are equal to some constant that we will
            call $-\lambda$ (the negative is for simplicity later on).

            Now we have the following:
            \[
                \frac{T'\left(t\right)}{\alpha T\left(t\right)} = \frac{X''\left(x\right)}{X\left(x\right)} = -\lambda
            \]
            \[
                \begin{cases}
                    \frac{T'\left(t\right)}{\alpha T\left(t\right)} = -\lambda \\
                    \frac{X''\left(x\right)}{X\left(x\right)} = -\lambda
                \end{cases}
            \]
            Let us take the first equation, $\frac{T'\left(t\right)}{\alpha T\left(t\right)} = -\lambda$:
            \[
                \frac{1}{T\left(t\right)}\cdot\frac{dT}{dt} = -\lambda \alpha
            \]
            \[
                \int{\frac{1}{T\left(t\right)}}dT = -\int{\lambda \alpha}dt
            \]
            \[
                \ln{T\left(t\right)} + K_1= -\lambda \alpha t + K_2
            \]
            \[
                T\left(t\right) = e^{-\lambda \alpha t + K}
            \]
            \begin{equation}
                T\left(t\right) = A e^{-\lambda \alpha t}
            \end{equation}
            Now let us take the second equation, $\frac{X''\left(x\right)}{X\left(x\right)} = -\lambda$
            \[
                \frac{d^{2}X}{dx^{2}} = -\lambda X\left(x\right)
            \]
            This may seem daunting at first, but let us quickly observe a few things about this
            differential equation:
            \begin{itemize}
                \item Derived twice, it has a coefficient $-\lambda$
                \item Derived twice, it is still the same basic function
            \end{itemize}
            The latter point is very interesting. Only one other function remains the same after
            deriving: $e^{x}$. We have found the characteristic function for $X\left(x\right)$. All that remains
            is calculating the coefficients ($a$, in this case):
            \[
                \frac{d^{2} e^{ax}}{dx^{2}} = -\lambda e^{ax}
            \]
            \[
                a^{2} e^{ax} + \lambda e^{ax} = 0
            \]
            \[
                e^{ax}\left(a^{2} + \lambda\right) = 0
            \]
            Given that $e^{ax} \neq 0$:
            \[
                a^{2} + \lambda = 0
            \]
            \[
                a = \pm\sqrt{-\lambda}
            \]
            Therefore,
            \[
                X\left(x\right) = \sum_{b \in a}{B e^{bx}}
            \]
            \begin{equation}
                X\left(x\right) = B e^{\sqrt{-\lambda}x} + C e^{-\sqrt{-\lambda}x}
            \end{equation}

        \subsection{Limiting $\lambda$ to nontrivial solutions}
            Let us begin with $\lambda < 0$, and consider equation $\left(6\right)$:
            \[
                X\left(x\right) = B e^{\sqrt{\lambda}x} + C e^{-\sqrt{\lambda}x}
            \]
            Now, let us consider the boundary condition defined by equation $\left(3\right)$:
            \[
                X\left(0\right) = 0 = B e^{\sqrt{\lambda} \cdot 0} + C e^{-\sqrt{\lambda} \cdot 0}
            \]
            \[
                X\left(0\right) = 0 = B e^{0} + C e^{0}
            \]
            Which would mean that $B = 0 = C$, a trivial solution.

            Now let us consider $\lambda = 0$, again with equation $\left(6\right)$:
            \[
                X\left(0\right) = 0 = B e^{\sqrt{0}x} + C e^{-\sqrt{0}x}
            \]
            \[
                X\left(0\right) = 0 = B e^{0} + C e^{0}
            \]
            Which would again mean that $B = 0 = C$.

            Thus, $\lambda > 0$. With this knowledge, we can make a couple of changes to equation $\left(6\right)$
            using Euler's formula:
            \[
                X\left(x\right) = B e^{i\sqrt{\lambda} x} + C e^{-i\sqrt{\lambda} x}
            \]
            This is where $-\lambda$ becomes preferable to $\lambda$, as it only becomes possible to use Euler's
            formula on the exponent when it is $\sqrt{-\lambda} x$, as we can factor out an $i$ and make it a
            complex number. The expansion of the above equation yields
            \[
                X\left(x\right) = B\left(\cos{\left(\sqrt\lambda x\right)} + i\sin{\left(\sqrt\lambda x\right)}\right) + C\left(\cos{\left(\sqrt\lambda x\right)} - i\sin{\left(\sqrt\lambda x\right)}\right)
            \]
            Grouping like terms results in the equation
            \[
                X\left(x\right) = B\sin{\left(\sqrt\lambda x\right)} + C\cos{\left(\sqrt\lambda x\right)}
            \]
            From there, solving for the boundary conditions defined in equation $\left(3\right)$ yields:
            \[
                X\left(0\right) = 0 = B\sin{\left(\sqrt\lambda \cdot 0\right)} + C\cos{\left(\sqrt\lambda \cdot 0\right)}
            \]
            \[
                X\left(0\right) = 0 = B\sin{0} + C\cos{0}
            \]
            Which means that $C = 0$. However, another piece of information can be gained from
            this. If we look closely at the following equation, given $C = 0$:
            \[
                X\left(L\right) = 0 = B\sin{\left(\sqrt\lambda \cdot L\right)}
            \]
            We can see that we can calculate possible values for $\sqrt\lambda$
            \[
                \sin{\left(\sqrt\lambda \cdot L\right)} = 0
            \]
            \[
                \sqrt\lambda = \frac{n \pi}{L}
            \]

        \subsection{Finishing the proof}
            Now that $\lambda$ is defined, we can apply it to our functions $X\left(x\right)$ and $T\left(t\right)$
            \[
                \begin{cases}
                    X\left(x\right) = B \sin\left(\frac{n \pi x}{L}\right) \\
                    T\left(t\right) = A e^{-\frac{n^{2} \pi^{2} \alpha t}{L^{2}}}
                \end{cases}
            \]
            We can now apply this to equation $\left(4\right)$, yielding the particular solution
            \[
                u_{par}\left(x,t\right) = B_{n} \sin\left(\frac{n \pi x}{L}\right) \cdot e^{-\frac{n^{2} \pi^{2} \alpha t}{L^{2}}}
            \]
            Computing the summation of $u_{par}$ for all $n$ yields the general solution
            \[
                u\left(x,t\right) = \sum_{n=1}^{\infty}{u_{par}}
            \]
            \[
                u\left(x,t\right) = \sum_{n=1}^{\infty}{B_{n} \sin\left(\frac{n \pi x}{L}\right) \cdot e^{-\frac{n^{2} \pi^{2} \alpha t}{L^{2}}}}
            \]
            Let us now solve for the initial condition stated in equation $\left(2\right)$
            \[
                u\left(x,0\right) = \sum_{n=1}^{\infty}{B_{n} \sin\left(\frac{n \pi x}{L}\right) \cdot e^{-\frac{n^{2} \pi^{2} \alpha 0}{L^{2}}}}
            \]
            \[
                u\left(x,0\right) = \sum_{n=1}^{\infty}{B_{n} \sin\left(\frac{n \pi x}{L}\right) \cdot e^{0}}
            \]
            \[
                u\left(x,0\right) = \sum_{n=1}^{\infty}{B_{n} \sin\left(\frac{n \pi x}{L}\right)}
            \]
            By the definition of the Fourier Transform, we can now define $B_{n}$
            \[
                B_{n} = \frac{2}{L} \int_{0}^{L}{f\left(x\right) \sin\left(\frac{n \pi x}{L}\right)} dx
            \]
            and solve for $u\left(x,t\right)$, finishing the problem
            \[
                u\left(x,t\right) = \sum_{n=1}^{\infty}{\frac{2}{L} \left(\int_{0}^{L}{f\left(x\right) \sin\left(\frac{n \pi x}{L}\right)} dx\right) \sin\left(\frac{n \pi x}{L}\right) \cdot e^{-\frac{n^{2} \pi^{2} \alpha t}{L^{2}}}}
            \]

    %--------------------------------------------------------------------------------------------------%

    \section{Reflection}

        \vfill

    %--------------------------------------------------------------------------------------------------%

    \nocite{fourierj}
    \printbibliography
\end{document}


\subsection{Kernel Fisher discriminant analysis}

Use LDA with kernel feature spaces.


\documentclass[letterpaper]{article}

\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[utf8]{inputenc}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\title{Notes}
\date{November 11, 2014}
\maketitle
$f:\mathbb{R}^n\to\mathbb{R}^m$ is continous iff $\forall C$ is closed in $R^{m}$ then $f^{-1}(C)$ is closed in $\mathbb{R}^n$.o

assume $f$ is continuous. let $c\in \mathbb{R}^n$ be closed. we want to show $f^{-1}(C)$ is closed.

first we pick a sequence $x_k\in f^{-1}(C)$. or $f(x_k)\in C$. we are picking $x_k$ so that it converges to something (say $y$). now because $f(x)$ is continous, then $f(x_k)\to f(y)$. and because $f(y)\in C$ then $C$ is closed.

\section*{true false}
$f:\mathbb{R}^n\to\mathbb{R}^m$ is continous
\begin{enumerate}
\item
fi $A\subseteq \mathbb{R}^n$ is open then $f(A)$ is open
\item
fi $A\subseteq \mathbb{R}^n$ is closed then $f(A)$ is closed
\item
fi $A\subseteq \mathbb{R}^n$ is compact then $f(A)$ is compact
\item
fi $A\subseteq \mathbb{R}^m$ is open then $f^{-1}(A)$ is open
\item
fi $A\subseteq \mathbb{R}^m$ is compact then $f(A)$ is compact
\end{enumerate}

unions, intersections of $f$or $f^{-1}$ over two sets. $f(A^{c})=(f(A))^{c}$ and same with $f^{-1}$.

\section*{5.5.A}
note that $g'(x)$ is unbounded on $(0,\infty)$. so we cannot sed the ``bounded slope '' argueent for uniform continuity. need to show $\exists r=r(\varepsilon)$ such that if $|x-y|<r$ then $|\sqrt{x}-\sqrt{y}|<\varepsilon$

if we prove this then $\sqrt{x}-\sqrt{y}\le \sqrt{x-y}$ $\sqrt{r}=\varepsilon$

\begin{align*}
  x-y=(\sqrt{x}-\sqrt{y})(\sqrt{x}+\sqrt{y})\ge (\sqrt{x}-\sqrt{y})^2\\
  \sqrt{x-y}\ge \sqrt{x}-\sqrt{y}
\end{align*}
\section*{5.5.D}
show that $f(x)=x^p$ is not uniformally continuous on $\mathbb{R}$ is $p>1$

\begin{align*}
  \frac{x^p-y^p}{x-y}=|xx^{p-1}-y^p|=xx^{p-1}-x^{p-1}y+x^{p-1}y-y^{p}|le |x^{p-1}||x-y|+|y||x^{p-1}-y^{p-1}|
\end{align*}
\section*{T is continouous, A is closed, it T(A) closed?}
no, hint, look for $T:\mathbb{R}^2\to \mathbb{R}$ or $\mathbb{R}^2$
 where $T$ is a linear transform (matrix), example $f(x)=\frac{1}{x^2+1}$ on $\mathbb{R}$, $f(\mathbb{R})=(0.1]$

 \section*{5.4.J}
 let $A$ be compact in $\mathbb{R}^n$. show that $\forall x\in \mathbb{R}^n\exists a\in A$ such that $a$ is the closest point from $A$ so $x$. that is $||x-a||\le||x-y||\forall y \in A$.
 \subsubsection*{proof}
 $x$ is a fixed point. $f(y)=||x-y||$. $A$ is compact, if we showthat $f$ is continous then $f$ has  min on $A$.

 if $||z-y||<r$ then $|f(z)-f(y)|<\varepsilon$. $| ||x-z||-||x-y|| |\le ||z-y||$. need $r=\epsilon$
\section*{5.5.HI}
let $f$ be continuous on $(0,1]$ show $f$ is uniformallly continuous iff $\lim_{x\to 0^+}f(x)$ exists.

asssuming $f$ is uniformally continuous, $|f(x)-f(y)|<\varepsilon$ whenever $|x-y|<r$. take $x_k$ any decreasing sequence converging to zero. we use the cauchy condition. $\forall r\exists N$ such that $|x_k-x_l|<r$ if $k,l\ge N$. so $|f(x_k)-f(x_l)|<\varepsilon$ then $f(x_k)$ is cauchy. and so $\lim_{k\to\infty}f(x_k)=L=\lim_{x\to0^+}f(x)$

other way, we need to shwo that $r$ does not depend on $\varepsilon$
\end{document}


\documentclass{article}

\usepackage{mathrsfs,amsmath}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{listings}
\usepackage{syntax}
\usepackage{pythonhighlighting}
\usepackage{graphicx}

\usepackage[margin=1.4in]{geometry}
\graphicspath{ {./images/} }

\title{Exercise \#00 | CS 335}
\author{Jared Dyreson\\
        California State University, Fullerton}

\DeclareRobustCommand{\bowtie}{%
  \mathrel\triangleright\joinrel\mathrel\triangleleft}

\usepackage [english]{babel}
\usepackage [autostyle, english = american]{csquotes}
\MakeOuterQuote{"}

\titlespacing*{\section}
{0pt}{5.5ex plus 1ex minus .2ex}{4.3ex plus .2ex}
\titlespacing*{\subsection}
{0pt}{5.5ex plus 1ex minus .2ex}{4.3ex plus .2ex}

\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
}

\begin{document}

\maketitle
\tableofcontents

\newpage

\section{Examples}

\subsection{Arithmetic}

\begin{flushleft}

\textbf{Problem:}

\begin{python}
def arithmetic(lst):
    x = lst[0]
    y = lst[1]
    lst[2] = x + y
    return lst[0] + lst[1]
\end{python}

\textbf{Analysis:} Each line only contains one 1 step, therefore it linear. Thus having a classification of $O(n)$.

\end{flushleft}

\subsection{Nested Function Calls}

\begin{flushleft}

\begin{python}
def setup():
    forward = make_list(20) # n + 3 : dependent of defined size and contents of function called below
    backward = make_list(30) # n + 3 ^ see above
    return forward, backward # 1
    # 2(n + 3) + 1 => 2n + 6 + 1 => 2n + 7

def make_list(n):
    L = [] # 1
    for i in range(n): # n
        L.append(0) # 1
    return L # 1
    # 1 + n + 1  + 1 => n + 3
\end{python}

\textbf{Analysis:} Therefore, the current runtime is $O(2n + 7)$. However, since we are classifying algorithms in Big Oh, we ignore leading coefficients and only focus on the leading term.
Thus, the true classification of this algorithm is of $O(n)$, as it is directly proportional to the input of the problem set.

\end{flushleft}

\subsection{Loops}

$$T(n) = \sum_{x \in X} t_{x}$$

\begin{flushleft}

\begin{python}
for x in range(100):
    print("hello") # please assume printing only takes one instruction/atomic
    print("world")
    print("goodbye")
\end{python}

\textbf{Analysis:} Since this loop only contains atomics, we can add up the amount of them and use it as our coefficient. Thus becoming: $O(3n) \implies O(n)$

\end{flushleft}

\subsection{Loops in Sequence}

\begin{flushleft}
\begin{python}
def func():
    for x in range(100):
        # contains three atomics
        print("hello")
        print("hello")
        print("hello")
    for x in range(1000):
        # contains two atomics
        print("world")
        print("hello")
\end{python}

\textbf{Analysis:} Since both of these loops only contain atomics, we can add up the amount of them and use it as our coefficient for each. Both loops are independent of one another and do not contribute to the overall runtime classification. Thus becoming: $( O(3n) + O(2n) ) \implies O(5n) \implies O(n)$

\end{flushleft}

\subsection{Nested Loops}

\begin{flushleft}

\begin{python}
for x in range(10):
    # three atomics
    for y in range(10):
        # two atomics
\end{python}

\textbf{Analysis:} When attempting to analyze the runtime of nested loops, we need to count how many loop calls there are. This will give us the degree our polynomial will be. These instructions compound on one another, as the parent must execute along with all it's children. In this case, our deepest for loop call is of $O(2n)$ and our parent is $O(3n)$. We can determine the runtime by saying that:

$$O(2n) \times O(3n) \implies O(6n^{2}) \implies O(n^{2})$$

\end{flushleft}

\newpage

\section{General Notes}

\begin{itemize}
\item If a math function gives a large resultant from a small input size, please refrain from using this algorithm

\includegraphics[width=7cm]{joy.jpg}
\end{itemize}

\end{document}