\input{PreambleCommon}
\input{../WeekTitles}

\begin{document}
\setfont
\pagestyle{fancy}
\renewcommand{\Week}{1 }
\renewcommand{\WeekTitle}{\WeekTitleOne }

\fancyhead[LE,RO]{Week \Week}  % default, usually only for first page
\fancyfoot{}
\sectionbox{Week \#\Week: \WeekTitle}

\vspace{5mm}
\goals
\begin{itemize}
\item Interpret the derivative, and be able to discuss the difference
  between the secant line and the derivative
\item Compute the derivative of polynomial, exponential, logarithmic,
  powers, trigonometric functions and their combinations, with the
  correct application of the product and quotient rules, and the chain
  rule
\item Report the graphs, domain and range of the inverse trigonometric
  functions arcsin, arccos and arctan.
\item Apply the derivative rules for arcsin, arccos and arctan.
 \end{itemize}

\vspace{5mm}

% topics
% 2.6 - give examples of functions which are and are NOT differentiable.
%  - graphical and formula

\newpage

\topic{Introduction}
\subsection*{Introduction}

The two fundamental ideas in calculus are:
\begin{itemize}
\item The {\bf derivative}, which gives the rate of change of a function, and \\[2ex]
\item The {\bf integral}, which computes the total accumulation based
  on a rate.
\end{itemize}

\newpage

Many fundamental quantities in physics are
related through derivatives and integrals.  For example: \\

\begin{center}
  {\bf Position} \\[10ex]
  {\bf Velocity} \\[10ex]
  {\bf Acceleration}
\end{center}

\newpage

\newpage

We will spend the first half of this course examining differential
calculus and integral calculus.  \\[2ex]

The assumption for the derivative section is that the fundamental
ideas will be review, so the pace will be fairly aggressive.  We will
also start including some calculations and graphical analysis using MATLAB.  \\[2ex]

Take advantage of the practice problems to practice your skills, and
get in touch with the instructor if you need any help.

\newpage
\topic{Differential Calculus - Slopes, Secants and the Derivative}
\subsection*{Slopes, Secants and the Derivative}
A {\bf secant line} is a line connecting any two points on a graph.
\vfill

The {\bf slope of a secant line} gives
\begin{itemize}
\item the {\bf average rate of change} of $f(x)$ over some interval $\Delta x$.
\item the {\bf average velocity} over an interval, if $f(t)$ represents {\bf position}.
\item the {\bf average acceleration} over an interval, if $f(t)$ represents {\bf velocity}.
\end{itemize}
\problem Give the units of the slope of a secant line.

\vspace{1in}

\newpage

The {\bf derivative} gives the {\bf slope of a tangent line} at a {\bf
  single point} on a graph.

\vfill

The derivative gives:
\begin{itemize}
\item the {\bf limit of the average slope} as the interval $\Delta x $ approaches zero.
\item the {\bf instantaneous rate of change} of $f(x)$.
\item the {\bf velocity}, if $f(t)$ represents {\bf position}.
\item the {\bf acceleration}, if $f(t)$ represents {\bf velocity}.
\end{itemize}

\problem Give the units of the derivative.
\vspace{1in}

\newpage

\topic{Differentiability}

\section*{Differentiability}

The definition of the derivative is based on the classic
$\ds \left(\frac{\mbox{rise}}{\mbox{run}}\right)$ formula for slopes.

\begin{align*}
  f'(x) = \frac{d}{dx} f = \dfdx = \lim_{\Delta x \to 0} \frac{\Delta f}{\Delta x} = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}
\end{align*}

\newpage

A function $f$ is {\bf{differentiable}} at a given point $a$ if it has
a derivative at $a$, or the limit above exists.  There is also a
graphical interpretation differentiability: {\bf{if the graph has a
    unique and finite slope at a point}}.  Since the slope in question
is automatically the slope of the tangent line, we could also say that

\begin{quote} {\sc{$f$ is differentiable at $a$ if its graph has a
      (non-vertical) tangent at $(a,f(a))$}}.
\end{quote}

\vfill

For functions of the form $y = f(x)$, we do not consider points with
vertical tangent lines to have a real-valued derivative, because a
vertical line does not have a finite slope.

\vsc
\newpage

Here are the ways in which a function can fail to be differentiable at a point $a$:
\begin{enumerate}
\item The function is not continuous at $a$.
\item The function has a corner (or a cusp) at $a$.
\item The function has a vertical tangent at $(a,f(a))$.
\end{enumerate}

\problem Sketch an example graph of each possible case.

\vfill

\newpage

{\bf Reminder: Differentiability is Common}

You will notice that, despite our concern about some functions {\em
  not} being differentiable, most of our standard functions
(polynomials, rationals, exponentials, logarithms, roots) {\bf are}
differentiable at most points.  Therefore we should investigate what
all these possible derivative/slope values could tell us.

\vspace{0.5in}

\topic{Interpreting the Derivative}

{\bf Interpreting the Derivative}

\begin{boxnote}

\begin{itemize}
\item Where $f'(x) > 0$, or the {\bf derivative is positive}, \\
  $f(x)$ is {\bf increasing}. \\[1ex]
\item Where $f'(x) < 0$, or the {\bf derivative is negative}, \\
  $f(x)$ is {\bf decreasing}. \\[1ex]
\item Where $f'(x) = 0$, or the {\bf tangent line to the graph is
    horizontal}, $f(x)$ has a {\bf critical point}.
\end{itemize}
\end{boxnote}

\newpage

\problem Consider the graph of $f(x)$ shown below.

\begin{tabular}{ll}
\begin{minipage}{5in}
\includegraphics[width=5in]{graphics/notes_01_incr_decr}
\end{minipage} &
\begin{minipage}{4.5in}
On what intervals is $f'(x) > 0$?
\end{minipage}
\end{tabular}

\newpage

\begin{tabular}{ll}
\begin{minipage}{5in}
\includegraphics[width=5in]{graphics/notes_01_incr_decr}
\end{minipage} &
\begin{minipage}{4.5in}
\problem Where does $f'(x)$ takes on its {\bf largest negative value}?
\end{minipage}
\end{tabular}

\newpage

\topic{Graphs of the Derivative}

\section*{Graphs, and Graphs of their Derivatives}

\problem Consider the same graph again, and the graph of its derivative.
Identify important features that associate the two.

\includegraphics[width=2.9in]{graphics/notes_01_incr_decr} \\[.1in]
\includegraphics[width=2.9in]{graphics/notes_01_incr_decr_deriv}

\newpage

\problem  Consider the graph of $f(x)$ shown:

\begin{minipage}[h]{0.3\linewidth}
\begin{center}
  \includegraphics[width=1.0\linewidth]{graphics/notes_01_f_and_deriv_graph_f} \\
  $f(x)$
\end{center}
\end{minipage}
\begin{minipage}[h]{0.65\linewidth}
\begin{center}
\begin{tabular}{cc}
\includegraphics[width=2.5in]{graphics/notes_01_f_and_deriv_graph_c} &
\includegraphics[width=2.5in]{graphics/notes_01_f_and_deriv_graph_b} \\
{\bf A} &  {\bf B} \\ \hline
\includegraphics[width=2.5in]{graphics/notes_01_f_and_deriv_graph_a} &
\includegraphics[width=2.5in]{graphics/notes_01_f_and_deriv_graph_d} \\
{\bf C} &  {\bf D}
\end{tabular}
\end{center}
\end{minipage}

Which of the graphs on the right is the graph of the {\bf derivative} of
$f(x)$?
\newpage

\topic{Computing Derivatives - Basic Formulas}

\section*{Computing Derivatives}
% {\bf Note:} The standard formulas for derivatives are covered in the
% Grade 12 Ontario curriculum. While they will be reviewed here, {\bf
%   students who are not familiar with them should begin both textbook
%   reading and the assignment problems for this unit as soon as
%   possible.}

Beyond the graphical interpretation of derivatives, there are all the
algebraic rules.  {\bf All of these rules} are based on the {\bf definition}
of the derivative, \\[2ex]
\begin{align*}
f'(x) = \frac{d}{dx} f = \dfdx = \lim_{\Delta x \to 0} \frac{\Delta f}{\Delta x} = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}
\end{align*}  \\[2ex]

However, by finding common patterns in the derivatives of certain
families of functions, we can compute derivatives much more quickly
than by using the definition.

\newpage

\begin{boxnote}
{\bf Sums, Powers, and Differences}

\LARGE
\begin{tabular}{lc}
Constant Functions: & $\ds \ddx k = 0 $ \\[7ex]
Power rule: & $\ds \ddx x^p = p x^{p-1}$ \\[7ex]
Sums : & $\ds \ddx f(x) + g(x) = \left(\ddx f(x)\right) + \left(\ddx g(x) \right)$ \\[7ex]
Differences: & $\ds \ddx f(x) - g(x) = \left(\ddx f(x)\right) - \left(\ddx g(x) \right)$ \\[7ex]
Constant Multiplier: & $\ds \ddx \left[k f(x)\right] = k \left(\ddx f(x)\right)$, so long as $k$ is a constant
\end{tabular}
\setfont

\end{boxnote}

\newpage

\problem Evaluate the following derivatives:

$\ds \ddx \left(x^{5} - 2 x\right)$

\vfill

$\ds \ddx \left(4.1 \sqrt{x} + \frac{4}{x}\right)$

\vfill

\newpage
{\bf Question: } The derivative of $\ds -3t^2 - \frac{1}{t^2}$ is

\begin{enumerate}
\item $\ds -6 t^3 + 2 \frac{1}{t^3} $ \\[1ex]
\item $\ds -6 t + 2 \frac{1}{t^3} $ \\[1ex]
\item $\ds -6 t - 2 \frac{1}{t^3} $ \\[1ex]
\item $\ds -t^3 + 2 \frac{1}{t} $
\end{enumerate}

\newpage

\begin{boxnote}
{\bf Exponentials and Logs}
\begin{center}
\begin{tabular}{lp{0.2in}l}
$e$ as a base: && $\ds \ddx e^x = e^x $ \\[7ex]
Other bases: && $\ds \ddx a^x = a^x (\ln(a))$ \\[7ex]
Natural Log: && $\ds \ddx \ln(x) = \frac{1}{x}$ \\[7ex]
Other Logs: &&$\ds \ddx \log_a(x) = \frac{1}{x} \frac{1}{\ln(a)}$ \\[7ex]
\end{tabular}
\end{center}
\end{boxnote}

\newpage

\problem Evaluate the following derivatives:

$\ds \ddx \left( 3 \cdot 10^x + 10 \cdot x^3  \right)$

\vfill

$\ds \ddx \left( e^x + \log_{10}(x) \right)$

\vfill

(Exponential and log derivatives are relatively straightforward, until
we mix in the product, quotient, and chain rules.)

\newpage

\topic{Computing Derivatives - Product and Quotient Rules }

\begin{boxnote}
{\bf Product and Quotient Rules}

\begin{center}
\begin{tabular}{lc}
  Products: & \LARGE $\ds \ddx f(x) \cdot g(x) = f'(x) g(x) + f(x) g'(x)$ \\[1in]
  Quotients: &\LARGE  $\ds \ddx \frac{f(x)}{g(x)} = \frac{f'(x) g(x) - f(x) g'(x)}{\left(g(x) \right)^2}$ \\
\end{tabular}
\end{center}

\end{boxnote}

\problem Evaluate the following derivatives:

$\ds \ddx \left( 2.1 x^4 \ln(x) \right)$

\vfill

\newpage

$\ds \ddx \left( \frac{\sqrt{x}}{e^x} \right)$

\vfill

$\ds \ddt{} \left( 7 t^3 2^t \right)$

\vfill

\newpage
{\bf Question: } The derivative of $\ds \frac{10^x}{x^3}$ is

\begin{enumerate}[(a)]
\item $\ds   \frac{10^x}{\ln(10)} x^{-3} + 10^x (-3 x^{-4})$  \\[3ex]
\item $\ds \frac{10^x \ln(10) x^3  - 10^x (3x^2)} {x^6}$ \\[3ex]
\item $\ds  \frac{10^x \frac{1}{\ln(10)} x^3  - 10^x (3x^2)} {x^6}$ \\[3ex]
\item $\ds  \ln(10) 10^x x^{-3} + 10^x (-3 x^{-4})$  \\[3ex]
\end{enumerate}

\newpage

\topic{Computing Derivatives - Chain Rule}

\begin{boxnote}
{\bf Chain Rule}

\begin{center}
\begin{tabular}{lc}
Nested Functions: & \LARGE $\ds \ddx \left[ f(g(x)) \right] = f'(g(x))\cdot g'(x)$  \\
~\\[1in]

Liebnitz form & \LARGE $\ds \ddx f(g(x)) = \frac{df}{dg} \frac{dg}{dx}$ \\
\end{tabular}
\end{center}
\end{boxnote}

\newpage

\problem Evaluate the following derivatives:

$\ds \ddt{} e^{t^4}$

\vfill

\newpage

$\ds \ddx  \ln( 1+ \sqrt{x}) $

\vfill

\newpage
$\ds \ddx \left( \frac{1}{\ln(x)+x^3} \right)$

\vfill

\newpage

$\ds \ddt{} \left( e^{5t-1} + 10^{3t} \right)$

\vfill

\newpage
{\bf Question: } The derivative of $\ds e^{\sqrt{x}}$ is

\begin{enumerate}[(a)]
\item $\ds  \frac{1}{2} e^{\frac{1}{\sqrt{x}}}$ \\[1ex]
\item $\ds e^{\sqrt{x}} \left(\sqrt{x}\right)$  \\[1ex]
\item $\ds \frac{1}{2} e^{\sqrt{x}} \left(\frac{1}{\sqrt{x}}\right)$ \\[1ex]
\item $\ds \frac{1}{2} e^{\sqrt{x}} \left(\sqrt{x}\right)$
\end{enumerate}

\vfill

\newpage

\topic{Computing Derivatives - Trigonometric Functions}

\subsection*{Derivatives of Trigonometric Functions}
\begin{boxnote}
$$ \ds \diff \sin( x) = \cos (x)$$ \\[-2.0ex]
$$ \ds \diff \cos( x) = - \sin (x)$$ \\[-2.0ex]
$$ \ds \diff \tan(x) = \sec^2 (x)$$ \\[-2.0ex]
$$ \ds \diff \sec(x) = \sec(x)\tan(x)$$ \\[-2.0ex]
$$ \ds \diff \csc(x) = -\csc(x)\cot(x)$$ \\[-2.0ex]
$$ \ds \diff \cot(x) = -\csc^2(x)$$
\end{boxnote}

\newpage
\problem Prove the derivative rule for $\ds \ddx \tan(x)$, using the
definition $\ds \tan(x)= \frac{\sin(x)}{\cos(x)}$ and the other
derivative rules.

\vfill

\newpage

\problem Find the derivative of $4 + 6 \cos(\pi t^2 + 1)$

\begin{enumerate}[(a)]
\item $4 - 6 \sin(\pi t^2 + 1) \cdot (2 \pi t)$ \\[2ex]
\item $- 6 \cos(\pi t^2 + 1) \cdot (2 \pi t)$ \\[2ex]
\item $- 6 \sin(\pi t^2 + 1) \cdot (2 \pi t)$ \\[2ex]
\item $-6 \sin(\pi t^2 + 1) \cdot (\pi t^2 + 1)$ \\[2ex]
\item $6 \sin(2 \pi t)$
\end{enumerate}

%\newpage
%\Example{What is the derivative of $\cos^3(x)$?}

\newpage

 \topic{Inverse Trig Functions}

 \subsection*{Inverse Trig Functions}

 In addition to the 6 trig functions just seen, there are 6 inverse
 functions as well, though the inverses of sine, cosine, and tangent
 are the most commonly used. \\[2ex]

 Notation: $y = \arcsin(x)$ and $y = \sin^{-1}(x)$ are both commonly
 used for the inverse of sine function. \\[1ex]
 \begin{itemize}
 \item We will use the $\arcsin$ notation as much as possible. \\[1ex]
 \item On your calculator, you will typically see the $\sin^{-1}$
   notation.
 \end{itemize}

\newpage

 \problem Sketch the graph of $\sin(x)$ on the axes below.

 \includegraphics[width=0.5\linewidth]{graphics/empty_graph_wide_12}

 On the same axes, sketch the graph of $\arcsin(x)$, or $\sin^{-1}(x)$.

 \newpage
 \includegraphics[width=0.5\linewidth]{graphics/empty_graph_wide_12}

 \problem What is the domain of $\arcsin(x)$?  \vspace{1in}

   What is the range of $\arcsin(x)$?
 \vspace{1in}

\newpage

\problem Sketch the graphs of $\arccos(x)$ and $\arctan(x)$. \\[2ex]

\begin{minipage}[t]{0.45\linewidth}
\begin{center}
Graph of $\arccos(x)$ \\
\includegraphics[width=0.9\linewidth]{graphics/empty_graph_square_8}
\end{center}
\end{minipage}
\hfill
\begin{minipage}[t]{0.45\linewidth}
\begin{center}
Graph of $\arctan(x)$ \\
\includegraphics[width=0.9\linewidth]{graphics/empty_graph_square_8}
\end{center}
\end{minipage}
 \newpage

 \topic{Derivative of Inverse Trig Functions}

 \subsection*{Derivative of Inverse Trig Functions}
 \vsc \problem Simplify the expression $\sin (\arcsin x)$.

 \vspace{4cm} Differentiate both sides of this equation, using the
 chain rule on the left.  You should end up with an equation involving
 $\ds{ \diff \arcsin x}$.

 \vfill

 \newpage

 \problem  Solve for $\ds{\diff \arcsin x}$, and simplify the resulting
 expression by means of the formula
 $$
 \cos \theta = \sqrt{1-\sin^2 \theta},
 $$
 which is valid if $ \ds{\theta \in [-\frac{\pi}{2},\,\frac{\pi}{2}]}$.

 \vfill

\newpage
\begin{minipage}[t]{0.45\linewidth}
  \vspace{0pt} From this, we see that

 \begin{center}
  $\ds \diff \arcsin x =$ \hspace{2in}~
 \end{center}
\end{minipage}
\hfill
\begin{minipage}[t]{0.45\linewidth}
\vspace{0pt}
\begin{center}
Graph of $\arcsin(x)$ \\
\includegraphics[width=0.7\linewidth]{graphics/empty_graph_square_8}

Graph of $\ds \ddx \arcsin(x)$ \\
\includegraphics[width=0.7\linewidth]{graphics/empty_graph_square_8}
\end{center}
\end{minipage}

\newpage

Through a similar process, we can find the derivatives of all the
commonly used inverse trig functions.
\begin{boxnote}
$$ \ds \diff \arcsin( x) = \frac{1}{\sqrt{1-x^2}}$$ \\
$$ \ds \diff \arccos( x) = \frac{-1}{\sqrt{1-x^2}}$$ \\
$$ \ds \diff \arctan(x) = \frac{1}{1+x^2}$$
\end{boxnote}
\problem Note any common themes or differences, related to the earlier
trigonometric derivatives.

\newpage

\problem Evaluate the following derivatives.

$\ds \ddt{} \arcsin\left(\frac{x}{4}\right)$

\vfill

$\ds \ddx{} \arctan\left(e^{3x} \right)$

\vfill

  \end{document}


\documentclass[12pt]{article}
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault}
\usepackage[T1]{fontenc}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{parskip}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{xcolor}

\definecolor{Brown}{cmyk}{0,0.81,1,0.60}
\definecolor{OliveGreen}{cmyk}{0.64,0,0.95,0.40}
\definecolor{CadetBlue}{cmyk}{0.62,0.57,0.23,0}
\definecolor{lightlightgray}{gray}{0.9}

\lstset { %
    language=C++,
    %backgroundcolor=\color{black!5}, % set backgroundcolor
    %basicstyle=\footnotesize,% basic font setting
	basicstyle=\ttfamily,                   % Code font, Examples: \footnotesize, \ttfamily
	keywordstyle=\color{OliveGreen},        % Keywords font ('*' = uppercase)
	commentstyle=\color{gray},              % Comments font
	backgroundcolor=\color{lightlightgray},
	tabsize=4,
	frame=single,
}

\title{\textbf{Practical 5: Mass-Spring Systems, part 2 }}
\author{Babis Koniaris}
\date{}

\begin{document}
\maketitle

\begin{center}
\includegraphics[width=0.7\textwidth,height=\textheight,keepaspectratio]{p5-teaser.png}
\end{center}
\pagebreak

\section*{Introduction}

The goals of this practical are to:

\begin{itemize}
\item Improve your practical understanding of mass-spring systems
\item Implement 1D and 2D mass-spring system simulations
\end{itemize}

You will continue working on and evolving the same project: ``03\_constraints\_framework''.

\section*{Tasks}

\subsection*{Chain of particles connected by springs}

This is identical to task 3 from last week, and is only included here to keep the assessed tasks together.

\subsection*{Chain of particles connected by damped springs}

\textbf{Task 2: Simulate a chain of 10 particles connected to each other by a damped spring}

The system is assumed to be under the influence of gravity. The two extremities of the chain should be fixed at the same height. It should look approximately like mass\_spring\_systems\_1d\_b.exe.

\subsection*{Chain of particles connected by damped springs, plus collision with plane}

\textbf{Task 3: Same as task 2, but particles collide with the ground plane}

It should look approximately like mass\_spring\_systems\_1d\_c.exe.

\subsection*{Cloth simulation 1}

\textbf{Task 4: Simulate a square piece of cloth whose 4 corners are fixed to points located at the same height}

\begin{itemize}
\item Use a 10$\times$10 particle array. You can use:
	\begin{itemize}
	\item C-style arrays, e.g. Particle particles[10][10]
	\item std::array<Particle, 100>
	\item std::vector<Particle>
	\end{itemize}
\item Include collision detection with plane, as per previous task
\item The cloth should be aligned with the XZ axis, like a trampoline.
\item It should look approximately like mass\_spring\_systems\_2d\_a.exe.
\item You should use, at a minimum, structural constraints, but you might find that the simulation is better with shear constraints and bending constraints.
\end{itemize}

\subsection*{Cloth simulation 2}

\textbf{Task 5: Simulate a square piece of cloth where two adjacent corners are attached to fixed points in space located at the same height. Add a variable (horizontal) wind effect or moving (horizonta ) blow-dryer to your scene}

The cloth structure will be identical to the one created in the previous task, but with different fixed particles. The real challenge that you need to address to get full marks for this practical is the implementation of a force field (wind or blow dryer) that applies to the cloth geometry, not to the particles themselves. Without wind, it should look approximately like mass\_spring\_systems\_2d\_b.exe.

\section*{Deliverables}

This week's work (and a bit from last week) is assessed, so you need to submit evidence of completed tasks to gain credits.

\subsection*{Marking scheme}

Here's a summary of what you need to deliver, and the associated marks:

\begin{itemize}
\item \textbf{Chain of particles connected by springs (Task 1): 4 marks}
\item \textbf{Chain of particles connected by damped springs (Task 2): 4 marks}
\item \textbf{Chain of particles connected by springs, plus collision with plane (Task 3): 4 marks}
\item \textbf{Cloth simulation 1 (Task 4): 4 marks}
\item \textbf{Cloth simulation 2 (Task 5): 4 marks}
\end{itemize}

\subsection*{Submission details}

You must submit your work using the relevant Moodle assignment by the deadline specified on Moodle. Please submit, in a zip file:

\begin{itemize}
\item Your source code (/path-to-repository/code/03\_constraints\_framework)
\item A working executable (/path-to-repository/code/build/bin/03\_constraints\_framework)
\item Instructions of how to use the program (key mappings, etc) as a text file
\end{itemize}

Marks will only be granted when a working application is demonstrated in the lab or via screen-sharing video.

\end{document}


\textit{Algorithmic music composition} (AMC) can be literally defined as the use of algorithms to compose music. This broad term includes non computational procedures from music theory developed to guide music composition and computational methods designed to generate music automatically or semi-automatically. This chapter presents a brief history of AMC to contextualize this dissertation, from the first procedures created by medieval music theorists to the modern computational methods designed by scientists and engineers. Most computational methods are briefly discussed with a few examples in this chapter, except neural networks, which are covered in greater detail in the next chapter. Moreover, it is important to highlight that this dissertation focuses on symbolic music composition, and hence audio-based methods are not covered in this chapter.

\section{Procedures in Music Theory}

% Guido of Arezzo
Music composers have been developing procedures for centuries to compose different aspects of music pieces. Guido of Arezzo (around 991-–1031) developed one of the earlier examples of AMC in his work \textit{Micrologus}, where he described a method for mapping Latin lyrics into melodies. The method extracts the vowels from given lyrics and then maps the vowels into pitches. Figure \ref{fig:arezzo} shows how Guido of Arezzo mapped the Latin vowels into the seven different natural pitches of the western music system\footnote{C, D, E, F, G, A, B}.

\begin{figure}[!h]
 \centering
 \includegraphics[width=\columnwidth]{imgs/background/arezzo.pdf}
 \caption{Mapping of vowels on natural pitches by Guido of Arezzo.}
 \label{fig:arezzo}
\end{figure}

Since there are more pitches than vowels, some vowels are mapped to different pitches. When mapping vowels that have more than one associated pitch, the pitch should be selected at random. For example, consider the verse from the \textit{Hymn to St John} in Figure \ref{fig:hymn}, in which the vowels are shown in parenthesis. With the mapping rules defined in Figure \ref{fig:arezzo}, the first line of the verse can be mapped to the melody \textit{DBFCCE}.

\begin{figure}[!h]
\centering
\settowidth{\versewidth}{UT queant laxis,}
\begin{verse}[\versewidth]
    REsonare fibris (eoaeii) \\
    MIra gestorum (iaeou) \\
    FAmuli tuorum (auiuou) \\
    SOLve polluti (oeoui)\\
    LAbii reatum  (aiieau)\\
    Sancte Ioannes (aeioae)
\end{verse}
\caption{A verse from the \textit{Hymn to St John}.}
\label{fig:hymn}
\end{figure}

% Isorhythm
Around 1280, the music theorist Franco de Cologne, in his work \textit{Cantus Mensurabilis}, introduced a music notation system where the note durations are defined by their shapes. This new notation allowed composers to treat rhythm independently from pitch. For example, French composers of the \textit{ars nova}, such as Phillipe de Vitry and Guillaume de Machaut, used a technique called isorhythm to map a rhythmic pattern (named the \textit{talea}) onto a pitch contour (named the \textit{color}). Figure \ref{fig:isorhythm} shows the tenor melody of the piece \textit{De bon espoir-Puisque la douce-Speravi} by Guillaume de Machaut built using the isorhythm technique.

\begin{figure}[!h]
 \centering
 \includegraphics[width=\columnwidth]{imgs/background/isorhythm.pdf}
 \caption{The tenor melody of the piece \textit{De bon espoir-Puisque la douce-Speravi} by Guillaume de Machaut.}
 \label{fig:isorhythm}
\end{figure}

The first staff is the talea and the second one is the color. The third staff is the resulting melody of applying the former onto the latter. In this example, the talea has twelve notes and five rests, whereas the color has eighteen notes. The note durations of the talea are applied in order onto the respective notes of the color. Whenever there is a rest in the talea, that rest is merged into the pitches of the color. If the last note of the talea is mapped and there are still notes left in the color, the mapping process continues from the first note of the talea.

% Counterpoint: Art of Fugue
In the Baroque Period (1600--1750), Johann Sebastian Bach wrote \textit{The Art of Fugue}, a musical work that explores different \textit{fugues} and \textit{canons} from a single musical subject\footnote{A subject is the material, usually a recognizable melody, upon which part or all of a composition is based.}. Fugues and canons are highly procedural contrapuntal compositional techniques. Counterpoint consists of interleaving two or more melodies that are harmonically dependent but independent in rhythm and melodic contour. For example, in a canon, the composer starts with a melody, called the \textit{leader}, which is strictly followed at a delayed time interval by another voice, called the \textit{follower}. The follower may present a variation of the leader through transformation operations such as transposition\footnote{Moving a set of notes up or down in pitch by a constant interval}, augmentation\footnote{Repeating a set of notes with longer durations.}, or inversion\footnote{Playing a given set of notes upside down, reversing the contour of the notes.} \cite{simoni2003algorithmic}. For example, Figure \ref{fig:canon} shows the first 13 measures\footnote{A measure (or bar) refers to a single unit of time featuring a specific number of beats played at a particular tempo. Measures are indicated by vertical bar lines on the staff.} of the \textit{Canon per Augmentationem in Contrario Motu} from \textit{The Art of Fugue}.

\begin{figure}[!h]
 \centering
 \includegraphics[width=\columnwidth]{imgs/background/canon_a.pdf}
 \caption{The first 13 measures of the \textit{Canon per Augmentationem in Contrario Motu} from \textit{The Art of the Fugue} by Johann Sebastian Bach.}
 \label{fig:canon}
\end{figure}

The first 4 measures of the upper voice present the subject (leader) of the canon. In measures 5 to 13, the lower voice (follower) transforms the leader using augmentation and inversion. Note that each ascending interval in the leader becomes a descending interval in the follower. Figure \ref{fig:canon_subject} highlights these transformations by aligning the leader (upper voice) with the follower (lower voice). Due to augmentation, the follower needs 8 measures to answer the first 4 measures of the leader.

\begin{figure}[!h]
 \centering
 \includegraphics[width=\columnwidth]{imgs/background/canon_b.pdf}
 \includegraphics[width=\columnwidth]{imgs/background/canon_c.pdf}
 \caption{The leader (upper voice) aligned with the follower (lower voice) of the \textit{Canon per Augmentationem in Contrario Motu} from \textit{The Art of the Fugue}. }
 \label{fig:canon_subject}
\end{figure}

% Mozart's dice game
In the Classical Period (1750-1827), \textit{Musikalisches W{\"u}rfelspiel} (german for a musical dice game) became a popular method to generate music randomly. It consists of selecting precomposed snippets of music according to the result of dice rolls. One of the most famous applications of this method is attributed to Wolfgang Amadeus Mozart, although this attribution has not been authenticated \cite{cope1989experiments}. Mozart's dice game was designed to generate sixteen-measure-long minuets\footnote{A minuet is a classic form of dance from the classical period.}. The game works by creating an eleven-by-sixteen table, where the rows represent possible results of rolling two six-sided dice and columns are the indices of each measure of the minuet. Each element in the table is a precomposed measure.

\begin{table}[!h]
    \centering
    % \setlength{\tabcolsep}{4pt}
    \begin{tabular}{ccccccccc}
    \toprule
    & \multicolumn{8}{c}{\textbf{Part 1}} \\
    & I & II & III & IV & V & VI & VII & VII \\
    \midrule
    2  & 96  & 22  & 141 & 41  & 105 & 122 & 11  & 30  \\
    3  & 32  & 6   & 128 & 63  & 146 & 46  & 134 & 81  \\
    4  & 69  & 95  & 158 & 13  & 153 & 55  & 110 & 24  \\
    5  & 40  & 17  & 113 & 85  & 161 & 2   & 159 & 100 \\
    6  & 148 & 74  & 163 & 45  & 80  & 97  & 36  & 107 \\
    7  & 104 & 157 & 27  & 167 & 154 & 68  & 118 & 91  \\
    8  & 152 & 60  & 171 & 53  & 99  & 133 & 21  & 127 \\
    9  & 119 & 84  & 114 & 50  & 140 & 86  & 169 & 94  \\
    10 & 98  & 142 & 42  & 156 & 75  & 129 & 62  & 123 \\
    11 & 3   & 87  & 165 & 61  & 135 & 47  & 147 & 33  \\
    12 & 54  & 130 & 10  & 103 & 28  & 37  & 106 & 5   \\
    \bottomrule
    \end{tabular}
    \caption{Example of Mozart's dice game. Each element in the table is an integer
    representing the number of a precomposed measure.}
    \label{tab:mozart_dice}
\end{table}

Table \ref{tab:mozart_dice} shows an example of Mozart's dice game with only the first part of the minuet and hence only eight columns. To generate the first part of the minuet with this implementation, one has to roll two six-sided dice for each column $j$ of Table \ref{tab:mozart_dice}. After each roll, the sum $i$  of the two dice is
used to look up the row number $i$ for column $j$. The element $i,j$ in Table \ref{tab:mozart_dice}
is then used to retrieve a single measure from a collection of musical fragments.
Figure \ref{fig:mozart_dice} shows the first eight measures of a minuet that can
be generated using Table \ref{tab:mozart_dice}.

\begin{figure}[!h]
 \centering
 \includegraphics[width=\columnwidth]{imgs/background/mozart_dice.pdf}
 \caption{Example of minuet generated using Mozart's dice game.}
 \label{fig:mozart_dice}
\end{figure}

% Schoenberg's twelve-tone
In the Romantic Period (1800--1850), composers developed a harmonic vocabulary with extensive use of chromaticism\footnote{Chromaticism is the use of notes outside the scale of which a composition is based.}. In the transition from Romanticism to Modernism, Arnold Schoenberg, with his students, Anton Webern and Alban Berg, established new procedures for music composition called \textit{Twelve-tone serialism}. Serial composition consists of arranging a series of musical elements (e.g., pitches and rhythms) into a pattern that repeats itself throughout a composition. A basic form of serial composition consists of selecting a given number of notes on the chromatic scale\footnote{A musical scale with twelve pitches, each a semitone, above or below its adjacent pitches.} and creating permutations using only that number of notes. The selected notes, called the \textit{row}, must all be played once before repeating, although a note can be repeated immediately after it has been played (for example, A, and then A). The first arrangement of the row is called the \textit{tone row}. Transformations such as transposition, inversion, retrograde\footnote{Playing a sequence of notes backwards.}, or retrograde inversion\footnote{Playing a sequence of notes backwards and upside down.} can be applied to the tone row to introduce variation into a serial composition.

\textit{Twelve-tone serialism} is a serial technique where the tone row is an ordered arrangement of all the twelve notes of the chromatic scale. The goal of this technique was to replace tonal music, which is built based on keys (such as C major or D minor). By focusing on the twelve notes of the chromatic scale, no emphasis is given to any single key. Figure \ref{fig:serial} illustrates the tone row used by Alban Berg in the \textit{Lyric Suite} for string quartet composed in 1926.

\begin{figure}[!h]
 \centering
 \includegraphics[width=\columnwidth]{imgs/background/serial.pdf}
 \caption{Tone row used by Alban Berg in the \textit{Lyric Suite} for string quartet composed in 1926.}
 \label{fig:serial}
\end{figure}

Table \ref{tab:serial} shows different transformations that can be applied to the tone
row showed in Figure \ref{fig:serial}. The first row, when read from left to right, is the tone row.
When read from right to left, the first row is the retrograde form of the tone row.
The inversion of the tone row is the first column when read from top to bottom.
The retrograde inversion is found by reading the first column from bottom to top.
Each row and column is labeled with $T_i$, where $0 \leq i \leq 11$. A label
$T_i$ means that the respective row is the transposition of the tone row
by $i$ half steps. For example, T5 means the tone row has been transposed up five half steps.

\begin{table}[h]
    \centering
    % \setlength{\tabcolsep}{4pt}
    \begin{tabular}{ccccccccccccc}
    & T0 & T11 & T7 & T4 & T2 & T9 & T3 & T8 & T10 & T1 & T5 & T6 \\
    \midrule
    T0  & F  & E & C  & A  & G  & D  & Ab & Db & Eb & Gb & Bb & B \\
    T1  & Gb & F & Db & Bb & Ab & Eb & A  & D  & E  & G  & B  & C \\
    T5  & Bb & A & F  & D  & C  & G  & Db & Gb & Ab & B  & Eb & E \\
    T8  & Db & C & Ab & F  & Eb & Bb & E  & A  & B  & D  & Gb & G \\
    T10 & Eb & D & Bb & G  & F  & C  & Gb & B  & Db & E  & Ab & A \\
    T3  & Ab & G & Eb & C  & Bb & F  & B  & E  & Gb & A  & Db & D \\
    T9  & D  & Db & A  & Gb & E & B  & F  & Bb & C & Eb  & G & Ab \\
    T4  & A  & Ab & E  & Db & B & Gb  & C  & F & G & Bb  & D & Eb \\
    T2  & G  & Gb & D  & B  & A  & E  & Bb & Eb & F  & Ab & C & Db \\
    T11 & E  & Eb & B  & Ab & Gb & Db & G  & C  & D  & F  & A & Bb \\
    T7  & C  & B  & G  & E  & D  & A  & Eb & Ab & Bb & Db & F & Gb \\
    T6  & B  & Bb & Gb & Eb & Db & Ab & D  & G  & A  & C  & R & F\\
    \bottomrule
    \end{tabular}
    \caption{Different transformations that can be applied to the tone row showed in Figure \ref{fig:serial}.}
    \label{tab:serial}
\end{table}

% Xenakis
In the 20th century, Iannis Xenakis deeply explored the use of statistical methods to compose \textit{stochastic music} \cite{xenakis1992formalized} -- music in which some elements of the composition are defined randomly. For example, in \textit{Pithoprakta} (1956), he used Gaussian distributions to define the ``temperatures'' of massed glissandi\footnote{Continuous transition between two notes of different pitches.}. In \textit{Achorripsis} (1957), he used Poisson's distribution of rare events to organize ``clouds'' of sound \cite{ames1987automated}. John Cage is another important composer of the 20th century who worked with stochastic music. Cage's \textit{Music of Changes} is a piece for solo piano which was composed using the \textit{I Ching}, a Chinese classic text that is commonly used as a divination system. The I Ching was applied to randomly generate charts of pitches, durations, dynamics, tempo, and densities.

\section{Computational Methods}

% As showed in this section, procedures and rules have been used for centuries to guide different
% aspects of music composition.
% Although many of the procedures presented in the previous section could be
% implemented in a computer, they were not originally designed as computer algorithms.
% The next section presents a short survey of computational methods in AMC.
% ILLIAC Suite (Hiller and Isaacson)
The \textit{ILLIAC Suite: String Quarter No 4} \cite{hiller1957musical}, a composition for string quartet, is considered to be the first music piece to be entirely generated by a digital computer. This piece was generated in 1956 by an ILLIAC computer programmed by Lejaren Hiller and Leonard Isaacson at the University of Illinois. The \textit{ILLIAC Suite} has four movements with melodies that increase in complexity across the movements. The first movement used counterpoint rules from the Renaissance to generate simple polyphonic melodies. The second movement used a random chromatic method that explored aesthetic differences between seventeenth and twentieth-century musical styles. For the third and fourth movements, Hiller and Isaacson manually designed a Markov chain to generate melodies with the style of Arnold Schoenberg's twelve-tone music.

% Xenakis and John Cage
Xenakis and Cage were also pioneers in the use of computer algorithms to compose music. In 1962, Xenakis wrote the \textit{Stochastic Music Program} in the FORTRAN programming language, which employed probability functions to determine the global structure (e.g., length of sections and density) and the note parameters (e.g., pitch and duration) of his compositions \cite{luque2009stochastic}. \textit{Morsima-Amorsima} is an example of piece composed by Xenakis with the support of this program. From 1967 to 1969, John Cage partnered with Lejaren Hiller to compose a multimedia piece called \textit{HPSCHD}, which used a dice game approach with precomposed snippets from pieces by Mozart, Beethoven, Chopin, and others. There are several other early examples of computational approaches to AMC, such as the \textit{Push Button Bertha} \cite{ames1987automated}, a piece generated in 1956 by a DATATRON computer programmed by Martin Klein and Douglas Bolitho at the company Burroughs, Inc. Another important early example is the PROJECT1 (1964), a computer program written by Gottfried Michael Koenig that used serial composition and Markov chains to compose pieces such as the \textit{Project 1, Version 1} for 14 instruments.

Most of these early computational examples of AMC were developed by artists in an \textit{ad hoc} way. More recently, computer scientists and engineers started to explore AMC more systematically and a wide range of methods have been proposed: expert systems \cite{gill1963technique}, generative grammars \cite{cope1989experiments}, cellular automata \cite{miranda1993cellular}, evolutionary algorithms \cite{horner1991genetic}, Markov chains \cite{hild1992harmonet}, neural networks \cite{todd1989connectionist}, and others. The remainder of this chapter briefly introduces these methods, except neural networks, which are discussed in greater detail in the next chapter.
% Symbolic, Knowledge-Based System
% TODO: rephrase final part

\subsection{Expert Systems}

AMC \textit{expert systems} use rules that manipulate symbolic music to mimic the reasoning of music composers. For example, \citet{gill1963technique} presented the first application of hierarchical search with backtracking to guide a set of compositional rules from Schoenberg's twelve-tone technique. Many different works formulated AMC expert systems as a \textit{constraint satisfaction problem} (CSP) \cite{anders2011constraint}. For example, \citet{ebciouglu1988expert} designed a system called CHORAL for harmonizing four-part chorales in the style of J.S. Bach. The system contains over 270 rules (related to melody, harmony, etc.), expressed in the form of first-order predicate calculus. CHORAL harmonizes the chorales using an informed search method where the heuristics guide the search towards Bachian cadences\footnote{A cadence is a chord progression that occurs at the end of a phrase. A phrase is a series of notes that sound complete even when played apart from the main song.}. AMC expert systems can also be formalized with \textit{case-based reasoning}. For example, \citet{pereira1997composing} proposed a system with a case database from just three Baroque music pieces, which were analyzed into hierarchical structures. The system composes just the soprano melodic line of the piece by searching for similar cases in its case database.

\subsection{Generative Grammars}

\textit{Generative grammars} are a set of expansion rules that give instructions for how to expand symbols from a vocabulary. Starting with an initial sequence of symbols, one can compose music with generative grammars by recursively applying expansion rules until a terminal symbol has been reached or a desired length of music has been generated \cite{holtzman1981using}. The expansion rules can be manually defined or inferred from analyzing a corpus of pre-existing music compositions. Lidov and Gadura \cite{lidov1973melody} presented an early example of a generative grammar manually designed for the generation of melodies with different rhythmic patterns. A more recent example is the work of Keller and Morrison \cite{keller2007grammatical}, who designed a probabilistic generative grammar for the automatic generation of convincing jazz melodies. In this case, the expansion rules have probabilities associated with them.

One of the most famous examples of generative grammars in AMC is Cope's \textit{Experiments in Musical Intelligence} (EMI) \cite{cope1989experiments}, which automatically derives a special type of grammar called an \textit{augmented transition network} from a corpus of compositions in a specific style. EMI extracts this augmented transition network by finding short musical patterns that are characteristic of the style being analyzed. EMI also determines how and when to use these patterns in compositions with that style. The inferred transition network can be used to generate new music pieces with the style of the analyzed corpus.

% Self-similarity and Cellular Automata
\subsection{Cellular Automata}

\textit{Cellular Automata} (CA) is a dynamic system composed of simple units (called \textit{cells}) usually arranged in an n-dimensional grid. A cell can be in one state at a time. At each time step, the CA updates each cell according to \textit{transition rules}, which consider the state of the cell and/or the state of the neighbor cells \cite{wolfram2002new}. In his 1986 work \textit{Horos}, Xenakis designed a CA to produce harmonic progressions and new instrument combinations \cite{solomos2005cellular}. CAMUS \cite{miranda1993cellular} is a system that combined two bi-dimensional CAs to compose polyphonic music: Conway's \textit{Game of Life} \cite{gardner1970} and Griffeath’s \textit{Crystalline Growths} \cite{dewdney1989}. Each activated cell in the Game of Life was mapped to a triad\footnote{A tuple of three notes.}, whose instrument was selected according to the corresponding cell in the Crystalline Growths CA. WolframTones \cite{ball2005making} is a commercial system that composes music with one-dimensional CAs that resemble a selected musical style. The system allows users to select a pre-defined music style (e.g., classical, ambient, and jazz) and set different parameters of the algorithm (e.g., rule number, rule type, and seed). Moreover, users can define how to map the CA patterns to different musical features (e.g., pitch, tempo, and timber).

\subsection{Evolutionary Algorithms}

\textit{Evolutionary Algorithms} (EAs) are optimization algorithms that keep a population of candidate solutions (called \textit{individuals}) to maximize (or minimize) a given objective function (called \textit{fitness function}) with an iterative process: (a) evaluation of the current population with the given fitness function, (b) selection of the best solutions and (c) generation of new solutions from the selected solutions. \citet{horner1991genetic} presented one of the first examples of EA for music composition. Their algorithm was inspired by a composition technique called \textit{thematic bridging}, where the beginning and end of a piece are given, and a fixed number of transformations (e.g., transposition, inversion, and retrograde) are applied to map the beginning into the ending. Each candidate solution was encoded as a fixed set of transformations. The fitness function measured the distance between the ending generated by the candidate and the given ending. New solutions are generated with regular mutation and 1-point crossover. Other examples of EAs include the works of \citet{mcintyre1994bach} for four-part baroque harmonization, \citet{polito1997musica} for counterpoint composition, and \citet{papadopoulos1998genetic} for the generation of melodies for given jazz chord progressions.

Formulating good fitness functions is one of the major challenges of applying evolutionary algorithms for AMC. To deal with this problem, a wide range of works use human evaluators to listen and judge the fitness of the candidate solutions. These approaches are called \textit{interactive genetic algorithms} (IGAs). For example, GenJam \cite{biles1994genjam} is a IGA for generating jazz solos with two hierarchically structured populations: one for bar units and the other for jazz phrases (constructed as sequences of measures). A human evaluator defines the fitness of the candidate solutions with a binary score (good or bad). GenJam accumulates these scores to select phrases during the evolutionary process and generate the solos for a given chord progression. Other examples of IGAs are presented in the works of \citet{jacob1995composing}, \citet{schmidl2008pseudo}, and \citet{tokui2000music}.

\subsection{Markov Chains}

\textit{Markov chains} were a very popular method in the early days of AMC \cite{ames1989markov}.
A Markov chain is a system with a sequence of states, using conditional probabilities to model the transitions between successive states \cite{gillick2010machine}. In a first-order Markov chain, the probability of the next state depends only on the current state, but in an nth-order Markov chain, the probability is conditioned on the previous n-1 states \cite{gillick2010machine}. Markov Chains can be represented as a directed graph where nodes represent states, edges represent transitions between states, and edge weights represent the probability transition between states. This graph can be mapped to a probability table $T$ where rows $i$ and columns $j$ represent nodes, and elements $T_{i,j}$ represent the probability of transitioning between nodes $i$ and $j$. Figure \ref{fig:markov_chain} shows an example of a simple abstract Markov Chain.

\begin{figure}[!h]
 \centering
 \begin{minipage}{0.5\columnwidth}
  \centering
 \begin{tikzpicture}[->,shorten >=1pt,auto,node distance=3cm,
         thick,main node/.style={circle,draw,minimum size=1cm,inner sep=0pt]}]

     \node[main node] (A) {A};
     \node[main node] (B) [below left of=A]  {B};
     \node[main node] (C) [below right of=A] {C};

     \draw[->] (A) -- (B);
     \draw[->] (A) -- (C);
     \draw[->] (C) -- (B);
 \end{tikzpicture}
 \end{minipage}
 \begin{minipage}{0.4\columnwidth}
 \centering
 \begin{tabular}{cccc}
   & A   &  B  & C   \\
 \toprule
 A & 0.0 & 0.1 & 0.9 \\
 B & 0.1 & 0.0 & 0.9 \\
 C & 0.5 & 0.5 & 0.0 \\
 \bottomrule
 \end{tabular}

 \end{minipage}

 \caption{Example of Markov Chain represented as a directed graph with its respective probability table.}
 \label{fig:markov_chain}
\end{figure}

Markov chains can be derived manually with the support of music theory  or learned from a corpus of music pieces. In both cases, one has to define how to encode music symbols into a sequence of states \cite{ames1989markov}. To learn a Markov chain from a corpus, one can count, for each state $s_1$ in the corpus, the number of times $s_1$ appears after each other state $s_2$. The transition probability table can then be constructed by normalizing these counts with the total number of transitions in the corpus.
The third and fourth movements of the \textit{ILLIAC Suite} are the earliest examples of
manually-designed Markov chains, while \citet{brooks1957} presented one of the first examples inferred from a corpus of music. \citet{brooks1957} experimented with different orders of Markov chains where each state represents a pitch class. The probability tables of these chains were learned from 37 common meter ($\frac{4}{4}$) hymn tunes (monophonic). While Markov chains designed manually by composers
worked well for specific compositional tasks \cite{tipei1975mp1, jones1981compositional, langston1989six},
those learned from a corpus, in practice, can capture only short-term dependencies in music
\cite{moorer1972music}. Moreover, low order chains typically generate unmusical compositions that
wander aimlessly, while high order ones tend to repeat segments from the corpus and are
very expensive to train \cite{moorer1972music}.

Markov chains can also be used to evaluate music generated by other methods. Given a sequence of states representing a piece of music, one can evaluate this piece with the joint probability of the sequence as given by the Markov chain. Thus, the higher the probability, the better the music. This approach was used by \citet{lo2006evolving}. They trained a Markov chain with classical music pieces and used it to calculate the fitness of candidate solutions of an EA. Each solution in the EA represents a melody encoded as a sequence of pitch numbers as defined by the MIDI format.

Most methods presented in this section require manually designed musical models (or rules) to manipulate or evaluate music. Although music theory formalizes several aspects of music analysis and composition, designing computational music models for AMC is still very challenging, given that music composition is a task that involves human creativity. Some of the presented methods, such as generative grammars and Markov models, can infer composition rules from a music corpus. However, in practice, they have limited performance in terms of music quality. Deep learning is a modern approach to AI, where neural networks are trained to perform various tasks. Recently, the AI research community has drawn substantial attention to this approach due to the impressive results that it has been achieving in different problems (e.g., image classification, speech recognition, and machine translation) \cite{lecun2015deep}. These results also motivated AMC researchers to explore deep learning algorithms for music composition \cite{briot2017deep}. The next chapter presents a detailed discussion on how (deep) neural networks can learn music models from a symbolic music corpus.