\newcommand{\numfoil}{$\boldsymbol{\Gamma}$\textbf{py}\ }
\chapter{Problem description}
To get a preliminary estimation of an airfoil's performance, numerical methods
can be used which represent the airfoil as a series of flat, zero-thickness,
panels. Various kinds of singularities can then be placed on those panels to
manipulated the airflow around them to resemble the flow behavior around the
actual airfoil.\\

In this part of the report, two separate methods will be discussed.
The first method ignores the airfoil's thickness and instead reduces it to only
a set of $n$ panels located on the camber line. A lumped vortex element is then
placed at some location on each panel, as well as a collocation point. At each
collocation point, the influence of all these vortex elements will be evaluated.
From this, values like $C_l$, $C_m$ and $C_P$ can be estimated. Using this
method the effect of camber on the airfoil can be quickly evaluated.\\

To also evaluated the effect of thickness, the second method instead places $n$
panels along the airfoil's surface. This time constant vortex elements are
placed in the panels.
Both methods are based on the Kutta condition, meaning this condition is
intrinsically satisfied. Both methods have the same general structure, which can
be seen in \autoref{fig:flow_diagram}. The steps are discussed in more detail
for each of the two methods in the following sections.

% \begin{figure}[H]
% \label{fig:flow_diagram}
% \centering
% \includegraphics[width=.8\textwidth]{static/missing.jpg}
% \caption{Flow diagram showing the general structure of the created solver program.}
% \end{figure}

\chapter{\numfoil Implementation}

\blindtext

\section{Software Architecture \& Flow Diagram}
\begin{wrapfigure}{R}[2em]{0.45\textwidth}
    \vspace{-2em}
    \begin{center}
      \includegraphics[width=0.40\textwidth]{static/activity_diagram.pdf}
    \end{center}
    \caption{UML Activity Diagram of \numfoil}
    \label{fig:activity}
\end{wrapfigure}

\blindtext\\

\blindtext\\

\section{Geometry Definition}
Before we can begin the analysis, the functions describing the desired airfoil's
camber line, and upper and lower surface should be created. Airfoils are defined
using the NACA 4-digit code. \autoref{eq:camber} is used to obtain the camber
line function.

\begin{equation}
\label{eq:camber}
    y_{c}=\left\{
        \begin{array}{ll}
            \frac{m}{p^{2}}\left(2 p\left(\frac{x}{c}\right)-\left(\frac{x}{c}\right)^{2}\right),
            & 0 \leq x \leq p c \\
            \frac{m}{(1-p)^{2}}\left((1-2 p)+2 p\left(\frac{x}{c}\right)-\left(\frac{x}{c}\right)^{2}\right),
            & p c \leq x \leq c
        \end{array}\right.
\end{equation}
\medskip

Here $m$ is the maximum camber and $P$ is the location of the maximum camber, or
the first and second digit of the 4-digit NACA code divided by ten respectively.
Subsequently, to find the coordinates of the the upper and lower airfoil
surface, the thickness is applied perpendicular to the camber line using
\autoref{eq:coor_u} and \autoref{eq:coor_l} respectively, where $\theta =
\arctan\left( \frac{y_c}{dx}\right)$.

\begin{equation}
\label{eq:coor_u}
    \left(\begin{array}{l} x_U, \: y_U\end{array}\right) =
    \left(\begin{array}{l} x-y_t \sin \theta, \: y_c+y_t\cos \theta\end{array}\right)
\end{equation}
\begin{equation}
\label{eq:coor_l}
    \left(\begin{array}{l} x_L, \:  y_L\end{array}\right) =
    \left(\begin{array}{l} x+y_t \sin \theta, \: y_c-y_ t \cos \theta\end{array}\right)
\end{equation}

\chapter{Panel Methods}  % TODO Decide if this should be a section?
Two different methods well be implemented to peform basic airfoil analysis.
First, the airfoil is represented by its camberline only, and thus has a
thickness of zero. The results of this method will be compared with the second
method, which discritizes the airfoil by placing panels on the outer surface
instead. Hence this second method does take airfoil thickness into account.

\section{Lumped Vortex Method}
\label{sec:thin}
The first method, described by \citeauthor{katz_plotkin}\cite{katz_plotkin}, analyzes an airfoil
looking only at the airfoil's camber line. This discritization is visualized in
\autoref{fig:discr_thin}, where $n=7$ panels are placed on the camber line starting at
the leading edge. These panels are created by adding $n+1$ nodes on the camber
line, the coordinates for which are obtained using the camber line function from
\autoref{eq:camber}. Lumped vortex elements and collocation points are placed at
25\% and 75\% of each panel's length. This way the airfoil is represented as a
set of zero-thickness vortex sheets. Not that linear node spacing is used in
\autoref{fig:discr_thin}. For the implementation, however, cosine spacing is used to
increase accuracy of the results at the leading and trailing edge.

\begin{figure}[H]
\centering
\includegraphics[width=.8\textwidth]{static/disc_camber.png}
\caption{Discritization of the airfoil camber line using $n=7$ flat panels\cite{katz_plotkin}}
\label{fig:discr_thin}
\end{figure}

\subsection{Equations}
The normal velocity, which consists of the free-stream velocity and the
self-induced velocity, must be zero at each point along the camber line. This
way the camber line is set to be a streamline of the free-stream. This
boundary condition is described by \autoref{eq:thin_cond}. Here,
$\vec{\bf{n}}_i$ is the normal vector of the $i-$th panel given by
\autoref{eq:normal}, and $\alpha_i$ is the angle w.r.t. the x-axis of the $i-$th
panel.

\begin{equation}
\label{eq:thin_cond}
    \left( u_i, \: w_i \right) \cdot \vec{\bf{n}}_i + \left( U_\infty,
    \: W_\infty \right) \cdot  \vec{\bf{n}}_i = 0
\end{equation}
\begin{equation}
\label{eq:normal}
    \vec{\bf{n}}_i = \left( \sin \alpha_i, \: \cos \alpha_i \right)
\end{equation}

Next, if $\left( x_i, \: y_i \right)$ is the location of the $i-$th panel
collocation point, and $\left( x_j, \: y_j \right)$ is the location of the
$j-$th vortex element, the velocity induced at each collocation point due to the
presence of the $n$ vortices, with strength $\Gamma_j$, is found using
\autoref{eq:v_ind_thin}.
\medskip

\begin{equation}
\label{eq:v_ind_thin}
    \left(\begin{array}{l}
    u_i \\ w_i
    \end{array}\right)
    =
    \sum_{j=1}^{n} \:
    \left[ \frac{\Gamma_{j}}{2 \pi r_{i,j}^{2}}
    \left(\begin{array}{cc}
    0 & 1 \\ -1 & 0
    \end{array}\right)
    \left(\begin{array}{l}
    x_i-x_{j} \\ z_i-z_{j}
    \end{array}\right) \right], \; \; \; \; \; \forall \; i \in \{1,...,n\}
\end{equation}
\begin{equation}r_{j}^{2}=\left(x_i-x_j\right)^{2}+\left(z_i-z_j\right)^{2}\end{equation}
\medskip

Naturally, if $i=j$, the respective collocation point and vortex are located
on the same panel. The vorticities, $\Gamma_j$, are the unknown which will be solved for.
Combining \autoref{eq:v_ind_thin} with \autoref{eq:thin_cond}, and moving the free-stream
velocity from \autoref{eq:thin_cond} to the right hand side of the equation,  yields a
system of $n$ equations which can be solved algebraically to find the vorticity of each vortex element.
Once the vorticity $\Gamma_j$ is know for each vortex element, the change in lift and
pressure are obtained using \autoref{eq:thin_lift} and \autoref{eq:thin_press} respectively.
 $s_i$ is the length of the $i-$th panel.

\begin{equation}
\label{eq:thin_lift}
\Delta L_i = \rho v_\infty \Gamma_{j=i}
\end{equation}
\begin{equation}
\label{eq:thin_press}
\Delta P_i = \rho v_\infty \frac{\Gamma_{j=i}}{s_i}
\end{equation}

\subsection{Verification}
The results of the zero-thickness camberline panel method are verified by
comparison with example data from \citeauthor{katz_plotkin} for an elliptical
camberline with a maximum camber of $0.1$. Since Naca 4-digit airfoils are
limited to a maximum camber of $0.09$, the Naca 9501 is used to approximate that
same airfoil. Both the reference plot and obtained plot are shown in \autoref{fig:verif_thin}.

% ###########################################################################################
% ###########################################################################################

\section{Panelled Airfoil Surface}
\label{sec:thick}
The second method, described by \citeauthor{katz_plotkin}\cite{katz_plotkin},
and \citeauthor{kuethe_chow_1998}\cite{kuethe_chow_1998}, places constant vortex
elements on in the center of panels on the airfoils surface. The airfoil is
discritized by placing $n$ nodes on the airfoil starting at the trailing edge,
over the lower airfoil surface to the leading edge and back to the trailing edge
over the upper surface. Each node presents a panel edge, so there are $n$
panels. The same naming scheme as used in \autoref{sec:thin} applies here too.
Note that the method is explained using the equations from
\citeauthor{katz_plotkin}\cite{katz_plotkin}, as it is easier to see what they
represent than the version from
\citeauthor{kuethe_chow_1998}\cite{kuethe_chow_1998}, which breaks everything
down in coefficients. The code, however, implements the coefficient equations
from \citeauthor{kuethe_chow_1998}\cite{kuethe_chow_1998} as they are slightly
easier to implement.

\subsection{Equations}
\label{ssec:eq_thick}
The boundary condition in this case states that the inner tangential velocity
must be zero, as described by \autoref{eq:thick_cond}\cite{katz_plotkin}.
Naturally there can be no airflow inside the airfoil itself. Alternatively, also
the zero normal flow boundary condition could here be used again
\cite{kuethe_chow_1998}. The Kutta-condition, shown in \autoref{eq:kutta}, is
added to ensure smooth flow transition to freestream at the trailing adge.

\begin{equation}
\label{eq:thick_cond}
    \left( U_\infty + u_i, \: W_\infty + w_i \right) \cdot \left( \cos \alpha_i,
    \: -\sin \alpha_i \right) = 0
\end{equation}
\begin{equation}
  \label{eq:kutta}
      \gamma_1 + \gamma_{n} = 0
\end{equation}

The induced velocity, $\gamma_j$, in a collocation point at $(x_i,\: y_i)$ due
to $n$ vortices located at $(x_j, \: y_j)$ is obtained using
\autoref{eq:v_ind_thick}. Here $(x_j, \: y_j)$ is also the panel's leading edge
node, so $(x_{j+1}, \: y_{j+1})$ refer to the panel's trailing edge node.
Substituting \autoref{eq:v_ind_thick} in \autoref{eq:thick_cond} and applying it
to every collocation point present will yield a system of $n$ equations which
can be solved for the vorticities $\gamma_j$.

\begin{equation}
\label{eq:v_ind_thick}
    \left(\begin{array}{l}
    u_{p_i} \\ w_{p_i}
    \end{array}\right)
    =
    \sum_{j=1}^{n} \:
    \left(\begin{array}{c}
    \frac{\gamma_j}{2\pi}\left[ \tan^{-1} \left(
        \frac{z_i - z_{j+1}}{x_i - x_{j+1}}\right)
         - \tan^{-1} \left( \frac{z_i - z_j}{x_i - x_j}\right) \right] \\[1em]
    -\frac{\gamma_j}{4\pi} \ln \left[ \frac{\left( x_i - x_j \right)^2 +
    \left( z_i - z_j \right)^2}{\left( x_i - x_{j+1}\right)^2 +
    \left( z_i - z_{j+1} \right)^2 }  \right]
    \end{array}\right), \; \; \; \; \; \forall \; i \in \{1,...,n\}
\end{equation}
\medskip

Once that the results of \autoref{eq:v_ind_thick} are in the local panel
coordinate system and must be transformed back to the global one. Adding
\autoref{eq:kutta} to the system of equations obtained from
\autoref{eq:v_ind_thick}, will result in n+1 equations.
\citeauthor{katz_plotkin}\cite{katz_plotkin} deals with this by replacing an
arbetrary equation from the system with the Kutta condition, while
\citeauthor{kuethe_chow_1998}\cite{kuethe_chow_1998} adds an equation, where the
Kutta condition is altered as shown in \autoref{eq:kutta2}. Either way results
in again an equal amount of equations and unknowns.

\begin{equation}
  \label{eq:kutta2}
      \gamma_1 + \gamma_{n+1} = 0
  \end{equation}

Once the vorticity $\gamma_j$ is know for each vortex element, the change in
lift and pressure are obtained using \autoref{eq:thick_lift} and
\autoref{eq:thick_press} respectively.

\begin{equation}
\label{eq:thick_lift}
\Delta L_i = \rho v_\infty \gamma_{j=i} s_j
\end{equation}
\medskip
\begin{equation}
\label{eq:thick_press}
\Delta Cp = 1 - \left( \cos{\alpha+\alpha_i} + \frac{ \gamma_{j=i} }{ 2 v_\infty } \right)
\end{equation}
\medskip

To facilitate the implementation of \autoref{eq:v_ind_thick}, the coefficient
breakdown version by \citeauthor{kuethe_chow_1998} was used in the actual code
for this problem.

\subsection{verification}
The constant vortex method with panelled airfoil surface is validated with data
obtained from XFOIL\cite{xfoil}. The pressure distribution found for the
NACA4412 airfoil is shown in \autoref{fig:thick_verif}.
\autoref{fig:thick_verif1} and \autoref{fig:thick_verif2} show the results for
the NACA4412 at 0 and 10 degrees angle of attack respectively. It can be seen
that the results coincide almost perfectly, the only exception being at zero
angle of attack, where the calculated pressure coefficient near the leading edge
on the bottom surface is slightly higher compared to the reference data. A
second verification was performed, results from which are plotted in
\autoref{fig:thick_verif3}, his time using the NACA0012 airfoil. Again, the
only descripencies are at the leading edge, where the program slightly
underestimates the underpressure on the top surface. Note that
\autoref{fig:thick_verif4} shows the pressure distribution over the NACA0012
airfoil at 3 degrees angle of attack (instead of zero degrees like in
\autoref{fig:thick_verif1}), since the symmetric airfoil at zero angle of attack
has equal pressure on top and bottom surfaces, resulting in a simple line plot.

\begin{figure}[h]
    \centering
    \begin{subfigure}{.5\textwidth}
      \centering
      \includegraphics[width=.9\linewidth]{static/naca4412_0_verif_thick.png}
      \caption{Pressure distribution NACA4412 at $\alpha = 0^{\circ}$}
      \label{fig:thick_verif1}
    \end{subfigure}%
    \begin{subfigure}{.5\textwidth}
      \centering
      \includegraphics[width=.9\linewidth]{static/naca4412_verif_thick.png}
      \caption{Pressure distribution NACA4412 at $\alpha = 10^{\circ}$}
      \label{fig:thick_verif2}
    \end{subfigure}
    \caption{\centering Validation of panelled airfoil method results for NACA4412 with XFOIL\cite{xfoil}}
    \label{fig:thick_verif}
\end{figure}

\begin{figure}[h]
    \centering
    \begin{subfigure}{.5\textwidth}
      \centering
      \includegraphics[width=.9\linewidth]{static/naca0012_0_verif_thick.png}
      \caption{Pressure distribution NACA0012 at $\alpha = 3^{\circ}$}
      \label{fig:thick_verif4}
    \end{subfigure}%
    \begin{subfigure}{.5\textwidth}
      \centering
      \includegraphics[width=.9\linewidth]{static/naca0012_verif_thick.png}
      \caption{Pressure distribution NACA0012 at $\alpha = 10^{\circ}$}
      \label{fig:thick_verif5}
    \end{subfigure}
    \caption{\centering Validation of panelled airfoil method results for NACA0012 with XFOIL\cite{xfoil}}
    \label{fig:thick_verif3}
\end{figure}

Looking at the resulting estimation for $C_l$, shown in \autoref{tab:cl_thick},
it can be seen that the calculated values for the lift coefficient are slightly
below the values returned by XFOIL. For the NACA0012, the relative error
$\epsilon$ is zero for $\alpha=0$, and increases with angle of attack. When
$\alpha=10\deg$, the error has risen to $\epsilon=-3.51\%$ (the minus indication
the obtained values is lower than the one returned by XFOIL). The same is true
for the NACA4412 results, where the errro $\epsilon$ is lowest when $\alpha$ is
zero, and increases with increasing angle of attack. The value of the error si
lower, however, than for the symmetrical airfoil, having a value of
$\epsilon=-2.07\%$ at $\alpha=10\deg$. These results are also shown as plots in \autoref{fig:cl_thick}

\begin{table}[H]
	\centering
	\caption{Estimated values of $C_l$ for a range of angles of attack from XFOIL and NumFoil, as well as the relative error, for NACA0012 and NACA4412.}
	\label{tab:cl_thick}
    \begin{tabularx}{\textwidth}{C  C C C | C C C} %'L' for Left Aligned, 'C' for Centered, 'R' for Right Aligned
    \toprule\
    \hfill & \multicolumn{3}{c}{$C_l$ NACA0012} & \multicolumn{3}{c}{$C_l$ NACA4412} \\ \toprule
    {$\alpha \:[\deg]$} & {$NumFoil$} & {$XFOIL$} & {$\epsilon$} & {$NumFoil$} & {$XFOIL$} & {$\epsilon$} \\ \toprule
    0   & 0        & 0      & 0         & 0.5100 & 0.5109  & +0.0018    \\ \hdashline
    3   & 0.3623   & 0.3583 & -0.0110   & 0.8715 & 0.8634  & -0.0093    \\ \hdashline
    5   & 0.6034   & 0.5952 & -0.0136   & 1.1113 & 1.0983  & -0.0117    \\ \hdashline
    8   & 0.9635   & 0.9449 & -0.0193   & 1.4683 & 1.4474  & -0.0209    \\ \hdashline%\midrule
    10  & 1.2022   & 1.1724 & -0.0248   & 1.7041 & 1.6764  & -0.0162    \\ \hdashline
    13  & 1.55743  & 1.5027 & -0.0351   & 2.0539 & 2.0114  & 0.0207     \\ \bottomrule
    \end{tabularx}
\end{table}

\begin{figure}[h]
  \centering
  \begin{subfigure}{.5\textwidth}
    \centering
    \captionsetup{width=.8\linewidth}
    \includegraphics[width=.9\linewidth]{static/naca0012_cl_verif.png}
    \caption{\centering $C_l - \alpha$ plots for NACA0012}
    \label{fig:cl_thick_0012}
  \end{subfigure}\hfill% or \hspace{5mm} or \hspace{0.3\textwidth}
  \begin{subfigure}{.5\textwidth}
    \centering
    \captionsetup{width=.9\linewidth}
    \includegraphics[width=.9\linewidth]{static/naca4412_cl_verif.png}
    \caption{\centering $C_l - \alpha$ plots for NACA0012}
    \label{fig:cl_thick_4412}
  \end{subfigure}
  \caption{\centering Comparing  $C_l - \alpha$ with results from XFOIL for NACA0012 and NACA4412}
  \label{fig:cl_thick}
\end{figure}

% ###########################################################################################
% ###########################################################################################
\chapter{Analysis}
Now that the program is validated, the different aspects of airfoils can be
looked at. First, the effect of camber is discussed in \autoref{sec:camber}.
Next, the change in results due to varying panel thickness is evaluated in
\autoref{sec:thickness}, and, finally, the effect of panel density on the
obtained results is checked in \autoref{sec:panels}.

\section{Effect of Camber}
\label{sec:camber}
To see the effect of varying camber on the results, both the panelled
comaberline and panelled surface methods will be used on airfoils a set of
airfoils (see \autoref{fig:camber}) where the only the camber value is
different. The first one, NACA0012, is a symmetrical airfoil and thus has zero
camber. Subsequent airfoils NACA2412, NACA4412, and NACA9412 have a respective
maximum camber of 0.2, 0.4, and 0.9 at $\frac{x}{c}=0.4$. \autoref{fig:camber1}
plot these airfoils' pressure distributions for $\alpha=3$, and
\autoref{fig:camber2} does the same for $\alpha=8$.

\begin{figure}[h]
    \centering
    \begin{subfigure}{.5\textwidth}
      \centering
      \captionsetup{width=.8\linewidth}
      \includegraphics[width=.9\linewidth]{static/camber_a3.png}
      \caption{\centering Pressure distributions with varying camber at $\alpha = 3^{\circ}$}
      \label{fig:camber1}
    \end{subfigure}\hfill% or \hspace{5mm} or \hspace{0.3\textwidth}
    \begin{subfigure}{.5\textwidth}
      \centering
      \captionsetup{width=.9\linewidth}
      \includegraphics[width=.9\linewidth]{static/camber_a8.png}
      \caption{\centering Pressure distributions with varying camber at $\alpha = 8^{\circ}$}
      \label{fig:camber2}
    \end{subfigure}
    \caption{\centering Plots showing the effect of camber on the pressure distribution}
    \label{fig:camber}
\end{figure}

Clearly, a higher camber value leads to higher local values for the pressure
coefficient. This means the plotted lines representing the $C_p$ of the upper
and lower surfaces lie further appart. This increase in pressure difference in
turn results in a higher value for the lift coefficients. The increase of $C_P$
with camber is not linear. It can be seen that at high values for camber, the
increase of pressure coefficients with camber is higher than for low camber.

The same is true for $C_l$, as shown in \autoref{fig:cambercl}. For different
angles of attack, the $C_l$ is plotted as a function of camber for two airfoil
series: \autoref{fig:cambercl1} shows the $C_l$ variations for NACA4X12, where X
is the camber value$x10$, and \autoref{fig:cambercl2} shows the $C_l$ variations
for NACA2X22. Angle of attack clearly has no effect on how much the camber
increases the lift coefficient, as the lines of different values for $\alpha$
ahave equal gradients for every camber value.

\begin{figure}[h]
    \centering
    \begin{subfigure}{.5\textwidth}
      \centering
      \captionsetup{width=.8\linewidth}
      \includegraphics[width=.9\linewidth]{static/cambereffect_thick.png}
      \caption{\centering Variation of $C_l$ with camber for NACA4X12}
      \label{fig:cambercl1}
    \end{subfigure}\hfill% or \hspace{5mm} or \hspace{0.3\textwidth}
    \begin{subfigure}{.5\textwidth}
      \centering
      \captionsetup{width=.9\linewidth}
      \includegraphics[width=.9\linewidth]{static/cambereffect2_thick.png}
      \caption{\centering Variation of $C_l$ with camber for NACA2X22}
      \label{fig:cambercl2}
    \end{subfigure}
    \caption{\centering Variation of $C_l$ with increasing camber for different angles of attack. The X in the NACA codes is the camber which is varied.}
    \label{fig:cambercl}
\end{figure}

\section{Effect of Airfoil Thickness}
\label{sec:thickness}

For the lumped vortex method, with a panelled camberline, as discussed in
\autoref{sec:thin}, the thickness will not have any effect on the results. This
method only looks at the camberline, and ignores the airfoil's thickness.
Instead, only the constant vortex method with panelled airfoil surfaces from
\autoref{sec:thick} can be used for this. Again, results for symmetric
(NACA00XX) and cambered airfoils (NACA44XX) are plotted in
\autoref{fig:thickcp1} and \autoref{fig:thickcp2} respectively. The angle of
attack is constant for all cases: $\alpha = 5^{\circ}$. The pressure
distributions show that an increase in thickness reduces the suction peak on the
leading edge, while increasing the pressure deferential over the rest of the
airfoil, leading to a net increase in lift. This is confirmed by looking at the
change of $C_l$ with increasing thicness, shown in \autoref{fig:thickcl}.
Comparing the results for a symmetric airfoil (\autoref{fig:thickcl1}) with
those for a cambered airfoil (\autoref{fig:thickcl2}), shows that the increase
in lift for a cambered airfoil is greater than for a symmetric airfoil if the
thickness is increased. This can be seen by the slightly larger gradients in
\autoref{fig:thickcl2}, compared to \autoref{fig:thickcl1}.

\begin{figure}[h]
  \centering
  \begin{subfigure}{.5\textwidth}
    \centering
    \captionsetup{width=.8\linewidth}
    \includegraphics[width=.9\linewidth]{static/thickness_effect_00xx.png}
    \caption{\centering Pressure distributions with varying thickness for a symmetric airfoil}
    \label{fig:thickcp1}
  \end{subfigure}\hfill% or \hspace{5mm} or \hspace{0.3\textwidth}
  \begin{subfigure}{.5\textwidth}
    \centering
    \captionsetup{width=.9\linewidth}
    \includegraphics[width=.9\linewidth]{static/thickness_effect_44xx.png}
    \caption{\centering Pressure distributions with varying thickness for a cambered airfoil}
    \label{fig:thickcp2}
  \end{subfigure}
  \caption{\centering Effect of thickness on the pressure distribution for a cambered and symmetric airfoil at $\alpha = 5^{\circ}$.}
  \label{fig:thickcp}
\end{figure}

\begin{figure}[h]
  \centering
  \begin{subfigure}{.5\textwidth}
    \centering
    \captionsetup{width=.8\linewidth}
    \includegraphics[width=.9\linewidth]{static/thickness_Cl_effect_00xx.png}
    \caption{\centering $C_l$ values for varying thickness for a symmetric airfoil (NACA00XX)}
    \label{fig:thickcl1}
  \end{subfigure}\hfill% or \hspace{5mm} or \hspace{0.3\textwidth}
  \begin{subfigure}{.5\textwidth}
    \centering
    \captionsetup{width=.9\linewidth}
    \includegraphics[width=.9\linewidth]{static/thickness_Cl_effect_44xx.png}
    \caption{\centering $C_l$ values for with varying thickness for a cambered airfoil (NACA44XX)}
    \label{fig:thickcl2}
  \end{subfigure}
  \caption{\centering Effect of thickness on the $C_l$ for a cambered and symmetric airfoil at different angles of attack.}
  \label{fig:thickcl}
\end{figure}

\section{Effect of Panel Density}
\label{sec:panels}
Varying the panel density of course will also vary the fidelity of the analysis.
\autoref{fig:thick_panels} shows the effect of increasing the amount of panels
on $C_l$ (with $\alpha = 5^{\circ}$), for a symmetric (\autoref{fig:thick_panels1}) and a cambered
(\autoref{fig:thick_panels2}) airfoil. The choice was made to consider values
with a relative error lower than 0.5\%, compared to values from XFOIL, are
adequate. To satisfy this requirement, 98 panels are needed for the symmetric
airfoil and 102 are required for the cambered airfoil. From this it can be
concluded that, to obtain adequately accurate values, at no less than 100 panels
should be used at all times.

\begin{figure}[h]
  \centering
  \begin{subfigure}{.5\textwidth}
    \centering
    \captionsetup{width=.8\linewidth}
    \includegraphics[width=.9\linewidth]{static/conv_thick_sym.png}
    \caption{For the NACA0012 at $\alpha = 5^{\circ}$, results are within 0.5\% of XFOIL with 98 panels}
    \label{fig:thick_panels1}
  \end{subfigure}%
  \begin{subfigure}{.5\textwidth}
    \centering
    \captionsetup{width=.8\linewidth}
    \includegraphics[width=.9\linewidth]{static/conv_thick.png}
    \caption{For the NACA4412 at $\alpha = 5^{\circ}$, results are within 0.5\% of XFOIL with 102 panels}
    \label{fig:thick_panels2}
  \end{subfigure}
  \caption{\centering Convergence of results with increasing panel density}
  \label{fig:thick_panels}
\end{figure}


\documentclass{warpdoc}
\newlength\lengthfigure                  % declare a figure width unit
\setlength\lengthfigure{0.158\textwidth} % make the figure width unit scale with the textwidth
\usepackage{psfrag}         % use it to substitute a string in a eps figure
\usepackage{subfigure}
\usepackage{rotating}
\usepackage{pstricks}
\usepackage[innercaption]{sidecap} % the cute space-saving side captions
\usepackage{scalefnt}
\usepackage{amsbsy}
\usepackage{bm}
\usepackage{amsmath}

%%%%%%%%%%%%%=--NEW COMMANDS BEGINS--=%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\alb}{\vspace{0.1cm}\\} % array line break
\newcommand{\mfa}{\scriptscriptstyle}
\newcommand{\mfb}{\scriptstyle}
\newcommand{\mfc}{\textstyle}
\newcommand{\mfd}{\displaystyle}
\newcommand{\hlinex}{\vspace{-0.34cm}~~\\ \hline \vspace{-0.31cm}~~\\}
\newcommand{\hlinextop}{\vspace{-0.46cm}~~\\ \hline \hline \vspace{-0.32cm}~~\\}
\newcommand{\hlinexbot}{\vspace{-0.37cm}~~\\ \hline \hline \vspace{-0.50cm}~~\\}
\newcommand{\tablespacing}{\vspace{-0.4cm}}
\newcommand{\fontxfig}{\footnotesize\scalefont{0.918}}
\newcommand{\fontgnu}{\footnotesize\scalefont{0.896}}
\renewcommand{\fontsizetable}{\footnotesize\scalefont{1.0}}
\renewcommand{\fontsizefigure}{\footnotesize}
%\renewcommand{\vec}[1]{\pmb{#1}}
%\renewcommand{\vec}[1]{\boldsymbol{#1}}
\renewcommand{\vec}[1]{\bm{#1}}
\setcounter{tocdepth}{3}
\let\citen\cite
\newcommand\frameeqn[1]{\fbox{$\displaystyle #1$}}

%%%%%%%%%%%%%=--NEW COMMANDS BEGINS--=%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setcounter{tocdepth}{3}

%%%%%%%%%%%%%=--NEW COMMANDS ENDS--=%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\author{
  Bernard Parent
}

\email{
  bernparent@gmail.com
}

\department{
  Department of Aerospace Engineering
}

\institution{
  Pusan National University
}

\title{
  Flux Integration on Interface
}

\date{
  2019
}

%\setlength\nomenclaturelabelwidth{0.13\hsize}  % optional, default is 0.03\hsize
%\setlength\nomenclaturecolumnsep{0.09\hsize}  % optional, default is 0.06\hsize

\nomenclature{

  \begin{nomenclaturelist}{Roman symbols}
   \item[$a$] speed of sound
  \end{nomenclaturelist}
}

\abstract{
abstract
}

\begin{document}
  \pagestyle{headings}
  \pagenumbering{arabic}
  \setcounter{page}{1}
%%  \maketitle
  \makewarpdoctitle
%  \makeabstract
  \tableofcontents
%  \makenomenclature
%%  \listoftables
%%  \listoffigures

\section{Third Order Central}

Let's say we wish to find the integral of the flux at the $i+1/2$ interface between two nodes. The integral should be performed from $\eta=-1/2$ to $\eta=1/2$. We know the fluxes $F_{i+1/2,j}$ at $\eta=0$, $F_{i+1/2,j+1}$ at $\eta=1$, and $F_{i+1/2,j-1}$ at $\eta=-1$, as determined through a standard WENO interpolation \cite{jcp:1994:liu}
 of the primitives reconstructed over a FDS \cite{jcp:1981:roe} or FVS flux. Now, let's fit a second-order polynomial through the fluxes:
%
\begin{equation}
F_{i+1/2}=c_1 \eta^2 + c_2 \eta + c_3
\end{equation}
%
Find the coefficients $c_1$, $c_2$, $c_3$ by making sure $F_{i+1/2}$ goes through the three $F$s. First, at $\eta=0$, $F_{i+1/2}=F_{i+1/2,j}$:
%
\begin{equation}
c_3=F_{i+1/2,j}
\end{equation}
%
Second, at $\eta=1$, $F_{i+1/2}=F_{i+1/2,j+1}$:
%
\begin{equation}
F_{i+1/2,j+1}=c_1  + c_2  + F_{i+1/2,j}
\end{equation}
%
Third, at $\eta=-1$, $F_{i+1/2}=F_{i+1/2,j-1}$:
%
\begin{equation}
F_{i+1/2,j-1}=c_1  - c_2  + F_{i+1/2,j}
\end{equation}
%
Add the latter two equations and isolate $c_1$:
%
\begin{equation}
c_1=\frac{F_{i+1/2,j+1}+F_{i+1/2,j-1}}{2}- F_{i+1/2,j}
\end{equation}
%
Substitute the latter in the former and isolate $c_2$:
%
\begin{equation}
c_2=\frac{F_{i+1/2,j+1}+F_{i+1/2,j-1}}{2} -F_{i+1/2,j-1}
\end{equation}
%
Now that $c_1$, $c_2$, and $c_3$ are known, we can integrate the flux from $\eta=-1/2$ to $\eta=1/2$ to obtain the integrated flux $\overline{F}_{i+1/2}$:
%
\begin{equation}
\overline{F}_{i+1/2}=\int_{\eta=-1/2}^{\eta=1/2} F_{i+1/2} d\eta
\end{equation}
%
%
\begin{equation}
\overline{F}_{i+1/2}=\int_{\eta=-1/2}^{\eta=1/2} (c_1 \eta^2 + c_2 \eta + c_3 ) d\eta
\end{equation}
%
Noting that $c_1$, $c_2$, $c_3$ do not depend on $\eta$:
%
\begin{equation}
\overline{F}_{i+1/2}=\left(\frac{1}{3}c_1 \eta^3 + \frac{1}{2} c_2 \eta^2 + c_3 \eta\right)_{\eta=-1/2}^{\eta=1/2}
\end{equation}
%
or
%
\begin{equation}
\overline{F}_{i+1/2}=\frac{1}{24}c_1  + \frac{1}{8} c_2  + c_3 \frac{1}{2}
+\frac{1}{24}c_1  - \frac{1}{8} c_2  + \frac{1}{2} c_3
\end{equation}
%
Simplify:
%
\begin{equation}
\overline{F}_{i+1/2}=\frac{1}{12}c_1   + c_3
\end{equation}
%
Substitute $c_1$ and $c_3$ from previous expressions in the latter:
%
\begin{equation}
\overline{F}_{i+1/2}=\frac{1}{12}\left(\frac{F_{i+1/2,j+1}+F_{i+1/2,j-1}}{2}- F_{i+1/2,j} \right)   + F_{i+1/2,j}
\end{equation}
%
Simplify:
%
\begin{equation}
\frameeqn{
\overline{F}_{i+1/2}=\frac{1}{24} F_{i+1/2,j+1}+ \frac{1}{24}F_{i+1/2,j-1}   + \frac{11}{12}F_{i+1/2,j}
}
\label{eqn:Finteg_central3}
\end{equation}
%

\section{Fifth Order Central}

Let's fit a fourth-order polynomial through the fluxes:
%
\begin{equation}
F_{i+1/2}=c_1 \eta^4 + c_2 \eta^3 + c_3 \eta^2 + c_4 \eta + c_5
\label{eqn:central5a}
\end{equation}
%
Find the coefficients $c_1$, $c_2$, $c_3$, $c_4$, and $c_5$ by making sure $F_{i+1/2}$ goes through the three $F$s. First, at $\eta=0$, $F_{i+1/2}=F_{i+1/2,j}$:
%
\begin{equation}
c_5=F_{i+1/2,j}
\label{eqn:central5_c5}
\end{equation}
%
Second, at $\eta=1$, $F_{i+1/2}=F_{i+1/2,j+1}$:
%
\begin{equation}
F_{i+1/2,j+1}=c_1  + c_2  + c_3  + c_4  + c_5
\label{eqn:central5c}
\end{equation}
%
Third, at $\eta=-1$, $F_{i+1/2}=F_{i+1/2,j-1}$:
%
\begin{equation}
F_{i+1/2,j-1}=c_1  - c_2  + c_3  - c_4  + c_5
\label{eqn:central5d}
\end{equation}
%
Fourth, at $\eta=2$, $F_{i+1/2}=F_{i+1/2,j+2}$:
%
\begin{equation}
F_{i+1/2,j+2}= 16 c_1 + 8 c_2 + 4 c_3 + 2 c_4 + c_5
\label{eqn:central5e}
\end{equation}
%
Fifth, at $\eta=-2$, $F_{i+1/2}=F_{i+1/2,j-2}$:
%
\begin{equation}
F_{i+1/2,j-2}= 16 c_1 - 8 c_2 + 4 c_3 - 2 c_4 + c_5
\label{eqn:central5f}
\end{equation}
%
Add the former two equations and the latter two equations:
%
\begin{equation}
F_{i+1/2,j-1}+F_{i+1/2,j+1} = 2 c_1    + 2 c_3   + 2 c_5
\label{eqn:central5g}
\end{equation}
%
%
\begin{equation}
F_{i+1/2,j-2}+F_{i+1/2,j+2} = 32 c_1  + 8 c_3  + 2 c_5
\label{eqn:central5h}
\end{equation}
%
Substitute $c_5=F_{i+1/2,j}$:
%
\begin{equation}
F_{i+1/2,j-1}- 2 F_{i+1/2,j}+F_{i+1/2,j+1} = 2 c_1    + 2 c_3
\label{eqn:central5i}
\end{equation}
%
%
\begin{equation}
F_{i+1/2,j-2}- 2 F_{i+1/2,j}+F_{i+1/2,j+2} = 32 c_1  + 8 c_3
\label{eqn:central5j}
\end{equation}
%

Multiply Eq.\ (\ref{eqn:central5i}) by -4 and add to Eq.\ (\ref{eqn:central5j}):
%
\begin{equation}
 c_1= \frac{+F_{i+1/2,j-2} -4 F_{i+1/2,j-1}+ 6 F_{i+1/2,j} -4 F_{i+1/2,j+1} +F_{i+1/2,j+2}}{24}
\label{eqn:central5_c1}
\end{equation}
%
Multiply Eq.\ (\ref{eqn:central5i}) by -16 and add to Eq.\ (\ref{eqn:central5j}):
%
\begin{equation}
c_3=\frac{+ F_{i+1/2,j-2} -16 F_{i+1/2,j-1}+ 30 F_{i+1/2,j} -16 F_{i+1/2,j+1}
+F_{i+1/2,j+2}}{24}
\label{eqn:central5_c3}
\end{equation}
%

Now that $c_1$, $c_3$, and $c_5$ are known, we can integrate the flux from $\eta=-1/2$ to $\eta=1/2$ to obtain the integrated flux $\overline{F}_{i+1/2}$:
%
\begin{equation}
\overline{F}_{i+1/2}=\int_{\eta=-1/2}^{\eta=1/2} F_{i+1/2} d\eta
\end{equation}
%
or
%
\begin{equation}
\overline{F}_{i+1/2}=\int_{\eta=-1/2}^{\eta=1/2} \left( c_1 \eta^4 + c_2 \eta^3 + c_3 \eta^2 + c_4 \eta + c_5 \right) d\eta
\end{equation}
%
Noting that $c_1$, $c_2$, $c_3$ do not depend on $\eta$:
%
\begin{equation}
\overline{F}_{i+1/2}= \left[ \frac{c_1}{5} \eta^5 + \frac{c_2}{4} \eta^4 + \frac{c_3}{3} \eta^3 + \frac{c_4}{2} \eta^2 + c_5 \eta \right]_{\eta=-1/2}^{\eta=1/2}
\end{equation}
%
or
%
\begin{equation}
\overline{F}_{i+1/2}=  \frac{c_1}{80}  + \frac{c_3}{12}   + c_5
\end{equation}
%
Substitute $c_1$ and $c_3$ in the latter:
%
\begin{align}
\overline{F}_{i+1/2}= & \frac{+F_{i+1/2,j-2} -4 F_{i+1/2,j-1}+ 6 F_{i+1/2,j} -4 F_{i+1/2,j+1} +F_{i+1/2,j+2}}{24\times 80}\nonumber\\
 &+ \frac{+ F_{i+1/2,j-2} -16 F_{i+1/2,j-1}+ 30 F_{i+1/2,j} -16 F_{i+1/2,j+1} +F_{i+1/2,j+2}}{24\times 12}
 + F_{i+1/2,j}
\end{align}
%
Put all terms under a common denominator:
%
\begin{align}
\overline{F}_{i+1/2}= & \frac{+3 F_{i+1/2,j-2} -12 F_{i+1/2,j-1}+ 18 F_{i+1/2,j} - 12 F_{i+1/2,j+1} +3F_{i+1/2,j+2}}{24\times 240}\nonumber\\
 &+ \frac{+ 20 F_{i+1/2,j-2} -320 F_{i+1/2,j-1}+ 600 F_{i+1/2,j} -320 F_{i+1/2,j+1} +20 F_{i+1/2,j+2}}{24\times 240}
 + \frac{ 5760 F_{i+1/2,j}}{24\times 240}
\end{align}
%
Regroup:
%
\begin{equation}
\frameeqn{
\overline{F}_{i+1/2}=  \frac{+23 F_{i+1/2,j-2} -332 F_{i+1/2,j-1}+ 6378 F_{i+1/2,j} - 332 F_{i+1/2,j+1} + 23 F_{i+1/2,j+2}}{5760}
}
\label{eqn:Finteg_central5}
\end{equation}
%
Also, can find $c_2$ and $c_4$ by subtracting (\ref{eqn:central5d}) from (\ref{eqn:central5c}) and subtracting (\ref{eqn:central5f}) from (\ref{eqn:central5e}):
%
\begin{equation}
F_{i+1/2,j+1}-F_{i+1/2,j-1}=2 c_2    + 2 c_4
\label{eqn:central5k}
\end{equation}
%
%
\begin{equation}
F_{i+1/2,j+2}-F_{i+1/2,j-2}=  16 c_2  + 4 c_4
\label{eqn:central5l}
\end{equation}
%
Multiply (\ref{eqn:central5k}) by $-2$ and add it to (\ref{eqn:central5l}):
%
\begin{equation}
c_2=\frac{F_{i+1/2,j+2}-F_{i+1/2,j-2}-2F_{i+1/2,j+1}+2F_{i+1/2,j-1}}{12}
\label{eqn:central5_c2}
\end{equation}
%
Multiply (\ref{eqn:central5k}) by $-8$ and add it to (\ref{eqn:central5l}):
%
\begin{equation}
c_4=\frac{-8F_{i+1/2,j+1}+8F_{i+1/2,j-1}+F_{i+1/2,j+2}-F_{i+1/2,j-2}}{-12}
\label{eqn:central5_c4}
\end{equation}
%

\section{3rd-5th Adaptive Order WENO}

First find the indicator of smoothness for the 3rd order and 5th order central stencils. We define the indicator of smoothness $\beta$  as follows:
%
\begin{equation}
\beta = \sum_m (\Delta \eta)^{2m-1} \int_{\eta=-0.5}^{\eta=0.5} \left( \frac{d^m F_{i+1/2}}{d\eta^m} \right)^2 d\eta
\end{equation}
%
But $\Delta \eta=1$:
%
\begin{equation}
\beta = \sum_m  \int_{\eta=-0.5}^{\eta=0.5} \left( \frac{d^m F_{i+1/2}}{d\eta^m} \right)^2 d\eta
\end{equation}
%
Now let us find the indicator of smoothness for the 3-point central stencil, $\beta_3$.
%
\begin{equation}
\beta_3 =   \int_{\eta=-0.5}^{\eta=0.5} \sum_{m=1}^2 \left(  \frac{d^m }{d\eta^m}\left(c_{31} \eta^2 + c_{32} \eta + c_{33}
\right) \right)^2 d\eta
\end{equation}
%
%
\begin{equation}
\beta_3 =   \int_{\eta=-0.5}^{\eta=0.5}  \left(\left(  2 c_{31} \eta + c_{32}
\right)^2 +  \left(  2 c_{31}
\right)^2 \right) d\eta
\end{equation}
%
or
%
\begin{equation}
\beta_3 =   \int_{\eta=-0.5}^{\eta=0.5}  \left(  4 c_{31}^2 \eta^2 + c_{32}^2 + 4 c_{31} c_{32} \eta  +   4 c_{31}^2
 \right) d\eta
\end{equation}
%
integrate:
%
\begin{equation}
\beta_3 =     \left[  \frac{4}{3} c_{31}^2 \eta^3 + c_{32}^2 \eta + 2 c_{31} c_{32} \eta^2  +   4 c_{31}^2 \eta
 \right]_{\eta=-0.5}^{\eta=0.5}
\end{equation}
%
or
%
\begin{equation}
\frameeqn{
\beta_3 =     \frac{13}{3} c_{31}^2  + c_{32}^2
}
\end{equation}
%
where
%
\begin{equation}
c_{31}=\frac{F_{i+1/2,j+1}+F_{i+1/2,j-1}}{2}- F_{i+1/2,j}
\end{equation}
%
%
\begin{equation}
c_{32}=\frac{F_{i+1/2,j+1}+F_{i+1/2,j-1}}{2} -F_{i+1/2,j-1}
\end{equation}
%

Second, let us find the smoothness indicator for the 5th order stencil.
%
\begin{equation}
\beta_5 =   \int_{\eta=-0.5}^{\eta=0.5} \sum_{m=1}^4 \left(  \frac{d^m }{d\eta^m}\left(c_{51} \eta^4 + c_{52} \eta^3 + c_{53} \eta^2 + c_{54} \eta + c_{55}
\right) \right)^2 d\eta
\end{equation}
%
Expand the sum:
%
\begin{equation}
\beta_5 =   \int_{\eta=-0.5}^{\eta=0.5}  \left(  \left(4 c_{51} \eta^3 + 3 c_{52} \eta^2 + 2 c_{53} \eta + c_{54}
\right)^2 + \left(12 c_{51} \eta^2 + 6 c_{52} \eta + 2 c_{53}
\right)^2 + \left(24 c_{51} \eta + 6 c_{52} \right)^2 + \left(24 c_{51}  \right)^2 \right) d\eta
\end{equation}
%
Integrate with mathematica:
%f = (4 c1 eta^3 + 3 c2 eta^2 + 2 c3 eta + c4 )^2 + (12 c1 eta^2 +
%     6 c2 eta + 2 c3 )^2 + (24 c1 eta + 6 c2 )^2 + (24 c1 )^2
%B = Simplify[Integrate[f, {eta, -1/2, 1/2}]]
%
\begin{equation}
\frameeqn{
\beta_5 =   \frac{87617}{140}c_{51}^2+ \frac{3129}{80}c_{52}^2 + \frac{21}{5}c_{51} c_{53} + \frac{13}{3} c_{53}^2 + \frac{1}{2}c_{52} c_{54} + c_{54}^2
}
\end{equation}
%
where the constants $c_{51}$, $c_{52}$, etc can be obtained from Eqs.\ (\ref{eqn:central5_c1}), (\ref{eqn:central5_c2}), (\ref{eqn:central5_c3}), (\ref{eqn:central5_c4}):
%
\begin{equation}
 c_{51}= \frac{+F_{i+1/2,j-2} -4 F_{i+1/2,j-1}+ 6 F_{i+1/2,j} -4 F_{i+1/2,j+1} +F_{i+1/2,j+2}}{24}
\end{equation}
%
%
\begin{equation}
c_{52}=\frac{F_{i+1/2,j+2}-F_{i+1/2,j-2}-2F_{i+1/2,j+1}+2F_{i+1/2,j-1}}{12}
\end{equation}
%
%
\begin{equation}
c_{53}=\frac{+ F_{i+1/2,j-2} -16 F_{i+1/2,j-1}+ 30 F_{i+1/2,j} -16 F_{i+1/2,j+1}
+F_{i+1/2,j+2}}{24}
\end{equation}
%
%
\begin{equation}
c_{54}=\frac{-8F_{i+1/2,j+1}+8F_{i+1/2,j-1}+F_{i+1/2,j+2}-F_{i+1/2,j-2}}{-12}
\end{equation}
%
Now, set the weights to:
%
\begin{align}
w_3&=\frac{1-\gamma_{\rm hi}}{ \left( \beta_3 + \epsilon \right)^2} \\
w_5&=\frac{\gamma_{\rm hi}}{ \left( \beta_5 + \epsilon \right)^2}
\end{align}
%
and the normalized weights to:
%
\begin{align}
\tilde{w}_3&=\frac{w_3}{w_3+w_5} \\
\tilde{w}_5&=\frac{w_5}{w_3+w_5}
\end{align}
%
Then, the flux at the interface becomes:
%
\begin{equation}
\frameeqn{
\bar{F}_{i+1/2}=\frac{\tilde{w}_5}{\gamma_{\rm hi}} \left( F_5 - (1-\gamma_{\rm hi}) F_3 \right)+ \tilde{w}_3 F_3
}
\end{equation}
%
with $F_3$ and $F_5$ from Eqs.\ (\ref{eqn:Finteg_central3}) and (\ref{eqn:Finteg_central5})
%
\begin{equation}
F_3=\frac{1}{24} F_{i+1/2,j+1}+ \frac{1}{24}F_{i+1/2,j-1}   + \frac{11}{12}F_{i+1/2,j}
\end{equation}
%
%
\begin{equation}
F_5=  \frac{+23 F_{i+1/2,j-2} -332 F_{i+1/2,j-1}+ 6378 F_{i+1/2,j} - 332 F_{i+1/2,j+1} + 23 F_{i+1/2,j+2}}{5760}
\end{equation}
%

\appendix

  \bibliographystyle{warpdoc}
  \bibliography{all}

\end{document}


% s,over

Although there are numerous options
in the \irt,
most image reconstruction examples
in the toolbox
have the following outline.
A concrete example
is \ty{example/recon_limited_angle1.m}.

\blist
\item
Pick an image size
and generate a ``true'' digital phantom image
such as the Shepp-Logan phantom.
\item
Generate a system matrix
(usually called \ty{A}),
typically a \fatrixx object (see below),
that will be used for iterative reconstruction.
\item
Generate simulated measurements \ty{y},
possibly using the \fatrixx object
or possibly using an analytical model
(\eg, the line-integrals through the phantom).
(Using the \fatrixx object
is cheating because in the real world
there is model mismatch that contaminates the measurements.)
\item
Perform a conventional non-iterative reconstruction method
(\eg, \ty{fbp2})
to get a baseline image for comparison.
\item
Generate a regularization object
(usually \ty{R}).
\item
Check the predicted resolution properties
of that \ty{R}
using \ty{qpwls_psf},
and adjust the regularization parameter \bet
if necessary.
\item
Apply an iterative algorithm
to the data \ty{y}
using the system model \ty{A} and the regularizer \ty{R}
for some user-specified number of iterations.
\elist

\subsection{Getting started}

The best way to learn
is probably to run an example file
like
\ty{recon_limited_angle1.m},
possibly
inserting \ty{keyboard} commands
within the m-file
to examine the variables.
Most of \irt routines
have a built-in help message;
\eg,
typing \ty{im}
without any arguments
will return usage information.
Many \irt routines
have a built-in test routine,
\eg,
\ty{ellipse_sino test}
runs a built-in test
of the routine for generating
the sinogram of ellipse objects.
The test code illustrates
how to use the routine.

\subsection{Image orientation}

In \irt,
a 3D digital image $f(i,j,k)$
often corresponds to samples
of a 3D continuous function
$f(x,y,z)$.
To easily relate the three indexes,
\irt uses \ty{ndgrid}, not \ty{meshgrid}.
Likewise,
a 2D digital image $f(m,n)$
having $M$ columns and $N$ rows
often corresponds to samples
of a 2D continuous function
$f(x,y)$.
\irt stores $f(m,n)$
as a 2D array
with $M$ rows and $N$ columns,
and the \ty{im} command
has a built-in transpose
so that 2D array
with, say, $M=200$ rows and $N=100$ columns
is displayed as a 2D image
with 200 columns and 100 rows,
so that $m$ relates to horizontal coordinate ``$x$''
and $n$ relates to vertical coordinate ``$y$.''
This transpose may feel unnatural to some users of 2D images,
but has the benefit of providing more consistency
between 2D and 3D index ordering
and also is helpful
for passing \matlab arrays to C-compiled \ty{mex} files
because in C usually the $x$ coordinate varies fastest.


\section{Continuity}\label{sec:Continuity}

The graph shown in Figure \ref{fig:continuousfunc}(a) represents a
\dfont{continuous} function.  Geometrically, this is because there are no
jumps in the graphs.  That is, if you pick a point on the graph and
approach it from the left and right, the values of the function approach
the value of the function at that point.  For example, we can see that this
is not true for function values near $x=1$ on the graph in Figure \ref{fig:continuousfunc}(b) which is
not continuous at that location.

\figure[!ht]
$$\includegraphics[width=4.0in]{images/continuous}$$
\caption{(a) A continuous function. (b) A function with a discontinuity at $x=1$. \label{fig:continuousfunc}}
\endfigure

\begin{definition}{Continuous at a Point}{ContinuousPoint}
A function $f$ is \deffont{continuous
at a point $a$} if $$\ds \lim_{x\to a} f(x) = f(a).$$
\end{definition}

Some readers may prefer to think of continuity at a point as a three part definition.
That is, a function $f(x)$ is continuous at $x=a$ if the following three conditions hold:
\begin{enumerate}[(i)]
	\item $f(a)$ is defined (that is, $a$ belongs to the domain of $f$),
	\item $\ds{\lim_{x\to a}f(x)}$ exists (that is, left-hand limit $=$ right-hand limit),
	\item $\ds{\lim_{x\to a}f(x)=f(a)}$ (that is, the numbers from (i) and (ii) are equal).
\end{enumerate}

The figures below show graphical examples of functions where either (i), (ii) or (iii) can fail to hold.

$$\includegraphics[width=6.5in]{images2/continuity-3-part}$$

On the other hand, if $f$ is defined on an open interval containing $a$, except perhaps at $a$, we can say that $f$ is \dfont{discontinuous} at $a$ if $f$ is not continuous at $a$.

Graphically, you can think of continuity as being able to draw your function without having to lift your pencil off the paper. If your pencil has to jump off the page to continue drawing the function, then the function is not continuous at that point.
This is illustrated in Figure \ref{fig:continuousfunc}(b) where if we tried to draw the function (from left to right) we need to lift our pencil off the page once we reach the point $x=1$ in order to be able to continue drawing the function.

\begin{definition}{Continuity on an Open Interval}{ContinuousOpenIntervalDefinition}
A function $f$ is \deffont{continuous on an open interval $(a,b)$} if it is continuous at every point in the interval.

\medskip
Furthermore, a function is \deffont{everywhere continuous} if it is continuous on the entire real number line $(-\infty,\infty)$..
\end{definition}

Recall the function graphed in a previous section as shown in Figure \ref{fig:discontgraph}.

\figure[!ht]
\includegraphics[width=5.3in]{images/limits-graphically}
\caption{A function with discontinuities at $x=-5$, $x=-2$, $x=-1$ and $x=4$. \label{fig:discontgraph}}
\endfigure

We can draw this function without lifting our pencil \ifont{except} at the points $x=-5$, $x=-2$, $x=-1$, and $x=4$.
Thus, $f(x)$ is \ifont{continuous} at every real number \ifont{except} at these four numbers.
At $x=-5$, $x=-2$, $x=-1$, and $x=4$, the function $f(x)$ is \ifont{discontinuous}.

At $x=-2$ we have a \dfont{removable discontinuity} because we could remove this discontinuity simply by redefining $f(-2)$ to be $3.5$.
At $x=-5$ and $x=-1$ we have \dfont{jump discontinuities} because the function jumps from one value to another.
From the right of $x=4$, we have an \dfont{infinite discontinuity} because the function goes off to infinity.

Formally, we say $f(x)$ has a \dfont{removable discontinuity} at $x=a$ if $\lim_{x\to a}f(x)$ exists but is not equal to $f(a)$. Note that we do not require $f(a)$ to be defined in this case, that is, $a$ need not belong to the domain of $f(x)$.

$$\includegraphics[width=6.4in]{images2/continuity-types-of-discont}$$

\begin{example}{Continuous at a Point}{ContinuousPoint}
	What value of $c$ will make the following function $f(x)$ continuous at $2$?
	$$f(x)=\left\{\begin{array}{cl}
	\ds{\frac{x^2-x-2}{x-2}}&\qquad\mbox{if $x\neq 2$}\\
	\\
	c&\qquad\mbox{if $x=2$}\\\end{array}\right.$$
\end{example}
\begin{solution}
	In order to be continuous at $2$ we require
	$$\lim_{x\to 2}f(x)=f(2)$$
	to hold.
	We use the three part definition listed previously to check this.

	1. First, $f(2)=c$, and $c$ is some real number. Thus, $f(2)$ is defined.

	2. Now, we must evaluate the limit.
	Rather than computing both one-sided limits, we just compute the limit directly.
	For $x$ close to $2$ (but not equal to $2$) we can replace $f(x)$ with $\frac{x^2-x-2}{x-2}$ to get:
	$$\lim_{x\to 2}f(x)=\lim_{x\to 2}\frac{x^2-x-2}{x-2}=\lim_{x\to 2}\frac{(x-2)(x+1)}{x-2}=\lim_{x\to 2}(x+1)=3.$$
	Therefore the limit exists and equals $3$.

	3. Finally, for $f$ to be continuous at $2$, we need that the numbers in the first two items to be equal.
	Therefore, we require $c=3$.
	Thus, when $c=3$, $f(x)$ is continuous at $2$, for any other value of $c$, $f(x)$ is discontinuous at $2$.
\end{solution}

\begin{example}{Finding intervals of continuity}{ex_contint2}{
The \textit{floor function},\index{floor function} $f(x) = \lfloor x \rfloor$, returns the largest integer smaller than the input $x$. (For example, $f(\pi) = \lfloor \pi \rfloor = 3$.) The graph of $f$ in Figure \ref{fig:continuous2} demonstrates why this is often called a ``step function.'' \\

\noindent Give the intervals on which $f$ is continuous.

\mfigure{.7}{A graph of the step function in Example \ref{exa:ex_contint2}.}{fig:continuous2}{\begin{tikzpicture}
\begin{axis}[minor x tick num=1,axis y line=middle,axis x line=middle,ymin=-2.4,ymax=2.4,xmin=-2.4,xmax=3.4,name=myplot]
\addplot [{\colorone},smooth,thick] coordinates {(-2,-2) (-1,-2)};
\addplot [{\colorone},smooth,thick] coordinates {(-1,-1) (0,-1)};
\addplot [{\colorone},smooth,thick] coordinates {(0,0) (1,0)};
\addplot [{\colorone},smooth,thick] coordinates {(1,1) (2,1)};
\addplot [{\colorone},smooth,thick] coordinates {(2,2) (3,2)};
\fill[white,draw=black] (axis cs:-1,-2) circle (1pt);
\fill[black,draw=black] (axis cs:-2,-2) circle (1pt);

\fill[white,draw=black] (axis cs:0,-1) circle (1pt);
\fill[black,draw=black] (axis cs:-1,-1) circle (1pt);

\fill[white,draw=black] (axis cs:1,0) circle (1pt);
\fill[black,draw=black] (axis cs:0,0) circle (1pt);

\fill[white,draw=black] (axis cs:2,1) circle (1pt);
\fill[black,draw=black] (axis cs:1,1) circle (1pt);

\fill[white,draw=black] (axis cs:3,2) circle (1pt);
\fill[black,draw=black] (axis cs:2,2) circle (1pt);
\end{axis}
\node [right] at (myplot.right of origin) {  $x$};
\node [above] at (myplot.above origin) {  $y$};
\end{tikzpicture}}
}
\end{example}

\begin{solution}
{We examine the three criteria for continuity.
		\begin{enumerate}
		\item		The limits $\lim_{x\to c} f(x)$ do not exist at the jumps from one ``step'' to the next, which occur at all integer values of $c$. Therefore the limits exist for all $c$ except when $c$ is an integer.
		\item		The function is defined for all values of $c$.
		\item		The limit $\ds \lim_{x\to c} f(x) = f(c)$ for all values of $c$ where the limit exist, since each step consists of just a line.
		\end{enumerate}
		We conclude that $f$ is continuous everywhere except at integer values of $c$. So the intervals on which $f$ is continuous are $$\ldots, (-2,-1), (-1,0), (0,1), (1,2), \ldots.$$
}
\end{solution}

Our definition of continuity on an interval specifies the interval is an open interval. We can extend the definition of continuity to closed intervals by considering the appropriate one-sided limits at the endpoints.

\begin{definition}{Continuous from the Right and from the Left}{ContinuousRightLeftDefinition}
A function $f$ is \deffont{left continuous at a point $a$} if
\[\ds \lim_{x\to a^-} f(x) = f(a)\]

and \deffont{right continuous at a point $a$} if
\[\ds \lim_{x\to a^+} f(x) = f(a).\]
\end{definition}

If a function $f$ is continuous at $a$, then it is both left and right continuous at $a$.

The above definition regarding left (or right) continuous functions is illustrated with the following figure:
$$\includegraphics[width=4.7in]{images2/continuity-left-and-right}$$

One-sided limits allows us to extend the definition of continuity to closed intervals. The following definition means a function is continuous on a closed interval if it is continuous in the interior of the interval and possesses the appropriate one-sided continuity at the endpoints of the interval.

\begin{definition}{Continuity on a Closed Interval}{ContinuityClosedIntervalDefinition}
A function $f$ is \deffont{continuous on the closed interval $[a,b]$} if:
\begin{enumerate}
	\item[(i)] it is continuous on the open interval $(a,b)$;
	\item[(ii)] it is left continuous at point $a$:
	\[\ds\lim_{x\to a^-}f(x)=f(a);\]
	and
	\item[(iii)] it is right continuous at point $b$:
	\[\ds\lim_{x\to b^+}f(x)=f(b).\]
\end{enumerate}

\end{definition}

This definition can be extended to continuity on half-open intervals such as $(a,b]$ and $[a,b)$, and unbounded intervals.

\begin{example}{Continuity on Other Intervals}{ContinuityOtherInt}
The function $f(x)=\sqrt{x}$ is continuous on the (closed) interval $[0,\infty)$.

\medskip
The function $f(x)=\sqrt{4-x}$ is continuous on the (closed) interval $(-\infty,4]$.
\end{example}

The continuity of functions is preserved under the operations of addition, subtraction, multiplication and division (in the case that the function in the denominator is nonzero).

\begin{theorem}{Operations of Continuous Functions}{OpsContFunct}
If $f$ and $g$ are continous at $a$, and $c$ is a constant, then the following functions are also \ifont{continuous} at $a$:
\begin{multicols}{2}
\begin{enumerate}[(i)]
\item $f\pm g$;
\item $cf$;
\item $fg$;
\item $f/g$ (provided $g(a)\neq 0$).
\end{enumerate}
\end{multicols}
\end{theorem}

\begin{example}{Determining intervals on which a function is continuous}{ex_cont_funct}{
State the interval(s) on which each of the following functions is continuous.

		\noindent\begin{minipage}{.5\linewidth}
		\begin{enumerate}
		\item		$\ds f(x) = \sqrt{x-1} + \sqrt{5-x}$
		\item		$\ds f(x) = x\sin x$
		\end{enumerate}
		\end{minipage}
		\begin{minipage}{.5\linewidth}
		\begin{enumerate}\addtocounter{enumi}{2}
		\item		$\ds f(x) = \tan x$
		\item		$\ds f(x) = \sqrt{\ln x}$
		\end{enumerate}
		\end{minipage}
}
\end{example}

\begin{solution}
{We examine each in turn.
		\begin{enumerate}
			\item		The square--root terms are continuous on the intervals $[1,\infty)$ and $(-\infty,5]$, respectively. As $f$ is continuous only where each term is continuous, $f$ is continuous on $[1,5]$, the intersection of these two intervals. A graph of $f$ is given in Figure \ref{fig_continuous3}.

	\mfigure{.7}{A graph of $f$ in Example \ref{exa:ex_cont_funct}(a).}{fig_continuous3}{\begin{tikzpicture}
	\begin{axis}[minor x tick num=1,axis y line=middle,axis x line=middle,ymin=-.4,ymax=3.2,xmin=-.4,xmax=5.4,name=myplot]
	\addplot [{\colorone},smooth,thick] coordinates {(1.,2.)(1.01,2.0975) (1.02,2.13642) (1.03,2.16569) (1.04,2.18997) (1.05,2.21107) (1.1,2.29107) (1.15,2.34944) (1.2,2.39657) (1.3,2.47126) (1.4,2.52982)
	(1.5,2.57794) (1.6,2.61851) (1.7,2.65325) (1.8,2.68328) (1.9,2.70936)
	(2.,2.73205) (2.1,2.75175) (2.2,2.76877) (2.3,2.78334) (2.4,2.79567)
	(2.5,2.80588) (2.6,2.8141) (2.7,2.82042) (2.8,2.82488) (2.9,2.82754)
	(3.,2.82843) (3.1,2.82754) (3.2,2.82488) (3.3,2.82042) (3.4,2.8141) (3.5,2.80588) (3.6,2.79567) (3.7,2.78334) (3.8,2.76877) (3.9,2.75175)(4.,2.73205) (4.1,2.70936) (4.2,2.68328) (4.3,2.65325) (4.4,2.61851)(4.5,2.57794) (4.6,2.52982) (4.7,2.47126) (4.8,2.39657) (4.85,2.34944) (4.9,2.29107) (4.95,2.21107) (4.96,2.18997) (4.97,2.16569) (4.98,2.13642) (4.99,2.0975)(5.,2.)
	};
	%\addplot [{\colorone},smooth] coordinates {(1.,1.) (2,1)};
	%\addplot [{\colorone},smooth] coordinates {(2.,1.) (2.1,1.09) (2.2,1.16) (2.3,1.21) (2.4,1.24) (2.5,1.25)
	%(2.6,1.24) (2.7,1.21) (2.8,1.16) (2.9,1.09) (3.,1.)};
	%\fill[white,draw=black] (axis cs:2,0) circle (1pt);
	\fill[black,draw=black] (axis cs:1,2) circle (1pt);
	\fill[black,draw=black] (axis cs:5,2) circle (1pt);
	%\fill[black,draw=black] (axis cs:3,1) circle (1pt);
	\end{axis}
	\node [right] at (myplot.right of origin) {  $x$};
	\node [above] at (myplot.above origin) {  $y$};
	\end{tikzpicture}}
			\item		The functions $y=x$ and $y=\sin x$ are each continuous everywhere, hence their product is, too.
			\item	 $f(x) = \tan x$ is continuous ``on its domain.'' Its domain includes all real numbers except odd multiples of $\pi/2$. Thus $f(x) = \tan x$ is continuous on $$\ldots \left(-\frac{3\pi}{2},-\frac{\pi}2\right),\ \left(-\frac{\pi}2,\frac{\pi}2\right),\ \left(\frac{\pi}2,\frac{3\pi}2\right),\ldots,$$ or, equivalently, on $D = \{x\in \mathbb{R}\ |\ x\neq n\cdot \frac{\pi}2,\ $n$\ \text{is an odd integer} \}.$
			\item		The domain of $y = \sqrt{x}$ is $[0,\infty)$. The range of $y=\ln x$ is $(-\infty,\infty)$, but if we restrict its domain to $[1,\infty)$ its range is $[0,\infty)$. So restricting $y = \ln x$ to the domain of $[1,\infty)$ restricts its output is $[0,\infty)$, on which $y = \sqrt{x}$ is defined. Thus the domain of $f(x) = \sqrt{\ln x}$ is $[1,\infty)$.
			\end{enumerate}
}
\end{solution}

The next theorem states that the inverse $ f^{-1} $ of a continuous function $ f(x) $ is also continuous. This is not so surprising because the graph of $ f^{-1}(x) $ is a reflection of the graph of $ f(x) $ through the line $ y=x $. If the graph of $ f $ has no "breaks" in it, then neither will the graph of $ f^{-1} $.

\begin{theorem}{Continuity of Inverse Functions}{InvCont}
If $ f(x) $ is continuous on an interval $ I $, with range $ R $, then $ f^{-1} $ is continuous on every interval of the domain $ R $.
\end{theorem}

One consequence of this is that the inverse trigonometric functions are all continuous on their respective domains. Below we list some common functions that are known to be continuous on every interval inside their domains.

\begin{example}{Common Types of Continuous Functions}{CommonContinuousFunctionsList}
\begin{itemize}
	\item	Polynomials (for all $x$), e.g., $y=mx+b$, $y=ax^2+bx+c$.
	\item	Rational functions (except at points $x$ which gives division by zero).
	\item	Root functions $\sqrt[n]{x}$ (for all $x$ if $n$ is odd, and for $x\geq 0$ if $n$ is even).
	\item	Trigonometric functions
	\item	Inverse trigonometric functions
	\item	Exponential funtions
	\item	Logarithmic functions
\end{itemize}
\end{example}

For rational functions with removable discontinuities as a result of a zero, we can define a new function filling in these gaps to create a piecewise function that is continuous everywhere.

Continuous functions are where the \ifont{direct substitution
property} hold. This fact can often be used to compute the limit of a
continuous function.

\begin{example}{Evaluate a Limit}{EvaluateLimit}
Evaluate the following limit:
$\ds\lim_{x\to\pi}\frac{\sqrt{x}+\sin x}{1+x+\cos x}$.
%\vspace{-0.5cm}
\end{example}

\begin{solution}
We will use a continuity argument to justify that direct substitution can be applied.
By the list above, $\sqrt{x}$, $\sin x$, $1$, $x$ and $\cos x$ are all continuous functions at $\pi$.
Then $\sqrt x+\sin x$ and $1+x+\cos x$ are both continuous at $\pi$.
Finally,
$$\frac{\sqrt{x}+\sin x}{1+x+\cos x}$$
is a continuous function at $\pi$ since $1+\pi+\cos\pi\neq 0$.
Hence, we can directly substitute to get the limit:
$$\lim_{x\to\pi}\frac{\sqrt{x}+\sin x}{1+x+\cos x}=\frac{\sqrt{\pi}+\sin \pi}{1+\pi+\cos \pi}=\frac{\sqrt{\pi}}{\pi}=\frac{1}{\sqrt{\pi}}.$$
\end{solution}

Continuity is also preserved under the composition of functions.

\begin{theorem}{Continuity of Function Composition}{ContinuityFunctionComposition}
If $g$ is continuous at $a$ and $f$ is continuous at $g(a)$, then the composition function $f\circ g$ is continuous at $a$.
\end{theorem}

\begin{example}{Continuity with Composition of Functions}{ContCompositions}
Determine where the following functions is continuous:
\begin{enumerate}[(a)]
	\item	$h(x)=\cos(x^2)$
	\item	$H(x)=\ln(1+\sin(x))$
\end{enumerate}
\end{example}
\begin{solution}
\begin{enumerate}[(a)]
	\item	The functions that make up the composition $h(x)=f(g(x))$
	are $g(x)=x^2$ and $f(x)=\cos(x)$.
	The function $g$ is continuous on $\mathbb{R}$ since it is a polynomial,
	and $f$ is also continuous everywhere. Therefore, $h(x)=(f\circ g)(x)$
	is continuous on $\mathbb{R}$ by Theorem~\ref{thm:ContinuityFunctionComposition}.
	\item	We know from Example~\ref{exa:CommonContinuousFunctionsList}
	that $f(x)=\ln x$ is continuous and $g(x)=1+\sin x$ are continuous. Thus by
	Theorem~\ref{thm:ContinuityFunctionComposition}, $H(x)=f(g(x))$ is continuous
	wherever it is defined. Now $\ln(1+\sin x)$ is defined when $1+\sin x>0$.
	Recall that $-1\leq \sin x\leq 1$, so $1+\sin x>0$ except when $\sin x=-1$,
	which happens when $x=\pm 3\pi/2,\pm 7\pi/2,\ldots$. Therefore, $H$ has discontinuities
	when $x=3\pi n/2$, $n=1,2,3,\ldots$ and is continuous on the intervals between these values.
\end{enumerate}
\end{solution}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection*{Intermediate Value Theorem}
Whether or not an equation \ifont{has} a solution is an important question in mathematics.
Consider the following two questions:

\begin{example}{Motivation for the Intermediate Value Theorem}{Motivation for IVT}\label{MotivationforIVT}
\vspace{-0.5cm}
\begin{enumerate}
	\item Does $e^x+x^2=0$ have a solution?
	\item Does $e^x+x=0$ have a solution?
\end{enumerate}
\end{example}

\begin{solution}
\begin{enumerate}
	\item	The first question is easy to answer since for any exponential function we know that $a^x>0$, and we also know that whenever you square a number you get a nonnegative answer: $x^2\geq 0$. Hence, $e^x+x^2>0$, and thus, is never equal to zero. Therefore, the first equation has no solution.
	\item	For the second question, it is difficult to see if $e^x+x=0$ has a solution.
	If we tried to solve for $x$, we would run into problems.
	Let's make a table of values to see what kind of values we get (recall that $e\approx 2.7183$):
	$$\begin{array}{c|c}
	x & e^x+x\\
	\hline
	-2 & e^{-2}-2\approx -1.9\\
	-1 & e^{-1}-1\approx -0.6\\
	0 & e^0+0=1\\
	1 & e+1\approx 3.7\\
	\end{array}$$
	Sketching this gives:
	$$\includegraphics[width=1.9in]{images/ivt1}$$
	Let $f(x)=e^x+x$.
	Notice that if we choose $a=-1$ and $b=0$ then we have $f(a)<0$ and $f(b)>0$.
	A point where the function $f(x)$ crosses the $x$-axis gives a solution to $e^x+x=0$.
	Since $f(x)=e^x+x$ is continuous (both $e^x$ and $x$ are continuous), then the function \ifont{must} cross the $x$-axis somewhere between $-1$ and $0$:
	$$\includegraphics[width=2.2in]{images/ivt2}$$
	Therefore, our equation has a solution.

	Note that by looking at smaller and smaller intervals $(a,b)$ with $f(a)<0$ and $f(b)>0$, we can get a better and better approximation for a solution to $e^x+x=0$.
	For example, taking the interval $(-0.4,-0.6)$ gives $f(-0.4)<0$ and $f(-0.6)>0$, thus, there is a solution to $f(x)=0$ between $-0.4$ and $-0.6$.
	It turns out that the solution to $e^x+x=0$ is $x\approx -0.56714$.
\end{enumerate}
\end{solution}

We now generalize the argument used in the previous example.
In that example we had a continuous function that went from negative to positive and hence, had to cross the $x$-axis at some point.
In fact, we don't need to use the $x$-axis, any line $y=N$ will work so long as the function is continuous and below the line $y=N$ at some point and above the line $y=N$ at another point.
This is known as the Intermediate Values Theorem and it is formally stated as follows:

\begin{theorem}{Intermediate Value Theorem}{IntermediateValueTheorem}
If $f$ is continuous on the interval
$[a,b]$ and $N$ is between $f(a)$ and $f(b)$, where $f(a)\neq f(b)$,
then there is a number $c$ in $(a,b)$ such that $f(c)=N$.
\end{theorem}

The Intermediate Value Theorem guarantees that if $f(x)$ is continuous and $f(a)<N<f(b)$, the line $y=N$ intersects the function at some point $x=c$. Such a number $c$ is between $a$ and $b$ and has the property that $f(c)=N$ (see Figure \ref{fig-ivt}(a)).
We can also think of the theorem as saying if we draw the line $y=N$ between the lines $y=f(a)$ and $y=f(b)$, then the function cannot jump over the line $y=N$.
On the other hand, if $f(x)$ is \ifont{not} continuous, then the theorem may \ifont{not} hold.
See Figure \ref{fig-ivt}(b) where there is no number $c$ in $(a,b)$ such that $f(c)=N$.
Finally, we remark that there may be multiple choices for $c$ (i.e., lots of numbers between $a$ and $b$ with $y$-coordinate $N$). See Figure \ref{fig-ivt}(c) for such an example.
\begin{figure}[!ht]
$$\includegraphics[width=6in]{images/ivt3}$$
\caption{(a) A continuous function where IVT holds for a single value $c$.
(b) A discontinuous function where IVT fails to hold.
(c) A continuous function where IVT holds for multiple values in $(a,b)$. \label{fig-ivt}}
\end{figure}

The Intermediate Value Theorem is most frequently used for $N=0$.

\begin{example}{Intermediate Value Theorem}{IntermediateValueTheorem}
Show that there is a solution of $\sqrt[3]{x}+x=1$ in the interval $(0,8)$.
\end{example}

\begin{solution}
Let $f(x)=\sqrt[3]{x}+x-1$, $N=0$, $a=0$, and $b=8$.
Since $\sqrt[3]{x}$, $x$ and $-1$ are continuous on $\mathbb{R}$, and the sum of continuous functions is again continuous, we have that $f(x)$ is continuous on $\mathbb{R}$, thus in particular, $f(x)$ is continuous on $[0,8]$.
We have $f(a)=f(0)=\sqrt[3]{0}+0-1=-1$ and $f(b)=f(8)=\sqrt[3]{8}+8-1=9$.
Thus $N=0$ lies between $f(a)=-1$ and $f(b)=9$, so the conditions of the Intermediate Value Theorem are satisfied.
So, there exists a number $c$ in $(0,8)$ such that $f(c)=0$.
This means that $c$ satisfies $\sqrt[3]{c}+c-1=0$, in otherwords, is a solution for the equation given.

Alternatively we can let $f(x)=\sqrt[3]{x}+x$, $N=1$, $a=0$ and $b=8$.
Then as before $f(x)$ is the sum of two continuous functions, so is also continuous everywhere, in particular, continuous on the interval $[0,8]$.
We have $f(a)=f(0)=\sqrt[3]{0}+0=0$ and $f(b)=f(8)=\sqrt[3]{8}+8=10$.
Thus $N=1$ lies between $f(a)=0$ and $f(b)=10$, so the conditions of the Intermediate Value Theorem are satisfied.
So, there exists a number $c$ in $(0,8)$ such that $f(c)=1$.
This means that $c$ satisfies $\sqrt[3]{c}+c=1$, in otherwords, is a solution for the equation given.
\end{solution}

\begin{example}{Roots of Function}{RootsFunction}
Explain why the function $\ds f=x^3 + 3x^2+x-2$ has a root between 0
and 1.
\end{example}

\begin{solution}
By theorem~\ref{thm:PropertiesLimits}, $f$ is continuous.
Since $f(0)=-2$ and $f(1)=3$, and $0$ is between $-2$ and $3$, there
is a $c\in(0,1)$ such that $f(c)=0$.
\end{solution}

One important application of the Intermediate Value Theorem is root finding. Given a function $f$, we are often interested in finding values of $x$ where $f(x) = 0$. These roots may be very difficult to find exactly. Good approximations can be found through successive applications of this theorem. Suppose through direct computation we find that $f(a) <0 $ and $f(b)>0$, where $a<b$. The Intermediate Value Theorem states that there is a $c$ in $[a,b]$ such that $f(c) = 0$. The theorem does not give us any clue as to where that value is in the interval $[a,b]$, just that it exists.

There is a technique that produces a good approximation of $c$. Let $d$ be the midpoint of the interval $[a,b]$ and consider $f(d)$. There are three possibilities:
	\begin{enumerate}
	\item		$f(d) = 0$ -- we got lucky and stumbled on the actual value. We stop as we found a root.
	\item		$f(d) <0$ Then we know there is a root of $f$ on the interval $[d,b]$ -- we have halved the size of our interval, hence are closer to a good approximation of the root.
	\item		$f(d) >0$ Then we know there is a root of $f$ on the interval $[a,d]$ -- again,we have halved the size of our interval, hence are closer to a good approximation of the root.
	\end{enumerate}

\enlargethispage{2\baselineskip}
Successively applying this technique is called the \textit{Bisection Method} \index{Bisection Method} of root finding. We continue until the interval is sufficiently small. We demonstrate this in the following example.\\

\begin{example}{Using the Bisection Method}{ex_bisect_method}{
Approximate the root of $f(x) = x-\cos x$, accurate to three places after the decimal.}
\end{example}

\begin{solution}
{Consider the graph of $f(x) = x-\cos x$, shown in Figure \ref{fig:xminuscosx}. It is clear that the graph crosses the $x$-axis somewhere near $x=0.8$. To start the Bisection Method, pick an interval that contains $0.8$. We choose $[0.7,0.9]$. Note that all we care about are signs of $f(x)$, not their actual value, so this is all we display.

\mfigure{.8}{Graphing a root of $f(x) = x-\cos x$.}{fig:xminuscosx}{\begin{tikzpicture}
\begin{axis}[minor x tick num=4,axis y line=middle,axis x line=middle,ymin=-1.1,ymax=.7,xmin=-.05,xmax=1.07,name=myplot]
\addplot [{\colorone},smooth,thick] coordinates {(0.,-1.) (0.05,-0.94875) (0.1,-0.895004) (0.15,-0.838771)(0.2,-0.780067) (0.25,-0.718912) (0.3,-0.655336) (0.35,-0.589373)(0.4,-0.521061) (0.45,-0.450447) (0.5,-0.377583) (0.55,-0.302525)(0.6,-0.225336) (0.65,-0.146084)(0.7,-0.0648422) (0.71,-0.0483619) (0.72,-0.0318057)(0.73,-0.0151744) (0.74,0.00153144) (0.75,0.0183111) (0.76,0.035164)(0.77,0.0520893) (0.78,0.0690865) (0.79,0.0861547) (0.8,0.103293)(0.85,0.190017) (0.9,0.27839) (0.95,0.368317) (1.,0.459698)
};
\end{axis}
\node [right] at (myplot.right of origin) {  $x$};
\node [above] at (myplot.above origin) { $y$};
%\spy [{\colortwo}] on (1,1) in node at (1.5,-2);
\end{tikzpicture}}

		\begin{description}
		\item [Iteration 1:] $f(0.7) < 0$, $f(0.9) > 0$, and $f(0.8) >0$. So replace $0.9$ with $0.8$ and repeat.
		\item	[Iteration 2:]	$f(0.7)<0$, $f(0.8) > 0$, and at the midpoint, $0.75$, we have $f(0.75) >0 $. So replace $0.8$ with $0.75$ and repeat. Note that we don't need to continue to check the endpoints, just the midpoint. Thus we put the rest of the iterations in Table \ref{table:rootfinding}.
		\end{description}

\mtable{.5}{Iterations of the Bisection Method of Root Finding}{table:rootfinding}%
			{ \noindent \begin{tabular}{ccc}
			Iteration \# & Interval & Midpoint Sign \\ \hline
			1		& $[0.7,0.9]$ & $f(0.8) >0$ \\
			2 & $[0.7,0.8] $ & $f(0.75) >0$ \\
			3 & $[0.7,0.75]$ & $f(0.725)<0$\\
			4 & $[0.725,0.75]$ & $f(0.7375)<0$\\
			5 & $[0.7375,0.75]$ & $f(0.7438)>0$\\
			6 & $[0.7375,0.7438]$ & $f(0.7407)>0$\\
			7 & $[0.7375,0.7407]$ & $f(0.7391)>0$\\
			8 & $[0.7375,0.7391]$ & $f(0.7383)<0$\\
			9 & $[0.7383,0.7391]$ & $f(0.7387)<0$\\
			10 & $[0.7387,0.7391]$ & $f(0.7389)<0$\\
			11 & $[0.7389,0.7391]$ & $f(0.7390)<0$\\
			12 & $[0.7390,0.7391]$ &   \\
			\end{tabular}
			}%

Notice that in the 12$^\text{th}$ iteration we have the endpoints of the interval each starting with $0.739$. Thus we have narrowed the zero down to an accuracy of the first three places after the decimal. Using a computer, we have
$$ f(0.7390) = -0.00014, \quad f(0.7391) = 0.000024.$$ Either endpoint of the interval gives a good approximation of where $f$ is 0. The Intermediate Value Theorem states that the actual zero is still within this interval. While we do not know its exact value, we know it starts with $0.739$.

This type of exercise is rarely done by hand. Rather, it is simple to program a computer to run such an algorithm and stop when the endpoints differ by a preset small amount. One of the authors did write such a program and found the zero of $f$, accurate to 10 places after the decimal, to be 0.7390851332. While it took a few minutes to write the program, it took less than a thousandth of a second for the program to run the necessary 35 iterations. In less than 8 hundredths of a second, the zero was calculated to 100 decimal places (with less than 200 iterations).
}\\
\end{solution}

It is a simple matter to extend the Bisection Method to solve problems similar to ``Find $x$, where $f(x) = 0$.'' For instance, we can find $x$, where $f(x) = 1$. %This may seem obvious, but to many it is not.
It actually works very well to define a new function $g$ where $g(x) = f(x) - 1$. Then use the Bisection Method to solve $g(x)=0$.

Similarly, given two functions $f$ and $g$, we can use the Bisection Method to solve $f(x) = g(x)$. Once again, create a new function $h$ where $h(x) = f(x)-g(x)$ and solve $h(x) = 0$.

In Section \ref{sec:Newton} another equation solving method will be introduced, called Newton's Method. In many cases, Newton's Method is much faster. It relies on more advanced mathematics, though, so we will wait before introducing it.

This section formally defined what it means to be a continuous function. ``Most'' functions that we deal with are continuous, so often it feels odd to have to formally define this concept. Regardless, it is important, and forms the basis of the next chapter.

In the next section we examine one more aspect of limits: limits that involve infinity.

%This example also points the way to a simple method for  approximating
%roots.
%
%\begin{example}{Approximating Roots}{ApproximatingRoots}
%Approximate the root of the previous example  to one decimal
%place.
%\end{example}
%
%\begin{solution}
%If we compute $f(0.1)$, $f(0.2)$, and so on, we find that
%$f(0.6)<0$ and $f(0.7)>0$, so by the Intermediate Value Theorem, $f$
%has a root between $0.6$ and $0.7$. Repeating the process with
%$f(0.61)$, $f(0.62)$, and so on, we find that
%$f(0.61)<0$ and $f(0.62)>0$, so $f$ has a root between
%$0.61$ and $0.62$, and the root is $0.6$ rounded to one decimal place.
%\end{solution}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Opensolutionfile{solutions}[ex]
\section*{Exercises for \ref{sec:Continuity}}

\begin{enumialphparenastyle}

% % % % % % % % % % %
\begin{ex}
Concepts.
\begin{enumerate}

\item {Given functions $f$ and $g$ on an interval $I$, how can the Bisection Method be used to find a value $c$ where $f(c) = g(c)$?}

\item {What is a ``root'' of a function?}

\item {In your own words, describe what the Intermediate Value Theorem states.}

\item {In your own words, describe what it means for a function to be continuous.}
\item {T/F: The sum of continuous functions is also continuous.}
\item {T/F: If $f$ is continuous on $[0,1)$ and $[1,2)$, then $f$ is continuous on $[0,2)$.}

\item {T/F: If $f$ is continuous on $[a,b]$, then $\ds\lim_{x\to a^-}f(x) = f(a)$.}

\item {T/F: If $f$ is continuous at $c$, then $\ds \lim_{x\to c^+}f(x) = f(c)$.}

\item {T/F: If $f$ is continuous at $c$, then $\ds \lim_{x\to c}f(x)$ exists.}

\item {T/F:	If $f$ is defined on an open interval containing $c$, and $\ds \lim_{x\to c}f(x)$ exists, then $f$ is continuous at $c$.
}

\end{enumerate}

\begin{sol}
\begin{enumerate}
\item {Consider the function $h(x) = g(x) - f(x)$, and use the Bisection Method to find a root of $h$.}
\item {A root of a function $f$ is a value $c$ such that $f(c)=0$.}
\item {Answers will vary.}

\item {Answers will vary.}
\item {T}
\item {F}
\item {F}
\item {T}
\item {T}
\item {F}
\end{enumerate}
\end{sol}

\end{ex}
% % % % % % % % % % % %

% % % % % % % % % % %
\begin{ex}

In the following exercises a graph of a function $f$ is given along with a value $a$. Determine if $f$ is continuous at $a$; if it is not, state why it is not.
\begin{multicols}{2}
\begin{enumerate}
\item $ a=1 $

\begin{tikzpicture}
\begin{axis}[ %width=\marginparwidth+25pt,tick label style={font=\scriptsize},
axis y line=middle,axis x line=middle,name=myplot,%
%			xtick={-2,-1,1,2,3},%
%			ytick={-6,-4,-2,0,2,4,6},
%			minor y tick num=1,
%			extra y ticks={-5,-3,...,7},%
			ymin=-.1,ymax=2.1,%
			xmin=-.1,xmax=2.1%
]

\addplot [thick,{\colorone}] coordinates {(0.,1) (1,2)};
\addplot [{\colorone},smooth,thick,domain=1:2] {2*(x-2)^2};

\fill[black,draw=black] (axis cs:0,1) circle (1.5pt);
\fill[white,draw=black] (axis cs:1,2) circle (1.5pt);
\fill[black,draw=black] (axis cs:1,1) circle (1.5pt);
\fill[black,draw=black] (axis cs:2,0) circle (1.5pt);
\end{axis}
\node [right] at (myplot.right of origin) {\scriptsize $x$};
\node [above] at (myplot.above origin) {\scriptsize $y$};
\end{tikzpicture}
\item $ a=1 $

\begin{tikzpicture}
\begin{axis}[ %width=\marginparwidth+25pt,tick label style={font=\scriptsize},
axis y line=middle,axis x line=middle,name=myplot,%
%			xtick={-2,-1,1,2,3},%
%			ytick={-6,-4,-2,0,2,4,6},
%			minor y tick num=1,
%			extra y ticks={-5,-3,...,7},%
			ymin=-.1,ymax=2.1,%
			xmin=-.1,xmax=2.1%
]

\addplot [thick,{\colorone}] coordinates {(0.,0) (1,1)};
\addplot [{\colorone},thick] coordinates {(1,2) (2,0)};

\fill[black,draw=black] (axis cs:0,0) circle (1.5pt);
\fill[white,draw=black] (axis cs:1,1) circle (1.5pt);
\fill[black,draw=black] (axis cs:1,2) circle (1.5pt);
\fill[black,draw=black] (axis cs:2,0) circle (1.5pt);
\end{axis}
\node [right] at (myplot.right of origin) {\scriptsize $x$};
\node [above] at (myplot.above origin) {\scriptsize $y$};
\end{tikzpicture}
\item $ a=1 $

\begin{tikzpicture}
\begin{axis}[ %width=\marginparwidth+25pt,tick label style={font=\scriptsize},
axis y line=middle,axis x line=middle,name=myplot,%
%			xtick={-2,-1,1,2,3},%
%			ytick={-6,-4,-2,0,2,4,6},
%			minor y tick num=1,
%			extra y ticks={-5,-3,...,7},%
			ymin=-.1,ymax=2.1,%
			xmin=-.1,xmax=2.1%
]

%\addplot [thick,{\colorone},smooth,domain=0:.9] {1/(x-1)^2};
%\addplot [{\colorone},thick,smooth,domain=1.1:2] {1/(x-1)^2};
\draw [thick,{\colorone}] (axis cs:0,0) parabola (axis cs:1,3);
\draw [thick,{\colorone}] (axis cs:2,0) parabola (axis cs:1,3);
\draw [{\colorone},dashed] (axis cs: 1,2.1) -- (axis cs:1,-.1);

\fill[black,draw=black] (axis cs:0,0) circle (1.5pt);
%\fill[white,draw=black] (axis cs:1,1) circle (1.5pt);
%\fill[black,draw=black] (axis cs:1,2) circle (1.5pt);
\fill[black,draw=black] (axis cs:2,0) circle (1.5pt);
\end{axis}
\node [right] at (myplot.right of origin) {\scriptsize $x$};
\node [above] at (myplot.above origin) {\scriptsize $y$};
\end{tikzpicture}

\item $ a=0 $

\begin{tikzpicture}
\begin{axis}[ %width=\marginparwidth+25pt,tick label style={font=\scriptsize},
axis y line=middle,axis x line=middle,name=myplot,%
%			xtick={-2,-1,1,2,3},%
%			ytick={-6,-4,-2,0,2,4,6},
%			minor y tick num=1,
%			extra y ticks={-5,-3,...,7},%
			ymin=-.1,ymax=2.1,%
			xmin=-.1,xmax=2.1%
]

%\addplot [thick,{\colorone},smooth,domain=0:.9] {1/(x-1)^2};
%\addplot [{\colorone},thick,smooth,domain=1.1:2] {1/(x-1)^2};
\draw [thick,{\colorone}] (axis cs:1,0) parabola (axis cs:2,2);
\draw [thick,{\colorone}] (axis cs:0,1) -- (axis cs:1,2);

\fill[black,draw=black] (axis cs:0,1) circle (1.5pt);
\fill[white,draw=black] (axis cs:1,2) circle (1.5pt);
\fill[black,draw=black] (axis cs:1,1) circle (1.5pt);
\fill[black,draw=black] (axis cs:2,2) circle (1.5pt);
\fill[white,draw=black] (axis cs:1,0) circle (1.5pt);
\end{axis}
\node [right] at (myplot.right of origin) {\scriptsize $x$};
\node [above] at (myplot.above origin) {\scriptsize $y$};
\end{tikzpicture}
\item $ a=1 $

\begin{tikzpicture}
\begin{axis}[ %width=\marginparwidth+25pt,tick label style={font=\scriptsize},
axis y line=middle,axis x line=middle,name=myplot,%
%			xtick={-2,-1,1,2,3},%
%			ytick={-6,-4,-2,0,2,4,6},
%			minor y tick num=1,
%			extra y ticks={-5,-3,...,7},%
			ymin=-.1,ymax=2.1,%
			xmin=-.1,xmax=2.1%
]

%\addplot [thick,{\colorone},smooth,domain=0:.9] {1/(x-1)^2};
%\addplot [{\colorone},thick,smooth,domain=1.1:2] {1/(x-1)^2};
\draw [thick,{\colorone}] (axis cs:1,2) parabola (axis cs:0,0);
\draw [thick,{\colorone}] (axis cs:1,2) -- (axis cs:2,0);

\fill[black,draw=black] (axis cs:0,0) circle (1.5pt);
\fill[black,draw=black] (axis cs:1,2) circle (1.5pt);
\fill[black,draw=black] (axis cs:2,0) circle (1.5pt);
%\fill[black,draw=black] (axis cs:2,2) circle (1.5pt);
%\fill[white,draw=black] (axis cs:1,0) circle (1.5pt);
\end{axis}
\node [right] at (myplot.right of origin) {\scriptsize $x$};
\node [above] at (myplot.above origin) {\scriptsize $y$};
\end{tikzpicture}
\item $ a=4 $

 \begin{tikzpicture}
\begin{axis}[ %width=\marginparwidth+25pt,tick label style={font=\scriptsize},
axis y line=middle,axis x line=middle,name=myplot,%
			xtick={-4,...,-1,1,2,...,4},%
%			ytick={-6,-4,-2,0,2,4,6},
%			minor y tick num=1,
%			extra y ticks={-5,-3,...,7},%
			ymin=-4.5,ymax=4.5,%
			xmin=-4.5,xmax=4.5%
]

%\addplot [thick,{\colorone},smooth,domain=0:.9] {1/(x-1)^2};
%\addplot [{\colorone},thick,smooth,domain=1.1:2] {1/(x-1)^2};
\addplot [thick,{\colorone},domain=-4:0] {4*cos(deg(x)*3.14159/4};
\addplot [thick,{\colorone},domain=0:4]  {-4*cos(deg(x)*3.14159/4};
%
\fill[black,draw=black] (axis cs:0,0) circle (1.5pt);
\fill[white,draw=black] (axis cs:0,4) circle (1.5pt);
\fill[black,draw=black] (axis cs:-4,-4) circle (1.5pt);
\fill[black,draw=black] (axis cs:4,4) circle (1.5pt);
\fill[white,draw=black] (axis cs:0,-4) circle (1.5pt);
\end{axis}
\node [right] at (myplot.right of origin) {\scriptsize $x$};
\node [above] at (myplot.above origin) {\scriptsize $y$};
\end{tikzpicture}

\item \begin{enumerate}
\item		$a = -2$
\item		$a=0$
\item		$a=2$
\end{enumerate}

 \begin{tikzpicture}
\begin{axis}[ %width=\marginparwidth+25pt,tick label style={font=\scriptsize},
axis y line=middle,axis x line=middle,name=myplot,%
			xtick={-4,...,-1,1,2,...,4},%
%			ytick={-6,-4,-2,0,2,4,6},
%			minor y tick num=1,
%			extra y ticks={-5,-3,...,7},%
			ymin=-4.5,ymax=4.5,%
			xmin=-4.5,xmax=4.5%
]

%\addplot [thick,{\colorone},smooth,domain=0:.9] {1/(x-1)^2};
%\addplot [{\colorone},thick,smooth,domain=1.1:2] {1/(x-1)^2};
\addplot [thick,{\colorone}] coordinates {(-4,0) (-2,2) (0,0) (2,2) (4,0)};
%\addplot [thick,{\colorone},domain=0:4]  {-4*cos(deg(x)*3.14159/4};
%
\fill[black,draw=black] (axis cs:0,0) circle (1.5pt);
\fill[black,draw=black] (axis cs:-4,0) circle (1.5pt);
\fill[black,draw=black] (axis cs:-2,0) circle (1.5pt);
\fill[white,draw=black] (axis cs:-2,2) circle (1.5pt);
\fill[white,draw=black] (axis cs:2,2) circle (1.5pt);
\fill[black,draw=black] (axis cs:4,0) circle (1.5pt);
\end{axis}
\node [right] at (myplot.right of origin) {\scriptsize $x$};
\node [above] at (myplot.above origin) {\scriptsize $y$};
\end{tikzpicture}

\item $ a=3 $

\begin{tikzpicture}
\begin{axis}[ %width=\marginparwidth+25pt,tick label style={font=\scriptsize},
axis y line=middle,axis x line=middle,name=myplot,%
			xtick={-4,...,-1,1,2,...,4},%
%			ytick={-6,-4,-2,0,2,4,6},
%			minor y tick num=1,
%			extra y ticks={-5,-3,...,7},%
			ymin=-4.5,ymax=4.5,%
			xmin=-4.5,xmax=4.5%
]
\draw [thick,{\colorone}] (axis cs:-4,-4) -- (axis cs:-3,-4);
\draw [thick,{\colorone}] (axis cs:-3,-3) -- (axis cs:-2,-3);
\draw [thick,{\colorone}] (axis cs:-2,-2) -- (axis cs:-1,-2);
\draw [thick,{\colorone}] (axis cs:-1,-1) -- (axis cs:0,-1);
\draw [thick,{\colorone}] (axis cs:0,0) -- (axis cs:1,0);
\draw [thick,{\colorone}] (axis cs:1,1) -- (axis cs:2,1);
\draw [thick,{\colorone}] (axis cs:2,2) -- (axis cs:3,2);
\draw [thick,{\colorone}] (axis cs:3,3) -- (axis cs:4,3);

%
\fill[black,draw=black] (axis cs:-4,-4) circle (1.5pt);
\fill[white,draw=black] (axis cs:-3,-4) circle (1.5pt);
\fill[black,draw=black] (axis cs:-3,-3) circle (1.5pt);
\fill[white,draw=black] (axis cs:-2,-3) circle (1.5pt);
\fill[black,draw=black] (axis cs:-2,-2) circle (1.5pt);
\fill[white,draw=black] (axis cs:-1,-2) circle (1.5pt);
\fill[black,draw=black] (axis cs:-1,-1) circle (1.5pt);
\fill[white,draw=black] (axis cs:0,-1) circle (1.5pt);
\fill[black,draw=black] (axis cs:0,0) circle (1.5pt);
\fill[white,draw=black] (axis cs:1,0) circle (1.5pt);
\fill[black,draw=black] (axis cs:1,1) circle (1.5pt);
\fill[white,draw=black] (axis cs:2,1) circle (1.5pt);
\fill[black,draw=black] (axis cs:2,2) circle (1.5pt);
\fill[white,draw=black] (axis cs:3,2) circle (1.5pt);
\fill[black,draw=black] (axis cs:3,3) circle (1.5pt);
\fill[white,draw=black] (axis cs:4,3) circle (1.5pt);
\end{axis}
\node [right] at (myplot.right of origin) {\scriptsize $x$};
\node [above] at (myplot.above origin) {\scriptsize $y$};
\end{tikzpicture}
\end{enumerate}

\begin{sol}
\begin{enumerate}
\item {No; $\ds \lim_{x\to 1} f(x) = 2$, while $f(1) = 1$.}
\item {No; $\ds \lim_{x\to 1} f(x)$ does not exist.}
\item {No; $f(1)$ does not exist.}
\item {Yes}
\item {Yes}
\item {Yes}
\item {\begin{enumerate}
\item		No; $\ds \lim_{x\to -2}f(x) \neq f(-2)$
\item		Yes
\item		No; $f(2)$ is not defined.
\end{enumerate}
}
\item No.
\end{enumerate}
\end{sol}

\end{multicols}
\end{ex}
% % % % % % % % % % % %

% % % % % % % % % % %
\begin{ex}
Determine if $f$ is continuous at the indicated values. If not, explain why.
\begin{enumerate}
\item {$\ds f(x) = \left\{\begin{array}{ccc}
1		& & x=0\\
\frac{\sin x}{x} & & x>0
\end{array}\right.
$
\begin{enumerate}
\item		$x=0$
\item		$x=\pi$
\end{enumerate}
}

\item {$\ds f(x) = \left\{\begin{array}{ccc}
x^3-x		& & x<1\\
x-2 & & x\geq 1
\end{array}\right.
$
\begin{enumerate}
\item		$x=0$
\item		$x=1$
\end{enumerate}
}

\item {$\ds f(x) = \left\{\begin{array}{ccc}
\frac{x^2+5x+4}{x^2+3x+2}		& &  x\neq -1\\
3 & & x=-1
\end{array}\right.
$
\begin{enumerate}
\item		$x=-1$
\item		$x=10$
\end{enumerate}
}

\item {$\ds f(x) = \left\{\begin{array}{ccc}
\frac{x^2-64}{x^2-11 x+24}		& &  x\neq 8\\
5 & & x=8
\end{array}\right.
$
\begin{enumerate}
\item		$x=0$
\item		$x=8$
\end{enumerate}
}

\end{enumerate}

\begin{sol}
\begin{enumerate}
\item {\begin{enumerate}
\item		Yes
\item		Yes
\end{enumerate}
}
\item {\begin{enumerate}
\item		Yes
\item		No; the left and right hand limits at 1 are not equal.
\end{enumerate}
}
\item {\begin{enumerate}
\item		Yes
\item		Yes
\end{enumerate}
}
\item {\begin{enumerate}
\item		Yes
\item		No. $\lim_{x\to 8} f(x) = 16/5 \neq f(8) = 5$.
\end{enumerate}
}
\end{enumerate}
\end{sol}

\end{ex}
% % % % % % % % % % % %

% % % % % % % % % % %
\begin{ex}
Give the intervals on which the given function is continuous.
\begin{enumerate}

\item {$f(x) = x^2-3x+9$
}

\item {$\ds g(x) = \sqrt{x^2-4}$
}

\item {$\ds h(k) = \sqrt{1-k}+\sqrt{k+1}$
}

\item {$\ds f(t) = \sqrt{5t^2-30}$
}

\item {$\ds g(t) = \frac{1}{\sqrt{1-t^2}}$
}

\item {$\ds g(x) = \frac{1}{1+x^2}$
}

\item {$\ds f(x) = e^x$
}

\item {$\ds g(s) = \ln s$
}

\item {$\ds h(t) = \cos t$
}

\item {$\ds f(k) = \sqrt{1-e^k}$
}
\item {$\ds f(x) = \sin(e^x+x^2)$
}
\end{enumerate}

\begin{sol}
\begin{enumerate}
\item {$(-\infty,\infty)$
}
\item {$(-\infty,-2]\cup [2,\infty)$
}
\item {$[-1,1]$
}
\item {$(-\infty,-\sqrt{6}]\cup [\sqrt{6},\infty)$
}
\item {$(-1,1)$
}
\item {$(-\infty,\infty)$
}
\item {$(-\infty,\infty)$
}
\item {$(0,\infty)$
}
\item {$(-\infty,\infty)$
}
\item
{$(-\infty,0]$
}
\item
{$(-\infty,\infty)$
}
\end{enumerate}
\end{sol}

\end{ex}
% % % % % % % % % % % %

%%%%%%%%%%
\begin{ex}
Consider the function
$$h(x) = \left\{
\begin{array}{rl}
2x-3, & \mbox{if $x<1$,}\\
0, & \mbox{if $x\geq 1$.}\\
\end{array}\right.$$

Show that it is continuous at the point $x=0$.  Is $h$ a continuous function?
\end{ex}

%%%%%%%%%%
\begin{ex}
Find the values of $a$ that make the function $f(x)$ continuous for all real numbers.
$$f(x) = \left\{
\begin{array}{rl}
4x+5, & \mbox{if $x\geq -2$,}\\
x^2+a, & \mbox{if $x<-2$.}\\
\end{array}\right.$$
\end{ex}

%%%%%%%%%%
\begin{ex}
Find the values of the constant $c$ so that the function $g(x)$ is continuous on $(-\infty,\infty)$, where
$$g(x) = \left\{
\begin{array}{rl}
2-2c^2x, & \mbox{if $x<-1$,}\\
6-7cx^2, & \mbox{if $x\geq-1$.}\\
\end{array}\right.$$
\end{ex}

% % % % % % % % % % %
\begin{ex}

{Let $f$ be continuous on $[1,5]$ where $f(1) = -2$ and $f(5) = -10$. Does a value $1<c<5$ exist such that $f(c) = -9$? Why/why not?
}

\begin{sol}
{Yes, by the Intermediate Value Theorem.
}
\end{sol}

\end{ex}
% % % % % % % % % % % %
% % % % % % % % % % %
\begin{ex}
 {Let $g$ be continuous on $[-3,7]$ where $g(0) = 0$ and $g(2) = 25$. Does a value $-3<c<7$ exist such that $g(c) = 15$? Why/why not?
 }

\begin{sol}
  {Yes, by the Intermediate Value Theorem. In fact, we can be more specific and state such a value $c$ exists in $(0,2)$, not just in $(-3,7)$.
  }
\end{sol}

\end{ex}
% % % % % % % % % % % %
% % % % % % % % % % %
\begin{ex}
 {Let $f$ be continuous on $[-1,1]$ where $f(-1) = -10$ and $f(1) = 10$. Does a value $-1<c<1$ exist such that $f(c) = 11$? Why/why not?
 }

\begin{sol}
 {We cannot say; the Intermediate Value Theorem only applies to function values between $-10$ and 10; as 11 is outside this range, we do not know.
  }
\end{sol}

\end{ex}
% % % % % % % % % % % %
% % % % % % % % % % %
\begin{ex}
 {Let $h$ be a function on $[-1,1]$ where $h(-1) = -10$ and $h(1) = 10$. Does a value $-1<c<1$ exist such that $h(c) = 0$? Why/why not?
 }

\begin{sol}
 {We cannot say; the Intermediate Value Theorem only applies to continuous functions. As we do know know if $h$ is continuous, we cannot say.
  }
\end{sol}

\end{ex}
% % % % % % % % % % % %

% % % % % % % % % % %
\begin{ex}
Use the Bisection Method to approximate, accurate to two decimal places, the value of the root of the given function in the given interval.
\begin{enumerate}
\item {$f(x) = x^2+2x-4$ on $[1,1.5]$.
}

\item {$f(x) = \sin x - 1/2$ on $[0.5,0.55]$
}

\item {$f(x) = e^x - 2$ on $[0.65,0.7]$.
}

\item {$f(x) = \cos x -\sin x$ on $[0.7,0.8]$.
}

\end{enumerate}

\begin{sol}
\begin{enumerate}
\item {Approximate root is $x=1.23$. The intervals used are:
$[1,1.5] \quad [1,1.25] \quad [1.125,1.25]$
$[1.1875,1.25]\quad [1.21875,1.25]\quad [1.234375,1.25]$
$[1.234375,1.2421875]\quad [1.234375,1.2382813]$
}
\item {Approximate root is $x=0.52$. The intervals used are:
$[0.5,0.55] \quad [0.5,0.525] \quad [0.5125,0.525]$
$[0.51875,0.525]\quad [0.521875,0.525]$
}
\item {Approximate root is $x=0.69$. The intervals used are:
$[0.65,0.7] \quad [0.675,0.7] \quad [0.6875,0.7]$
$[0.6875,0.69375]\quad [0.690625,0.69375]$
}
\item {Approximate root is $x=0.78$. The intervals used are:
$[0.7,0.8] \quad [0.75,0.8] \quad [0.775,0.8]$
$[0.775,0.7875]\quad [0.78125,0.7875]$

(A few more steps show that $0.79$ is better as the root is $\pi/4 \approx 0.78539$.)
}
\end{enumerate}
\end{sol}

\end{ex}
% % % % % % % % % % % %

% % % % % % % % % % %
\begin{ex}
{Let $\ds f(x)= \left\{\begin{array}{ccc}
x^2-5 & & x<5 \\
5x & & x \geq 5
\end{array}\right.$.

\noindent\begin{minipage}[t]{.5\linewidth}
\begin{enumerate}
\item		$\ds \lim_{x\to 5^-} f(x)$
\item		$\ds \lim_{x\to 5^+} f(x)$
\end{enumerate}
\end{minipage}
\noindent\begin{minipage}[t]{.5\linewidth}
\begin{enumerate}\addtocounter{enumii}{2}
\item		$\ds \lim_{x\to 5} f(x)$
\item		$f(5)$\end{enumerate}
\end{minipage}
}

\begin{sol}
{\begin{enumerate}
\item		20
\item		25
\item		Limit does not exist
\item		25
\end{enumerate}
}

\end{sol}
\end{ex}
% % % % % % % % % % % %

% % % % % % % % % % %
\begin{ex}

{Numerically approximate the following limits:
\begin{enumerate}
\item	$\ds \lim_{x\to -4/5^+} \frac{x^2-8.2 x-7.2}{x^2+5.8 x+4}$
\item	$\ds \lim_{x\to -4/5^-} \frac{x^2-8.2 x-7.2}{x^2+5.8 x+4}$
\end{enumerate}
}
\begin{sol}

{\begin{tabular}{cc}
$x$ & $f(x)$ \\ \hline
$-0.81 $& $-2.34129$ \\
$ -0.801$ & $-2.33413$ \\
$ -0.79 $& $-2.32542 $\\
$ -0.799$ & $-2.33254$
\end{tabular}

The top two lines give an approximation of the limit from the left: $-2.33$. The bottom two lines give an approximation from the right: $-2.33$ as well.
}
\end{sol}
\end{ex}
% % % % % % % % % % % %

\end{enumialphparenastyle}