% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
]{article}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
  \usepackage{unicode-math}
  \defaultfontfeatures{Scale=MatchLowercase}
  \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
  \usepackage[]{microtype}
  \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
  \IfFileExists{parskip.sty}{%
    \usepackage{parskip}
  }{% else
    \setlength{\parindent}{0pt}
    \setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
  \KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
  hidelinks,
  pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\ifluatex
  \usepackage{selnolig}  % disable illegal ligatures
\fi

\author{}
\date{}

\begin{document}

\hypertarget{honors-seminar-in-machine-learning}{%
\section{Honors Seminar in Machine
Learning}\label{honors-seminar-in-machine-learning}}

Math 3094, Spring Semester 2021 University of Connecticut

\hypertarget{instructors}{%
\subsubsection{Instructors}\label{instructors}}

\begin{itemize}
\tightlist
\item
  \href{mailto:khlee@math.uconn.edu}{Kyu-Hwan Lee}
\item
  \href{mailto:jeremy.teitelbaum@uconn.edu}{Jeremy Teitelbaum}
\end{itemize}

\hypertarget{introduction}{%
\subsubsection{Introduction}\label{introduction}}

The interdisciplinary field known as Machine Learning or Data Science
draws together techniques from computer science, mathematics, and
statistics to extract meaning from data. In this course, we will discuss
some of the essential mathematical ideas in this field.

While our focus will be on the role of Calculus, Probability, and Linear
Algebra, we will introduce computational techniques using Python and the
Jupyter notebook environment, and some ideas from statistics, in order
to closely link theory and practice.

\hypertarget{schedule}{%
\subsubsection{Schedule}\label{schedule}}

The course will meet synchronously online on Tuesdays and Thursdays from
11:00 to 12:15 EST.

\hypertarget{topics}{%
\subsubsection{Topics}\label{topics}}

Topics will include Linear Regression, Gradient Descent, Logistic
Regression, Principal Component Analysis, and others as time permits.
The course will include both (online) lectures and lab sessions.

\hypertarget{assessment}{%
\subsubsection{Assessment}\label{assessment}}

Students will be expected to complete two projects, one due at midterm
time and one by the final. The final project may be a
continuation/extension of the midterm project. A typical project will be
an example data analysis written up using the Jupyter notebook. Projects
may be done individually or in groups of up to three people.

\hypertarget{resources}{%
\subsubsection{Resources}\label{resources}}

We will use the \href{http://campuswire.com}{Campus Wire} platform for
online help and discussions. Students enrolled in the course should
receive an electronic invite to the forum. Contact one of the professors
if you need access.

We will rely on the Python programming language, the Anaconda open
source data science platform, and the Jupyter notebook environment for
our computer work. All of this software can be obtained for Linux, Mac,
or Windows from the Anaconda website:
\href{http://www.anaconda.com}{www.anaconda.com}.

A very brief guide to installing the software is
\href{installing.md}{available here}.

There is no official textbook for the course. We will be providing notes
as we progress. The following texts may be useful as references.

\begin{itemize}
\item
  James, Witten, Hastie, Tibshirani. An Introduction to Statistical
  Learning (with Applications in R). This is an introductory text on
  machine learning with a more statistical emphasis than our course, and
  with computer examples in R instead of Python. It is an excellent and
  informative work, and it is \href{https://statlearning.com/}{available
  for free} from the book home page.
\item
  Bass, Alonso-Ruiz, Baudoin, et. al.\\
  \href{https://probability.oer.math.uconn.edu/3160-oer/}{UConn's Open
  Undergraduate Probability Text}. This is the (open source) textbook
  for UConn's undergraduate probability course, Math 3160.
\item
  Boyd, S. and Vandenberghe, L.
  \href{https://web.stanford.edu/~boyd/vmls/}{Introduction to Applied
  Linear Algebra}. This is a (free) introductory text on Linear Algebra
  with a focus on applications, especially to Least Squares.
\item
  Treil, S.
  \href{https://www.math.brown.edu/streil/papers/LADW/LADW.html}{Linear
  Algebra Done Wrong}. This is a more theoretical linear algebra text
  that treats important topics such as inner product spaces.
\item
  Bishop, C.
  \href{https://www.microsoft.com/en-us/research/people/cmbishop/prml-book/}{Pattern
  Recognition and Machine Learning} This is a (free) comprehensive look
  at machine learning; it claims to be aimed at ``advanced
  undergraduates or first year PhD students'' but is technically
  demanding.
\end{itemize}

\hypertarget{policy-statements}{%
\subsection{Policy Statements}\label{policy-statements}}

\hypertarget{academic-integrity}{%
\subsubsection{Academic Integrity}\label{academic-integrity}}

Students are bound by the university's policies on academic integrity.

\hypertarget{students-with-disabilities}{%
\subsubsection{Students with
disabilities}\label{students-with-disabilities}}

Students with disabilities should contact one of the instructors as soon
as possible to discuss any accommodations needed during the semester due
to a documented disabilities. If you have a documented disability for
which you wish to request academic accommodations and have not contacted
the Center for Students with Disabilities, please do so as soon as
possible. The CSD is located in Wilbur Cross, Room 204 and can be
reached at (860) 486-2020 or at csd@uconn.edu. Detailed information
regarding the process to request accommodations is available on the CSD
website at www.csd.uconn.edu.

\hypertarget{policy-against-discrimination-harassment-and-inappropriate-romantic-relationships}{%
\subsubsection{Policy Against Discrimination, Harassment and
Inappropriate Romantic
Relationships}\label{policy-against-discrimination-harassment-and-inappropriate-romantic-relationships}}

The University is committed to maintaining an environment free of
discrimination or discriminatory harassment directed toward any person
or group within its community -- students, employees, or visitors.
Academic and professional excellence can flourish only when each member
of our community is assured an atmosphere of mutual respect. All members
of the University community are responsible for the maintenance of an
academic and work environment in which people are free to learn and work
without fear of discrimination or discriminatory harassment. In
addition, inappropriate Romantic relationships can undermine the
University's mission when those in positions of authority abuse or
appear to abuse their authority. To that end, and in accordance with
federal and state law, the University prohibits discrimination and
discriminatory harassment, as well as inappropriate Romantic
relationships, and such behavior will be met with appropriate
disciplinary action, up to and including dismissal from the University.
More information is available at http://policy.uconn.edu/?p=2884.

\hypertarget{sexual-assault-reporting-policy}{%
\subsubsection{Sexual Assault Reporting
Policy}\label{sexual-assault-reporting-policy}}

To protect the campus community, all non-confidential University
employees (including faculty) are required to report assaults they
witness or are told about to the Office of Diversity \& Equity under the
Sexual Assault Response Policy. The University takes all reports with
the utmost seriousness. Please be aware that while the information you
provide will remain private, it will not be confidential and will be
shared with University officials who can help. More information is
available at http://sexualviolence.uconn.edu/.

\end{document}


% !TEX program = xelatex
\documentclass[UTF8]{ctexart}
\usepackage{amsmath}
\usepackage{graphicx}

\usepackage{geometry}
\geometry{top=20mm,bottom=20mm,left=20mm,right=20mm}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[C]{\bf \footnotesize SYSU Collegiate Programming Contest 2020, Online}
\fancyfoot[C]{\bf \thepage}
\setlength{\topmargin}{-20mm}

\title{\bf SYSU Collegiate Programming Contest 2020, Online}
\author{}
\date{\bf November 14, 2020}

\renewcommand\contentsname{}
\renewcommand\thesection{\Large \Alph{section}.}

\def\problem#1{\clearpage \section{\Large \bf #1}}
\def\subitem#1{\noindent{\large \bf \\#1}\nopagebreak}
\def\input{\subitem{Input}}
\def\output{\subitem{Output}}
\def\sample{\subitem{Sample}}
\def\note{\subitem{Note}}
\def\source{\subitem{Source}}
\def\tabincell#1#2{\begin{tabular}[t]{@{}#1@{}}#2\end{tabular}}

\begin{document}
\maketitle
\tableofcontents
\thispagestyle{fancy}

%-----

\problem{Welcome to SYSU}

Sun Yat-sen University, originally known as National Guangdong University, was founded in 1924 by Dr. Sun Yat-sen (also called Sun Zhongshan), a great democratic revolutionary leader of the 20th century. The University is located in Guangdong Province, an area neighboring Hong Kong and Macao, which is at the forefront of China's reform and opening up.

\begin{center}
	\includegraphics[width=0.618\textwidth]{welcome.jpg}
\end{center}

Being one of the leading universities in the People's Republic of China, Sun Yat-sen University is a comprehensive multi-disciplinary university, including the humanities, social sciences, natural sciences, technical sciences, medical sciences, pharmacology, and management science. At present, Sun Yat-sen University covers a total area of 6.17 square kilometers and has 4 campuses: Guangzhou South Campus, Guangzhou North Campus, Guangzhou East Campus, and Zhuhai Campus.

\input

The input contains a positive integers n.

$1\le n\le 12$

\output

You should output the lexicographically N-th string with the same letters (2*`S'+1*`Y'+1*`U') as ``SYSU''.

\sample

\noindent\begin{tabular}{|p{5cm}|p{5cm}|} \hline
	Input            & Output              \\ \hline
	\tabincell{l}{1} & \tabincell{l}{SSUY} \\ \hline
	\tabincell{l}{5} & \tabincell{l}{SYSU} \\ \hline
\end{tabular}

\source

吴坎

%-----

\problem{Formula}

This formula is written as an equation about the length of edges A, B and C, which is usually called Pythagorean law.

$A^2 + B^2 = C^2$

Where $C$ is the length of the slanted side and $A$ and $B$ are the lengths of the other two sides.

Given $n$, you need to compute right triangles with side lengths $A$, $B$ and $C$ satisfying inequality $1 \le A \le B \le C \le n$.

\input

The first line of input contains an integer $n~(1\leq n\leq 10000)$.

\output

The first line of input contains an integer donating the answer.

\sample

\noindent\begin{tabular}{|p{5cm}|p{5cm}|} \hline
	Input            & Output           \\ \hline
	\tabincell{l}{5} & \tabincell{l}{1} \\ \hline
\end{tabular}

\note

3, 4, 5

\source

范俭豪

%-----

\problem{Island}

A tour group is trapped on an island. The island can be regarded as a matrix of equal side length.

Each grid is either an obstacle (character `\#'), a tourist (character `O'), or an open space (character `.'), visitors can walk up, down, left, right(to neighboring grid), but can't walk over obstacles.

Ask how many tourists can never get out of the island.

\input

First line of the input is an integer $T$($1\le T \le 10$) indicating the number of test cases.

For each case, the first line contains an integer $n$ ($1\le n \le 50$) indicating the side length of island, each of the following $n$ lines contains a string with exact n charactors(obstacle `\#', tourist `O' or space `.').

\output

For each case output one integer, the number of tourist(s) cannot get out of the island.

\sample

\noindent\begin{tabular}{|p{5cm}|p{5cm}|} \hline
	Input & Output         \\ \hline
	\tabincell{l}{
		1                      \\
		4                      \\
		O.\#\#                 \\
		.\#O\#                 \\
		\#O.\#                 \\
		.\#\#\#
	}     & \tabincell{l}{
		2
	}                      \\ \hline
\end{tabular}

\source

梁赛波

%-----

\problem{Liz and the Blue Bird}

After a long thought, Liz made a tough decision. When the girl came back home from picking raspberries with delight. Liz said goodbye to the girl with smile. A basket of raspberries dropped, scattering on the floor. ``You are ought to be free and use your lightsome wings to fly to everywhere you want.'' ``Why? I just want to stay with you forever. Only by your side can I taste the sweet of happiness.'' ``I am the cage that traps you. You have wings and vast sky to explore. I can't deprive you of your wings,'' Liz opened the door, smiling mildly. ``So just leave here and fly high. Please let me watch your beautiful figure go away,'' Liz held out her hand, ``That's the way I convey my feelings.'' She paused and took a deep breath ``I love you.'' The girl sobbed, stepped slowly towards door. She looked back, with love, with unwillingness, and turned into a blue bird, flying away.

\begin{center}
	\includegraphics[width=0.618\textwidth]{bluebird.jpg}
\end{center}

After the blue bird flew away, Liz still missed her very much. Worrying that she and other small animals might be caught in a storm again, Liz decided to transplant trees in the woods to cover as much area as possible. There were $n$ trees in the woods, and each tree $T_i$ can be represented as a closed interval $[a_i,b_i]$. Liz wanted to find a solution so that all intervals covered $[0,10000]$, and the displacement of the interval with the largest displacement was minimized. Specifically, suppose $T_i$ was moved to $[a_i+c_i, b_i+c_i]$, and Liz wanted to minimize $\max_i\lvert c_i \rvert$.

\input

First line of the input is an integer $n$ indicating the number of trees.

The following $n$ lines, each line contains 2 integers $a_i,b_i$.

$1<n<10000, 0\le a_i<b_i\le 10000, \sum_{i=1}^n(b_i-a_i)\ge 10000$

\output

Output a real number that represents the answer.

If the answer is an integer, output the integer directly; otherwise, keep 1 decimal place.

If you still have any questions, you can refer to the sample output.

\sample

\noindent\begin{tabular}{|p{5cm}|p{5cm}|} \hline
	Input & Output         \\ \hline
	\tabincell{l}{
		2                      \\
		10 5010                \\
		4980 9980
	}     & \tabincell{l}{
		20
	}                      \\ \hline
	\tabincell{l}{
		4                      \\
		0 4000                 \\
		3000 5000              \\
		5001 8000              \\
		7000 10000
	}     & \tabincell{l}{
		0.5
	}                      \\ \hline
\end{tabular}

\note

The answer must be a semi-integer, that is, twice the number must be an integer.

\source

吴坎

%-----

\problem{Berth Allocation}

In a container terminal, the bottleneck of the traffic is often at the quay. Therefore, the terminal operator has to allocate a limited number of berths of the quay to vessels in an efficient way.

\begin{center}
	\includegraphics[width=0.618\textwidth]{berth.png}
\end{center}

As illustrate in Figure above (An illustrated example, with a quay of $n=5$ berths, $m=7$ vessels, where two vessels are waiting outside the quay), consider a container terminal of $n$ berths and $m$ vessels arrived, where each vessel $i$ (for $i=1,2,\ldots,m$) requires a berth to load and unload containers, and the handling time is $t_{i,j}$ minutes if berth $j$ (for $j=1, 2, \ldots, n$) is allocated to vessel $i$. For each vessel $i=1,2,\ldots,m$, the terminal manager, Brother D, needs to decide on the berth, denoted by $b_i\in\{1,2,\ldots,n\}$, as well on the starting time of berthing, denoted by $s_i\ge 0$. It must be satisfied that no two vessels are allowed to occupy the same berth simultaneously, i.e., for any two different vessels i and j, if $b_i=b_j$, then either $s_i+t_{i,b_i}\le s_j$ or $s_j+t_{j,b_j}\le s_i$ must be satisfied. Your task is to help Brother D to minimize the total completion time of the vessels, i.e., to minimize $\sum_{i=1}^m(s_i+t_{i,b_i})$.

\input

First line of the input is an integer $T$ indicating the number of test cases. For each case, the first line contains two integers $n$ and $m$ (for $1\le n\le 50, 1\le m\le 200$). Each of the following $m$ lines contains $n$ positive integers representing vessel i's handling times $t_{i1}, t_{i2}, \ldots, t_{i,m} (t_{i,j} \le 1000)$.

\output

For each case, output one integer, the minimum total weighted completion time of all the vessels.

\sample

\noindent\begin{tabular}{|p{5cm}|p{5cm}|} \hline
	Input & Output         \\ \hline
	\tabincell{l}{
		1                      \\
		5 7                    \\
		1 2 3 4 5              \\
		2 1 3 4 5              \\
		2 3 1 4 5              \\
		2 3 4 1 5              \\
		2 3 4 5 1              \\
		2 2 2 2 2              \\
		2 2 2 2 2
	}     & \tabincell{l}{
		11
	}                      \\ \hline
\end{tabular}

\source

吴坎

\end{document}


\chapter{Defining the problem}

\section{Predict whether salary exceeds 50,000}
Prediction task is to determine whether a person makes over 50K a year by given data for his social background.

\section{History of the dataset}
Extraction was done by Barry Becker from the 1994 Census database
The dataset has 48,882 instances, 14 attributes, has missing values and our problem is a class

\section{Attribute information}
The dataset contains the following attributes about a person ~\cite{uci-link}:
\begin{enumerate}
    \item Age - continuos
    \item Workclass - Private, Self-emp-not-inc, Self-emp-inc, Federal-gov, Local-gov, State-gov, Without-pay, Never-worked.
    \item Fnlwgt - sample weighting; this should be ignored while creating models
    \item Education - Bachelors, Some-college, 11th, HS-grad, Prof-school, Assoc-acdm, Assoc-voc, 9th, 7th-8th, 12th, Masters, 1st-4th, 10th, Doctorate, 5th-6th, Preschool.
    \item Education-num: continuous (how many years has one learned)
    \item Marital status: Married-civ-spouse, Divorced, Never-married, Separated, Widowed, Married-spouse-absent, Married-AF-spouse.
    \item Occupation: Tech-support, Craft-repair, Other-service, Sales, Exec-managerial, Prof-specialty, Handlers-cleaners, Machine-op-inspct, Adm-clerical, Farming-fishing, Transport-moving, Priv-house-serv, Protective-serv, Armed-Forces.
    \item Relationship: Wife, Own-child, Husband, Not-in-family, Other-relative, Unmarried.
    \item Race: White, Asian-Pac-Islander, Amer-Indian-Eskimo, Other, Black.
    \item Sex: Female, Male.
    \item Capital gain: continuous, how much an individual has learned outside his usual wage
    \item Capital loss: continuous, how much an individual has lost outside his usual wage.
    \item Hours per week: continuous, how many hours per week an individual works
    \item Native country: United-States, Cambodia, England, Puerto-Rico, Canada, Germany, Outlying-US(Guam-USVI-etc), India, Japan, Greece, South, China, Cuba, Iran, Honduras, Philippines, Italy, Poland, Jamaica, Vietnam, Mexico, Portugal, Ireland, France, Dominican-Republic, Laos, Ecuador, Taiwan, Haiti, Columbia, Hungary, Guatemala, Nicaragua, Scotland, Thailand, Yugoslavia, El-Salvador, Trinadad and Tobago, Peru, Hong, Holand-Netherlands.
\end{enumerate}
\section{First look at the dataset}
There are a lot more examples from the first class (<50k earnings). If we always predict the majority class, we get accuracy of 76.07\%. This is a baseline accuracy, we obviously need result better than that. The accuracy metric is too biased and we will use the Kappa metric, since the classes are unbalanced. There are features of different scales. Two attributes have missing values: work class(6\%) and native country(2\%). There are no obvious correlation between the features and the output class \ref{fig:visual}.
\begin{figure}
    \centering
    \includegraphics[scale=0.3]{visualize_all}
    \caption{Attributes correlation with output class visualized}
    \label{fig:visual}
\end{figure}

\chapter{Analyze the data}
Since there are 48842 instances, we will use hold out set. We will split the dataset and we will use only 75\% of it. We will use the other 25\% at the end, to test how our model generalizes. Since the attributes have a lot of different scales, we will almost certainly benefit from data transformations like normalization and standardization. There does not seem to be attributes with Gaussian-like distributions, so methods which assume normal distribution like Logistic Regression and Linear Discriminant Analysis. We have a lot of attributes, so we should consider removing some of them to remove the noise and speed up the model. Since there are a lot of points, k-NN will be very slow if we search every datapoint, so alternative methods should be used like KD-trees or locality sensitivity hashing. Also note that if features are on the same scale, Euclidean distance is fine, but if they are on different, Manhattan distance should be preferred.
\section{Handling missing values}
For this dataset, it looks like the most logical decision is to replace the missing values with the mean or median for every attribute, since imputing the rows will likely lose data in this noisy dataset.
\section{Normalization and standardization}
Standardization does not seem like a good solution, since the attributes do not look Gaussian distributed. A normalized dataset however makes sense, and one is available in the Github repository for the project \cite{repo}.

\chapter{Prepare data}
We will now present different views of the datasets. Note that in every view, the attribute Fnlwgt was removed.
\section{Raw view of the dataset}
The dataset as it was downloaded from UCI Machine Learning Repository \cite{uci-link}, with Fnlwgt removed.
\section{Normalized view of the dataset}
The dataset as it was downloaded from UCI Machine Learning Repository \cite{uci-link}, with Fnlwgt removed, after applying normalizing filter.
\section{Dataset after feature selection}
In the normalized view, after evaluting attributes by their info gain and selecting the top 8, we get the following attributes: \ref{fig:attr}.
\begin{figure}
    \centering
    \includegraphics[scale=1]{selected_attibutes}
    \caption{Selected attributes from feature selection}
    \label{fig:attr}
\end{figure}

\chapter{Evaluate algorithms}
\section{Initial experiment design}
We will evaluate the datasets described in the previous chapter, and for algorithms we will use:
\begin{enumerate}
    \item Naive Bayes
    \item Logistic regression with ridge parameter $10^{-8}$
    \item Pruned C4 decision tree with confidence factor 0.25 and 2 minimum objects
    \item Linear Discriminant Analysis classifier
    \item k-Nearest Neighbor with 3 neighbors and KD-tree for searching algorithm
    \item Support vector machine using sequential minimal optimization for training and logistic regression for calibrator with radial basis function kernel and 0.001 tolerance parameter.
    \item Random forest
    \item Bootstraping aggregation
    \item Adaboost with decision stump classifier run on 100 iterations
    \item Stacking of C4 decision trees
\end{enumerate}
After the test run we see \cite{repo} that the stacking of C4 decision trees and the C4 decision tree alone give the highest results, and we will of course choose the C4 decision tree to improve the results in the next section.

\chapter{Impove results}
\section{Experiment for improving result}
We will now run the experiment with different confidence scores of the C4 decision tree:
\begin{enumerate}
    \item Confidence score: 0.1
    \item Confidence score: 0.25
    \item Confidence score: 0.4
    \item Confidence score: 0.5
\end{enumerate}
As we can see from the results \cite{repo}, the optimal decision tree is the one with confidence score 0.5 on the dataset which is not normalized at all. It achieves 0.60 Kappa statistic and accuracy of nearly 86\%.

\chapter{Present results}
The final model, C4 decision tree with confidence score 0.5, achieves 85.595\% accuracy on the unseen part of the data. See the Github repository \cite{repo} for more info.


\input{SingleAssignmentSetup.tex}
\input{../WeekTitles.tex}
\begin{document}

\begin{center}
\subsection*{MNTC P01 - Week \#1 - \WeekTitleOne}
\end{center}

\subsection*{Derivative Concept and Definition}

\begin{enumerate}[1.]
\begin{multicols}{2}
\item
\begin{Question}
  A car is driven at a speed that is initially high and then
  decreases, starting at noon.  Which of the following could be a
  graph of the distance the car has traveled as a function of time
  past noon?
\par
\begin{center}
\par\smallskip\begin{center}\begin{tabular}{|c|c|c|c|} \hline
1. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-4855-setUnit_02_DerivativeDefinitionprob1image4}
 &2. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-4855-setUnit_02_DerivativeDefinitionprob1image7}
 \\ \hline
 3. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-4855-setUnit_02_DerivativeDefinitionprob1image6}
 &4. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-4855-setUnit_02_DerivativeDefinitionprob1image5}
 \\ \hline
5. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-4855-setUnit_02_DerivativeDefinitionprob1image1}
 &6. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-4855-setUnit_02_DerivativeDefinitionprob1image2}
 \\ \hline
 7. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-4855-setUnit_02_DerivativeDefinitionprob1image3}
 &8. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-4855-setUnit_02_DerivativeDefinitionprob1image8}
 \\ \hline
\end {tabular}\end{center}\par\smallskip
\end{center}
\par
\par  \end{Question}
\begin{Solution}

Because the car is driven at a decreasing speed, the distance
traveled for different time intervals of the same length must
decrease as time goes on.  Therefore the slope of the graph
of distance traveled must decrease with increasing time, and
must be 3.
\par\end{Solution}
\item
\begin{Question}
 A car is driven at a constant speed, starting at noon.  Which of the following
could be a graph of the distance the car has traveled as a function
of time past noon?
\par
\begin{center}
\par\smallskip\begin{center}\begin{tabular}{|c|c|c|c|} \hline
1. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-2062-setUnit_02_DerivativeDefinitionprob2image4}
 &2. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-2062-setUnit_02_DerivativeDefinitionprob2image7}
 \\ \hline
 3. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-2062-setUnit_02_DerivativeDefinitionprob2image6}
 &4. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-2062-setUnit_02_DerivativeDefinitionprob2image5}
 \\ \hline
5. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-2062-setUnit_02_DerivativeDefinitionprob2image1}
 &6. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-2062-setUnit_02_DerivativeDefinitionprob2image2}
 \\ \hline
 7. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-2062-setUnit_02_DerivativeDefinitionprob2image3}
 &8. &\includegraphics[width=0.20\linewidth]{graphics/Week01_DerivativeDefinition/aableson-2062-setUnit_02_DerivativeDefinitionprob2image8}
 \\ \hline
\end {tabular}\end{center}\par\smallskip
\end{center}
\par
\par  \end{Question}
\begin{Solution}

Because the car is driven at a constant speed, the change in the
distance traveled is the same for different time intervals of the
same length.  Thus the graph of the distance traveled must have
a constant positive slope, and must be graph 5.
\par\end{Solution}
\item
\begin{Question}
 Match the points labeled on the curve below with the given slopes in the
following table.
\begin{center}
\includegraphics[width=0.5\linewidth]{graphics/Week01_DerivativeDefinition/aableson-4563-setUnit_02_DerivativeDefinitionprob3image1}
\par
\par\smallskip\begin{center}\begin{tabular}{|c|c|c|c|c|c|c|} \hline
slope &-3 &-1 &-1/2 &0 &1 &2 \\ \hline
label &&&&&&\\ \hline
\end {tabular}\end{center}\par\smallskip
\end{center}
\par  \end{Question}
\begin{Solution}

We match the points and slopes by noting that the slope is zero where the
tangent to the curve is horizontal, negative where the function is
decreasing, and positive where the function is increasing.  The magnitude
of the slope gives the rate at which the function is increasing or
decreasing, so that we have
\par
\par\smallskip\begin{center}\begin{tabular}{|c|c|c|c|c|c|c|} \hline
slope &-3 &-1 &-1/2 &0 &1 &2 \\ \hline
label &F &C &E &A &B &D \\ \hline
\end {tabular}\end{center}\par\smallskip
\par\end{Solution}
\item
\begin{Question}
 Consider the function shown in the graph below.
\par
\includegraphics[width=0.7\linewidth]{graphics/Week01_DerivativeDefinition/q_001_3}
\par
(a)For each labelled point, is the slope of the graph positive, negative or zero?  \\
(b) At which labeled point does the graph have the greatest ( i. e., most positive) slope?  \\
(c) At which labeled point does the graph have the {\bf largest negative} slope?  \\
\par\end{Question}
\begin{Solution}
 {
\vspace{-\parskip}\begin{enumerate}[(a)]
\item ~\begin{enumerate}[A.]
\item Negative
\item Negative
\item Positive
\item Positive
\item Zero
\item Negative
\end{enumerate}
\item D
\item F
\end{enumerate}}\par

\end{Solution}
\item
\begin{Question}
 Consider the {\bf  distance vs time } graph shown below.
\par
\includegraphics[width=0.7\linewidth]{graphics/Week01_DerivativeDefinition/q_002_4}
\par
Rank the following quantities as if along the real line (i.e. largest negative, through zero, up to largest positive). \\
A - Instantaneous velocity at \(t=1\). \leavevmode\\\relax
B - Instantaneous velocity at \(t=3\). \leavevmode\\\relax
C - Instantaneous velocity at \(t=4\). \leavevmode\\\relax
D - Instantaneous velocity at \(t=5\). \leavevmode\\\relax
E - Average velocity over \(t=1 \ldots 3\). \leavevmode\\\relax
F - Average velocity over \(t=4 \ldots 5\).
\par\end{Question}
\begin{Solution}
\vspace{-\parskip}
The order, from largest negative through to largest positive, is: \\
$A \to E \to B \to C \to F \to D  $

\end{Solution}
\item
\begin{Question}

\par
Let \(f(x)\) be the function whose graph is shown below.
\par
\includegraphics[width=0.8\linewidth]{graphics/Week01_DerivativeDefinition/aableson-4855-setUnit_02_DerivativeDefinitionprob6image1}
\par
Determine the derivative of \(f(a)\) at the points \(a = 1,2,4,7\).
\par  \end{Question}
\begin{Solution}

Remember that the value of the derivative of \(f\) at \(x=a\) can be interpreted as the slope of the line tangent to the graph of \(y = f(x)\) at \(x=a\).  From the figure, we see that the graph of \(y = f(x)\) is a horizontal line (that is, a line with zero slope) on the interval \(0 \le x \le 3\).  Accordingly, \(f'(1) = f'(2) = 0\).  On the interval \(3 \le x \le 5\), the graph of \(y = f(x)\) is a line of slope \(0.5\); thus, \(f'(4) = 0.5\).  Finally, the line tangent to the graph of \(y = f(x)\) at \(x=7\) is horizontal, so \(f'(7) = 0\).
\par\end{Solution}

\item
\begin{Question}

\par
Let \(f(x)\) be the function whose graph is shown below.
\par
\includegraphics[width=0.8\linewidth]{graphics/Week01_DerivativeDefinition/aableson-2062-setUnit_02_DerivativeDefinitionprob7image1}
\par
Which is larger?
\begin{itemize}
\item{A. \(f'(6.5)\)}
\item{B. \(f'(5.5)\)}
\end{itemize}
\par  \end{Question}
\begin{Solution}

The line tangent to the graph of \(y = f(x)\) at \(x = 5.5\) has a larger slope than the line tangent to the graph of \(y = f(x)\) at \(x = 6.5\).  Therefore, \(f'(5.5)\) is larger than \(f'(6.5)\).
\par\end{Solution}
\item
\begin{Question}
 Use algebra to evaluate the following limit.
\par
\(\ds \lim\limits_{h \rightarrow 0} \frac{(3+h)^2- 9  }{h} \)
\par  \end{Question}
\begin{Solution}

\(\frac{(3+h)^2- 9}{h} =
     \frac{3^2+6 h + h^2- 9}{h} =
	\frac{6 h + h^2}{h}=6+h\)
\par
Thus, as \(h\to 0\) we have
\(\frac{(3+h)^2- 9}{h} \to 6\).
\par\end{Solution}
\item
\begin{Question}
 Estimate the following limit by substituting smaller and smaller values of
\(h\), and by using algebra (the two answers should be very similar!).
\par
\(\ds \lim \limits_{h \rightarrow 0} \frac{(4+h)^3- 64  }{h} \)
\par  \end{Question}
\begin{Solution}

We try successively smaller values of \(h\):
\(\frac{(4+0.1)^3-64}{0.1}=49.2100\)
\(\frac{(4+0.01)^3-64}{0.01}=48.1201\)
\(\frac{(4+0.001)^3-64}{0.001}=48.0120\)
\(\frac{(4+0.0001)^3-64}{0.0001}=48.0012\)
\(\frac{(4+0.00001)^3-64}{0.00001}=48.0001\)
\par
These values suggest that the limit is 48.000.
\par\end{Solution}
\item
\begin{Question}
 Suppose \(y = f(x)\) graphed in the figure below
represents the cost of manufacturing \(x\) kilograms of a chemical.
\par
\begin{center}
\includegraphics[width=0.5\linewidth]{graphics/Week01_DerivativeAtAPoint/aableson-2134-setUnit_02_DerivativeAtAPointprob1image1}
\end{center}
\par
\(f(x)/x\) represents the average cost of
producing 1 kilogram of the chemical when \(x\) kilograms are made.
This problem asks you to visualize these averages graphically.
\par
\begin{enumerate}[(a)]
\item We can represent \(f(4)/4\) as the slope of a line.  Through what
points does this line extend?
\item Which is larger, \(f(3)/3\) or \(f(4)/4\)?
\end{enumerate}
\par  \end{Question}
\begin{Solution}
\begin{enumerate}[(a)]
\item \(f(4)/4\) is the slope of the line connecting
\((0,0)\) to \((4,f(4))\), as shown below.
\par
\begin{center}
\includegraphics[width=0.5\linewidth]{graphics/Week01_DerivativeAtAPoint/aableson-2134-setUnit_02_DerivativeAtAPointprob1image2}
\end{center}
\par
\item Extending the line described in part (a) for both the points $x=3$ and $x=4$, we will get a higher slope in the second case, so
\[\ds \frac{f(3)}{3} < \frac{f(4)}{4}\]
\end{enumerate}
\par\end{Solution}
\item
\begin{Question}
 Consider the function \(y = f(x)\) graphed below.
\par
\begin{center}
\includegraphics[width=0.5\linewidth]{graphics/Week01_DerivativeAtAPoint/aableson-1303-setUnit_02_DerivativeAtAPointprob2image1}
\end{center}
\par
Give the \(x\)-coordinate of a point where:
\begin{enumerate}[(a)]
\item The derivative of the function is positive.
\item The value of the function is positive.
\item The derivative of the function is largest.
\item The derivative of the function is zero.
\item The derivative of the function is approximately the same
as the derivative at \(x = 3.25\).
\end{enumerate}
\par  \end{Question}
\begin{Solution}
\begin{enumerate}[(a)]
\item Recall that the derivative is positive when the function is increasing.  So
we're looking for a point on the graph where the function is increasing;
one such point is \(x = 1\).
\par
\item
The function is positive when the function is above the \(x\)-axis.  One such point is
\(x = 1.5\).
\par
\item
The derivative of the function is largest when the function is increasing
the fastest. This occurs at \(x \approx 3.25\).
\par
\item
The derivative of the function is zero when the function has a horizontal
tangent.  One such point is \(x \approx 1.45\).
\par
\item
Finally, we're looking for a point where the derivative is the same as the
derivative at \(x = 3.25\).  This means that we want the slope of a tangent
to the curve to be approximately the same as it is at \(x = 3.25\).  Such a
point is \(x = 0.75\).
\end{enumerate}
\par\end{Solution}
\item
\begin{Question}
 Consider the graph of the function \(f(x)\) shown below.
\par
\begin{center}
\includegraphics[width=0.5\linewidth]{graphics/Week01_DerivativeAtAPoint/aableson-2475-setUnit_02_DerivativeAtAPointprob3image1}
\end{center}
\par
Using this graph, for each of the following pairs of numbers
decide which is larger.  {\it Be sure that you can explain your
answer.}
\par
\begin{enumerate}[(a)]
\item
\(f(8)\) vs. \(f(10)\)
\item
\(f(8) - f(6)\) vs. \(f(6) - f(4)\)
\item
\(\ds \frac{f(6) - f(4)}{6 - 4}\)
  vs.
  \(\ds \frac{f(8) - f(4)}{8 - 4}\)
\item
\(f'(4)\) vs. \(f'(10)\)
\end{enumerate}
\par  \end{Question}
\begin{Solution}
\begin{enumerate}[(a)]
\item
Since \(f\) is increasing,
\(f(8) < f(10)\).
\item
From the figure, it appears that
\(f(8) - f(6) > f(6) - f(4)\).
\item
The quantity \(\frac{f(6)-f(4)}{6-4}\)
represents the slope of the secant line connecting the points on the graph
at \(x=4\) and \(x=6\). This is less than the slope of the
secant line connecting the points at \(x=4\) and \(x=8\), which
is \(\frac{f(8)-f(4)}{8-4}\)
\item
The function is less steep at \(x=4\) than at \(x=10\), so
\(f'(4) < f'(10)\).
\end{enumerate}
\par\end{Solution}
\end{multicols}

\hrulefill
\subsection*{The Derivative as a Function}

\begin{multicols}{2}
\item
\begin{Question}
 Consider the function \(f(x)\) shown in the graph below.
\begin{center}
\includegraphics[width=0.5\linewidth]{graphics/Week01_DerivativeFunction/aableson-1955-setUnit_03_DerivativeFunctionprob2image1}
\end{center}
\par
Carefully sketch the derivative of the given function (you will want
to estimate values on the derivative function at different \(x\)
values as you do this).  Use your derivative function graph to
estimate the following values on the derivative function.
\par
\begin{center}
\par\smallskip\begin{center}\begin{tabular}{|c|c|c|c|c|} \hline
at \(x =\) &-3 &-1 &1 &3 \\ \hline
the derivative is &\mbox{\parbox[t]{3ex}{\hrulefill}} &\mbox{\parbox[t]{3ex}{\hrulefill}} &\mbox{\parbox[t]{3ex}{\hrulefill}} &\mbox{\parbox[t]{3ex}{\hrulefill}} \\ \hline
\end {tabular}\end{center}\par\smallskip
\end{center}
\par  \end{Question}
\begin{Solution}

At each value of \(x\), we estimate the derivative by estimating the
slope (=rise/run) from the graph.  This allows us to both sketch the
graph of the derivative and estimate the derivatives that are requested.
The derivative (in red) is shown with the original function (in blue)
below.
\par
\begin{center}
\includegraphics[width=0.5\linewidth]{graphics/Week01_DerivativeFunction/aableson-1955-setUnit_03_DerivativeFunctionprob2image2}
\end{center}
\par
From the graph and our calculations, it appears that
\(f'(-3) \approx -1\), \leavevmode\\\relax
\(f'(-1) \approx 2\), \leavevmode\\\relax
\(f'(1) \approx 0\), and \leavevmode\\\relax
\(f'(3) \approx -2\). \leavevmode\\\relax
\par\end{Solution}
\item
\begin{Question}
Below is the graph of \(f(x)\). Sketch the graph of $f'(x)$.
\includegraphics[width=0.3\linewidth]{graphics/Week01_DerivativeFunction/aableson-4521-setUnit_03_DerivativeFunctionprob5image1}
\par
\par\end{Question}
\begin{Solution}

The {\bf slope} on the original function is constant, so the {\bf derivative} value is constant.

\includegraphics[width=0.3\linewidth]{graphics/Week01_DerivativeFunction/aableson-4521-setUnit_03_DerivativeFunctionprob5image2}

\end{Solution}
\item
\begin{Question}
Below is the graph of \(f(x)\). Sketch the graph of $f'(x)$.
\includegraphics[width=0.5\linewidth]{graphics/Week01_DerivativeFunction/aableson-1624-setUnit_03_DerivativeFunctionprob6image1}
\par
\par\end{Question}
\begin{Solution}
There is a point with {\bf slope} zero at $x=2$, so there must be a {\bf derivative} value of zero at $x=2$. \\
For smaller values of $x$, the {\bf slopes} are negative, so the {\bf derivative} values will be negative. \\
For larger values of $x$, the {\bf slopes} are positive, so the {\bf derivative} values will be positive. \\

\hfil \includegraphics[width=0.50\linewidth]{graphics/Week01_DerivativeFunction/aableson-1624-setUnit_03_DerivativeFunctionprob6image2}

Note that the graph of $f'(x)$ shown here has an accurate vertical
scale; however, that would be difficult for you to estimate by eye
based simply on the graph of $f(x)$, so we do not expect that level of
precision on a test or exam.

\end{Solution}
\item
\begin{Question}
Below is the graph of \(f(x)\). Sketch the graph of $f'(x)$.
\includegraphics[width=0.6\linewidth]{graphics/Week01_DerivativeFunction/aableson-880-setUnit_03_DerivativeFunctionprob7image1}
\par\end{Question}
\begin{Solution}
There are two points with {\bf slope} zero, at $x=2$ and $x \approx 2.5$, so there must be a {\bf derivative} value of zero at those two $x$ locations. \\
In between those landmark points, the slopes of $f$ go: negative, positive, negative.

 \includegraphics[width=0.60\linewidth]{graphics/Week01_DerivativeFunction/aableson-880-setUnit_03_DerivativeFunctionprob7image2}

Note that the graph of $f'(x)$ shown here has an accurate vertical
scale; however, that would be difficult for you to estimate by eye
based simply on the graph of $f(x)$, so we do not expect that level of
precision on a test or exam.

\end{Solution}
\item \begin{Question}
  For the function \(f(x)\) shown in the graph below, sketch a graph
  of the derivative.
\par
\begin{center}
\includegraphics[width=0.6\linewidth]{graphics/Week01_DerivativeFunction/aableson-4073-setUnit_03_DerivativeFunctionprob3image1}
\end{center}
\par
\par  \end{Question}
\begin{Solution}

Because the derivative gives the slope of the original function at
each point \(x\), we know that the derivative is negative where
\(f(x)\) is decreasing and positive where it is increasing.  Applying
this to \(f(x)\), a sketch of the derivative would resemble the graph below:
\par
\begin{center}
\includegraphics[width=0.5\linewidth]{graphics/Week01_DerivativeFunction/aableson-4073-setUnit_03_DerivativeFunctionprob3image2}
\end{center}
\par\end{Solution}
\item
\begin{Question}
 A child fills a pail by using a water hose.  After finishing, the child
plays in a sandbox for a while before tipping the pail over to empty it.
If \(V(t)\) gives the volume of the water in the pail at time \(t\),
then the figure below shows \(V'(t)\) as a function of \(t\).
\par
\begin{center}
\includegraphics[width=0.5\linewidth]{graphics/Week01_DerivativeFunction/aableson-3218-setUnit_03_DerivativeFunctionprob4image1}
\end{center}
\par
At what time does the child:
\begin{enumerate}[(a)]
\item Begin to fill the pail?
\item Finish filling the pail?
\item Tip the pail over?
\end{enumerate}
\par  \end{Question}
\begin{Solution}

The child begins filling the pail when \(V'(t)\) becomes positive,
which is when the volume of water in the pail starts increasing.  This is
at \(t = 3\).  The child finishes filling the pail when the volume stops
increasing, which is at \(t = 9\).  The child tips the pail over when the
volume of water in the pail start decreasing, which is where  \(V'(t)\)
first becomes negative, which is at \(t=14\).
\par\end{Solution}
\end{multicols}

\hrulefill

\subsection*{Computing Derivatives}

Below are a {\bf small sample of problems} involving the computation
of derivatives.  They are {\bf not enough} to properly learn and
memorize how to apply all the derivative rules.  You should practice
with as many problems as you need to become proficient at computing
derivatives.

Further practice problems can be found in any calculus textbook.    For example,

\begin{multicols}{2}

From Hughes-Hallett 5th edition,  \\
Section 3.1 - 7-47 (odd)\symbolfootnote[2]{For this section, simplify products and fractions {\em before} you differentiate, rather than using the product rule and quotient rule.} \\
Section 3.2 - 1-33 (odd)  \\
Section 3.3 - 3-29 (odd) \\
Section 3.4 - 1-49 (odd) \\
Section 3.5 - 3-39 (odd) \\  % All pure differentiation problems; no word problems
Section 3.6 - 1-33 (odd)

\columnbreak

From Hughes-Hallett 6th edition,  \\
Section 3.1 - 7-49 (odd)\symbolfootnote[2]{For this section, simplify products and fractions {\em before} you differentiate, rather than using the product rule and quotient rule.} \\
Section 3.2 - 1-25 (odd)  \\
Section 3.3 - 3-29 (odd) \\
Section 3.4 - 1-55 (odd) \\
Section 3.5 - 3-47 (odd) \\  % All pure differentiation problems; no word problems
Section 3.6 - 1-41 (odd)

\end{multicols}

\hrulefill

\begin{multicols}{2}
\item
\begin{Question}
 Let \(f(x) =  4 e^x - 9 x^2 + 5\). Compute  \(f'( x )\).
\par\end{Question}
\begin{Solution}
$f'(x) = 4e^x - 18 x$

\end{Solution}
\item
\begin{Question}
\par
Let \(\displaystyle f(x) =  2 x^{6} \sqrt{x} + \frac{-5} {x^{3} \sqrt{x} }\). Compute $f'(x)$.
\par
\par\end{Question}
\begin{Solution}
You can use the product rule here if you like, but it is far easier to rewrite the function before you start,
since all the terms are just powers of $x$.
\begin{align*}
f(x) & =  2 x^{6} \sqrt{x} + \frac{-5} {x^{3} \sqrt{x}}  \\
f(x) & =  2 x^{6} \cdot x^{1/2} + \frac{-5} {x^{3} \cdot x^{1/2}}  \\
& = 2 x^{\frac{13}{2}} -5 x^{\frac{-7}{2}}
\end{align*}
Differentiating,
\begin{align*}
f'(x) & = 2 \frac{13}{2}x^{\frac{11}{2}} -5\left(\frac{-7}{2}\right) x^{\frac{-9}{2}} \\
& = 13 x^5 \sqrt{x} + \frac{35}{2 x^4 \sqrt{x}}
\end{align*}

\end{Solution}
\item
\begin{Question}
 Let
\(\ds f(x) =  \frac { 7 x^2 + 7 x + 5 } {\sqrt{x} }\).

(a) Compute \(f'( x )\).  \hfill (b) Find \(f'( 3 )\).\hfill \hfill
\par\end{Question}
\begin{Solution}
You can use the quotient rule here if you like, but it is far easier to rewrite the function before you start,
since all the terms are just powers of $x$.
\begin{align*}
f(x)&  =  \frac { 7 x^2 + 7 x + 5 } {\sqrt{x} } \\
& = 7 x^{3/2} + 7 x^{1/2} + 5 x^{-1/2}
\end{align*}
\begin{enumerate}[(a)]
\item $\ds f'(x) = \frac{21}{2} x^{1/2} + \frac{7}{2} x^{-1/2} - \frac{5}{2} x^{-3/2}$
\item Evaluating $f'(x)$ at $x=3$, we obtain $\approx 19.726$.
\end{enumerate}

\end{Solution}
\item
\begin{Question}
 Let \(f(t) =  7 t^{-7}\).

(a) Compute \(f'( t )\). \hfill (b) Find \(f'( 3 )\). \hfill \hfill
\par\end{Question}
\begin{Solution}
\begin{enumerate}[(a)]
\item $f'(x) = -49 ~t^{-8}$
\item $f'(3) = -49 ~(3^{-8})$
\end{enumerate}

\end{Solution}
\item
\begin{Question}
 Let \(f(x) =  4 e^{x} + e^{1}\). Compute \(f'( x ) .\)
\par\end{Question}
\begin{Solution}
Don't be thrown off by the $e^{1}$: that's a constant (equal to $e$ or $\approx$ 2.7), so the derivative of that term is zero.

$f'(x) = 4 e^{x}$

\end{Solution}
\item
\begin{Question}
 Let \(f(x) =  4 e^{x} + 4 x\). Compute \(f'( x ).\)
\par\end{Question}
\begin{Solution}
$f'(x) = 4 e^x +4$
\end{Solution}
\item
\begin{Question}
 \(f(x) =  (3 x^2 - 2 )(6 x + 3)\).

(a) Compute \(f'( x )\). \hfill
(b) Find \(f'( 4 )\). \hfill \hfill
\par\end{Question}
\begin{Solution}
You can either expand the product before differentiating (and obtain $f(x) = 18x^3 +9x^2-12x-6$), or use the product rule.  Both give the same answer.
\begin{enumerate}[(a)]
\item $f'(x) =  54x^2 + 18x -12$.
\item $f'(4) = 924$.
\end{enumerate}

\end{Solution}
\item
\begin{Question}
\par

Let \(\ds f(x) =  \frac {\sqrt { x } - 4 } {\sqrt { x } + 4 }\).  Compute $f'(9)$.
\par\end{Question}
\begin{Solution}
We need to use the quotient rule for this function.
\begin{align*}
f'(x) & = \frac{\frac{1}{2}x^{-1/2}(x^{1/2} + 4) - (x^{1/2}-4)\left(\frac{1}{2}\right)x^{-1/2}}{ (\sqrt{x} + 4)^2} \\
& = \frac{1 + 4/\sqrt{x} - 1 + 4/\sqrt{x}}{2(\sqrt{x} + 4)^2} \\
& = \frac{4}{\sqrt{x} (\sqrt{x} + 4)^2} \\
f'(9) & = \frac{4}{3 (3 + 4)^2} \\
& = \frac{4}{147}
\end{align*}

\end{Solution}
\item
\begin{Question}
 Consider $\ds f(x) =  \frac { 4 x +  3 } { 3 x + 2 }$.

(a) Compute \(f'( x )\). \hfill
(b) Find \(f'( 5 )\). \hfill \hfill
\par\end{Question}
\begin{Solution}
\begin{enumerate}[(a)]
\item $\ds f'(x) = \frac{4(3x+2) - (4x+3)(3)}{(3x+2)^2}$
\item $\ds f'(5) = \frac{-1}{17^2}$
\end{enumerate}

\end{Solution}
\item
\begin{Question}
Consider $\ds f(x) =  \frac { 7 - x^2 } { 7 + x^2 }$

(a) Compute \(f'( x )\). \hfill
(b) Find \(f'( 1 )\). \hfill \hfill
\par\end{Question}
\begin{Solution}
\begin{enumerate}[(a)]
\item $\ds f'(x) = \frac{-28x}{ (x^2 + 7)^2}  $
\item $\ds f'(1) = \frac{-28}{ 64}  $
\end{enumerate}

\end{Solution}
\item
\begin{Question}
Let \(f(x) = -2 x(x-3)\).

(a) Compute \(f'(x)\). \hfill (b) Find \(f'(-5)\). \hfill \hfill
\par\end{Question}
\begin{Solution}
\begin{enumerate}[(a)]
\item $f'(x) = -4x+6$
\item $f'(-5) = 26$
\end{enumerate}
\end{Solution}
\item
\begin{Question}
$\ds f(x) =  \frac {4 x^3- 3} {x^4}$

(a) Compute \(f'( x )\). \hfill
(b) Find \(f'( 2 )\). \hfill \hfill
\par\end{Question}
\begin{Solution}
\begin{enumerate}[(a)]
\item $-4x^{-2}+12x^{-5}$
\item $-0.625$
\end{enumerate}

\end{Solution}
\item
\begin{Question}
$\ds g(x) = \frac{e^x}{5 + 4x}$.  Compute $g'(x)$.
\par\end{Question}
\begin{Solution}
$\ds g'(x) = \frac{(1 +4x )e^x }{(5+4x)^2}$

\end{Solution}
%\item
%\begin{Question}
%$\ds f(x) =  \frac {\sqrt { x } - 5 }{\sqrt { x } + 5 }$
%
%(a) Compute \(f'( x )\). \hfill
%(b) Find \(f'( 2 )\). \hfill \hfill
%\par\end{Question}
%\begin{Solution}
%\begin{enumerate}[(a)]
%\item $\ds f'(x) = \frac{5}{\sqrt{x} (\sqrt{x} + 5)^2}$
%\item $\ds f'(2) = \frac{5}{\sqrt{2} (\sqrt{2} + 5)^2} \approx 0.08593$
%\end{enumerate}
%\end{Solution}
\item
\begin{Question}
\(\ds f(x) =  \frac { 4 x^2 \tan x }{ \sec x }\).

(a) Find \(f'( x )\).  \hfill
(b) Find \(f'( 3 )\). \hfill \hfill
\par\end{Question}
\begin{Solution}
This should definitely be simplified before you differentiate!

Recall: $\ds \tan(x) = \frac{\sin(x)}{\cos(x)}$, and $\ds \sec(x) = \frac{1}{\cos(x)}$,
so $\ds \frac{\tan(x)}{\sec(x)} = \frac{\sin(x)}{\cos(x)} \cos(x) = \sin(x)$.

\begin{enumerate}[(a)]
\item $f'(x) = 8x \sin(x) + 4x^2 \cos(x)$
\item $f'(3) = 24 \sin(3) + 36 \cos(3) \approx -32.253$
\end{enumerate}
\end{Solution}
\item
\begin{Question}
\(f(x) = 7 \sin x + 12 \cos x\)

(a)Compute \(f'(x)\). \hfill
(b) Find \(f'( 1 )\). \hfill \hfill
\par\end{Question}
\begin{Solution}

\begin{enumerate}[(a)]
\item $f'(x) = 7\cos(x) - 12 \sin(x)$
\item $f'(1) = 7 \cos(1) - 12 \sin(1) \approx -6.3155$
\end{enumerate}

\end{Solution}
\item
\begin{Question}
Let \(f(x) =  \cos x - 2 \tan x\). Compute \(f'(x)\).
\par\end{Question}
\begin{Solution}
$f'(x) = -\sin(x)-2 \sec^2(x)$
\end{Solution}
\item
\begin{Question}
$\ds f(x) = \frac { 5 \sin x }{ 3 + \cos x }$

(a) Compute \(f'( x )\). \hfill
(b) Find \(f'( 2 )\).\hfill \hfill
\par\end{Question}
\begin{Solution}
Don't forget the identity $\sin^2(x) + \cos^2(x) = 1$.
\begin{enumerate}[(a)]
\item $f'(x) = (15 \cos(x)+5)/(3+\cos(x))^2$
\item $f'(2) = (15 \cos(2) + 5)/(3 + \cos(2))^2 \approx -0.18606$
\end{enumerate}
\end{Solution}
\item
\begin{Question}
$\ds f(x) = 7 x( \sin x + \cos x) $

(a) Compute $f'(x)$. \hfill
(a) Find $f'(3)$. \hfill \hfill
\par
\par\end{Question}
\begin{Solution}
\begin{enumerate}[(a)]
\item $f'(x) = 7(\sin(x)+\cos(x))+ 7x(\cos(x)-\sin(x))$
\item $f'(3) \approx -29.695$
\end{enumerate}

\end{Solution}
%\item
%\begin{Question}
% Let \[f(x) = 6 \sin (\sin x)\]
%\par
%\(f'( x ) =\) \mbox{\parbox[t]{15ex}{\hrulefill}}
%\par\end{Question}
%\begin{Solution}
%\item $6*cos(sin(x))*cos(x)$
%
%\end{Solution}
\item
\begin{Question}
Let  \(\ds f(x) = \cos ( \sin ( x ^2 ))\). Compute $f'(x)$.
\par\end{Question}
\begin{Solution}
$f'(x) = -\sin(\sin(x^2)) \cos(x^2)\cdot (2x)$

\end{Solution}
%\item
%\begin{Question}
% Let \[f(x) = (x^3+ 4 x + 3) ^ { 2 }\]
%\par
%\(f'( x ) =\) \mbox{\parbox[t]{20ex}{\hrulefill}}
%\par
%\par\end{Question}
%\begin{Solution}
%$(2*(x**3+4*x+3)**(2-1))*(3*x*x+4)$
%
%\end{Solution}
%\item
%\begin{Question}
% Let \(f(x) = 7 e^{x \cos x}\). \leavevmode\\\relax
%\(f'( x ) =\) \mbox{\parbox[t]{15ex}{\hrulefill}}
%\par\end{Question}
%\begin{Solution}
%$7*e^(x*cos(x))*(cos(x) - x*sin(x))$
%
%\end{Solution}
\item
\begin{Question}
 Let \(f(x) = 2 \sin ^{3} x\). Compute $f'(x)$.
\par\end{Question}
\begin{Solution}
$f'(x) = 6\sin^2(x) \cos(x)$

\end{Solution}
\item
\begin{Question}
 Let $y = (8 + \cos^2{x})^{6}$.  Compute $\ds \frac{dy}{dx}$.
\par
\par\end{Question}
\begin{Solution}
$\ds \frac{dy}{dx} = 6 (8+cos^2(x))^5(2 \cos(x) (-\sin(x)))$

\end{Solution}
\item
\begin{Question}
 Let $f(x) = -3 \ln[\sin(x)]$.  Compute $f'(x)$.
\par\end{Question}
\begin{Solution}
$\ds f'(x) = \frac{-3}{\sin(x)} \cos(x) \mbox{ or, using trig identities } = -3 \cot(x)$

\end{Solution}
 \item
 \begin{Question}
  Let \(f(x) = 2 \ln(4+x)\). Compute \(f'( x )\).
 \par\end{Question}
 \begin{Solution}
 $\ds f'(x) = \frac{2}{4+x}$
 \end{Solution}
%\item
%\begin{Question}
% If \(f(x) = 2 \cos(5\ln(x))\), find \(f'( x )\).
%Find \(f'( 2 )\).
%\par\end{Question}
%\begin{Solution}
%\item $-2*sin(5*ln(x))*5/x$
%\item 1.59248384128973
%
%\end{Solution}
%\item
%\begin{Question}
% Let \[f(x) = \ln (x^ {2})\]
%\par
%\(f'( x ) =\) \mbox{\parbox[t]{20ex}{\hrulefill}}
%\par
%\(f'( e^{4} ) =\) \mbox{\parbox[t]{20ex}{\hrulefill}}
%\par\end{Question}
%\begin{Solution}
%\item 2 / x
%\item 0.0366312778022126
%
%\end{Solution}
%\item
%\begin{Question}
% Let \[f(x) = 9^x \log_{4} (x)\]
%\par
%\(f'( x ) =\) \mbox{\parbox[t]{20ex}{\hrulefill}}
%\par\end{Question}
%\begin{Solution}
%\item $9^x*(ln(9)*ln(x)/ln(4)+1/x/ln(4))$
%
%\end{Solution}

\item
\begin{Question}
Consider the function $\cos(\arccos(x))$.
\begin{enumerate}[(a)]
\item Simplify the expression to get a simple equation.
\item Differentiate both sides of the equation, and then solve for
  $\ds \ddx{} \arccos(x)$.
\item Use the trig identity $\sin(\theta) = \sqrt{1 - \cos^2(\theta)}$
    to simplify your expression for $\ds \ddx \arccos(x)$.
\end{enumerate}
\end{Question}

\begin{Solution}
\begin{enumerate}[(a)]
\item Since $\cos$ and $\arccos$ are inverse functions, if we start
  with $x$ then apply both functions, we get back to $x$:
$$ \cos(\arccos(x)) = x$$.
\item Differentiating both sides,
  \begin{align*}
    \ddx{} \cos(\arccos(x)) & = \ddx{} x \\
-\sin(\arccos(x)) \cdot \ddx{} \arccos(x) & = 1 \\
\mbox{ so } \ddx{} \arccos(x) & = \frac{1}{-\sin(\arccos(x))}
  \end{align*}
\item To simplify the denominator, we note that
  \begin{align*}
\sin(\arccos(x)) & = \sqrt{1 - \cos(\arccos(x))} \\
& = \sqrt{1 - x^2}
  \end{align*}
so
\begin{align*}
\ddx{} \arccos(x) & = \frac{1}{-\sqrt{1-x^2}} \\
& = \frac{-1}{\sqrt{1 - x^2}}
\end{align*}
\end{enumerate}

\end{Solution}

%*******************************
\item
\begin{Question}
Consider the function $\tan(\arctan(x))$.
\begin{enumerate}[(a)]
\item Simplify the expression to get a simple equation.
\item Differentiate both sides of the equation, and then solve for
  $\ds \ddx{} \arctan(x)$.
\item Use the trig identity $\sec^2(\theta) = 1 + tan^2(\theta)$
    to simplify your expression for $\ds \ddx \arctan(x)$.
\end{enumerate}

\end{Question}

\begin{Solution}
\begin{enumerate}[(a)]
\item Since $\tan$ and $\arctan$ are inverse functions, if we start
  with $x$ then apply both functions, we get back to $x$:
$$ \tan(\arctan(x)) = x$$.
\item Differentiating both sides,
  \begin{align*}
    \ddx{} \tan(\arctan(x)) & = \ddx{} x \\
\sec^2(\arctan(x)) \cdot \ddx{} \arctan(x) & = 1 \\
\mbox{ so } \ddx{} \arctan(x) & = \frac{1}{\sec^2(\arctan(x))}
  \end{align*}
\item To simplify the denominator, we note that
  \begin{align*}
\sec^2(\theta) & = 1 + tan^2(\theta) \\
\mbox{ so }&  \\
\sec^2(\arctan(x)) = 1 + \tan^2(\arctan(x)) \\
& =  1 + x^2\\
  \end{align*}
meaning the derivative can be rewritten as
\begin{align*}
\ddx{} \arctan(x) & = \frac{1}{1 + x^2}
\end{align*}
\end{enumerate}

\end{Solution}

%*******************************
\item
\begin{Question}
Take the derivative of  $y = \arcsin(4x)$.
\end{Question}

\begin{Solution}
  \begin{align*}
    \ddx{} \arcsin(4x) = \frac{1}{\sqrt{1 - (4x)^2}}(4)
  \end{align*}
\end{Solution}

%*******************************
\item
\begin{Question}
If $f(x) = x \arctan(x)$, find $f'(x)$.
\end{Question}

\begin{Solution}
  \begin{align*}
   f'(x) = (1) \arctan(x) + x \left(\frac{1}{ 1+ x^2}\right)
  \end{align*}
\end{Solution}

%*******************************
\item
\begin{Question}
Find the slope of $\ds y = \frac{3x}{\arccos(x)}$ at the point $x=0$.
\end{Question}

\begin{Solution}
  \begin{align*}
    y'  & = \frac{ (3) \arccos(x) - (3x) \frac{1}{\sqrt{1-x^2}}}{(\arccos(x))^2}
  \end{align*}
Evaluating this at $x = 0$,
  \begin{align*}
    y'(0)  & = \frac{ (3) \arccos(0) - (0) \frac{1}{\sqrt{1-0^2}}}{(\arccos(0))^2} \\
      & = \frac{ (3) \arccos(0) }{(\arccos(0))^2} \\
  \end{align*}
Remembering that since $\cos(\pi/2) = 0$, then $\arccos(0) = \pi/2$,
  \begin{align*}
      y'(0) & = \frac{ (3) \frac{\pi}{2} }{(\frac{\pi}{2})^2} \\
& = \frac{6}{\pi}
  \end{align*}
\end{Solution}
\item
\begin{Question}

\par
Let
\(f(x) = \arcsin\!\left(x\right)\).

(a) Compute $f'(x)$ \hfill
(b) Find $f'(0.4)$.
\par  \end{Question}
\begin{Solution}
Recall that the derivative of \(\arcsin(x) \) is: \\
\(f'(x) = \frac{1}{\sqrt{1-x^2}}\) \\
Evaluating this at \(x = 0.4\), we get: \\
\(f'(0.4) \approx 1.0911\)
\par\end{Solution}
\item
\begin{Question}
Let $\ds f(x)=\frac{\arccos(14 x)}{\arcsin(14 x)}$.  Compute $f'(x)$.
\par  \end{Question}
\begin{Solution}
Applying the quotient rule: \leavevmode\\\relax
\[\begin{array}{rcl}
f'(x)
&=& \displaystyle \frac{ \arcsin(14 x) \left( \arccos(14 x) \right) ' - \arccos(14 x) \left( \arcsin(14 x) \right) ' }{\left( \arcsin(14 x) \right)^2 } \\
&=& \displaystyle \frac {\frac {-14 \arcsin(14 x)}{\sqrt{1-(14 x)^2}} - \frac {14 \arccos(14 x)}{\sqrt{1-(14 x)^2}} }{ (\arcsin(14 x))^2} \\
&=& \displaystyle \frac {-14 \left( \arcsin(14 x) + \arccos(14 x) \right)}{ \left( \arcsin(14 x) \right)^2 \sqrt{1-(14 x)^2}}
\end{array}\]
\par\end{Solution}
\item
\begin{Question}

\par
Let \[P=\frac{V^{2}R}{\left(R+r\right)^{2}}.\]
Calculate \(\ds \frac{dP}{dr}\),
assuming that \(r\) is variable and \(R\) and \(V\) are constant.
\par
\par  \end{Question}
\begin{Solution}

\par
Note that \(V\) is also constant. Let
\[f(r)=\frac{V^2 R}{(R+r)^2}=\frac{V^2 R}{R^2+2Rr+r^2}.\]
Using the quotient rule:
\[f'(r)=\frac{(R^2+2Rr+r^2)(0) - (V^2 R)(2R + 2r)}{(R+r)^4}\]
\[= -\frac{2V^2 R(R+r)}{(R+r)^4} = -\frac{2V^2 R}{(R+r)^3}.\]
\par\end{Solution}

\end{multicols}

\hrulefill

\subsection*{Inverse Trig Functions}

\begin{multicols}{2}

%*******************************
\item
\begin{Question}
  \begin{enumerate}[(a)]
  \item Sketch the graph of $y = \arccos(x)$.
  \item Find the exact values of
    \begin{enumerate}[(i)]
    \item $\arccos(0)$
    \item $\arccos(0.5)$
    \item $\arccos(1)$
    \item $\arccos(-1)$
    \end{enumerate}
  \end{enumerate}
\end{Question}

\begin{Solution}
  \begin{enumerate}[(a)]
  \item The graph of $y = arccos(x)$ can be created by reflecting
the $y = \cos(x)$ graph across the $y = x$ line.
\begin{center}
\includegraphics[width=0.8\linewidth]{graphics/Week01_InverseTrig/arccos}
\end{center}
\item These calculations depend on the inverse relationship between
  $\cos$ and $\arccos$, and your background knowledge of the $\cos(x)$
  graph/function.
\begin{enumerate}[(i)]
\item Since $\cos(\pi/2) = 0$, then $\arccos(0) = \pi/2$.
\item Since $\cos(\pi/3) = 0.5$ (try drawing a 30/60 triangle to
  confirm), then $\arccos(0.5) = \pi/3$.
\item Since $\cos(0) = 1$, then $\arccos(1) = 0$.
\item Since $\cos(\pi) = -1$, then $\arccos(-1) = \pi$.
\end{enumerate}
All the points are indicated on the $y = \arccos(x)$ graph below.
\begin{center}
\includegraphics[width=0.8\linewidth]{graphics/Week01_InverseTrig/arccos_with_points}
\end{center}
  \end{enumerate}
\end{Solution}

%*******************************
\item
\begin{Question}
  \begin{enumerate}[(a)]
  \item Sketch the graph of $y = \arctan(x)$.
  \item Find the exact values of
    \begin{enumerate}[(i)]
    \item $\arctan(0)$
    \item $\arctan(1)$
    \item $\arctan(-1)$
    \item $\arctan(x)$ as $x$ gets very large.
    \end{enumerate}
  \end{enumerate}
\end{Question}

\begin{Solution}
  \begin{enumerate}[(a)]
  \item The graph of $y = \arctan(x)$ can be created by reflecting
the $y = \tan(x)$ graph across the $y = x$ line.
\begin{center}
\includegraphics[width=0.8\linewidth]{graphics/Week01_InverseTrig/arctan}
\end{center}
\item These calculations depend on the inverse relationship between
  $\tan$ and $\arctan$, and your background knowledge of the $\tan(x)$
  graph/function.
\begin{enumerate}[(i)]
\item Since $\tan(0) = 0$, then $\arctan(0) = 0$.
\item Since $\tan(\pi/4) = 1$ (try drawing a 45/45 triangle to
  confirm), then $\arctan(1) = \pi/4$.
\item Similarly $\tan(-\pi/4) = -1$, so $\arctan(-1) = \pi/4$.
\item Looking at the horizontal asymptote of the $y = \arctan(x)$
  graph, the limiting value as $x$ increases is $\ds y \to
  \frac{\pi}{2}$.
\end{enumerate}
  \end{enumerate}
\end{Solution}
\end{multicols}
\end{enumerate}
\end{document}


\section{\textbf{What} is quantum computing?}

\begin{fullwidth}

\textit{Quantum computing} sounds pretty intimidating to most people. What if I remove the ``quantum'' part, leaving only the ``computing'' part?
Much friendlier, huh?
The ``computing'' part is plain as simple: Give a system some input, and it will give you some output.
Now comes the jargon, ``quantum''. The word ``quantum'' comes from \textit{Quantum Mechanics}, a branch of physics that study tiny things.
Therefore, \textit{quantum computing} is essentially a way of using tiny particles to do calculation for us.
The quantum computer manipulates on subatomic particles to do calculations, so you can imagine it is EXTREMELY difficult to build a quantum computer.
Although there are prototypes of quantum computer as year of 2018, none of them has real application yet.
However, quantum computing is not that far away from us.
In fact, people believe it will become an critical technology in the following decades.

\end{fullwidth}

\section{\textbf{Why} quantum computing?}

\begin{marginfigure}[15\baselineskip]
    \includegraphics[width=\linewidth]{chapter1/quantum-computer-picture}
    \caption{Support structure for a D-WAVE quantum computer.}
    \label{fig:chapter1-quantum-computer-picture}
\end{marginfigure}

In short, quantum computer (Figure \ref{fig:chapter1-quantum-computer-picture}\cite{Chapter1-quantum-computer-picture}) can solve problems we can never solve with classical computer.
For example, there is an encryption algorithm we use everywhere, everyday, called RSA algorithm.
By using RSA algorithm, our passwords are encrypted during transmission and keep our money/data safe.
It is safe because it will take centuries for the most powerful super computer to decrypt the message encrypted by RSA.
But for quantum computer? This decryption process could be just a matter of seconds.
What does that mean? If you have a quantum computer today, you would be able to hack almost all bank accounts on earth.
Of course, we don't want to build a quantum computer only good for hacking bank accounts, right?
There are a number of other applications like climate simulation, machine learning, material research, etc.
You already know how computers change the world.
Then just imagine the world will be changed again by quantum computers, and embrace the future!

\section{\textbf{How} can we try quantum computing?}

\begin{fullwidth}

As of April 2018, there are a few options for us to write quantum programs on a simulated quantum computer.
Why simulated quantum computer? Because the real quantum computer doesn't exist yet!
Furthermore, using simulated quantum computer can get our hands dirty already.
The Q\# language from Microsoft will be used as the main language for quantum programs throughout the book.

\end{fullwidth}

\section{Introduction to quantum mechanics}

\begin{fullwidth}

Before playing around with quantum computing, we need to have some basic background in quantum mechanics.
But don't worry, let's go through the basics together.
Since the mathematical foundation of quantum mechanics is linear algebra, we are gonna learn linear algebra first.
Then we will use the powerful mathematical tool to explain a few important ideas in quantum mechanics.
Finally, we will apply our newly learned knowledge to write our first quantum program!
How cool is that!
So please bear with me for the theoretical part.
Otherwise, you will not understand how we code the quantum program.

\end{fullwidth}

\subsection{Linear algebra for quantum computing}
It could easily take a few months for normal people to learn linear algebra.
Therefore, we will only cover essential parts here.
There are numerous resources on linear algebra out there, if you want to learn more about it.
For example, the MIT open course: \href{https://ocw.mit.edu/courses/mathematics/18-06-linear-algebra-spring-2010/}{Linear Algebra 18.06} from Prof. Strang\cite{Chapter1-mit-linear-algebra} is extremely good, and you can benefit a lot by completing it.

\subsubsection{\textbf{What} is linear algebra?}

\section{Your first quantum program with Q\#}

\begin{fullwidth}

Now let's get down to business. It's time to write our first quantum program!
But first things first, let me give you an overview of Q\#.
Q\# is a quantum programming language.
This means that Q\# is designed to express quantum algorithm or logic instead of classical computation.
The Q\# language is NOT a program language that we can use for implementing classical algorithms.
Therefore, when we want to write a complete quantum program, we might end up using some classical programming language along with quanutm programming language like Q\#.
For example, let's say you live in the U.S., and you want to visit China.
What you will probably do is to take a car ride to the airport, then take the plain to China, right?
In the example, the car is the classical language and the plain is the quantum language.
They both have their own strength, and only by working together they can get you to your destination.

\end{fullwidth}

Now let's do the coding.
This program is taken from Microsoft blog\cite{Chapter1-first-quantum-program}, but that blog assumes the reader has some quantum computing background.
So instead of redirecting you to the article, let's walk through the program together with our beloved rubber duck methodology\cite{Chapter1-rubber-duck}.

\begin{marginfigure}[\baselineskip]
    \includegraphics[width=\linewidth]{chapter1/rubber-duck-debugging}
    \caption{Rubber duck debugging}
    \label{fig:chapter1-rubber-duck-picture}
\end{marginfigure}

For those who doesn't know what rubber duck methodology is, I encourage you to spend a minute and search for rubber duck debugging\cite{Chapter1-rubber-duck-picture}.

\subsection{Setting up environment}
To setup a Q\# development environment, you need to install
\begin{enumerate}
  \item .NET core 2.0 SDK or later
  \item Visual Studio Code (For Windows users, you can use Visual Studio)
  \item Microsoft Quantum Development Kit Extension for Visual Studio Code/Visual Studio
\end{enumerate}
For detailed instructions, please refer to
\href{https://docs.microsoft.com/en-us/quantum/quantum-installconfig?view=qsharp-preview&tabs=tabid-vscode}{Installing and Validating the Q\# Development Environment}\cite{Chapter1-setup-environment}.

\subsection{Creating a Bell state}


\chapter{Before you start writing}

A dozen mistakes and bad choices can be made before even the first word of the actual text is written.
In this chapter we talk about how to prevent this from happening.
Some of the points -- those about code quality and code management -- are not unique to writing {\LaTeX}.

\section{Use version control}

Use some kind of sensible version control\index{version control} for your code.
The author uses Git\index{Git} but has also heard good things about Mercurial\index{Mercurial}.
Sending code to yourself on Facebook\index{Facebook} is not a proper system of version control.

\section{The compilation process}

\subsection{Use \texorpdfstring{\XeLaTeX}{XeLaTeX} or \texorpdfstring{\LuaLaTeX}{LuaLaTeX}}

Use {\XeLaTeX}\index{XeLaTeX@{\XeLaTeX}} or {\LuaLaTeX}\index{LuaLaTeX@{\LuaLaTeX}} for out-of-the-box Unicode\index{Unicode} support.
The author generally recommends {\LuaLaTeX} because the \packname{microtype}\massindex{microtype}[\packname] package his only a limited functionality under {\XeLaTeX}.

In the following we always talk about \enquote{the~{\LaTeX}~compiler}, whether it may \inlinecode{latex}, \inlinecode{lualatex} or \inlinecode{xelatex}.

\subsection{Don’t ignore warnings}

There are two ways in which {\LaTeX} will tell you that something went wrong:
Errors\index{error} and warnings\index{warning}.

The occurrence of an error means that {\LaTeX} was unable the process the source code and gave up at some point in the process.
In the case of a warning {\LaTeX} again wasn’t able to process the source code, but decided to produce some output nevertheless.
Hence the only difference between an error and a warning is how {\LaTeX} decided to proceed with it.
But there is no intrinsic difference between the two of them.

It is typically hard to ignore errors, as no output file will be generated.
But warnings also shouldn’t be ignored:
While the occurrence of an error means that you get no output at all, the occurrence of a warning means that you’re getting a faulty output.

% TODO: Too many warnings make future problems worse.

\section{Code quality}

\subsection{Make use of whitespace to organize the code}

The {\LaTeX} compiler almost never cares about unnecessary whitespace in your code.
Use generous amounts of whitespace to organize your code in a sensible way.
Don’t do the following:
\begin{showcode}{Code is too cramped}
\[\begin{pmatrix*}[r]a^2+b^2&a^2-b^2\\-a^2+b^2&-a^2-b^2\end{pmatrix*}\]
\end{showcode}
Instead do the following:
\begin{showcode}{Code is less cramped}
\[
  \begin{pmatrix*}[r]
     a^2 + b^2 &  a^2 - b^2 \\
    -a^2 + b^2 & -a^2 - b^2
  \end{pmatrix*}
\]
\end{showcode}
You could (and maybe should) even do the following:
\begin{showcode}{Code isn’t cramped}
\[
  \begin{pmatrix*}[r]
    a^2 + b^2
    &
    a^2 - b^2
    \\
    - a^2 + b^2
    &
    - a^2 - b^2
  \end{pmatrix*}
\]
\end{showcode}
This last version is easiest to write and easiest to navigate.

Also put at least one space between any two symbols that do not belong together.
Don’t do the following:
\begin{showcode}{Unrelated symbols need to be separated}
$y=\sin(x)-e^x$
\end{showcode}
Instead do the following:
\begin{showcode}{Unrelated symbols are separated}
$y = \sin(x) - e^x$
\end{showcode}
One could (and probably should) go even further and do the following:
\begin{showcode}{Unrelated symbols are separated even better}
$y = \sin ( x ) - e^x$
\end{showcode}

\subsection{Write one sentence per line}

Related the previous point, write at most one sentence per line.
This has at least three advantages:
\begin{itemize}[wide=0pt, leftmargin=*]
  \item
    When an error\index{error} or warning\index{warning} occurs, {\LaTeX} will (try to) tell you in which line of source code the problem occured.
    Having your source code split up over multiple lines makes it much easier to find the problem.
  \item
    Organizing the source code into more lines will make the tools provided by your version control\index{version control} system more efficient to use.
  \item
   Sentences which are overly long become more easily recognizable.
\end{itemize}

\subsection{Properly indent your source code}

Writing {\LaTeX} means writing source code.
Make sure that your source code is properly indented\index{indentation!in source code}.

\subsection{Use \inlinecodetitle{\%} for problematic line~breaks}

Sometimes a sensible line break in your source code can lead to unwanted effects in the resulting output.
Consider the following example:
\begin{showlatex}*{Wrong spacing before a footnote}
Here is some text.
\footnote{Here is a footnote for this text.}
\end{showlatex}
Note the unwanted space\index{before a footnote} between the period and the superscript belonging to the footnote\index{footnote}.
This unwanted space comes from the line break that occurs between them in the source code.
By ending the first line with \inlinecode{\%}\massindex{\%}[\inlinecode] we can \enquote{comment out} this line break.
We hence do the following:
\begin{showlatex}*{Right spacing before a footnote}
Here is some text.%
\footnote{Here is a footnote for this text.}
\end{showlatex}

\section{Splitting up a project into multiple files}
\index{including files!zzzz@\igobble |see{file inclusion}}

Nearly every project should be split up into multiple files.

\subsection{The commands~\comtitle{usepackage}, \comtitle{include}, \comtitle{input}}

There are (at least) three useful ways to include another file into your project: \comname{usepackage}\massindex[file inclusion]{usepackage}[\comname], \comname{include}\massindex[file inclusion]{include}[\comname] and \comname{input}\massindex[file inclusion]{input}[\comname].
\begin{myitemize}
  \item
    Most of the preamble information -- inclusion packages, configuration of styles, configuration of the look and feels of the document -- should be put into one or multiple \filename{sty}-files.
    These file(s) can then be included into the document via the command~\comname{usepackage}\massindex[file inclusion]{usepackage}[\comname].
  \item
    The commands~\comname{include} and~\comname{input} insert the text of the specified documents at the position where they are used, but have slight differences:
    \begin{myitemize}
      \item
        The command~\comname{include}\massindex[file inclusion]{include}[\comname] ensures that the specified content starts on a new page, and also that the following content begins on a new page.
        The command~\comname{input}\massindex[file inclusion]{input}[\comname] simply inserts the specified content at the given position without any such additional formatting.
      \item
        The command~\comname{include} cannot be nested:
        The specified file is not allowed to include the command~\comname{include} again.
    \end{myitemize}
\end{myitemize}

One should use the command~\comname{include} for chapters and the command~\comname{input} for any smaller level of text organization.
One should in particular break the main text into smaller units until each of them can be put into its own file of sensible length.

\subsection{An Example}

Suppose that your text consists of two chapters, each of which consists of three sections.
Then you should have at least ten files:
\begin{myitemize}
  \item
    A master file \filename{main.tex}.
    This file includes all other files in some way, and this is the file which needs to be compiled.
  \item
    A file \filename{mystyle.sty} in which packages are included and options are set.
  \item
    Two files for the chapters, say \filename{chapter1.tex} and \filename{chapter2.tex}.
  \item
    Six files for the sections, say \filename{section1.tex} up to \filename{section6.tex}.
\end{myitemize}
These files should include each other as shown in \cref{file inclusion structure}.
\begin{figure}[tb]
  \begin{center}
    % the following diagram uses the "trees" library
    \begin{tikzpicture}[
      every node/.style = {shape=rectangle, rounded corners, draw, align=center},
      level 1/.style = {sibling distance = 15em},
      level 2/.style = {sibling distance = 5em}
      ]
      \node {\filename{main}}
        child { node [right=3em] {\filename{mystyle}} }
        child { node {\filename{chapter1}}
          child { node {\filename{section1}} }
          child { node {\filename{section2}} }
          child { node {\filename{section3}} }
        }
        child { node {\filename{chapter2}}
          child { node {\filename{section4}} }
          child { node {\filename{section5}} }
          child { node {\filename{section6}} }
        };
    \end{tikzpicture}
  \end{center}
  \caption{Splitting up a project into multiple files.}
  \label{file inclusion structure}
\end{figure}

Let us suppose for simplicity that all ten files are contained in the same directory.
The master file \filename{main.tex} should then look roughly as follows:
%
\begin{showcode}{Layout of \filename{main.tex}}
\documentclass[a4paper, 10pt]{scrreprt}

\usepackage{mystyle}

\title{A Report}
\author{John Doe}

\begin{document}

\maketitle

\include{chapter1}
\include{chapter2}

\end{document}
\end{showcode}
%
The file \filename{mystyle.sty} may look as follows:
%
\begin{showcode}{Layout of \filename{mystyle.sty}}
%%%%% PACKAGES

% general mathematics
\usepackage{mathtools}
\usepackage{amssymb}

% commutative diagrams
\usepackage{tikz-cd}

%%%%% NEW COMMANDS

% new operators
\DeclareMathOperator{\End}{End}
\DeclareMathOperator{\Hom}{Hom}
\end{showcode}
%
The file \filename{chapter1.tex} should look roughly as follows:
%
\begin{showcode}{Layout of \filename{chapter1.tex}}
\chapter{Name of the first chapter}

Some introduction to this chapter before the first section appears.

\input{section1}
\input{section2}
\end{showcode}
%
The file \filename{section1.tex} should look roughly as follows:
%
\begin{showcode}{Layout of \filename{section1.tex}}
\section{Name of the first section}

Text of the first section.
\end{showcode}

\subsection{Use \comtitle{includeonly}}

As your document grows so does the time needed to compile it.
It is therefore often desirable to compile only certain parts of the document.
One naive solution to this problem is to simply not include the currently unwanted parts, e.g.\ by commenting out the corresponding lines of~\comname{include} and~\comname{input}.
This approach has the problem that references to the now-excluded parts of the document will not compile properly.
This problem can be fixed by using the command~\comname{inludeonly}\massindex[file inclusion]{includeonly}[\comname].

\subsubsection{Usage of the command}

Suppose that your main document, \filename{main.tex}, includes two other files, say \filename{chapter1.tex} and \filename{chapter2.tex}, via the command \comname{include}.
Hence the file~\filename{main.tex} should look roughly as follows:
\begin{showcode}{Basic example of \filename{main.tex}}
\documentclass[a4paper, 10pt]{scrreprt}

\begin{document}

\include{chapter1}
\include{chapter2}

\end{document}
\end{showcode}
By putting~\inlinecode{{\tbs}includeonly\{chapter1\}} in the preamble we tell {\LaTeX} to only compile this specific chapter.
\begin{showcode}{Using the command~\comname{includeonly}}
\documentclass[a4paper, 10pt]{scrreprt}

\includeonly{chapter1}
\begin{document}

\include{chapter1}
\include{chapter2}

\end{document}
\end{showcode}
If in the above situation the file~\filename{chapter1.tex} contains some references to labels contained in the file~\filename{chapter2.tex} then these references will still compile correctly, even though only~\filename{chapter1.tex} is compiled.

\subsubsection{Things to be aware of}

The command~\comname{includeonly} has two quirks, which follow from the way {\LaTeX} handles referencing:

When {\LaTeX} compiles the file~\filename{main.tex} an auxiliary file~\filename{main.aux} is created.
This file contains various information about the compiled document.
It does in particular contain a list of all labels found in \filename{main.tex} during the compilation process.
The next compilation process can then access these information to properly typeset all references that refer to these labels.

A feature of the command~\comname{include} (which the command~\comname{input} does not have) is that such an auxiliary file is also generated for the included file.
So in the above example the files~\filename{chapter1.aux} and \filename{chapter2.aux} will be created whenever corresponding \filename{tex}-files are compiled.
These files will in particular contain lists of all the labels found in~\filename{chapter1.tex} and \filename{chapter2.tex}.

When~\inlinecode{{\tbs}includeonly\{chapter1\}} is used, only \filename{chapter1.tex} is recompiled.
As a consequence, the auxiliary file~\filename{chapter1.aux} may change, but the file~\filename{chapter2.aux} remains unchanged.
This allows {\LaTeX} to access the labels in~\filename{chapter2.tex} (which are now listed in \filename{chapter2.aux}) without going through this file again.
However, that the file~\filename{chapter2.aux} remains unchanged leads to two quirks that one should be aware of:
\begin{myitemize}
  \item
    Before inserting the code \inlinecode{{\tbs}includeonly\{chapter1\}} one needs to compile the whole document, including \filename{chapter2.tex}, a least once.
    This needs to be done so that {\LaTeX} can properly create the auxiliary file~\filename{chapter2.aux}.
  \item
    Changes made to the file~\filename{chapter2.tex} will not be seen by {\LaTeX} while the code~\inlinecode{{\tbs}includeonly\{chapter1\}} is present.
    This means in particular that {\LaTeX} won’t notice any new labels that are added in this file.
    In this case one need to stop excluding \filename{chapter1.tex} for at least one compilation process to ensure that the auxiliary file~\filename{chapter2.aux} is updated.
\end{myitemize}

\subsubsection{Specifying multiple files}

The command~\comname{includeonly} actually accepts as its argument a list of files to be included:
\begin{showcode}{Syntax of \comname{includeonly}}
  \includeonly{file_1, ..., file_n}
\end{showcode}

\section{Choosing the document class}

\subsection{Use the KOMA-Script classes}

Instead of the standard classes\index{standard classes} \optname{article}\massindex[standard classes, document class!classes]{article}[\optname], \optname{report}\massindex[standard classes, document class!classes]{report}[\optname] or \optname{book}\massindex[standard classes, document class!classes]{book}[\optname], the the KOMA-Script classes \optname{scrartcl}\massindex[KOMA-Script classes, document class!classes]{scrartcl}[\optname], \optname{scrreprt}\massindex[KOMA-Script classes, document class!classes]{scrreprt}[\optname] and \optname{scrbook}\massindex[KOMA-Script classes, document class!classes]{scrbook}[\optname] should be used.
They provide more built-in functionalities than the standard classes and a more unified interface.

The KOMA-Script classes make slightly different design choices than the standard classes.
Some of them are the following:
\begin{myitemize}
  \item
    The KOMA-Script classes have a different chapter title layout than the standard classes.
    The standard look can be regained by setting the option~\optname{chapterprefix}\massindex[KOMA-Script classes, document class!options]{chapterprefix}[\optname] to~\optname{true}:
    \begin{showcode}{Using the option~\optname{chapterprefix}}
\documentclass[10pt, a4paper, chapterprefix = true]{scrbook}
    \end{showcode}
  \item
    Headings and description~labels are set in bold and sans-serif.
    This can be changed to a serif font with help of the command~\comname{setkomafont}\massindex[KOMA-Script classes, fonts]{addtokomafont}[\comname].
    \begin{showcode}{Changing KOMA fonts}
\addtokomafont{disposition}{\rmfamily}
\addtokomafont{descriptionlabel}{\rmfamily}
    \end{showcode}
%     One can also make the heading be in small capitals instead of boldface by replacing~\comname{bfseries}\massindex[fonts]{bfseries}[\comname] by~\comname{scshape}\massindex[fonts]{scshape}[\comname].
  One can also use the undocumented option~\optname{egregdoesnotlikesansseriftitles}\massindex[KOMA-Script classes, document class!options]{egreg\-does\-not\-like\-sans\-serif\-titles}[\optname].
  \begin{showcode}{Using the option~\optname{egregdoesnotlikesansseriftitles}}
\documentclass[10pt, a4paper, egregdoesnotlikesansseriftitles]{scrbook}
  \end{showcode}
\end{myitemize}

\subsection{Deciding on a document class}
\index{document class}

The three standard classes to consider for a mathematical project are~\optname{scrartcl}\massindex[KOMA-Script classes, document class!classes]{scrartcl}[\optname],~\optname{scrreprt}\massindex[KOMA-Script classes, document class!classes]{scrreprt}[\optname] and~\optname{scrbook}\optionindex{scrbook}{scrbook}\massindex[KOMA-Script classes, document class!classes]{scrbook}[\optname].
These three classes differ in what functionalities they provide and what their standard settings are.

The class~\optname{scrartcl} is the most basic one.
It provides the standard sectioning commands~\comname{section}\massindex[sectioning]{section}[\comname],~\comname{subsection}\massindex[sectioning]{subsection}[\comname] and~\comname{subsubsection}\massindex[sectioning]{subsubsection}[\comname].
An abstract can be added with the~\envname{abstract}\massindex{abstract}[\envname] environment and by giving~\comname{documentclass} the option~\inlinecode{abstract~=~on}\massindex[document class!options]{abstract}[\envname]:
\begin{showcode}{Using the environment~\envname{abstract}}
\documentclass[10pt, a4paper, abstract = on]{scrartcl}

\begin{document}

\begin{abstract}
  Our results are cool and our proofs have no details.
\end{abstract}

\end{document}
\end{showcode}

The class~\optname{scrreprt} extends the previous class:
It provides the additional sectioning command~\comname{chapter}\massindex[sectioning]{chapter}[\comname], which is higher-level than~\comname{section}.
The title has a complete page for itself, although this behavior can be changed by setting the option~\optname{titlepage}\massindex[KOMA-Script classes, document class!options]{titlepage}[\optname] to~\optname{false}:
\begin{showcode}{Using the option~\optname{titlepage}}
\documentclass[10pt, a4paper, titlepage = false]{scrreprt}
\end{showcode}
This class also provides the sectioning command~\comname{appendix} after which all chapters will be counted towards the appendix.
The~\envname{abstract} environment is still available in the same way as before.
(But the abstract is printed only on the second page, after the title page.)

The class~\optname{scrbook} provides the additional sectioning command~\comname{part}\massindex[sectioning]{part}[\comname] that that is even more higher-level than~\comname{chapter}.
This class also provides the (very useful) additional sectioning commands~\comname{frontmatter}\massindex[sectioning]{frontmatter}[\comname],~\comname{mainmatter}\massindex[sectioning]{mainmatter}[\comname] and~\comname{backmatter}\massindex[sectioning]{backmatter}[\comname].
The~\envname{abstract} environment isn’t available anymore.
This class does by default distinguish between left and right pages, i.e.\ even and odd pages.
This can be disabled by using the option~\optname{oneside}\massindex[KOMA-Script classes, document class!options]{oneside}[\optname]:
\begin{showcode}{Using the option~\optname{oneside}}
\documentclass[10pt, a4paper, oneside]{scrbook}
\end{showcode}
By default chapters will begin on the right page.
This can be disabled with the option~\optname{openany}\massindex[KOMA-Script classes, document class!options]{openany}[\optname]:
\begin{showcode}{Using the option~\optname{openany}}
\documentclass[10pt, a4paper, openany]{scrbook}
\end{showcode}
When the option~\optname{oneside} then chapters are automatically allowed to start on both left pages and right pages.
The option~\optname{openany} is then not needed.

In practice one should use the class~\optname{scrartcl} if only sections and subsections are needed, and otherwise the class~\optname{scrbook}.
Instead of~\optname{scrreprt} one should directly use~\optname{scrbook}:
The additional commands~\comname{frontmatter},~\comname{mainmatter} and~\comname{backmatter} that~\optname{scrbook} provides are extremely useful (see \cref{using frontmatter}), and the visual difference between~\optname{scrreprt} and~\optname{scrbook} (which is their main difference) can easily be adjusted by using the aforementioned option~\optname{openany}.

% TODO: Better explanation of twoside, oneside and semi.

\section{Use \comtitle{frontmatter} and its friends}
\label{using frontmatter}

The class~\optname{scrbook} provides the commands~\comname{frontmatter}\massindex[sectioning]{frontmatter}[\comname],~\comname{mainmatter}\massindex[sectioning]{mainmatter}[\comname] and\comname{backmatter}\massindex[sectioning]{backmatter}[\comname].
Together with the sectioning command~\comname{appendix}\massindex[sectioning]{appendix}[\comname] these can be used to separate the document into four parts:
The front part, the main part, the appendix and the back part.
These parts behave slightly differently:
\begin{myitemize}
  \item
    The front part uses lower case roman numerals\index{roman numerals}\index{numerals!roman} for page numbers.
    In the generated \filename{pdf}-file these pages will again be numbered with roman numerals (this will be important for the main part).
    Chapters in this part of the document will not be numbered, but will appear in the table of contents.

    This part of the document should include the title page\index{title page}, preface\index{preface}, table of content\index{table of contents}, list of figures, list of tables, and the introduction\index{introduction}.
    In other words, everything that occurs before the first chapter.
  \item
    The main part uses Arabic numerals\index{Arabic numerals}\index{numerals!Arabic} for page numbers and the page number is reset at the beginning of the main part.
    The first page of the main part is therefore numbered~\enquote{1}.
    In the generated \filename{pdf}-file this first page will also be numbered as such.
    This means that going to page~15 of the \filename{pdf}-file will indeed give page~15 of the document.
    The chapters in this part of the document are numbered and appear in the table of contents.

    This part of the document does contain the vast amount of the document.
    It contains all the chapters excluding the ones belonging into the appendix.
  \item
    The appendix part continues the numbering of the main part.
    It both resets the chapter number and changes its style to upper case letters.
    The first chapter in this part will hence be numbered~\enquote{A}.
    If the option~\inlinecode{chapterprefix~=~true} is set then the word~\enquote{Chapter} at the beginning of a new chapter will be replaced by~\enquote{Appendix}.

    This part of the document should contain the appendices.
  \item
    The back part continues the numbering of the appendix (and thus the numbering of the main part).
    The chapters appearing in this part of the document are again unnumbered, and no~\enquote{Chapter} is printed at the beginning of a new chapter.

    This part of the document should contain the bibliography, list of symbols, and the index.
    An entry for the bibliography\index{bibliography} can be added to the table of contents by setting the option~\optname{bibliography}\massindex[KOMA-Script classes, document class!options, bibliography]{bibliography}[\optname] to~\optname{totoc}\massindex[KOMA-Script classes]{totoc}[\optname].
\end{myitemize}

The document layout with~\optname{scrbook} should therefore look roughly as follows:

\begin{showcode}[label = {layout for scrbook}]{General document layout with~\optname{scrbook}}
\documentclass[a4paper, 10pt, bibliography = totocnumbered]{scrbook}

% preamble

\begin{document}

\frontmatter
\maketitle
% dedication
% preface
\tableofcontents
% \listoftables
% \listoffigures
% introduction

\mainmatter
% most of the document

\appendix
% the appendices

\backmatter
\printbibliography
% list of symbols
% index
\end{document}
\end{showcode}

\section{Be consistent}

One of the most important aspects of both mathematical writing and the use of mathematical notation is consistency\index{consistency}.
If you’re making crappy choices then at least do them consistently.
Consider the following example:
%
% \begin{tcblisting}{title = {Bad}}
% % in the preamble:
% \newcommand{\glie}{\mathfrak{g}}
% % in the main text:
% The algebra $U(\glie)$ is commutative if and only if the original Lie algebra $\glie$ is abelian.
% But $\operatorname{U}(\glie)$ is infinite dimensional whenever $\glie$ is nonzero, even if $\glie$ itself is finite dimensional as well.
% \end{tcblisting}
% Even if the reader doesn’t care if you use $U(\mathfrak{g})$ or $\operatorname{U}(\mathfrak{g})$ they will notice the inconsistent use of the two notations, and this will distract them from the actual content of the text.
%
% We consider another example:
\begin{showlatex}{Inconsistency looks bad}
If $X$ and $Y$ are two objects in a category $\mathcal{C}$ then it may happen that the set $\operatorname{Hom}_{\mathcal{C}}(X,Y)$ is empty even though the set $Hom_{\mathcal{C}}(Y,X)$ is non-empty.
\end{showlatex}
The inconsistent use of~$Hom$ and~$\operatorname{Hom}$ makes the already bad~$Hom$ even worse.


\documentclass[11pt, oneside]{article}   	% use "amsart" instead of "article" for AMSLaTeX format

% \usepackage{draftwatermark}
% \SetWatermarkText{Draft}
% \SetWatermarkScale{5}
% \SetWatermarkLightness {0.9}
% \SetWatermarkColor[rgb]{0.7,0,0}

\usepackage{geometry}                		% See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                   		% ... or a4paper or a5paper or ...
%\geometry{landscape}                		% Activate for for rotated page geometry
%\usepackage[parfill]{parskip}    		% Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}				% Use pdf, png, jpg, or eps� with pdflatex; use eps in DVI mode
								% TeX will automatically convert eps --> pdf in pdflat
								% TeX will automatically convert eps --> pdf in pdflatex
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{hyperref}
\usepackage{url}
\usepackage{subcaption}
\usepackage{authblk}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{fixltx2e}
\usepackage{hyperref}
\usepackage{alltt}
\usepackage{color}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{float}
\usepackage{bigints}
\usepackage{braket}
\usepackage{siunitx}

%
% so you can do e.g., \begin{bmatrix}[r] (or [c] or [l])
%

\makeatletter
\renewcommand*\env@matrix[1][c]{\hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{*\c@MaxMatrixCols #1}}
\makeatother

\newcommand{\argmax}{\operatornamewithlimits{argmax}}
\newcommand{\argmin}{\operatornamewithlimits{argmin}}

\begin{document}

\section*{What Does The Series $\sum\limits_{n = 1}^\infty (\frac{a}{b})^n $ Converge To?}

\noindent
Well,  $\sum\limits_{n = 1}^\infty (\frac{a}{b})^n  = \frac{a}{b \:-\: a}$ where $a,b \in \mathbb{N}$, $b \neq 0$ and $a < b$ (so $b - a \neq 0$). OK, but why?

\bigskip
\noindent
 Here's one way to think about it:

\begin{equation*}
\begin{array}{lllll}
S
&=& \sum\limits_{n = 1}^\infty (\frac{a}{b})^n = (\frac{a}{b})^1 + (\frac{a}{b})^2 + (\frac{a}{b})^3 + \cdots                                                                                &\qquad  \mathrel{\#} \text{define $S$}                                          \\
\vspace{2.0mm}
&\Rightarrow& (\frac{b}{a}) \cdot S = (\frac{b}{a}) \cdot \Big [(\frac{a}{b})^1 + (\frac{a}{b})^2 + (\frac{a}{b})^3 + \cdots \Big ]   &\qquad  \mathrel{\#} \text{multiply both sides by $\frac{b}{a}$}         \\
\vspace{2.0mm}
&\Rightarrow&  (\frac{b}{a}) \cdot S = 1 + \Big [(\frac{a}{b})^1 + (\frac{a}{b})^2 + (\frac{a}{b})^3 + \cdots \Big ]                        &\qquad  \mathrel{\#} \text{multiply through on right side}                   \\
\vspace{2.0mm}
&\Rightarrow&  (\frac{b}{a}) \cdot S = 1 + S                                                                                &\qquad  \mathrel{\#} \text{definition of $S$}                                         \\
\vspace{2.0mm}
&\Rightarrow&  (\frac{b}{a}) \cdot S - S = 1                                                                                &\qquad  \mathrel{\#} \text{subtract $S$ from both sides}                     \\
\vspace{2.0mm}
&\Rightarrow&  (\frac{b}{a}) \cdot S - (\frac{a}{a}) \cdot S = 1                                                                                &\qquad  \mathrel{\#} \text{multiply $S$ by $1 = \frac{a}{a}$}                \\
\vspace{2.0mm}
&\Rightarrow&  S \cdot \Big [\frac{b}{a}  - \frac{a}{a} \Big ] = 1                                                                                &\qquad  \mathrel{\#} \text{factor out $S$}                                              \\
\vspace{2.0mm}
&\Rightarrow& S \cdot \Big [ \frac{b \:-\: a} {a} \Big ] = 1                                                                                &\qquad  \mathrel{\#} \text{simplify}                                                         \\
\vspace{2.0mm}
&\Rightarrow& S  = \frac{a}{b \:-\: a}                                                                                &\qquad  \mathrel{\#} \text{multiply both sides by $ \frac{a}{b \:-\: a} $}
\end{array}
\end{equation*}

\bigskip
\noindent
So $S = \sum\limits_{n = 1}^\infty (\frac{a}{b})^n  =  \frac{a}{b \:-\: a}$ where $a,b \in \mathbb{N}$, $b \neq 0$ and $a < b$.

\bigskip
\noindent
For example, if we  let $a =1$ and $b =2$ then $\sum\limits_{n = 1}^\infty (\frac{1}{2})^n  =  \frac{1}{2 \:-\: 1} = 1$. Similarly, if $a =1$ and $b = 3$ then
$\sum\limits_{n = 1}^\infty (\frac{1}{3})^n  =  \frac{1}{3 \:-\: 1} = \frac{1}{2}$.

\bigskip
\noindent
\section*{Acknowledgements}

Thanks to Dave Neary for pointing out that this series diverges if $a \geq b$.

\end{document}