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

\chapter{Indefinite \& Definite Integrals}%
\label{cha:indefinite_&_definite_integrals}

\section{Antiderivatives \& Indefinite Integrals}%
\label{sec:antiderivatives_&_indefinite_integrals}

\begin{definition}
	Antiderivative.
	A function $F$ is said to be an \textbf{antiderivative} of $f$ on an open interval $I$ if $F^{\prime}(x)=f(x)\ \forall x \in I$.
\end{definition}
\begin{note}
	An antiderivative of $f$ is defined for $f$ on an open set, which is a union of open intervals.
\end{note}
\begin{thrm}
	Let $F(x)$ and $G(x)$ be two antiderivatives of $f$ on an open interval $I$.
	Then, $G(x)=F(x) + C$ on $I$, for some constant $C$.
\end{thrm}
\begin{proof}
	Let us choose two arbitrary real numbers $x_1,x_2 \in I$ where $x_1<x_2$.
	Next, let us construct a function $h(x)$ on $[x_1,x_2]$ and let:
	\[
		h(x) = G(x) - F(x)
	.\]
	Since $G(x)$ and  $F(x)$ are \textbf{anti derivatives} of $f(x)$ on $I$, the following equations are true:
	\begin{align*}
		G^{\prime}(x) & = f(x)\\
		F^{\prime}(x) & = f(x)
	\end{align*}
	Both $G(x)$ and $F(x)$ are differentiable on $I$, which implies that both $G(x)$ and $F(x)$ are continuous on $I$ and in particular on $[x_1,x_2]$.
	Therefore, we can say that $h(x)=G(x)-F(x)$ is also continuous on $[x_1,x_2]$ and that it is also differentiable on $I$.
	By the Mean Value Theorem, we have the following equation that holds true:
	\[
		\frac{h(x_2)-h(x_1)}{x_2-x_1}=h^{\prime}(c),\ c\in (x_1,x_2)
	.\]
	And now we have:
	\begin{align*}
		h^{\prime}(c) & = G^{\prime}(c)-F^{\prime}(c)\\
			      & = f(c)-f(c) = 0
	\end{align*}
	Therefore we have:
	\[
		\frac{h(x_2)-h(x_1)}{x_2-x_1}=0 
	.\]
	Which means that:
	\[
		h(x_2)-h(x_1)=0
	.\]
	Since $x_1,x_2\in I$, we have:
	\[
		h(x_1)=h(x_2)=C
	.\]
	where $C$ is some constant.
	We therefore conclude that:
	\begin{align*}
		h(x) & = C\ \forall x\in I\\
		G(x)-F(x) & = C\ \forall x\in I\\
		\therefore G(x) & =F(x) + C\ \forall x\in I
	\end{align*}
\end{proof}

\begin{definition}
	Indefinite Integral.
	The \textbf{indefinite integral} of $f$, denoted by:
	\[
		\int f(x) \ud x
	.\]
	is the most general antiderivative of $f$.
	The function $f$ is called the \textbf{integrand}.
\end{definition}
\begin{exmp}
	For $I=\mathbb{R}$, we have:
	\[
		\int \cos(x) \ud x = \sin(x) + C
	.\]
	Where $C$ is an arbitrary constant.
\end{exmp}
\begin{exmp}
	For $I=(0,\infty)$, we have:
	\[
		\int 3x^2 - \frac{2}{\sqrt{x}}\ud x = x^3-4\sqrt{x} + 179 + C
	.\]
	Where $C$ is an arbitrary constant.
\end{exmp}
By definition, we have:
\[
	\frac{\ud}{\ud x}\left(\int f(x) \ud x\right) = f(x)
.\]
Thus, to verify $\int f(x) \ud x = F(x)$, we verify:
\[
	\frac{\ud}{\ud x}(F(x)) = f(x)
.\]
\begin{exmp}
	Prove that for $I\subseteq (0,\infty)$ or $I\subseteq (-\infty, 0)$, we have:
	\[
	\int \frac{1}{x} \ud x = \ln |x| +C
	.\]
	\begin{sol}
		First we note that it follows from the definition that:
		\begin{align*}
			\int f(x) \ud x = \ln |x| + C & \iff \frac{\ud}{\ud x}(\ln |x| +C) =f(x)\\
						      & \iff \frac{\ud}{\ud x}\ln |x| = \frac{1}{x}
		\end{align*}
		For $I\subseteq (0,\infty)$, we have $x>0$ and:
		\[
			\frac{\ud}{\ud x}(\ln |x|) = \frac{\ud}{\ud x}(\ln x) = \frac{1}{x}
		.\]
		For $I\subseteq (-\infty, 0)$, we have $x<0$ and:
		\[
			\frac{\ud}{\ud x}(\ln |x|) = \frac{\ud}{\ud x}(\ln -x) = \frac{1}{-x}\cdot -1 = \frac{1}{x}
		.\]
		Therefore we have proven that:
		\[
		\frac{\ud}{\ud x}\ln |x| = \frac{1}{x}
		.\]
		And by definition, we have:
		\[
		\int \frac{1}{x} \ud x=\ln |x| +C
		.\]
	\end{sol}
\end{exmp}

\section{Rules for Integration}%
\label{sec:rules_for_integration}

\begin{thrm}
	Rules for Integration.
	\begin{align*}
		& \int (f(x)+g(x)) \ud x = \int f(x) \ud x + \int g(x) \ud x\\
		& \int (f(x)-g(x)) \ud x = \int f(x) \ud x - \int g(x) \ud x\\
		& \int cf(x) \ud x = c\int f(x) \ud x,\ \text{where $c$ is a constant}
	\end{align*}
\end{thrm}
To prove the above properties, we verify that the derivatives of functions on both sides are equal.
\begin{proof}
	The integral of a sum is the sum of the integrals.
	We can prove this by differentiating the expression on the right.
	\begin{align*}
		\frac{\ud}{\ud x}\left(\int f(x) \ud x + \int g(x) \ud x\right) & = \frac{\ud}{\ud x}\left(\int f(x)\ud x\right) + \left(\int g(x)\ud x\right)\\
										& = f(x) + g(x)
	\end{align*}
	Thus, we have:
	\[
	\int (f(x)+g(x))\ud x= \int f(x)\ud x + \int g(x)\ud x
	.\]
	The same proof method is used for the other rules.
\end{proof}
\begin{exmp}
	If $f^{\prime}(x)=2x-3$ and $f(2)=3$, find $f(x)$ where $x\in \mathbb{R}$.
	\begin{sol}
		Since $f^{\prime}(x)=2x-3$, we have:
		\[
			f(x) = \int 2x-3 \ud x = x^2-3x+C
		.\]
		for some constant $C$.
		Given that $f(2)=3$, we obtain $C=5$.
		Thus:
		\[
			f(x)=x^2-3x+5
		.\]
	\end{sol}
\end{exmp}
