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

\section{Riemann Sum using Equal-width Partition}%
\label{sec:riemann_sum_using_equal_width_partition}

Consider a continuous function $f$ on $[a,b]$, where the definite integral exists.
We shall consider a special Riemann sum and use it to compute the value of the definite integral.
Suppose the width of each subinterval is the same:
\[
	\Delta x = \frac{b-a}{n}
.\]
Then:
\[
	x_{k} = a + k\left(\frac{b-a}{n}\right)\quad k=0,1,2,\dotsc,n
.\]
With $x^{*}_{k}\in [x_{k-1},x_{k}]$, the corresponding Riemann sum of $f$ on $[a,b]$ is:
\[
	\sum_{k=1}^{n} \frac{b-a}{n}f(x^{*}_{k})
.\]
And the definite integral of $f$ from $a$ to $b$ is:
\[
	\int_{a}^{b} f(x) \ud x=\lim_{n \to \infty}\sum_{k=1}^{n} \frac{b-a}{n}f(x^{*}_{k})
.\]
Where the limit of the Riemann sum as $n\to \infty$ must be independent of how the sample points $x^{*}_{k}$ are chosen.
With the \textbf{right endpoints} as sample points, we have the right Riemann sum:
\begin{align*}
	\int_{a}^{b} f(x) \ud x & = \lim_{n \to \infty}\sum_{k=1}^{n} f(x_k)\frac{b-a}{n}\\
				& = \lim_{n \to \infty}\sum_{k=1}^{n} f\left(a + \frac{k(b-a)}{n}\right)\cdot \frac{b-a}{n}
\end{align*}
With the \textbf{left endpoints} as sample points, we have the left Riemann sum:
\begin{align*}
	\int_{a}^{b} f(x) \ud x & = \lim_{n \to \infty}\sum_{k=1}^{n} f(x_{k-1})\frac{b-a}{n}\\
				& = \lim_{n \to \infty}\sum_{k=1}^{n} f\left(a + \frac{(k-1)(b-a)}{n}\right)\cdot \frac{b-a}{n}
\end{align*}
\begin{exmp}
	Use the right Riemann sums to find the value of the following definite integral:
	\[
	\int_{1}^{3} x^2 \ud x
	.\]
	\begin{sol}
		Partition the interval $[1,3]$ into $n$ subintervals of equal width:
		\[
			\Delta x = \frac{3-1}{n}=\frac{2}{n}
		.\]
		Thus we have:
		\[
		x_{k}=1 + k\Delta x = 1 + \frac{2k}{n}
		.\]
		And our Riemann sum is of the following form:
		\begin{align*}
			\sum_{k=1}^{n} f(x^{*}_{k})\Delta x & = \sum_{k=1}^{n} f\left(1+ \frac{2k}{n}\right)\Delta x\\
							    & = \sum_{k=1}^{n} \left(1+ \frac{2k}{n}\right)^2\cdot \frac{2}{n}\\
							    & = \frac{2}{n}\sum_{k=1}^{n} \left(1 + \frac{4k}{n} + \frac{4k^2}{n^2}\right)\\
							    & = \frac{2}{n}\left(\sum_{k=1}^{n} 1 + \sum_{k=1}^{n} \frac{4k}{n} + \sum_{k=1}^{n} \frac{4k^2}{n^2}\right)\\
							    & = \frac{2}{n}\left(n + \frac{4}{n}\sum_{k=1}^{n} k + \frac{4}{n^2}\sum_{k=1}^{n} k^2\right)\\
							    & = \frac{2}{n}\left(n + \frac{1}{n}\cdot \frac{n(n+1)}{2} + \frac{4}{n^2}\cdot \frac{n(n+1)(2n+1)}{6}\right)\\
							    & = 2\left(1+ 2 + \frac{2}{n} + \frac{2}{3}\left(2+\frac{3}{n}+\frac{1}{n^2}\right)\right)
		\end{align*}
	\end{sol}
\end{exmp}
Therefore the definite integral:
\[
	\int_{1}^{3} x^2 \ud x = \lim_{n \to \infty}\left[2+\left(1+2+\frac{2}{n}+\frac{2}{3}\left(2+\frac{3}{n}+\frac{1}{n^2}\right)\right)\right] = \frac{26}{3}
.\]

\section{Properties of Definite Integrals}%
\label{sec:properties_of_definite_integrals}

\begin{thrm}
	If the integral on the left hand side of the equation exists, the result on the right is true:
	\begin{align*}
		& \int_{a}^{b} c \ud x=c(b-a)\\
		& \int_{a}^{b} Kf(x) \ud x = K \int_{a}^{b} f(x) \ud x\\
		& \int_{a}^{b} (f(x)\pm g(x)) \ud x = \int_{a}^{b} f(x) \ud x \pm \int_{a}^{b} g(x) \ud x\\
		& \int_{a}^{b} f(x) \ud x = \int_{a}^{c} f(x) \ud x + \int_{c}^{b} f(x) \ud x
	\end{align*}
	Where $K$ is a constant.
\end{thrm}
\begin{exmp}
	Suppose $f$ is continuous on $\mathbb{R}$, and:
	\[
	\int_{0}^{3} f(x) \ud x=3,\quad \int_{0}^{4} f(x) \ud x=7
	.\]
	Find:
	\[
		\int_{4}^{3} f(x) \ud x
	.\]
	\begin{sol}
		\begin{align*}
			\int_{4}^{3} f(x) \ud x & = - \int_{3}^{4} f(x) \ud x\\
						& = - \left(\int_{0}^{4} f(x) \ud x - \int_{0}^{3} f(x) \ud x\right)\\
						& = -(7-3)\\
						& = -4
		\end{align*}
	\end{sol}
\end{exmp}
\begin{thrm}
	Suppose the following integrals exist and $a<b$.
	\begin{align*}
		& f(x) \geqslant 0\ \forall x \in [a,b]\implies \int_{a}^{b} f(x) \ud x\geqslant 0.\\
		& f(x) \geqslant g(x)\ \forall x\in [a,b]\implies \int_{a}^{b} f(x) \ud x\geqslant \int_{a}^{b} g(x) \ud x.\\
		& m\geqslant f(x) \geqslant M\ \forall x\in [a,b]\implies m(b-a) \geqslant \int_{a}^{b} f(x) \ud x\geqslant M(b-a).
	\end{align*}
\end{thrm}
