\section{Simplified Higher-Order Closure (SHOC)}

\subsection{Introduction}

Simplified Higher Order Closure \citep[SHOC;][]{Bogenschutz_Krueger13} is a parameterization of subgrid-scale (SGS) clouds and turbulence.  It is formulated to parameterize SGS shallow cumulus, stratiform cloud, and boundary layer turbulence in models that can either resolve deep convection or has an existing deep convection parameterization.  SHOC is an assumed-PDF based parameterization and uses a double Gaussian PDF to diagnose cloud fraction, cloud water, and higher-order turbulence moments.  SHOC is only a liquid cloud parameterization, thus it is assumed that any model SHOC is implemented in can treat the ice cloud phase.

Table~\ref{table:prognostic} describes the SHOC prognostic variables and their nomenclature to be used throughout this document.

\begin{table}[b]
\caption{Prognostic Variables in SHOC}
\centering
\begin{tabular}{c c c}
\hline\hline
variable & description & units \\
\hline
$\theta_{l}$ & Liquid water potential temperature & K \\
$q_{t}$ & Total water mixing ratio (vapor + cloud liquid) & kg/kg \\
$e$ & Turbulent kinetic energy & m$^2$/s$^2$ \\
$u$ & Zonal wind component & m/s \\
$v$ & Meridional wind component & m/s \\
$c$ & Tracer constituent & varies \\
\hline
\end{tabular}
\label{table:prognostic}
\end{table}

The liquid water potential temperature, $\theta_{l}$, is defined as:
%
\begin{equation}
  \theta_{l} \approx \theta - \frac{L_{v}}{c_{pd}}q_{l}
  \label{thetal}
\end{equation}
%
where $\theta$ is potential temperature, $L_{v}$ is the latent heat of vaporization, $c_{pd}$ the specific heat of dry air at constant pressure, $q_{l}$ the liquid water mixing ratio.  The turbulent kinetic energy ($\overline{e}$) is defined as
%
\begin{equation}
  \overline{e} = 0.5(\overline{u^{'2}}+\overline{v^{'2}}+\overline{w^{'2}}) ,
  \label{tke}
\end{equation}
%
where $\overline{u^{'2}}$, $\overline{v^{'2}}$, and $\overline{w^{'2}}$ represent the SGS zonal, meridional, and vertical wind variances, respectively.

In the SHOC parameterization, all prognostic variables are defined vertically at the mid-point of the grid box.

Table~\ref{table:diagnostic} describes key diagnostic variables used throughout the SHOC parameterization, and their respective locations on the vertical grid.  Note that many diagnostic variables are defined at the interfaces of the grid box.  This is because many diagnostic variables are the result of centered vertical differences of the prognostic variables.

\begin{table}[ht]
\caption{Key Diagnostic Variables in SHOC.  M in the location column indicates that the variable is located vertically in the mid-point of the grid box, while I indicates that the variable is located at the grid interfaces.}
\centering
\begin{tabular}{c c c c}
\hline\hline
variable & description & units & location \\
\hline
$L$ & Turbulent Length Scale & m & M \\
$\overline{\theta_{l}^{'2}}$ & Temperature variance & K$^2$ & I \\
$\overline{q_{t}^{'2}}$ & Moisture variance & kg$^2$/kg$^2$ & I \\
$\overline{w^{'2}}$ & Vertical velocity variance & m$^2$/s$^2$ & M \\
$\overline{w^{'}\theta_{l}^{'}}$ & Vertical temperature flux & K m/s & I \\
$\overline{w^{'}q_{t}^{'}}$ & Vertical moisture flux & m/s kg/kg & I \\
$\overline{q_{t}^{'}\theta_{l}^{'}}$ & Temperature and moisture covariance & K kg/kg & I \\
$\overline{w^{'3}}$ & Third moment of vertical velocity &  m$^3$/s$^3$ & I \\
$\overline{w^{'}\theta_{v}^{'}}$ & Buoyancy flux & K m/s & M \\
$K_{m}$ & Eddy diffusivity for momentum & m$^2$/s & M \\
$K_{h}$ & Eddy diffusivity for heat & m$^2$/s & M \\
\hline
\end{tabular}
\label{table:diagnostic}
\end{table}

The code for SHOC breaks down each process into a separate subroutine.  Briefly, the order of operations of SHOC is described below.  Each process is then expanded upon with its own section.

SHOC order of operations:
\begin{enumerate}
  \item \textbf{Diagnose Turbulence Length Scale} (section~\ref{turb_scale}): The length scale represents the size of unresolved large eddies in a column.  This is needed to close the TKE equation and to diagnose several second order moments.
  \item \textbf{Solve the Turbulence Kinetic Energy Equation} (section~\ref{tke_equation}): Advance the TKE equation (due to shear production, buoyant production, and dissipation processes) one time step.  Note that advection of TKE is performed by the host model, while turbulent transport of TKE is done by SHOC turbulence diffusion.
  \item \textbf{Perform Turbulence Diffusion} (section~\ref{turb_diffusion}): Using eddy coefficients derived from TKE, advance $\overline{u}$, $\overline{v}$, $\overline{\theta_{l}}$, $\overline{q_{t}}$ , $\overline{e}$, and any tracers ($\overline{c}$) one time step using an implicit diffusion solver.
  \item \textbf{Diagnose the Second Order Moments} (section~\ref{diag_second}): Diagnose $\overline{q_{t}^{'2}}$, $\overline{\theta_{l}^{'2}}$, $\overline{q_{t}^{'}\theta_{l}^{'}}$, $\overline{w^{'2}}$, $\overline{w^{'}\theta_{l}^{'}}$, and $\overline{w^{'}q_{t}^{'}}$.  These are the second order moments needed to close the assumed PDF.
  \item \textbf{Diagnose the Third Order Moment} (section~\ref{diag_third}):  Diagnose the third moment of vertical velocity ($\overline{w^{'3}}$), needed to parameterize vertical velocity skewness in the assumed PDF
  \item \textbf{Compute Assumed PDF} (section~\ref{assumed_pdf}): Use the Assumed PDF to compute SGS cloud water, cloud fraction, and the buoyancy flux ($\overline{w^{'}\theta_{v}^{'}}$).
\end{enumerate}

In SHOC the order of operations is chosen deliberately so that the prognostic variables are updated first and the clouds are diagnosed last.  This is to prevent supersaturation from occurring when SHOC is complete, to avoid any potential conflicts with a microphysics scheme which may be called in the host model.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% TURBULENCE LENGTH SCALE
\subsection{Turbulence Length Scale}
\label{turb_scale}

The empirical formulation is based on the finding that the turbulent length scale is highly correlated with the distance from the wall, strength of the turbulence, boundary layer depth, and local thermal stability (Bogenschutz et al. 2010).  Within the turbulent boundary layer, the length scale definition is set equal to an asymptotic shape, similar to that of \cite{Blackadar_62}.  However it is weighted more strongly by the strength of the turbulence.  This reflects the behavior that as the grid size increases, the SGS TKE increases and so does the mixing length.  The effects of thermal stability are also included to reduce the length scale where the local stability is large.

The formulation in (\ref{thelength}) is empirically determined from LES data and essentially represents a geometric average between the strength of the SGS TKE (as suggested by Texieria et al. 2004) and an asymptote length scale, with a contribution due to stability effects.  The geometric average assures that in close proximity to the surface, the length scale will be small.
%
\begin{equation}
  L=\sqrt[]{8\left[\frac{1}{\tau\sqrt[]{e}kz}+\frac{1}{\tau\sqrt[]{e}L_{\infty}}+0.01\delta\frac{N^{2}}{\overline{e}}\right]^{-1}}
  \label{thelength}
\end{equation}

Above, $k$ is the von Karman constant.  $L_{\infty}$ is the asymptotic value of the length scale as defined in Blackadar (1962) as
%
 \begin{equation}
  L_{\infty}=0.1\frac{\int_{0}^{\infty}\overline{e}^{1/2}z dz}{\int_{0}^{\infty} \overline{e}^{1/2} dz}.
  \end{equation}
 %
   In equation~\ref{thelength} $\delta$ is defined as:
\[
\delta = \left\{
\begin{array}{l l}
  1 & \quad \text{if} \quad N^{2} > 0 \\
  0 & \quad \text{if} \quad N^{2} \le 0 \\
\end{array} \right.
\]
%
where $N^{2}$ is the moist Brunt Vaisala Frequency.  In SHOC $N^{2}$ is defined as:
%
\begin{equation}
  N^{2} = \frac{g}{\overline{\theta_{v}}}\frac{\partial{\overline{\theta_{v}}}}{\partial{z}}
  \label{brunt}
\end{equation}
%
where $\theta_{v}$ is the virtual potential temperature defined as:
%
\begin{equation}
  \theta_{v}=\theta(1 + 0.61q_{v} - q_{l}) ,
  \label{thetav}
\end{equation}
%
where $q_{v}$ is the water vapor mixing ratio.
%
Finally, $\tau$ in equation~\ref{thelength} represents the eddy turnover timescale and is defined as
%
\begin{equation}
  \tau = \frac{D_{b}}{w_{*}},
  \label{conv_scale}
\end{equation}

where $D_{b}$ is the boundary layer depth and is computed according to that of Holtslag and Boville (1993).  $w_{*}$ represents the convective velocity scale, integrated from the surface to the height of the boundary layer depth, and is defined as:
%
\begin{equation}
  w_{*}^{3}=2.5\frac{g}{\overline{\theta_{v}}} \int_{0}^{z_{D_{b}}} \overline{w^{'}\theta_{v}^{'}} dz .
  \label{wstar_pbl}
\end{equation}

In the event that $w_{*}^{3} < 0$, which is indicative of a stable boundary layer, then $\tau$ is set to a default value of 100 s.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% TURBULENT KINETIC ENERGY
\subsection{Turbulent Kinetic Energy Equation}
\label{tke_equation}

In SHOC, the turbulent kinetic energy (TKE) equation to be solved is given by:
%
\begin{equation}
  \frac{\partial{\overline{e}}}{\partial{t}}=\underbrace{-\overline{u_{j}}\frac{\partial{\overline{e}}}{\partial{x_{j}}}}_\text{advection}+\underbrace{\frac{g}{\overline{\theta_{v}}}\left(\overline{w^{'}\theta_{v}^{'}}\right)}_\text{buoyant production}-\underbrace{P_{s}}_\text{shear production}-\underbrace{\frac{\partial{\overline{w^{'}e}}}{\partial{z}}}_\text{turbulent transport}-\underbrace{C_{ee}\frac{\overline{e}^{3/2}}{L}}_\text{dissipation} .
  \label{sgstke}
\end{equation}

The first term on the RHS of equation~\ref{sgstke} is advection, which is performed by the host model (i.e. SCREAM dynamics) and not SHOC.

The second term is the buoyant production of TKE.  The buoyancy flux term ($\overline{w^{'}\theta_{v}^{'}}$) is closed by integrating over the assumed PDF (see section~\ref{assumed_pdf}) using equation~\ref{buoyancy}.  Thus, $\overline{w^{'}\theta_{v}^{'}}$ from the previous SHOC time step is used to close this term.

The shear production term is computed according to \cite{bretherton2009_moist}:
%
\begin{equation}
  -P_{s}= -\overline{w^{'}u^{'}}\frac{\partial{\overline{u}}}{\partial{z}}-\overline{w^{'}v^{'}}\frac{\partial{\overline{v}}}{\partial{z}} = K_{M}S^{2} ,
  \label{shearprod}
\end{equation}
%
where
\begin{equation}
  S^{2} = \left(\frac{\partial{\overline{u}}}{\partial{z}}\right)^2+\left(\frac{\partial{\overline{v}}}{\partial{z}}\right)^2 .
  \label{tke_Sterm}
\end{equation}
%
Since $\overline{u}$ and $\overline{v}$ are located vertically in the mid-points, $S^{2}$ is computed on the interface grid, then interpolated onto the mid-point grid.  After the shear production term is calculated on the interface grid, it is interpolated to the mid-point grid to be consistent with the location of $\overline{e}$.

The boundary surface value of $K_{M}S^{2}$ is set to zero as the boundary fluxes for TKE are applied in the diffusion solver.

The fourth term on the RHS of equation~\ref{sgstke} represents the turbulent transport of TKE.  This term is computed in the turbulent diffusion (section~\ref{turb_diffusion}) of SHOC.

The last term on the RHS of equation~\ref{sgstke} represents the turbulent dissipation of TKE.  Here $C_{ee}$ is a turbulent constant, which is defined in \cite{Deardorff_80} as $C_{ee}=C_{e1}+C_{e2}$, where $C_{e1} = C_{e}/0.133$ and $C_{e1} = C_{e}/0.357$ and $C_{e}=C_{k}^{3}/C_{s}^{4}$.  Finally, $C_{k} = 0.1$ and $C_{s} = 0.15$.

\subsubsection{Eddy Diffusivities}

\paragraph{Default Formulation}

After TKE is updated due to buoyant production, shear production, and dissipation processes, the eddy diffusivity parameters for heat and momentum, to be used in turbulence diffusion, are respectively defined in the TKE module as:
\begin{equation}
  K_{H}=C_{Kh} \tau_{v} \overline{e}
  \label{diffusivity_heat}
\end{equation}
%
\begin{equation}
  K_{M}=C_{Km} \tau_{v} \overline{e}
  \label{diffusivity_momentum}
\end{equation}
%
where $C_{Kh}$ and $C_{Km}$ are tunable constants.  $C_{Kh}$ and $C_{Km}$ could be tuned independently, but as a starting point we set them equal to 0.1.  In equations~\ref{diffusivity_heat} and~\ref{diffusivity_momentum} $\tau_{v}$ represents a damped return to isotropic timescale where $\tau=2\overline{e}/\epsilon$ and
%
\begin{equation}
  \tau_{v}=\tau\left[1+\lambda_{0}N^{2}\tau^{2}\right]^{-1}
  \label{tauv}
\end{equation}
%
where $\lambda_{0}=0$ if $N^{2} < 0$ and $\epsilon$ is the turbulence dissipation rate (last term of equation~\ref{sgstke}).  If $N^{2} > 0$ then $\lambda_{0}$ is set as a ramp function in terms of the integrated column stability in the lower troposphere ($N_{\infty}^{2}$):
%
\begin{equation}
  \lambda_{0} = \lambda_{min} + \lambda_{slope}*(\frac{N_{\infty}^{2}}{g} - N_{low}),
  \label{lambda0}
\end{equation}
%
%
\begin{equation}
  N_{\infty}^{2} = \int_{1000 hPa}^{800 hPa} N^{2} dz .
  \label{int_N}
\end{equation}
%

Where $\lambda_{min} = 0.001$, $\lambda_{slope}$ = 0.35, and $N_{low}$ = 0.037.  Here, $\lambda_{slope}$ is an adjustable parameter.  $\lambda_{0}$ has a minimum threshold of 0.001 and a maximum threshold of 0.04.

\paragraph{Stable Boundary Layer}

For the case of a moderate to very stable boundary layer, the formulation of the eddy diffusivities are revised to promote sufficient mixing, as they are based primarily on turbulence shear production, and prevent runaway cooling.  We use the dimensionless Obukov length, $z/L$ to determine when to trigger the stable boundary layer eddy diffusivities, where $z$ is the height of the lowest mid-point grid height and L the Monin-Obukhov length defined as
%
\begin{equation}
  L=-\frac{u_{*}^{3}\overline{\theta_{v}}}{kg\left(\overline{w^{'}\theta^{'}_{v}}\right)_{s}}.
  \label{monin}
\end{equation}
%
The stable boundary layer formulation for the eddy diffusivities triggers when $z/L$ is greater than 100, which signifies a moderately or very stable boundary layer.  These stable boundary layer diffusivities are applied for the PBL depth within this column and are defined as:
%
\begin{equation}
  K_{H}=C_{Khs} L^{2} S
  \label{stable_diffusivity_heat}
\end{equation}
%
and
%
\begin{equation}
  K_{M}=C_{Kms} L^{2} S ,
  \label{stable_diffusivity_momentum}
\end{equation}
%
where $C_{Khs}$ and $C_{Kms}$ are the stable boundary eddy coefficients for heat and momentum, respectively.  By default these values are set to 1.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% TURBULENCE DIFFUSION
\subsection{Turbulence Diffusion}
\label{turb_diffusion}

The prognostic variables for SHOC (table~\ref{table:prognostic}) are updated due to turbulence diffusion via:
%
\begin{equation}
  \frac{\partial{\overline{\chi}}}{\partial{t}}= - \frac{\partial{\overline{w^{'}\chi^{'}}}}{\partial{z}} .
  \label{turb_gov}
\end{equation}
%
Where $\chi$ represents any of SHOC's prognostic variables ($\theta_{l}$, $q_{t}$, $u$, $v$, $e$, or $c$).  SHOC uses downgradient diffusion to represent the vertical flux of turbulence using:
%
\begin{equation}
  \overline{w^{'}\chi^{'}} = -K_{\chi}\frac{\partial{\chi}}{\partial{z}},
  \label{vert_diffusion}
\end{equation}
%
where $K_{\chi}$ represents either $K_{H}$ or $K_{M}$.

To preserve numerical stability equations~\ref{turb_gov} and~\ref{vert_diffusion} are solved using an implicit backward Euler scheme for the diffusion of $\theta_{l}$, $q_{t}$, $u$, $v$, $e$, or $c$.  Given an input state $\chi^{*}$ and diffusivity profile:
%
\begin{equation}
  \frac{\chi(t+\Delta{t}) - \chi^{*}}{\Delta{t}} = \frac{\partial}{\partial{z}}\left(K_{\chi}(z)\frac{\partial}{\partial{z}}\chi(t+\Delta{t})\right) .
  \label{euler_step}
\end{equation}
%
In SHOC the surface fluxes for heat, moisture, TKE, and tracers are explicitly deposited into the lowest model layer and then implicit diffusion is performed.  For TKE the bottom surface flux is defined as
\begin{equation}
  u_{*}^{3} = max(\sqrt((\overline{u^{'}w^{'}}_{sfc}+\overline{v^{'}w^{'}}_{sfc})^{0.5}),0.01) .
  \label{ustar_tke}
\end{equation}

However, the method of explicit surface fluxes results in a numerically unstable solution for momentum since such explicit adding can flip the direction of the lowest model layer wind ($\overline{u}_{s}^{*}$, $\overline{v}_{s}^{*}$), especially when the lowest model layer is thin.    Thus, the surface momentum fluxes ($\tau_{x}^{*}$ = $\overline{u^{'}w^{'}}_{s}$,$\tau_{y}^{*}$ = $\overline{v^{'}w^{'}}_{s}$) in SHOC are added in an implicit way.  This is done by computing the total momentum surface stress and applying this as a boundary condition in equation~\ref{euler_step}:
%
\begin{equation}
  k_{tot} = max[\sqrt((\tau_{x}^{*})^{2}+(\tau_{y}^{*})^{2}) /max(\sqrt((\overline{u}_{s}^{*})^{2}+(\overline{u}_{s}^{*})^{2}),1),10^{-4}] .
  \label{k_tot}
\end{equation}
%
The procedure for the solution of the implicit equation~\ref{euler_step} follows that of \cite{Richtmyer_Morton67} pages 198-200.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% SECOND ORDER MOMENTS
\subsection{Diagnosis of Second Order Moments}
\label{diag_second}

In order to close the assumed PDF (section~\ref{assumed_pdf}) we need to diagnose several second order moments.  Namely, we need to determine, $\overline{w^{'}\theta_{l}^{'}}$, $\overline{w^{'}q_{t}^{'}}$, $\overline{q_{w}^{'}\theta_{l}^{'}}$, $\overline{q_{t}^{'2}}$, $\overline{\theta_{l}^{'2}}$, and $\overline{q_{w}^{'}\theta_{l}^{'}}$.

The expression we use to determine $\overline{w^{'}\theta_{l}^{'}}$ and $\overline{w^{'}q_{t}^{'}}$ is based on downgradient diffusion as:
%
\begin{equation}
 \begin{split}
    \overline{w^{'}C^{'}}=-K_{H}\frac{\partial{\overline{C}}}{\partial{z}} \\
  \end{split}
  \label{downgradient4}
\end{equation}
%
where $C$ is interchanged for $\theta_{l}$ and $q_{t}$.

For the scalar variances and covariances, SHOC diagnoses these terms as:
%
\begin{equation}
  \overline{q_{t}^{'2}}=C_{q_{t}}S_{m}\left(\frac{\partial{\overline{q_{t}}}}{\partial{z}}\right)^{2}
  \label{bogen_qw2}
\end{equation}
%
\begin{equation}
  \overline{\theta_{l}^{'2}}=C_{\theta_{l}}S_{m}\left(\frac{\partial{\overline{\theta_{l}}}}{\partial{z}}\right)^{2}
  \label{bogen_thl2}
\end{equation}
%
\begin{equation}
  \overline{q_{t}^{'}\theta_{l}^{'}}=C_{q_{t}\theta_{l}}S_{m}\frac{\partial{\overline{q_{t}}}}{\partial{z}}\frac{\partial{\overline{\theta_{l}}}}{\partial{z}} ,
  \label{bogen_qwhl2}
\end{equation}
%
where $S_{m}=\tau_{v} K_{H}$.  $C_{q_{t}}$, $C_{\theta_{l}}$, and $C_{q_{t}\theta_{l}}$ are tunable coefficients to adjust the strength of diagnosed variances and covariances.  Default setting for these coefficients are $C_{q_{t}}$, $C_{\theta_{l}}$, and $C_{q_{t}\theta_{l}}= 1.0$.

Note that $\overline{w^{'}\theta_{l}^{'}}$, $\overline{w^{'}q_{t}^{'}}$, $\overline{q_{w}^{'}\theta_{l}^{'}}$, $\overline{q_{t}^{'2}}$, $\overline{\theta_{l}^{'2}}$, and $\overline{q_{t}^{'}\theta_{l}^{'}}$ are all computed on the interface grid.  Thus, before the computation of these terms $K_{H}$ and $\tau_{v}$ are linearly interpolated to the interface grid.

The expression for $\overline{w^{'2}}$ is:
%
\begin{equation}
  \overline{w^{'2}}=\frac{2}{3}\overline{e}
  \label{w2_param_2}
\end{equation}
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% THIRD MOMENT OF VERTICAL VELOCITY
\subsection{Third Moment of Vertical Velocity}
\label{diag_third}

The final term needed to close the assumed PDF is the third order moment of vertical velocity ($\overline{w^{'3}}$), which is parameterized following that of \citep{Canuto_et01}. \cite{Canuto_et01} provides expressions for several third-order moments, but we are only interested in $\overline{w^{'3}}$.

The expressions provided by \cite{Canuto_et01} were originally derived for the dry convective boundary layer and we simply replace potential temperature with liquid water potential temperature ($\overline{\theta_{l}}$) to make the expressions valid in moist convection. The original dynamic equations for the third order moment can be found in \cite{Canuto_92} and these equations entail fourth-order moments that can be written as
%
\begin{equation}
  \overline{a^{'}b^{'}c^{'}d^{'}}=\left(\overline{a^{'}b^{'}}\hspace{0.1cm}\overline{c^{'}d^{'}}+\overline{a^{'}c^{'}}\hspace{0.1cm}\overline{b^{'}d^{'}}+\overline{a^{'}d^{'}}\hspace{0.1cm}\overline{b^{'}c^{'}}\right)F .
  \label{fourth}
\end{equation}
%
If function $F$ is taken to be unity then the above expression reduces to the quasi-normal approximation.  This was done in \cite{Canuto_et94} but the results of some of their third-order moments were not satisfactory when compared to LES data.

The expression for $\overline{w^{'3}}$ is as follows:
%
\begin{equation}
\overline{w^{'3}}=\left(\Omega_{1}-1.2X_{1}-\frac{3}{2}f_{5}\right)\left(c-1.2X_{0}+\Omega_{0}\right)^{-1},
  \label{w3_z}
\end{equation}
%
with the functions $X$ and $\Omega_{0}$ defined as
%
\begin{equation}
  \label{Xomega_func}
  \begin{split}
    X_{0}=\gamma_{2}\tilde{N}^{2}\left(1-\gamma_{3}\tilde{N}^{2}\right)\left[1-\left(\gamma_{1}+\gamma_{3}\right)\tilde{N}^{2}\right]^{-1}\\
    X_{1}=\left[\gamma_{0}f_{0}+\gamma_{1}f_{1}+\gamma_{2}\left(1-\gamma_{3}\tilde{N}^{2}\right)f_{2}\right]\left[1-\left(\gamma_{1}+\gamma_{3}\right)\tilde{N}^{2}\right]^{-1}\\
    \Omega_{0}=\omega_{0}X_{0}+\omega_{1}Y_{0}\\
    \Omega_{1}=\omega_{o}X_{1}+\omega_{1}Y_{1}+\omega_{2}.
  \end{split}
\end{equation}
%
The $\omega$ function's are given by
%
\begin{equation}
  \label{omegas}
  \begin{split}
  \omega_{0}=\gamma_{4}\left(1-\gamma_{5}\tilde{N}^{2}\right)^{-1}\\
  \omega_{1}=\left(2c\right)^{-1}\omega_{0}\\
  \omega_{2}=\omega_{1}f_{3}+\frac{5}{4}\omega_{0}f_{4}.
  \end{split}
\end{equation}
%
The $\gamma$'s are constants which depend on the adjustable parameter $c$.  Canuto et al. (2001) and previous work found that $c=7$, although small variations are allowed.  The $\gamma$ constants are given by:
%
\begin{equation}
  \label{gammas}
  \begin{split}
  \gamma_{0}=0.52c^{-2}\left(c-2\right)^{-1}\\
  \gamma_{1}=0.87c^{-2}\\
  \gamma_{2}=0.5c^{-1}\\
  \gamma_{3}=0.60c^{-1}\left(c-2\right)^{-1}\\
  \gamma_{4}=2.4\left(3c+5\right)^{-1}\\
  \gamma_{5}=0.6c^{-1}\left(3c+5\right)^{-1}.
  \end{split}
\end{equation}
%
Finally, the functions are introduced which incorporate the second-order moments of $\overline{w^{'2}}$, $\overline{w^{'}\theta_{l}^{'}}$, $\overline{\theta_{l}^{'}}$, and $\overline{e}$.  These are defined as follows:
%
\begin{equation}
  \label{f_functions}
  \begin{split}
  f_{0}=\left(g\alpha\right)^{3}\tau_{v}^{4}\overline{w^{'}\theta_{l}^{'}}\frac{\partial{\overline{\theta_{l}^{'2}}}}{\partial{z}}\\
  f_{1}=\left(g\alpha\right)^{2}\tau_{v}^{3}\left(\overline{w^{'}\theta_{l}^{'}}\frac{\partial{\overline{w^{'}\theta_{l}^{'}}}}{\partial{z}}+\frac{1}{2}\overline{w^{'2}}\frac{\partial{\overline{\theta_{l}^{'}}}}{\partial{z}}\right)\\
  f_{2}=g\alpha\tau_{v}^{2}\overline{w^{'}\theta_{l}^{'}}\frac{\partial{\overline{w^{'2}}}}{\partial{z}}+2g\alpha\tau_{v}^{2}\overline{w^{'2}}\frac{\partial{\overline{w^{'}\theta_{l}^{'}}}}{\partial{z}}\\
  f_{3}=g\alpha\tau_{v}^{2}\left(\overline{w^{'2}}\frac{\partial{\overline{w^{'}\theta_{l}^{'}}}}{\partial{z}}+\overline{w^{'}\theta_{l}^{'}}\frac{\partial{\overline{e}}}{\partial{z}}\right)\\
  f_{4}=\tau_{v}\overline{w^{'2}}\left(\frac{\partial{\overline{w^{'2}}}}{\partial{z}}+\frac{\partial{\overline{e}}}{\partial{z}}\right)\\
  f_{5}=\tau_{v}\overline{w^{'2}}\frac{\partial{\overline{w^{'2}}}}{\partial{z}}.
  \end{split}
\end{equation}
%
All of the above $f$ functions have the dimensions of velocity cubed.  In addition, we define $\tilde{N}^{2}=\tau_{v}^{2}N^{2}$.

Once $\overline{w^{'3}}$ is determined we perform clipping to ensure that this calculation does not produce unrealistically large values.  $\mid\overline{w^{'3}}\mid$ is constrained by $ w3_{clip} \sqrt{2.0 \overline{w^{'2}}} $.  Where $w3_{clip}$ is an adjustable parameter with a default value of 1.2.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% ASSUMED PDF
\subsection{Assumed PDF}
\label{assumed_pdf}
%
Here details of the Analytic Double Gaussian (ADG) 1 PDF (as referred to in \cite{Larson_et02}, which is the PDF used in SHOC, are presented.  The input moments for this PDF are $\overline{\theta_{l}}$, $\overline{q_{t}}$, $\overline{w^{'2}}$, $\overline{w^{'}\theta_{l}^{'}}$, $\overline{w^{'}q_{t}^{'}}$, $\overline{q_{w}^{'}\theta_{l}^{'}}$, $\overline{q_{t}^{'2}}$, $\overline{\theta_{l}^{'2}}$, $\overline{q_{w}^{'}\theta_{l}^{'}}$, and $\overline{w^{'3}}$.  Note that at the beginning of this module $\overline{w^{'}\theta_{l}^{'}}$, $\overline{w^{'}q_{t}^{'}}$, $\overline{q_{w}^{'}\theta_{l}^{'}}$, $\overline{q_{t}^{'2}}$, $\overline{\theta_{l}^{'2}}$, $\overline{w^{'3}}$ are interpolated to the mid-point grid.

This PDF, as the name suggests, is based on the double Gaussian form as
%
\begin{equation}
  P_{adg1}(w^{'},\theta_{l}^{'},q_{t}^{'})=aG_{1}(w^{'},\theta_{l}^{'},q_{t}^{'})+(1-a)G_{2}(w^{'},\theta_{l}^{'},q_{t}^{'}).
  \label{adg1}
\end{equation}
%
Here $G_{1}$ and $G_{2}$ are the individual Gaussians and the parameters for the ADG 1 can be found analytically.  To do this, some assumptions have to be made.  The first assumption is that the subplume variations in $w$ are uncorrelated with those in $q_{t}$ and $\theta_{l}$.  Letting $i$ = 1 or 2, the individual Gaussians in equation~\ref{adg1} are then given by
%
\begin{equation}
  \label{ind_gaus}
  \begin{split}
    G_{i}(w^{'},\theta_{l}^{'},q_{t}^{'})=\frac{1}{(2\pi)^{3/2}\sigma_{wi}\sigma_{q_{t}i}\sigma_{\theta_{l}i}(1-r_{q_{t}\theta_{l}i}^{2})^{1/2}}\exp\left[-\frac{1}{2}\left(\frac{w^{'}-(w_{i}-\overline{w})}{\sigma_{wi}}\right)^{2}\right] \\
    \times \exp\left(-\frac{1}{2(1-r_{q_{t}\theta_{l}i}^{2})}\left\{\left[\frac{q_{t}^{'}-(q_{ti}-\overline{q_{t}})}{\sigma_{q_{t}i}}\right]^{2}+\left[\frac{\theta_{l}^{'}-(\theta_{li}-\overline{\theta_{l}})}{\sigma_{\theta_{l}i}}\right]^{2} \right. \right. \\
    -\left.\left.2r_{q_{t}\theta_{l}i}\left[\frac{q_{t}^{'}-(q_{ti}-\overline{q_{t}})}{\sigma_{q_{t}i}}\right]\left[\frac{\theta_{l}^{'}-(\theta_{li}-\overline{\theta_{l}})}{\sigma_{\theta_{l}i}}\right]\right\}\right).
  \end{split}
\end{equation}
%
Now we must define the PDF parameters.  The PDF parameters are based on the equations of \cite{Lewellen_Yoh93} and are found by integrating over the 12 relevant input moments over the double Gaussian PDF.  Four of these equations are (the rest are analogous):
%
\begin{eqnarray}
%  \begin{split}
    \overline{w} &=& aw_{1}+(1-a)w_{2}  \label{mom_equations} \\
    \overline{w^{'2}} &=& a[(w_{1}-\overline{w})^{2}+\sigma_{w1}^{2}]+(1-a)[(w_{2}-\overline{w})^{2}+\sigma_{w2}^{2}] \nonumber \\
    \overline{w^{'3}} &=& a[(w_{1}-\overline{w})^{3}+3(w_{1}-\overline{w})\sigma_{w1}^{2}]+(1-a)[(w_{2}-\overline{w})^{3}+3(w_{2}-\overline{w})\sigma_{w2}^{2}] \nonumber \\
    \overline{w^{'}q_{t}^{'}} &=& a[(w_{1}-\overline{w})(q_{t1}-\overline{q_{t}})+r_{wq_{t}1}\sigma_{w1}\sigma_{q_{t1}}]+(1-a)[(w_{2}-\overline{w})(q_{t2}-\overline{q_{t}})+r_{wq_{t}2}\sigma_{w2}\sigma_{q_{t2}}]. \nonumber
%  \end{split}
\end{eqnarray}
%
with the relative amplitude of the Gaussian $a$ is defined as
%
\begin{equation}
  a=\frac{1}{2}\left\{1-Sk_{w}\left[\frac{1}{4(1-\tilde{\sigma}_{w}^{2})^{3}+Sk_{w}^{2}}\right]^{1/2}\right\}.
  \label{adg_a}
\end{equation}
%
This is obtained by assuming that the standard deviations of the two Gaussians are equal in $w$ and integrating over the PDF.  Here $Sk_{w}\equiv \overline{w^{'3}}/(\overline{w^{'2}}^{3/2})$, represents the skewness of vertical velocity.  In the case of $\overline{w^{'2}}$=0 it is assumed that the PDF reduces to a single delta function.  The parameters for $w_{1}$ and $w_{2}$ are given by:
%
\begin{equation}
  \tilde{w}_{1}\equiv\frac{w_{1}-\overline{w}}{\sqrt[]{\overline{w^{'2}}}}=\left(\frac{1-a}{a}\right)^{1/2}(1-\tilde{\sigma}_{w}^{2})^{1/2}
  \label{tildew_1}
\end{equation}
%
and
%
\begin{equation}
  \tilde{w}_{2}\equiv\frac{w_{2}-\overline{w}}{\sqrt[]{\overline{w^{'2}}}}=\left(\frac{a}{1-a}\right)^{1/2}(1-\tilde{\sigma}_{w}^{2})^{1/2} .
  \label{tildew_2}
\end{equation}
%
To avoid numerical instabilities in the model a threshold for $a$ must be defined as 0.01 $\le$ $a$ $\le$ 0.99.  We also have the definitions of $\tilde{\sigma}_{w}\equiv\sigma_{w1}/ \sqrt[]{\overline{w^{'2}}} = \sigma_{w2}/\sqrt[]{\overline{w^{'2}}}$ and $\tilde{\sigma}_{w}^{2}=0.4$.

Now to define terms for $\theta_{l1}$ and $\theta_{l2}$ we get:
%
\begin{equation}
  \tilde{\theta}_{l1}\equiv\frac{\theta_{l1}-\overline{\theta_{l}}}{\sqrt[]{\overline{\theta_{l}^{'2}}}}=-\frac{\overline{w^{'}\theta_{l}^{'}}/(\sqrt[]{\overline{w^{'2}}}\sqrt[]{\overline{\theta_{l}^{'2}}})}{\tilde{w}_{2}}
  \label{tildethl_1}
\end{equation}
%
and
%
\begin{equation}
  \tilde{\theta}_{l2}\equiv\frac{\theta_{l2}-\overline{\theta_{l}}}{\sqrt[]{\overline{\theta_{l}^{'2}}}}=-\frac{\overline{w^{'}\theta_{l}^{'}}/(\sqrt[]{\overline{w^{'2}}}\sqrt[]{\overline{\theta_{l}^{'2}}})}{\tilde{w}_{1}} .
  \label{tildethl_2}
\end{equation}
%
Should there be no variability in $\theta_{l}$ then the means of the Gaussians are set equal so that $\theta_{l1}$ = $\theta_{l2}$ = $\overline{\theta_{l}}$ and the widths of the Gaussians in the $\theta_{l}$ direction are set to zero.

Unlike vertical velocity, the widths in the $\theta_{l}$ direction are allowed to differ.  These are found by integrating over the PDF and defined as:
%
\begin{equation}
  \frac{\sigma_{\theta_{l}1}^{2}}{\overline{\theta_{l}^{'2}}}=\frac{3\tilde{\theta}_{l2}[1-a\tilde{\theta}_{l1}^{2}-(1-a)\tilde{\theta}_{l2}^{2}]-[Sk_{\theta_{l}}-a\tilde{\theta}_{l1}^{3}-(1-a)\tilde{\theta}_{l2}^{3}]}{3a(\tilde{\theta}_{l2}-\tilde{\theta}_{l1})}
  \label{sig_thl1}
\end{equation}
%
and
%
\begin{equation}
    \frac{\sigma_{\theta_{l}2}^{2}}{\overline{\theta_{l}^{'2}}}=\frac{3\tilde{\theta}_{l1}[1-a\tilde{\theta}_{l1}^{2}-(1-a)\tilde{\theta}_{l2}^{2}]-[Sk_{\theta_{l}}-a\tilde{\theta}_{l1}^{3}-(1-a)\tilde{\theta}_{l2}^{3}]}{3(1-a)(\tilde{\theta}_{l2}-\tilde{\theta}_{l1})}.
  \label{sig_thl2}
\end{equation}
%
To prevent unrealistic solutions the following condition is set
%
\begin{equation}
  0 \le \frac{\sigma_{\theta_{l}1,2}^{2}}{\overline{\theta_{l}^{'2}}} \le 100.
  \label{cond}
\end{equation}
%
Analogous equations are used to find $\tilde{q}_{t1,2}$ and $\sigma_{qt1,2}^{2}$.

The equations above make clear that SHOC is dependent on the skewness of $\theta_{l}$ and $q_{t}$.  For the ADG 1 PDF, neither $\overline{\theta_{l}^{'3}}$ and $\overline{q_{t}^{'3}}$ are input moments, therefore diagnostic assumptions must be made.  $Sk_{\theta_{l}}$ is simply set to zero for the ADG 1 PDF as it is found that this value prevents numerical instabilities from being introduced.  To represent skewness in cumulus layers the following conditions are set for $Sk_{q_{t}}$:  When $|\tilde{q}_{t2}-\tilde{q}_{t1}| >$ 0.4 we set $Sk_{q_{t}}$ = 1.2$Sk_{w}$.  When $|\tilde{q}_{t2}-\tilde{q}_{t1}| \le$ 0.2 we set $Sk_{q_{t}}$ = 0.  Between these two extremes $Sk_{q_{t}}$ is linearly interpolated.

The within-plume correlations are computed by setting $r_{q_{t}\theta_{l}1}$ = $r_{q_{t}\theta_{l}2}$ and integrating over the PDF to obtain an equation for $\overline{q_{t}^{'}\theta_{l}^{'}}$ and hence:
%
\begin{equation}
  r_{q_{t}\theta_{l}1,2}=\frac{\overline{q_{t}^{'}\theta_{l}^{'}}-a(q_{t1}-\overline{q_{t}})(\theta_{l1}-\overline{\theta_{l}})-(1-a)(q_{t2}-\overline{q_{t}})(\theta_{l2}-\overline{\theta_{l}})}{a\sigma_{q_{t}1}\sigma_{\theta_{l}1}+(1-a)\sigma_{q_{t}2}\sigma_{\theta_{l2}}}
 \label{corr_eq}
\end{equation}
%
with the condition that
%
\begin{equation}
-1 \le  r_{q_{t}\theta_{l}1,2} \le 1
\end{equation}
%
because correlations must lie between -1 and 1.

Now that we have defined the PDF parameters, we can now diagnose SGS cloud and turbulence terms.  Cloud fraction, liquid water content, and liquid water flux are all given by:
%
\begin{eqnarray}
  C &=& a(C)_{1}+(1-a)(C)_{2} \label{turb_terms}\\
  \overline{q_{l}} &=& a(\overline{q_{l}})_{1}+(1-a)(\overline{q_{l}})_{2} \nonumber \\
  \overline{w^{'}q_{l}^{'}} &=& a[(w_{1}-\overline{w})(\overline{q_{l}})+(\overline{w^{'}q_{l}^{'}})_{1}]+(1-a)[(w_{2}-\overline{w})(\overline{q_{l}})_{2}+(\overline{w^{'}q_{l}^{'}})_{2}] . \nonumber
\end{eqnarray}
%
In addition, the buoyancy flux can be closed using the expression:
%
\begin{equation}
  \overline{w^{'}\theta_{v}^{'}}=\overline{w^{'}\theta_{l}^{'}}+\frac{1-\epsilon_{o}}{\epsilon_{o}}\theta_{o}\overline{w^{'}q_{t}^{'}}+\left[\frac{L_{v}}{c_{p}}\left(\frac{p_{o}}{p}\right)^{R_{d}/c_{p}}-\frac{1}{\epsilon_{o}}\theta_{o}\right]\overline{w^{'}q_{l}^{'}}
  \label{buoyancy}
\end{equation}
%
The individual cloud fraction $C$ and mean specific liquid water content $\overline{q_{l}}$ are calculated by linearizing the variability in $\theta_{l}$ and $q_{t}$ (with analogous expressions for the Gaussian 1 and 2 for equations~\ref{cld_fracadg} though~\ref{wql_s}):
%
\begin{equation}
 C=\frac{1}{2}\left[1+\operatorname{erf}\left(\frac{s}{\sqrt[]{2}\sigma_{s}}\right)\right]
  \label{cld_fracadg}
\end{equation}
%
and
%
\begin{equation}
  \overline{q_{l}}=sC+\frac{\sigma_{s}}{\sqrt[]{2\pi}}\exp\left[-\frac{1}{2}\left(\frac{s}{\sigma_{s}}\right)^{2}\right].
  \label{ql_adg}
\end{equation}
%
Here $\operatorname{erf}$ is the error function and $\sigma_{s}$ is the standard deviation of $s$, which is equal to the liquid water content when $s$ is greater than zero, but can also be negative and is conserved under condensation.  These two terms are defined as \citep{Lewellen_Yoh93}:
%
\begin{equation}
  \begin{split}
    s=q_{t}-q_{s}(T_{l},p)\frac{(1+\beta q_{t})}{[1+\beta q_{s}(T_{l},p)]}\\
  \sigma_{s}^{2}=c_{\theta_{l}}^{2}\sigma_{\theta_{l}}^{2}+c_{q_{t}}^{2}\sigma_{q_{t}}^{2}-2c_{\theta_{l}}\sigma_{\theta_{l}}c_{q_{t}}\sigma_{q_{t}}r_{q_{t}\theta_{l}}
  \end{split}
  \label{sterms}
\end{equation}
%
where $q_{s}$ is the saturation mixing ratio with respect to either water or ice or a hybrid of the two depending on the temperature, and $\beta$ is defined as:
%
\begin{equation}
  \beta=\beta(T_{l})=\frac{R_{d}}{R_{v}}\left(\frac{L_{v}}{R_{d}T_{l}}\right)\left(\frac{L_{v}}{c_{p}T_{l}}\right).
  \label{beta_equation}
\end{equation}
%
Also defined are the following terms:
%
\begin{equation}
  c_{q_{t}}=\frac{1}{1+\beta (T_{l})q_{s}(\overline{T_{l}},p)}\\
  \label{cqt_term}
\end{equation}
%
and
%
\begin{equation}
  c_{\theta_{l}}=\frac{1+ \beta (\overline{T_{l}})\overline{q_{t}}}{[1+\beta (\overline{T_{l}})q_{s}(\overline{T_{l}},p)]^{2}}\frac{c_{p}}{L_{v}}\beta (\overline{T_{l}}) q_{s}(\overline{T_{l}},p)\left(\frac{p}{p_{o}}\right)^{R_{d}/C_{p}}
  \label{cthl_term}
\end{equation}
%
Finally, the flux of liquid water is given by:
%
\begin{equation}
  \overline{w^{'}q_{l}^{'}}=C\overline{w^{'}s^{'}}
  \label{wql_equation}
\end{equation}
%
where
%
\begin{equation}
  \overline{w^{'}s^{'}}=c_{q_{t}}\sigma_{w}\sigma_{q_{t}}r_{wq_{t}}-c_{\theta_{l}}\sigma_{w}\sigma_{\theta_{l}}r_{w\theta_{l}} .
  \label{wql_s}
\end{equation}
%
In the above expressions $q_{s}$ is defined as:
%
\begin{equation}
  q_s (T_{l},P) = \frac{R_{d}}{R_{v}}\frac{e_{s}(T_{l})}{p-[1-(R_{d}/R_{v})]e_{s}(T_{l})}.
  \label{qs_equation}
\end{equation}
%
Here $q_{s}$ is the saturation specific humidity, $e_{s}$ is the saturation vapor pressure over liquid, $p$ is pressure, $c_{p}$ is the specific heat at constant pressure, and $R_{d}$ and $R_{v}$ are the gas constants for dry air and water vapor.  In addition, we define $T_{l}$ as the liquid water temperature:
%
\begin{equation}
  T_{l} = T - \frac{L_{v}}{c_{p}}q_{l}
  \label{T_liq}
\end{equation}
%
where $T$ is temperature.  In SHOC, $e_{s}$ is computed based on \cite{Flatau_et92}.

%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%% IMPLICIT DIFFUSION NUMERICS


\vssub
\subsection{~The \ws\ Modeling Framework}
\vssub

\ww\ is a community wave modeling framework that includes the latest scientific advancements in the field of
wind-wave modeling and dynamics.

The core of the framework consists of the \ws\ third-generation wave model, developed at the
US National Centers for Environmental Prediction (NOAA/NCEP) in the spirit of the WAM model \citep{bk:WAM94}.
The current framework evolved from earlier WAVEWATCH I \& II model packages \citep{tol:JPO91b, tol:JPO92}, and differs from its predecessors
in many important points such as governing equations, model structure, numerical methods and physical parameterizations.

\ws\ solves the random phase spectral action density balance equation for wavenumber-direction spectra. The implicit
assumption of this equation is that properties of medium (water depth and current) as well as the wave field itself
vary on time and space scales that are much larger than the variation scales of a single wave. The model includes options
for shallow-water (surf zone) applications, as well as wetting and drying of grid points. Propagation of a wave spectrum
can be solved using regular (rectilinear or curvilinear) and unstructured (triangular) grids, individually or combined into
multi-grid mosaics.

Source terms for physical processes (source terms) include parameterizations for wave growth due to the actions of wind, exact and parametrized
forms accounting for nonlinear resonant wave-wave interactions, scattering due to wave-bottom interactions, triad interactions,
and dissipation due to whitecapping, bottom friction, surf-breaking, and interactions with mud and ice. The model includes several
alleviation methods for the Garden Sprinkler Effect, and computes other transofrmation processes
such as the effects of surface currents to wind and wave fields, and sub-grid blocking due to unresolved islands.

Inputs to \ws\ may be provided via external files or via coupling using the OASIS or ESMF/NUOPC frameworks. Input data is
dynamically updated within the wave model driver, and may include ice coverage, mud, current fields, bottom properties for dissipation
on a moveable bed, and data for assimilation within a data assimilation placeholder module that may be developed by users.

\ws\ is written in ANSI standard FORTRAN 90, fully modular and fully allocatable. The model is set up for traditional one-way nesting,
and also using a `mosaic' or multiple-grid approach, where an arbitrary number of grids can be considered with full two-way interactions
between all grids. Individual or multi-grid mosaics can be used as moving frame of reference that allows high-resolution
modeling of hurricanes away from the coast.

Wave energy spectra are discretized using a constant directional increment (covering all directions), and a spatially varying wavenumber grid.
First-, second- and third-order accurate numerical schemes are available to describe wave propagation. Source terms are integrated
in time using a dynamically adjusted time stepping algorithm, which concentrates computational efforts in conditions with rapid spectral
changes. \ws\ can optionally be compiled to include shared memory parallelisms using OpenMP compiler directives,
and/or for a distributed memory environment using the Message Passing Interface.

%, spectral partitioning is now available for post-processing of
%        point output, or for the entire wave model grid using the Vincent and Soille
%        (1991) algorithm (Hanson and Jenssen, 2004; Hanson  et al , 2006,
%        2009).   New in model version 3.14


\documentclass[letterpaper]{article}

\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\allowdisplaybreaks

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

\begin{document}
\title{Notes}
\date{September 8, 2014}
\maketitle
\section*{exercises}
second part of chinese remainder theorem
Section 1.3: exercises \# 4, 6, 12, 18, 20, 24.
\begin{enumerate}
\setcounter{enumi}{3}
\item
\begin{align*}
  20x\equiv12\mod 72\\
  \gcd(20,12)=4\\
  4|12\\
  ax=b+qn\\
  20x=12+q72
  20=4a_1,12=4b_1,72=4m\\
  a_1x=b_1=qm\\
  a_1x\equiv b_1\mod m\\
  5x\equiv 3\mod 18\\
  ca_1\equiv1\mod m\\
  c5\equiv1\mod 18\\
  55=18*3+1\\
\end{align*}
\setcounter{enumi}{23}
\item
claim:remainder of integer when divided by 9.

proof:
\begin{align*}
  n_0\equiv r\mod 9\\
  n_0=10^na_n+10^{n-1}a_{n-1}+\dots+a_0\\
  a\equiv b\mod n\\
  c\equiv d\mod n\\
  ac\equiv bd\mod n\\
  a\equiv b\mod n\to a^k\equiv b^k\mod n\\
  10\equiv1\mod 9\\
  10^k\equiv 1\mod 9\\
  n_0\equiv a_n+a_{n-1}+\dots+a_0\mod 9
\end{align*}
similar to 25
\end{enumerate}
\section*{section 2.1}
$f:S\longrightarrow T$ and $S$ is domain, $T$ is codomain.

$f':S'\longrightarrow T'$

$f=f'\Leftrightarrow S=S',T=T'$ and $f(x)=f'(x)\forall x\in S$

The image of $f$ is $f(s)=\{f(t)|x\in S\}$

\section*{example}
\begin{align*}
  f:R\to R\\
  f(x)=x^2\\
  \text{Im} f=f(R)=[0,\infty)
\end{align*}
one to one (injective functions) $f:S\to T$ $f(x_1)=f(x_2)\Rightarrow x_1=x_2$

onto (surjective) $f:S\to T$ $f(S)=T$

one to one correspondences (bijective) satisfy both  injective and surjective (one-to-one and onto)

inverse function $f:S\to  T$ $f^{-1}:T\to S$. $f(f^{-1}(x))=x\forall x\in T$ and $f^{-1}(f(x))=x\forall x\in S$. defined iff $f$ is bijective
\section*{section 2.2 equivalence relations}
$S$ set

an equivalence relation is a subset $R\subseteq S\times S$ with the properties
\begin{enumerate}
\item
for all $x\in S$ we have that $(x,x)\in R$
\item
$\forall x,y\in S$ if $(x,y)\in R$ then $(y,x)\in R$
\item
$\forall x,y,z\in S$ if $(x,y)\in R$ and $(y,z)\in R$ then $(x,z)\in R$
\end{enumerate}
\subsection*{notation}
we write $a\sim{ }b$ to indicate that $a,b\in R$
\subsection*{example}
\begin{align*}
  S=\mathbb{Z}\\
  n\in\mathbb{Z}\\
  n>0\\
  \intertext{we say  that $x\sim y$ iff}
  x\equiv y\mod n
\end{align*}
\subsection*{example}
\begin{align*}
  S=\mathbb{R}
\end{align*}
$x\sim y$ iff $x+y\ge 0$. is this equivalence? no $x+x$ might be negative
\subsection*{example}
\begin{align*}
  S=[0,\infty)
\end{align*}
$x\sim y$ iff $x+y\ge 0$. is this equivalence? yes

\subsubsection*{note}
equality  is always equivalence relation, the trivial case

\section*{equivalence class}
$S$ is a set and $~$ is and equivalence relation. let $a\in S$, $[a]=\{x\in S|a\sim x\}$ where $[a]$ is equivalence class of $a$. $S/\sim$ is the set of all equivalence classes
\subsection*{example}
$S=\mathbb{Z}$ and $\sim$ is the congruence modulo n, then the set $\mathbb{Z}/\sim$ has $n$ elements: $[0],[1],\dots,[n-1]$
\subsection*{observation}
\begin{enumerate}
\item

let $\sim$ be an equivalence relation on the set $S$. take two elements $a,b\in S$ then $a\sim b\Leftrightarrow [a]=[b]$
\item
if $a\not\sim b$ then $[a]\cap[b]=\emptyset$
\item
$S=\cup_{a\in S}[a]$. each element of S belongs to exactly one equivalence class. the equivalence classes form a partition of S.
\subsection*{question}
if we have a partition of S, can we ``naturally'' define an equivalence on S? yes, two way relation $x\sim y$ iff $x,y$ belong to the same subset of the partition.
\end{enumerate}
\subsection*{observation}
let $\sim$ be an equiv relation on $S$. then we can define a function $\pi:S\to S/\sim$. $\pi(x)=[x]$. aside (call $S/\sim$ factor set from now on). is this function surjective? $S/\sim$ is the set of all possible equiv classes, so $\pi$ (the natural projection) is always surjective. it is injective iff every equiv classes has one element (itself) and is therefore the trivial equality relation.
\end{document}


\section{Statistical analysis}
\label{sec:stat_analysis}

The final discriminant distributions across all analysis regions considered are jointly analysed to test for the
presence of a signal. The statistical analysis uses a binned likelihood function ${\cal L}(\mu,\theta)$ constructed as
a product of Poisson probability terms over all bins considered in the search. This function depends
on the signal-strength parameter $\mu$, defined as a factor multiplying the expected yield of $tH$ and $tt(Hq)$ signal events
normalised to a reference branching ratio $\BR_{\mathrm{ref}}(t\to Hq)=0.1\%$,
and $\theta$, a set of nuisance parameters that encode the effect of systematic uncertainties on the signal and background expectations.
Therefore, the expected total number of events in a given bin depends on $\mu$ and $\theta$.
All nuisance parameters are subject to Gaussian constraints in the likelihood.
For a given value of $\mu$, the nuisance parameters $\theta$ allow variations of the expectations for signal and background
according to the corresponding systematic uncertainties, and their fitted values result in the deviations from
the nominal expectations that globally provide the best fit to the data.
This procedure allows a reduction of the impact of systematic uncertainties on
the search sensitivity by taking advantage of the highly populated background-dominated bins included in the likelihood fit.
%To verify the improved background prediction, fits under the background-only hypothesis are performed,
%and differences between the data and the post-fit background prediction are checked
%using kinematic variables other than the ones used in the fit.
Statistical uncertainties in each bin of the predicted final discriminant distributions are taken into account by dedicated parameters in the fit.
The best-fit $\BR(t\to Hq)$ is obtained by performing a binned likelihood fit to the data under the signal-plus-background
hypothesis, maximising the likelihood function ${\cal L}(\mu,\theta)$ over $\mu$ and $\theta$.

The fitting procedure was initially validated through extensive studies using mock data, defined as the sum of all predicted backgrounds
plus an injected signal of variable strength, as well as by performing fits to real data where bins of the final discriminant variable with
a signal contamination above 10\% are excluded (referred to as blinding requirements).
In both cases, the robustness of the model for systematic uncertainties is established by verifying the stability of the fitted background
when varying assumptions about some of the leading sources of uncertainty.
After this, the blinding requirements
are removed in the data and a fit under the signal-plus-background hypothesis is performed. Further checks involve the comparison of the fitted
nuisance parameters before and after removal of the blinding requirements, and their values are found to be consistent. In addition, it is verified that the
fit is able to correctly determine the strength of a simulated signal injected into the real data.

The test statistic $q_\mu$ is defined as the profile likelihood ratio,
$q_\mu = -2\ln({\cal L}(\mu,{\hat{\theta}}_\mu)/{\cal L}(\hat{\mu},\hat{\theta}))$,
where $\hat{\mu}$ and $\hat{\theta}$ are the values of the parameters that
maximise the likelihood function (subject to the constraint $0\leq \hat{\mu} \leq \mu$), and ${\hat{\theta}}_\mu$ are the values of the
nuisance parameters that maximise the likelihood function for a given value of $\mu$.
The test statistic $q_\mu$ is evaluated with the {\textsc RooFit} package~\cite{Verkerke:2003ir,RooFitManual}.
%A related statistic is used to determine whether the observed data is compatible with the background-only hypothesis (the so-called discovery test)
%by setting $\mu=0$ in the profile likelihood ratio and leaving $\hat{\mu}$ unconstrained: $q_0 = -2\ln({\cal L}(0,{\hat{\theta}}_0)/{\cal L}(\hat{\mu},\hat{\theta}))$.
%The $p$-value (referred to as $p_0$), representing the level of agreement between the data and the background-only hypothesis, is estimated by integrating
%%representing the probability of the data being compatible with the background-only hypothesis is estimated by integrating
%%the distribution of $q_0$ obtained from background-only pseudo-experiments, approximated using the asymptotic formulae given in Refs.~\cite{Cowan:2010js},
%the distribution of $q_0$ based on the asymptotic formulae in Ref.~\cite{Cowan:2010js},
%above the observed value of $q_0$ in the data.
%%The observed $p_0$-value is checked for each explored signal scenario.
%%In the case of the data being compatible with the background-only hypothesis,
%Upper limits on $\mu$, and thus on
%$\BR(t\to Hq)$, are derived by using $q_\mu$ in the CL$_{\textrm{s}}$ method~\cite{Junk:1999kv,Read:2002hq}.
%For a given signal scenario, values of the $\BR(t\to Hq)$ yielding CL$_{\textrm{s}} < 0.05$,
%where CL$_{\textrm{s}}$ is computed using the asymptotic approximation~\cite{Cowan:2010js}, are excluded at $\geq 95\%$ CL.

In the absence of signal, exclusion limits are set on $\mu$ , and thus on
$\BR(t\to Hq)$, are derived by using $q_\mu$ in the CL$_{\textrm{s}}$ method~\cite{Junk:1999kv,Read:2002hq}.
For a given signal scenario, values of the $\BR(t\to Hq)$ yielding CL$_{\textrm{s}} < 0.05$,
where CL$_{\textrm{s}}$ is computed using the asymptotic approximation~\cite{Cowan:2010js}, are excluded at $\geq 95\%$ CL.


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}
\setlength{\parindent}{0pt}

\newtheorem*{theorem}{Theorem}
\newtheorem*{definition}{Definition}
\newtheorem*{lemma}{Lemma}
\newtheorem*{corollary}{Corollary}
\newtheorem{example}{Example}
\newtheorem{trick}{Trick}
\newtheorem{question}{Question}

\title{Problem Set 1}
\author{}
\date{}

\begin{document}

\begin{center}
{\rmfamily\bfseries\Large 18.02 EXERCISES}

\vspace{25px}

{\rmfamily\bfseries\LARGE Problem Set 1: Vectors, Determinants and Planes}
\end{center}

\begin{center}
\section*{Part I}
\end{center}

\subsection*{Unit 1 Vectors}

1. Find the magnitude and direction of the vectors \\
a) $\vec{i} + \vec{j} + \vec{k}$ \\
b) $2\vec{i} - \vec{j} + 2\vec{k}$ \\
c) $3\vec{i} - 6\vec{j} - 2\vec{k}$

Solution:

a) Suppose $\vec{A} = \vec{i} + \vec{j} + \vec{k}$, then
\[
  \begin{split}
    |\vec{A}| &= \sqrt{1^2 + 1^2 + 1^2} \\
              &= \sqrt{3}
  \end{split}
\]
\[
  \begin{split}
    dir \vec{A} &= \frac{\vec{A}}{|\vec{A}|} \\
                &= \frac{\vec{i} + \vec{j} + \vec{k}}{\sqrt{3}} \\
                &= \frac{\sqrt{3}}{3}\vec{i} + \frac{\sqrt{3}}{3}\vec{j} + \frac{\sqrt{3}}{3}\vec{k}
  \end{split}
\]

b) Suppose $\vec{A} = 2\vec{i} - \vec{j} + 2\vec{k}$, then
\[
  \begin{split}
    |\vec{A}| &= \sqrt{2^2 + (-1)^2 + 2^2} \\
              &= \sqrt{9} \\
              &= 3
  \end{split}
  |\vec{A}| = \sqrt{2^2 + (-1)^2 + 2^2} = \sqrt{9} = 3
\]
\[
  \begin{split}
    dir \vec{A} &= \frac{\vec{A}}{|\vec{A}|} \\
                &= \frac{2\vec{i} - \vec{j} + 2\vec{k}}{3} \\
                &= \frac{2}{3}\vec{i} - \frac{1}{3}\vec{j} + \frac{2}{3}\vec{k}
  \end{split}
\]

c) Suppose $\vec{A} = 3\vec{i} - 6\vec{j} - 2\vec{k}$, then
\[
  \begin{split}
    |\vec{A}| &= \sqrt{3^2 + (-6)^2 + (-2)^2} \\
              &= \sqrt{49} \\
              &= 7
  \end{split}
\]
\[
  \begin{split}
    dir \vec{A} &= \frac{\vec{A}}{|\vec{A}|} \\
                &= \frac{3\vec{i} - 6\vec{j} - 2\vec{k}}{7} \\
                &= \frac{3}{7}\vec{i} - \frac{6}{7}\vec{j} - \frac{2}{7}\vec{k}
  \end{split}
\]

2. a) Let $P$ and $Q$ be two points in space, and X the midpoint of the line
segment $PQ$. Let $O$ be an arbitrary fixed point; show that as vectors, $OX =
\frac{1}{2}(OP + OQ)$.\\
b) With the notation of part (a), assume that X divides the line segment $PQ$
in the ratio $r:s$, where $r + s = 1$. Derive an expression for $OX$ in terms
of $OP$ and $OQ$.

Solution:

a) Suppose $P = (a_1, b_1, c_1)$, $Q = (a_2, b_2, c_2)$, and $O = (a_0, b_0, c_0)$.\\
Since $X$ is the midpoint of the line segment $PQ$, then
\[
    X = (\frac{a_1 + a_2}{2}, \frac{b_1 + b_2}{2}, \frac{c_1 + c_2}{2})
\]
Therefore,
\[
  \vec{OP} = <a_1 - a_0, b_1 - b_0, c_1 - c_0>
\]
\[
  \vec{OQ} = <a_2 - a_0, b_2 - b_0, c_2 - c_0>
\]
\[
  \begin{split}
    \vec{OX} &= <\frac{a_1 + a_2}{2} - a_0, \frac{b_1 + b_2}{2} - b_0, \frac{c_1 + c_2}{2} - c_0> \\
             &= \frac{1}{2}<a_1 + a_2 - 2a_0, b_1 + b_2 - 2b_0, c_1 + c_2 - 2c_0> \\
             &= \frac{1}{2}(\vec{OP} + \vec{OQ})
  \end{split}
\]

b) Since $X$ divides the line segment $PQ$ in the ratio $r : s$, where
$r + s = 1$,
\[
  \vec{PX} = \frac{r}{r + s}\vec{PQ}
\]
Then we also know
\[
  \vec{PQ} = \vec{OQ} - \vec{OP}
\]
\[
  \vec{OX} = \vec{OP} + \vec{PX}
\]
Therefore,
\[
  \begin{split}
    \vec{OX} &= \vec{OP} + \vec{PX} \\
             &= \vec{OP} + \frac{r}{r + s}\vec{PQ} \\
             &= \vec{OP} + \frac{r}{r + s}(\vec{OQ} - \vec{OP}) \\
             &= \frac{s}{r + s}\vec{OP} + \frac{r}{r + s}\vec{OQ} \\
  \end{split}
\]

3. What are the $\vec{i} \vec{j}$-components of a plane vector $\vec{A}$ of
length 3, if it makes an angle of $30^{\circ}$ with $\vec{i}$ and $60^{\circ}$
with $\vec{j}$. Is the second condition redundant?

Solution:

\begin{tikzpicture}
  [help lines/.style={dashed}]
  \draw[->] (-3, 0, 0) -- (3, 0, 0) node[anchor=south] {x};
  \draw[->] (0, 0, 0) -- (1, 0, 0) node[anchor=south] {$\vec{i}$};
  \draw[->] (0, -3, 0) -- (0, 3, 0) node[anchor=east] {y};
  \draw[->] (0, 0, 0) -- (0, 1, 0) node[anchor=east] {$\vec{j}$};
  \draw[->] (0, 0, 0) -- (2.6, 1.5, 0) node[anchor=south] {$\vec{A}$};
  \draw (0.2, 0) arc [start angle=0, end angle=30, radius=0.2]
    node[anchor=west] {$30^{\circ}$};
  \draw[->, help lines] (0, 0, 0) -- (2.6, -1.5, 0) node[anchor=north] {$\vec{A'}$};
\end{tikzpicture}

Apparently
\[
  \begin{split}
    \vec{A} &= <|\vec{A}|\cos(30^{\circ}), |\vec{A}|\sin(30^{\circ})> \\
            &= <3 \cdot \frac{\sqrt{3}}{2}, 3 \cdot \frac{1}{2}> \\
            &= <\frac{3\sqrt{3}}{2}, \frac{3}{2}> \\
            &= \frac{3\sqrt{3}}{2}\vec{i} + \frac{3}{2} \vec{j} \\
  \end{split}
\]
The second condition that the vector $\vec{A}$ makes an angle of $60^{\circ}$
with $\vec{j}$ is not redundant, otherwise the referred vector can be $\vec{A}$
or $\vec{A'}$ in the above diagram.

4. A small plane wishes to fly due north at 200 mph (as seen from the ground),
in a wind blowing from the northeast at 50 mph. Tell with what vector velocity
in the air it should travel (given the $\vec{i} \vec{j}$-components).

Solution:

Suppose that $\vec{i}$ represents east, then $\vec{j}$ represents north, and
$-\vec{i}$ represents west, and $-\vec{j}$ represents south. Let $\vec{V_w}$
denote the velocity of the wind, $\vec{V_p}$ denote the velocity of the plane in
the air, and $\vec{V}$ denote the velocity of plane seen from the ground. \\
$\vec{V}$ should be the result of $\vec{V_p}$ and $\vec{V_w}$ applied together,
therefore
\[
  \vec{V} = \vec{V_p} + \vec{V_w}
\]
According to the problem description,
\[
  \begin{split}
    \vec{V_w} &= <50\cos45^{\circ}, 50\sin45^{\circ}> \\
              &= <25\sqrt{2}, 25\sqrt{2}> \\
  \end{split}
\]
\[
  \vec{V} = <0, 200>
\]
Therefore
\[
  \begin{split}
    \vec{V_p} &= \vec{V} - \vec{V_w} \\
              &= <0, 200> - <25\sqrt{2}, 25\sqrt{2}> \\
              &= <-25\sqrt{2}, 200 - 25\sqrt{2}> \\
  \end{split}
\]

5. Let $\vec{A} = a \vec{i} + b \vec{j}$ be a plane vector; find in terms of
$a$ and $b$ the vectors $\vec{A'}$ and $\vec{A''}$ resulting from rotating
$\vec{A}$ by $90^{\circ}$ \hspace{10px} a) clockwise \hspace{10px} b)
counterclockwise.\\
c) Let $\vec{i'} = (3 \vec{i} + 4 \vec{j}) / 5$. Show that $\vec{i'}$ is a unit
vector, and use the first part of the exercise to find a vector $\vec{j'}$ such
that $\vec{i'}$, $\vec{j'}$ forms a right-handed coordinate system.

Solution:

a) According to the problem description, $\vec{A'}$ is the result of rotating
$\vec{A}$ clockwise by $90^{\circ}$. Therefore, the $\vec{i} \vec{j}$-components
of $\vec{A}$ should be rotated the same way to get the corresponding components
of $\vec{A'}$. After being rotated in the mentioned way, $\vec{i}$ becomes
$-\vec{j}$, and $\vec{j}$ becomes $\vec{i}$. Therefore,
\[
  \vec{A'} = b \cdot \vec{i} - a \cdot \vec{j}
\]

b) Similar to a), after being rotated counterclockwise by $90^{\circ}$,
$\vec{i}$ becomes $\vec{j}$, and $\vec{j}$ becomes $-\vec{i}$. Therefore,
\[
  \vec{A''} = -b \cdot \vec{i} + a \cdot \vec{j}
\]

c) To prove $\vec{i'}$ is a unit vector,
\[
  \begin{split}
    |\vec{i'}| &= \sqrt{(\frac{3}{5})^2 + (\frac{4}{5})^2} \\
               &= 1
  \end{split}
\]
To form a right-handed coordinate system, $\vec{j'}$ should be the result of
rotating $\vec{i'}$ counterclockwise by $90^{\circ}$. According the part b),
we can derive that
\[
  \vec{j'} = -\frac{4}{5} \cdot \vec{i} + \frac{3}{5} \cdot \vec{j}
\]

6. The direction of a space vector is in engineering practice often given by
its \textbf{direction cosines}. To describe these, let
$\vec{A} = a \vec{i} + b \vec{j} + c \vec{k}$ be a space vector, represented as
an origin vector, and let $\alpha$, $\beta$, and $\gamma$ be the three angles
($\le \pi$) that $\vec{A}$ makes respectively with $\vec{i}$, $\vec{j}$, and
$\vec{k}$.\\
a) Show that $dir \vec{A} = \cos\alpha \vec{i} + \cos\beta \vec{j} +
\cos\gamma \vec{k}$. (The three coefficients are called the \emph{direction
cosines} of $\vec{A}$.)\\
b) Express the direction cosines of $\vec{A}$ in terms of $a$, $b$, $c$; find
the direction cosines of the vector $-\vec{i} + 2\vec{j} + 2\vec{k}$.\\
c) Prove that three numbers $t$, $u$, $v$ are the direction cosines of a vector
in space if and only if they satisfy $t^{2} + u^{2} + v^{2} = 1$.

Solution:

a) According to the definition, $dir \vec{A}$ is the unit vector with the same
direction as $\vec{A}$, hence $dir \vec{A}$ makes the same angles with
$\vec{i}$, $\vec{j}$, $\vec{k}$ as $\vec{A}$, i.e. $\alpha$, $\beta$, and
$\gamma$ respectively. Then according to the definition of component vectors,
i.e. the cast on a specific directions, we can derive that
\[
  dir \vec{A} = \cos\alpha \cdot \vec{i} + \cos\beta \cdot \vec{j} + \cos\gamma \cdot \vec{k}
\]

b) According to the definition of vector directions,
\[
  \begin{split}
    dir \vec{A} &= \frac{\vec{A}}{|\vec{A}|} \\
                &= \frac{a \vec{i} + b \vec{j} + c \vec{k}}{\sqrt{a^2 + b^2 + c^2}} \\
                &= \frac{a}{\sqrt{a^2 + b^2 + c^2}} \vec{i} + \frac{b}{\sqrt{a^2 + b^2 + c^2}} \vec{j} + \frac{c}{\sqrt{a^2 + b^2 + c^2}} \vec{k} \\
                &= \cos\alpha \cdot \vec{i} + \cos\beta \cdot \vec{j} + \cos\gamma \cdot \vec{k}
  \end{split}
\]
Therefore,
\begin{gather*}
  \cos\alpha = \frac{a}{\sqrt{a^2 + b^2 + c^2}} \\
  \cos\beta = \frac{b}{\sqrt{a^2 + b^2 + c^2}} \\
  \cos\gamma = \frac{c}{\sqrt{a^2 + b^2 + c^2}} \\
\end{gather*}
Hence for the vector $-\vec{i} + 2\vec{j} + 2\vec{k}$,
\begin{gather*}
  \begin{split}
    \cos\alpha &= \frac{-1}{\sqrt{(-1)^2 + 2^2 + 2^2}} \\
               &= -\frac{1}{3} \\
  \end{split} \\
  \begin{split}
    \cos\beta &= \frac{2}{\sqrt{(-1)^2 + 2^2 + 2^2}} \\
              &= \frac{2}{3} \\
  \end{split} \\
  \begin{split}
    \cos\gamma &= \frac{2}{\sqrt{(-1)^2 + 2^2 + 2^2}} \\
              &= \frac{2}{3} \\
  \end{split} \\
\end{gather*}

c) Proof: \\
If $t$, $u$, $v$ are the direction cosines of a vector $\vec{A}$ in space, then
they are the components of its direction:
\[
  dir \vec{A} = t \cdot \vec{i} + u \cdot \vec{j} + v \cdot \vec{k}
\]
Since $dir \vec{A}$ is a unit vector, then
\[
  |dir \vec{A}| = \sqrt{t^2 + u^2 + v^2} = 1
\]
\[
  t^2 + u^2 + v^2 = 1
\]
If $t$, $u$, $v$ satisfy $t^2 + u^2 + v^2 = 1$, then we can construct a unit
vector $\vec{D} = t \cdot \vec{i} + u \cdot \vec{j} + v \cdot \vec{k}$. Then
$t$, $u$, $v$ are the direction cosines of the constructed space vector.

7. Prove using vector methods (without components) that the line segment
joining the midpoints of two sides of a triangle is parallel to the third side
and half its length. (Call the two sides $\vec{A}$ and $\vec{B}$.)

Proof:

Suppose that the two sides are $\vec{A}$ and $\vec{B}$, the third side is
$\vec{C}$, and the line segment joining the midpoints of the two sides is
$\vec{C'}$. Then
\[
  \vec{C} = \vec{A} - \vec{B}
\]
or
\[
  \vec{C} = -(\vec{A} - \vec{B})
\]
And
\[
  \begin{split}
    \vec{C'} &= \frac{1}{2}\vec{A} - \frac{1}{2}\vec{B} \\
             &= \frac{1}{2}(\vec{A} - \vec{B}) \\
  \end{split}
\]
or
\[
  \begin{split}
    \vec{C'} &= -(\frac{1}{2}\vec{A} - \frac{1}{2}\vec{B}) \\
             &= -\frac{1}{2}(\vec{A} - \vec{B}) \\
  \end{split}
\]
Therefore, either of the following equations must hold:
\[
  \vec{C'} = \frac{1}{2}\vec{C}
\]
or
\[
  \vec{C'} = -\frac{1}{2}\vec{C}
\]
Therefore, $\vec{C'}$ is parallel to $\vec{C}$ and the magnitude of $\vec{C'}$
is the half of the one of $\vec{C}$.

8. Prove using vector methods (without components) that the diagonals of a
parallelogram bisect each other. (One way: let $X$ and $Y$ be the midpoints of
the two diagonals; show $X$ = $Y$.)

Proof:

\begin{tikzpicture}
  [help lines/.style={dashed}]
  \draw[-] (-2, 0) node[anchor=north] {A} -- (2, 0) node[anchor=north] {B} --
    (4, 2) node[anchor=south] {C} -- (0, 2) node[anchor=south] {D} -- (-2, 0);
  \draw[-, help lines] (-2, 0) -- (1, 1) node[anchor=north] {X} -- (4, 2);
  \draw[-, help lines] (2, 0) -- (1, 1) node[anchor=south] {Y} -- (0, 2);
\end{tikzpicture}

As shown in the diagram, suppose that the four endpoints of a parallelogram are
$A$, $B$, $C$, $D$, and the midpoint of the diagonal $AC$ is $X$, and the
midpoint of the diagonal $BD$ is $Y$. Then
\[
  \begin{split}
    \vec{AX} &= \frac{1}{2}\vec{AC} \\
             &= \frac{1}{2}(\vec{AB} + \vec{AD}) \\
             &= \frac{1}{2}\vec{AB} + \frac{1}{2}\vec{AD} \\
  \end{split}
\]
\[
  \begin{split}
    \vec{AY} &= \vec{AB} + \vec{BY} \\
             &= \vec{AB} + \frac{1}{2}\vec{BD} \\
             &= \vec{AB} + \frac{1}{2}(\vec{AD} - \vec{AB}) \\
             &= \frac{1}{2}\vec{AB} + \frac{1}{2}\vec{AD} \\
  \end{split}
\]
Therefore, $\vec{AX} = \vec{AY}$, which means the midpoints of the two
diagonals are the same point. Hence, the two diagonals of a parallelogram
bisect each other.

\subsection*{Unit 2 Dot Product}

1. Tell for what values of $c$ the vectors $c \vec{i} + 2 \vec{j} - \vec{k}$
and $\vec{i} - \vec{j} + 2 \vec{k}$ will \\
a) be orthogonal \hspace{10px} b) form an acute angle

Solution:

a) The vectors $c \vec{i} + 2 \vec{j} - \vec{k}$ and
$\vec{i} - \vec{j} + 2 \vec{k}$ are orthogonal if and only if
\[
  (c \vec{i} + 2 \vec{j} - \vec{k}) \cdot (\vec{i} - \vec{j} + 2 \vec{k}) = 0
\]
\[
  c - 2 - 2 = 0
\]
\[
  c = 4
\]

b) The vectors $c \vec{i} + 2 \vec{j} - \vec{k}$ and
$\vec{i} - \vec{j} + 2 \vec{k}$ form an acute angle if and only if
\[
  (c \vec{i} + 2 \vec{j} - \vec{k}) \cdot (\vec{i} - \vec{j} + 2 \vec{k}) > 0
\]
\[
  c - 2 - 2 > 0
\]
\[
  c > 4
\]

2. Using vectors, find the angle between a longest diagonal $PQ$ of a cube,
and \\
a) a diagonal $PR$ of one of its faces; \hspace{10px} b) an edge $PS$ of the
cube. \\
(Choose a size and position for the cube that makes calculation easiest.)

Solution:

a) Suppose that $P = (0, 0, 0)$, $Q = (1, 1, 1)$, and $R = (1, 1, 0)$.
Therefore, $\vec{PQ} = <1, 1, 1>$, and $\vec{PR} = <1, 1, 0>$. Then, the angle
$\theta$ between $PQ$ and $PR$ satisfies
\[
  \begin{split}
    \cos\theta &= \frac{\vec{PQ} \cdot \vec{PR}}{|\vec{PQ}| \cdot |\vec{PR}|} \\
               &= \frac{1 \times 1 + 1 \times 1 + 1 \times 0}{\sqrt{1^2 + 1^2 + 1^2} \times \sqrt{1^2 + 1^2 + 0^2}} \\
               &= \frac{2}{\sqrt{3} \times \sqrt{2}} \\
               &= \frac{\sqrt{6}}{3} \\
  \end{split}
\]

b) Suppose that $P = (0, 0, 0)$, $Q = (1, 1, 1)$, and $S = (1, 0, 0)$.
Therefore, $\vec{PQ} = <1, 1, 1>$, and $\vec{PS} = <1, 0, 0>$. Then, the angle
$\theta$ between $PQ$ and $PS$ satisfies
\[
  \begin{split}
    \cos\theta &= \frac{\vec{PQ} \cdot \vec{PS}}{|\vec{PQ}| \cdot |\vec{PS}|} \\
               &= \frac{1 \times 1 + 1 \times 0 + 1 \times 0}{\sqrt{1^2 + 1^2 + 1^2} \times \sqrt{1^2 + 0^2 + 0^2}} \\
               &= \frac{1}{\sqrt{3} \times 1} \\
               &= \frac{\sqrt{3}}{3} \\
  \end{split}
\]

3. Three points in space are $P:(a,1,-1)$, $Q:(0,1,1)$, $R:(a,-1,3)$. For what
value(s) of $a$ will $PQR$ be\\
a) a right angle \hspace{10px} b) an acute angle

Solution:

a) $PQR$ will be a right angle $\iff$ $\vec{PQ} \cdot \vec{QR} = 0$
\begin{gather*}
  \vec{PQ} = <-a, 0, 2> \\
  \vec{QR} = <a, -2, 2> \\
  \vec{PQ} \cdot \vec{QR} = 0 \\
  <-a, 0, 2> \cdot <a, -2, 2> = 0 \\
  -a^2 + 4 = 0 \\
  a = \pm 2 \\
\end{gather*}

b) $PQR$ will be an acute angle $\iff$ $\vec{PQ} \cdot \vec{QR} > 0$
\begin{gather*}
  \vec{PQ} \cdot \vec{QR} > 0 \\
  <-a, 0, 2> \cdot <a, -2, 2> > 0 \\
  -a^2 + 4 > 0 \\
  a^2 < 4 \\
  -2 < a < 2 \\
\end{gather*}

4. Find the component of the force $\vec{F} = 2 \vec{i} - 2 \vec{j} + \vec{k}$
in\\
a) the direction $\frac{\vec{i} + \vec{j} - \vec{k}}{\sqrt{3}}$ \hspace{10px}
b) the direction of the vector $3 \vec{i} + 2 \vec{j} - 6 \vec{k}$.

Solution:

a) To get the component of a vector along a certain direction, we can calculate
the dot product of the vector and the direction. Since dot product satisfies the
distributive property, the dot product of a vector and a direction is equivalent
to the dot product of the direction and the component vector of the vector along
the direction, plus the dot product of the direction and the other component
vector, which is perpendicular to the direction. Therefore, the result is only
the dot product of the direction and the component vector of the vector along
the direction, which is the component value.
\begin{equation*}
\begin{split}
  c &= (2\vec{i} - 2\vec{j} + \vec{k}) \cdot (\frac{\vec{i} + \vec{j} - \vec{k}}{\sqrt{3}}) \\
    &= <2, -2, 1> \cdot <\frac{\sqrt{3}}{3}, \frac{\sqrt{3}}{3}, -\frac{\sqrt{3}}{3}> \\
    &= -\frac{\sqrt{3}}{3} \\
\end{split}
\end{equation*}

b) Similar to a),
\begin{gather*}
\begin{split}
  dir(3\vec{i} + 2\vec{j} - 6\vec{k}) &= \frac{3\vec{i} + 2\vec{j} - 6\vec{k}}{|3\vec{i} + 2\vec{j} - 6\vec{k}|} \\
                                      &= \frac{3\vec{i} + 2\vec{j} - 6\vec{k}}{7} \\
                                      &= <\frac{3}{7}, \frac{2}{7}, -\frac{6}{7}> \\
\end{split} \\
\begin{split}
  c &= (2\vec{i} - 2\vec{j} + \vec{k}) \cdot dir(3\vec{i} + 2\vec{j} - 6\vec{k}) \\
    &= <2, -2, 1> \cdot <\frac{3}{7}, \frac{2}{7}, -\frac{6}{7}> \\
    &= -\frac{4}{7} \\
\end{split} \\
\end{gather*}

5. Prove using vector methods (without components) that the diagonals of a
parallelogram have equal lengths if and only if it is a rectangle.

Proof:

Let $\vec{A}$ and $\vec{B}$ denote the vectors of two adjecent sides of a parallelogram,
and $\vec{D_1}$ and $\vec{D_2}$ denote the two diagonals of the parallelogram.
\begin{gather*}
  \vec{D_1} = \vec{A} + \vec{B} \\
  \vec{D_2} = \vec{A} - \vec{B} \\
\end{gather*}
The two diagonals have equal lengths is equivalent to
\begin{gather*}
  |\vec{D_1}| = |\vec{D_2}| \\
  \iff |\vec{A} + \vec{B}| = |\vec{A} - \vec{B}| \\
  \iff |\vec{A} + \vec{B}|^2 = |\vec{A} - \vec{B}|^2 \\
  \iff (\vec{A} + \vec{B}) \cdot (\vec{A} + \vec{B}) = (\vec{A} - \vec{B}) \cdot (\vec{A} - \vec{B}) \\
  \iff |\vec{A}|^2 + |\vec{B}|^2 + 2\vec{A} \cdot \vec{B} = |\vec{A}|^2 + |\vec{B}|^2 - 2\vec{A} \cdot \vec{B} \\
  \iff 4\vec{A} \cdot \vec{B} = 0 \\
  \iff \vec{A} \cdot \vec{B} = 0 \\
  \iff \vec{A} \perp \vec{B} \\
\end{gather*}
which is equivalent to the parallelogram is a rectangle.

Therefore, it is proved that the diagonals of a parallelogram have equal lengths
if and only if it is a rectangle.

6. Prove using vector methods (without components) that the diagonals of a
parallelogram are perpendicular if and only if it is a rhombus, i.e., its four
sides are equal.

Proof:

Let $\vec{A}$ and $\vec{B}$ denote the vectors of two adjecent sides of a parallelogram,
and $\vec{D_1}$ and $\vec{D_2}$ denote the two diagonals of the parallelogram.
\begin{gather*}
  \vec{D_1} = \vec{A} + \vec{B} \\
  \vec{D_2} = \vec{A} - \vec{B} \\
\end{gather*}
The two diagonals are perpendicular is equivalent to
\begin{gather*}
  \vec{D_1} \perp \vec{D_2} \\
  \iff \vec{D_1} \cdot \vec{D_2} = 0 \\
  \iff (\vec{A} + \vec{B}) \cdot (\vec{A} - \vec{B}) = 0 \\
  \iff |\vec{A}|^2 - |\vec{B}|^2 = 0 \\
  \iff |\vec{A}|^2 = |\vec{B}|^2 \\
  \iff |\vec{A}| = |\vec{B}| \\
\end{gather*}
which is equivalent to the four sides of the parallelogram are equal.

Therefore, it is proved that the diagonals of a parallelogram are perpendicular
if and only if it is a rhombus, i.e., its four sides are equal.

7. Prove using vector methods (without components) that an angle inscribed in
a semicircle is a right angle.

Proof:

\begin{tikzpicture}
  [help lines/.style={dashed}]
  \draw (-2, 0) .. controls (-2, 1.11) and (-1.11, 2) .. (0, 2)
                .. controls (1.11, 2) and (2, 1.11) .. (2, 0);
  \draw[-] (-2, 0) node[anchor=north]{A} -- (2, 0) node[anchor=north]{B};
  \draw[-] (-1.414, 1.414) node[anchor=south]{P} -- (-2, 0);
  \draw[-] (-1.414, 1.414) -- (2, 0);
  \draw[-] (-1.414, 1.414) -- (0, 0) node[anchor=north]{O};
\end{tikzpicture}

Suppose $P$ is a random point on the semicircle, then $APB$ is an angle
inscribed in a semicircle.
\begin{equation*}
\begin{split}
  \vec{PA} \cdot \vec{PB} &= (\vec{OA} - \vec{OP}) \cdot (\vec{OB} - \vec{OP}) \\
                          &= \vec{OA} \cdot \vec{OB} + |\vec{OP}|^2 - \vec{OA} \cdot \vec{OP} - \vec{OB} \cdot \vec{OP} \\
                          &= -|\vec{OA}|^2 + |\vec{OP}|^2 - (\vec{OA} + \vec{OB}) \cdot \vec{OP} \\
\end{split}
\end{equation*}
Given that $APB$ is inscribed in a semicircle,
$|\vec{OA}| = |\vec{OB}| = |\vec{OP}|$, and $\vec{OA} = -\vec{OB}$.
\begin{gather*}
  \begin{split}
    \vec{PA} \cdot \vec{PB} &= -|\vec{OA}|^2 + |\vec{OP}|^2 - (\vec{OA} + \vec{OB}) \cdot \vec{OP} \\
                            &= -|\vec{OP}|^2 + |\vec{OP}|^2 - \vec{0} \cdot \vec{OP} \\
                            &= 0 \\
  \end{split} \\
  \vec{PA} \perp \vec{PB}
\end{gather*}
Therefore, it is proved that an angle inscribed in a semicircle is a right
angle.

8. Prove the trigonometric formula:
$\cos(\theta_1 - \theta_2) = \cos\theta_1\cos\theta_2 + \sin\theta_1\sin\theta_2$.

Proof:

Suppose the angle between the unit vector $\vec{u_1}$ and $\vec{i}$ is
$\theta_1$, and the angle between the unit vector $\vec{u_2}$ and $\vec{i}$ is
$\theta_2$.
\begin{gather*}
  \vec{u_1} = <\cos\theta_1, \sin\theta_1> \\
  \vec{u_2} = <\cos\theta_2, \sin\theta_2> \\
\end{gather*}
The angle between $\vec{u_1}$ and $\vec{u_2}$ is $|\theta_1 - \theta_2|$. Hence,
\begin{gather*}
  \begin{split}
    \vec{u_1} \cdot \vec{u_2} &= |\vec{u_1}| \cdot |\vec{u_2}| \cdot \cos(|\theta_1 - \theta_2|) \\
                              &= |\vec{u_1}| \cdot |\vec{u_2}| \cdot \cos(\theta_1 - \theta_2) \\
                              &= \cos(\theta_1 - \theta_2) \\
  \end{split} \\
  \begin{split}
    \vec{u_1} \cdot \vec{u_2} &= <\cos\theta_1, \sin\theta_1> \cdot <\cos\theta_2, \sin\theta_2> \\
                              &= \cos\theta_1\cos\theta_2 + \sin\theta_1\sin\theta_2 \\
  \end{split} \\
  \cos(\theta_1 - \theta_2) = \cos\theta_1\cos\theta_2 + \sin\theta_1\sin\theta_2 \\
\end{gather*}

Therefore, it is proved that
$\cos(\theta_1 - \theta_2) = \cos\theta_1\cos\theta_2 + \sin\theta_1\sin\theta_2$.

\subsection*{Unit 3 Determinants}

1. Calculate the value of the determinants\\
a) $\begin{vmatrix}
    1 & 4 \\
    2 & -1 \\
\end{vmatrix}$

b) $\begin{vmatrix}
    3 & -4 \\
    -1 & -2 \\
\end{vmatrix}$

Solution:

a)
\[
  \begin{vmatrix}
    1 & 4 \\
    2 & -1 \\
  \end{vmatrix} = (1 \times (-1)) - (4 \times 2) = -9
\]

b)
\[
  \begin{vmatrix}
    3 & -4 \\
    -1 & -2 \\
  \end{vmatrix} = (3 \times (-2)) - ((-4) \times (-1)) = -10
\]

2. Calculate
$\begin{vmatrix}
  -1 & 0 & 4 \\
  1 & 2 & 2 \\
  3 & -2 & -1 \\
\end{vmatrix}$ using the Laplace expansion by the cofactors of:\\
a) the first row \hspace{10px} b) the first column

Solution:

a)
\begin{equation*}
\begin{split}
  \begin{vmatrix}
    -1 & 0 & 4 \\
    1 & 2 & 2 \\
    3 & -2 & -1 \\
  \end{vmatrix}
  &= (-1) \cdot \begin{vmatrix}
                  2 & 2 \\
                  -2 & -1 \\
                \end{vmatrix} -
     0 \cdot \begin{vmatrix}
               1 & 2 \\
               3 & -1 \\
             \end{vmatrix} +
     4 \cdot \begin{vmatrix}
               1 & 2 \\
               3 & -2 \\
             \end{vmatrix} \\
  &= (-1) \times 2 - 0 \times (-7) + 4 \times (-8) \\
  &= -34 \\
\end{split}
\end{equation*}

b)
\begin{equation*}
\begin{split}
  \begin{vmatrix}
    -1 & 0 & 4 \\
    1 & 2 & 2 \\
    3 & -2 & -1 \\
  \end{vmatrix}
  &= (-1) \cdot \begin{vmatrix}
                  2 & 2 \\
                  -2 & -1 \\
                \end{vmatrix} -
     1 \cdot \begin{vmatrix}
               0 & 4 \\
               -2 & -1 \\
             \end{vmatrix} +
     3 \cdot \begin{vmatrix}
               0 & 4 \\
               2 & 2 \\
             \end{vmatrix} \\
  &= (-1) \times 2 - 1 \times (8) + 3 \times (-8) \\
  &= -34 \\
\end{split}
\end{equation*}

3. Find the area of the plane triangle whose vertices lie at\\
a) $(0, 0), (1, 2), (1, -1)$ \hspace{10px} b) $(1, 2), (1, -1), (2, 3)$

Solution:

a) The vectors of the two edges of the plane triangle are $<1, 2>$ and
$<1, -1>$. The area of the plane triangle $A$ can be calculated as
\begin{gather*}
  \begin{split}
    det(<1, 2>, <1, -1>) &= \begin{vmatrix}
                              1 & 2 \\
                              1 & -1 \\
                            \end{vmatrix} \\
                         &= -3
  \end{split} \\
  A = |det(<1, 2>, <1, -1>)| = 3 \\
\end{gather*}

b) The vectors of the two edges of the plane triangle are $<0, -3>$ and
$<1, 1>$. The area of the plane triangle $A$ can be calculated as
\begin{gather*}
  \begin{split}
    det(<0, -3>, <1, 1>) &= \begin{vmatrix}
                              0 & -3 \\
                              1 & 1 \\
                            \end{vmatrix} \\
                         &= 3
  \end{split} \\
  A = |det(<1, 2>, <1, -1>)| = 3 \\
\end{gather*}

4. a) Show that the value of a $2 \times 2$ determinants is unchanged if you add
to the second row a scalar multiple of the first row.\\
   b) Show that the value of a $2 \times 2$ determinants is unchanged if you add
to the second column a scalar multiple of the first column.

Solution:

a)
\begin{gather*}
  \begin{vmatrix}
    a_1 & a_2 \\
    b_1 & b_2 \\
  \end{vmatrix} = a_1b_2 - a_2b_1 \\
  \begin{split}
    \begin{vmatrix}
      a_1 & a_2 \\
      b_1 + c \cdot a_1 & b_2 + c \cdot a_2 \\
    \end{vmatrix} &=
    a_1 \cdot (b_2 + c \cdot a_2) - a_2 \cdot (b_1 + c \cdot a_1) \\
    &= a_1b_2 + c \cdot a_1a_2 - a_2b_1 - c \cdot a_1a_2 \\
    &= a_1b_2 - a_2b_1 \\
  \end{split} \\
\end{gather*}

b)
\begin{gather*}
  \begin{vmatrix}
    a_1 & a_2 \\
    b_1 & b_2 \\
  \end{vmatrix} = a_1b_2 - a_2b_1 \\
  \begin{split}
    \begin{vmatrix}
      a_1 & c \cdot a_1 + a_2 \\
      b_1 & c \cdot b_1 + b_2 \\
    \end{vmatrix} &=
    a_1 \cdot (c \cdot b_1 + b_2) - b_1 \cdot (c \cdot a_1 + a_2) \\
    &= c \cdot a_1b_1 + a_1b_2 - c \cdot a_1b_1 - a_2b_1\\
    &= a_1b_2 - a_2b_1 \\
  \end{split} \\
\end{gather*}

5. Use a Laplace expansion and Exercise 4a to show the value of a $3 \times 3$
determinants is unchanged if you add to the second row a scalar multiple of the
third row.

Solution:

\begin{gather*}
  \begin{vmatrix}
    a_1 & a_2 & a_3 \\
    b_1 & b_2 & b_3 \\
    c_1 & c_2 & c_3 \\
  \end{vmatrix} =
  a_1 \cdot \begin{vmatrix}
              b_2 & b_3 \\
              c_2 & c_3 \\
            \end{vmatrix} -
  a_2 \cdot \begin{vmatrix}
              b_1 & b_3 \\
              c_1 & c_3 \\
            \end{vmatrix} +
  a_3 \cdot \begin{vmatrix}
              b_1 & b_2 \\
              c_1 & c_2 \\
            \end{vmatrix} \\
  \begin{vmatrix}
    a_1 & a_2 & a_3 \\
    b_1 + k \cdot c_1 & b_2 + k \cdot c_2 & b_3 + k \cdot c_3 \\
    c_1 & c_2 & c_3 \\
  \end{vmatrix} =
  a_1 \cdot \begin{vmatrix}
              b_2 + k \cdot c_2 & b_3 + k \cdot c_3 \\
              c_2 & c_3 \\
            \end{vmatrix} - \\
  a_2 \cdot \begin{vmatrix}
              b_1 + k \cdot c_1 & b_3 + k \cdot c_3 \\
              c_1 & c_3 \\
            \end{vmatrix} +
  a_3 \cdot \begin{vmatrix}
              b_1 + k \cdot c_1 & b_2 + k \cdot c_2 \\
              c_1 & c_2 \\
            \end{vmatrix} \\
\end{gather*}
According to the result of Exercise 4a,
\begin{gather*}
  \begin{vmatrix}
    b_2 + k \cdot c_2 & b_3 + k \cdot c_3 \\
    c_2 & c_3 \\
  \end{vmatrix} =
  \begin{vmatrix}
    b_2 & b_3 \\
    c_2 & c_3 \\
  \end{vmatrix} \\
  \begin{vmatrix}
    b_1 + k \cdot c_1 & b_3 + k \cdot c_3 \\
    c_1 & c_3 \\
  \end{vmatrix} =
  \begin{vmatrix}
    b_1 & b_3 \\
    c_1 & c_3 \\
  \end{vmatrix} \\
  \begin{vmatrix}
    b_1 + k \cdot c_1 & b_2 + k \cdot c_2 \\
    c_1 & c_2 \\
  \end{vmatrix} =
  \begin{vmatrix}
    b_1 & b_2 \\
    c_1 & c_2 \\
  \end{vmatrix} \\
\end{gather*}
Therefore,
\begin{equation*}
\begin{split}
  \begin{vmatrix}
    a_1 & a_2 & a_3 \\
    b_1 + k \cdot c_1 & b_2 + k \cdot c_2 & b_3 + k \cdot c_3 \\
    c_1 & c_2 & c_3 \\
  \end{vmatrix}
  &= a_1 \cdot \begin{vmatrix}
                 b_2 + k \cdot c_2 & b_3 + k \cdot c_3 \\
                 c_2 & c_3 \\
               \end{vmatrix} -
     a_2 \cdot \begin{vmatrix}
                 b_1 + k \cdot c_1 & b_3 + k \cdot c_3 \\
                 c_1 & c_3 \\
               \end{vmatrix} + \\
     a_3 \cdot \begin{vmatrix}
                 b_1 + k \cdot c_1 & b_2 + k \cdot c_2 \\
                 c_1 & c_2 \\
               \end{vmatrix} \\
  &= a_1 \cdot \begin{vmatrix}
                 b_2 & b_3 \\
                 c_2 & c_3 \\
               \end{vmatrix} -
     a_2 \cdot \begin{vmatrix}
                 b_1 & b_3 \\
                 c_1 & c_3 \\
               \end{vmatrix} +
     a_3 \cdot \begin{vmatrix}
                 b_1 & b_2 \\
                 c_1 & c_2 \\
               \end{vmatrix} \\
  &= \begin{vmatrix}
       a_1 & a_2 & a_3 \\
       b_1 & b_2 & b_3 \\
       c_1 & c_2 & c_3 \\
     \end{vmatrix} \\
\end{split}
\end{equation*}

6. Let $(x_{1}, y_{1})$ and $(x_{2}, y_{2})$ both range over all unit vectors.
Find the maximum value of the function $f(x_{1}, x_{2}, y_{1}, y_{2}) =
\begin{vmatrix}
x_{1} & y_{1} \\
x_{2} & y_{2} \\
\end{vmatrix}$.

Solution:

According to the geometric interpretation of $2 \times 2$ determinants, the
value of the function $f(x_{1}, x_{2}, y_{1}, y_{2}) =
\begin{vmatrix}
x_{1} & y_{1} \\
x_{2} & y_{2} \\
\end{vmatrix}$ is the positive or negative value of the parallelogram formed by
the two unit vectors $(x_1, y_1)$ and $(x_2, y_2)$. The area of the
parallelogram formed by these two vectors can be calculated as
\begin{equation*}
\begin{split}
  A &= |<x_1, y_1>| \cdot |<x_2, y_2>| \cdot \sin\theta \\
    &= \sin\theta \\
\end{split}
\end{equation*}
where $\theta$ is the angle between these two vectors.

Apparently, the maximum value of the area of the parallelogram formed by these
two vectors is $1$, which is achieved when $\theta = \frac{\pi}{2}$, i.e. the
two unit vectors are perpendicular to each other.

\subsection*{Unit 4 Cross Product}

1. Find $\vec{A} \times \vec{B}$ if\\
a) $\vec{A} = \vec{i} - 2 \vec{j} + \vec{k}$, $\vec{B} = 2 \vec{i} - \vec{j} -
\vec{k}$ \\
b) $\vec{A} = 2 \vec{i} - 3 \vec{k}$, $\vec{B} = \vec{i} + \vec{j} - \vec{k}$

Solution:

a)
\begin{equation*}
\begin{split}
  \vec{A} \times \vec{B}
  &= \begin{vmatrix}
       \vec{i} & \vec{j} & \vec{k} \\
       1 & -2 & 1 \\
       2 & -1 & -1 \\
     \end{vmatrix} \\
  &= \vec{i} \cdot \begin{vmatrix}
                     -2 & 1 \\
                     -1 & -1 \\
                   \end{vmatrix} -
     \vec{j} \cdot \begin{vmatrix}
                     1 & 1 \\
                     2 & -1 \\
                   \end{vmatrix} +
     \vec{k} \cdot \begin{vmatrix}
                     1 & -2 \\
                     2 & -1 \\
                   \end{vmatrix} \\
  &= 3\vec{i} + 3\vec{j} + 3\vec{k} \\
\end{split}
\end{equation*}

b)
\begin{equation*}
\begin{split}
  \vec{A} \times \vec{B}
  &= \begin{vmatrix}
       \vec{i} & \vec{j} & \vec{k} \\
       2 & 0 & -3 \\
       2 & 1 & -1 \\
     \end{vmatrix} \\
  &= \vec{i} \cdot \begin{vmatrix}
                     0 & -3 \\
                     1 & -1 \\
                   \end{vmatrix} -
     \vec{j} \cdot \begin{vmatrix}
                     2 & -3 \\
                     2 & -1 \\
                   \end{vmatrix} +
     \vec{k} \cdot \begin{vmatrix}
                     2 & 0 \\
                     2 & 1 \\
                   \end{vmatrix} \\
  &= 3\vec{i} - 4\vec{j} + 2\vec{k} \\
\end{split}
\end{equation*}

2. Find the area of the triangle in space having its vertices at the points
\[ P:(2,0,1), Q:(3,1,0), R:(-1,1,-1).\]

Solution:

\begin{gather*}
  \vec{PQ} = <1, 1, -1> \\
  \vec{PR} = <-3, 1, -2> \\
  \begin{split}
    \vec{PQ} \times \vec{PR}
    &= \begin{vmatrix}
         \vec{i} & \vec{j} & \vec{k} \\
         1 & 1 & -1 \\
         -3 & 1 & -2 \\
       \end{vmatrix} \\
    &= <-1, 5, 4> \\
  \end{split} \\
  \begin{split}
    A &= \frac{|\vec{PQ} \times \vec{PR}|}{2} \\
      &= \frac{\sqrt{(-1)^2 + 5^2 + 4^2}}{2} \\
      &= \frac{\sqrt{42}}{2} \\
  \end{split} \\
\end{gather*}
Therefore, the area of the described triangle is $\frac{\sqrt{42}}{2}$.

3. Two vectors $\vec{i'}$ and $\vec{j'}$ of a right-handed coordinate system are
to have the directions respectively of the vectors $\vec{A} = 2\vec{i} - \vec{j}$
and $\vec{B} = \vec{i} + 2\vec{j} + \vec{k}$. Find all three vectors
$\vec{i'}$, $\vec{j'}$, $\vec{k'}$.

Solution:

According to the problem description, $\vec{i'}$ is the direction of the vector
$\vec{A} = 2\vec{i} - \vec{j}$, hence
\begin{equation*}
\begin{split}
  \vec{i'} &= \frac{\vec{A}}{|\vec{A}|} \\
           &= \frac{<2, -1, 0>}{\sqrt{5}} \\
           &= <\frac{2\sqrt{5}}{5}, -\frac{\sqrt{5}}{5}, 0> \\
\end{split}
\end{equation*}

Similarly, since $\vec{j'}$ is the direction of the vector
$\vec{B} = \vec{i} + 2\vec{j} + \vec{k}$,
\begin{equation*}
\begin{split}
  \vec{j'} &= \frac{\vec{B}}{|\vec{B}|} \\
           &= \frac{<1, 2, 1>}{\sqrt{6}} \\
           &= <\frac{\sqrt{6}}{6}, \frac{2\sqrt{6}}{6}, \frac{\sqrt{6}}{6}> \\
\end{split}
\end{equation*}
According to the geometric interpretation of cross product,
\begin{gather*}
  \begin{split}
    \vec{A} \times \vec{B}
    &= \begin{vmatrix}
         \vec{i} & \vec{j} & \vec{k} \\
         2 & -1 & 0 \\
         1 & 2 & 1 \\
       \end{vmatrix} \\
    &= <-1, -2, 5>
  \end{split} \\
  \begin{split}
    \vec{k'} &= dir(\vec{A} \times \vec{B}) \\
             &= \frac{\vec{A} \times \vec{B}}{|\vec{A} \times \vec{B}|} \\
             &= \frac{<-1, -2, 5>}{\sqrt{30}} \\
             &= <-\frac{\sqrt{30}}{30}, -\frac{\sqrt{30}}{15}, \frac{\sqrt{30}}{6}> \\
  \end{split}
\end{gather*}

4. Verify that the cross product $\times$ does not in general satisfy the
associative law, by showing that for the particular vectors $\vec{i}$,
$\vec{j}$, $\vec{k}$, we have $(\vec{i} \times \vec{j}) \times \vec{k} \neq
\vec{i} \times (\vec{j} \times \vec{k})$.

Solution:

Suppose that $\vec{i} = <1, 0, 1>$, $\vec{j} = <1, 1, 0>$, and
$\vec{k} = <0, 1, 1>$.
Then
\begin{gather*}
  (\vec{i} \times \vec{j}) \times \vec{k} = <0, 1, -1> \\
  \vec{i} \times (\vec{j} \times \vec{k}) = <1, 0, -1> \\
\end{gather*}
Hence, the cross product does not in general satisfy the associative law.

5. What can you conclude about $\vec{A}$ and $\vec{B}$\\
a) if $|\vec{A} \times \vec{B}| = |\vec{A}| |\vec{B}|$;\\
b) if $|\vec{A} \times \vec{B}| = \vec{A} \cdot \vec{B}$.

Solution:

a) According to the geometric interpretation of cross product,
$|\vec{A} \times \vec{B}|$ is the area of the parallelogram formed by the
vectors $\vec{A}$ and $\vec{B}$. Therefore,
\[
  |\vec{A} \times \vec{B}| = |\vec{A}| |\vec{B}| \sin\theta
\]
where $\theta$ is the angle between the vectors $\vec{A}$ and $\vec{B}$.

Then if $|\vec{A} \times \vec{B}| = |\vec{A}| |\vec{B}|$,
\begin{gather*}
  |\vec{A} \times \vec{B}| = |\vec{A}| |\vec{B}| \\
  |\vec{A}| |\vec{B}| \sin\theta = |\vec{A}| |\vec{B}| \\
  \sin\theta = 1 \\
  \theta = \frac{\pi}{2} \\
\end{gather*}
We can conclude that the angle between the vectors $\vec{A}$ and $\vec{B}$ is
$\frac{\pi}{2}$.

b) Similar to Exercise a), if
$|\vec{A} \times \vec{B}| = \vec{A} \cdot \vec{B}$,
\begin{gather*}
  |\vec{A} \times \vec{B}| = \vec{A} \cdot \vec{B} \\
  |\vec{A}| |\vec{B}| \sin\theta = |\vec{A}| |\vec{B}| \cos\theta \\
  \sin\theta = \cos\theta \\
  \theta = \frac{pi}{4} \\
\end{gather*}
We can conclude that the angle between the vectors $\vec{A}$ and $\vec{B}$ is
$\frac{\pi}{4}$.

6. Find the volume of the tetrahedron having vertices at the four points
\[ P:(1,0,1), Q:(-1,1,2), R:(0,0,2), S:(3,1,-1).\]

Solution:

\begin{gather*}
  \vec{PQ} = <-2, 1, 1> \\
  \vec{PR} = <-1, 0, 1> \\
  \vec{PS} = <2, 1, -2> \\
\end{gather*}

According to the geometric interpretation of $3 \times 3$ determinants, the
volume of the tetrahedron with the described vertices can be calculated as
\begin{gather*}
  \begin{split}
    det(\vec{PQ}, \vec{PR}, \vec{PS})
    &= \begin{vmatrix}
         -2 & 1 & 1 \\
         -1 & 0 & 1 \\
         2 & 1 & -2 \\
       \end{vmatrix} \\
    &= -2 \times (-1) - 1 \times 0 + 1 \times (-1) \\
    &= 1
  \end{split} \\
  \begin{split}
    V &= |det(\vec{PQ}, \vec{PR}, \vec{PS})| \\
      &= 1 \\
  \end{split} \\
\end{gather*}
Therefore, the volume of the described tetrahedron is 1.

\begin{center}
\section*{Part II}
\end{center}

1. Find the dihedral angle between two faces of a regular tetrahedron.

Solution:

\begin{definition}
  A dihedral angle is the angle between two intersecting planes or half-planes.
\end{definition}

\begin{definition}
  A regular tetrahedron is a tetrahedron in which all four faces are equilateral
  triangles.
\end{definition}

\begin{definition}
  In geometry, an equilateral triangle is a triangle in which all three sides
  have the same length.
\end{definition}

\begin{tikzpicture}
  [help line/.style={dashed}]
  \draw[->] (-3, 0, 0) -- (3, 0, 0) node[below right] {x};
  \draw[->] (0, -1, 0) -- (0, 3, 0) node[right] {y};
  \draw (0, 0) node[below right] {O};
  \draw[-] (-1, 0, 0) -- (1, 0, 0);
  \draw[-] (-1, 0, 0) -- (0, 1.732, 0);
  \draw[-] (1, 0, 0) -- (0, 1.732, 0);
  \draw (0, 1.732) node[above] {A};
  \draw (-1, 0) node[left] {B};
  \draw (1, 0) node[right] {C};
  \draw[help line] (0, 1.732, 0) -- (0, 0, 0);
  \draw[help line] (-1, 0, 0) -- (0.5, 0.866, 0);
  \draw[help line] (1, 0, 0) -- (-0.5, 0.866, 0);
  \draw (0, 0.577) node[below right] {S'};
\end{tikzpicture}

Suppose that there is a regular tetrahedron whose length is 2. Let A, B, C, S
denote the four vertices of the tetrahedron, and we'll build a Cartesian
coordinate system as shown in the diagram.

According to the geometric property of a regular tetrahedron, we can get
the coordinates of the four vertices:
\[ A = (0, \sqrt{3}, 0), B = (-1, 0, 0), C = (1, 0, 0), S = (0, \frac{\sqrt{3}}{3}, \frac{2\sqrt{3}}{3})\]

To calculate the dihedral angle between two planes, we can find a point on the
intersection line, and from that point find two lines in two planes respectively
which is perpendicular to the intersection line.

In this case, we 'll try to find the dihedral angle between the plane $ABC$ and
$SBC$, using the point $O$ as the starting point and hence $BC$ as the
intersection line. According to the geometric property of equilateral triangles:
\[ OA \perp BC, OS \perp BC \]
Therefore, the dihedral angle between the plane $ABC$ and $SBC$ is the angle
$\angle{AOS}$ between the line $OA$ and $OS$.
\begin{gather*}
  \vec{OA} = <0, \sqrt{3}, 0> \\
  \vec{OS} = <0, \frac{\sqrt{3}}{3}, \frac{2\sqrt{3}}{3}> \\
  \begin{split}
    \cos\angle{AOS} &= \frac{\vec{OA} \cdot \vec{OS}}{|\vec{OA}| \cdot |\vec{OS}|} \\
                    &= \frac{0 \times 0 + \sqrt{3} \times \frac{\sqrt{3}}{3} + 0 \times \frac{2\sqrt{3}}{3}}{\sqrt{3} \times \sqrt{(\frac{\sqrt{3}}{3})^2 + (\frac{2\sqrt{3}}{3})^2}} \\
                    &= \frac{\sqrt{5}}{5} \\
  \end{split} \\
  \angle{AOS} = cos^{-1}(\frac{\sqrt{5}}{5}) \\
\end{gather*}
Therefore, the dihedral angle between two faces of a regular tetrahedron is
$cos^{-1}(\frac{\sqrt{5}}{5})$.

2. a) Show that the 'polarization identity'
$\frac{1}{4}(|\vec{u} + \vec{v}|^{2} - |\vec{u} - \vec{v}|^{2}) = \vec{u} \cdot \vec{v}$
holds for any two n-vectors $\vec{u}$ and $\vec{v}$. (Use vector algebra, not
components.) \\
b) Given two non-zero vectors $\vec{u}$ and $\vec{v}$, give the formula for the
unit vector which bisects the (smaller) angle between $\vec{u}$ and $\vec{v}$.
(Use the notation $\hat{\vec{u}}$ for the unit vector in the $\vec{u}$ -
direction.)

Solution:

a) Proof:
\begin{gather*}
  \begin{split}
    \frac{1}{4}(|\vec{u} + \vec{v}|^{2} - |\vec{u} - \vec{v}|^{2}) &= \frac{1}{4}((\vec{u} + \vec{v})^2 - (\vec{u} - \vec{v})^2) \\
                                                                   &= \frac{1}{4}((\vec{u}^2 + \vec{v}^2 + 2\vec{u} \cdot \vec{v}) - (\vec{u}^2 + \vec{v}^2 - 2\vec{u} \cdot \vec{v})) \\
                                                                   &= \frac{1}{4}(4\vec{u} \cdot \vec{v}) \\
                                                                   &= \vec{u} \cdot \vec{v} \\
  \end{split} \\
\end{gather*}

b) According to the geometric interpretation of the addition of vectors, for two
unit vectors $\vec{a}$ and $\vec{b}$, the vector $\vec{a} + \vec{b}$ bisects the
(smaller) angle between $\vec{a}$ and $\vec{b}$ because $\vec{a}$, $\vec{b}$,
and $\vec{a} + \vec{b}$ would form an isosceles triangle where the $\vec{a}$ and
$\vec{b}$ are the two side that have equal lengths.

Therefore, to find the unit vector which bisects the (smaller) angle between
$\vec{u}$ and $\vec{v}$, we can find the unit vector which bisects the (smaller)
angle between $\hat{\vec{u}}$ and $\hat{\vec{v}}$, which is
\begin{gather*}
  \begin{split}
    \vec{w} &= \frac{\hat{\vec{u}} + \hat{\vec{v}}}{|\hat{\vec{u}} + \hat{\vec{v}}|} \\
            &= \frac{\frac{\vec{u}}{|\vec{u}|} + \frac{\vec{v}}{|\vec{v}|}}{\sqrt{(\frac{\vec{u}}{|\vec{u}|} + \frac{\vec{v}}{|\vec{v}|})^2}} \\
            &= \frac{\frac{|\vec{v}| \cdot \vec{u} + |\vec{u}| \cdot \vec{v}}{|\vec{u}| \cdot |\vec{v}|}}{\sqrt{2 + 2\frac{\vec{u} \cdot \vec{v}}{|\vec{u} \cdot |\vec{v}|}}} \\
            &= \frac{|\vec{v}| \cdot \vec{u} + |\vec{u}| \cdot \vec{v}}{\sqrt{2|\vec{u}|^2 \cdot |\vec{v}|^2 + 2|\vec{u}||\vec{v}|\vec{u} \cdot \vec{v}}}
  \end{split} \\
\end{gather*}

3. In this problem we examine tacking, which is the process sailboats use to
travel against the wind. Sails are a familar tool to harness the energy of the
wind for transportation over the sea. Early ships had large fixed sails which
would capture the wind blowing from behind to propel the ship forward. Even if
the wind is blowing behind at an (acute) angle the component of the wind vector
perpendicular to the sail will push on the sail and hence on the boat. However,
these early fixed sail ships had no way to go against the wind and had to rely
on oarsmen if the wind was blowing in the wrong direction.

A great advance that allowed boats to sail against the wind was the invention
of movable sails in combination with a rudder and a keel. By carefully
positioning the sail the boat can be made to sail into the wind - this process
is called \emph{tacking}.

As noted before, the component of the wind perpendicular to the sail pushes on
the sail and, through it, the boat. The keel only allows the boat to move along
its axis. (The rudder is used to turn the boat.) That is, for any force on the
boat, only the component along the boat's axis actually pushes the boat.

Described mathematically, the wind vector is first projected on the
perpendicular to the sail to get the direction of the force on the sail. This
resultant force is projected on the axis of the boat to find the direction the
boat is being pushed. By orienting the sail correctly this double projection
can result in a vector with a component pointing into the wind.

\begin{tikzpicture}
  [help line/.style={dashed}]
  \draw[help line] (-3, 0, 0) -- (3, 0, 0) node[right] {x};
  \draw[help line] (0, -3, 0) -- (0, 3, 0) node[above] {y};
  \draw[->] (0, 0, 0) -- (2, 0, 0) node[below] {$\vec{w} = a\vec{i}$};
  \draw[-] (-1, -1.732, 0) -- (1, 1.732, 0) node[above right] {$l_s$};
  \draw[-] (1, -1.732, 0) -- (-1, 1.732, 0) node[above left] {$l_B$};
  \draw (0, 0, 0) node[above right] {$\alpha$};
  \draw (0, 0, 0) node[above] {$\beta$};
\end{tikzpicture}

In the picture $\vec{w} = a \vec{i}$ is the wind direction. The line $l_s$ is
perpendicular to the sail (with $0 \leq \alpha \leq \frac{\pi}{2}$). And the
line $l_B$ is along the boat's axis (with $0 \leq \beta \leq \frac{\pi}{2}$).

a) Let $\vec{w_1}$ be the projection of $\vec{w}$ onto the line $l_s$. Show that
$\vec{w_1}$ does not have a non-zero component in the direction opposite
$\vec{w}$. (It is sufficient to show the projections on the sketch.)

b) Find the projection of $\vec{w_{1}}$ onto $l_{B}$. (Give an explicit formula
in terms of $\alpha$ and $\beta$.) What is the condition on $\alpha$ and $\beta$
that this projection has a component in the $-\vec{i}$ direction? (For warmup
you might try the specific case $\alpha = \frac{\pi}{3} = \beta$.)

Solution:

a) According to the definition of additions and decomposition of vectors, the
projection $\vec{w_1}$ of $\vec{w}$ along the line $l_s$ must have an acute
angle, which is $\alpha$, with $\vec{w}$. Therefore, $\vec{w_1}$ has an obtuse
angle with the reverse direction of $\vec{w}$. Therefore, according to the rule
of vector decomopsition, $\vec{w_1}$ cannot have a non-zero component on the
reverse direction of $\vec{w}$.

b) Let $\vec{w_B}$ denote the projection vector of $\vec{w_1}$ onto $l_B$. Then
\begin{gather*}
  \begin{split}
    |\vec{w_B}| &= |\vec{w_1}| \cos\beta \\
                &= |\vec{w}| \cos\alpha \cos\beta \\
                &= a \cos\alpha \cos\beta \\
  \end{split} \\
\end{gather*}
From geometric point of view, for the projection of $\vec{w_B}$ on the x axis,
we can see from the diagram that if $l_B$ passes the second quadrant,
$\vec{w_B}$ would has a non-zero component along the reverse direction of
$\vec{i}$. Therefore, the condition is that $\alpha + \beta > \frac{\pi}{2}$.

From analytical point of view, the component of $\vec{w_B}$ on the $-\vec{i}$
direction can be calculated as
\begin{gather*}
  \begin{split}
    |\vec{w_B}| \cos(\pi - \alpha - \beta) = -|\vec{w_B}| \cos(\alpha + \beta)
  \end{split}
\end{gather*}
Therefore, to make sure the component on the $-\vec{i}$ direction is non-zero,
the condition is:
\begin{itemize}
  \item $|\vec{w_B}|$ is non-zero, which is guaranteed by the values of $a$,
    $\alpha$ and $\beta$.
  \item $\cos(\alpha + \beta) < 0$, which is equivalent to
    $\alpha + \beta > \frac{\pi}{2}$.
\end{itemize}

\end{document}