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

\chapter{Fundamental Theorem of Calculus}%
\label{cha:fundamental_theorem_of_calculus}

\section{The First Fundamental Theorem of Calculus}%
\label{sec:the_fundamental_theorem_of_calculus}

The fundamental theorem gives the precise inverse relationship between the derivative and the definite integral.

\begin{definition}
	Mean Value.
	If $f$ is continuous on $[a,b]$, then the \textbf{mean value} (also known as the \textbf{average value}) of $f$ on $[a,b]$ is:
	\[
	\frac{1}{b-a}\int_{a}^{b} f(x) \ud x
	.\]
\end{definition}
\begin{exmp}
	What is the mean value of $f(x)=x^2$ on the interval $[1,3]$?
	\begin{sol}
		We had previously calculated in \cref{sec:riemann_sum_using_equal_width_partition} that:
		\[
		\int_{1}^{3} x^2 \ud x=\frac{26}{3}
		.\]
		Thus the mean value of $x^2$ on $[1,3]$ is:
		\begin{align*}
			\frac{1}{3-1}\int_{1}^{3} x^2 \ud x & = \frac{1}{3-1}\cdot \frac{26}{3}\\
							    & = \frac{13}{3}.
		\end{align*}
	\end{sol}
\end{exmp}
\begin{thrm}
	The Mean Value Theorem for Definite Integrals.
	If $f$ is continuous on $[a,b]$, then $\exists c\in [a,b]$ such that:
	\[
		f(c)= \frac{1}{b-a}\int_{a}^{b} f(x) \ud x
	.\]
	Otherwise written:
	\[
		(b-a)f(c)=\int_{a}^{b} f(x) \ud x
	.\]
\end{thrm}
\begin{proof}
	Mean Value Theorem for Definite Integrals.
	Suppose $f$ is continuous on the interval $[a,b]$.
	Then we know that $f$ has a maximum $M=f(s)$ and a minimum $m=f(r)$ on $[a,b]$ by the \textbf{Extreme Value Theorem}.
	By one of the order properties of the definite integral, we then have:
	\[
		m(b-a)\leqslant \int_{a}^{b} f(x) \ud x\leqslant M(b-a)
	.\]
	And if we divide by $b-a$ we get:
	\[
		f(r)=m\leqslant \frac{1}{b-a}\int_{a}^{b} f(x) \ud x\leqslant M=f(s)
	.\]
	By the \textbf{Intermediate Value Theorem}, $f$ must take on every value between $f(r)$ and $f(s)$.
	Therefore, $\exists c\in [a,b]$ such that:
	\[
		f(c) = \frac{1}{b-a}\int_{a}^{b} f(x) \ud x
	.\]
\end{proof}
\begin{thrm}
	First Fundamental Theorem of Calculus.
	Suppose $f$ is continuous on $[a,b]$.
	Let $F(x)$ be the function defined by:
	\[
		F(x) = \int_{a}^{x} f(t) \ud t,\quad a\leqslant x\leqslant b
	.\]
	Then $F(x)$ is continuous on $[a,b]$, and $F(x)$ is differentiable on $(a,b)$ where:
	\[
		F^{\prime}(x)=\frac{\ud}{\ud x}\left(\int_{a}^{x} f(t) \ud t\right) = f(x)
	.\]
\end{thrm}
\begin{note}
	In the integral above, the lower limit $a$ is a constant, and the upper limit of the integral is the variable $x$.
\end{note}
\begin{proof}
	First Fundamental Theorem of Calculus.
	The definite integral:
	\[
		F(x) = \int_{a}^{x} f(t) \ud t
	.\]
	Is the area under $f(t)$ on the interval $[a,x]$.
	Note the $F(x)$ is a continuous function for $x\in [a,b]$.
	Then:
	\[
		\frac{\Delta F}{\Delta x}= \frac{F(x+h)-F(x)}{h} = \frac{\displaystyle\int_{x}^{x+h} f(t) \ud t}{h} = \frac{h\cdot f(x^{*})}{h} = f(x^{*})
	.\]
	Where $x^{*}$ is between $x$ and $x+h$.
	As $h\to 0$, we have $x^{*}\to x$, and hence:
	\[
		\frac{F(x+h)-F(x)}{h}\to f(x)
	.\]
	Thus, we have:
	\[
		F^{\prime}(x)=f(x)
	.\]
\end{proof}
\begin{exmp}
	Let $b>1$.
	Find $g^{\prime}(x)$, where:
	\[
		g(x) = \int_{1}^{x} \frac{\sin(t)}{t} \ud t,\quad 1\leqslant x\leqslant b
	.\]
	\begin{sol}
		By the First Fundamental Theorem of Calculus, the function:
		\[
			g(x) = \int_{1}^{x} \frac{\sin(t)}{t} \ud t
		\]
		is continuous on $[1,b]$ and is differentiable in $(1,b)$ and:
		\[
			g^{\prime}(x) = \frac{\ud}{\ud x}\left(\int_{1}^{x} \frac{\sin(t)}{t} \ud t\right) = \frac{\sin(x)}{x}
		.\]
	\end{sol}
\end{exmp}
\begin{exmp}
	Find the following:
	\[
		\frac{\ud}{\ud x}\left(\int_{x}^{\pi} e^{(t-3)^2} \ud t\right)
	.\]
	\begin{note}
		The lower limit of the integral is not a constant.
	\end{note}
	\begin{sol}
		\begin{align*}
			\frac{\ud}{\ud x}\left(\int_{x}^{\pi} e^{(t-3)^2} \ud t\right) & = \frac{\ud}{\ud x}\left(-\int_{\pi}^{x} e^{(t-3)^2} \ud t\right)\\
										       & = - \frac{\ud}{\ud x}\left(\int_{\pi}^{x} e^{(t-3)^2} \ud t\right)\\
										       & = -e^{(x-3)^2}.
		\end{align*}
	\end{sol}
\end{exmp}
\begin{mdframed}
	\begin{note}
		In general, we have the following:
		\[
			\frac{\ud}{\ud x}\int_{a}^{u(x)} f(t) \ud t = u^{\prime}(x)\cdot f(u(x))
		.\]
	\end{note}
\end{mdframed}
\begin{proof}
	Let $F(x) = {\displaystyle \int_{a}^{x} f(t) \ud t}$.
	Then:
	\[
		\int_{a}^{u(x)} f(t) \ud t = F(u(x)) = (F\circ u)(x)
	.\]
	Therefore, we apply the \textbf{Chain Rule} to obtain:
	\[
		\frac{\ud}{\ud x}\left(\int_{a}^{u(x)} f(t) \ud t\right) = \frac{\ud}{\ud u}\left(\int_{a}^{u} f(t) \ud t\right)\cdot \frac{\ud u}{\ud x} = u^{\prime}(x)\cdot f(u(x))
	.\]
\end{proof}
\begin{exmp}
	Find the derivative of:
	\[
		F(x) = \int_{x^2}^{x^3} e^{-t^2} \ud t
	.\]
	\begin{sol}
		First note that:
		\[
			F(x) = \int_{x^2}^{x^3} e^{-t^2} \ud t = \int_{0}^{x^3} e^{-t^2} \ud t - \int_{0}^{x^2} e^{-t^2} \ud t
		.\]
		Thus we have:
		\begin{align*}
			F^{\prime}(x) & = \frac{\ud}{\ud x}\left(\int_{0}^{x^3} e^{-t^2} \ud t\right) - \frac{\ud}{\ud x}\left(\int_{0}^{x^2} e^{-t^2} \ud t\right)\\
				      & = 3x^2e^{-x^{6}} - 2xe^{-x^{4}}.
		\end{align*}
	\end{sol}
\end{exmp}

\section{The Second Fundamental Theorem of Calculus}%
\label{sec:the_second_fundamental_theorem_of_calculus}

\begin{thrm}
	The Second Fundamental Theorem of Calculus.
	If $f$ is continuous on $[a,b]$, then:
	\[
		\int_{a}^{b} f(x) \ud x = G(b)-G(a)
	,\]
	where $G$ is any continuous antiderivative of $f$ on $[a,b]$ such that:
	\[
	G^{\prime}=f
	.\]
	We write:
	\[
		\int_{a}^{b} f(x) \ud x = G(x)\Big |_a^b
	.\]
\end{thrm}
\begin{proof}
	Second Fundamental Theorem of Calculus.
	We know that:
	\[
		G^{\prime}(x) = f(x)
	.\]
	And by the first fundamental theorem of calculus:
	\[
		\frac{\ud}{\ud x}\left(\int_{a}^{x} f(t) \ud t\right) = f(x)
	.\]
	Hence, both $G(x)$ and ${\displaystyle \int_{a}^{x} f(t) \ud t}$ are antiderivatives of $f(x)$, and they must differ by a constant on $(a,b)$:
	\[
		G(x) = \int_{a}^{x} f(t) \ud t +C,\quad \forall x\in (a,b)
	,\]
	for some constant $C$.
	Next, we have:
	\begin{align*}
		G(b)-G(a) & = \left(\int_{a}^{b} f(t) \ud t + C\right) - \left(\int_{a}^{a} f(t) \ud t + C\right)\\
			  & = \int_{a}^{b} f(t) \ud t.
	\end{align*}
\end{proof}
\begin{exmp}
	Evaluate the following:
	\[
		\int_{1}^{4} x^{-2}+3\sqrt{x}-\frac{1}{\sqrt{x}} \ud x
	.\]
	\begin{sol}
		\begin{align*}
			\int_{1}^{4} x^{-2}+3\sqrt{x}-\frac{1}{\sqrt{x}} \ud x & = -x^{-1} + 3\left(\frac{x^{\frac{3}{2}}}{\frac{3}{2}}\right) - \left.\left(\frac{\sqrt{x}}{\frac{1}{2}}\right)\right|_1^4 \\
									       & = \left(-\frac{1}{4}+1\right) + 2(8-1) -2(2-1)\\
									       & = 12 \frac{3}{4}.
		\end{align*}
	\end{sol}
\end{exmp}

\section{Application}%
\label{sec:application}

\begin{exmp}
	Evaluate:
	\[
		\lim_{n \to \infty}\frac{\pi}{n}\left(\sin \frac{\pi}{n} + \sin \frac{2\pi}{n} + \dotsb + \sin \frac{n\pi}{n}\right)
	.\]
	\begin{sol}
		Express the limit as a definite integral:
		\[
			\int_{a}^{b} g(x) \ud x = \lim_{n \to \infty}\sum_{k=1}^{n} \frac{b-a}{n}g(x^{*}_k)
		,\]
		with $x^{*}_k\in \left[a + \frac{(k-1)(b-a)}{n}, a + \frac{k(b-a)}{n}\right]$.
		We get:
		\[
			\int_{0}^{1} g(x) \ud x = \lim_{n \to \infty}\sum_{k=1}^{n} \frac{1}{n}g(x^{*}_k)
		,\]
		with $x^{*}_k = \frac{k}{n}$.
		Therefore we rewrite the sum in the question:
		\begin{align*}
			\frac{\pi}{n}\left(\sin \frac{\pi}{n} + \sin \frac{2\pi}{n} + \dotsb + \frac{n\pi}{n}\right)
			& = \sum_{k=1}^{n} \frac{\pi}{n}\sin \frac{k\pi}{n}\\
			& = \sum_{k=1}^{n} \frac{1}{n}\pi \sin \left(\left(\frac{k}{n}\right)\pi\right).
		\end{align*}
		Equating the expression above with our Riemann sum:
		\[
			\sum_{k=1}^{n} \frac{1}{n}g\left(\frac{k}{n}\right) \equiv \sum_{k=1}^{n} \frac{1}{n}\sin\left(\left(\frac{k}{n}\right)\pi\right)
		.\]
		By replacing $\frac{k}{n}$ by $x$, we take $g(x) = \pi\sin(\pi x)$ over $[0,1]$.
		Thus we have:
		\[
			\lim_{n \to \infty}\sum_{k=1}^{n} \frac{\pi}{n}\sin\left(\frac{k\pi}{n}\right)
			=
			\int_{0}^{1} \pi\sin(\pi x) \ud x
			=
			\left.\pi\left(-\frac{1}{\pi}\cos\left(\pi x\right)\right)\right|_0^1 = 2
		.\]
		As required.
	\end{sol}
\end{exmp}
