\chapter{Governing Equations}
\label{cha:governing:equations}

We present here a brief derivation of the equations for both quasi-static
and dynamic computations. Since the general equations are the same
(except for the absence of inertial terms in the quasi-static case),
we first derive these equations. We then present solution methods
for each specific case. In all of our derivations, we use the notation
described in Table \vref{tab:notation} for both index
and vector notation. When using index notation, we use the common
convention that repeated indices indicate summation over the range
of the index.

\begin{table}[htbp]
  \caption{Mathematical notation}
  \label{tab:notation}
  \begin{tabular}{ccp{3in}}
    \multicolumn{2}{c}{{\bf Symbol}} & {\bf Description} \\
    {\bf Index notation} & {\bf Vector Notation} & \\
    \hline
    $a_{i}$ & \raisebox{12pt}{}$\overrightarrow{a}$ & Vector field a \\
    $a_{ij}$ & $\underline{a}$ & Second order tensor field a \\
    $u_{i}$ & $\overrightarrow{u}$ & Displacement vector field \\
    $d_{i}$ & $\vec{{d}}$ & Fault slip vector field \\
    $f_{i}$ & $\overrightarrow{f}$ & Body force vector field \\
    $T_{i}$ & $\overrightarrow{T}$ & Traction vector field \\
    $\sigma_{ij}$ & $\underline{\sigma}$ & Stress tensor field \\
    $n_{i}$ & $\overrightarrow{n}$ & Normal vector field \\
    $\rho$ & $\rho$ & Mass density scalar field \\
    \hline
  \end{tabular}
\end{table}

\section{Derivation of Elasticity Equation}

\subsection{Index Notation}

Consider volume $V$ bounded by surface $S$. Applying a Lagrangian
description of the conservation of momentum gives
\begin{equation}
\label{eqn:momentum:index}
\frac{\partial}{\partial t}\int_{V}\rho\frac{\partial u_{i}}{\partial t}\, dV=\int_{V}f_{i}\, dV+\int_{S}T_{i}\, dS.
\end{equation}
The traction vector field is related to the stress tensor through
\begin{equation}
T_{i}=\sigma_{ij}n_{j},
\end{equation}
where $n_{j}$ is the vector normal to $S$. Substituting into equation
\vref{eqn:momentum:index} yields
\begin{equation}
\frac{\partial}{\partial t}\int_{V}\rho\frac{\partial u_{i}}{\partial t}\, dV=\int_{V}f_{i}\, dV+\int_{S}\sigma_{ij}n_{j}\, dS.
\end{equation}
Applying the divergence theorem,
\begin{equation}
\int_{V}a_{i,j}\: dV=\int_{S}a_{j}n_{j}\: dS,
\end{equation}
to the surface integral results in
\begin{equation}
\frac{\partial}{\partial t}\int_{V}\rho\frac{\partial u_{i}}{\partial t}\, dV=\int_{V}f_{i}\, dV+\int_{V}\sigma_{ij,j}\, dV,
\end{equation}
which we can rewrite as
\begin{equation}
\int_{V}\left(\rho\frac{\partial^{2}u_{i}}{\partial t^{2}}-f_{i}-\sigma_{ij,j}\right)\, dV=0.
\end{equation}
Because the volume $V$ is arbitrary, the integrand must be zero at
every location in the volume, so that we end up with
\begin{gather}
\rho\frac{\partial^{2}u_{i}}{\partial t^{2}}-f_{i}-\sigma_{ij,j}=0\text{ in }V,\\
\sigma_{ij}n_{j}=T_{i}\text{ on }S_{T}\text{,}\\
u_{i}=u_{i}^{o}\text{ on }S_{u}\text{, and}\\
R_{ki}(u_{i}^{+}-u_{i}^{-})=d_{k}\text{ on }S_{f}.
\end{gather}
We specify tractions, $T_{i}$, on surface $S_{f}$, displacements,
$u_{i}^{o}$, on surface $S_{u}$, and slip, $d_{k}$, on fault surface
$S_{f}$ (we will consider the case of fault constitutive models in
Section \vref{sec:fault}). The rotation matrix $R_{ki}$ transforms
vectors from the global coordinate system to the fault coordinate
system. Note that since both $T_{i}$ and $u_{i}$ are vector quantities,
there can be some spatial overlap of the surfaces $S_{T}$ and $S_{u}$;
however, the same degree of freedom cannot simultaneously have both
types of boundary conditions.

\subsection{Vector Notation}

Consider volume $V$ bounded by surface $S$. Applying a Lagrangian
description of the conservation of momentum gives
\begin{equation}
\label{eqn:momentum:vec}
\frac{\partial}{\partial t}\int_{V}\rho\frac{\partial\vec{u}}{\partial t}\, dV=\int_{V}\overrightarrow{f}\, dV+\int_{S}\overrightarrow{T}\, dS.
\end{equation}
The traction vector field is related to the stress tensor through
\begin{equation}
\overrightarrow{T}=\underline{\sigma}\cdot\overrightarrow{n},
\end{equation}
where $\overrightarrow{n}$ is the vector normal to $S$. Substituting
into equation \vref{eqn:momentum:vec} yields
\begin{equation}
\frac{\partial}{\partial t}\int_{V}\rho\frac{\partial\overrightarrow{u}}{\partial t}\, dV=\int_{V}\overrightarrow{f}\, dV+\int_{S}\underline{\sigma}\cdot\overrightarrow{n}\, dS.
\end{equation}
Applying the divergence theorem,
\begin{equation}
\int_{V}\nabla\cdot\overrightarrow{a}\: dV=\int_{S}\overrightarrow{a}\cdot\overrightarrow{n}\: dS,
\end{equation}
to the surface integral results in
\begin{equation}
\frac{\partial}{\partial t}\int_{V}\rho\frac{\partial\overrightarrow{u}}{\partial t}\, dV=\int_{V}\overrightarrow{f}\, dV+\int_{V}\nabla\cdot\underline{\sigma}\, dV,
\end{equation}
which we can rewrite as
\begin{equation}
\int_{V}\left(\rho\frac{\partial^{2}\overrightarrow{u}}{\partial t^{2}}-\overrightarrow{f}-\nabla\cdot\overrightarrow{\sigma}\right)\, dV=\vec{0}.
\end{equation}
Because the volume $V$ is arbitrary, the integrand must be the zero
vector at every location in the volume, so that we end up with
\begin{gather}
\rho\frac{\partial^{2}\overrightarrow{u}}{\partial t^{2}}-\overrightarrow{f}-\nabla\cdot\overrightarrow{\sigma}=\vec{0}\text{ in }V,\\
\underline{\sigma}\cdot\overrightarrow{n}=\overrightarrow{T}\text{ on }S_{T}\text{,}\\
\overrightarrow{u}=\overrightarrow{u^{o}}\text{ on }S_{u},\text{ and}\\
\underbar{R}\cdot(\vec{u^{+}}-\vec{u^{-}})=\vec{d}\text{ on }S_{f}.
\end{gather}
We specify tractions, $\vec{T}$, on surface $S_{f}$, displacements,
$\overrightarrow{u^{o}}$, on surface $S_{u}$, and slip, $\vec{d}$,
on fault surface $S_{f}$ (we will consider the case of fault constitutive
models in Section \vref{sec:fault}). The rotation matrix $\underline{R}$
transforms vectors from the global coordinate system to the fault
coordinate system. Note that since both $\overrightarrow{T}$ and
$\overrightarrow{u}$ are vector quantities, there can be some spatial
overlap of the surfaces $S_{T}$ and $S_{u}$; however, the same degree
of freedom cannot simultaneously have both types of boundary conditions.

\section{Finite-Element Formulation of Elasticity Equation}

We formulate a set of algebraic equations using Galerkin's method.
We consider (1) a trial solution, $\vec{u}$, that is a piecewise
differentiable vector field and satisfies the Dirichlet boundary conditions
on $S_{u}$, and (2) a weighting function, $\vec{\phi}$, that is
a piecewise differentiable vector field and is zero on $S_{u}$.

\subsection{Index Notation}

We start with the wave equation (strong form),
\begin{gather}
\sigma_{ij,j}+f_{i}=\rho\ddot{u_{i}}\text{ in }V,\\
\sigma_{ij}n_{j}=T_{i}\text{ on }S_{T},\\
u_{i}=u_{i}^{o}\text{ on }S_{u},\\
R_{ki}(u_{i}^{+}-u_{i}^{-})=d_{k}\text{ on }S_{f},\text{ and}\\
\sigma_{ij}=\sigma_{ji}\text{ (symmetric).}
\end{gather}
We construct the weak form by computing the dot product of the wave
equation and weighting function and setting the integral over the
domain to zero:
\begin{gather}
\int_{V}\left(\sigma_{ij,j}+f_{i}-\rho\ddot{u}_{i}\right)\phi_{i}\, dV=0\text{, or }\\
\int_{V}\sigma_{ij,j}\phi_{i}\: dV+\int_{V}f_{i}\phi_{i}\: dV-\int_{V}\rho\ddot{u}_{i}\phi_{i}\: dV=0.
\end{gather}
 Consider the divergence theorem applied to the dot product of the
stress tensor and the weighting function, $\sigma_{ij}\phi_{i}$,
\begin{equation}
\int_{V}(\sigma_{ij}\phi_{i})_{,j}\, dV=\int_{S}(\sigma_{ij}\phi_{i})n_{i}\, dS.
\end{equation}
Expanding the left-hand side yields
\begin{gather}
\int_{V}\sigma_{ij,j}\phi_{i}\: dV+\int_{V}\sigma_{ij}\phi_{i,j}\: dV=\int_{S}\sigma_{ij}\phi_{i}n_{i}\: dS,\text{ or}\\
\int_{V}\sigma_{ij,j}\phi_{i}\: dV=-\int_{V}\sigma_{ij}\phi_{i,j}\, dV+\int_{S}\sigma_{ij}\phi_{i}n_{i}\, dS.
\end{gather}
Substituting into the weak form gives
\begin{equation}
-\int_{V}\sigma_{ij}\phi_{i,j}\, dV+\int_{S}\sigma_{ij}\phi_{i}n_{i}\, dS+\int_{V}f_{i}\phi_{i}\, dV-\int_{V}\rho\ddot{u}_{i}\phi_{i}\, dV=0.
\end{equation}
Turning our attention to the second term, we separate the integration
over $S$ into integration over $S_{T}$ and $S_{u}$ (we will consider
tractions over the fault surface, $S_{f}$, associated with the fault
constitutive model in Section \vref{sec:fault}),
\begin{equation}
-\int_{V}\sigma_{ij}\phi_{i,j}\, dV+\int_{S_{T}}\sigma_{ij}\phi_{i}n_{i}\, dS+\int_{S_{u}}\sigma_{ij}\phi_{i}n_{i}\, dS+\int_{V}f_{i}\phi_{i}\, dV-\int_{V}\rho\ddot{u}_{i}\phi_{i}\, dV=0,
\end{equation}
and recognize that
\begin{gather}
\sigma_{ij}n_{i}=T_{i}\text{ on }S_{T}\text{ and}\\
\phi_{i}=0\text{ on }S_{u},
\end{gather}
so that the equation reduces to
\begin{equation}
\label{eq:elasticity:integral}
-\int_{V}\sigma_{ij}\phi_{i,j}\: dV+\int_{S_{T}}T_{i}\phi_{i}\, dS+\int_{V}f_{i}\phi_{i}\, dV-\int_{V}\rho\ddot{u}_{i}\phi_{i}\, dV=0.
\end{equation}
We express the trial solution and weighting function as linear combinations
of basis functions,
\begin{gather}
u_{i}=\sum_{m}a_{i}^{m}N^{m},\\
\phi_{i}=\sum_{n}c_{i}^{n}N^{n}.
\end{gather}
Note that because the trial solution satisfies the Dirichlet boundary
condition, the number of basis functions for $u$ is generally greater
than the number of basis functions for $\phi$, i.e., $m>n$. Substituting
in the expressions for the trial solution and weighting function yields
\begin{gather}
-\int_{V}\sigma_{ij}\sum_{n}c_{i}^{n}N_{,j}^{n}\: dV+\int_{S_{T}}T_{i}\sum_{n}c_{i}^{n}N^{n}\, dS+\int_{V}f_{i}\sum_{n}c_{i}^{n}N^{n}\, dV-\int_{V}\rho\sum_{m}\ddot{a}_{i}^{m}N^{m}\sum_{n}c_{i}^{n}N^{n}\ dV=0,\text{ or}\\
\sum_{n}c_{i}^{n}(-\int_{V}\sigma_{ij}N_{,j}^{n}\: dV+\int_{S_{T}}T_{i}N^{n}\, dS+\int_{V}f_{i}N^{n}\, dV-\int_{V}\rho\sum_{m}\ddot{a}_{i}^{m}N^{m}N^{n}\ dV)=0.
\end{gather}
 Because the weighting function is arbitrary, this equation must hold
for all $c_{i}^{n}$, so that the quantity in parenthesis is zero
for each $c_{i}^{n}$
\begin{equation}
\label{eq:elasticity:integral:discretized}
-\int_{V}\sigma_{ij}N_{,j}^{n}\: dV+\int_{S_{T}}T_{i}N^{n}\, dS+\int_{V}f_{i}N^{n}\, dV-\int_{V}\rho\sum_{m}\ddot{a}_{i}^{m}N^{m}N^{n}\ dV=\vec{0}.
\end{equation}
We want to solve this equation for the unknown coefficients $a_{i}^{m}$
subject to
\begin{gather}
u_{i}=u_{i}^{o}\text{ on }S_{u},\text{ and}\\
R_{ki}(u_{i}^{+}-u_{i}^{-})=d_{k}\text{ on }S_{f},
\end{gather}

\subsection{Vector Notation}

We start with the wave equation (strong form),
\begin{gather}
\nabla\cdot\underline{\sigma}+\overrightarrow{f}=\rho\frac{\partial^{2}\overrightarrow{u}}{\partial t^{2}}\text{ in }V,\\
\underline{\sigma}\cdot\overrightarrow{n}=\overrightarrow{T}\text{ on }S_{T},\\
\overrightarrow{u}=\overrightarrow{u^{o}}\text{ on }S_{u},\\
\underbar{R}\cdot(\overrightarrow{u^{+}}-\overrightarrow{u^{-}})=\vec{d}\text{ on }S_{f}\\
\underline{\sigma}=\underline{\sigma}^{T}\text{ (symmetric).}
\end{gather}
We construct the weak form by multiplying the wave equation by a weighting
function and setting the integral over the domain to zero. The weighting
function is a piecewise differential vector field, $\overrightarrow{\phi}$,
where $\overrightarrow{\phi}=0$ on $S_{u}.$ Hence our weak form
is
\begin{gather}
\int_{V}\left(\nabla\cdot\underline{\sigma}+\overrightarrow{f}-\rho\frac{\partial^{2}\overrightarrow{u}}{\partial t^{2}}\right)\cdot\overrightarrow{\phi}\, dV=0\text{, or }\\
\int_{V}(\nabla\cdot\underline{\sigma})\cdot\overrightarrow{\phi}\: dV+\int_{V}\overrightarrow{f}\cdot\overrightarrow{\phi}\: dV-\int_{V}\rho\frac{\partial^{2}\overrightarrow{u}}{\partial t^{2}}\cdot\overrightarrow{\phi}\: dV=0.
\end{gather}
 Consider the divergence theorem applied to the dot product of the
stress tensor and the trial function, $\underline{\sigma}\cdot\overrightarrow{\phi}$,
\begin{equation}
\int_{V}\nabla\cdot(\underline{\sigma}\cdot\overrightarrow{\phi})\, dV=\int_{S}(\underline{\sigma}\cdot\overrightarrow{\phi})\cdot\overrightarrow{n}\, dS.
\end{equation}
Expanding the left-hand side yields
\begin{equation}
\int_{V}(\nabla\cdot\underline{\sigma})\cdot\overrightarrow{\phi}\: dV+\int_{V}\underline{\sigma}:\nabla\overrightarrow{\phi}\: dV=\int_{S}(\underline{\sigma}\cdot\overrightarrow{\phi})\cdot\overrightarrow{n}\: dS,\text{ or}
\end{equation}
\begin{equation}
\int_{V}(\nabla\cdot\underline{\sigma})\cdot\overrightarrow{\phi}\: dV=-\int_{V}\underline{\sigma}:\nabla\overrightarrow{\phi}\, dV+\int_{S}\underline{\sigma}\cdot\overrightarrow{n}\cdot\overrightarrow{\phi}\, dS.
\end{equation}
Substituting into the weak form gives
\begin{equation}
-\int_{V}\underline{\sigma}:\nabla\overrightarrow{\phi}\, dV+\int_{S}\underline{\sigma}\cdot\overrightarrow{n}\cdot\overrightarrow{\phi}\, dS+\int_{V}\overrightarrow{f}\cdot\overrightarrow{\phi}\, dV-\int_{V}\rho\frac{\partial^{2}\overrightarrow{u}}{\partial t^{2}}\cdot\overrightarrow{\phi}\, dV=0.
\end{equation}
We separate the integration over $S$ into integration over $S_{T}$
and $S_{u}$,
\begin{multline}
-\int_{V}\underline{\sigma}:\nabla\overrightarrow{\phi}\, dV+\int_{S_{T}}\underline{\sigma}\cdot\overrightarrow{n}\cdot\overrightarrow{\phi}\, dS+\int_{S_{u}}\underline{\sigma}\cdot\overrightarrow{n}\cdot\overrightarrow{\phi}\, dS+\int_{V}\overrightarrow{f}\cdot\overrightarrow{\phi}\, dV-\int_{V}\rho\frac{\partial^{2}\overrightarrow{u}}{\partial t^{2}}\cdot\overrightarrow{\phi}\, dV=0,
\end{multline}
and recognize that
\begin{gather}
\underline{\sigma}\cdot\overrightarrow{n}=\overrightarrow{T}\text{ on }S_{T}\text{ and}\\
\overrightarrow{\phi}=0\text{ on }S_{u},
\end{gather}
so that the equation reduces to
\begin{equation}
-\int_{V}\underline{\sigma}:\nabla\overrightarrow{\phi}\: dV+\int_{S_{T}}\overrightarrow{T}\cdot\overrightarrow{\phi}\, dS+\int_{V}\overrightarrow{f}\cdot\overrightarrow{\phi}\, dV-\int_{V}\rho\frac{\partial^{2}\overrightarrow{u}}{\partial t^{2}}\cdot\overrightarrow{\phi}\, dV=0.
\end{equation}
We express the trial solution and weighting function as linear combinations
of basis functions,
\begin{gather}
\vec{u}=\sum_{m}\overrightarrow{a^{m}}N^{m},\\
\vec{\phi}=\sum_{n}\overrightarrow{c^{n}}N^{n}.
\end{gather}
Note that because the weighting function is zero on $S_{u}$, the
number of basis functions for $\vec{u}$ is generally greater than
the number of basis functions for $\vec{\phi}$, i.e., $m>n$. Substituting
in the expressions for the trial solution and weighting function yields
\begin{multline}
-\int_{V}\underline{\sigma}:\sum_{n}\overrightarrow{c^{n}}\nabla N_{,}^{n}\, dV+\int_{S_{T}}\vec{T}\cdot\sum_{n}\overrightarrow{c^{n}}N^{n}\, dS+\int_{V}\vec{f}\cdot\sum_{n}\overrightarrow{c^{n}}N^{n}\, dV\\
-\int_{V}\rho\sum_{m}\frac{\partial^{2}\overrightarrow{a^{m}}}{\partial t^{2}}N^{m}\cdot\sum_{n}\overrightarrow{c^{n}}N^{n}\ dV=0.
\end{multline}
 Because the weighting function is arbitrary, this equation must hold
for all $\overrightarrow{c^{n}}$, so that
\begin{equation}
-\int_{V}\underline{\sigma}:\nabla N^{n}\, dV+\int_{S_{T}}\vec{T}N^{n}\, dS+\int_{V}\vec{f}N^{n}\, dV-\int_{V}\rho\sum_{m}\frac{\partial^{2}\overrightarrow{a^{m}}}{\partial t^{2}}N^{m}N^{n}\, dV=\vec{0}.
\end{equation}
We want to solve this equation for the unknown coefficients $\overrightarrow{a^{m}}$
subject to
\begin{gather}
\vec{u}=u^{o}\overrightarrow{}\text{ on }S_{u},\text{ and}\\
\underline{R}(\overrightarrow{u^{+}}-\overrightarrow{u^{-}})=\vec{d}\text{ on }S_{f},
\end{gather}

\section{Solution Method for Quasi-Static Problems}

For brevity we outline the solution method for quasi-static problems
using only index notation. In quasi-static problems we neglect the
inertial terms, so equation \eqref{eq:elasticity:integral:discretized}
reduces to
\begin{equation}
-\int_{V}\sigma_{ij}N_{,j}^{n}\: dV+\int_{S_{T}}T_{i}N^{n}\, dS+\int_{V}f_{i}N^{n}\, dV=\vec{0}.
\end{equation}
As a result, time-dependence only enters through the constitutive
relationships and the loading conditions. We consider the deformation
at time $t+\Delta t$,
\begin{equation}
\label{eq:elasticity:integral:quasistatic}
-\int_{V}\sigma_{ij}(t+\Delta t)N_{,j}^{n}\: dV+\int_{S_{T}}T_{i}(t+\Delta t)N^{n}\, dS+\int_{V}f_{i}(t+\Delta t)N^{n}\, dV=\vec{0}.
\end{equation}
We solve this equation through formulation of a linear algebraic system
of equations ($Au=b$), involving the residual ($r=b-Au$) and Jacobian
($A$). The residual is simply
\begin{equation}
r_{i}^{n}=-\int_{V}\sigma_{ij}(t+\Delta t)N_{,j}^{n}\: dV+\int_{S_{T}}T_{i}(t+\Delta t)N^{n}\, dS+\int_{V}f_{i}(t+\Delta t)N^{n}\, dV.
\end{equation}
We employ numerical quadrature in the finite-element discretization
and replace the integrals with sums over the cells and quadrature
points,
\begin{multline}
r_{i}^{n}=-\sum_{\text{vol cells}}\sum_{\text{quad pts}}\sigma_{ij}(x_{q},t+\Delta t)N_{,j}^{n}(x_{q})\: w_{q}|J_{cell}(x_{q})|+\sum_{\text{vol cells}}\sum_{\text{quad pt}s}f_{i}(x_{q},t+\Delta t)N^{n}(x_{q})\, w_{q}|J_{cell}(x_{q})|\\
+\sum_{\text{tract cells}}\sum_{\text{quad pts}}T_{i}(x_{q},t+\Delta t)N^{n}(x_{q})\, w_{q}|J_{cell}(x_{q})|,
\end{multline}
where $r_{i}^{n}$ is an $nd$ vector ($d$ is the dimension of the
vector space) and $i$ is a vector space component, $x_{q}$ are the
coordinates of the quadrature points, $w_{q}$ are the weights of
the quadrature points, and $|J_{cell}(x_{q})|$ is the determinant
of the Jacobian matrix evaluated at the quadrature points associated
with mapping the reference cell to the actual cell. The quadrature
scheme for the integral over the tractions is one dimension lower
than the one used in integrating the terms for the volume cells.

In order to find the Jacobian of the system, we let
\begin{equation}
\sigma_{ij}(t+\Delta t)=\sigma_{ij}(t)+d\sigma_{ij}(t).
\end{equation}
Isolating the term associated with the increment in stresses yields

\begin{equation}
\int_{V}d\sigma_{ij}(t)N_{j}^{n}\ dV=-\int_{V}\sigma_{ij}(t)N_{,j}^{n}\: dV+\int_{S_{T}}T_{i}(t+\Delta t)N^{n}\, dS+\int_{V}f_{i}(t+\Delta t)N^{n}\, dV
\end{equation}
We associate the term on the left-hand-side with the action of the
system Jacobian on the increment of the displacement field. We approximate
the increment in stresses using linear elasticity and infinitesimal
strains,

\begin{gather}
d\sigma_{ij}(t)=C_{ijkl}(t)d\varepsilon_{kl}(t)\\
d\sigma_{ij}(t)=\frac{1}{2}C_{ijkl}(t)(du_{k.l}(t)+du_{l,k}(t))\\
d\sigma_{ij}(t)=\frac{1}{2}C_{ijkl}(t)(\sum_{m}da_{k,l}^{m}(t)N^{m}+\sum_{m}da_{l,k}^{m}(t)N^{m})
\end{gather}
Now, $d\sigma_{ij}\phi_{i,j}$ is a scalar, so it is symmetric,
\begin{equation}
d\sigma_{ij}\phi_{i,j}=d\sigma_{ji}\phi_{j,i},
\end{equation}
and we know that $d\sigma_{ij}$ is symmetric, so
\begin{equation}
d\sigma_{ij}\phi_{i,j}=d\sigma_{ij}\phi_{j,i},
\end{equation}
which means
\begin{equation}
\phi_{i,j}=\phi_{j,i},
\end{equation}
which we can write as
\begin{equation}
\phi_{i,j}=\frac{1}{2}(\phi_{i,j}+\phi_{j,i}).
\end{equation}
In terms of the basis functions, we have

\begin{equation}
\sum_{n}c_{i}^{n}N_{,j}^{n}=\frac{1}{2}(\sum_{n}c_{i}^{n}N_{,j}^{n}+\sum_{n}c_{j}^{n}N_{,i}^{n}).
\end{equation}
Combining these expressions for the increment in stresses and making
use of the symmetry of the weighting functions, we find the system
Jacobian is

\begin{equation}
A_{ij}^{nm}=\int_{V}\frac{1}{4}C_{ijkl}(N_{,l}^{m}+N_{,k}^{m})(N_{,j}^{n}+N_{,i}^{n})\ dV.
\end{equation}
We employ numerical quadrature in the finite-element discretization
and replace the integral with a sum over the cells and quadrature
points,
\begin{equation}
A_{ij}^{nm}=\sum_{\text{vol cells}}\sum_{\text{quad pts}}\frac{1}{4}C_{ijkl}(N_{,l}^{m}(x_{q})+N_{,k}^{m}(x_{q}))(N_{,j}^{n}(x_{q})+N_{,i}^{n}(x_{q}))w_{q}|J_{cell}(x_{q}).
\end{equation}

\section{Solution Method for Dynamic Problems}

For brevity we outline the solution method for dynamic problems using
only index notation. Time-dependence enters through the constitutive
relationships, loading conditions, and the inertial terms. We consider
the deformation at time $t$,
\begin{equation}
\label{eq:elasticity:integral:dynamic:t}
-\int_{V}\sigma_{ij}(t)N_{,j}^{n}\: dV+\int_{S_{T}}T_{i}(t)N^{n}\, dS+\int_{V}f_{i}(t)N^{n}\, dV-\int_{V}\rho\sum_{m}\ddot{a}_{i}^{m}(t)N^{m}N^{n}\ dV=\vec{0}.
\end{equation}
We solve this equation through formulation of a linear algebraic system
of equations ($Au=b$), involving the residual ($r=b-Au$) and Jacobian
($A$). The residual is simply
\begin{equation}
r_{i}^{n}=-\int_{V}\sigma_{ij}(t)N_{,j}^{n}\: dV+\int_{S_{T}}T_{i}(t)N^{n}\, dS+\int_{V}f_{i}(t)N^{n}\, dV-\int_{V}\rho\sum_{m}\ddot{a}_{i}^{m}(t)N^{m}N^{n}\ dV.
\end{equation}
We employ numerical quadrature in the finite-element discretization
and replace the integrals with sums over the cells and quadrature
points,
\begin{multline}
r_{i}^{n}=-\sum_{\text{vol cells}}\sum_{\text{quad pts}}\sigma_{ij}(x_{q},t)N^{n}(x_{q})\: w_{q}|J_{cell}(x_{q})|+\sum_{\text{vol cells}}\sum_{\text{quad pt}s}f_{i}(x_{q},t)N^{n}(x_{q})\, w_{q}|J_{cell}(x_{q})|\\
+\sum_{\text{tract cells}}\sum_{\text{quad pts}}T_{i}(x_{q},t)N^{n}(x_{q})\, w_{q}|J_{cell}(x_{q})|-\sum_{\text{vol cells}}\sum_{\text{quad pts}}\rho\sum_{m}\ddot{a}_{i}^{m}(t)N^{m}N^{n}\ w_{q|J_{cell}(x_{q})},
\end{multline}
where $x_{q}$ are the coordinates of the quadrature points, $w_{q}$
are the weights of the quadrature points, and $|J_{cell}(x_{q})|$
is the determinant of the Jacobian matrix evaluated at the quadrature
points associated with mapping the reference cell to the actual cell.
The quadrature scheme for the integral over the tractions is one dimension
lower than the one used in integrating the terms for the volume cells.

We find the system Jacobian matrix by making use of the temporal discretization
and isolating the term for the increment in the displacement field
at time $t$. Using the central difference method to approximate the
acceleration (and velocity),
\begin{gather}
\ddot{u}_{i}(t)=\frac{1}{\Delta t^{2}}\left(u_{i}(t+\Delta t)-2u_{i}(t)+u_{i}(t-\Delta t)\right)\\
\dot{u}_{i}(t)=\frac{1}{2\Delta t}\left(u_{i}(t+\Delta t)-u_{i}(t-\Delta t)\right)
\end{gather}
and writing the displacement at time $t+\Delta t$ in terms of the
displacement at $t$ (for consistency with the displacement increment
quasi-static formulation),
\begin{gather}
u_{i}(t+\Delta t)=u_{i}(t)+du_{i}(t),\\
\ddot{u}_{i}(t)=\frac{1}{\Delta t^{2}}\left(du_{i}(t)-u_{i}(t)+u_{i}(t-\Delta t)\right),\\
\dot{u}_{i}(t)=\frac{1}{2\Delta t}\left(du_{i}(t)+u_{i}(t)-u_{i}(t-\Delta t)\right).
\end{gather}
Substituting into equation \eqref{eq:elasticity:integral:dynamic:t}
yields
\begin{multline}
\frac{1}{\Delta t^{2}}\int_{V}\rho\sum_{m}da_{i}^{m}(t)N^{m}N^{n}\ dV=-\int_{V}\sigma_{ij}N_{,j}^{n}\: dV+\int_{S_{T}}T_{i}N^{n}\, dS+\int_{V}f_{i}N^{n}\, dV\\
-\frac{1}{\Delta t^{2}}\int_{V}\rho\sum_{m}(a_{i}^{m}(t)-a_{i}^{m}(t-\Delta t))N^{m}N^{n}\ dV.
\end{multline}
Thus, the Jacobian for the system is
\begin{equation}
A_{ij}^{nm}=\delta_{ij}\frac{1}{\Delta t^{2}}\int_{V}\rho N^{m}N^{n}\ dV,
\end{equation}
and using numerical quadrature in the finite-element discretization
to replace the integrals with sums over the cells and quadrature points,

\begin{equation}
A_{ij}^{nm}=\delta_{ij}\frac{1}{\Delta t^{2}}\sum_{\text{vol cells}}\sum_{\text{quad pts}}\rho(x_{q})N^{m}(x_{q})N^{n}(x_{q}),
\end{equation}
where $A_{ij}^{mn}$ is a $nd$ by $md$ matrix ($d$ is the dimension
of the vector space), $m$ and $n$ refer to the basis functions and
$i$ and $j$ are vector space components. We consider the contributions
associated with the fault in section \vref{sec:fault} and with absorbing
boundaries is section \vref{sec:absorbing:boundaries}.

\section{Small (Finite) Strain Formulation}
\label{sec:small:strain:formulation}

In some crustal deformation problems sufficient deformation may occur
that the assumptions associated with infinitesimal strains no longer
hold. This is often the case for problems when one wants to include
the effects of gravitational body forces on vertical deformation.
In such cases we want to account for both rigid body motion and small
strains. We use a total Lagrangian formulation (quantities are associated
with the undeformed configuration) based on the one presented by Bathe
\cite{Bathe:1995}.

Starting from the governing equation, written for the deformed configuration
(denoted by the subscript $t$), we have
\begin{equation}
\label{eq:governing:equation:deformed}
\int(\nabla_{t}\cdot\underline{\sigma})\cdot\vec{\phi}\: dV_{t}+\int_{Vt}\overrightarrow{f_{t}}\cdot\overrightarrow{\phi}\, dV_{t}-\int_{Vt}\rho_{t}\frac{\partial^{2}\overrightarrow{u}}{\partial t^{2}}\cdot\overrightarrow{\phi}\, dV_{t}=0.
\end{equation}
For the total Lagrangian formulation we want to transform these integrals
over the deformed configuration to integrals over the undeformed configuration.
We require that the deformed and undeformed configurations use the
same coordinate system (origin and orientation). Conservation of mass
requires that $\rho\, dV_{t}=\rho_{0}\, dV_{0}$. We define the body
force as a force per unit volume that does not depend on the configuration,
which leads to $\vec{f}_{t}\, dV_{t}=\vec{f}_{0}\, dV_{0}$.

The Green-Lagrange strain provides a measure of the strain relative
to the original, undeformed configuration.
\begin{gather}
\underline{\epsilon}=\frac{1}{2}(\nabla u_{i,j}+(\nabla u)^{T}+u_{k,i}u_{k,j}),\text{ or}\\
\underline{\epsilon}=\underline{X}_{0}^{T}\underline{\, X}_{0}-\underline{I},\text{ where}\\
\underline{X_{0}}=\frac{\partial}{\partial x_{j}}(\vec{x}(0)+\vec{u}(t)),
\end{gather}
and $\underline{X}$ is the deformation gradient tensor. The second
Piola-Kirchhoff stress tensor, $\underline{S}$, is the work conjugate
of the Green-Lagrange strain tensor. As a result, they are related
through the elasticity constants,

\begin{equation}
\underline{S}=\underline{C\,}\underline{\varepsilon},
\end{equation}
in the same manner as the Cauchy stress is related to the infinitesimal
strain. The Cauchy stress is related to the second Piola-Kirchoff
stress through the deformation gradient tensor,
\begin{equation}
\underline{\sigma}=\frac{1}{|\underline{X}_{0}|}\underline{\, X}_{0}\,\underline{S\,}\underline{X}_{0}^{T},
\end{equation}
 where $\mathit{det}(\underline{X}_{0})=|\underline{X}_{0}|$. Additionally,
the first Piola-Kirhoff stress is define to be
\begin{equation}
\underline{P}=\underline{S\,}\underline{X}_{0}^{T}.
\end{equation}

Applying the divergence theorem, making use of the fact that $dV_{t}=|\underline{X}_{0}|\, dV_{0}$,
and recognizing that the gradient in the deformed configuration is
related to the gradient in the undeformed configuration through the
deformation gradient tensor, we can show that
\begin{equation}
\int_{V_{t}}\nabla_{t}\cdot\underline{\sigma}\cdot\vec{\phi}\: dV_{t}=-\int_{V_{0}}\underline{P}:\nabla\overrightarrow{\phi}\, dV_{0}+\int_{S_{0}}\overrightarrow{T_{0}}\cdot\overrightarrow{\phi}\, dS_{0},
\end{equation}
where we assume the the tractions on the boundary do not depend on
the configuration. That is, the normal and share traction components
are defined in terms of the undeformed configuration. Incorporating
the other relationships between the underformed and deformed configurations
allows us to rewrite Equation \vref{eq:governing:equation:deformed}
in the undeformed configuration,
\begin{equation}
-\int_{V_{0}}\underline{P}:\nabla\overrightarrow{\phi}\, dV_{0}+\int_{S_{0}}\overrightarrow{T_{0}}\cdot\overrightarrow{\phi}\, dS_{0}+\int_{V_{0}}\overrightarrow{f_{0}}\cdot\overrightarrow{\phi}\, dV_{0}-\int_{V_{0}}\rho_{0}\frac{\partial^{2}\overrightarrow{u}}{\partial t^{2}}\cdot\overrightarrow{\phi}\, dV_{0}=0.
\end{equation}

\subsection{Quasi-static Problems}

The system Jacobian for quasi-static problems includes terms associated
with elasticity. For the small strain formulation, we write the elasticity
term at time $t+\Delta t$ and consider the first terms of the Taylor
series expansion,
\begin{equation}
\int_{v}S_{ij}(t+\Delta t)\delta\varepsilon_{ij}(t+\Delta t)\: dV=\int_{V}(S_{ij}(t)\delta\varepsilon_{ij}(t)+dS_{ij}(t)\delta\varepsilon_{ij}(t)+S_{ij}(t)d\delta\varepsilon_{ij}(t))\: dV.
\end{equation}
We approximate the increment in the stress tensor using the elastic
constants,
\begin{equation}
dS_{ij}=C_{ijkl}d\varepsilon_{kl},
\end{equation}
and the increment in the ``virtual'' strain via
\begin{equation}
d\delta\varepsilon_{ij}=\frac{1}{2}(du_{k,i}\delta u_{k,j}+du_{k,j}\delta u_{k,i}).
\end{equation}
We associate the system Jacobian with the terms involving the increment
in displacements. After substituting in the expressions for the increment
in the stresses and the increment in the ``virtual'' strains, we
have
\begin{equation}
A_{ij}^{nm}=\int_{V}\frac{1}{4}C_{ijkl}(N_{,k}^{m}+(\sum_{r}a_{p}^{r}N_{,l}^{r})N_{,k}^{m})(N_{,i}^{n}+(\sum_{r}a_{p}^{r}N_{,j}^{r})N_{,i}^{n})+\frac{1}{2}S_{kl}N_{,l}^{m}N_{,l}^{n}\delta_{ij}\: dV.
\end{equation}
The small strain formulation produces additional terms associated
with the elastic constants and a new term associated with the stress
tensor.

\subsection{Dynamic Problems}

The system Jacobian matrix in dynamic problems does not include any
terms associated with elasticity, so the system Jacobian matrix in
the small strain formulation matches the one used in the infinitesimal
strain formulation.


\documentclass[a4paper]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amssymb}

\setlength{\parindent}{0em}

\title{\textbf{COMP90056 Assignment A}}
\author{Tingsheng (Tinson) Lai (731319)}
\date{\today}

\begin{document}
    \maketitle
    \section{Part 1}
    Let $S$ denotes the union, i.e. $$S = S_1 \cup S_2$$
    From the inequality, we can claim that the inequality inherently holds for $\forall x \in S \backslash S_2$ and $\forall x \in S \backslash S_1$. So the only task is to prove that the inequality holds for the third circumstance where $$\forall x \in S_1 \cap S_2$$
    Use $\hat{S}$ as the intersection $$\hat{S} = S_1 \cap S_2$$
    First prove the $RHS$ where $\forall x \in \hat{Z}$ $\hat{c} \left( x \right) \leq f_{x}$. As $x \in S_1 \wedge x \in S_2$, we know that $\hat{c}_1 \left( x \right) \leq f_{1,x}$ and $\hat{c}_2 \left( x \right) \leq f_{2,x}$. So $$\hat{c} \left( x \right) = \hat{c}_1 \left( x \right) + \hat{c}_2 \left( x \right) \leq f_{1,x} + f_{2,x} = f_{x}$$
    Even if the subtraction to shrink the size happens, the $RHS$ still holds as $\forall i \in \mathbb{U}$, $f_{i}$ will not be changed throughout the whole process. For the $LHS$, using the same trick we can get $$f_{1,x} - \frac{m_1 - \tau_1}{k_1} + f_{2,x} - \frac{m_2 - \tau_2}{k_2} = f_x - \frac{m - \tau}{x}$$ So $$\hat{c} \left( x \right) \geq f_x - \frac{m - r}{k} = LHS$$ Subtracting $a$ from each $x \in S$ will decrease the value of $\tau$ by at least $k \cdot a$. Denoting $\Delta \hat{c}_x$ = -a as the change in the counter and $\Delta \tau$ as the change in $\tau \leq -a \cdot k$. It is clear that $f_x$ and $m$ and $k$ are fixed, so $\Delta LHS \leq -a$. So the decrease in the $LHS$ are even greater than $\hat{c} \left( x \right)$, so the inequality still holds.
\end{document}


\section*{Ex.34.5-6}
\subsection*{Hamiltonian path NP complete}

To show that HAM--PATH is NP complete we show
\begin{enumerate}[]
	\item HAM--PATH is NP
	\item HAM--CYCLE $\leq_P$ HAM--PATH
\end{enumerate}
That HAM--PATH is NP, is shown in EX.34.2-6.

To see that HAM--CYCLE $\leq_P$ HAM--PATH:

Given a graph $G$ where there is an instance of HAM--CYCLE, pick a node $u$ and create a new graph $G'$ where $u$ is replaced with two new nodes $u'$ and $u''$. All the edges that goes in to $u$ are also going into $u''$ and all of the outgoing edges from $u$ are also outgoing edges from $u'$. No edges are going from $u'$ to $u''$.
\\
Then it holds that
\\
$G$ has HAM--CYCLE $\Leftrightarrow$ $G'$ has HAM--PATH

Before we prove it, note that a HAM--PATH must start in $u'$ and end in $u''$

We show $\Rightarrow$:

Assume $G$ has a HAM-CYCLE, then the same nodes creates a HAM--CYCLE in $G'$ if we split $u$ into $u'$ and $u''$.

We show $\Leftarrow$:

Assume $G'$ has HAM-PATH, then combining $u'$ and $u''$ into $u$ will create a HAM-CYCLE in $G$.

This show item 2. Hence we have shown that HAM-PATH is NP complete.


\paragraph{Def} $x_i \in [l_i, u_i]$, $a_i^\le \le x_i \le a_i^\ge$, $a_i^\cdot = \sum_j w_j x_j + v$
\paragraph{Complexity} Affine: $\mathcal{O}(\left(\text{\#layers} \right) \left(\text{max \#neurons}\right)^2)$, ReLU: $\mathcal{O}(1)$
\paragraph{ReLU}
\begin{tabular}[t]{c|c|c|c|c}
    Condition & $a_j^\le$ & $a_j^\ge$ & $l_j$ & $u_j$ \\\midrule
    $u_i \le 0$ & 0 & 0 & 0 & 0 \\
    $l_i \ge 0$ & $x_i$ & $x_i$ & $l_i$ & $u_i$ \\
    $l_i < 0 < u_i$ & $\lambda x_i$ & $u_i \dfrac{x_i-l_i}{u_i-l_i}$ & $\lambda l_i$ & $u_i$
\end{tabular}
For any $\lambda \in [0,1]$
\paragraph{Area heuristic} Choose $\lambda=0$ if $u\le-l$, else $\lambda=1$

\paragraph{Backsub} After affine layer, repeatedly backsubstitute (for $l$, choose $a^\le$ for $w \ge 0$, $a^\ge$ otherwise)
\paragraph{Verification} Backsubstitute $x_\text{label} - x_i$ to find lower bound, verifies iff $> 0$


In Chapter~\ref{chapter:bdp}, we assumed that an event organizer is only allowed to inspect a group of columns (as a batch) by polling all invitees at once.
In this chapter, we relax this restriction, and assume that the organizer can inspect each entry of a random matrix at unit cost (by querying a certain invitee about a certain date/time option).
Consequently, \Time and \Inconvenience are always equal in this setting, and the goal is to find an optimal inspection sequence which is a permutation of entries of a given random matrix.
As in \BDP, we would like to optimize the expected cost, which is the expected number of inspections until a feasible column is found or all columns are deemed infeasible -- we call this problem the Probabilistic Matrix Inspection Problem (\PMIP).

The main difference between the Batched Doodle Problem (\BDP) and the Probabilistic Matrix Inspection Problem (\PMIP) lies in the solution domain (a unit operation on a group of columns versus entries) and the cost model (a function of Time and Inconvenience versus the number of inspections).
The Batched Doodle generalizes Doodle by allowing columns-by-columns inspections, and we further generalize it by allowing entry-by-entry inspections.

%TODO: To re-write intro?

\section{Notation and Definitions} \label{PMIP:sec:notation}

  We use the same definition of feasibility as in previous chapter, which is copied below.

 \begin{definition}[Feasibility]
 Let $A$ be a matrix whose entries are from $\{0,1\}$, and refer to the entry of $A$ at row $r$ and column $c$ as $a_{r,c}$.
 We say that a column $c$ of $A$ is {\em feasible} if it consists only of 1's (otherwise it is {\em infeasible}).
 We say that $A$ is {\em feasible} if it contains at least one feasible column (otherwise it is {\em infeasible}).
 \end{definition}

 In the Probabilistic Matrix Inspection Problem, we do not know of the values of the entries of $A$, as they are Bernoulli random variables, but we know of probability distribution of each entry.
 An input to the problem is this probability distribution.
 \begin{definition}[Input instance]
 An input instance of the Probabilistic Matrix Inspection problem is a pair of matrices $(A, P_A)$ of size $n$ by $m$
 where $A$ is a matrix of Bernoulli random variables
 and $P_A$ is the probability matrix associated with it.
 We denote an entry of $A$ as $a_{r,c}$ and of $P_A$ as $p_{r,c}$.
 Each entry $a_{r,c}$ of $A$ is a Bernoulli random variable, and $p_{r,c}$ is the probability of success for $a_{r,c}$ (i.e., $p_{r,c} = \mathbf{P}[a_{r,c} = 1]$).
 We define $s_c = \prod_{r=1}^{n} p_{r,c}$ to denote the probability that column $c$ is feasible (probability of success for column $c$).
 \end{definition}
 Throughout this work we will assume that the set of random variables $\{a_{r,c}\}$ are mutually independent. This assumption is crucial to our technical results because it allows to compute (in polynomial time) the probability of a specific realization of $A$ conditioning on the event in which some entries of $A$ have already been realized.
 Without this assumption, it is unclear how one can compute such probabilities without having an access to the joint probability distribution over all realizations of $A$ (whose size is exponential in the size of $A$).

 We define an ``inspection'' as an operation that can be performed on $A$.
 One can inspect an arbitrary entry $a_{r,c}$ of $A$ at unit cost, so as to know of the realization of the random variable. In group scheduling, an inspection corresponds to querying an agent about her availability for a certain outcome.
 The objective of the problem is to determine whether $A$ is feasible or not, with minimum (expected) number of inspections possible. The expectation is with respect to the probability distribution specified by $P_A$.

 Because we are interested in determining feasibility of $A$ with minimum number of inspections, there are certain ``unnecessary inspections'' that an optimal strategy must avoid.
 For instance, if a certain entry $a_{r,c}$ is found to be unsuccessful (i.e., $a_{r,c} = 0$ is realized), then there is no need to inspect any other entry from the same column because the column is already known to be infeasible. Similarly, if a certain column is found to be feasible (which implies $A$ is feasible) or if all columns are found to be infeasible (which implies $A$ is infeasible), then there is no need to inspect any other entries of the matrix. Lastly, if $p_{r,c} = 0$ or $p_{r,c} = 1$, then there is no need to inspect the entry $a_{r,c}$ because we already know its realization with probability $1$.
 Therefore, without loss of generality, we will assume that $p_{r,c} \in (0,1)$ (i.e., $p_{r,c}\neq 0,1$) in this work.

 Let us define what constitutes a solution to the problem.
 \begin{definition}[Inspection policy]
 	Given an input instance $(A,P_{A})$, a solution is any permutation of the entries of $A$, and we call it an ``inspection policy'' (or simply, a ``policy'').
 \end{definition}
 The interpretation of a permutation is as follows. The entries of $A$ will be inspected in order specified by the permutation. After each inspection, if $A$ is found to be feasible or infeasible, the inspection process ends. Otherwise, it continues inspecting the entries as specified, but it will not make any unnecessary inspections as mentioned earlier.

 If $\pi$ is a permutation of the entries of $A$, we write $C(\pi)$ to denote the number of inspections performed by $\pi$. $C(\pi)$ is a random variable whose probability distribution is determined by $P_A$. We are interested in finding an optimal policy which minimizes the expected number of inspections, $\mathbf{E}[C(\pi)]$.
 Note that there are $(nm)!$ permutations of the entries of $A$, and therefore exhaustive search for an optimal permutation will not produce an efficient algorithm.

 \subsection{Example} \label{sec:example}

 Consider a 2-by-2 matrix $A$ of Bernoulli random variables whose probability of success is given by $P_A$ as follows. In group scheduling, this corresponds to two agents and a set of two date/time options being considered.
 \begin{equation*}
 A =
 	\begin{bmatrix}
 		a_{1,1}  & a_{1, 2} \\
 		a_{2,1}  & a_{2, 2}
 	\end{bmatrix},
 P_A =
 	\begin{bmatrix}
 		0.6  & 0.7  \\
 		0.9  & 0.8
 	\end{bmatrix}
 \end{equation*}
 Let us consider an inspection policy $\pi$ which inspects the entries of $A$ column-by-column while inspecting them from top to bottom within a column:
 \begin{equation*}
 	\pi =
 	\begin{pmatrix}
 	1 & 2 & 3 & 4  \\
 	a_{1,1} & a_{2,1} & a_{1,2} & a_{2,2}
 	\end{pmatrix}.
 \end{equation*}
 Suppose that the realization of $A$ happens to be the identity matrix of size $2$ (i.e., $a_{1,1} = a_{2,2} = 1$ and $a_{2,1} = a_{1,2} = 0$). If we use $\pi$, it will first inspect $a_{1,1}$ and learn its realization. Since $a_{1,1} = 1$, it will inspect $a_{2,1}$ next only to find that column $1$ is infeasible after all. It will then inspect $a_{1,2}$ and learn that column $2$ is also infeasible, which implies that $A$ is infeasible. At this point, the inspection process terminates without inspecting $a_{2,2}$.
 This specific realization of $A$ happens with probability $p_{1,1}(1 - p_{2,1})(1-p_{1,2})p_{2,2}$, and yields $C(\pi) = 3$ because 3 inspections would occur.
 If the realization of $A$ happens to be the null matrix (i.e., all entries are $0$'s), then $\pi$ would only inspect $a_{1,1}$ and $a_{1,2}$ but skip $a_{2,1}$ and $a_{2,2}$.  In this manner one can consider all $2^{2\cdot 2} = 16$ possible realizations of $A$, and compute $\mathbf{E}[C(\pi)]$ in this example.

 Another way to compute $\mathbf{E}[C(\pi)]$ is by de-coupling $C(\pi)$ into two random variables $N(\pi, c)$ with $c\in\{1,2\}$ where $N(\pi,c)$ denotes the number of inspections (on column $c$) performed by $\pi$ conditioning on the event that (at least one element of) column $c$ is inspected.
 We can efficiently compute these: $\mathbf{E}[N(\pi, c)] = 1 \cdot \mathbf{P}[a_{1,c} = 0] + 2 \cdot \mathbf{P}[a_{1,c} = 1]$ for $c\in \{1, 2\}$.
 To express $\mathbf{E}[C(\pi)]$ in $N(\pi,c)$'s, we need to take conditional probability into account, as column 2 is inspected only if column 1 is infeasible:
 $\mathbf{E}[C(\pi)] = \mathbf{E}[N(\pi,1)] + \mathbf{E}[N(\pi,2)] (1-s_1) = 2.382$. Recall that $s_c$ is the probability of success for column $c$.

\section{Technical Results and Algorithm} \label{PMIP:sec:results}

 We first consider two special cases (1-row or 1-column matrices) of the Probabilistic Matrix Inspection problem, which admit intuitive, greedy algorithms. We then discuss a couple of interesting properties of an optimal inspection policy, which leads to our main result and algorithm.

 \subsection{1-Row Matrix and 1-Column Matrix}
 Let us first consider the case where an input matrix $A$ has only one row (i.e., $n = 1$).
 In this case it is natural to inspect entries with largest probability first because we can stop as soon as we find an entry whose value is $1$ -- which makes its column and $A$ feasible. This intuition is exactly what an optimal policy should do in the single row case.

 \begin{lemma}[1-Row Matrix]\label{lemma:single_row_opt}
 When $n = 1$, an inspection policy $\pi$ is optimal if and only if it inspects the entries in non-increasing order of their associated probabilities.
 \end{lemma}
 \begin{proof}
 	Without loss of generality let us assume that a policy $\pi$ inspects the entries in increasing order of their column index; that is, $\pi(i) = a_{1,i}$.
 	Recall that $C(\pi)$ is a random variable that denotes the number of inspections $\pi$ incurs.
 	We can express the expectation of $C(\pi)$ in terms of $p_{1,c}$'s as follows:
 	\small
 	\begin{equation} \label{eqn:exp_cost_pi_1row}
 		\mathbf{E}\left[C(\pi)\right] =
 		m \left(\prod_{k=1}^{m-1}(1 - p_{1,k})\right) +
 		\sum_{j=1}^{m-1} j \left(p_j \prod_{k=1}^{j-1} (1-p_{1,k}) \right).
 	\end{equation}
 	\normalsize

 	Suppose that there exists some $c^*$ such that $p_{1,c^*} < p_{1,c^*+1}$ (if no such $c^*$ exists, then $\pi$ is an inspection policy that inspects the entries in non-increasing order of probabilities).
 	Let $\pi'$ be the same policy as $\pi$ except we swap the order of $a_{1,c^*}$ and $a_{1,c^*+1}$.
 	That is, $\pi'$ is defined as follows.
 	\begin{equation*}
 		\pi'(j) =
 		\begin{cases}
 			\pi'(j) = \pi(c^*+1)&  \mbox{if~} j = c^* \\
 			\pi'(j) = \pi(c^*)  &  \mbox{if~} j = c^*+1 \\
 			\pi'(j) = \pi(j)  &  \mbox{if~} j \neq c^* \land j \neq c^*+1
 		\end{cases}
 	\end{equation*}
 	After expressing $\mathbf{E}[C(\pi)]$ and $\mathbf{E}[C(\pi')]$ as in Equation~\ref{eqn:exp_cost_pi_1row}, one can re-arrange the terms to obtain the following:
 	\begin{equation} \label{eqn:proof_pi_1row}
 	\mathbf{E}\left[C(\pi)\right] - \mathbf{E}\left[C(\pi')\right] =
 	\left(\prod_{j=1}^{c^*-1} (1-p_{1,j})\right) (p_{1,c^*+1} - p_{1,c^*}).
 	\end{equation}
 	This quantity is positive if $p_{1,c^*+1} > p_{1,c^*}$ (recall that $p_{1,j} \in (0,1)$ for all $j$ as mentioned in Section~\ref{PMIP:sec:notation}).

 	This proves the lemma because any policy that inspects an entry with smaller probability before another entry with higher probability is suboptimal, and therefore an optimal policy must inspect entries in non-increasing order of their associated probabilities.
 \end{proof}
 Although the proof of Lemma~\ref{lemma:single_row_opt} is simple, it confirms correctness of our intuition. Equation~\ref{eqn:proof_pi_1row} illustrates this intuition; conditioning on the event that the first $c^*-1$ inspections fail (whose probability is the product term in Equation~\ref{eqn:proof_pi_1row}), the difference $\mathbf{E}[C(\pi)] - \mathbf{E}[C(\pi')]$ depends on the difference in the probabilities of success between the next-entry-to-be-inspected by $\pi$ and $\pi'$.

 We can also consider the case where an input matrix $A$ has only one column.
 Intuitively, if we wish to minimize the expected number of inspections, we must inspect entries with smallest probability first because we can stop as soon as we determine that $A$ is infeasible.
 Lemma~\ref{lemma:single_column_opt} formally states this intuition about optimal policy, and we omit a proof of it as it can be easily done by following the proof of Lemma~\ref{lemma:single_row_opt}.
 \begin{lemma}[1-Column Matrix] \label{lemma:single_column_opt}
 When $m = 1$, an inspection policy $\pi$ is optimal if and only if it inspects the entries in non-decreasing order of their associated probabilities.
 \end{lemma}

 \subsection{Inspection of Entire Column}
 Another interesting property of an optimal inspection policy is that once it inspects the first entry of a column, then it must commit to it and continue inspecting the remaining entries of the column until feasibility of the column is determined. Otherwise, if the policy switches to another column too soon, then it is not optimal.
 \begin{theorem}[Optimality of inspecting entire column] \label{theorem:col_by_col_opt}
 Consider any inspection policy $\pi$.
 Without loss of generality, let us assume that for each column $c$, $\pi$ inspects $a_{n,c}$ the last among $n$ entries of the column.
 Let $b_c$ be the index of $\pi$ such that $\pi(b_c) = a_{n,c}$.
 Without loss of generality, assume $b_1 < b_2 < \cdots < b_m$ (we can do this by re-labeling the columns of $A$).
 If there is some column $c^*$ such that $b_{c^*} > n\cdot c^*$, then $\pi$ is not optimal.
 \end{theorem}
 \begin{proof}
 First, note that $b_c \geq n\cdot c$ for all $c$ because we assumed $b_1 < b_2 < \cdots < b_m$, and therefore the entries of previous columns must appear before the last entry of each column.

 Let $\pi$ be an inspection policy being considered in the theorem for which there exists some $c$ with $b_{c} > n \cdot c$.
 Let us construct a different inspection policy $\pi'$.
 First, $\pi'$ inspects all entries of column $1$ in the same order $\pi$ does.
 Then, $\pi'$ inspects all entries of column $2$ in the same order $\pi$ does, and so on.
 In particular, $\pi'$ inspects all entries of a column before inspecting another column, while preserving the original ordering of the entries within each column that is given by $\pi$.
 We will show that $\mathbf{E}[C(\pi')] < \mathbf{E}[C(\pi)]$.

 Let us define a set of new random variables which can be used to express $C(\cdot)$, as we did in Section~\ref{sec:example} when analyzing an example.
 Recall that $s_c = \prod_{r=1}^{n} a_{r,c}$ is the probability of success for column $c$.
 Let $N(\pi, c)$ ($N(\pi', c)$, respectively) be a random variable that denotes the number of entries of column $c$ that is inspected by $\pi$ (by $\pi'$, respectively), conditioning on the event that column $c$ is inspected (i.e., when the previous $c-1$ columns are infeasible).
 We can then express $\mathbf{E}[C(\pi)]$ and $\mathbf{E}[C(\pi')]$ as follows:
 \begin{equation} \label{eqn:exp_c_pi_decoupled}
 	\mathbf{E}[C(\pi)] = \sum_{c=1}^{m} \mathbf{E}[N(\pi, c)]\left( \prod_{k=1}^{c-1} (1 - s_c) \right)
 \end{equation}
 and
 \begin{equation} \label{eqn:exp_c_pi2_decoupled}
 	\mathbf{E}[C(\pi')] = \sum_{c=1}^{m} \mathbf{E}[N(\pi', c)]\left( \prod_{k=1}^{c-1} (1 - s_c) \right).
 \end{equation}

 To prove the theorem we will first show that for any realization of $A$, $N(\pi, c) \geq N(\pi', c)$ holds for all $c$; this immediately implies $\mathbf{E}[C(\pi)] \geq \mathbf{E}[C(\pi')]$.
 We will then show that there exists at least one realization of $A$ such that for some column $c'$ the strict inequality $N(\pi, c') > N(\pi', c')$ holds. These two statements together imply that $\mathbf{E}[C(\pi)] > \mathbf{E}[C(\pi')]$.

 Consider any realization of $A$ with the condition that the first $m-1$ columns are infeasible (recall that $m$ is the number of columns of $A$).
 Then $N(\pi, c) = N(\pi', c)$ for all $c$ regardless of feasibility of column $m$.
 To see why, both $\pi$ and $\pi'$ would inspect the same set of entries in each of the first $m-1$ columns in the same order until the column is determined to be infeasible, and therefore $N(\pi, c) = N(\pi', c)$ if $c<m$.
 If column $m$ is feasible, then both $\pi$ and $\pi'$ would inspect all $n$ entries of it, and thus we have $N(\pi, m) = N(\pi', m) = n$. Otherwise, if column $m$ is also infeasible (in which case $A$ is infeasible), then $\pi$ and $\pi'$ would inspect the same set of entries of column $m$ in the same order until the first infeasible entry of the column is found. Therefore if the first $m-1$ columns are infeasible we have $N(\pi, c) \geq N(\pi', c)$ for all $c$.

 Now consider any realization of $A$ with the condition that at least one of the first $m-1$ columns is feasible. Let $c'$ be the smallest index of feasible columns of $A$.
 Because the columns from $1$ to $c'-1$ are infeasible, $N(\pi, c) = N(\pi', c)$ for all $c < c'$ for the same reason we stated earlier for the other case.
 Since $c'$ is feasible, $N(\pi, c') = N(\pi', c') = n$ as both policies would inspect all $n$ entries of $c'$. By our construction of $\pi'$ it is clear that $N(\pi', c) = 0$ for all $c > c'$; therefore we have $N(\pi, c) \geq N(\pi', c)$ for all $c>c'$. In summary $N(\pi, c) \geq N(\pi', c)$ holds for all $c$ in this case as well.

 So far we proved the first claim we stated earlier: for all realizations of $A$, we have $N(\pi, c) \geq N(\pi', c)$ for all $c$.
 Let us now prove the second claim. Let $c^*$ be the smallest index $c$ of columns such that $b_c > nc$ (note that $c^* < m$ because $b_m = nm$ by definition).
 Consider any realization of $A$ with the condition that the first $c^*-1$ columns are infeasible and column $c^*$ is feasible (feasibility of other columns do not matter).
 Using the same arguments we used earlier, we can show that $N(\pi, c) = N(\pi', c)$ for all $c < c^*$, that $N(\pi, c^*) = N(\pi', c^*) = n$, and that $N(\pi', c) = 0$ for all $c> c^*$.
 However, because $b_{c^*} > n \cdot c^*$, there is at least one entry $a_{r',c'}$ with $c' > c^*$ which  appears before $b_{n, c^*}$ in $\pi$ (otherwise, if no such entry exists, then $b_{c^*}$ would be equal to $n \cdot c^*$). This implies that there exists some $c'$ with $c' > c^*$ such that $N(\pi, c') > 0$.
 This proves the second claim that for some realization of $A$, there is some column $c'$ for which $N(\pi, c') >  N(\pi', c')$, and together with the first claim we proved earlier, this implies that $\mathbf{E}[C(\pi)] > \mathbf{E}[C(\pi')]$.

 This proves the theorem: Any policy that does not inspect all entries of a column consecutively is suboptimal.
 \end{proof}
 By Theorem~\ref{theorem:col_by_col_opt}, when seeking an optimal policy, it is sufficient to consider the set of policies that inspect an entire column before committing to another column. Lemma~\ref{lemma:single_column_opt} hints that one should inspect the entries of each column in increasing order of probabilities, and this is what we prove next.

 \subsection{Optimal Ordering within Column}

 Lemma~\ref{lemma:single_column_opt} states that
 an optimal policy must inspect the entries in increasing order of their probability of success, if $A$ is a 1-column matrix.
 This argument can be generalized to the case where there is more than one column: If an optimal policy is to inspect an entry of some column $c$, it must inspect the entry with smallest probability of success first.
 \begin{theorem}[Optimal ordering within column] \label{theorem:within_column_opt}
 	Consider any inspection policy $\pi$.
 	If there exist two entries $a_{r_1,c}$ and $a_{r_2,c}$ from the same column such that $a_{r_1,c}$ appears before $a_{r_2,c}$ in $\pi$ and $p_{r_1,c} > p_{r_2,c}$, then $\pi$ is not optimal.
 	In other words, when restricted to each column, an optimal policy must inspect the entries of the column in non-decreasing order of probabilities.
 \end{theorem}
 \begin{proof}
 	Let $\pi$ be an inspection policy being considered in the theorem.
 	Because of Theorem~\ref{theorem:col_by_col_opt} we can assume, without loss of generality, that $\pi$ inspects all entries of column 1, followed by column 2, and so on.
 	Further let us assume that $\pi$ inspects the entries of each column in increasing order of their row index (we can do so by re-labeling the indices of entries). Precisely, $\pi(r + n (c-1)) = a_{r,c}$ defines $\pi$. Let $p_{r,c^*}$ and $p_{r+1,c^*}$ be the entries with $p_{r,c^*} > p_{r+1, c^*}$.
 	Let us consider a different inspection policy $\pi'$ that is the same as $\pi$ except that $\pi'$ inspects $p_{r+1,c^*}$ before $p_{r,c^*}$, by swapping the ordering of them.
 	\begin{equation*}
 		\pi'(j) =
 		\begin{cases}
 			\pi'(j) = a_{r+1,c^*}  &  \mbox{if~} \pi(j) = a_{r,c^*} \\
 			\pi'(j) = a_{r,c^*}    &  \mbox{if~} \pi(j) = a_{r+1,c^*} \\
 			\pi'(j) = \pi(j)     &  \mbox{otherwise}
 		\end{cases}
 	\end{equation*}

 	We claim that $\mathbf{E}[C(\pi')] < \mathbf{E}[C(\pi)]$, which implies that $\pi$ is not optimal.

 	Let us define new random variables $N(\pi, c)$ and $N(\pi', c)$ as we did in our proof of Theorem~\ref{theorem:col_by_col_opt} (i.e., the number of inspections performed by the respective policy on column $c$, conditioning on the event that the column is inspected).
 	Then we can express $\mathbf{E}[C(\pi)]$ and $\mathbf{E}[C(\pi')]$ in terms of the new random variables and $s_c$'s as we did in Equations~\ref{eqn:exp_c_pi_decoupled} and \ref{eqn:exp_c_pi2_decoupled}.

 	Observe that $N(\pi, c) = N(\pi', c)$ for any realization of $A$ if $c \neq c^*$.
 	To see this, first note that column $c$ would not be inspected by $\pi$ or by $\pi'$ if any of the previous columns (that is, columns $1$ through $c-1$) is found to be feasible, in which case $N(\pi, c) = N(\pi', c) = 0$. Otherwise, if column $c$ is inspected, both policies would inspect the entries of $c$ in the very same order, so $N(\pi, c) = N(\pi', c)$ must hold. Therefore we conclude that $\mathbf{E}[N(\pi, c)] = \mathbf{E}[N(\pi', c)]$ when $c \neq c^*$.

 	We will now show that $\mathbf{E}[N(\pi, c^*)] > \mathbf{E}[N(\pi', c^*)]$ holds.
 	This immediately implies $\mathbf{E}[C(\pi)] > \mathbf{E}[C(\pi')]$ due to Equations~\ref{eqn:exp_c_pi_decoupled} and \ref{eqn:exp_c_pi2_decoupled}.
 	Let us express $\mathbf{E}[N(\pi, c^*)]$ in terms of $p_{r,c^*}$'s.
 	\begin{equation*}
 		\mathbf{E}[N(\pi, c^*)] = n\left( \prod_{k=1}^{n-1} p_{k,c^*}\right) +
 		\sum_{j=1}^{n-1} j (1-p_{j,c^*}) \left( \prod_{k=1}^{j-1} p_{k,c^*} \right)
 	\end{equation*}
 	Note that the event $N(\pi, c^*) = j$ occurs if the first $j-1$ entries are feasible while the $j$-th entry is not feasible when $j < n$, and $N(\pi, c^*) = n$ occurs if the first $n-1$ entries are feasible (but the $n$-th entry's feasibility does not matter).

 	We can express $\mathbf{E}[N(\pi', c^*)]$ in a similar manner, and simplify  $\mathbf{E}[N(\pi, c^*)] - \mathbf{E}[N(\pi', c^*)]$ as follows:
 	\small
 	\begin{equation*}
 		\mathbf{E}[N(\pi, c^*)] - \mathbf{E}[N(\pi', c^*)] =
 		r \left( \prod_{k=1}^{r-1} p_{k,c^*} \right) (p_{r,c^*} - p_{r+1,c^*}).
 	\end{equation*}
 	\normalsize
 	The quantity above is positive if $p_{r,c^*} > p_{r+1,c^*}$, which is the assumption we began with.
 	This proves the theorem.
 \end{proof}

 Theorems~\ref{theorem:col_by_col_opt} and \ref{theorem:within_column_opt} together tell us that
 in order to find an optimal policy we only need to decide the ordering of the columns.
 There are still $m!$ orderings of columns, and an exhaustive search algorithm would not be efficient.
 As we were able to generalize Lemma~\ref{lemma:single_column_opt} to Theorem~\ref{theorem:within_column_opt} by generalizing the optimal solution for 1-column case, it would be natural to consider generalizing Lemma~\ref{lemma:single_row_opt} in a similar manner.

 This idea leads to the following greedy algorithm: First we sort columns by their probability of success ($s_c = \prod_{r=1}^{n} p_{r,c}$) in decreasing order, and inspect the entries of each column in increasing order of their associated probabilities. However, as the following example shows, this algorithm is suboptimal.
 \begin{equation*}
 A =
 	\begin{bmatrix}
 		a_{1,1}  & a_{1, 2} \\
 		a_{2,1}  & a_{2, 2}
 	\end{bmatrix},
 	P_A =
 	\begin{bmatrix}
 		0.4459  & 0.2262 \\
 		0.4459  & 0.8114
 	\end{bmatrix}
 \end{equation*}
 Here we have $s_1 ~= 0.199$ and $s_2 ~= 0.184$, and the greedy algorithm would produce $\pi = \begin{pmatrix} a_{1,1} & a_{2,1} & a_{1,2} & a_{2,2} \end{pmatrix}$. Its expected cost, $\mathbf{E}[C(\pi)]$, is $2.428$, but if we inspect the second column first, then the expected cost is $2.407$ which is optimal in this example.
 One can consider another greedy algorithm which inspects the columns in increasing order of their expected number of inspections (within column), but this algorithm turns out to be suboptimal as well.

 \subsection{Main Result and Algorithm}
 Let us present the main result that leads to an efficient algorithm for finding an optimal inspection policy.

 \begin{theorem} \label{thm:main_result}
 	Let $s_c$ be the probability of success for column $c$ as before.
 	Let $\mu_c$ be the expected number of inspections that column $c$ incurs if its entries are inspected in increasing order of their probability of success, conditioning on the event that column $c$ is inspected and infeasible.
 	An optimal policy must be a column-by-column policy (due to Theorem~\ref{theorem:col_by_col_opt}), must inspect the entries of each column in non-decreasing order of probabilities (due to Theorem~\ref{theorem:within_column_opt}), and must inspect the columns in non-decreasing order of $\mu_c(1 - s_c)/s_c$.
 \end{theorem}
 \begin{proof}
 	Consider a column-by-column inspection policy $\pi$ which inspects the column 1 through $m$ in increasing order of their index (we can assume this without loss of generality by re-labeling columns).

 	As before, let $N(\pi,c)$ be a random variable that denotes the number of inspections performed by $\pi$ on column $c$, conditioning on the event that column $c$ is inspected.
 	Then we can express $\mathbf{E}[N(\pi, c)]$ in terms of $s_c$ and $\mu_c$ as follows.
 	\begin{equation}\label{eqn:exp_cost_column_by_condition}
 		\mathbf{E}[N(\pi, c)] = s_c \cdot n  + (1-s_c) \cdot \mu_c
 	\end{equation}
 	This equation holds because if the column is feasible (with probability $s_c$), it would require $n$ inspections, but if it is not (with probability $1-s_c$), it would require $\mu_c$ inspections in expectation. The equation above simply considers these two events, and calculates the expected value of $N(\pi, c)$.

 	Suppose that there is some column $c^*$ such that $\mu_{c^*}(1 - s_{c^*}) / s_{c^*} > \mu_{c^*+1} (1 - s_{c^*+1}) / s_{c^*+1}$. Because $\pi$ inspects column $c^*$ before column $c^*+1$, it would not be inspecting the columns in increasing order of $\mu_c(1-s_c)/s_c$.
 	Consider a different inspection policy $\pi'$ which inspects the columns in the same order as $\pi$ except that $\pi'$ inspects column $c^*+1$ before $c^*$ by swapping the inspection ordering of the two.
 	We can relate $N(\pi, \cdot)$ to $N(\pi', \cdot)$ as follows.
 	\begin{equation*}
 		N(\pi', c) =
 		\begin{cases}
 			N(\pi, c^*+1) & \mbox{if~} c = c^* \\
 			N(\pi, c^*)   & \mbox{if~} c = c^* + 1 \\
 			N(\pi, c)     & \mbox{otherwise}
 		\end{cases}
 	\end{equation*}

 	As we did in proofs of Theorems~\ref{theorem:col_by_col_opt} and \ref{theorem:within_column_opt}, we can use Equations~\ref{eqn:exp_c_pi_decoupled} and \ref{eqn:exp_c_pi2_decoupled}, and simplify $\mathbf{E}[C(\pi)] - \mathbf{E}[C(\pi')]$ as follows.
	\small
 	\begin{equation} \label{eqn:main_result_diff}
 		\begin{aligned}
 		\mathbf{E}[C(\pi)] - \mathbf{E}[C(\pi')] ={} & \left(\frac{\mathbf{E}[N(\pi, c^*)]}{s_{c^*}}  - \frac{\mathbf{E}[N(\pi, c^*+1)]}{s_{c^*+1}} \right) \\
 		& \cdot \left( \prod_{j=1}^{c^*-1} (1 - s_j)\right) s_{c^*} s_{c^*+1}
 		 \end{aligned}
 	\end{equation}
	\normalsize
 	The quantity in Equation~\ref{eqn:main_result_diff} is positive if the difference of the weighted expected values (in the first parentheses) are positive. Using Equation~\ref{eqn:exp_cost_column_by_condition} we obtain the following inequality.
 	\begin{equation*}
 		\begin{aligned}
 			{} &
 		\frac{\mathbf{E}[N(\pi, c^*)]}{s_{c^*}}  > \frac{\mathbf{E}[N(\pi, c^*+1)]}{s_{c^*+1}} \\
 		\Leftrightarrow &
 		\mu_{c^*} (1 - s_{c^*}) / s_{c^*} > \mu_{c^*+1}(1 - s_{c^*+1}) / s_{c^*+1}
 		\end{aligned}
 	\end{equation*}
 	By definition of $c^*$, the second inequality above holds, which implies $\mathbf{E}[C(\pi)] > \mathbf{E}[C(\pi')]$.
 	Therefore, an optimal inspection policy must inspect the columns in non-decreasing order of $\mu_c(1 - s_c)/s_c$.
 \end{proof}
 Because there is a unique ordering of columns if we sort them by $\mu_c(1-s_c)/s_c$ (up to ties), Theorem~\ref{thm:main_result} leads to the following algorithm: We inspect the columns in increasing order of $\mu_c(1-s_c)/s_c$, and in each column, we inspect the entries of it in increasing order of probabilities.
 This algorithm can easily be implemented to run in polynomial time.

\section{Discussion and Future Work} \label{PMIP:sec:discussion}
In this work we defined the Probabilistic Matrix Inspection problem motivated by group scheduling and Doodle.
We first considered two special cases, and discovered interesting properties of an optimal inspection policy which agree with our intuition. We then generalized our findings to design an efficient algorithm to solve the general case, and along the way we showed that two natural greedy algorithms fail to find an optimal solution. While we believe that our technical results make a great starting point for studying and optimizing a group scheduling process, there remain several open problems and future work to be done.

As we discussed in previous chapter, our model and algorithm rely on the assumption that probability estimates on availability of agents are available. We suggested several ideas motivated by previous work in the literature, but it will be important to deploy such ideas into a system, and integrate it with our algorithm. From a theoretical perspective, there remain several open problems. While we assumed that an inspection can be performed on a single entry at unit cost, one can generalize the cost model by allowing an inspection of any subset of entries whose cost depends on, for example, the number of entries being inspected. In the context of group scheduling, an inspection on many entries means querying multiple agents at the same time for one or many outcomes (but an inspection is not limited to the entries from the same column or row). This generalization is particularly useful when scheduling takes place in a hierarchical setting such as corporates. For instance the event organizer may feel that the cost of querying a supervisor is significantly different from that of querying a colleague.

Lastly, although we focused on relating our model to group scheduling, the Probabilistic Matrix Inspection problem has other applications. Finding the right childcare facility, for example, involves extensive inquiries as parents wish to gather more information about how they would handle certain situations, what benefits and environments they provide, and so on. Through advertisements or brochures parents may even be able to gauge the likelihood of a certain facility satisfying their needs. Yet they still need to inquire facilities for precise information, which can be modeled by our probabilistic matrix model where columns correspond to facilities and rows correspond to the needs of parents.


%---------------------------Shape & Size-----------------------------
\section{Shape and Size\label{s:tri-shape-and-size}}

Let $R$ be the relative size squared as defined in \S\ref{s:tri-rel-size-squared}
and $S$ be the shape as defined in \S\ref{s:tri-shape}.
Then the ``shape and size'' metric is
\[
  q = RS
\]

\trimetrictable{shape and size}%
{$1$}%                                                Dimension
{$[0.25,1]$}%                                         Acceptable range
{$[0,1]$}%                                            Normal range
{$[0,1]$}%                                            Full range
{Dependent on $\overline{A}$}%                        Unit equilateral triangle value
{\cite{knu:03}}%                                      Reference(s)
{v\_tri\_shape\_and\_size}%                            Verdict function name


\newpage
\part{Introduction}
%\section{Introduction}

\section{Terminologies \& Intros }

\subsection{Categories of Business Analytics}
\begin{itemize}
	\item descriptive analytics
		\begin{itemize}
			\item data engineering(organizing data, queries) \& statistics (mean, trend, standard deviation, test hypotheses)
		\end{itemize}

	 \item predictive analytics
	 	\begin{itemize}
	 		\item machine learning \& econometrics
	 		\item learn the pattern of data
	 	\end{itemize}

 	\item prescriptive analytics
 	\begin{itemize}
 		\item algorithm \& optimization models
 	\end{itemize}

\end{itemize}

\subsection{From Data to Information}
\begin{figure}[H]
	\centering
	\includegraphics[width=0.8\textwidth]{datatoinfo.png}
\end{figure}

\subsection{Types of Analytic Exercises}
\begin{itemize}
	\item Numeric Prediction
	\begin{itemize}
		\item \textbf{supervised} learning
		\item input: a collection of data input + \textbf{known} output

			  job: create a function  $f(\text{input}_{0}) = \text{output}_0$

			  output: \textbf{prediction} values to a \textbf{new} collection of data: $f(\text{input}_1) = ?$
		\item example: linear regression
	\end{itemize}

	\item Classification
	\begin{itemize}
		\item \textbf{supervised} learning
		\item input: a collection of data input + \textbf{known} label

			  job: create a classifier $f(\text{input}_0) = \text{label}_0$

			  output: \textbf{prediction} label to a \textbf{new} collection of data: $f(\text{input}_1) = ?$
	\end{itemize}

	\item Clustering
	\begin{itemize}
		\item \textbf{unsupervised} learning
		\item input: a collection of data input

			  job: identify "natural" grouping in data

			  output: clustered data
	\end{itemize}

	\item Association Rule Analysis
	\begin{itemize}
		\item \textbf{unsupervised} learning
		\item input: a collection of data list

			  job: identify \textbf{relationships} in data from \textbf{co-occuring items}
		\item grocery store purchases analysis
	\end{itemize}
\end{itemize}

\subsection{Machine Learning Terminology in categorizing analytic exercises}
\begin{itemize}
	\item \textbf{supervised learning}
	\begin{itemize}
		\item a training set is given
		\item find relationship between input \& target attributes
		\item examples: numeric prediction, classification
	\end{itemize}

	\item \textbf{unsupervised learning}
	\begin{itemize}
		\item only input data available, no training set
		\item find regularities, irregularities, relationships, similarities among data points
		\item examples: clustering, association rule analysis
	\end{itemize}
\end{itemize}

\subsection{Model}
examples:
\begin{itemize}
	\item linear model
	\item decision tree
	\item neural network
\end{itemize}

\section{Statistics Recap}
\subsection{Categories}
\begin{itemize}
	\item \hl{descriptive statistics}: \textbf{summary} of data

	\begin{itemize}

		\item examples: mean, standard deviation
	\end{itemize}

	\item \hl{inferential statistics}: model \textbf{patterns} of data, accounting for \textbf{randomness} and drawing \textbf{inferences about a larger population}
	\begin{itemize}
		\item estimation
		\item hypothesis testing
		\item forecasting
		\item correlation
		\item regression
	\end{itemize}

\end{itemize}

\subsection{Random Variables}
$X$ is a \textbf{random variable} if:
\begin{itemize}
	\item it represents a \textbf{random draw} from a population
	\item it's associated with a \textbf{probability distribution}
	\item either \textbf{discrete} or \textbf{continuous}
	\item example: a random variable that follows a \textbf{normal distribution} $N(\mu, \sigma^2)$ has a probability density function of
	$$f(x) = \frac{1}{\sigma \sqrt{2\pi}}e^{-\frac{(x-\mu)^2}{2\sigma^2}}$$
\end{itemize}

\subsection{Normal Distribution \& Standard Normal Distribution}
A random variable $X$ follows a normal distribution $N(\mu, \sigma^2)$

To \textbf{''standardize''} a random variable $x$ to \textbf{standard normal distribution }
$N(0,1)$: $$Z = \frac{X - \mu}{\sigma}$$

\subsection{Probability density function \& Cumulative density function}
\textbf{Probability density function (pdf): f(x)} $$f(x) = P(X = x)$$

\textbf{Cumulative distribution fuction (cdf): F(x)} $$F(x) = P(X \leq x)$$ $$P(X \geq x) = 1 - F(x)$$  $$P(x_1 \leq X \leq x_2) = F(x_2) - F(x_1)$$

\subsection{Statistical Estimation}
\textbf{Statistical estimation}:

The parameters of a population are \textbf{unknown}. However, we can \textbf{estimate} the parameters by \textbf{drawing a random sample} out of the population, analyzing this random sample and getting the statistics. The statistics should infer the parameters.
\\ \ \\
Requirements of random sampling:
\begin{itemize}
	\item each variable $X$ from the population is a random variable.
	\item each combination of $n$ sample points has an \textbf{equal} chance of being selected.

\end{itemize}
	$\longrightarrow$ a random sample is a set of \textbf{independent, identically distributed (i.i.d)} random variables.
\\ \ \\
\textbf{Categories:}
\begin{itemize}
	\item Point Estimate
	\begin{itemize}
		\item sample mean
		\item sample proportion
	\end{itemize}

	\item Interval Estimate
	\begin{itemize}
		\item \textbf{confidence interval} for sample mean
		\item \textbf{confidence interval} for sample proportion
	\end{itemize}
\end{itemize}
Point estimate is always within the interval estimate.

\subsubsection{Point Estimate: Population Mean and Its Estimation}
\begin{itemize}
	\item \textbf{Expected Value of X and the Population Mean}

	The expected value of a probability \textbf{weighted average} of $X$, $E(X)$, is the mean/expected value of the probability distribution of $X$.

	$f(x_i)$ is the (discrete) probability that $X = x_i$.
	$$\mu_x = E(X) = \Sigma_{i=1}^{n} x_i f(x_i)$$ or $$\mu_x = E(X) = \int_{-\infty}^{+\infty} xf(x) dx$$

	If this random sample is a set of i.i.d random variables, the \textbf{expected value of X} is the \textbf{population mean}(unknown).

	\item \textbf{Estimation of the Population Mean by Sample Mean}

	\textbf{Sample Mean $\bar{X}$:} the \textbf{random variable} for the arithmetic mean of the sample. $\bar{x}$ is the mean of a \textbf{particular realization} of a sample.

	$$\bar{X} = \frac{\Sigma X_i}{n} $$

	This is a random variable, because a lot of samples are drawn repeatedly, the arithmetic mean of the sample has also a probability distribution. \textbf{The mean(center) of this distribution should estimate the mean of the whole population. }

	\item Requirements for an estimator: \textbf{unbiased}

	Example: $$E(\bar{X}) = \mu_x$$

	\item \textbf{Standard Error of the Sample Mean}:

	\begin{itemize}
		\item  \hl{\textbf{standard error of the sample mean $SE_{\bar{X}}$}} : an estimate of how far the \textbf{sample mean} is likely to be \textbf{from the population mean}.

		When $n \rightarrow \infty$,  $SE_{\bar{X}}  \rightarrow \sigma_{\bar{X}}$ (\hl{\textbf{true standard deviation of sample mean}}).

		$$SE_{\bar{X}} = \frac{s}{\sqrt{n}}$$
		$$\sigma_{\bar{X}} = SD(\bar{X}) = \sqrt{Var(\bar{X})} = \frac{\sigma}{\sqrt{n}}$$

		\item\hl{\textbf{sample standard deviation $s$}} : the degree to which \textbf{individuals within the sample} differ from the \textbf{sample mean}

		$$s = \sqrt{\frac{1}{n-1} \Sigma_{i=1}^{n} (X_i - \bar{X})^2}$$
	\end{itemize}

	\item \textbf{Law of Large Numbers}

	If $n \rightarrow \infty, \bar{X}_n \rightarrow \mu$.

	If the size of the random sample is large enough, then the arithmetic mean converge to the real population mean.
	$$\lim\limits_{n\rightarrow \infty} P(|\bar{X}_n - \mu| > \epsilon) = 0$$

	\item \textbf{Central Limit Theorem}

	If \textbf{$n \rightarrow \infty$}, the \textbf{average $\bar{X}$} of any population of \textbf{i.i.d.} random variables $X_i$ with the population mean $\mu_X$ and population variance $\sigma^2$ \textbf{follows asymptotically a normal distribution} $\bar{X} \sim N(\mu_X, \frac{\sigma^2}{n})$.
	$$\bar{X} = \frac{X_1 + X_2 + \dots + X_n}{n}$$
	The \textbf{standardize average} $Z \sim N(0,1)$: $$Z = \frac{\bar{X} - \mu_X}{\frac{\sigma}{\sqrt{n}}}$$
\end{itemize}

\subsubsection{Interval Estimate: }
\begin{itemize}
	\item \textbf{Confidence Interval of Sample Mean:}
	\begin{itemize}
		\item Assumption: samples drawn from a population that follows a normal distribution $N(\mu_X, \sigma^2)$.

		eg: The sample mean $\bar{X}$ follows asymptotically a normal distribution $N(\mu_X, \frac{\sigma^2}{n})$
		\item a level of confidence($1 - \alpha$) is given.
		\item \textbf{two-sided} $\rightarrow z_{(1 - \frac{\alpha}{2})} $  / $z_{(1 + \frac{\alpha}{2})}$
		\item z value: \textbf{standardized}. \textbf{Find z value from cdf-table given an $\alpha$}.
		\item if population standard deviation $\sigma$ is given,
		$$CI = \left[ \bar{X} - z_{(1 - \frac{\alpha}{2})}\cdot \frac{\sigma}{\sqrt{n}} , \bar{X} + z_{(1 - \frac{\alpha}{2})}\cdot \frac{\sigma}{\sqrt{n}} \right] $$
		$$Pr(\bar{X} - z_{(1 - \frac{\alpha}{2})}\cdot \frac{\sigma}{\sqrt{n}} < \mu_X < \bar{X} + z_{(1 - \frac{\alpha}{2})}\cdot \frac{\sigma}{\sqrt{n}} ) = 1 - \alpha$$

		\item if population standard deviation $\sigma$ is unknown,
		\begin{itemize}
			\item n is \textbf{small}: use \textbf{sample standard deviation $s$} and \textbf{t-distribution}
			$$CI = \left[ \bar{X} - t_{(1 - \frac{\alpha}{2})}\cdot \frac{s}{\sqrt{n}} , \bar{X} + t_{(1 - \frac{\alpha}{2})}\cdot \frac{s}{\sqrt{n}} \right] $$
			\item n is \textbf{large}: use \textbf{sample standard deviation $s$} and \textbf{normal distribution}
			$$CI = \left[ \bar{X} - z_{(1 - \frac{\alpha}{2})}\cdot \frac{s}{\sqrt{n}} , \bar{X} + z_{(1 - \frac{\alpha}{2})}\cdot \frac{s}{\sqrt{n}} \right] $$
		\end{itemize}
		If $n \rightarrow \infty$, the T-Distribution converges to a Normal Distribution.

	\end{itemize}

	\item Effects on Confidence Intervals:
	\begin{itemize}
		\item \textbf{sample size} n: n $\uparrow$, interval size $\downarrow$

		(the larger the size, more precise is the estimation)
		\item \textbf{confidence level} ($1 - \alpha$): confidence level $\uparrow$, interval size $\uparrow$

		(given the same sample size, the higher the confidence level, the more values need to be included.)
		\item \textbf{population standard deviation} $\sigma$: $\sigma \uparrow$, interval size $\uparrow$

		(the more spreaded the population, the more values need to be included to achieve same confidence level.)
	\end{itemize}
\end{itemize}

\subsection{Statistical Tests}
\subsubsection{Process}
\begin{itemize}
	\item number of samples
	\begin{itemize}
		\item 1 sample:
		\begin{itemize}
			\item $\sigma$ known: \textbf{Z-Test}
			\item $\sigma$ unknown: \textbf{T-Test}
		\end{itemize}
		\item 2 samples:
		\begin{itemize}
			\item dependent:\textbf{ Paired T-Test}
			\item independent: \textbf{Welch-Test}
		\end{itemize}
	\end{itemize}
	\item Formulate \textbf{null and alternative hypothesis} ($H_0$ and $H_1$), $H_1$ is the hypothesis we want to test.
	\item Choose an \textbf{$\alpha$ level}. (type I error: probability of falsely rejecting $H_0$)
	\item Find corresponding \textbf{distribution}, calculate \textbf{test statistic},
	\item Find the \textbf{critical value} in the table and corresponding \textbf{p-value}
	\item Conclusion:
	\begin{itemize}
		\item $p \leq \alpha$, reject $H_0$
		\item $p > \alpha$, reject $H_1$
	\end{itemize}
	Interpretation of p-value: the probability of having the other mean $\bar{x}$, given that $H_0$ is true.
\end{itemize}

\subsubsection{Two-sided or One-sided Test}
Three possible alternative hypotheses $H_1$:
\begin{figure}[H]
	\centering
	\includegraphics[width=0.5\textwidth]{H1.png}
\end{figure}
Critical Value:
\begin{itemize}
	\item two-sided test: $z_{\frac{\alpha}{2}}, z_{1-\frac{\alpha}{2}}$ / $t_{\frac{\alpha}{2}}, t_{1-\frac{\alpha}{2}}$
	\item one-sided test: $z_{1-\alpha}$ / $t_{1-\alpha}$
\end{itemize}

\subsubsection{Z-Test}
\begin{itemize}
	\item Requirements: \textbf{1 sample, $\mu$, $\sigma$ known} (population mean and population standard deviation)
	\item Distribution: \textbf{standardized normal distribution}
	\item test statistic: \large{$$ z = \frac{\bar{X} - \mu_0}{\frac{\sigma}{\sqrt{n}}}$$}
	\item critical value: $z^c_{1-\frac{\alpha}{2}}$ / $z^c_{1-\alpha}$
	\item $H_0$ Rejection region/ $H_1$ Acceptance region :

	\begin{table}[H]
		\begin{center}
			\begin{tabular}{|c|c|c|}
				\hline
				$H_1$ 				& Rejection Region					& test variant \\ \hline
				$\mu\mu \neq \mu_0$	& $|z| \geq z^c_{1-\frac{\alpha}{2}}$	& two-sided                 \\ \hline
				$\mu\mu > \mu_0$	& $ z \geq z^c_{1-\alpha}$			& one-sided                  \\ \hline
				$\mu\mu < \mu_0$	& $ z \leq -z^c_{1-\alpha} $			& one-sided                  \\ \hline
			\end{tabular}
		\end{center}
	\end{table}
\end{itemize}

\subsubsection{Single Sample T-test}
\begin{itemize}
	\item Requirements: \textbf{1 sample, $\sigma$ unknown}
	\item Distribution: Student \textbf{t-Distribution}
	\item Degree of Freedom($df$): determines how spread the distribution is.
	\large{$$df = n - 1$$}
	\item test statistic:

	$s$ is the standard error(empirical)
	\large{$$t(df) = \frac{\bar{X} - \mu_0}{\frac{s}{\sqrt{n}}}$$}
	\item critical value: $t^c_{1-\frac{\alpha}{2}, df}$ / $t^c_{1-\alpha, df}$
	\item $H_0$ Rejection region/ $H_1$ Acceptance region :

	\begin{table}[H]
		\begin{center}
			\begin{tabular}{|c|c|c|}
				\hline
				$H_1$ 				& Rejection Region					& test variant \\ \hline
				$\mu\mu \neq \mu_0$	& $|t| \geq t^c_{1-\frac{\alpha}{2}, df}$	& two-sided                 \\ \hline
				$\mu\mu > \mu_0$	& $ t \geq t^c_{1-\alpha, df}$			& one-sided                  \\ \hline
				$\mu\mu < \mu_0$	& $ t \leq -t^c_{1-\alpha,df} $			& one-sided                  \\ \hline
			\end{tabular}
		\end{center}
	\end{table}
\end{itemize}

\subsubsection{Paired Sample T-test}
\begin{itemize}
	\item Requirements: \textbf{2 samples, $\sigma$ unknown, dependent}

	eg: means obtained in 2 conditions(time,places,etc.) by a single group of participants
	\item Distribution: \textbf{T-Distribution}
	\item Test of relationship between 2 linked samples (eg: Difference)
	\item Degree of Freedom($df$): $$df = n -1 $$
	\item Example null hypothesis: $ H_0: \mu_d = \mu_1 - \mu_2 = \Delta_0$
	\item test statistic:
	\large{$$t = \frac{\bar{d} - \Delta_0}{\frac{s}{\sqrt{n}}}$$}
	\item critical value: $t^c_{1-\frac{\alpha}{2}, df}$ / $t^c_{1-\alpha, df}$
	\item $H_0$ Rejection Region/ $H_1$ Acceptance Region:
	\begin{table}[H]
		\begin{center}
			\begin{tabular}{|c|c|c|}
				\hline
				$H_1$ 				& Rejection Region					& test variant \\ \hline
				$\mu_d \neq \Delta_0$	& $|t| \geq t^c_{1-\frac{\alpha}{2}, df}$	& two-sided                 \\ \hline
				$\mu_d > \Delta_0$	& $ t \geq t^c_{1-\alpha, df}$			& one-sided                  \\ \hline
				$\mu_d < \Delta_0$	& $ t \leq -t^c_{1-\alpha,df} $			& one-sided                  \\ \hline
			\end{tabular}
		\end{center}
	\end{table}
\end{itemize}

\subsubsection{Independent T-Test/ Welch-Test}
\begin{itemize}
	\item Requirements: \textbf{2 samples, $\sigma$ unknown, independent}

	eg: credit card debt difference between urban and rural households/ shopping expenses between male and female
	\item Distribution: \textbf{T-Distribution}
	\item Test of relationship between 2 independent samples (doesn't need to be same size)
	\item Degree of Freedom($df$): round to \textbf{nearest integer} number
	\large{$$df = \dfrac{(\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2})^2}{\frac{(\frac{s_1^2}{n_1})^2}{n_1 -1} + \frac{(\frac{s_2^2}{n_2})^2}{n_2 -1}}$$}
	\item test statistic:
	\large{$$t = \frac{(\bar{x}_1 - \bar{x}_2) - \mu_0}{s_{\bar{x}_1 -\bar{x}_2}}$$}
	\large{$$s_{\bar{x}_1 -\bar{x}_2} = \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}$$}
	\item $H_0$ Rejection Region/ $H_1$ Acceptance Region:
	\begin{table}[H]
		\begin{center}
			\begin{tabular}{|c|c|c|}
				\hline
				$H_1$ 				& Rejection Region					& test variant \\ \hline
				$\mu_d \neq \Delta_0$	& $|t| \geq t^c_{1-\frac{\alpha}{2}, df}$	& two-sided                 \\ \hline
				$\mu_d > \Delta_0$	& $ t \geq t^c_{1-\alpha, df}$			& one-sided                  \\ \hline
				$\mu_d < \Delta_0$	& $ t \leq -t^c_{1-\alpha,df} $			& one-sided                  \\ \hline
			\end{tabular}
		\end{center}
	\end{table}
	\item Confidence Interval of both samples: if both confidence intervals overlap each other $\rightarrow$ \textbf{cannot reject} $H_0$
\end{itemize}
\subsubsection{Using Confidence Intervals in Significance Tests}
Find confidence intervals for $\mu_x$, which -- under $H_0$ -- contains the true value $\mu_x$ with a probability of at least $1 - \alpha$:
\begin{itemize}
	\item $\sigma$ known: \textbf{Normal Distribution}
	$$CI = [\bar{x} - z^c_{(1-\frac{\alpha}{2})} \cdot \frac{\sigma}{\sqrt{n}}, \bar{x} + z^c_{(1-\frac{\alpha}{2})} \cdot \frac{\sigma}{\sqrt{n}}]$$
	\item $\sigma$ unknown: \textbf{t-Distribution}
	$$CI = [\bar{x} - t^c_{(1-\frac{\alpha}{2}, n-1)} \cdot \frac{s}{\sqrt{n}}, \bar{x} + t^c_{(1-\frac{\alpha}{2}, n-1)} \cdot \frac{s}{\sqrt{n}}]$$
\end{itemize}
Conclusion:
\begin{itemize}
	\item Accept $H_0$: if $\mu_0$ lies \textbf{within} the confidence interval
	\item Rejection $H_0$: if $\mu_0$ lies \textbf{outside} the confidence interval
\end{itemize}

\subsubsection{Other Tests}
\begin{itemize}
	\item Parametric Tests: eg: T-tests,  F-test(comparing variance of 2 samples)
	\item Non-parametric Tests: eg: Wilcoxon signed-rank test(2 paired i.i.d. samples), Mann-Whitney-U test(2 independent i.i.d. samples)
	\item Test of Probability Distribution: Kolmogorov-Smirnov test, Chi-square test
\end{itemize}

\section{Description of a Dataset}
\begin{itemize}
	\item \textbf{Dependent} and \textbf{independent} variables
	\item Scales of measurement of the variables
	\begin{figure}[H]
		\centering
		\includegraphics[width=0.8\textwidth]{scale_measurement.jpg}
	\end{figure}
	\begin{itemize}
		\item \textbf{Nominal}: \textbf{categorical} variable scale. A scale used for labeling variables into distinct classifications, \textbf{doesn't involve quantitative value or order. }
		\begin{itemize}
			\item eg: Gender, City, Nationality, Jobs
		\end{itemize}
		\item \textbf{Ordinal}: scale to depict \textbf{order} of the variables for non-mathematical ideas. It maintains a \textbf{descriptional} quality and the \textbf{difference between variables can't be calculated}.
		\begin{itemize}
			\item eg: Frequency(high, medium, low), Happiness, Satisfaction, Pain level, Cloth size (S, M, L), rank of Unis
		\end{itemize}
		\item \textbf{Interval}: numeric scale where \textbf{order} of the variables as well as the \textbf{difference between variables are known}. There exists \textbf{no true 0}. Variables can be added and subtracted, but \textbf{not multiplied or divided}.
		\begin{itemize}
			\item eg: GPA, GRE, Celsius, Fahrenheit (20$^\circ$C is 10$^\circ$C higher than 10$^\circ$C, it doesn't mean 2 times warmer.)
		\end{itemize}
		\item \textbf{Ratio}: numeric scale that's ordered, difference between variables known, and there \textbf{exists true 0}. Variables can be added, subtracted, multiplied and divided.
		\begin{itemize}
			\item eg: weight, height, time, Kelvin temperature, money
		\end{itemize}
	\end{itemize}
	\item \textbf{Cross-sectional, time series, panel data} (see 7.1.5)
\end{itemize}

%\section{Summary of Possible Exam Questions}
%\begin{itemize}
%	\item Calculation of arithmetic weighted mean of sample $\bar{X}$, variance $\sigma^2$ of the sample, standard deviation $\sigma$ of the sample.
%	\item Calculation of variance/standard deviation of the sample mean $\sigma_{\bar{X}}^2$/$\sigma_{\bar{X}}$
%	\item Standardization of a normal distribution
%	\item Calculation of probability, find values from pdf or cdf table
%	\item independent, identically distributed sample points (i.i.d.)
%	\item Performance of Significance Test according to requirements
%	\item p-value: Interpretation when to reject $H_0$ ($p < \alpha$)
%	\item description of dataset
%\end{itemize}


\documentclass{ximera}
\input{../preamble}
\title{Exercises: Partial Fractions}
%%%%%\author{Philip T. Gressman}

\begin{document}
\begin{abstract}
Various exercises relating to partial fractions and integration.
\end{abstract}
\maketitle

Compute the indefinite integrals below. Since there are many possible answers (which differ by constant values), use the given instructions if needed to choose which possible answer to use. Do not forget absolute value signs inside logarithms when they are needed.

\begin{exercise}%[APEX0604PF07]
\[ \frac{7x+7}{x^2+3x-10} = \frac{\answer{3}}{x-2} + \frac{\answer{4}}{x+5} \]
\[ \int \frac{7x+7}{x^2+3x-10}\ dx = \answer{3 \ln |x-2|+4 \ln |x+5|}+C\]
(Do not include any constant terms in your antiderivative.)
%%
%%
\end{exercise}

\begin{exercise}%[APEX0604PF08]
\[ \int \frac{7x-2}{x^2+x}\ dx = \answer{9 \ln |x+1|-2 \ln |x|}+C\]
(Do not include any constant terms in your antiderivative.)
%
%
\end{exercise}

\begin{exercise}%[APEX0604PF11]
\[ \frac{x+7}{(x+5)^2} = \frac{\answer{1}}{x+5} + \frac{\answer{2}}{(x+5)^2} \]
\[ \int \frac{x+7}{(x+5)^2}\ dx = \answer{\ln |x+5|-\frac{2}{x+5}}+C\]
(Do not include any constant terms in your antiderivative.)
%
%
\end{exercise}

\begin{exercise}%[APEX0604PF13]
\[ \int \frac{9x^2+11x+7}{x(x+1)^2}\ dx = \answer{\frac{5}{x+1}+7 \ln |x|+2 \ln |x+1|}+C\]
(Do not include any constant terms in your answer.)
%
%
\end{exercise}

\begin{exercise}%[APEX0604PF16]
\[ \int \frac{x^2+x+1}{x^2+x-2}\ dx = \answer{x+\ln |x-1|-\ln |x+2|}+C \]
(Do not include any constant terms in your answer.)
\begin{hint}
Don't forget polynomial long division; it is needed in this case because the degree of the numerator is at least as large as the degree of the denominator.
\end{hint}
%
%
\end{exercise}

\begin{exercise}%[APEX0604PF20]
\[ \int \frac{x^2+x+5}{x^2+4x+10}\ dx = \answer{-\frac{3}{2} \ln \left|x^2+4 x+10\right|+x+\frac{\arctan \left(\frac{x+2}{\sqrt{6}}\right)}{\sqrt{6}}}+C \]
(Do not include any constant terms in your answer.)
\begin{hint}
\[ \frac{x^2+x+5}{x^2+4x+10} = \answer{1} + \frac{\answer{-3} x + \answer{-5}}{x^{2} + 4 x + 10}  \]
Since the derivative of the denominator is $2x + 4$, we should rewrite the numerator of the big fraction to have $x+2$'s if possible:
\[  \frac{x^2+x+5}{x^2+4x+10} = \answer{1} + \frac{\answer{-3}(x+2) + \answer{1}}{x^2 + 4x + 10}. \]
For expressions like
\[ \int \frac{x+2}{x^2 +4x+10} dx \]
we should do a substitution. For terms like
\[ \int \frac{1}{x^2 + 4x + 10} dx \]
we should first complete the square: $x^2 + 4x + 10 =  (x + 2)^2 + 6$ and then make the substitution $x + 2 = u \sqrt{6}$.
\end{hint}
%
%
\end{exercise}

\begin{exercise}%[APEX0604PF23]
\[ \int \frac{2x^2+x+1}{(x+1)(x^2+9)}\ dx = \answer{\frac{9}{10} \ln \left|x^2+9\right|+\frac{1}{5} \ln |x+1|-\frac{4}{15} \arctan \left(\frac{x}{3}\right)} +C\]
(Do not include any constant terms in your answer.)
%
%
\end{exercise}

\section*{Sample Quiz Questions}

\begin{question}%%%%%[PartialFracHeav001v2]

Compute the integral
\[\int_{3}^{4}\frac{2x-3}{x^2-3x+2}~dx.\]
(Hints won't be revealed until after you choose a response.)
\begin{multiplechoice}
\choice{\(\displaystyle \ln 2\)}
\choice[correct]{\(\displaystyle \ln 3\)}
\choice{\(\displaystyle \ln 4\)}
\choice{\(\displaystyle \ln 5\)}
\choice{\(\displaystyle \ln 6\)}
\choice{\(\displaystyle \ln 7\)}
\end{multiplechoice}
\begin{feedback}
First factor the denominator of the integrand: \(x^2-3x+2 = (x-1)(x-2)\). Since the roots are distinct, it is possible to use the Heaviside cover-up method.  \begin{hint} The partial fractions expansion will take the form \[\frac{A}{x-1} + \frac{B}{x-2}, \] where the coefficient \(A\) can be computed by cancelling the factor of \(x-1\) in the denominator and evaluating the result at \(x = 1\), i.e., \[A = \frac{2(1)-3}{(1)-2} = 1. \] Similarly, \[B = \frac{2(2)-3}{(2)-1} = 1,\] which gives that \[\frac{2x-3}{(x-1)(x-2)} = \frac{1}{x-1} + \frac{1}{x-2}. \] \begin{hint} Therefore
\[ \begin{aligned}
\int_{3}^{4}\frac{2x-3}{x^2-3x+2}~dx & = \int_{3}^{4}\left(\frac{1}{x-1} + \frac{1}{x-2}\right)~dx \\
 & = \left(\ln |4-1| + \ln |4-2| \right) - \left(\ln |3-1| + \ln |3-2| \right)\\
 & = \ln 3 + \ln 2 + \ln \frac{1}{2} + 0 = \ln 3.\end{aligned}\] \end{hint} \end{hint}
\end{feedback}

\end{question}

\section*{Sample Exam Questions}

\begin{question}%%%%%[2019WrittenByClass01]
Compute the volume of the solid of revolution obtained by revolving around the $y$-axis the region below the graph
\[ y = \frac{1}{(x-1)^2}, \]
above $y=0$, and between $x=2$ and $x=3$.
(Hints won't be revealed until after you choose a response.)
\begin{multiplechoice}
\choice{\(\displaystyle \pi\)}
\choice{\(\displaystyle \pi ( \ln 2 + 3)\)}
\choice[correct]{\(\displaystyle \pi (2 \ln 2 + 1)\)}
\choice{\(\displaystyle \pi (2 \ln 3 + 1)\)}
\choice{\(\displaystyle \pi (3 \ln 2 + 1)\)}
\choice{\(\displaystyle \pi (3 \ln 3 + 1)\)}
\end{multiplechoice}
\begin{feedback}
Choosing $x$ as the variable of integration, slices will be parallel to the $y$-axis, indicating that the shell method should be used. The radius of a shell is $x$ (because the axis lies to the left of the region) and the height will be $(x-1)^{-2}$, so
\[ V = \int_2^3 \frac{2 \pi x}{(x-1)^2} dx = 2 \pi \int_2^3 \frac{x}{(x-1)^2} dx. \] \begin{hint}
The integral can be computed by partial fractions; the expansion has the form
\[ \frac{x}{(x-1)^2} = \frac{A}{x-1} + \frac{B}{(x-1)^2}. \]
The coefficients $A$ and $B$ can be found by usual methods (but note that the Heaviside cover up method will \textit{not} work in this case), but it is also possible to find them directly by carefully rewriting the numerator of the fraction in terms of $x-1$:
\[ \frac{x}{(x-1)^2} = \frac{(x-1) + 1}{(x-1)^2} = \frac{(x-1)}{(x-1)^2} + \frac{1}{(x-1)^2} = \frac{1}{x-1} + \frac{1}{(x-1)^2}. \]
Therefore
\[ \begin{aligned} V & = 2 \pi \int_2^3 \left[ \frac{1}{x-1} + \frac{1}{(x-1)^2} \right] dx = 2 \pi \left. \left[ \ln |x-1| - \frac{1}{x-1} \right] \right|_{2}^3 \\
& = 2 \pi \left( \ln 2 - \frac{1}{2} \right) - 2 \pi \left( 0 - 1 \right) = \pi(2 \ln 2 + 1). \end{aligned}\] \end{hint}
\end{feedback}

\end{question}

\begin{question}%%%%%[2016C.04]

Compute the constants \(A\) and \(B\) in the partial fractions expansion indicated below. \offline{To receive full credit, it is not necessary to compute \(C, D,\) or \(E\).}
\[ \frac{x^4 + 16}{x^4 - 16} =A +  \frac{B}{x-2} + \frac{C}{x+2} + \frac{Dx + E}{x^2 + 4} \]
(Hints won't be revealed until after you choose a response.)
\begin{multiplechoice}
\choice{\(A=-1, B=1\)}
\choice{\(A = 0, B = 1\)}
\choice[correct]{\(A = 1, B = 1\)}
\choice{\(A=-1, B=-1\)}
\choice{\(A = 0, B = -1\)}
\choice{\(A = 1, B = -1\)}
\end{multiplechoice}
\begin{feedback}
You'll need to do polynomial long division first. To compute $B$, you can use Heaviside cover-up.
\begin{hint}
\[  \frac{x^4 + 16}{x^4 - 16} = 1 + \frac{1}{x-2} - \frac{1}{x+2} - \frac{4}{x^2+4} \]
\end{hint}
\end{feedback}

\end{question}

\begin{question}%%%%%[2017C.04]

Evaluate \(\displaystyle \int_1^2 \frac{x^2+x+1}{x^2+x} dx\).
\begin{multiplechoice}
\choice{\(0\)}
\choice{\(1\)}
\choice[correct]{\(\displaystyle 1 + \ln \left(\frac{4}{3}\right)\)}
\choice{\(2\)}
\choice{\(\displaystyle 2 + \ln \left(\frac{8}{3}\right)\)}
\choice{none of these}
\end{multiplechoice}

\end{question}

\end{document}