% This is lecture no. 9 of MH1101/: Calculus II.

\chapter{Substitution \& Integration by Parts}%
\label{cha:substitution_&_integration_by_parts}

\section{The Substitution Rule}%
\label{sec:the_substitution_rule}

\begin{mdframed}
	The \textbf{Substitution Rule} is a consequence of the \textbf{Chain Rule}:
	\[
		\int f(u(x))\underbrace{u^{\prime}(x)\ud x}_{\ud u} = \int f(u)\ud u
	.\]
	The idea behind the \textbf{substitution rule} is to replace a relatively complicated integral by a simpler integral.
\end{mdframed}
\begin{exmp}
	Evaluate the following integral:
	\[
		\int x^{4}\sin\left(x^{5}\right)\ud x
	.\]
	\begin{sol}
		Choose $u$ to be some integrand whose derivative also occurs:
		\begin{align*}
			\int x^{4}\sin\left(x^{5}\right)\ud x & = \frac{1}{5}\int \sin\left(x^{5}\right)\cdot 5x^{4}\ud x\\
		\intertext{Substitute $u(x)=x^{5}$, $u^{\prime}(x)=5x^{4}$:}
						   & = \frac{1}{5}\int \underbrace{\sin\left(x^{5}\right)}_{\sin(u)}\cdot \underbrace{5x^{4}\ud x}_{u^{\prime}(x)\ud u}\\
						   & = \frac{1}{5}\int \sin(u)\ud u\\
						   & = \frac{1}{5}((-\cos(u))+C)\\
						   & = -\frac{1}{5}\cos(x^{5})+C.
		\end{align*}
	\end{sol}
\end{exmp}
\begin{exmp}
	Evaluate the following integral:
	\[
	\int \frac{x}{x^2+1}\ud x
	.\]
	\begin{sol}
		Note that:
		\[
			\frac{\ud}{\ud x}\left(x^2+1\right) = 2x
		.\]
		Let $u=x^2+1$, $u^{\prime}=2x$:
		\begin{align*}
			\int \frac{x}{x^2+1}\ud x & = \frac{1}{2}\int \frac{1}{x^2+1}(2x)\ud x\\
						  & = \frac{1}{2}\int \frac{1}{u}\ud u\\
						  & = \frac{1}{2}\ln |u| + C\\
						  & = \frac{1}{2}\ln\left(x^2+1\right)+C\\
						  & = \ln\sqrt{x^2+1}+C.
		\end{align*}
	\end{sol}
\end{exmp}
\begin{mdframed}
	When using the \textbf{substitution rule} for definite integrals, change the upper and lower limits of the definite integral together with the substitution $u$:
	\[
		\int_{a}^{b} f(u(x))u^{\prime}(x) \ud x = \int_{u(a)}^{u(b)} f(u) \ud u
	.\]
\end{mdframed}
\begin{exmp}
	Evaluate the following definite integral:
	\[
		\int_{0}^{8} \frac{\cos\sqrt{x+1}}{\sqrt{x+1}} \ud x
	.\]
	\begin{sol}
		Choose $u=\sqrt{x+1}$, ${\displaystyle \frac{\ud u}{\ud x}=\frac{1}{2\sqrt{x+1}}}$, then:
		\[
		x=0\implies u=1,
		\qquad
		x=8\implies u=3
		.\]
		Thus we have:
		\begin{align*}
			\int_{0}^{8} \frac{\cos\sqrt{x+1}}{\sqrt{x+1}} \ud x & = \int_{0}^{8} 2\left(\cos\sqrt{x+1}\right)\frac{1}{2\sqrt{x+1}} \ud x\\
									     & = \int_{1}^{3} 2\cos u \ud u\\
									     & = 2\sin u\Big|_1^3\\
									     & = 2(\sin(3)-\sin(1))
		\end{align*}
	\end{sol}
\end{exmp}
\section{Integration by Parts}%
\label{sec:integration_by_parts}

\textbf{Integration by Parts} is a consequence of the \textbf{Product Rule} for differentiation:
\[
	\int u(x)\underbrace{v^{\prime}(x)\ud x}_{\ud v} = u(x)v(x) - \int v(x)\underbrace{u^{\prime}(x)\ud x}_{\ud u}
.\]
In short:
\[
\int u\ud v = uv -\int v\ud u
.\]
\begin{exmp}
	Evaluate the following integral:
	\[
	\int x^2\ln x\ud x
	.\]
	\begin{sol}
		Let $u=\ln x$, $v^{\prime}=x^2$, then:
		\[
		u^{\prime}=\frac{1}{x},\qquad v=\frac{x^3}{3}
		.\]
		Thus we have:
		\begin{align*}
			\int x^2\ln x\ud x & = \left(\frac{x^3}{3}\ln x\right) -\int \frac{1}{x}\cdot \frac{x^3}{3}\ud x\\
					   & = \frac{x^3}{3}\ln x - \int \frac{x^2}{3}\ud x\\
					   & = \frac{x^3}{3}\ln x - \frac{x^3}{9}+C.
		\end{align*}
	\end{sol}
\end{exmp}
\begin{exmp}
	Evaluate the following integral:
	\[
		\int (t+1)e^{t}\ud t
	.\]
	\begin{sol}
		Let $u=t+1$, $v^{\prime}e^{t}$, then:
		\[
		u^{\prime} = 1,\qquad v = e^{t}
		.\]
		Thus we have:
		\begin{align*}
			\int (t+1)e^{t}\ud t & = (t+1)e^{t}-\int e^{t}\ud t\\
					     & = (t+1)e^{t}-e^{t}+C\\
					     & = te^{t}+C.
		\end{align*}
	\end{sol}
\end{exmp}
\begin{exmp}
	Evaluate the following integral:
	\[
	\int \tan^{-1}x\ud x
	.\]
	\begin{sol}
		Let $u=\tan^{-1}x$, $v^{\prime}=1$, then:
		\[
		u^{\prime} = \frac{1}{1+x^2},\qquad v = x
		.\]
		Thus we have:
		\begin{align*}
			\int \tan^{-1}x\ud x & = x\tan^{-1}x - \int \frac{x}{1+x^2}\ud x\\
			\intertext{We evaluate the integral by substituting $w = 1+x^2$:}
					     & = x\tan^{-1}x - \int \frac{1}{2}\cdot\frac{1}{u}\ud u\\
					     & = x\tan^{-1}x - \frac{1}{2}\ln |u| + C\\
					     & = x\tan^{-1}x - \frac{1}{2}\ln(1+x^2) + C.
		\end{align*}
	\end{sol}
\end{exmp}
\subsection{The \textbf{LIPET} Rule}%
\label{sub:the_lipet_rule}

When doing integration by parts, certain choices of $u$ work better in general.
This is where the \textbf{LIPET} rule comes in.
It is an acronym, where each letter represents a different type of function:
\[
\begin{matrix}[c c l]
	\textbf{L} & = & \text{Logarithmic functions}\\ 
	\textbf{I} & = & \text{Inverse trigonometric functions}\\ 
	\textbf{P} & = & \text{Polynomial functions}\\ 
	\textbf{E} & = & \text{Exponential functions}\\ 
	\textbf{T} & = & \text{Trigonometric functions}\\ 
\end{matrix}
\]
This gives a systematic list of functions to try and set equal to $u$ in the integration by parts formula.

\section{Reduction Formulas}%
\label{sec:reduction_formulas}

Consider the integral:
\[
I_n = \int x^{n}e^{x}\ud x
.\]
Where $n$ is a non-negative integer.
Then for $n\geqslant 1$, the formula:
\[
I_n = x^{n}e^{x}-nI_{n-1}
,\]
expresses $I_n$ in terms of $I_{n-1}$.
This is known as a \textbf{reduction formula} for:
\[
I_n = \int x^{n}e^{x}\ud x
.\]
This uses integration by parts recursively to integrate expressions.
\begin{proof}
	For $n\geqslant 1$, use integration by parts, with:
	\[
		u(x) = x^{n},\qquad v^{\prime}(x)=e^{x}
	,\]
	so that:
	\[
		u^{\prime}(x) = nx^{n-1},\qquad v(x) = e^{x}
	.\]
	This gives us:
	\begin{align*}
		I_n & = \int x^{n}e^{x}\ud x\\
		    & = x^{n}e^{x}-\int n(x^{n-1})e^{x}\ud x\\
		    & = x^{n}e^{x}-n\underbrace{\int x^{n-1}e^{x}\ud x}_{I_{n-1}}\\
		    & = x^{n}e^{x}-nI_{n-1}.
	\end{align*}
\end{proof}
\begin{exmp}
	Let $\displaystyle{I_n = \int x^{n}e^{x}\ud x}$, where $n\geqslant 0$.
	Use the reduction formula to determine a formula for $I_4$.
	\begin{sol}
		We have:
		\begin{align*}
			I_4 & = x^{4}e^{x}-4I_3\\
			I_3 & = x^3e^{x}-3I_2\\
			I_2 & = x^2e^{x}-2I_1\\
			I_1 & = xe^{x}-I_0.
		\end{align*}
		Note that $I_0 =\displaystyle{\int e^{x}\ud x}=e^{x}+C$. 
		Thus, we obtain:
		\[
		I_4 = x^{4}e^{x}-4x^3e^{x}+12x^2e^{x}-24xe^{x}+24e^{x}+24C
		.\]
	\end{sol}
\end{exmp}
