\documentclass{article}
\usepackage[a4paper, margin=1in]{geometry}

\usepackage[dvipsnames]{xcolor}

%%% standard math packages for equations:
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}

\usepackage{hyperref}
\usepackage{cleveref}

\usepackage{annotate-equations}

%\usepackage{showexpl} % LTXexample
\usepackage[skins,listings]{tcolorbox}
\newtcblisting{LTXexample}[1][]{%
  colframe=black!20,
  colback=black!10,
  coltitle=red!50!yellow!3!white,
  bicolor,colbacklower=white,
  fonttitle=\sffamily\bfseries,
%  listing options={escapeinside=\`\`},
  %sidebyside,
  text above listing,
  #1}

\title{\texttt{annotate-equations.sty}}
\author{ST John}
\date{\url{https://github.com/st--/annotate-equations}}

\begin{document}

\maketitle

\section{Introduction}

This package is there to make it easier to make annotated equations in \LaTeX, such as in this example:
\begin{LTXexample}[]
\vspace{4em}
\renewcommand{\eqnhighlightheight}{\vphantom{\hat{H}}\mathstrut}
\begin{equation*}
    i \tikzmarknode{hbar}{\mathstrut\hbar} \frac{\partial}{\partial t} \eqnmarkbox[blue]{Psi1}{\Psi(x, t)} = \eqnmark[red]{Hhat}{\hat{H}} \eqnmarkbox[blue]{Psi2}{\Psi(x, t)}
\end{equation*}
\annotate[yshift=3em]{above}{hbar}{$\hbar = \frac{h}{2\pi}$, reduced Planck constant}
\annotate[yshift=1em]{above}{Hhat}{Hamilton operator}
\annotatetwo[yshift=-1em]{below}{Psi1}{Psi2}{Wave function}
\vspace{1em}
\end{LTXexample}
There is still a bit of manual tweaking required (such as adding vertical space before/after the equation), but hopefully this package will already make it a bit more inviting to annotate your equations!

\section{Marking annotation targets within your equation}

\newcommand{\cmdoption}[1]{$\langle$\textit{#1}$\rangle$}

Use
\verb|\eqnmarkbox[|\cmdoption{color}\verb|]{|\cmdoption{node name}\verb|}{|\cmdoption{equation term(s)}\verb|}|
or
\verb|\eqnmark[|\cmdoption{color}\verb|]{|\cmdoption{node name}\verb|}{| \cmdoption{equation term(s)}\verb|}|
to define the target of an annotation within your equation. \verb|\eqnmarkbox| adds background shading, whereas \verb|\eqnmark| changes the text color.
(You can also use
\verb|\tikzmarknode{|\cmdoption{node name}\verb|}{|\cmdoption{equation term(s)}\verb|}|,
but this is likely to end up with the arrow tip too close to the target.)
%
\begin{LTXexample}[text outside listing,lefthand width=1in]
\begin{equation*}
    \eqnmarkbox[blue]{node1}{e_q^n}
    \eqnmark[red]{node2}{f(x)}
    \tikzmarknode{node3}{kT}
\end{equation*}
\end{LTXexample}
\noindent

\section{Simple annotations}
\label{sec:annotate}

Once you have defined nodes within your equations, you can annotate them using
\verb|\annotate[|\cmdoption{tikz options}\verb|]{|\cmdoption{annotate keys}\verb|}{|\cmdoption{node name[,\dots]}\verb|}{|\cmdoption{annotation text}\verb|}|.
%
\cmdoption{tikz options} is passed through to the options for the TikZ node defining the annotation; its most important use is to set the \texttt{yshift}.
For \cmdoption{annotate keys}, see \cref{sec:annotate-keys}.
\cmdoption{node name} is the same name you used to mark the node within the equation, e.g.\ using \verb|\eqnmarkbox|.
\cmdoption{annotation text} is the text of the annotation itself.
%
\begin{LTXexample}[text outside listing,lefthand width=1in]
\begin{equation*}
    \eqnmarkbox[blue]{node1}{e_q^n}
    \eqnmark[red]{node2}{f(x)}
    \tikzmarknode{node3}{kT}
\end{equation*}
\annotate[yshift=1em]{}{node1,node2}{my annotation text}
\end{LTXexample}
\noindent
%
\label{sec:tikz-options}
You generally need to manually adjust the \texttt{yshift} to move the annotations to an appropriate distance above (or negative values for below) the equation.
(You can also adjust \texttt{xshift} if needed, also positive or negative.)

The annotation picks the same text color as given to \verb|\eqnmarkbox| or \verb|\eqnmark|, but you can also override it using \texttt{color} option.

One annotation can point to multiple targets, and multiple annotations can point to the same target.

\subsection{Annotation options}
\label{sec:annotate-keys}

\cmdoption{annotate keys} can be empty, or contain one or more of:
\begin{itemize}
    \item \texttt{above} (default) or \texttt{below},
    \item \texttt{right} (default) or \texttt{left},
    \item \texttt{label above} (default) or \texttt{label below}.

        Note: currently only works for \verb|\annotatetwo| (\cref{sec:annotatetwo}).
\end{itemize}
%
\begin{LTXexample}[text outside listing,lefthand width=1in]
\begin{equation*}
    \eqnmarkbox[blue]{node1}{e_q^n}
    \eqnmark[red]{node2}{f(x)}
    \tikzmarknode{node3}{kT}
\end{equation*}
\annotate[yshift=1em]{left}{node1}{my}
\annotate[yshift=-0.5em]{below,left}{node2}{annotation}
\annotate[yshift=-1em]{below}{node3}{text}
\end{LTXexample}
\noindent
%

\section{Double annotations}
\label{sec:annotatetwo}

\verb|\annotatetwo[|\cmdoption{tikz options}\verb|]{|\cmdoption{annotate keys}\verb|}{|\cmdoption{first node name}\verb|}{|\cmdoption{second node name}\verb|}{|\cmdoption{annotation text}\verb|}|.
\cmdoption{tikz options} and \cmdoption{annotate keys} are as described above in \cref{sec:tikz-options,sec:annotate-keys}. Note that \cmdoption{annotate keys} \texttt{left}/\texttt{right} have no effect in \verb|\annotatetwo|.

\begin{LTXexample}[text outside listing,lefthand width=1in]
\begin{equation*}
    \eqnmarkbox[red]{a1}{a} \eqnmarkbox[blue]{b1}{b} = \eqnmarkbox[green]{b2}{b} \eqnmarkbox{a2}{a}
\end{equation*}
\annotatetwo[yshift=1.5em]{above, label below}{a1}{a2}{var 1}
\annotatetwo[yshift=0.5em]{above}{b1}{b2}{var 2}
\annotatetwo[yshift=-0.5em]{below}{b2}{b1}{var 2}
\end{LTXexample}
\noindent
%
Color is picked from the first of the two nodes.

\section{Package options}

\subsection{Size of highlight: shrink to content or always full height}

\verb|\eqnhighlightheight| is inserted into every \verb|\eqnhighlight|, \verb|\eqncolor|, \verb|\eqnmark|, and \verb|\eqnmarkbox| and by redefining it you can specify the minimum height for the corresponding box:
%
\begin{LTXexample}[text outside listing,lefthand width=0.5in]
\renewcommand{\eqnhighlightheight}{}  % package default
\begin{equation*}
    \eqnmarkbox[red]{hbar}{\hbar} \eqnmarkbox[blue]{q}{q}
\end{equation*}
\end{LTXexample}
\noindent
%
\begin{LTXexample}[text outside listing,lefthand width=0.5in]
\renewcommand{\eqnhighlightheight}{\mathstrut}  % 0-width "constant" height
\begin{equation*}
    \eqnmarkbox[red]{hbar}{\hbar} \eqnmarkbox[blue]{q}{q}
\end{equation*}
\end{LTXexample}
\noindent
%
\verb|\eqnhighlightheight| is used in math mode.

Note that in some cases \verb|\mathstrut| might not be enough, as in the introductory example:
%
\begin{LTXexample}[text outside listing,lefthand width=0.5in]
\renewcommand{\eqnhighlightheight}{\mathstrut}  % 0-width "constant" height
\begin{equation*}
    \eqnmarkbox[red]{Hhat}{\hat{H}} \eqnmarkbox[blue]{Psi}{\Psi}
\end{equation*}
\end{LTXexample}
\noindent
%
You can create custom 0-width characters using \verb|\vphantom|:
%
\begin{LTXexample}[text outside listing,lefthand width=0.5in]
\renewcommand{\eqnhighlightheight}{\vphantom{\hat{H}}\mathstrut}  % custom 0-width height
\begin{equation*}
    \eqnmarkbox[red]{Hhat}{\hat{H}} \eqnmarkbox[blue]{Psi}{\Psi}
\end{equation*}
\end{LTXexample}
\noindent
%
(It looks more balanced if you still include the \verb|\mathstrut|.)

\subsection{Amount of shading of mark highlight}

\verb|\eqnhighlightshade| defines the percentage of the specified color to take:
%
\begin{LTXexample}[text outside listing,lefthand width=0.5in]
\renewcommand{\eqnhighlightshade}{17}  % package default
\begin{equation*}
    \eqnmarkbox[red]{hbar}{\hbar} \eqnmarkbox[blue]{q}{q}
\end{equation*}
\end{LTXexample}
\noindent
%
By redefining this command, you can change the ``alpha'' value of the highlight:
%
\begin{LTXexample}[text outside listing,lefthand width=0.5in]
\renewcommand{\eqnhighlightshade}{47}  % 0 is white, 100 is solid color
\begin{equation*}
    \eqnmarkbox[red]{hbar}{\hbar} \eqnmarkbox[blue]{q}{q}
\end{equation*}
\end{LTXexample}
\noindent

\subsection{Default formatting of annotation labels}

\verb|\eqnannotationtext| is a one-argument command that gets the annotation text as an argument and can be used to have consistent formatting:
\begin{LTXexample}[text outside listing,lefthand width=0.5in]
% package default:
\renewcommand{\eqnannotationtext}[1]{\sffamily\footnotesize#1\strut}

\begin{equation*}
    \eqnmarkbox[blue]{v}{v}
\end{equation*}
\annotate[yshift=-0.5em]{below}{v}{velocity}
\vspace{1em}
\end{LTXexample}
\noindent
%
(The \verb|\strut| has a similar effect to \verb|\mathstrut| in \verb|\eqnhighlightheight|.)
%
\begin{LTXexample}[text outside listing,lefthand width=0.5in]
\renewcommand{\eqnannotationtext}[1]{\bfseries\small#1}

\begin{equation*}
    \eqnmarkbox[blue]{v}{v}
\end{equation*}
\annotate[yshift=-0.5em]{below}{v}{velocity}
\vspace{1em}
\end{LTXexample}
\noindent
%

\section{Recommendations, tips \& tricks}

\subsection{Use \texttt{\textbackslash{}colorlet} for consistent, easily changeable colors}

\subsection{Line breaks within annotations}
\label{sec:multiline}

Possible, but a bit annoying. By default, the formatting only covers the first line:
%
\begin{LTXexample}[text outside listing,lefthand width=0.5in]
\begin{equation*}
    \eqnmarkbox[blue]{h}{h}
\end{equation*}
\annotate[yshift=-0.5em]{below}{h}{Planck\\constant}
\vspace{1em}
\end{LTXexample}
\noindent
%
Here is a manual work-around:
%
\begin{LTXexample}[text outside listing,lefthand width=0.5in]
\begin{equation*}
    \eqnmarkbox[blue]{h}{h}
\end{equation*}
\annotate[yshift=-0.5em]{below}{h}{Planck\\\sffamily\footnotesize constant}
\vspace{1em}
\end{LTXexample}
\noindent

\section{Known issues}

\begin{itemize}
    \item \texttt{label above}/\texttt{label below} not implemented for \verb|\annotate|.

    \item Formatting only covers first line in multi-line annotation texts (see \cref{sec:multiline}).
\end{itemize}

\end{document}


\section{{\feff}}

\subsection{Scattering Amplitude and Phase}
\begin{frame} \frametitle{Scattering Amplitude and Phase-Shift:
    ${f(k)}$ and ${\delta(k)}$ }

  The scattering amplitude ${\Red{f(k)}}$ and phase-shift
  ${{\Red{\delta(k)}}}$ depend on Z:

    \vmm

    \begin{tabular}{ll}
      \begin{minipage}{55mm}
        \rgraph{55mm}{scatt_amp}
        \end{minipage} &
        \begin{minipage}{55mm}
          \rgraph{55mm}{scatt_pha}
      \end{minipage}\\

      \begin{minipage}{55mm}
      $\Red{f(k)}$ peaks at higher  $k$ as Z increases.  Heavy
        elements, have a characteristic dip in $\Red{f(k)}$, and
        scatter to high $k$.

        {\bf{Note: O is done at $k>15\rm\AA^{-1}$}}

      \end{minipage}
      &
      \begin{minipage}{55mm}

        The phase shift $\Red{\delta(k)}$ also shows strong Z
        dependence, and has sharp jumps for heavy elements where $f(k)$ dips.

        {\bf{Note:  $\delta(k) \approx -k$! }}
      \end{minipage} \\
    \end{tabular}

\begin{postitbox}{50mm}
  Z can usually be determined to $\pm 5$.

\vmm
  Fe and O can be distinguished.

\vmm
  N  and O cannot be distinguished.
\end{postitbox}
\vfill
\end{frame}

\begin{frame} \frametitle{ $\lambda(k)$: The Photo-Electron Mean-Free Path }

 \begin{cenpage}{102mm}
  The $ e^{-2R/\lambda(k)} $ term in the XAFS Equation accounts for how far the
   photo-electron can travel and still return (in phase) to the excited atom.
 \begin{columns}
   \begin{column}{55mm}
     \rgraph{57mm}{lambda}
   \end{column}
   \begin{column}{60mm}

     This includes both:

     \begin{itemize}
     \item  inelastic scattering of photo-electron.
     \item  finite lifetime of the core-hole (fs).
     \end{itemize}
     \vmm

   \end{column}
 \end{columns}

 \vmm\hrule\vmm

Basically, the photo-electron can only go out 20 \AA or so over most of the
EXAFS region.

 \begin{postitbox}{80mm}
     The $\lambda$ and $1/R^{2}$ terms make EXAFS a  {\RedEmph{local probe}}.
   \end{postitbox}

  \end{cenpage}
\end{frame}

\subsection{{\feff}}
\begin{frame}
  \frametitle{{\feff} Calculation Overview}

  \begin{cenpage}{112mm}
  {\feff} calculates the EXAFS {$\chi(k)$}  by simulating the scattering of a
  photo-electron along all scattering paths from a selected absorbing atom within
  a  cluster of atoms.
  \end{cenpage}

  \vmm

  \begin{enumerate}
    \onslide+<2->\item   build atomic potentials.   To  simplify calculations,

      \begin{center}
        \begin{tabular}{ll}
          \begin{minipage}{80mm}
            Use the {\BlueEmph{Cup-Cake Tin Approximation}}:
            atomic potentials up to a uniform Fermi level -no chemical bonding.

            \hspace{4mm}(Sometimes called ``Muffin-Tin'' Approximation)
          \end{minipage}
          &
          \begin{minipage}{25mm}
            \vspace{1mm} \includegraphics[width=20mm]{figs/theory/muffintin2}
          \end{minipage}
        \\
      \end{tabular}
    \end{center}

  \onslide+<3->\item determine important scattering paths.

    \begin{itemize}
    \item Build paths from a selected {\BlueEmph{central atom}} in a cluster of atoms
    \item decide which ones are ``degenerate'' .
    \item decide which ones are unimportant for XAFS
    \end{itemize}

  \onslide+<4->\item move photo-electron along path to determine
    $\Red{f}$ and $\Red{\delta}$ as a function of $k$:

    \begin{center}
      propagate $\Rightarrow$ scatter $\Rightarrow$ propagate $\Rightarrow$ \ldots.
    \end{center}

  \end{enumerate}

\end{frame}

\subsection{{\feff}   complications}
\begin{frame} \frametitle{{\feff}: what's so hard about that??}

  \begin{cenpage}{105mm}
    {\feff} includes sophisticated techniques to calculate of \feffc{f(k)},
    \feffc{\delta(k)}, and \feffc{\lambda(k)}.

    \begin{description}
    \item[\RedEmph{Curved Wave Effects}] the photo-electron goes out as
      spherical wave and scatters from atoms with finite size.

    \item[\RedEmph{Muffin-Tin Approximation:}] Makes the calculations
      tractable, but is an approximation.

    \item[\RedEmph{Multiple Scattering}]  the photo-electron can scatter
      multiple times. Most important at low $k$ and for \BlueEmph{linear paths}.

    \item[\RedEmph{Extrinsic Losses}] {\feffc{\lambda(k)}}: self-energy and
      core-hole lifetime.

    \item[\RedEmph{Intrinsic Losses}] {\feffc{S_0^2}}: the absorbing atom
      relaxes to the presence of the hole left in the core electron level.

    \item[\RedEmph{Polarization Effects}] synchrotron beams are highly
      polarized, which needs to be taken into account.  This is simple for
      $K$ edges ($s\rightarrow p$ is dipole), but slightly more complicated for
      $L$ and $M$ edges.

    \end{description}

    \end{cenpage}
\vmm
\begin{center} Usually, you don't have to worry about these things!\end{center}

\end{frame}

\section{{\feff} complications}

\subsection{{\feff} complication \#1: Multiple Scattering}
\begin{frame} \frametitle{{\feff} complication \#1: Multiple Scattering}

  \vmm
\begin{columns}
  \begin{column}{50mm}
  The photo-electron can scatter multiple times before getting back to the
  absorbing atom:

  \begin{center}
    \rgraph{50mm}{mspaths}
  \end{center}

  \end{column}
  \begin{column}{60mm}

  A {\Blue{Path Formalism}} is used in the  calculation:

  \begin{center}
    propagate $\Rightarrow$ scatter $\Rightarrow$ propagate $\Rightarrow$ \ldots.
  \end{center}

  \vmm  \pause
  \vmm {\Red{Single Scattering}}  usually important.

  \vmm {\Red{Triangle Paths}} with angles $ 45 < \theta <
  135^{\circ}$ scatter weakly, but there are lots of them.

  \vmm {\Red{Linear paths}} with angles $\theta \approx 180^{\circ}$
   are very strong: the photo-electron is {\Red{focused}} through an atom.
   Can be used to measure bond angles\ldots

  \end{column}
  \end{columns}

   \begin{postitbox}{92mm}
     \Red{ A {\feff} Path looks the same for Single and Multiple
       Scattering}
   \end{postitbox}
\end{frame}

\subsection{{\feff} Complication \#2: S02}
\begin{frame} \frametitle{{\feff} complication \#2: $S_0^2$, the  Amplitude Reduction Term}

  \vmm
    \begin{cenpage}{110mm}

  The {\RedEmph{other}} electrons in the absorbing atom can relax due to
  the core-hole, giving an {\Red{Amplitude Reduction Term}}:

   \vmm
   \[
   S_0^2 =  {  |{\langle \Phi^{N-1}_f |\Phi^{N-1}_0 \rangle}|^2}
   \]

    \vspace{1mm}

    ${| \Phi^{N-1}_0 \rangle }$ = $(N-1)$ electrons in unexcited atom.

    ${\langle \Phi^{N-1}_f|}$   = $(N-1)$ electrons, relaxed by core-hole.

    \vmm

    \onslide+<2->
    ${S_0^2}$ is taken as a constant: \hspace{3mm}  $ 0.7 < S_0^2 < 1.0 $.

    and may be used as a Fitting Parameter that multiplies {$\chi$}:

    \vmm \vmm
    \onslide+<3->
    \begin{center}
      {\Red{ ${S_0^2}$ is Completely Correlated with $N$      (!!!)}}
    \end{center}

    \onslide+<4->

    \begin{postitbox}{68mm}
      $S_0^2$ is usually constant for  data measured on
      the same edge {\bf{and}} beamline (energy resolution).
    \end{postitbox}

    Most Common Approach: Determine $S_0^2$ from experimental data on a
    system with known $N$, and then use that for unknown data.

    \vmm

    \end{cenpage}

\end{frame}


\section{Ogre}

Ogres are unintelligent, large, brutish creatures.\\
\\
Strength: 15\\
Vitality: 10\\
Dexterity: 4\\
Agility: 5\\
Intellect: 2\\
Perception: 6\\
Empathy: 4\\
\\
Combat: 3\\
Adventuring: 2\\
Social: 2\\
\\
HP: 4 x 2d6 + 40 = 68\\
Stamina: 4 x 1d6 + 45 = 59\\
Mana: 1 x 1d6 + 2 = 6\\
\\
Actions:\\
Pound (4 AP, 2ps): +18 + 1d4, 3d4 + 7 blunt\\
Ogre Rage (1 Stamina per AP): When seeing enemies, the ogre flies into a dangerous rage, which increases his pound's damage to 3d4 + 10. The rage ends when the Ogre becomes incapacitated. If the Ogre's stamina falls to 0 during this rage, he instantly dies.\\
\\
RV: 16\\
Dodge: 8\\
Armor\\
Blunt: 3\\
Cutting: 3\\
Piercing: 3\\
\\
Heat: 2\\
Cold: 2\\
Electrical: 2\\
Psychic: 5\\


\documentclass{apa7}

\usepackage{graphicx}
\graphicspath{ {./figures} }

\begin{document}

\section*{Explanation of flowchart}
\includegraphics[scale=0.7]{figures/flowchart.png}

\begin{enumerate}
    \item We start with an input.
    \item If the year is less than 1582, an error is thrown.
    \item If the year is divisible by 400, it is a leap year. Return true.
    \item If the year is divisible by 100, it is not a leap year, since it was not divisible by 400. Return false.
    \item If the year is divisible by 4, it is a leap year since it wasn't divisible by 100. Return true.
    \item Otherwise, the year is not a leap year since it is not divisible by 4. Return false.
\end{enumerate}

\end{document}


% BASIC SETTINGS
\documentclass[a4paper,12pt]{article} % Set paper size and document type
\usepackage{lmodern} % Use a slightly nicer looking font

% Change margins - default margins are too broad
\usepackage[margin=20mm]{geometry}

% SOURCE CODE LISTING SETTINGS
% https://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings
\usepackage{listings}
\usepackage{color}

\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}

\lstset{ %
  backgroundcolor=\color{white},   % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
  basicstyle=\footnotesize,        % the size of the fonts that are used for the code
  breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace
  breaklines=true,                 % sets automatic line breaking
  captionpos=b,                    % sets the caption-position to bottom
  commentstyle=\color{mygreen},    % comment style
  deletekeywords={...},            % if you want to delete keywords from the given language
  escapeinside={\%*}{*)},          % if you want to add LaTeX within your code
  extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
  frame=single,	                   % adds a frame around the code
  keepspaces=true,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
  keywordstyle=\color{blue},       % keyword style
  otherkeywords={*,...},           % if you want to add more keywords to the set
  numbers=left,                    % where to put the line-numbers; possible values are (none, left, right)
  numbersep=5pt,                   % how far the line-numbers are from the code
  numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers
  rulecolor=\color{black},         % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
  showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
  showstringspaces=false,          % underline spaces within strings only
  showtabs=false,                  % show tabs within strings adding particular underscores
  stepnumber=2,                    % the step between two line-numbers. If it's 1, each line will be numbered
  stringstyle=\color{mymauve},     % string literal style
  tabsize=2,	                   % sets default tabsize to 2 spaces
  title=\lstname                   % show the filename of files included with \lstinputlisting; also try caption instead of title
}

% PREPARE TITLE
\title{\textbf{Homework \#8 - Operator Overloading}}
\author{Name: }
\date{} % Hide the date

% START DOCUMENT
\begin{document}

\maketitle % Insert the title

\section{Changing the Meaning of Operators}

We talked last class about the general idea of a \textbf{class}, which is a collection of data and functions stored together in the computer's memory, inside a single variable. We talked about how - in general - we write "set" and "get" functions to access data inside our classes. Well, what do we do if we want to use built-in operations like "+", "-", "*", or "/" with our classes? What if we want to be able to print our classes out nicely using "\textless\textless"? This can be done with something called \textbf{operator overloading}. Basically, we can teach the computer a \textbf{new meaning} for operations like "+" or "\textless\textless", and this can make our classes even easier to work with. Here is an example of a Point class for storing 2D points $(x,y)$:

\vspace{5mm}
\lstinputlisting[language=C++,firstline=13,lastline=43]{operatorOverloading.cpp}

\noindent
It looks a lot like the classes we used before. It still has "set" and "get" functions, but there's some other new stuff as well. Let's talk about that.

\subsection{Constructors}

You'll notice that there are two functions in the class that look like this:

\vspace{5mm}
\begin{lstlisting}[language=C++]
// Empty constructor
Point();

// Constructor
Point(int xp, int yp);
\end{lstlisting}

\noindent
These are called \textbf{constructors}. Their job is to set up everything inside the class each time we make a new copy of it (a new copy of a class is called an \textbf{object}). When we first make an \textbf{object} we sometimes do it like this:

\vspace{5mm}
\begin{lstlisting}[language=C++]
Point p;
\end{lstlisting}

\noindent
And sometimes we want to do it in a way that sets up all the data inside the object, like this:

\vspace{5mm}
\begin{lstlisting}[language=C++]
Point p = Point(2,5);
\end{lstlisting}

\noindent
This sets up a new Point with $x = 2$ and $y = 5$. This is why there are \textbf{two} constructors: the "empty" one handles cases where we don't need to set up the data inside our object, or when we aren't making a new object yet, and the non-empty one handles cases where we are making a new object and need to set it up.

\subsection{Overloading Functions}

So why are we allowed to have two different functions with the same name? We have two \textbf{constructors}, after all:

\vspace{5mm}
\begin{lstlisting}[language=C++]
// Empty constructor
Point();

// Constructor
Point(int xp, int yp);
\end{lstlisting}

\noindent
They are both called "Point", so how does the computer know which one we want to use? In C++, you are allowed to have more than one function with the same name, as long as the functions have different numbers of \textbf{arguments} (the things inside the parentheses "()"). Here, we have one constructor that takes two arguments, and one that takes none. This idea is called \textbf{overloading}. Basically, when the computer is making our program into machine code, it can tell which function is the right one to use by checking to see how many \textbf{arguments} and what \textbf{type} of arguments we have put inside the "()".

\clearpage

\subsection{Prototypes vs Definitions}

Well hold on, this just keeps getting stranger! These two constructors do not contain any code! There's no "\{\}". They simply end with ";" like this:

\vspace{5mm}
\begin{lstlisting}[language=C++]
// Constructor
Point(int xp, int yp);
\end{lstlisting}

\noindent
So how does this function work? It doesn't actually do anything! In C++, you can actually split functions into two parts. One part is called a \textbf{prototype} and one part is called a \textbf{definition}. The \textbf{prototype} just tells us what kind of \textbf{arguments} go into the function. Later on in our code, we have to also write a \textbf{definition} which says says how the function will actually work. The strange thing about \textbf{constructors} is that their \textbf{definitions} go outside the class. So later on in our code, we have:

\vspace{5mm}
\lstinputlisting[language=C++,firstline=45,lastline=54]{operatorOverloading.cpp}

\noindent
These actually tell the computer what the two \textbf{constructors} should do. The "Point::" part in front just tells the computer that these two functions belong to the class "Point".

\subsection{Overloading Operators}

We need the idea of a \textbf{prototype} for operator overloading. If you look back at the first page, you'll see that there's a \textbf{prototype} for the "+" operator inside our Point class...but there's no code saying how it works. That's farther down in our program code and looks like this:

\vspace{5mm}
\lstinputlisting[language=C++,firstline=56,lastline=60]{operatorOverloading.cpp}

\noindent
The "+" operator has to be \textbf{defined} outside of the Point class so that we  can use it without also saying the name of the class (like this code to make a new point):

\vspace{5mm}
\begin{lstlisting}[language=C++]
Point x = Point.Point()
\end{lstlisting}

\noindent
Putting the \textbf{definition} outside the class keeps us from having to say "Point.Point()" every time we want to use the constructor, or "Point.+(otherPoint)" every time we want to add points together.

\section{Your Turn}

\subsection{Overloading Math}

Change your Array class so that it overloads "+", "-", "*", and "/" for arrays (so that you can multiply all the numbers in two arrays together just by doing "A * B", for instance). You only need to make this work for arrays that are the same length.

\subsection{Overloading output operators}

Look at the example code for the Point class and notice that "\textless\textless" is overloaded too. Try to overload this in your Array class as well, so that you can do things like this:

\vspace{5mm}
\begin{lstlisting}[language=C++]
cout << A << endl;
\end{lstlisting}

\end{document}


\documentclass{article}

% \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 geometryhttps://www.washingtonpost.com/world/europe/amid-impeachment-probe-gordon-sondland-is-overseeing-a-renovation-of-his-residence-that-has-cost-1-million-in-taxpayer-money/2019/10/16/d0eece92-ef86-11e9-bb7e-d2026ee0c199_story.html?tid=sm_tw
%\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						\label{thm:integral_domain}

								% TeX will automatically convert eps --> pdf in pdflatex
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{mathrsfs}
\usepackage[hyphens,spaces,obeyspaces]{url}
\usepackage{url}
\usepackage{hyperref}
\usepackage{subcaption}
\usepackage{authblk}
\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}
\usepackage{mathtools}

\usepackage{tikz}
\usepackage{verbatim}
\usetikzlibrary{plotmarks}
\usepackage{pgfplots}
\usepackage{amsmath}
\usepackage{relsize}
 \usepackage[hyphenbreaks]{breakurl}

 \newtheorem{thm}{Theorem}[section]
% \newtheorem{defn}[thm]{Definition}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\newtheorem{proposition}{Proposition}[section]
\newtheorem{lemma}{Lemma}[section]
\newtheorem{example}{Example}[section]

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

\title{A Few Notes On The Dirac Delta Function And \\ The Laplace Transform}
\author{David Meyer \\ dmm@1-4-5.net}

\date{Last update: \today}							% Activate to display a given date or no date

\begin{document}
\maketitle

\section{Introduction}
These notes began life as some thoughts on the Dirac Delta Function and evolved into notes on several related topics including  Laplace Transforms. The
Dirac Delta function has all kinds of crazy and interesting properties. More TBD.

\section{The Dirac Delta Function}
The Dirac Delta Function is defined as shown in Figure \ref{fig:delta}. In the limit ($\mathlarger{\epsilon} \to 0$) the
 Dirac Delta function is written $\delta_a(t)$ or sometimes $\delta(t - a)$. As we will see in a moment, the $\delta_{a,\epsilon}(t)$ form of the delta function
 is useful when we want to use the Mean Value Theorem for Integrals \cite{wiki:meam_value_theorem_for_integrals} to evaluate integrals involving the delta function.

\bigskip

\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=1.7]
     \draw [<->] (0,3) -- (0,0) -- (4,0);                                                                      % draw axes
     \draw (3,2) node[rectangle] {                                                                           % draw function to the right
         $\delta_{a,\epsilon}(t) =
           \begin{cases}
             \frac{1}{\mathlarger {\epsilon}} & a \leq t \leq a + \epsilon \\
             0                                               & \text{otherwise}
           \end{cases}$
       };
     \draw [dashed] (1,0) node[below] {$a$}                 -- (1,1);
     \draw [dashed] (2,0) node[below] {$a + \epsilon$} -- (2,1);
     \coordinate (y) at (0,1); \fill [black] (y) circle (1pt);                                           % draw a dot on the y axis (I'd like to make it smaller but I don't see how)
     \draw (0,1) node[left] {$\frac{1}{\mathlarger{\epsilon}}$};
     \draw [thick,red] (0,0) -- (1,0);
     \draw [thick,red] (2,0) -- (4,0);
     \draw [thick,red] (1,1) -- (2,1);
     \draw [dashed]   (0,1) -- (1,1);
     \draw (4,0) node [label=right:{$t$}] {};
     \draw (0,3) node [label=above:{$\delta_{a,\epsilon}(t)$}] {};
  \end{tikzpicture}
  \caption{The Dirac Delta Function $\delta_{a,\epsilon}(t)$}
  \label{fig:delta}
\end{figure}

\bigskip
\noindent
So $\delta_{a,\epsilon}(t)$ is defined to be

\begin{equation*}
\delta_{a,\epsilon}(t) =
 \begin{cases}
      \frac{1}{\mathlarger {\epsilon}} & a \leq t \leq a + \epsilon \\
      0                                               & \text{otherwise}
   \end{cases}
\label{eqn:delta}
\end{equation*}

\noindent
\bigskip
and has the constraint that

\begin{equation*}
  \int_{0}^{\infty} \delta_{a,\epsilon}(t) =  1
\end{equation*}

\bigskip
\bigskip
\noindent
\bigskip
That is, $\delta_{a,\epsilon}(t)$ is in some sense a probability density.

\bigskip
\noindent
In the limit the Dirac Delta Function looks like

\begin{equation*}
\lim_{\epsilon \to 0} \delta_{a,\epsilon}(t) =
\delta_{a}(t) =
 \begin{cases}
     \infty & t = a\\
      0     & t \neq a
   \end{cases}
\end{equation*}

\bigskip
\noindent
or sometimes

\begin{equation*}
\delta (t - a) =
  \begin{cases}
        \infty & t = a \\
        0       & t \neq a
  \end{cases}
\end{equation*}

\bigskip
\noindent
$\delta_a(t)$ also has the constraint that

\begin{equation*}
  \int_{0}^{\infty} \delta_{a}(t) =  1
\end{equation*}

\bigskip
\noindent
and so is also a probability density. $\delta_a(t)$  is shown in Figure \ref{fig:delta_limit}.

\bigskip
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=2.0]
     \draw [<->] (0,2) -- (0,0) -- (4,0);                                                                      % draw axes
     \draw (3,1) node[rectangle] {                                                                           % draw function to the right
         $\delta_{a}(t) =
           \begin{cases}
              \infty & t = a  \\
               0      & \text{otherwise}
           \end{cases}$
       };
     \draw (1,0) node[below] {$a$};
     \draw [dashed,red] (1,0) -- (1,2);
     \draw (4,0) node [label=right:{$t$}] {};
     \draw (0,2) node [label=above:{$\delta_{a}(t)$}] {};
     \draw [thick,red] (0,0) -- (1,0);
     \draw [thick,red] (1,0) -- (4,0);
  \end{tikzpicture}
  \caption{The Dirac Delta Function $\delta_{a}(t)$}
  \label{fig:delta_limit}
\end{figure}

\subsection{Integrals involving $\delta_{a,\epsilon}(t)$}
$\delta_{a,\epsilon}(t)$ has all kinds of interesting properties. One of them involves the integral of the product $\delta_{a,\epsilon}(t)$ with some function $g(t)$.
Here we would like to evaluate integrals of the form

\bigskip
\begin{equation}
  \int_{0}^{\infty} \delta_{a,\epsilon}(t) g(t) dt
  \label{eqn:delta_integral}
\end{equation}

\bigskip
\noindent
where $g(t)$ is continuous on the interval $[a, a+\epsilon]$.

\bigskip
\noindent
The Mean Value Theorem for Integrals  \cite{wiki:meam_value_theorem_for_integrals}  tells us that

\begin{equation}
  \int_{a}^{b} g(t) dt = (b -a) g(c)
  \label{eqn:mvti}
\end{equation}

\bigskip
\noindent
where the point $c$ lies in the interval $[a, a+\epsilon]$. Now, since we know that $\delta_{a,\epsilon}(t)$ is zero everywhere except on the interval
$[a, a+\epsilon]$ we can rewrite the improper integral in Equation \ref{eqn:delta_integral} as the proper integral

\begin{equation*}
  \int_{a}^{a + \epsilon} \delta_{a,\epsilon}(t) g(t) dt
\end{equation*}

\bigskip
\noindent
Here we can notice that $ \delta_{a,\epsilon}(t) = \frac{1}{\mathlarger{\epsilon}}$ on the interval $[a, a+\epsilon]$ so we can rewrite our integral as

\bigskip
\begin{equation*}
  \int_{a}^{a + \epsilon} \frac{1}{\mathlarger{\epsilon}} g(t) dt =  \frac{1}{\mathlarger{\epsilon}} \int_{a}^{a + \epsilon} g(t) dt
\end{equation*}

\bigskip
\noindent
Now we can use Equation \ref{eqn:mvti}, the Mean Value Theorem for Integrals\footnote{This is where the $\delta_{a,\epsilon}(t)$ form of the delta function comes in handy.},
by setting $b = a + \epsilon$ and $a = a$ so that $b - a = \epsilon$. Then

\bigskip
\begin{equation*}
 \frac{1}{\mathlarger{\epsilon}} \int_{a}^{a + \epsilon} g(t) dt =  \frac{1}{\mathlarger{\epsilon}} \underbrace{ \Big [(a + \epsilon) - a \Big]}_{b -a} g(c) = \frac{1}{\mathlarger{\epsilon}} \epsilon g(c) = g(c)
\end{equation*}

\bigskip
\noindent
where $c \in [a, a + \epsilon]$.

% \newpage
\bigskip
\noindent
Finally, if we look at what happens to $c$ as $\epsilon \to 0$ we see that $\lim\limits_{\epsilon \to 0} c = a$ (sorry about the notation abuse)
so that

\begin{equation}
  \int_{0}^{\infty} \delta_{a}(t) g(t) dt = g(a)
  \label{eqn:g(a)}
\end{equation}

\bigskip
\noindent
Essentially $\delta_{a}(t)$ pulls out the value of $g$ at $a$, that is, $g(a)$.

\bigskip
\noindent
Another way to look at this \cite{youtube:suskind2008.4} is to notice that the integrand of

\bigskip
\begin{equation*}
  \int_{0}^{\infty} \delta (t-a) g(t) dt
\end{equation*}

\bigskip
\noindent
is zero everywhere except where $t = a$, so we can rewrite our integral as
 $\int_{0}^{\infty} \delta (t-a) g(a) dt = g(a) \int_{0}^{\infty} \delta (t-a) dt$ (since $g(a)$ doesn't depend on $t$).
 Then since by definition $ \int_{0}^{\infty} \delta (t-a) dt = 1$ we get

\bigskip
\begin{equation*}
  \int_{0}^{\infty} \delta (t-a) g(t) dt = g(a)
\end{equation*}

\bigskip
\section{The Laplace Transform}
\label{sec:laplace_transform}
We start by defining the integral transform of some function $f(t)$.

\bigskip
\begin{definition}
{\bf Integral Transform:} If a function $f(t)$ is defined on $[0,\infty)$ then we can define an integral transform to be the improper integral
\end{definition}

\begin{equation*}
F(s) = \int_0^\infty K(s,t) f(t) dt
\end{equation*}

\bigskip
\noindent
If the improper integral converges then we say that $F(s)$ is the \emph{integral transform} of $f(t)$. The function $K(s,t)$ is called the \emph{kernel}
of the transform. When $K(s,t) = e^{-st}$ the transform is called the {\bf Laplace Transform}.

\bigskip
\begin{definition}
{\bf Laplace Transform:} The Laplace Transform of a function $f(t)$ is defined to be
\label{def:laplace_transform}
\end{definition}

\begin{equation}
\mathcal{L}\{f(t)\} = F(s) = \int_0^\infty e^{-st} f(t) dt
\label{eqn:laplace_transform}
\end{equation}

\bigskip
\noindent
The Laplace Transform will turn out to be useful when solving ordinary differential equations (ODEs). Interestingly, the Laplace Transform of the
Dirac Delta Function turns out to be

\bigskip
\begin{equation*}
\begin{array}{lllll}
\mathcal{L}\{\delta_a(t)\}
&=& \int_0^\infty  e^{-st} \delta_a(t) dt    &\qquad \qquad \mathrel{\#} \text{Equation \ref{eqn:laplace_transform} with $f(t) = \delta_a(t)$}                    \\
[4pt]                                                        % get a bit of space
&=& \int_0^\infty g(t) \delta_a(t) dt         &\qquad \qquad \mathrel{\#} \text{set $g(t) = e^{-st}$}                                                                                \\
[4pt]                                                        % get a bit of space
&=& g(a)                                                &\qquad \qquad \mathrel{\#} \text{by Equation \ref{eqn:g(a)}}                                                                           \\
[4pt]                                                        % get a bit of space
&=& e^{-sa}                                            &\qquad \qquad \mathrel{\#} g(a) = e^{-sa}
\end{array}
\end{equation*}

\subsection{The Linearity Property of the Laplace Transform}
\label{subsec:linearity}

\bigskip
\begin{definition}
{\bf Linearity Property:} $\mathcal{L}\{af (t) + bg(t)\} = a\mathcal{L}\{f(t)\} + b\mathcal{L}\{g(t)\}$
\label{def:linearity_properity}
\end{definition}

\bigskip
\noindent
Interestingly, $\mathcal{L}$ is what is called a linear operator in vector space parlance \cite{wiki:linear_map}.

\bigskip
\noindent
All good, but why does $\mathcal{L}$ have this property? Here's one way to think about it:

\smallskip
\begin{equation*}
\begin{array}{lllll}
\mathcal{L}\{af(t) + bg(t)\}
&=& \int_0^\infty e^{-st} \big [af (t) + bg(t) \big] dt                                & \mathrel{\#} \text{definition of the Laplace Transform (Definition \ref{def:laplace_transform})}                               \\
[10pt]                                                                                % get a bit of space
&=& \int_0^\infty e^{-st} af (t)  dt + \int_0^\infty e^{-st}  bg(t)  dt          & \mathrel{\#} \text{by the linearity of improper integrals \cite{lewis2014}}                                                                 \\
[10pt]                                                                                % get a bit of space
&=& a \int_0^\infty e^{-st}  f(t) dt + b \int_0^\infty e^{-st}  g(t) dt          & \mathrel{\#} \text{neither $a$ nor $b$ depends on $t$}                                                                                \\
[10pt]                                                                                % get a bit of space
&=& a \mathcal{L}\{f(t)\}  + b \mathcal{L}\{g(t)\}                                   & \mathrel{\#} \text{definition of the Laplace Transform (Definition \ref{def:laplace_transform})}
\end{array}
\end{equation*}

\smallskip
\subsection{So does every function have a Laplace Transform?}
The answer is no (consider a function like $f(t) = t^{-1}$). Ok, then what are the properties that $f(t)$ must have in order to have a Laplace Transform? First, $f$ must
be of "exponential order".

\bigskip
\begin{definition}
{\bf Exponential Order:} A function $f$ is said to be of exponential order $c$ if there exist constants $c, M, \text{ and } T > 0$ such that $|f(t)| \leq Me^{ct}$ for all $t > T$.
\label{def:exponential_order}
\end{definition}

\bigskip
\noindent
Said another way, in order for $f(t)$ to be of exponential order $c$ we require that

\bigskip
\begin{equation*}
\lim\limits_{t \to \infty} \frac{f(t)}{e^{ct}} = 0
\end{equation*}

\medskip
\bigskip
\noindent
Basically this is saying that in order for $f(t)$ to have a Laplace Transform then in a race between $|f(t)|$ and $e^{ct}$ as $t \to \infty$ $e^{ct}$ must
approach its limit first. This situation is depicted in Figure \ref{fig:exponential_order}.

\bigskip
\bigskip
\begin{figure}[H]
\center{\includegraphics[scale=0.39,frame] {images/exponential_order.png}}
\caption{$f$ is of exponential order with constants $c, M$ and $T$}
\label{fig:exponential_order}
\end{figure}

\bigskip
\bigskip
\noindent
Now we can answer the question of when $f$ has a Laplace Transfrom:

\bigskip
\begin{thm}
{\bf Existence Theorem for Laplace Transforms:} \normalfont If $f$ is s piecewise continuous on the interval $[0,\infty)$ and is of exponential order $c$ then
$F (s) = \mathcal{L}\{f (t)\} \text{ is defined for all $s > c$}.$
\end{thm}

\bigskip
\noindent
Ok, but why? Consider

\begin{equation*}
\begin{array}{lllll}
\mathcal{L}\{f(t)\}
&=& F(s)                                                                            &\quad  \mathrel{\#} \text{definition of the Laplace Transform (Definition \ref{def:laplace_transform})}                                                \\
[12pt]                                                                                % get a bit of space
&=&   \mathlarger{\int}_0^\infty \! e^{-st} f(t) dt                  &\quad  \mathrel{\#} \text{definition of the Laplace Transform (Definition \ref{def:laplace_transform})}                                                \\
[12pt]                                                                                % get a bit of space
&\leq& \mathlarger{\int}_0^\infty \! e^{-st}  Me^{ct}dt         &\quad  \mathrel{\#} \text{$f$ is of exponential order $c$ (Definition \ref{def:exponential_order})}                                                      \\
[12pt]                                                                                % get a bit of space
&=& M \mathlarger{\int}_0^\infty \! e^{-st} e^{ct} dt           &\quad  \mathrel{\#} \text{$M$ doesn't depend on $t$}                                                                                \\
[12pt]                                                                                % get a bit of space
&=& M \mathlarger{\int}_0^\infty \! e^{-st + ct}  dt             &\quad  \mathrel{\#} \text{$x^n \cdot x^m = x^{n+m}$}                                                                                \\
[12pt]                                                                                % get a bit of space
&=& M \mathlarger{\int}_0^\infty\! e^{(c-s)t}  dt                 &\quad  \mathrel{\#}  e^{-st + ct} = e^{ct -st} = e^{(c-s)t}                                                                                \\
[12pt]                                                                                % get a bit of space
&=&  M \mathlarger{\int}_0^\infty \! e^u dt                         &\quad  \mathrel{\#} \text{use a $u$ substitution with $u = (c-s)t$}                                                                                \\
[12pt]                                                                                % get a bit of space
&=&  M \mathlarger{\int}_0^\infty \! e^u \frac{du}{c-s}       &\quad  \mathrel{\#} u = (c-s)t  \: \Rightarrow \: du = (c-s) dt \: \Rightarrow \: dt = \dfrac{du}{c-s}                                                         \\
[12pt]                                                                                % get a bit of space
&=& \Big [ \frac{M}{c-s} \Big ] \mathlarger{\int}_0^\infty \! e^u du                                    &\quad  \mathrel{\#} \text{neither $c$ nor $s$ depends on $t$}                                                              \\
[12pt]                                                                                % get a bit of space
&=& \Big [ \frac{M}{c-s} \Big ] e^u \Big |_0^\infty              &\quad  \mathrel{\#} \int_0^\infty e^u du = e^u +C \text{ and the Fundamental Theorem of Calculus}                                                  \\
[12pt]                                                                                % get a bit of space
&=& \Big [ \frac{M}{c-s} \Big ]  e^{(c-s)t} \Big |_0^\infty     &\quad  \mathrel{\#} u = (c-s)t                                                                                \\
[12pt]                                                                                % get a bit of space
&=& \lim\limits_{d \to \infty}\Big [\frac{M}{c-s} e^{(c-s)d} \Big ] - \frac{M}{c - s}e^{(c-s)0}  &\quad \mathrel{\#} \text{evaluate at the limits}                                                                                \\
[12pt]                                                                                % get a bit of space
&=& \lim\limits_{d \to \infty}\Big [\frac{M}{c-s} e^{(c-s)d} \Big ] - \frac{M}{c - s}                 &\quad  \mathrel{\#} e^{(c-s)0} = e^0 = 1 \text{ and } \frac{M}{c-s} \cdot 1 = \frac{M}{c-s}                     \\
[12pt]                                                                                % get a bit of space
&=& 0 - \frac{M} {\mathlarger{c-s}}                                   &\quad  \mathrel{\#} s > c \: \Rightarrow \: c -s < 0 \: \Rightarrow  \lim\limits_{d \to \infty}\Big [\frac{M}{c-s} e^{(c-s)d} \Big ] = 0          \\
[12pt]                                                                                % get a bit of space
&=& \frac{M}{\mathlarger{s-c}}                                         &\quad  \mathrel{\#} \text{simplify}
\end{array}
\end{equation*}

\bigskip
\noindent
So if $s = c$ then $\frac{M}{\mathlarger{s-c}}$ is not defined and $\mathcal{L}\{f(t)\}$ does not exist. Similarly, if $s < c$ then $\lim\limits_{d \to \infty}\Big [\frac{M}{c-s} e^{(c-s)d} \Big ]$
does not converge and $\mathcal{L}\{f(t)\}$ does not exist. All of this implies that functions that do not satisfy the conditions of the Existence Theorem do not have Laplace Transforms.

\newpage
\subsection{Inverse Laplace Transform}
\label{sec:inverse_laplace_transform}

\begin{definition} {\bf Inverse Laplace Transform:}
If $F(s)$ represents the Laplace Transform of a function $f(t)$ such that $\mathcal{L}\{f(t)\} = F(s)$
then the Inverse Laplace Transform of $F(s)$ is $f(t)$, i.e. $\mathcal{L}^{-1}\{F(s)\} = f(t)$.
\end{definition}

\bigskip
\noindent
Here are a few examples:

\bigskip
\bigskip

\begin{minipage}[c]{0.40\textwidth}
\centering
\renewcommand{\arraystretch}{3}
\begin{tabular} {| c | c  |}
\hline
\multicolumn{2} {| c |}{\bf Laplace Transform}     \\
\hline
$f(t)$                 & $F(s) = \mathcal{L}\{f(t)\}$      \\
\hline \hline
1                       & $\frac{1}{s}$                            \\
[4pt]
\hline
$t^n$                & $\frac{n!}{s^{n+1}}$                 \\
[4pt]
\hline
$e^{at}$            & $\frac{1}{s - a}$                       \\
[4pt]
\hline
$\sin(kt)$           & $\frac{k}{s^2 + k^2}$               \\
[4pt]
\hline
$\cos(kt)$          & $\frac{s}{s^2 + k^2}$               \\
[4pt]
\hline
$\sinh(kt)$         & $\frac{k}{s^2 - k^2}$                \\
[4pt]
\hline
$\cosh(kt)$        & $\frac{s}{s^2 - k^2}$                \\
[4pt]
\hline
$\dfrac{dg}{dt}$ & $sG(s) - g(0)$                          \\
[4pt]
\hline
\end{tabular}
\end{minipage}
%
\begin{minipage}[c]{0.40\textwidth}
\renewcommand{\arraystretch}{3}
\centering
\begin{tabular} {| c | c  |}
\hline
\multicolumn{2} {| c |}{\bf Inverse Laplace Transform}      \\
\hline
$F(s)$  & $f(t) = \mathcal{L}^{-1}\{F(s)\}$                         \\
\hline \hline
$\frac{1}{s}$           & 1                                                     \\
[4pt]
\hline
$\frac{n!}{s^{n+1}}$ & $t^n$                                             \\
[4pt]
\hline
$\frac{1}{s - a}$       & $e^{at}$                                         \\
[4pt]
\hline
$\frac{k}{s^2 + k^2}$ & $\sin(kt)$                                      \\
[4pt]
\hline
$\frac{s}{s^2 + k^2}$ & $\cos(kt)$                                     \\
[4pt]
\hline
 $\frac{k}{s^2 - k^2}$ & $\sinh(kt)$                                     \\
[4pt]
\hline
$\frac{s}{s^2 - k^2}$  & $\cosh(kt)$                                    \\
[4pt]
\hline
$sG(s) - g(0)$           & $\dfrac{dg}{dt}$                              \\
[4pt]
\hline
\end{tabular}
\end{minipage}

\newpage

\subsection{Ok, then what is the Laplace Transform of $f^\prime (t)$?}
\label{sec:f_prime}
Suppose $f(t)$ is continuous, piecewise smooth and of exponential order, and suppose $f^\prime(t)$ is the derivative of $f(t)$. Then the
Laplace Transform of $f^\prime(t), \: \mathcal{L}\{f^\prime(t)\}$, turns out to be

\begin{equation*}
\begin{array}{lllll}
\mathcal{L}\{f^\prime(t)\}
&=& \mathlarger{\int} ^\infty_0 \! e^{-st}  f^\prime(t) dt                                                                                &\mathrel{\#} \text{definition Laplace Transform (Definition \ref{def:laplace_transform})} \\
[20pt]                                                                                % get some space
&=& \mathlarger{\int}^\infty_0 \! \underbracket [0.15 ex] {\strut e^{-st}}_{v}  \underbracket [0.15 ex] {\strut f^\prime(t) dt}_{du}    &\mathrel{\#} \text{use integration by parts}                                                                      \\
[20pt]                                                                                % get some space
&=& \underbracket [0.15 ex] {\strut e^{-st}}_{v}  \underbracket [0.15 ex] {\strut f(t)}_{u} \bigg |^\infty_0   -
        \mathlarger{\int}^\infty_0 \! \underbracket [0.15 ex] {\strut (-s) e^{-st}}_{dv}  \underbracket [0.15 ex] {\strut f(t)}_{u} dt
        &\mathrel{\#} \mathlarger{\int}_0^\infty \! v \: du = uv - \mathlarger{\int}_0^\infty \! u \: dv                                                                                \\
[20pt]                                                                                % get some space
&=& \lim\limits_{d \to \infty}\Big [e^{-sd} f(d) \Big ] - e^{-s \cdot 0} \cdot f(0) - \mathlarger{\int}^\infty_0 \!  (-s) e^{-st}  f(t) dt         &\mathrel{\#} \text{evaluate first term at the limits}                                                           \\
[20pt]                                                                                % get some space
&=& 0  - e^{-s \cdot 0} \cdot f(0)  - \mathlarger{\int}^\infty_0 \!  (-s) e^{-st}  f(t) dt                                                                          &\mathrel{\#} \lim\limits_{d \to \infty}\Big [e^{-sd} f(d) \Big ] = 0                                         \\
[20pt]                                                                                % get some space
&=& 0 - f(0) - \mathlarger{\int}^\infty_0 \!  (-s) e^{-st}  f(t) dt                                                                                &\mathrel{\#} e^{-s \cdot 0} = e^0 = 1 \text{ and } 1 \cdot f(0) = f(0)                                  \\
[20pt]                                                                                % get some space
&=& -f(0) + s \mathlarger{\int}^\infty_0 \!  e^{-st}  f(t) dt                                                                                &\mathrel{\#} \text{$s$ doesn't depend on $t$ and simplify}                                             \\
[20pt]                                                                                % get some space
% &=& -f(0) + s F(s)                                                                                \mathrel{\#} \text{definition Laplace Transform (Definition \ref{def:laplace_transform})} \\
% [20pt]                                                                                % get some space
&=& -f(0) + s \mathcal{L}\{f(t)\}                                                                                &\mathrel{\#} \text{definition Laplace Transform (Definition \ref{def:laplace_transform})} \\
[20pt]                                                                                % get some space
&=& s \mathcal{L}\{f(t)\} - f(0)                                                                                &\mathrel{\#} \text{rearrange}        \\
[20pt]                                                                                % get some space
&=& s F(s) - f(0)                                   &\mathrel{\#} \text{definition Laplace Transform (Definition \ref{def:laplace_transform})} \\
\end{array}
\end{equation*}

\bigskip
\noindent
One of the interesting things to note here is that by using the Laplace Transform we've taken a statement about the derivative of $f$, namely $\mathcal{L}\{f^\prime(t)\}$,
and converted it into a statement about $f$ itself: $s \mathcal{L}\{f(t)\} - f(0)$. That is, we've converted a differential equation into an algebraic one. This will come in handy later
when we want to solve differential equations.

\newpage
\subsection{What about $\mathcal{L}\{f^{\prime\prime}(t)\}$?}
\label{eqn:f_double_prime}

\bigskip
\noindent
Once we know how to compute $\mathcal{L}\{f^{\prime}(t)\}$ it is pretty easy to see how to compute $\mathcal{L}\{f^{\prime\prime}(t)\}$:

\begin{equation*}
\begin{array}{lllll}
\mathcal{L}\{f^{\prime \prime}(t)\}
&=&  \mathcal{L}\{g^\prime (t)\}                                 &\qquad \qquad \mathrel{\#} \text{set $g(t) = f^\prime(t) \Rightarrow g^\prime(t) = f^{\prime \prime}(t)$}                         \\
[8pt]
&=& s \mathcal{L}\{g(t)\}  - g(0)                                 &\qquad  \qquad \mathrel{\#} \mathcal{L}\{g(t)^\prime\} = s \mathcal{L}\{g(t)\}  - g(0) \text{ (Section \ref{sec:f_prime})}   \\
[8pt]
&=& s \mathcal{L}\{f^\prime(t)\} - f^\prime(0)             &\qquad \qquad \mathrel{\#} g(t) = f^\prime(t)                                                                                \\
[8pt]
&=& s \big [ sF(s) - f(0) \big ] - f^\prime(0)                 &\qquad \qquad \mathrel{\#} \mathcal{L}\{f(t)^\prime\} = s F(s) -f(0) \text{ (Section \ref{sec:f_prime})}                             \\
[8pt]
&=& s^2F(s) - sf(0) - f^\prime(0)                                &\qquad \qquad \mathrel{\#} \text{simplify}
\end{array}
\end{equation*}

\smallskip
\subsection{So what is the general form of $\mathcal{L}\{f^{(n)}(t)\}$?}
\bigskip
\noindent
The general form of the Laplace Transform of the $n^{th}$ derivative of some function $f(t)$ is

\bigskip
\begin{equation}
\mathcal{L}\{f^{(n)}(t)\} =  s^{n}F(s)- \sum_{k=1}^n s^{n-k} f^{(k-1)}(0)
\label{eqn:nth-derivative}
\end{equation}

\bigskip
\noindent
Here $f$ is assumed to be n-times differentiable and that it's $n^{th}$ derivative, denoted $f^{(n)}$, is piecewise continuous and of exponential order. The
result then follows by mathematical induction. Note that $f^{(0)}$, the $0^{\text{th}}$ derivative of $f$, is just $f$.

\bigskip
\noindent
So for example, for the Laplace Transform of the second derivative ($n = 2$) of some function $f$ Equation \ref{eqn:nth-derivative} tells us

\begin{equation*}
\begin{array}{lllll}
\mathcal{L}\{f^{(2)}(t)\}
&=&  s^{2}F(s)- \sum\limits_{k=1}^2 s^{2-k} f^{(k-1)}(0)                                         &\qquad \mathrel{\#} \text{Equation \ref{eqn:nth-derivative} with $n = 2$}               \\
[10pt]
&=&  s^{2}F(s)- s^{2-1}f^{(1-1)}(0)  - s^{2-2}f^{(2-1)}(0)                                         &\qquad \mathrel{\#} \text{expand terms}                                                                  \\
[10pt]
&=&  s^{2}F(s)- s^{1}f^{(0)}(0)  - s^0f^{(1)}(0)                                                        &\qquad \mathrel{\#} \text{arithmetic}                                                                        \\
[10pt]
&=&  s^{2}F(s)- sf(0)  - f^{(1)}(0)                                                                            &\qquad \mathrel{\#} \text{$s^1 = s$, $f^{(0)} = f$ and $s^0 = 1$}                             \\
[10pt]
&=& s^{2}F(s)- sf(0)  - f^{\prime}(0)                                                                       &\qquad \mathrel{\#} \text{alternate notation (Section \ref{eqn:f_double_prime})}
\end{array}
\end{equation*}

\subsection{What is the derivative of $F(s)$?}

\bigskip
\begin{equation*}
\begin{array}{lllll}
F^\prime(s)
&=& \dfrac{d}{ds} F(s)                                                                                &\qquad \qquad \mathrel{\#} \text{switch to more a convenient notation}                                                                    \\
[20pt]
&=& \dfrac{d}{ds} \mathlarger{\int} ^\infty_0 \! e^{-st}  f(t) dt                              &\qquad \qquad \mathrel{\#} \text{definition of the Laplace Transform (Definition \ref{def:laplace_transform})}          \\
[20pt]
&=& \mathlarger{\int} ^\infty_0 \! \dfrac{\partial}{\partial s} e^{-st}  f(t) dt           &\qquad \qquad \mathrel{\#} \text{swap $\dfrac{d}{ds}$ with $\mathlarger{\int}$ by the Leibniz integral rule}             \\
[20pt]
&=&  \mathlarger{\int}^\infty_0 \! (-t) e^{-st} f(t) dt                                             &\qquad \qquad \mathrel{\#} \mathlarger{\dfrac{\partial}{\partial s} e^{-st}} = -t e^{-st} \text{ by the chain rule}            \\
[20pt]
&=&  \mathlarger{\int}^\infty_0 \! e^{-st}  (-t) f(t) dt                                            &\qquad \qquad \mathrel{\#} \text{rearrange}                                                                                \\
[20pt]
&=&  \mathlarger{\int}^\infty_0 \! e^{-st} g(t) dt                                                  &\qquad \qquad \mathrel{\#} \text{set $g(t) = -t f(t)$}                                                                                \\
[20pt]
&=& \mathcal{L}\{g(t)\}                                                                                &\qquad \qquad \mathrel{\#} \text{definition of the Laplace Transform (Definition \ref{def:laplace_transform})}          \\
[20pt]
&=& \mathcal{L}\{-tf(t)\}                                                                                &\qquad \qquad \mathrel{\#} g(t) = -t f(t)                                                                                \\
[20pt]
&=& -\mathcal{L}\{tf(t)\}                                                                                &\qquad \qquad \mathrel{\#} \text{$-1$ doesn't depend on $t$ (see Section \ref{subsec:linearity})}
\end{array}
\end{equation*}

\bigskip
\noindent
So $F^\prime(s) = -\mathcal{L}\{tf(t)\}$. We can also pretty easily see that in general $F^{(n)}(s) = (-1)^n \mathcal{L}\{t^n f(t)\}$.

\bigskip
\subsection{Example: Solving Ordinary Differential Equations (ODEs)}
\label{sec:example_ode}
\bigskip
\noindent
Suppose we have the following Initial Value Problem (IVP)  \cite{wiki:initial_value_problem}:

\smallskip
\begin{equation}
y^{\prime \prime} - y^\prime -2y = 0 \text{ with $y(0) = 1$ and $y^\prime (0) = 0$}
\label{eqn:ode}
\end{equation}

\bigskip
\noindent
We can use the Laplace Transform to solve this ODE. The basic idea is to take the Laplace Transform of both sides of Equation \ref{eqn:ode}, set $Y(s) = \mathcal{L}\{y\}$,
and then solve for $Y(s)$. Then we can find $y(t)$ by taking the Inverse Laplace Transform of $Y(s)$.

\begin{equation*}
\begin{array}{lllll}
y^{\prime \prime} - y^\prime -2y
&=& 0                                                                                &\mathrel{\#} \text{ODE we want to solve (Equation \ref{eqn:ode}})                                                 \\
[15pt]
 &\Rightarrow& \mathcal{L}\{y^{\prime \prime}\} - \mathcal{L}\{y^\prime\} -\mathcal{L}\{2y\}  = \mathcal{L}\{0\}      &\mathrel{\#} \text{take the LT of both sides}                                                                                \\
[15pt]
&\Rightarrow& \mathcal{L}\{y^{\prime \prime}\} - \mathcal{L}\{y^\prime\} - 2\mathcal{L}\{y\}                 = 0             &\mathrel{\#} \text{$\mathcal{L}\{a f(t) \} = a \mathcal{L}\{f(t)\}$ and $\mathcal{L}\{0\} = 0$}             \\
[15pt]
&\Rightarrow& \big [ s^2 \mathcal{L}\{y\} - s y(0) - y^\prime (0) \big ] - \mathcal{L}\{y^\prime\} - 2\mathcal{L}\{y\} = 0   &\mathrel{\#} \text{$\mathcal{L}\{y^{\prime \prime}\} = \hdots$ (Section \ref{eqn:f_double_prime})}  \\
[15pt]
&\Rightarrow& \big [ s^2 Y(s) - s y(0) - y^\prime (0) \big ] - \mathcal{L}\{y^\prime\} - 2\mathcal{L}\{y\} = 0             &\mathrel{\#} \text{set } Y(s) = \mathcal{L}\{y\}                                                                                \\
[15pt]
&\Rightarrow&  \big [ s^2 Y(s) - s y(0) - y^\prime (0) \big ] - \big [ s Y(s) - y(0) \big ]- 2\mathcal{L}\{y\} = 0             &\mathrel{\#} \text{$\mathcal{L}\{y^\prime\} = sY(s) - y(0)$ (Section \ref{sec:f_prime})}                     \\
[15pt]
&\Rightarrow&  \big [ s^2 Y(s) - s y(0) - y^\prime (0) \big ] - \big [ s Y(s) - y(0) \big ]-  2 Y(s)                 = 0            &\mathrel{\#}  \mathcal{L}\{y\} = Y(s)                                                                                \\
[15pt]
&\Rightarrow&  s^2 Y(s) -s \cdot 1 - 0 - sY(s) + 1 - 2 Y(s)                                                                     = 0            &\mathrel{\#} \text{IVP: $y(0) = 1$ and $y^\prime (0) = 0$}                                                                 \\
[15pt]
&\Rightarrow&  s^2 Y(s) -s  - sY(s) + 1 -2 Y(s)                                                                                = 0             &\mathrel{\#} \text{simplify}                                                                                \\
[15pt]
&\Rightarrow&  s^2 Y(s) - s Y(s) - 2 Y(s) - (s - 1)                                                                                = 0             &\mathrel{\#} \text{collect terms}                                                                                \\
[15pt]
&\Rightarrow&  Y(s) \big [s^2- s - 2 \big] - (s - 1)                                                                                = 0             &\mathrel{\#} \text{factor out $Y(s)$}                                                                                \\
[15pt]
&\Rightarrow&  Y(s) \big [s^2- s - 2 \big]                                                                                = s - 1         &\mathrel{\#} \text{add $s - 1$ to both sides}                                                                                \\
[12pt]
&\Rightarrow&  Y(s) = \mathlarger{\frac{s - 1}{s^2 -s -2}}  &\mathrel{\#} \text{solve for $Y(s)$}
\end{array}
\end{equation*}

\bigskip
\noindent
So $Y(s) = \mathlarger{\frac{s - 1}{s^2 -s -2}}$. Now we can split $Y(s)$ using partial fractions and solve for $y(t)$ using the Inverse Laplace Transform:

\bigskip
\begin{equation*}
\begin{array}{lllll}
Y(s)
&=&  \mathlarger{\frac{s - 1}{s^2 -s -2}}                                                                                &\qquad \mathrel{\#} \text{see above}                                            \\
[12pt]
&=& \mathlarger{\frac{s-1}{(s-2)(s+1)}}                                                                                &\qquad \mathrel{\#} \text{factor denominator}                               \\
[12pt]
&\Rightarrow& \mathlarger{\frac{s-1}{(s-2)(s+1)}} =  \mathlarger{\frac{A}{(s-2)}} + \mathlarger{\frac{B}{(s+1)}}   &\qquad \mathrel{\#} \text{use partial fractions}                              \\
[15pt]
&\Rightarrow& s - 1 =  A (s + 1) + B (s - 2)                                                                                &\qquad \mathrel{\#} \text{multiply both sides by $(s - 2)(s + 1)$}   \\
[15pt]
&\Rightarrow& -1 = A - 2B                                                                                &\qquad \mathrel{\#} \text{coefficients of 1}                                    \\
[15pt]
&\Rightarrow& 1= A + B                                                                                &\qquad \mathrel{\#} \text{coefficients of $s$}                                 \\
[15pt]
&\Rightarrow& A = 1 -B                                                                                &\qquad \mathrel{\#} \text{solve for $A$ in previous equation}        \\
[15pt]
&\Rightarrow& -1 = (1 - B) - 2B                                                                                &\qquad \mathrel{\#} \text{plug $A = 1 -B$ into $-1 = A - 2B$}        \\
[15pt]
&\Rightarrow& -2 = -3B                                                                                &\qquad \mathrel{\#} \text{simplfy}                                                  \\
[15pt]
&\Rightarrow&  B =\frac{2}{3}                                                                                &\qquad \mathrel{\#} \text{solve for $B$}                                       \\
[15pt]
&\Rightarrow&  A =\frac{1}{3}                                                                                &\qquad \mathrel{\#} \text{plug $B$ into $A = 1 - B$}                     \\
[12pt]
&\Rightarrow& Y(s) = \mathlarger{\frac{\frac{1}{3}}{s-2}} + \mathlarger{\frac{\frac{2}{3}}{s+1}}
\end{array}
\end{equation*}

\bigskip
\noindent
So now we know that
\begin{equation*}
Y(s) = \mathlarger{\frac{\frac{1}{3}}{s-2}} + \mathlarger{\frac{\frac{2}{3}}{s+1}}
\end{equation*}

\bigskip
\noindent
and we also know (Section \ref{sec:inverse_laplace_transform}) that

\begin{equation*}
\mathcal{L}^{-1} \bigg \{ \frac{1}{s-a} \bigg \} =   e^{at}
\end{equation*}

\bigskip
\noindent
Putting this all together

\bigskip
\begin{equation*}
\begin{array}{lllll}
Y(s)
&=& \mathcal{L}\{y(t)\}                                                                                &\qquad \mathrel{\#} \text{definition of $Y(s)$ (Section \ref{sec:example_ode})}                                                        \\
[15pt]
 & \Rightarrow& \mathcal{L}^{-1}\{Y(s) \}  = \mathcal{L}^{-1}\{\mathcal{L}\{y(t)\}\}         &\qquad \mathrel{\#} \text{take the Inverse Laplace Transform of both sides}                                                            \\
[15pt]
&\Rightarrow& \mathcal{L}^{-1}\{Y(s) \}  = y(t)                                                               &\qquad \mathrel{\#}  \mathcal{L}^{-1}\{\mathcal{L}\{y(t)\}\} = y(t)                                                                                \\
[10pt]
&\Rightarrow& \mathcal{L}^{-1} \bigg \{ \mathlarger{\frac{\frac{1}{3}}{s-2}} + \mathlarger{\frac{\frac{2}{3}}{s+1}} \bigg \}  = y(t)
                                          &\qquad \mathrel{\#} Y(s) = \mathlarger{\frac{\frac{1}{3}}{s-2}} + \mathlarger{\frac{\frac{2}{3}}{s+1}} \text{ (Section \ref{sec:example_ode})}                                                        \\
[15pt]
&\Rightarrow& \mathcal{L}^{-1}\bigg \{\mathlarger{\frac{\frac{1}{3}}{s-2}} \bigg \} + \mathcal{L}^{-1}\bigg \{ \mathlarger{\frac{\frac{2}{3}}{s+1}} \bigg \} = y(t)
                                                                                &\qquad \mathrel{\#} \text{by the linearity of the Laplace Transform (Section \ref{subsec:linearity})}                         \\
[15pt]
&\Rightarrow& \frac{1}{3} \mathcal{L}^{-1}\bigg \{\mathlarger{\frac{1}{s-2}} \bigg \} + \frac{2}{3} \mathcal{L}^{-1}\bigg \{ \mathlarger{\frac{1}{s+1}} \bigg \}  = y(t)
                                                                                &\qquad \mathrel{\#} \text{neither $\frac{1}{3}$ nor $\frac{2}{3}$ depends on $t$}                                                     \\
[15pt]
&\Rightarrow& \frac{1}{3} e^{2t} +  \frac{2}{3} \mathcal{L}^{-1}\bigg \{ \mathlarger{\frac{1}{s+1}} \bigg \}  = y(t)
                                                                                &\qquad \mathrel{\#} \text{$\mathcal{L}^{-1} \Big \{ \frac{1}{s-2} \Big \} = e^{2t}$ (Section \ref{sec:inverse_laplace_transform})}  \\
[15pt]
&\Rightarrow& \frac{1}{3} e^{2t} + \frac{2}{3} e^{-t} = y(t)                          &\qquad \mathrel{\#} \text{$\mathcal{L}^{-1} \Big \{ \frac{1}{s+1} \Big \} = e^{-t}$ (Section \ref{sec:inverse_laplace_transform})}  \\
[15pt]
&\Rightarrow& y(t) = \frac{1}{3} e^{2t} + \frac{2}{3} e^{-t}                          &\qquad \mathrel{\#} \text{$=$ is symmetric}
\end{array}
\end{equation*}

\bigskip
\noindent
So we've been able to use the Laplace Transform to solve the ODE in Section \ref{sec:example_ode} (Equation \ref{eqn:ode}):

\bigskip
\begin{equation*}
y(t) = \frac{1}{3} e^{2t} + \frac{2}{3} e^{-t}
\end{equation*}

\section{\large The Heaviside Function, Convolution, and the Laplace Transform}
We saw in Section \ref{subsec:linearity} that the Laplace Transform has a linearity property, namely,

\bigskip
\begin{equation*}
\mathcal{L}\{af (t) + bg(t)\} = a\mathcal{L}\{f(t)\} + b\mathcal{L}\{g(t)\}
\end{equation*}

\bigskip
\noindent
One natural question is whether there is a "linearity-like" property for multiplication. Unfortunately

\bigskip
\begin{equation*}
\mathcal{L}\{f(t)g(t)\} \neq  \mathcal{L}\{f(t)\}\mathcal{L}\{g(t)\}
\end{equation*}

\bigskip
\noindent
However, convolution behaves better with respect to the Laplace Transform of a product. Specifically

\bigskip
\begin{equation}
\mathcal{L}\{f(t) \ast g(t)\} =  \mathcal{L}\{f(t)\}\mathcal{L}\{g(t)\}
\label{eqn:lt_of_convolution}
\end{equation}

\bigskip
\noindent
where $\ast$ is the convolution operator.

\bigskip
\noindent
To see why Equation  \ref{eqn:lt_of_convolution} holds we need another piece of machinery, the Heaviside function.

\subsection{The Heaviside Function}
The most basic definition of the Heaviside function is

\begin{definition} {\bf Heaviside Function:}
\bigskip
\begin{equation*}
u(t) =
 \begin{cases}
   0 & t < 0  \\
    1 & t \geq 0
   \end{cases}
\end{equation*}
\label{def:heaviside_function}
\end{definition}

\bigskip
\noindent
The Heaviside function is shown in Figure \ref{fig:u(t)}.

\bigskip
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=2.0]
     \draw [thick,->,dashed] (0,0) -- (0,2);                                                                      % draw axes
     \draw [thick,->,dashed] (0,0) -- (3,0);                                                                      % draw axes
     \draw (2,2) node[draw,rectangle] {                                                                          % draw function to the right
         $u(t) =
           \begin{cases}
               0 & t < 0  \\
               1  & t \geq 1
           \end{cases}$
       };
     \draw (3,0) node [label=right:{$t$}] {};
     \draw (0,2) node [label=above:{$u(t)$}] {};
     \draw [<-,thick,red] (-2,0) -- (0,0);
     \draw [->,thick,red] (0,1) -- (3,1);
     \coordinate (y) at (0,1); \fill [red] (y) circle (1pt);                                                     % draw a dot on the y axis (I'd like to make it smaller but I don't see how)
     \draw (0,1) node[left] {1};
     \draw [thick,red] (0,0) circle [radius =0.03cm];                                                       % draw an open red circle on the x axis at (0,0)
     \draw (0,0) node[below] {$0$};
  \end{tikzpicture}
  \caption{The Heaviside Function $u(t)$}
  \label{fig:u(t)}
\end{figure}

\bigskip
\noindent
More frequently we are interested in $u(t-a)$, which is sometimes written as $u_a(t)$,  is shown in Figure \ref{fig:u(t-a)}.

\bigskip
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=2.0]
%  \draw [<->] (0,2) -- (0,0) -- (4,0);                                                                      % draw axes
     \draw [thick,->] (0,0) -- (0,2);                                                                           % draw axes
     \draw [thick,<->] (-2,0) -- (3,0);                                                                        % draw axes
     \draw (2,2) node[draw,rectangle] {                                                                  % draw function to the right
         $u(t-a) =
           \begin{cases}
               0 & t < a  \\
               1  & t \geq a
           \end{cases}$
       };
     \draw (1,0) node[below] {$a$};
     \draw [thick,red] (1,0) circle [radius =0.03cm];                                                  % draw an open red circle on the x axis above the "a"
     \draw [dashed] (1,0) -- (1,1);
     \draw (3,0) node [label=right:{$t$}] {};
     \draw (0,2) node [label=above:{$u(t-a)$}] {};
     \draw [thick,red] (-2,0) -- (1,0);
     \draw [->,thick,red] (1,1) -- (3,1);
     \coordinate (xy) at (1,1); \fill [red] (xy) circle (1pt);                                           % draw a dot on the y axis (I'd like to make it smaller but I don't see how)
     \draw [dashed] (0,1) -- (2,1);
     \draw [thick,red] (1,1) circle [radius =0.03cm];                                                % draw an open red circle on the x axis above the "a"
     \coordinate (y) at (0,1); \fill [black] (y) circle (1pt);                                           % draw a dot on the y axis (I'd like to make it smaller but I don't see how)
     \draw (0,1) node[left] {1};
  \end{tikzpicture}
  \caption{$u(t-a)$}
  \label{fig:u(t-a)}
\end{figure}

\bigskip
\noindent
Another useful version of the Heaviside function, $u(a-t)$, is shown in Figure \ref{fig:u(a-t)}.

\bigskip
\begin{figure}[H]
  \centering
  \begin{tikzpicture}[scale=2.0]
     \draw [thick,->] (0,0) -- (0,2);                                                                      % draw axes
     \draw [thick,<->] (-2,0) -- (3,0);                                                                     % draw axes
     \draw (2,2) node[draw,rectangle] {                                                             % draw function to the right
         $u(a - t) =
           \begin{cases}
               0 & t > a  \\
               1  & t \leq a
           \end{cases}$
       };
     \draw (3,0) node [label=right:{$t$}] {};
     \draw (0,2) node [label=above:{$u(a - t)$}] {};
     \draw (1,0) node[below] {$a$};
     \draw [thick,red] (1,0) circle [radius =0.03cm];                                                  % draw an open red circle on the x axis above the "a"
     \draw [<-,thick,red] (-2,1) -- (1,1);
     \draw [dashed] (1,0) -- (1,1);
     \draw [->,thick,red] (1,0) -- (3,0);
     \coordinate (xy) at (1,1); \fill [red] (xy) circle (1pt);                                           % draw a dot on the y axis (I'd like to make it smaller but I don't see how)
     \coordinate (y) at (0,1); \fill [black] (y) circle (1pt);                                           % draw a dot on the y axis (I'd like to make it smaller but I don't see how)
     \draw (0,1) node[left] {1};
     \end{tikzpicture}
  \caption{$u(a - t)$}
  \label{fig:u(a-t)}
\end{figure}

\bigskip
\noindent
Now the obvious question is how do we compute $\mathcal{L}\{u(t-a)\}$? Recall that by the definition of the Laplace Transform we have

\begin{equation*}
F(s) = \int^\infty_0 e^{-st} u(t-a) dt
\end{equation*}

\bigskip
\noindent
The first thing to observe is that $u(t-a)$ is zero for $t < a$ and one otherwise (Figure \ref{fig:u(t-a)}), so we can rewrite our integral with a lower limit of $a$.

\bigskip
\begin{equation*}
\begin{array}{lllll}
F(s)
&=& \mathlarger{\int}^\infty_0 e^{-st} u(t-a) dt                        &\qquad\qquad \mathrel{\#} \text{definition of $\mathcal{L}\{u(t-a)\}$ (Section \ref{sec:laplace_transform})}                                 \\
[15pt]
&=& \mathlarger{\int}^\infty_a e^{-st} u(t-a) dt                        &\qquad\qquad \mathrel{\#} \text{we can change the lower integration limit since $u(t-a) = 0$ for $t < a$}                                    \\
[15pt]
&=& \mathlarger{\int}^\infty_a e^{-st} \cdot 1 dt                      &\qquad\qquad \mathrel{\#} \text{$u(t-a) = 1$ for $t \geq a$}                                                                                \\
[15pt]
&=& \mathlarger{\int}^\infty_a e^{-st} dt                                  &\qquad\qquad \mathrel{\#} \text{simplify}                                                                                \\
[15pt]
&=& \mathlarger{\frac{e^{-st}}{-s}} \bigg |^\infty_a                   &\qquad\qquad \mathrel{\#} \mathlarger{\int} e^{cx} dx = \frac{e^{cx}}{c} + C \text{ and the Fundamental Theorem of Calculus}  \\
[15pt]
&=& \lim\limits_{d \to \infty} \mathlarger{\frac{e^{-sd}}{-s}} - \mathlarger{\frac{e^{-sa}}{-s}}   &\qquad\qquad \mathrel{\#} \text{evaluate at limits}                                                                          \\
[15pt]
&=& 0 -  \mathlarger{\frac{e^{-sa}}{-s}}                                   &\qquad\qquad \mathrel{\#} \lim\limits_{d \to \infty} \mathlarger{\frac{e^{-sd}}{-s}} = 0                                                                      \\
[15pt]
&=& \mathlarger{\frac{e^{-sa}}{s}}                                          &\qquad\qquad \mathrel{\#} \mathcal{L}\{u(t-a)\} = \mathlarger{\frac{e^{-sa}}{s}}
\end{array}
\end{equation*}

\subsection{What about $\mathcal{L}\{u(t-a) f(t-a)\}$?}
\label{sec:lt_uf}

\bigskip
\noindent
What can we say about the Laplace Transform of $u(t-a)f(t-a)$, that is, the Heaviside function multiplied by another function? It turns out that

\bigskip
\begin{equation*}
e^{-as} F(s) = \mathcal{L}\{u(t-a) f(t-a)\}
\label{eqn:lt_uf}
\end{equation*}

\bigskip
\noindent
Ok, but why? First, notice that

\bigskip
\begin{equation*}
u(t-a)f(t-a) =
           \begin{cases}
               0        & t < a  \\
               f(t-a)  & t \geq a
           \end{cases}
\end{equation*}

\bigskip
\noindent
One way to think about this is that $u(t-a)$ "turns on" $f(t-a)$ at $a$. So consider

\begin{equation*}
\begin{array}{lllll}
F(s)
&=& \mathlarger{\int}_0^\infty e^{-s\tau} f(\tau) d\tau                                                       &\qquad \mathrel{\#} \text{definition of Laplace Transform (Section \ref{sec:laplace_transform})}    \\
[15pt]
&\Rightarrow& e^{-as} F(s) = e^{-as} \mathlarger{\int}_0^\infty e^{-s\tau} f(\tau) d\tau    &\qquad \mathrel{\#} \text{multiply both sides by $e^{-as}$}                                                              \\
[15pt]
&\Rightarrow& e^{-as} F(s) = \mathlarger{\int}_0^\infty e^{-as} e^{-s\tau} f(\tau) d\tau    &\qquad \mathrel{\#} \text{move $e^{-as}$ inside integral ($e^{-as}$ doesn't depend on $\tau$)}    \\
[15pt]
&\Rightarrow& e^{-as} F(s) = \mathlarger{\int}_0^\infty e^{-s\tau - sa} f(\tau) d\tau         &\qquad \mathrel{\#} a^n \cdot a^m = a^{(m+n)}                                                                                \\
[15pt]
&\Rightarrow& e^{-as} F(s) = \mathlarger{\int}_0^\infty e^{-s(\tau+a)} f(\tau) d\tau         &\qquad \mathrel{\#} \text{factor out $s$}                                                                                \\
[15pt]
&\Rightarrow& e^{-as} F(s) = \mathlarger{\int}_a^\infty e^{-st} f(t-a) dt                           &\qquad \mathrel{\#} \text{substitution: $t = \tau + a$ so $\tau = t - a$ and $d\tau = dt$}                   \\
[15pt]
&\Rightarrow& e^{-as} F(s) = \mathlarger{\int}_0^\infty e^{-st} u(t-a) f(t-a) dt                 &\qquad \mathrel{\#} \text{$u(t-a) = 0$ for $t < a$ so adjust lower limit to 0}                                       \\
[15pt]
&\Rightarrow& e^{-as} F(s) = \mathcal{L}\{u(t-a) f(t-a)\}                                                 &\qquad \mathrel{\#} \text{definition of Laplace Transform (Section \ref{sec:laplace_transform})}       \\
\end{array}
\end{equation*}

\bigskip
\subsection{Convolution}
\label{sec:convolution}
Next we need the definition of the convolution of two functions $f$ and $g$.

\bigskip
\begin{definition} {\bf Convolution:}
\bigskip
\begin{equation}
f(t) \ast g(t) = \int^t_0 f(\tau) g(t - \tau) d\tau
\label{eqn:convolution}
\end{equation}
\label{def:convolution}
\end{definition}

\noindent
where $\ast$ is the convolution operator. Note that the righthand side of Equation \ref{eqn:convolution} is some function of $t$ ($\tau$ is the dummy variable
for integration). That is

\bigskip
\begin{equation*}
f(t) \ast g(t) = \underbracket [0.15 ex] {\strut \int^t_0 f(\tau) g(t - \tau) d\tau}_{\text{some function of } t}
\end{equation*}

\bigskip
\noindent
Convolution has quite a few interesting properties including:

\bigskip
 \begin{itemize}
 \item Commutativity: $f \ast g = g \ast f$
 \item Associativity: $f \ast (g \ast h) = (f \ast g) \ast h$
 \item Distributivity:  $f \ast (g + h) = f \ast g + f \ast h$
\end{itemize}

\bigskip
\noindent
It is pretty easy to see why the commutative property holds:

\begin{equation*}
\begin{array}{lllll}
f(t) \ast g(t)
&=& \mathlarger{\int}^t_0 f(\tau) g(t - \tau) d\tau                  &\qquad \mathrel{\#} \text{definition of convolution (Section \ref{sec:convolution})}                                 \\
[15pt]
&=& -\mathlarger{\int}^t_0 f(t -u) g(u) du                              &\qquad \mathrel{\#} \text{use a u substitution with $u = t - \tau$ so $\tau = t -u$ and $d\tau = -du$}     \\
[15pt]
&=& - \mathlarger{\int}^0_t f(t -u) g(u) du                             &\qquad \mathrel{\#} \text{lower limit: $u = t - 0 = t$, upper limit: $u = t - t = 0$}                                     \\
[15pt]
&=& \mathlarger{\int}^t_0 f(t -u) g(u) du                               &\qquad \mathrel{\#} \text{by the Fundamental Theorem of Calculus}                                                      \\
[15pt]
&=& \mathlarger{\int}^t_0 g(u) f(t -u) du                               &\qquad \mathrel{\#} \text{multiplication is commutative}                                                                          \\
[15pt]
&=& g(t) \ast f(t)                                                                    &\qquad \mathrel{\#} \text{definition of convolution (Section \ref{sec:convolution})}
\end{array}
\end{equation*}

\newpage
\subsection{Ok, why does $\mathcal{L}\{f(t) \ast g(t)\} =  \mathcal{L}\{f(t)\}\mathcal{L}\{g(t)\}$ hold?}

\bigskip
\noindent
Now we can use the machinery we've built up to show why Equation \ref{eqn:lt_of_convolution} holds:

\begin{equation*}
\begin{array}{lllll}
\mathcal{L}\{f(t) \ast g(t)\}
&=& \mathlarger{\int}^\infty_0 e^{-st} \big [ f(t) \ast g(t) \big ] dt                                                                 &\quad \mathrel{\#} \text{definition of Laplace Transform (Definition \ref{def:laplace_transform})}            \\
[15pt]
&=& \mathlarger{\int}^\infty_0 e^{-st} \Bigg [ \mathlarger{\int}^t_0 f(t-v) g(v) dv \Bigg ] dt                         &\quad \mathrel{\#} \text{definition of convolution (Section \ref{sec:convolution})}                                     \\
[15pt]
&=& \mathlarger{\int}^\infty_0 e^{-st} \Bigg [ \mathlarger{\int}^\infty_0 f(t-v) g(v ) u(t-v) dv \Bigg ] dt        &\quad \mathrel{\#} \text{$u(t-v) = 0$ for $v > t$ so change upper limit}                                                    \\
[15pt]
&=& \mathlarger{\int}^\infty_0 \Bigg [ \mathlarger{\int}^\infty_0  e^{-st} f(t-v) g(v ) u(t-v) dv \Bigg ] dt       &\quad \mathrel{\#} \text{$e^{-st}$ doesn't depend on $v$}                                                                        \\
[15pt]
&=& \mathlarger{\int}^\infty_0 \Bigg [ \mathlarger{\int}^\infty_0  e^{-st} f(t-v) g(v ) u(t-v) dt \Bigg ] dv       &\quad \mathrel{\#} \text{swap order of integration}                                                                                \\
[15pt]
&=& \mathlarger{\int}^\infty_0 g(v) \Bigg [ \mathlarger{\int}^\infty_0  e^{-st} f(t-v) u(t-v) dt \Bigg ] dv        &\quad \mathrel{\#} \text{$g(v)$ doesn't depend on $t$}                                                                             \\
[15pt]
&=& \mathlarger{\int}^\infty_0 g(v) \: e^{-sv} \: F(s) \: dv                                                                            &\quad \mathrel{\#} \mathcal{L}\{ f(t-v) u(t-v)\} = e^{-sv} F(s) \text{ (Section \ref{sec:lt_uf})}                      \\
[15pt]
&=& F(s) \mathlarger{\int}^\infty_0 g(v) \: e^{-sv} \: dv                                                                               &\quad \mathrel{\#} \text{$F(s)$ doesn't depend on $v$}                                                                            \\
[15pt]
&=& F(s) \mathlarger{\int}^\infty_0 e^{-sv}  g(v) dv                                                                                &\quad \mathrel{\#} \text{multiplication is commutative}                                                                              \\
[15pt]
&=& F(s)\:G(s)                                                                                &\quad \mathrel{\#} G(s) = \mathlarger{\int}^\infty_0 \!\! e^{-sv}  g(v) dv \text{ (Definition \ref{def:laplace_transform})}      \\
[15pt]
&\Rightarrow& \mathcal{L}\{f(t) \ast g(t)\} = \mathcal{L}\{f(t)\}\mathcal{L}\{g(t)\}                                        &\quad \mathrel{\#} \text{the LT of a convolution is the product of LTs}                                                       \\
\end{array}
\end{equation*}

\bigskip
\bigskip
\noindent
This result also implies that $\mathcal{L}^{-1}\{F(s) G(s)\}  = f(t) \ast g(t)$. It is pretty easy to see why:

\bigskip
\begin{equation*}
\begin{array}{lllll}
\mathcal{L}\{f(t) \ast g(t)\}
&=& \mathcal{L}\{f(t)\}\mathcal{L}\{g(t)\}                                                                                &\quad \mathrel{\#} \text{above result}                                      \\
[8pt]
&\Rightarrow& \mathcal{L}^{-1}\{\mathcal{L}\{f(t) \ast g(t)\}\} =  \mathcal{L}^{-1}\{\mathcal{L}\{f(t)\}\mathcal{L}\{g(t)\}\}     &\quad \mathrel{\#} \text{take the inverse LT of both sides}       \\
[8pt]
&\Rightarrow& f(t) \ast g(t) =  \mathcal{L}^{-1}\{\mathcal{L}\{f(t)\}\mathcal{L}\{g(t)\}\}                                                          &\quad \mathrel{\#}   \mathcal{L}^{-1}\{\mathcal{L}\{f(t)\} = f(t)  \\
[8pt]
&\Rightarrow& f(t) \ast g(t) =  \mathcal{L}^{-1}\{F(s) G(s)\}                                                                                &\quad \mathrel{\#} \text{$\mathcal{L}\{f(t)\} = F(s)$ (Definition \ref{def:laplace_transform})} \\
[8pt]
&\Rightarrow& \mathcal{L}^{-1}\{F(s) G(s)\} = f(t) \ast g(t)                                                                                &\quad \mathrel{\#} \text{$=$ is symmetric}
\end{array}
\end{equation*}

\bigskip
\section*{Acknowledgements}
Thanks to Dave Neary for catching a typo: was $-f(0) + \mathcal{L}\{f(t)\}$, should be $-f(0) + s \mathcal{L}\{f(t)\} $.

\newpage
\bibliographystyle{plain}
\bibliography{/Users/dmm/papers/bib/qc}
\end{document}