\documentclass[11pt]{article}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{multicol}
\usepackage{latexsym}
\usepackage[pdftex]{graphicx}
\usepackage{url}
\usepackage{mathdots}
\usepackage{mathrsfs}
\usepackage{hyperref}
\hypersetup{colorlinks=true}
\setlength{\oddsidemargin}{.25in}
\setlength{\evensidemargin}{.25in}
\setlength{\textwidth}{6in}
\setlength{\topmargin}{-0.4in}
\setlength{\textheight}{8.5in}

\input{preamble.tex}

\begin{document}
\lecture{2: Derivatives and Integrals}{Week 2}

This is the second week of the Mathematics Subject Test GRE prep course; here, we review the concepts of \textbf{derivatives} and \textbf{integrals}!


\section{Bestiary of Functions}
For convenience's sake, we list the definitions, integrals, derivatives, and key values of several functions here.  
\begin{align*}
\begin{array}{|c|c|c|c|c|}
\hline
\textrm{Name} &  \textrm{Domain} & \textrm{Derivative} & \textrm{Integral} & \textrm{Key Values} \\
\hline
\ln(x)  & (0,\infty)  & 1/x & x\cdot\ln(x) -x + C & \ln(1) = 0,\\
 & & & & \ln(e) = 1 \\
\hline
e^x & \mathbb{R} & e^x  & e^x +C & e^0 = 1, \\
 & & & & e^1 = e \\
\hline
\sin(x) &  \mathbb{R}&  \cos(x) & -\cos(x) + C & \sin(0) = 0, \\
 & & & & \sin\left(\frac{\pi}4\right) = \frac{\sqrt{2}}{2},\\
 & & & &  \sin\left(\frac{\pi}2\right) = 1\\
\hline
\cos(x) & \mathbb{R}& -\sin(x) & \sin(x) + C & \cos(0) = 1, \\
 & & & &\cos\left(\frac{\pi}4\right) = \frac{\sqrt{2}}{2},\\
 & & & &  \cos\left(\frac{\pi}2\right) = 0\\
\hline
\tan(x) &  x \neq \frac{2k+1}{2}\pi & \sec^2(x) & \ln|\sec(x)| + C & \tan(0) = 0, \\
 & & & &\tan\left(\frac{\pi}4\right) = 1\\
\hline
\sec(x) & x \neq \frac{2k+1}{2}\pi  & \sec(x)\tan(x) & \ln|\sec(x) + \tan(x)| + C & \sec(0) = 1, \\
 & & & &\sec\left(\frac{\pi}4\right) = \sqrt{2}\\
\hline
\csc(x) &  x \neq k\pi  & -\csc(x)\cot(x) & \ln|\csc(x) - \cot(x)| + C & \csc\left(\frac{\pi}4\right) = \sqrt{2}, \\
 & & & &\sec\left(\frac{\pi}2\right) = 1\\
\hline
\cot(x) & x \neq k\pi & -\csc^2(x) & \ln|\sin(x)| + C & \cot\left(\frac{\pi}4\right) = 1, \\
 & & & &\cot\left(\frac{\pi}2\right) = 0\\
\hline
\arcsin(x) &(-1, 1) & \frac{1}{\sqrt{1-x^2}} & x\arcsin(x) +\sqrt{1-x^2} + C & \arcsin\left(0\right) = 0, \\
 & & & &\arcsin\left(1\right) = \frac{\pi}{2} \\
\hline
\arccos(x) & (-1, 1) & -\frac{1}{\sqrt{1-x^2}} & x\arccos(x) -\sqrt{1-x^2} + C & \arccos\left(0\right) = \frac\pi2, \\
 & & & &\arcsin\left(1\right) = 0 \\
\hline
\arctan(x) & \mathbb{R} & \frac{1}{1+x^2} & x\arctan(x) -\frac{\ln(1+x^2)}{2} + C & \arctan\left(0\right) = 0, \\
 & & & &\arctan\left(1\right) = \frac{\pi}{2} \\
 \hline
\end{array}
\end{align*}
Memorizing all of these is not necessary to do well on the GRE:\ as we'll discuss in class, you can derive almost all of these identities on the fly by using the product/chain rules or integration by parts/substitution!  However, doing those calculations can take time, and memorizing these formulas will save you time on the test; consider studying them in the two weeks before you test with flashcards and the like!
\newpage 

\section{The Derivative}
As always, we start with the formal definition:
\begin{defn}
For a function $f$ defined on some neighborhood $(a-\delta, a+\delta)$, we say that $f$ is \textbf{differentiable} at $a$ iff the limit
\begin{align*}
\lim_{h \to 0} \frac{f(a+h) - f(a)}{(a+h) - a}
\end{align*}
exists.  If it does, denote this limit as $f'(a)$; we will often call this value the \textbf{derivative} of $f$ at $a$.
\end{defn}
Again, as before, if you find yourself directly using this definition to solve a GRE problem, something has likely gone wrong!  Instead, you likely want to use one of several rules that we know for evaluating derivatives:
\subsection{Tools}
\begin{enumerate}
\item \textbf{Differentiation is linear}:  For $f$, $g$ a pair of functions differentiable at $a$ and $\alpha, \beta$ a pair of constants,
\begin{align*}
(\alpha f(x) + \beta g(x))'\Big|_{a} =\alpha f'(a) + \beta g'(a).
\end{align*}
\item \textbf{Product rule}:  For $f$, $g$ a pair of functions differentiable at $a$, 
\begin{align*}
(f(x) \cdot g(x))'\Big|_{a} = f'(a) \cdot  g(a) + g'(a) \cdot f(a).
\end{align*}
\item \textbf{Quotient rule}:  For $f$, $g$ a pair of functions differentiable at $a$, $g(a) \neq 0$, we have
\begin{align*}
\left(\frac{f(x)}{ g(x)}\right)'\Bigg|_{a} = \frac{f'(a) \cdot  g(a) - g'(a) \cdot f(a)}{(g(a))^2}
\end{align*}
\item \textbf{Chain rule}: For $f$ a function differentiable at $g(a)$ and $g$ a function differentiable at $a$, 
\begin{align*}
(f(g(x)))'\Big|_{a} = f'(g(a)) \cdot g'(a).
\end{align*}
\item \textbf{Inverse function rule}:  Suppose that $f(x)$ is a bijective function with inverse $f^{-1}(x)$, and that $f^{-1}(x)$ is differentiable at some point $a$.  Then we have that
\begin{align*}
\left(f^{-1}(x)\right)\Big|_a = \frac{1}{f'(f^{-1}(a))}
\end{align*}
\end{enumerate}

\subsection{Theorems and Interpretations}


The derivative has a number of useful interpretations and associated theorems.  We state a few here:
\begin{enumerate}
\item \textbf{Physical phenomena}:  if $f(x)$ is a function that calculates distance with respect to some time $t$, you can think of the derivative $f'(t)$ as denoting the velocity of $f$ at time $t$, and $f''(t)$ as denoting the acceleration of $f$ at time $t$.  
\item \textbf{Tangents}:  if $f(x) = y$ is a curve, the slope of the tangent to this curve at any point $x_0$ is given by $f'(x_0)$.
\begin{center}
\includegraphics[width=3in]{tangent.pdf}
\end{center}
\item \textbf{Mean Value Theorem}:  The Mean Value Theorem (abbreviated MVT) is the following result.   Suppose that $f$ is a continuous function on the interval $[a,b]$ that's differentiable on $(a,b)$.  Then there is some value $c$ such that 
\begin{align*}
f'(c) = \frac{f(b) - f(a)}{b-a}.
\end{align*}
In other words, there is some point $c$ between $f(a)$ and $f(b)$ such that the derivative at that point is equal to the slope of the line segment connecting $(a,f(a))$ and $(b,f(b))$.  The following picture illustrates this claim:
\begin{center}
\includegraphics[width=4.5in]{math8_wk6_mvt.pdf}
\end{center}
\item \textbf{Classification of extrema}: You can use the derivative to find minima and maxima of functions!  Specifically, recall the following two definitions:
\begin{defn}
A function $f$ has a \textbf{critical point} at some point $x$ if either of the two properties hold:
\begin{itemize}
\item $f$ is not differentiable, or
\item $f'(x) = 0$.
\end{itemize} 
\end{defn}
\begin{defn}
A function $f$ has a \textbf{local maxima}(resp. \textbf{local minima}) at some point $a$ iff there is a neighborhood $(a-\delta, a+\delta)$ around $a$ such that $f(a) \geq f(x)$ (resp. $f(a) \leq f(x)$,) for any $x \in (a-\delta, a+\delta)$.
\end{defn}
Derivatives relate to these properties as follows:
\begin{prop}
If $f$ is a function that has a local minima or maxima at some point $t$, $t$ is a critical point of $f$.  As a corollary, if $f$ is a continuous function defined on some interval $[a,b]$, $f$ adopts its global minima and maxima at either $f$'s critical points in $[a,b]$, or at the endpoints $\{a,b\}$ themselves.  

Furthermore, if $f''(x)$ is defined and positive at one of these critical points, $f$ adopts a local minima at $x$; conversely, if $f''(x)$ exists and is negative, $f$ adopts a local maxima at $x$. 
\end{prop}
\end{enumerate}


To illustrate these ideas, we work some sample problems:

\subsection{Worked examples.}


\begin{quest}
Choose $n \in \mathbb{N}$.  Where does the function
\begin{align*}
f(x) = x^n - xn^n
\end{align*}
take its local and global minima and maxima in the interval $[-2n,2n]$?
\end{quest}
\begin{proof}
First, note that if $n = 1$ our function is identically 0, and thus its local and global minima and maxima are uninteresting.  We will focus on $n > 1$ for the rest of the proof.

By the above proposition, we know that $f$ will take on these minima and maxima at its critical points and endpoints.  Because $f$ is differentiable everywhere, $f$'s only critical points come at places where $f'(x) = 0$.  We examine these points here:
\begin{align*}
f'(x) &= nx^{n-1} - n^n = 0\\
\Leftrightarrow     nx^{n-1} &= n^n \\
\Leftrightarrow    ~  x^{n-1} &= n^{n-1}. \\
\end{align*}
There are two cases, here: if $n$ is odd, its critical points occur at $\pm n$; if $n$ is even, however, its only critical point is at $n$.  In either situation, we have that $f''(x) = n(n-1)x^{n-2}$; thus, we have that $x=n$ is a local minima regardless of whether $n$ is odd or even, while $x=-n$ is a local maxima for $n$ odd.

This accomplished, we can then evaluate our function at these points along with the endpoints, and use this to find its global maxima and minima:

For $n$ odd:
\begin{align*}
f(-2n) &= (-2n)^n - (-2n)\cdot n^n = n^n\left(2n - 2^n\right),\\
f(-n) &= (-n)^n - (-n)\cdot n^n = n^n\left(n-1\right),\\
f(n) &= (n)^n - (n)\cdot n^n = n^n\left(1-n\right),\\
f(2n) &= (2n)^n - (2n)\cdot n^n = n^n\left(2^n-2n\right),\\
\end{align*}
So: if $n > 2$, we know that $2^n > 2n$; consequently, we have that $f(-2n)$ is the global minima and $f(2n)$ is the global maxima.  Because every odd number other than 1 is $>2$, we've thus resolved our question of $n$ odd.

For $n$ even:
\begin{align*}
f(-2n) &= (-2n)^n - (-2n)\cdot n^n = n^n\left(2n + 2^n\right),\\
f(n) &= (n)^n - (n)\cdot n^n = n^n\left(1-n\right),\\
f(2n) &= (2n)^n - (2n)\cdot n^n = n^n\left(2^n-2n\right).\\
\end{align*}
For any even value of $n$, this function has its global maxima at $f(-2n)$ and its global minima at $f(n)$.  Thus, we've classified $f$'s local and global minima and maxima for any value of $n$: so we're done!
\end{proof}


\begin{quest}
Let $p(t)$ denote the current location of a particle moving in a one-dimensional space.  Call this particle ``nice'' if $p(0) = 0, p(1) = 1$, $p'(0) = p'(1) = 0$, and $p(t)$ is continuous.

What is
\begin{align*}
\inf_{\textrm{``nice'' particles}} \left( \sup_{t \in [0,1]} |p''(t)|\right) ?
\end{align*}
\end{quest}

\begin{proof}
To start studying the above claim, let's assume that there is \textbf{some} answer $M$: in other words, there is some $M$ such that 
\begin{enumerate}
\item $M \geq |p''(t)|$, for any nice particle $p$ and any $t \in [0,1]$.
\item $M$ is the smallest such number that the above claim holds for.
\end{enumerate}

What can we do from here?  Well: we have some boundary conditions (niceness tell us that $p(0) = 0, p(1) = 1, p'(0) = 0, p'(1) = 0$) and one global piece of information ($|p''(t)| < M$).  How can we turn this knowledge of the second derivative into information about rest of the function?

Well: if we apply the mean value theorem to the function $p''(t)$, what does it say?  It tells us that on any interval $[a,b]$, there is some $c \in (a,b)$ such that 
\begin{align*}
\frac{p'(b) - p'(a)}{b-a} = (p')'(x) = p''(c).
\end{align*}
In other words, it relates the first and second derivatives to each other!  So, if we apply our known bound $|p''(t)| < M, \forall t \in [0,1]$, we've just shown that
\begin{align*}
\left| \frac{p'(b) - p'(a)}{b-a} \right| = |p''(c)| < M,
\end{align*}
for any $a<b \in [0,1]$.  In particular, if we set $a = 0, b = t$ and remember our boundary condition $p'(0) = 0$, we've proven that
\begin{align*}
&\left| \frac{p'(t) - p'(0)}{t-0} \right| = \left| \frac{p'(t) - 0}{t} \right| = \frac{|p'(t)|}{t} < M\\
\Rightarrow & |p'(t)| < Mt.\\
\end{align*}
Similarly, if we let $a = 1-t$ and $b = 1$, we get
\begin{align*}
&\left| \frac{p'(1) - p'(1-t)}{1 - (1-t)} \right| = \left| \frac{0 - p'(1-t)}{t} \right| =\frac{|p'(1-t)|}{t} < M\\
\Rightarrow & |p'(1-t)| < Mt.\\
\end{align*}

Excellent!  We've turned information about the second derivative into information about the first derivative.  

Pretend, for the moment, that you're back in your high school calculus courses, and you know how to find antiderivatives.  In this situation, you've got a function $p(t)$ with the following properties:
\begin{itemize}
\item $p(0) = 0$,
\item $p(1) = 1$,
\item $|p'(t)| < Mt$, and
\item $|p'(1-t)| < Mt$.
\end{itemize}
What do you know about $p(t)$?  Well: if $p'(t) < Mt,$ you can integrate to get that $p(t) < \frac{M}{2}t^2 + C$, for some constant $C$: using our boundary condition $p(0) = 0$ tells us that in specific we can pick $C = 0$, and we have 
\begin{align*}
p(t) < \frac{M}{2}t^2, \forall t \in(0,1).
\end{align*}
Similarly, if we use our observation that $p'(1-t) < Mt$, we can integrate to get that the integral of the LHS, $\int p(1-t)dt = -p(1-t)$, is bounded above by the integral of the RHS, which is $\frac{M}{2}t^2 + C$.  Using our boundary condition $p(1) = 1$ and multiplying both sides by $-1$ tells us that we can pick $C = 1$ and get
\begin{align*}
p(1-t) > -\frac{M}{2}t^2 + 1, \forall t \in(0,1).
\end{align*}
But what happens if we plug in $t = \frac{1}{2}$? In our first bound, we have $p\left( \frac{1}{2} \right) <  \frac{M}{2}\left(\frac{1}{2}\right)^2  = \frac{M}{8}$. Conversely, in our second bound we have $p\left(1 - \frac{1}{2} \right) >  -\frac{M}{2}\left(\frac{1}{2}\right)^2 + 1  = 1 - \frac{M}{8}$.

In other words, we have $\frac{M}{8} < p(1/2) <  1 - \frac{M}{8}$, which forces $M \leq 4$.   So we know an upper bound on our answer!

Moreover, it is an attainable bound, whose answer is suggested by our work here: if we actually set $M = 4$, we get the piecewise function
\begin{align*}
p(t) = \left\{ \begin{array}{cc} 2t^2, & t \in (-\infty, 1/2] \\ 1-2(1-t)^2, & t \in [1/2, \infty)\\ \end{array} \right.
\end{align*}
This function is continuous, as it is piecewise made up of polynomials (which are continuous) and at their join we have $2(1/2)^2 = 1/2 = 1-2(1-1/2)^2 = 1/2$.  As well, $p(0) = 0, p(1) = 1$, and the derivative of $p(t)$ is just
\begin{align*}
p(t) = \left\{ \begin{array}{cc} 4t, & t \in (-\infty, 1/2) \\ 4(1-t), & t \in (1/2, \infty)\\ \end{array} \right.,
\end{align*}
which has $p'(0) = 0 = p'(1) = 0$.
\end{proof}

\section{Integration}
As before, we start by defining our terms:
\begin{defn}
\textbf{The integral}: A function $f$ is \textbf{integrable}\footnote{To be specific, Riemann-integrable.} on the interval $[a,b]$ if and only if the following holds:
\begin{itemize}
\item For any $\epsilon > 0$, 
\item there is a partition $a=t_0 < t_1 < \ldots < t_{n-1}<t_n=b$ of the interval $[a,b]$ such that
\begin{align*}
\left(\sum^n_{i=1} \sup_{x\in(t_{i-1},t_i)}(f(x)) \cdot \textrm{length}(t_{i-1},  t_{i}) - \sum^n_{i=1} \inf_{x\in(t_{i-1},t_i)}(f(x)) \cdot \textrm{length}(t_{i-1}, t_{i}) \right)< \epsilon.
\end{align*}
\end{itemize}
Pictorially, this is just saying that the area of the teal rectangles approaches the area of the purple rectangles in the picture below:
\begin{center}
\includegraphics[width=4in]{integral_riemann.pdf}
\end{center}
Because of this picture, we often say that the integral of a function on some interval $[a,b]$ is the \textbf{area} beneath its curve from $x=a$ to $x=b$.
\end{defn}

Again, using this theorem directly is usually not the best idea.  Instead, we have a number of tools and theorems that are helpful for calculating integrals:

\subsection{Theorems and Tools}
\begin{enumerate}
\item \textbf{The first fundamental theorem of calculus}:  Let $[a,b]$ be some interval.  Suppose that $f$ is a bounded and integrable function over the interval $[a,x],$ for any $x \in [a,b].$ Then the function
\begin{align*}
A(x) := \int_a^x f(t)dt
\end{align*}
exists for all $x \in [a,b]$.  Furthermore, if $f(x)$ is continuous, the derivative of this function, $A'(x)$, is equal to $f(x)$.
\item \textbf{The second fundamental theorem of calculus}: Let $[a,b]$ be some interval.  Suppose that $f(x)$ is a function that has $\varphi(x)$ as its primitive on $[a,b]$; as well, suppose that $f(x)$ is bounded and integrable on $[a,b]$. Then, we have that
\begin{align*}
\int_a^b f(x)dx = \varphi(b) - \varphi(a).
\end{align*}
\item \textbf{Integration by parts}:  If $f,g$ are a pair of $C^1$ functions on $[a,b]$ -- i.e they have continuous derivatives on $[a,b]$ -- then we have
\begin{align*}
\int_a^b f(x)g'(x) = f(x)g(x)\Big|_a^b = \int_a^b f'(x)g(x)dx.
\end{align*}
\item \textbf{Integration by substitution}:  If $f$ is a continuous function on $g([a,b])$ and $g$ is a $C^1$ functions on $[a,b]$, then we have
\begin{align*}
\int_a^b f(g(x))g'(x)dx = \int_{g(a)}^{g(b)} f(x)dx.
\end{align*}
\end{enumerate}


We work some example integrals here:

\subsection{Worked Examples}


\begin{quest}
What's
\begin{align*}
\int_1^2 x^2e^x dx ~?
\end{align*}
\end{quest}
\begin{proof}
Looking at this problem, it doesn't seem like a substitution will be terribly useful: so, let's try to use integration by parts!

How do these kinds of proofs work?  Well: what we want to do is look at the quantity we're integrating (in this case, $x^2e^x$,) and try to divide it into two parts -- a ``$f(x)$''-part and a ``$g'(x)$'' part -- such that when we apply the relation $\int f(x)g'(x) = f(x)g(x) - \int g(x)f'(x)$, our expression gets simpler!

To ensure that our expression does in fact get simpler, we want to select our $f(x)$ and $g'(x)$ such that 
\begin{enumerate}
\item we can calculate the derivative $f'(x)$ of $f(x)$ and find a primitive $g(x)$ of $g'(x)$, so that either
\item the derivative $f'(x)$ of $f(x)$  is \textbf{simpler} than the expression $f(x)$, or
\item the integral  $g(x)$ of $g'(x)$ is \textbf{simpler} than the expression $g'(x)$.
\end{enumerate}
So: often, this means that you'll want to put quantities like polynomials or $\ln(x)$'s in the $f(x)$ spot, because taking derivatives of these things generally simplifies them.  Conversely, things like $e^x$'s or trig functions whose integrals you know are good choices for the integral spot, as they'll not get much more complex and their derivatives are generally no simpler.

Specifically: what should we choose here?  Well, the integral of $e^x$ is a particularly easy thing to calculate, as it's just $e^x$.  As well, $x^2$ becomes much simpler after repeated derivation: consequently, we want to make the choices
\begin{align*}
\begin{array}{ll}
f(x) = x^2  & g'(x) = e^x \\
f'(x) =2x & ~g(x) = e^x, \\
\end{array}
\end{align*}
which then gives us that
\begin{align*}
\int_1^2 x^2e^x dx & = f(x)g(x) \Big|^2_1 - \int_1^2 f'(x)g(x)dx \\
& = x^2e^x  \Big|^2_1- \int_1^2 2x e^x dx .\\
\end{align*}

Another integral!  Motivated by the same reasons as before, we attack this integral with integration by parts as well, setting
\begin{align*}
\begin{array}{ll}
f(x) = 2x  & g'(x) = e^x \\
f'(x) =2 & ~g(x) = e^x. \\
\end{array}
\end{align*}
This then tells us that
\begin{align*}
\int_1^2 x^2e^x dx &= x^2e^x  \Big|^2_1- \int_1^2 2x e^x dx \\
&= x^2e^x  \Big|^2_1-  \left(  f(x)g(x) \Big|^2_1 - \int_1^2 f'(x)g(x)dx\right)\\
&= x^2e^x  \Big|^2_1-  \left(  2xe^x \Big|^2_1 - \int_1^22e^xdx\right)\\
&= x^2e^x  \Big|^2_1-  \left(  2xe^x \Big|^2_1 - 2e^x\Big|^2_1  \right)\\
& = 4e^2 - e^1 - \left( 4e^2 - 2e^1 - 2e^2 + 2e^1\right)\\
& = 2e^2 - e^1.\\
\end{align*}
So we're done!
\end{proof}


\begin{quest}
What is
\begin{align*}
\int_0^2 x^2\sin(x^3)dx ~~?
\end{align*}
\end{quest}
\begin{proof}
How do we calculate such an integral?  Direct methods seem unpromising, and using trig identities seems completely insane.  What happens if we try substitution?  

Well: our first question is the following: \textbf{what should we pick?}  This is the only ``hard'' part about integration by substitution -- making the right choice on what to substitute in.  In most cases, what you want to do is to find the part of the integral that you don't know how to deal with -- i.e. some sort of ``obstruction.''  Then, try to make a substitution that (1) will remove that obstruction, usually such that (2) the derivative of this substitution is somewhere in your formula. 


Here, for example, the term $\sin(x^3)$ is definitely an ``obstruction'' -- we haven't developed any techniques for how to directly integrate such things.  So, we make a substitution to make this simpler!  In specific:  Let $g(x) = x^3$.  This turns our term $\sin(x^3)$ into a $\sin(g(x))$, which is much easier to deal with  Also, the derivative $g'(x) = 3x^2 dx$ is (up to a constant) being multiplied by our original formula -- so this substitution seems quite promising.  In fact, if we calculate and use our indicated substitution, we have that
\begin{align*}
\int_0^2 x^2\sin(x^3)dx  &= \int_0^2 \sin(g(x)) \cdot \frac{1}{3}\cdot  g'(x)dx \\
&= \int_{0^3}^{2^3} \sin(x) dx \\
&= \frac{\sin(8)}{3} - \frac{\sin(0)}{3} \\
&= \frac{\sin(8)}{3}.\\
\end{align*}
(Note that when we made our substitution, we also changed the bounds from $[a,b]$ to $[g(a), g(b)]$!  Please, please, always change your bounds when you make a substitution!)
\end{proof}



\subsection{Trigonometric Substitutions}


Usually, when people use integration by substitution, they use it to \textbf{take functions out} rather than to put functions in.  I.e. people usually start with integrals of the form
\begin{align*}
\int_a^b f(g(x))g'(x)dx, 
\end{align*}
and turn them into integrals of the form
\begin{align*}
\int_{g(a)}^{g(b)} f(x)dx.
\end{align*}

However: this is not the only way to use integration by substitution!  Specifically, it is possible to use integration by substitution to \textbf{put a g(x) into an integral}, as well!  In other words, if we have an integral of the form
\begin{align*}
\int_{a}^{b} f(x)dx,
\end{align*}
we can use integration by substitution to turn it into an integral of the form 
\begin{align*}
\int_{g^{-1}(a)}^{g^{-1}(b)} f(g(x))g'(x)dx,
\end{align*}
as long as we make sure that g is continuous on this new interval $[g^{-1}(a), g^{-1}(b)]$.

Why would you want to do this?  Well: suppose you're working with a function of the form 
\begin{align*}
\frac{1}{a^2+x^2}.
\end{align*}
Substituting $x = a\tan(\theta)$ then turns this expression into
\begin{align*}
\frac{1}{a^2+a^2 \tan^2(\theta)} = \frac{1}{a^2 \left( 1 + \frac{sin^2(\theta)}{\cos^2(\theta)}\right)} = \frac{\cos^2(theta)}{a^2\left( \cos^2(\theta) + \sin^2(\theta) \right)} = \frac{1}{a^2}\cos^2(\theta),
\end{align*}
which is much simpler.
As well: if you have a function of the form
\begin{align*}
\sqrt{a^2 - x^2},
\end{align*}
the substitution $x = a\sin(\theta)$ turns this into
\begin{align*}
\sqrt{a^2 - a^2\sin^2(\theta)} = |a| \cdot \sqrt{1 - \sin^2(\theta)} = |a| \cdot \sqrt{\cos^2(\theta)} = |a \cos(\theta)|,
\end{align*}
which is again a simpler and easier thing to work with!  These substitutions come up frequently enough that we refer to them as the \textbf{trigonometric substitutions}; they're pretty useful for dealing with many kinds of integrals.

We illustrate their use in the following example:
\begin{quest}
What is
\begin{align*}
\int_0^1 \left(x^2 + 1\right)^{-3/2} ~~?
\end{align*}
\end{quest}
\begin{proof}

Looking at this, we see that we have a $\frac{1}{1+x^2}$ term, surrounded by some other bits and pieces.  So: let's try the tangent substitution we talked about earlier!  Specifically:  let

\begin{align*}
\begin{array}{ll}
f(x) = \left(x^2 + 1\right)^{-3/2},   & g(x) = \tan(x), \\
 & g'(x) = \frac{1}{\cos^2(x)}. \\
\end{array}
\end{align*}
Then, we have that
\begin{align*}
\int_0^1 \left(x^2 + 1\right)^{-3/2}dx  &= \int_0^1 f(x)dx \\
&=  \int_{g^{-1}(0)}^{g^{-1}(1)}  f(g(x)) g'(x)dx\\
&=  \int_{\tan^{-1}(0)}^{\tan^{-1}(1)}  \cos^3(x) \cdot\frac{1}{\cos^2(x)}  dx\\
&=  \int_{0}^{\pi/4}  \cos(x) dx\\
&=   \sin(x) \Big|_{0}^{\pi/4} dx\\
&= \frac{\sqrt{2}}{2}.\\
\end{align*}
\end{proof}



\begin{quest}
Evaluate the improper integral
\begin{align*}
\int_2^\infty \frac{1}{x\sqrt{x^2-1}} dx.
\end{align*}
\end{quest}
\begin{proof}
 Try the u-substitution $u = \sqrt{x^2 -1} \Rightarrow x = \sqrt{u^2 + 1}$.  If you do this, you get that $du = \frac{x}{\sqrt{x^2 - 1}} dx \Rightarrow \frac{u}{\sqrt{u^2 + 1}} du = dx$, and therefore that our original integral is
\begin{align*}
\int_{\sqrt{2^2-1}}^{\lim_{a \to \infty} \sqrt{a^2 - 1}} \frac{1}{u\sqrt{u^2+1}} \cdot \frac{u}{\sqrt{u^2 + 1}} du = \int_{\sqrt{3}}^\infty \frac{1}{u^2 + 1} du.
\end{align*}

Now, you should try a trig substitution!  In particular, try $u = \tan(t), t = \arctan(u), du = \frac{1}{\cos^2(t)} dt$:
\begin{align*}
\int_{\sqrt{3}}^\infty \frac{1}{u^2 + 1} du &= \int_{\arctan(\sqrt{3})}^{\lim_{a \to \infty} \arctan(a)} \frac{1}{1 +\tan^2(u)}\cdot \frac{1}{\cos^2(u)} du\\
&= \int_{\arctan(\sqrt{3})}^{\lim_{a \to \infty} \arctan(a)} 1du\\
&= \left( \lim_{a \to \infty} \arctan(a) \right) - \arctan(\sqrt{3}).
\end{align*}
We know that tangent approaches positive-infinity on $(-\pi/2, \pi/2)$ as its argument approaches $\pi/2$: therefore, the limit as arctangent approaches $+\infty$ is just $\pi/2$.  Similarly, we know that tangent is equal to $\sqrt{3}$ when its argument is equal to $\pi/3$; therefore, $\arctan(\sqrt{3})$ is $\pi/3$.  Therefore, our integral is just is $\pi/6$. 
\end{proof}


\begin{quest}
Calculate the following two integrals:
\begin{align*}
\int_0^1 \ln(1+x^2)dx, \quad \int_2^3 \frac{1}{\sqrt{x+1} + \sqrt{x-1}}dx.
\end{align*}
\end{quest}
\begin{proof}
We begin by studying $\int_0^1 \ln(1+x^2)dx$.  Because no substitution looks very promising (as the $1+x^2$ term messes things up,) we are motivated to try integration by parts.  In particular, we can remember the trick we used when integrating $\ln(x)$, and set
\begin{align*}
\begin{array}{ll}
u = \ln(1+x^2)  & dv= dx \\
du =\frac{2x}{1+x^2} & v = x, \\
\end{array}
\end{align*}
which gives us
\begin{align*}
\int_0^1 \ln(1+x^2)dx &= \ln(1+x^2) \cdot x \Big|_0^1 - \int_0^1 \frac{2x^2}{1+x^2} dx \\ 
\end{align*}
A bit of algebra allows us to notice that
\begin{align*}
\ln(1+x^2) \cdot x \Big|_0^1 - 2\int_0^1 \frac{x^2}{1+x^2} dx &= \ln(1+x^2) \cdot x \Big|_0^1 - 2\left(\int_0^1 1 - \frac{1}{1+x^2} dx\right)\\
& =  \ln(1+x^2) \cdot x \Big|_0^1 - 2x\Big|_0^1  + 2\int_0^1 \frac{1}{1+x^2} dx.
\end{align*}
Now, we remember our inverse trig identities, and specifically remember that $\int \frac{1}{1+x^2}  dx= \arctan(x)$; combining, we have
\begin{align*}
\int_0^1 \ln(1+x^2)dx &= \ln(1+x^2) \cdot x \Big|_0^1 - 2x \Big|_0^1 + 2\arctan(x) \Big|_0^1 \\&= \ln(2) - 2 + \frac{\pi}{2}.\\
\end{align*}



We now look at $ \int_2^3 \frac{1}{\sqrt{x+1} + \sqrt{x-1}}dx.$  Before we can do anything, we have to do some algebra to clean up this function.  Specifically, to simplify this expression, we multiply top and bottom by $\sqrt{x+1} - \sqrt{x-1}$, a common algebraic technique used on square-root-involving expressions to clean things up:
\begin{align*}
\int_2^3 \frac{1}{\sqrt{x+1} + \sqrt{x-1}}dx &= \int_2^3 \frac{1}{\sqrt{x+1} + \sqrt{x-1}} \cdot \frac{\sqrt{x+1} - \sqrt{x-1}}{\sqrt{x+1} - \sqrt{x-1}}dx \\
&= \int_2^3 \frac{\sqrt{x+1} - \sqrt{x-1}}{(\sqrt{x+1})^2 - (\sqrt{x-1})^2}dx \\
&= \int_2^3 \frac{\sqrt{x+1} - \sqrt{x-1}}{x+1 - x + 1}dx \\
&= \frac{1}{2}\int_2^3 \sqrt{x+1} - \sqrt{x-1}dx \\
&= \frac{1}{2}\int_2^3 \sqrt{x+1}dx  -  \frac{1}{2}\int_2^3 \sqrt{x-1}dx. \\
\end{align*}
We now perform a pair of translation-substitutions, setting u = x+1 in the first integral and u = x-1 in the second integral:
\begin{align*}
&= \frac{1}{2}\int_3^4 \sqrt{u}du  -  \frac{1}{2}\int_1^2 \sqrt{u}du. \\
&= \frac{1}{2}\left( \frac{2u^{3/2}}{3} \right) \Big|_3^4  -  \frac{1}{2} \left( \frac{2u^{3/2}}{3} \right) \Big|_1^2\\
&= \frac{\sqrt{64} - \sqrt{27} - \sqrt{8} + 1}{3}.\\
\end{align*}

\end{proof}



\subsection{Undoing Trigonometric Substitutions}

So: often, when we're integrating things, we often come up across expressions like
\begin{align*}
\int_0^\pi \frac{1}{1+\sin(\theta)}d\theta, \textrm{ or } \int_{-\pi/4}^{\pi/4} \frac{1}{\cos(\theta)}d\theta,
\end{align*}
where there's no immediately obvious way to set up the integral.  Sometimes, we can be particuarly clever, and notice some algebraic trick: for example, to integrate $\frac{1}{\cos(\theta)}$, we can use partial fractions to see that
\begin{align*}
\frac{1}{\cos(\theta)} & = \frac{\cos(\theta)}{\cos^2(\theta)} \\
 & =  \frac{\cos(\theta)}{1 - \sin^2(\theta)} \\
& = \frac{1}{2}\left(  \frac{\cos(\theta)}{1 - \sin(\theta)} +  \frac{\cos(\theta)}{1 + \sin(\theta)}\right), \\
\end{align*}
and then integrate each of these two fractions separately with the substitutions $u = 1 \pm \sin(\theta)$.

Relying on being clever all the time, however, is not a terribly good strategy.  It would be nice if we could come up with some way of methodically studying such integrals above -- specifically, of working with integrals that feature a lot of trigonometric identities!  Is there a way to do this?

As it turns out: yes!  Specifically, consider the use of the following function as a substitution:
\begin{align*}
g(x) = 2\arctan(x),
\end{align*}
where $\arctan(x)$ is the inverse function to $\tan(x)$, and is a function $\mathbb{R} \to (-\pi/2, \pi/2)$.  In class, we showed that such inverse functions of differentiable functions are differentiable themselves: consequently, we can use the chain rule and the definition of the inverse to see that
\begin{align*}
&(\tan(\arctan(x))' = (x)' = 1, \textrm{ and } \\
&(\tan(\arctan(x))' = \tan'(\arctan(x)) \cdot (\arctan(x))' = \frac{1}{\cos^2(\arctan(x))} \cdot (\arctan(x))'\\
\Rightarrow &  \frac{1}{\cos^2(\arctan(x))} \cdot (\arctan(x))' = 1\\
\Rightarrow &   (\arctan(x))' = \cos^2(\arctan(x)).\\
\end{align*}


Then, if we remember how the trigonometric functions were defined, we can see that (via the below triangles)
\begin{center}
\includegraphics[width=3in]{math8_wk8_triangles.pdf}
\end{center}
we have that
\begin{align*}
  (\arctan(x))' = \cos^2(\arctan(x)) = \frac{1}{1+x^2}
\end{align*}
and thus that
\begin{align*}
g'(x) = \frac{2}{1+x^2}.
\end{align*}

As well: by using the above triangles, notice that
\begin{align*}
\sin(g(x)) &= \sin(2\arctan(x)) \\
&= 2\sin(\arctan(x))\cos(\arctan(x) \\
& = 2\cdot\frac{1}{\sqrt{1+x^2}}\cdot \frac{x}{\sqrt{1+x^2}} \\
&= \frac{2x}{1+x^2}, \\
\end{align*}
and
\begin{align*}
\cos(g(x)) &= \cos(2\arctan(x)) \\
&= 2\cos^2(\arctan(x)) - 1 \\
& = \frac{2}{1+x^2} - 1 \\
&= \frac{1 -x^2}{1+x^2}.\\
\end{align*}

Finally, note that trivially we have that
\begin{align*}
g^{-1}(x) = \tan(x/2),
\end{align*}
by definition.


What does this all mean?  Well: suppose we have some function $f(x)$ where all of its terms are trig functions -- i.e. $f(x) = \frac{1}{1+\sin(x)}$, or $f(x) = \frac{1}{\cos(x)}$ -- and we make the substiution
\begin{align*}
\int_a^b f(x) = \int_{g^{-1}(a)}^{g^{-1}(b)} f(g(x))g'(x), \quad \textrm{for }g(x) = 2\arctan(x).
\end{align*}
What do we know about the integral on the right?  Well: as we've just shown above, the substitution of $g(x)$ turns all of the $\sin(x)$'s into $\sin(g(x))$'s, which are just reciprocals of polynomials; similarly, we've turned all of the $\cos(x)$'s into $\cos(g(x))$'s, which are also made of polynomials.  In other words, this substitution turns a function that's made entirely out of trig functions into one that's made \textbf{only out of polynomials!} -- i.e. it turns trig functions into quadratic polynomials!  This is excellent for us, because (as you may have noticed) it's often \textit{far} easier to integrate polynomials than trig functions.

This substitution is probably one of those things that's perhaps clearer in its use than its explanation.  We provide an example here:

\begin{exmp}
Find the integral 
\begin{align*}
\int_0^{\pi/2} \frac{1}{1+\sin(\theta)}d\theta.
\end{align*}
\end{exmp}
\begin{proof}
So: without thinking, let's just try our substitution $\theta = g(x), $ where $g(x) = 2\arctan(x)$:
\begin{align*}
\int_0^{\pi/2} \frac{1}{1+\sin(\theta)}d\theta &=  \int_{g^{-1}(0)}^{g^{-1}(\pi/2)} f(g(x))g'(x)dx\\
&= \int_{\tan(0)}^{\tan(\pi/4)}\frac{1}{1 + \frac{2x}{1+x^2}}\cdot \frac{2}{1+x^2}dx \\
&= \int_{0}^{1}\frac{2}{1 +x^2+ 2x}dx \\
&= \int_{0}^{1}\frac{2}{(1+x)^2}dx \\
&= \int_{1}^{2}\frac{2}{x^2}dx \\
&= -\frac{2}{x} \Bigg|_{1}^{2} \\
& = 1/2.
\end{align*}
\ldots so it works!  Without any effort, we were able to just mechanically calculate an integral that otherwise looked quite impossible.  Neat!
\end{proof}




\end{document}