\documentclass[submit,12pt]{aiaa-pretty} %submit, draft, journal options can be used
\usepackage[belowskip=0pt, aboveskip=0pt]{subcaption}
\usepackage{float}
\usepackage{caption}
\usepackage{tcolorbox}
%\setlength{\belowcaptionskip}{-10pt}
%red
%\usepackage{classdiagram}
%\usepackage[T1]{fontenc}

\usepackage{amsmath}
\newenvironment{rcases}
  {\left.\begin{aligned}}
  {\end{aligned}\right\rbrace}
\newenvironment{lcases}
  {\left\lbrace\begin{aligned}}
  {\end{aligned}\right.}

\usepackage{amssymb}
\usepackage{amsfonts}
% * <komahan.cool@gmail.com> 2018-04-24T04:09:52.446Z:
%
% > }
%
% ^.
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{doi}
\usepackage{xcolor}
\usepackage{graphicx,dblfloatfix}
\usepackage{algorithm}
\usepackage{algpseudocode}
%\usepackage[superscript]{cite}
\usepackage[numbers,compress,sort]{natbib}
%
\usepackage{soul,xcolor}

\input{custom.tex}

\graphicspath{{talk/}{talk/figures/}{figures/}}

\title{Isogeometric Analysis Using Non-uniform Rational Bsplines}
\author{Komahan Boopathy  and Siddarth Niranjan Babu\\
  {\normalsize\itshape School of Aerospace Engineering, Georgia Institute of Technology,
    Atlanta, GA, USA. }
}

\abstract{Isogeometric analysis uses NURBS basis functions to
  represent geometry as well as solution fields. In this project, we
  use isogeometric analysis to analyse deformation of a
  one-dimensional bar and a two-dimensional plate. First, the
  representation of curves and surfaces using NURBS is outlined. We
  then present details pertaining to isogeometric analysis of bar and
  plate and plot the deformed structures. The source code and
  documentatation are hosted open-source at \href{https://github.com/komahanb/isogeometric-analysis}{https://github.com/komahanb/isogeometric-analysis}.}

\begin{document}
\maketitle

\section{Introduction and Motivation}
Non-uniform Rational B-Splines (NURBS) \cite{Piegl:NurbsBook} are a
popular way to represent curves and surfaces in geometry modeling. In
other words, they provide a basis for three-dimensional euclidean
space. In principle, they can be used to span other spaces as well,
for example, N-dimensional vector spaces in finite element
analysis. This realization has led to the development of isogeometric
analysis
(IGA)~\cite{HUGHES20054135,KACPRZYK201487,NGUYEN201589,Agrawal2018,Milic2013,Simpson}
where the same functions used for geometry representation in
$\mathbb{E}^3$ is also used to represent displacement field in
$\mathbb{R}^M$.
IGA is a recently introduced technique that employs the Computer Aided
Design concepts of Non-uniform Rational B-splines(NURBS) tool to
bridge the substantial bottleneck between the CAD and finite element
analysis field. The fundamental concept of IGA is to utilize the NURBS
basis functions not only for the construction or as a handler of the
exact form of CAD geometries, but also as a tool that can be used for
their mathematical analysis.
The importance of IGA is follows:
\begin{itemize}
  \item FEM utilizes the approximate form of CAD geometry by discretizing them into a smaller sub-geometry called elements. Whereas in IGA, CAD-based NURBS described geometries are directly employed in the analysis without making any geometrical approximations like in FEM.
  \item IGA reduces the burden of mesh regeneration and thus minimizes the computational cost. % to a great extent.
  \item Due to inherent higher order continuity and exact representation of geometrical features, IGA has been shown to be advantageous in contact, fluid, structural vibration problems and more.
  \item IGA can be applied to specific problems which have been solved with FEM to attain improved solution.
\end{itemize}
Isogeometric boundary element methods for elastostatic analysis were
presented in [127,118], demonstrating that mesh generation can be
completely circumvented by using CAD discretizations for analysis.
%To describe the application of IGA, a standard infinite plate with a
%circular hole problem in tension as shown in Figure~\ref{fig:iga-demo}
%is chosen.
%\begin{figure}[h]
%  \centering
%  \includegraphics[width=0.75\linewidth]{iga-demo.pdf}
%  \caption{\emph{NURBS decretized quarter-plate with a hole}}
%  \label{fig:iga-demo}
%\end{figure}
In IGA, apart from the
geometrical details(length, height, width) of a model, its parametric
details such as knot vectors, the order of NURBS basis functions, and
the control points are also needed to construct the exact form of
discretized geometry. The evaluation of NURBS basis functions and
their respective derivatives, along with their corresponding mappings
are need to be done along with the enforcement procedure for different
boundary conditions for NURBS defined geometry.
The main objective of the project is implementation of NURBS based
Isogeometric Analysis(IGA) on test problems.

\section{NURBS representation of Curves and Surfaces}
\subsection{Parametric Representation of Curves}
Let $\vv{p}(u) = [x(u), y(u), z(u)]^T$ refer to the parametric
representation of a point on a curve in three-dimensional Euclidean
space $\mathbb{E}^3$, where $u \in [u_{min}, u_{max}]$ is a scalar
parameter that takes a given range of values to characterize the curve.
Any point on the curve can be written as:
\begin{equation}
  \vv{p}(u) := {\sum_{i=0}^n \alpha_i N_{k,i}(u) \vv{P}^{i}}/{\sum_{i=0}^n \alpha_i N_{k,i}(u)} \quad 0 \le u \le n-k+2
\end{equation}
where $k$ refers to the order of the $i-$th BSpline basis functions $N_{k,i}$,
$\vv{P}^i$ is the $i-$th control point,  $n+1$ is the number of control points
and $\alpha_i$ is the weight associated with $i-th$ control point.
The inputs required  are
\begin{enumerate}
\item a given set of $n+1$ control points $\{\vv{P}^i\}_{i=0}^n$ and
\item chosen order $k$
\item weights $\alpha_i$
\end{enumerate}
Note that the order is chosen independent of the number of control
points. The first-derivative (slope) of the curve at a parametric point $u$ is defined as:
\begin{equation}
  \begin{aligned}
    \td{\vv{p}(u)}{u} := \vv{p}^u(u) & = \sum_{i=0}^n  \alpha_i \td{N_{k,i}(u)}{u} \vv{P}^{i} / \sum_{i=0}^n \alpha_i \td{N_{k,i}(u)}{u}  \\ &= \sum_{i=0}^n \alpha_i N_{k,i}^{u}(u) \vv{P}^{i} /\sum_{i=0}^n \alpha_i N_{k,i}^{u}(u).
  \end{aligned}
\end{equation}
where $N_{k,i}^u(u)$ is the u-derivative of the corresponding basis
function. Here, we simply use the fact that only the basis function is
dependent on the parameter $u$. This naturally extends to second-order
derivatives (curvature) as
\begin{equation}
  \begin{aligned}
    \tdt{\vv{p}(u)}{u} := \vv{p}^{uu}(u) & = \sum_{i=0}^n \alpha_i \tdt{N_{k,i}(u)}{u} \vv{P}^{i}/\sum_{i=0}^n \alpha_i \tdt{N_{k,i}(u)}{u} \\ & = \sum_{i=0}^n \alpha_i N_{k,i}^{uu}(u) \vv{P}^{i}/\sum_{i=0}^n \alpha_i N_{k,i}^{uu}(u).
  \end{aligned}
\end{equation}
We note the following important properties of the Bspline curve:
\begin{enumerate}
\item The range of the parameter values is $0 \le u \le n-k+2$
\item The curve $\vv{p}(u)$ is $C^{k-2}$ continuous
\item $\vv{p}(u)$ is a composite curve made up of (n-k+2) segments
\item Each segment is influenced by $k$ control points
\item A given control point affects upto $k$ segments
\item If the starting and ending control points are the same $\vv{P}^0  = \vv{P}^{n+1}$, then the curve $\vv{p}(u)$ is indeed a closed curve
\end{enumerate}
The form of the NURBS basis function is
\begin{equation}
  N_{k,i}(u) = \frac{(u-t_i) N_{k-1,i}(u)}{t_{k+i-1}-t_i} + \frac{(t_{k+i}-u)N_{k-1,i+1}(u)}{t_{k+i}-t_{i+1}}
\end{equation}
where $t_i$ are the knot values defined as
\begin{equation}
  t_i =
  \begin{cases}
    0 & i < k\\
    i+1 - k & k \le i \le n \\
    n+2 - k & i > n\\
  \end{cases}
\quad \forall i = 0,\ldots, n+k.
\end{equation}
It can be seen that there are a total of $n+k+1$ knot values. We can
implement a function $\texttt{knot\_values(n,k)}$ that computes the
knot values with $n$ and $k$ as inputs. The computed knot values can
be used to compute the basis function $N_{k,i}$ in a recursive manner.
The recursion is terminated when
\begin{equation}
  N_{0,i}(u) =
  \begin{cases}
    1 & t_i \le u \le t_{i+1}    \\
    0 & \mathrm{otherwise} \\
  \end{cases}
\end{equation}

\subsection{Parametric Representation of Surfaces}

We extend the parametric curves to represent surfaces as
\begin{equation}
  \vv{p}(u_1, u_2) := \dfrac{ {\sum\limits_{i=0}^{n} \sum\limits_{j=0}^{m} \alpha_i N_{k,i}(u_1) \beta_j M_{l,j}(u_2) \vv{P}^{i,j}}} {\sum\limits_{i=0}^{n} \sum\limits_{j=0}^{m} \alpha_i N_{k,i}(u_1) \beta_j M_{l,j}(u_2)}
\end{equation}
with parameter range $0 \le u_1 \le n - k + 2$ and $0 \le u_2 \le n - l + 2$.
For ease of notation we define the following form
\begin{equation}
  \vv{p}(\vv{u}) := \dfrac{ {\sum \limits_{s=0}^{n \times m} \alpha_{s} N_{k,s}(\vv{u}) \vv{P}^{s}}} {\sum \limits_{s=0}^{n \times m} \alpha_{s} N_{k,s}(\vv{u})}
\end{equation}

\section{Isogeometric Analysis of Bar}
An elastic bar is suspended vertically and is allowed to deform under
self weight as shown in Figure~\ref{fig:bar-setup}. We first consider
the solution of the elastic problem using isogeometric
analysis~\cite{bar-analysis,1D_bar}.
\begin{figure}[h]
  \centering
  \includegraphics[width=0.2\textwidth]{bar-setup.pdf}
  \caption{\emph{Setup of the deformation of bar problem.}}
  \label{fig:bar-setup}
\end{figure}
The geometry is modeled with information shown in
Table~\ref{tab:bar-problem-parameters} with NURBS basis functions.
\begin{table}
  \centering
  \caption{Parameters used in geometry modeling of bar.}
  \label{tab:bar-problem-parameters}
  \begin{tabular}{lc}
    \hline
    Parameter & Value \\
    \hline
    degree of basis & 2 \\
    control points  &  [0, 0.5, 1.5, 2.0] \\
    knot vector     & [0 0 0 0.5 1 1 1] \\
    number of knot spans & 2 \\
    \hline
  \end{tabular}
\end{table}
\subsection{Governing Equation}
The governing equation for the deformation of bar is
\begin{equation}\label{eqn:bar-governing-equation}
  \pd{}{x} \left( EA \pd{u(x)}{x} \right) - \rho g  = 0
\end{equation}
where $E$ is the Young's modulus of material of bar, $A$ is the area
of cross section, $\rho$ is the density of material and $g$ is the
acceleration due to gravity.
\subsection{Solution Form}
Consider the following expansions for the
solution form and its spatial derivative
\begin{equation}\label{eqn:bar-spectral-expansions}
  u(x) := \sum_{i=1}^{m} R_{i,p}(x) U_i \qquad \mathrm{and} \qquad \pd{u(x)}{x} := \sum_{i=1}^{m} \pd{R_{i,p}(x)}{x}  U_i,
\end{equation}
where $R_{i,p}(x)$ are NURBS basis functions and $U_i$ are the control
point displacements. We use the expansions~\eqref{eqn:bar-spectral-expansions} in
the governing equations~\eqref{eqn:bar-governing-equation}. This gives
rise to the following residual
\begin{equation}\label{eqn:bar-governing-equation}
  R := \pd{}{x} \left( EA  \sum_{i=1}^{m} \pd{R_{i,p}(x)}{x}  U_i \right) - \rho g  = 0.
\end{equation}
\subsection{Galerkin Projection}
The analysis procedure involves the projection of the above residual
onto the basis functions used in the assumed form of solution. This is
represented mathematically as an inner product (projection operation) as
\begin{equation}\nonumber
  \left\langle  {\color{black}{R_{j,p}(x)}} \bigg\vert {\color{black}{\pd{}{x} \left[ EA \sum_{i=1}^{m} \pd{R_{i,p}(x)}{x}  U_i  \right]}} \right\rangle  =
  \left\langle  {\color{black}{R_{j,p}(x)}} \bigg\vert {\color{black}{\rho g}} \right\rangle
\end{equation}
The weak form is obtained using integration by parts as follows
\begin{equation}\nonumber
  \begin{gathered}
    \underset{boundary~term}{{{R_{j,p}(x) EA \pd{u(x)}{x}}}  \bigg\vert_{x_a}^{x_b}} +  \underset{stiffness~matrix}{\left\langle {\color{black}{\pd{R_{j,p}(x)}{x}}}  \bigg\vert  {\color{black}{EA  \pd{R_{i,p}(x)}{x}  U_i}}   \right\rangle}  =
    \underset{force~vector}{\left\langle {\color{black}{R_{j,p}(x)}} \bigg\vert {\color{black}{\rho g}} \right\rangle} \quad \forall j = 1, \ldots,m
  \end{gathered}
\end{equation}
This gives rise to the following system for each element $x \in [x_a,
  x_b]$
\begin{equation}\nonumber
  \setlength\arraycolsep{1.5pt}
                        {EA}
                        \begin{bmatrix}
                          \left \langle {\color{black}{R_1^\prime(x)}} \vert {\color{black}{R_1^\prime(x)}} \right \rangle &  \left \langle {\color{black}{R_1^\prime(x)}} \vert {\color{black}{R_2^\prime(x)}} \right \rangle & \left \langle {\color{black}{R_1^\prime(x)}} \vert {\color{black}{R_m^\prime(x)}} \right \rangle \\
                          \left \langle {\color{black}{R_2^\prime(x)}} \vert {\color{black}{R_1^\prime(x)}} \right \rangle &  \left \langle {\color{black}{R_2^\prime(x)}} \vert {\color{black}{R_2^\prime(x)}} \right \rangle & \left \langle {\color{black}{R_2^\prime(x)}} \vert {\color{black}{R_m^\prime(x)}} \right \rangle \\
                          \left \langle {\color{black}{R_3^\prime(x)}} \vert {\color{black}{R_1^\prime(x)}} \right \rangle &  \left \langle {\color{black}{R_3^\prime(x)}} \vert {\color{black}{R_2^\prime(x)}} \right \rangle & \left \langle {\color{black}{R_3^\prime(x)}} \vert {\color{black}{R_m^\prime(x)}} \right \rangle \\
                        \end{bmatrix}
                        \begin{Bmatrix}
                          U_1 \\
                          U_2 \\
                          U_3 \\
                        \end{Bmatrix}=
                        \begin{Bmatrix}
                          \left \langle {\color{black}{R_1(x)}} \vert {\color{black}{\rho g}} \right \rangle \\
                          \left \langle {\color{black}{R_2(x)}} \vert {\color{black}{\rho g}} \right \rangle \\
                          \left \langle {\color{black}{R_3(x)}} \vert {\color{black}{\rho g}} \right \rangle \\
                        \end{Bmatrix}
\end{equation}
The evaluation of stiffness matrix and force vector requires the NURBS
basis function and its derivatives shown in
Table~\ref{tab:anlytical-form-of-nurbs-functions}
\begin{table}
  \centering
  \caption{NURBS shape functions used in isogeometric analysis.}
  \label{tab:anlytical-form-of-nurbs-functions}
  \begin{tabular}{cc}
    \hline
    Element 1 & Element 2 \\
    \hline
    $R_1^1(\xi) =  (2 \xi -1)^2$ & $R_1^2(\xi) = (2\xi-2)(\xi-1)$  \\
    $R_2^1(\xi) = -2\xi(3\xi-2)$ & $R_2^2(\xi) = -6\xi^2 + 8\xi -2$ \\
    $R_3^1(\xi) =  2\xi^2$       & $R_3^2(\xi) = (2\xi -1)^2$ \\
    \hline
  \end{tabular}
\end{table}
These functions are plotted and visualized in Figure~\ref{fig:nurbs-basis-function-derivatives}.

\subsection{Quadrature and Evaluation of Inner Products}
Evaluation of inner product is done as follows
\begin{equation}\nonumber
  \begin{aligned}
    \underset{\text{inner~product}}{\left\langle {\color{black}{f^x(x)}} \big\vert  {\color{black}{g^x(x)}} \right\rangle} &= \underset{\text{integral}}{\int\limits_{x_a}^{x_b}  {\color{black}{f^x(x)}}  {\color{black}{g^x(x)}}~dx} &= \underset{\text{quadrature}}{\sum_{k=1}^M \alpha_k^x  {\color{black}{f^x(x_k)}}  {\color{black}{g^x(x_k)}}}\\
  \end{aligned}
\end{equation}
Note that a transformation from $x$ to $\xi$ is required as NURBS
basis is a function of parameter $\xi$. This is achieved using
equations similar to ~\ref{eqn:bar-spectral-expansions}.
\begin{figure}[h]
  \begin{subfigure}{0.48\textwidth}
    \centering
    \includegraphics[width=1.0\textwidth]{figures/bar-basis-functions.pdf}
    \caption{basis function}
  \end{subfigure}
  \begin{subfigure}{0.48\textwidth}
    \centering
    \includegraphics[width=1.0\textwidth]{figures/bar-basis-function-derivatives.pdf}
    \caption{basis function derivatives}
  \end{subfigure}
  \caption{NURBS basis functions and derivatives for isogeometric
    analysis of bar.}
  \label{fig:nurbs-basis-function-derivatives}
\end{figure}

\begin{figure}
  \centering
  \includegraphics[width=0.5\textwidth]{figures/bar-solution.pdf} \\
  \caption{IGA solution and exact solution for the problem.}
  \label{fig:bar-solution}
\end{figure}
In Figure~\ref{fig:bar-solution} we compare the IGA solution with the analytical solution given as
\begin{equation}\nonumber
  u(x) = \frac{\rho g}{E} \left( Lx - \frac{x^2}{2}\right)
\end{equation}
It can be seen that the IGA solution with two elements produces the
exact solution.

\section{Isogeometric Analysis of Plate}
An infinite plate of L=8 and W=8 with a circular hole subjected to in-plane concentrated load at one of the control points. The material properties were taken as $E = 10^3$ and Poisson's ratio $\nu =0.3$
\begin{figure}[h]
  \centering
  \includegraphics[width=0.5\textwidth]{figures/plate1.PNG}
  \caption{\emph{Setup of the deformation of plate problem.}}
  \label{fig:plate-setup}
\end{figure}
The geometry can be simplified to a quarter plate due to its symmetry. It is modeled using NURBS with 12 control points. For this plate with a circular hole problem, the order of the basis function is chosen as p=2 and q=2. Therefore, the total of number of active control points and the basis functions in an element are 9. The number of control points along $\xi$ direction is given by $n_{cp}(\xi)$ = Total number of knots-(p+1) = 4 and the number of control points along $\eta$ direction is given by $n_{cp}(\eta)$ = Total number of knots in $\eta$ direction-(q+1) = 3. The geometry is divided into two elements with each having 9 active control points.
\begin{figure}[h]
  \centering
  \includegraphics[width=0.5\textwidth]{figures/plate2.png}
  \caption{\emph{Quarter model of the plate with circular hole.}}
  \label{fig:plate-setup}
\end{figure}
The geometry of the NURBS discretized element $\Omega^e$ is given by the combination of the basis function $R_i$ and the control point variable $P_i$ as
\begin{equation}\nonumber
    x^e = \sum_{i=1}^{n_{cp}^e} R_iP_i
\end{equation}
and using Galerkin approach, the solution field is given by,
\begin{equation}\nonumber
    u^e = \sum_{i=1}^{n_{cp}^e}R_iu_i
\end{equation}
The NURBS basis function and its derivatives are evaluated to obtain the strain-displacement matrix,
    \begin{equation*}
        B=\begin{bmatrix}
        R_{1,x} & 0 & R_{2,x} & 0 & \dots & R_{9,x} & 0\\
        0 & R_{1,y} & 0 &R_{2,y} & \dots & 0 & R_{9,y}\\
        R_{1,y} & 0 &R_{1,x} &  R_{2,y} & \dots &  R_{9,y} &R_{9,x}
        \end{bmatrix}
    \end{equation*}
The strain displacement matrix is then used to evaluate the element stiffness matrix and force vector using the weak formulation. The weak formulation is given by,
\begin{equation*}
        \int_{\Omega^e} (B^TCB  \,d\Omega)\,u = \int_{\Gamma^e_t} R.t \,d\Gamma +\int_{\Omega^e} R.f \,d\Omega
    \end{equation*}
Like FEM, IGA discretized weak form, can also be cast into the standard matrix form as
\begin{equation*}
    \sum_{e=1}^{nel}[K^eU^e=F^e]
\end{equation*}
which in global form can be written as
\begin{equation}
    K^GU^{cp}=F^G
\end{equation}\label{Global}
where $K^e$, $F^e$ and $U^e$ denote the NURBS described iso-geometric element's stiffness matrix, external force vector, and displacement vector, respectively. The procedure to assemble the global matrices are similar to assembly procedure of FEA but it uses control point assembly array instead of nodal connectivity matrix.\\
Using the global stiffness matrix and force vectors into the global form to obtain the displacements of the control points.
\begin{figure}
\centering
\begin{minipage}{.5\textwidth}
  \centering
  \includegraphics[width=1.0\linewidth,height=.9\textwidth]{figures/undeformed_plate.png}
  \captionof{figure}{Undeformed Plate}
  \label{fig:test1}
\end{minipage}%
\begin{minipage}{.5\textwidth}
  \centering
  \includegraphics[width=1.0\linewidth,height=.9\textwidth]{figures/deformed_plate.png}
  \captionof{figure}{Deformed Plate}
  \label{fig:test2}
\end{minipage}
\end{figure}

The displacements of the control points are then added to the original control points to obtain the new control points. The new control points are then used to plot the deformed plate. These displacement values can be used to find the stresses and strains in the model.

\section{Conclusions}
B-spline basis function has unique properties like local support exact
geometry representation and refinement technique. IGA analysis
framework makes use of these NURBS properties. It is observed that the
displacement solution obtained from IGA is equivalent to control
points of B-spline displacement curve. Coupling of CAD and analysis
solvers reduces the burden of mesh regeneration. This minimizes the
computational cost. Utilizing the exact geometry in analysis provide
accurate results than FEA. Also, IGA gives better solution per degree
of freedom than FEM.  IGA has many advantages over FEM, but also has
some disadvantages of its own. IGA is a NURBS based method, analysts
must require a lot of CAD knowledge. Multi-patch B-spline modeling of
intricate shapes is a very difficult task. Irrespective of the degree
of the basis function and number of elements, the FEM solution at
nodes always gives exact solution. But, that is not the case in IGA,
because of non-interpolation of B-spline control points.
The future work entails the following:
\begin{itemize}
    \item The visualization of quantities such as stresses and strains
      are not straight forward compared to conventional finite element
      analysis
    \item The mesh refinement process with a knot insertion algorithm
      to extend it for any number of elements during analysis
    \item The application of IGA for 3D problems and complex geometries.
\end{itemize}

\bibliographystyle{myabbrvnat}
\bibliography{references}

\end{document}


\documentclass[12pt]{article}
\usepackage[pdftex]{graphicx}
\newcommand{\kg}{\mathrm{kg}}
\newcommand{\m}{\mathrm{m}}
\newcommand{\cm}{\mathrm{cm}}
\newcommand{\mi}{\mathrm{mi}}
\newcommand{\s}{\mathrm{s}}
\newcommand{\ms}{\mathrm{ms}}
\newcommand{\h}{\mathrm{h}}
\newcommand{\N}{\mathrm{N}}
\newcommand{\W}{\mathrm{W}}
\newcommand{\hp}{\mathrm{hp}}
\newcounter{problem}
\stepcounter{problem}
\newcounter{answer}[problem]
\newenvironment{problem}{\noindent\begin{minipage}{\textwidth}\sloppy\sloppypar\raggedright\textbf{\theproblem.}\refstepcounter{problem}\stepcounter{answer}---}{\end{minipage}\vspace{2ex}}
\newcommand{\source}[1]{[{#1}]}
\newenvironment{answers}{\\}{}
\newcommand{\answer}[1]{\textbf{\Alph{answer}:}\refstepcounter{answer}~\mbox{#1}\hspace{3ex}}
\begin{document}

\section*{NYU General Physics 1---Term Exam 2}

\begin{problem}
  \source{from lecture 2011-10-06} I swung a coffee cup over my head
  and the coffee did not spill out.  If, at the top of the swing, the
  cup was moving at speed $v$ on a circular path of radius $R$, what
  needed to be true for the coffee to stay securely in the cup?
  \begin{answers}
    \answer{$\displaystyle \frac{v^2}{R} = 0$}
    \answer{$\displaystyle \frac{v^2}{R} < g$}
    \answer{$\displaystyle \frac{v^2}{R} = g$}
    \answer{$\displaystyle \frac{v^2}{R} > g$}
    \answer{None of these}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from lecture 2011-10-13} We considered a block sliding down
  a frictionless hill and off a frictionless jump.  The block flew up
  into the air, but it did not return to the height from which it
  started.  Why not?
  \begin{answers}
    \answer{Energy was not conserved.}
    \answer{The block lost energy to heat during its slide.}
    \answer{Not all of the potential energy was converted into kinetic energy.}
    \answer{After the jump, the horizontal component of velocity is constant.}
    \answer{There are energies other than kinetic and potential to consider.}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from lecture 2011-10-18} A small bullet of mass $m$ moving
  at velocity $\vec{v}$ lodged in a big block of mass $M$.
  Immediately before the collision, the bullet had momentum $\vec{p}_i =
  m\,\vec{v}$ and kinetic energy $K_i = (1/2)\,m\,|\vec{v}|^2$.
  Immediately after the collision, the momentum $\vec{p}_f$ and kinetic
  energy $K_f$ of the bullet+block system were
  \begin{answers}
    \answer{$|\vec{p}_f| = |\vec{p}_i|$ and $K_f = K_i$}
    \answer{$|\vec{p}_f| = |\vec{p}_i|$ and $K_f < K_i$}
    \answer{$|\vec{p}_f| = |\vec{p}_i|$ and $K_f > K_i$}
    \answer{$|\vec{p}_f| < |\vec{p}_i|$ and $K_f = K_i$}
    \answer{$|\vec{p}_f| > |\vec{p}_i|$ and $K_f = K_i$}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from lecture 2011-10-18} A block of mass $[M+m]$ attached to
  the ceiling by a string of length $L$ is moving at speed $v_f$ when
  the string is vertical, that is, when the block is at the minimum of
  potential energy.  It will then swing up to some maximum height
  $h_\mathrm{max}$ given by
  \begin{answers}
    \answer{$\displaystyle h_\mathrm{max} = \frac{v_f}{2\,g}$}
    \answer{$\displaystyle h_\mathrm{max} = \frac{v_f^2}{g}$}
    \answer{$\displaystyle h_\mathrm{max} = \frac{v_f}{g}$}
    \answer{$\displaystyle h_\mathrm{max} = \frac{v_f^2}{2\,g}$}
    \answer{none of these}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from lecture 2011-10-20} A block of mass $5.0\,\kg$ moves at
  $2.0\,\m\,\s^{-1}$ in the positive $x$ direction and a block of mass
  $3.0\,\kg$ moves at $3.0\,\m\,\s^{-1}$ in the negative $x$
  direction.  What is the $x$-direction velocity of the center of mass
  (or the velocity of the center-of-mass frame)?
  \begin{answers}
    \answer{$\displaystyle 0.125\,\m\,\s^{-1}$}
    \answer{$\displaystyle 0.5\,\m\,\s^{-1}$}
    \answer{$\displaystyle 1.0\,\m\,\s^{-1}$}
    \answer{$\displaystyle 2.375\,\m\,\s^{-1}$}
    \answer{$\displaystyle 19.0\,\m\,\s^{-1}$}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from lecture 2011-10-25} We found the forces on a light
  table holding a very heavy block of mass $M$.  The table was
  supported by two supports (support 1 and support 2) separated by a
  distance $L$.  The block was a distance $x$ from support 1.  The
  ratio of the normal force $N_2$ at support 2 to the normal force
  $N_1$ at support 1 was
  \begin{answers}
    \answer{$\displaystyle \frac{N_2}{N_1} = \left|x\right|$}
    \answer{$\displaystyle \frac{N_2}{N_1} = \left|x - L\right|$}
    \answer{$\displaystyle \frac{N_2}{N_1} = \left|\frac{x}{x - L}\right|$}
    \answer{$\displaystyle \frac{N_2}{N_1} = \left|\frac{x - L}{x}\right|$}
    \answer{none of these}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from lecture 2011-10-27} The hanging sign problem we did had
  a cable that made an angle $\theta$ with respect to the horizontal
  direction.  Imagine making $\theta$ very small, so the cable is
  nearly horizontal.  What happens to the tension $T$ in the cable as
  $\theta$ gets small?
  \begin{answers}
    \answer{$T$ gets very small}
    \answer{$T$ approaches $M\,g + m\,g/2$}
    \answer{$T$ gets very large}
    \answer{$T$ doesn't depend on $\theta$}
    \answer{none of these}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from lecture 2011-11-01} Stress is proportional to strain.
  What formula is most related to this fact?
  \begin{answers}
    \answer{$\displaystyle \vec{F} = m\,\vec{a}$}
    \answer{$\displaystyle \vec{F} = -k\,\vec{x}$}
    \answer{$\displaystyle E = \frac{1}{2}\,m\,v^2$}
    \answer{$\displaystyle E = \frac{|\vec{p}|^2}{2\,m}$}
    \answer{$\displaystyle \vec{p} = m\,\vec{v}$}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 5, problem 1} The driver of a car traveling
  east slams on the brakes, so that the car goes through a period of
  rapid deceleration.  The total force on the ground from the car must
  \begin{answers}
    \answer{have a downwards component and an eastwards component}
    \answer{have a downwards component and a westward component}
    \answer{have an upwards component and an eastwards component}
    \answer{have an upwards component and a westward component}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 5, problem 1} You are sitting in the
  passenger seat of a car moving forwards at high speed but also
  rapidly decelerating, with your seatbelt securely fastened.  The
  deceleration has been going on for some time, and you are tightly
  held in your seat by your seatbelt.  What is the direction of the
  net force acting on you?
  \begin{answers}
    \answer{There is (almost) no net force acting on you.}
    \answer{The net force points towards the front of the car.}
    \answer{The net force points towards the back of the car.}
    \answer{The net force points downwards.}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 5, problem 2} Why do the astronauts in the
  Space Station feel weightless?
  \begin{answers}
    \answer{There is no gravity in space.}
    \answer{The Space Station is accelerating downwards at $\vec{g}$.}
    \answer{The Space Station is going on a circular trajectory.}
    \answer{The Space Station is very far from Earth.}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 5, problem 3} You may have learned
  something like $P\,V = n\,R\,T$, where $P$ is pressure (force per
  area) and $V$ is volume.  Whether or not you ever have heard that,
  what are the units of this equation?  Note: You don't need to know
  what $n$, $R$, or $T$ are to solve this problem.
  \begin{answers}
    \answer{force}
    \answer{energy}
    \answer{mass}
    \answer{length}
    \answer{momentum}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 6, problem 1} You computed the energy
  expended by a college-age human by considering the potential energy
  gain over time of climbing 9 flights of stairs at a reasonable pace.
  The human also has kinetic energy during this climb.  Compare the
  kinetic energy $K$ of the human during the climb to her or his total
  change in potential energy $\Delta U$ during the climb.
  \begin{answers}
    \answer{$K$ is much less than $\Delta U$.}
    \answer{$K$ is about equal to $\Delta U$.}
    \answer{$K$ is much greater than $\Delta U$.}
    \answer{It is impossible to answer this question.}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 6, problem 1} A good athelete can climb
  stairs at a mechanical energy output of $1\,\hp$ (horesepower).
  Roughly how long would it take such an athelete to climb nine
  flights of stairs?
  \begin{answers}
    \answer{$0.03\,\s$}
    \answer{$0.3\,\s$}
    \answer{$3\,\s$}
    \answer{$30\,\s$}
    \answer{$300\,\s$}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 6, problem 2} If you compare the energy
  content of gasoline and olive oil, you find that
  \begin{answers}
    \answer{olive oil has more than 10 times higher energy density}
    \answer{they are about the same}
    \answer{gasoline has more than 10 times higher energy density}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 6, problem 3} A ball bounces on a hard
  surface.  In the period between bounces, when the ball is in
  free-fall, a graph of the kinetic energy as a function of time will
  look like
  \begin{answers}
    \answer{a straight line}
    \answer{two straight lines connected at a point}
    \answer{a parabola going from high to low to high}
    \answer{a parabola going from low to high to low}
    \answer{none of these}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 7, problem 1} Which of these figures---cut
  from a sheet of constant-thickness aluminum---has its center of
  mass \emph{precisely} at the point $(0,0)$?
  \begin{answers}
  \includegraphics[width=\textwidth]{../py/com_shapes.pdf}\addtocounter{answer}{4}
  \answer{none of these}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 7, problem 2} Just before jumping out of
  the way, a (daring) student throws a ball at $10\,\mi\,\h^{-1}$
  straight at a bus moving towards the student at $35\,\mi\,\h^{-1}$.
  Assume that these are the speeds just before the collision, that the
  collision is head-on, that the collision is elastic, and that the
  front of the bus is a flat, vertical plane.  Right after the
  collision (after the ball leaves contact with the bus), what will be
  the speed of the ball?  Give your answer for the original reference
  frame.
  \begin{answers}
    \answer{$60\,\mi\,\h^{-1}$}
    \answer{$70\,\mi\,\h^{-1}$}
    \answer{$80\,\mi\,\h^{-1}$}
    \answer{$90\,\mi\,\h^{-1}$}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 7, problem 3} A student of mass
  $m_\mathrm{student} = 80\,\kg$ stands at rest next to a block of ice
  of mass $m_\mathrm{ice} = 160\,\kg$, also at rest, on a frictionless
  frozen lake.  The student pushes on the block until both the student
  and the block are moving (in opposite directions).  What is the
  ratio of their speeds?
  \begin{answers}
    \answer{$\displaystyle\frac{|\vec{v}_\mathrm{student}|}{|\vec{v}_\mathrm{ice}|} = 4$}
    \answer{$\displaystyle\frac{|\vec{v}_\mathrm{student}|}{|\vec{v}_\mathrm{ice}|} = 2$}
    \answer{$\displaystyle\frac{|\vec{v}_\mathrm{student}|}{|\vec{v}_\mathrm{ice}|} = \sqrt{2}$}
    \answer{$\displaystyle\frac{|\vec{v}_\mathrm{student}|}{|\vec{v}_\mathrm{ice}|} = 1$}
    \answer{$\displaystyle\frac{|\vec{v}_\mathrm{student}|}{|\vec{v}_\mathrm{ice}|} = \frac{1}{2}$}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 8, problem 1} In this bridge, is the very
  top strut (across the top) in compression or tension?\\
  \includegraphics{../py/bridge.pdf}
  \begin{answers}
    \answer{compression}
    \answer{tension}
    \answer{neither}
    \answer{depends}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 8, problem 2} When you are holding a heavy
  bag of weight $N$ (heavier than your arm) in your arm, and you have
  your arm angled so the upper arm is vertical and the forearm is
  horizontal, there is a tension force $T$ in your bicep muscle and a
  compression force $F_h$ in your humerus bone (the vertical bone in
  your upper arm).  In addition to gravity, these three forces ($N$,
  $T$, and $F_h$) are all acting on the lower part of the arm.
  \begin{answers}
    \answer{$|F_h|>|N|>|T|$}
    \answer{$|N|>|F_h|>|T|$}
    \answer{$|F_h|>|T|>|N|$}
    \answer{$|T|>|N|>|F_h|$}
    \answer{$|T|>|F_h|>|N|$}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from problem set 8, problem 3} A ladder leans in static
  equilibrium against a frictionless wall, making an angle $\theta$
  with the vertical.  How does the normal force $N$ between the floor
  and the ladder vary as we increase $\theta$ (make the ladder less
  vertical)?
  \begin{answers}
    \answer{$N$ increases}
    \answer{$N$ decreases}
    \answer{$N$ stays the same}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from \textit{Newton's Second Law} lab} In one of the
  experiments, a glider mass is attached to a hanging mass by a string
  going over a pulley.  In the theory for this experiment, you assumed
  that the ``smart pulley'' was massless.  This assumption was made to
  \begin{answers}
    \answer{ensure that Newton's law holds}
    \answer{make sure the smart pulley reads out correct information}
    \answer{reduce the friction in the system}
    \answer{make the tension in the string single-valued}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from \textit{Centripetal Force} lab} What is the
  relationship between the angular frequency $\omega$ and the period
  $T$?
  \begin{answers}
    \answer{$\displaystyle\omega = \frac{2\pi}{T}$}
    \answer{$\displaystyle\omega = \frac{T}{2\pi}$}
    \answer{$\displaystyle\omega = 2\pi\,T$}
    \answer{$\displaystyle\omega = \frac{1}{2\pi\,T}$}
    \answer{you need more information to answer this}
  \end{answers}
\end{problem}

\begin{problem}
  \source{from \textit{Conservation of Energy} lab} The spring used in
  this lab had a spring constant $k$ with units of $N\,m^{-1}$, and a
  mass $m$ attached to it.  If you compress the spring by a distance
  $x$, you store potential energy $U$, where
  \begin{answers}
    \answer{$U = m\,k\,x$}
    \answer{$U = (1/2)\,m\,k\,x^2$}
    \answer{$U = (1/2)\,k\,x^2$}
    \answer{$U = (1/3)\,k\,x^3$}
    \answer{$U = \sqrt{k/m}$}
  \end{answers}
\end{problem}

\end{document}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Metamorphic Testing(MT)}
\subsection{Metamorphic Testing(MT)}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}[fragile]
	\frametitle{Metamorphic Testing(MT)}
	%% \structure{What is MT}
	\begin{itemize}
		\item comparing outputs of successive runs with varying(morphed) input data for validation
		\item Metamorphic Relation(MR): intrinsic function of software identified for validating
	\end{itemize}

			\begin{figure}
				 \includegraphics[scale = 0.22]{images/Metamorphic_Testing_image}
				%% \includegraphics[width = 0.95\textwidth]{images/Metamorphic testing.png}
				\linebreak
			 	\tiny{image:Metamorphic Testing by Teemu Kanstr\'{e}n from Towards Data Science}
			\end{figure}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}[fragile]
	\structure{ Metamorphic Relations}
		\begin{itemize}
			\item MRs are usually identified based on the system under test by domain experts
			\item Permutative(change the order of keywords in a search )
			\item Additive, Multiplicative (add or multiplying by a constant, resulting in increase/no effect on output)
			\item Invertive(changing the signs of each data point, resulting in negative of previous output)
			\item Inclusive(adding a new constraint in the search criteria)
			\item Exclusive(removing elements from the data points)
			\item periodicity(explored in Hands on session)
			\item could be linear or quadratic $$ \cos{(2x)} = 2{\cos} ^2  (x)   $$
		\end{itemize}

\end{frame}


 \documentclass [12pt]{article}

\usepackage {amsmath}
\usepackage {amsthm}
\usepackage {amssymb}
\usepackage {graphicx}
\usepackage {float}
\usepackage {multirow}
\usepackage {xcolor}
\usepackage {algorithmic}
\usepackage [ruled,vlined,commentsnumbered,titlenotnumbered]{algorithm2e} \usepackage {array}
\usepackage {booktabs}
\usepackage {url}
\usepackage {parskip}
\usepackage [margin=1in]{geometry}
\usepackage [T1]{fontenc}
\usepackage {cmbright}
\usepackage [many]{tcolorbox}
\usepackage [colorlinks = true,
            linkcolor = blue,
            urlcolor  = blue,
            citecolor = blue,
            anchorcolor = blue]{hyperref}
\usepackage {enumitem}
\usepackage {xparse}
\usepackage {verbatim}
\usepackage{listings}
\usepackage{xcolor}
\lstset { %
    language=C++,
    backgroundcolor=\color{black!5}, % set backgroundcolor
    basicstyle=\footnotesize,% basic font setting
}
\newtheorem{theorem}{Theorem}
\newtheorem{remark}{Remark}

\DeclareTColorBox {Solution}{}{breakable, title={Solution}} \DeclareTColorBox {Solution*}{}{breakable, title={Solution (provided)}} \DeclareTColorBox {Instruction}{}{boxrule=0pt, boxsep=0pt, left=0.5em, right=0.5em, top=0.5em, bottom=0.5em, arc=0pt, toprule=1pt, bottomrule=1pt} \DeclareDocumentCommand {\Expecting }{+m}{\textbf {[We are expecting:} #1\textbf {]}} \DeclareDocumentCommand {\Points }{m}{\textbf {(#1 pt.)}}

\begin {document}

\vspace {1em}
\begin {Instruction}
Adapted From Virginia Williams' lecture notes.
\end {Instruction}

{\LARGE \textbf {COMP 285 (NC A\&T, Spr `22)}\hfill \textbf {Lecture 9} }

\begin{centering}
\section*{Randomized Algorithms and QuickSort}
\end{centering}

Today we will study another sorting algorithm: \texttt{Quicksort}, which was invented in 1959 by Tony
Hoare. You may wonder why we want to study a new sorting algorithm. We have already studied \texttt{MergeSort}, which we showed to perform significantly better than the trivial $O(n^2)$ algorithm. While \texttt{MergeSort} achieves an $O(n \log n)$ worst-case asymptotic bound, in practice,
there are a number of implementation details about \texttt{MergeSort} that make it tricky to achieve
high performance. \texttt{Quicksort} is an alternative algorithm, which is simpler to implement in
practice. \texttt{Quicksort} will also use a divide and conquer strategy but will use randomization to
improve the performance of the algortithm in expectation. Java, Unix, and C stdlib all have
implementations of \texttt{Quicksort} as one of their built-in sorting routines.

\section{QuickSort Overview}
As in all sorting algorithms, we start with an array $A$ of $n$ numbers; again we assume without
loss of generality that the numbers are distinct\footnote{What does it mean to say that we can assume something without loss of generality? Why can we make this assumption without loss of generality in this proof?}. Quicksort is very similar to the \texttt{QuickSort} algorithm we studied last lecture. The description of Quicksort is the following:

\begin{algorithm}
\caption{QuickSort(A)}\label{alg:QuickSort}
\begin{algorithmic}
\IF {$n=1$}
    \RETURN $A$
\ENDIF
\STATE $p \gets \texttt{RandomPivot}(A)$
\STATE $A_< \gets \{A[i] \mid A[i] < p \}$
\STATE $A_> \gets \{A[i] \mid A[i] > p \}$
\STATE $A_<' \gets \texttt{QuickSort}(A_<)$
\STATE $A_>' \gets \texttt{QuickSort}(A_>)$
\RETURN $[A_<', p, A_>']$
\end{algorithmic}
\end{algorithm}

The above steps define a ``partition'' function on $A$. The partition function of \texttt{Quicksort} can vary depending on how the pivot is chosen and also on the implementation. \texttt{Quicksort} is often used in practice because we can implement this step in linear time, and with very small constant factors. In addition, the rearrangement can actually be done in-place, rather
than making several copies of the array (as is done in \texttt{MergeSort}). In these notes we will
not describe the details of an in-place implementation, but the pseudocode can be found in
CLRS.

\section{Speculation on the Runtime}

The performance of \texttt{Quicksort} depends on which element is chosen as the pivot. Assume
that we choose the $k$th smallest element; then $|A_<| = k - 1, |A_>| = n - k$. This allows us to write a recurrence; let $T(n)$ be the runtime of \texttt{Quicksort} on an $n$-element array. We know the partition step takes $O(n)$ time; therefore the recurrence is

$$
T(n) \leq cn + T(k-1) + T(n-k)
$$

For the worst pivot choice (the maximum or minimum element in the array\footnote{2Why are these the worst pivot choices?}), the runtime satisfies the recurrence $T(n) = T(n - 1) + O(n)$; hence $T(n) = O(n^2)$.

One way that seems optimal to define the partition function is to pick the median as the
pivot. In the above recurrence this would mean that $k = \lceil \frac{n}{2}\rceil$. We showed in the previous lecture that the algorithm \texttt{Select} can find the median element in linear time. Therefore the recurrence becomes $T(n) \leq cn + 2T(n^2)$. This is exactly the same recurrence as \texttt{MergeSort}, which means that this algorithm is guaranteed to run in $O(n \log n)$ time.

Unfortunately, the median selection algorithm is not practical; while it runs in linear time, it
has much larger constant factors than we would like. To improve it, we will explore some
alternative methods for choosing a pivot.

We leave the proof of correctness of \texttt{Quicksort} as an exercise to the reader (hint: use
induction).

\section{Random Pivot Selection}
Our discussion so far suggests two approaches to pivot selection: (1) We could pick an
arbitrary element as a pivot. This is super simple and takes O(1) time (good), but the worst
case running time of the resulting algorithm would be $O(n^2)$ (bad). (2) We could pick the
median as the pivot. This takes $O(n)$ time and is somewhat complicated (bad), but gives a
worst case running time of $O(n \log n)$ (good). Can we get the best of both worlds?

One method of ``defending'' against making a bad pivot choice is to choose a random element
as the pivot. We observe that it is unlikely that the random element will be either the
median (best-case) or the maximum or minimum (worst-case). Note that we have a uniform
distribution over the $n$ order statistics of the array (this is a fancy way of saying: for every
$1 \leq i \leq n$ we pick the $i$-th highest element with the same probability $\frac{1}{n}$). Let's pause for a moment. This is the first time in this course that we have encountered an algorithm that uses randomness in its execution. Such an algorithm (that ``flips coins'' and takes actions based on the outcome of these coin flips) is called a randomized algorithm. How do we analyze a randomized algorithm?

\end{document}