\documentclass[12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{tikz-3dplot}

\newcommand{\f}[1]{o_{#1}x_{#1}y_{#1}z_{#1}}
\newcommand{\fromlectures}{{\\ \color{blue} \hspace*{\fill}(from lecture slides)} \\}
\newcommand{\bydefn}{{\\ \color{blue} \hspace*{\fill}(by definition)} \\}
\newcommand{\given}{{\\ \color{blue} \hspace*{\fill}(given)} \\}
\newcommand{\rtp}{{\\ \color{blue} \hspace*{\fill}(required to prove)} \\}

\newcommand{\rx}[1]{\begin{bmatrix} 1 & 0 & 0 \\ 0 & cos(#1) & -sin(#1) \\ 0 & sin(#1) & cos(#1) \end{bmatrix}}
\newcommand{\ry}[1]{\begin{bmatrix} cos(#1) & 0 & sin(#1) \\ 0 & 1 & 0 \\ -sin(#1) & 0 & cos(#1) \end{bmatrix}}
\newcommand{\rz}[1]{\begin{bmatrix} cos(#1) & -sin(#1) & 0 \\ sin(#1) & cos(#1) & 0 \\ 0 & 0 & 1 \end{bmatrix}}

\newcommand{\vv}[1]{\overline{v}_{#1}}

\title{CSci 5551 - HW2}
\author{Yashasvi Sriram Patkuri\\patku001@umn.edu}

\begin{document}
\maketitle
\pagebreak

\section{}
\subsection*{1.a}
$ k \equiv \begin{bmatrix} k_x \\ k_y \\ k_z \end{bmatrix} $ is a unit vector.
A rotation about k by an angle $\theta$ is considered.
\given

Rotation matrix corresponding to this rotation is
\[
  R \equiv
  \begin{bmatrix}
    k_x^2v\theta + c\theta & k_xk_yv\theta - k_zs\theta & k_xk_zv\theta + k_ys\theta\\
    k_xk_yv\theta + k_zs\theta & k_y^2v\theta + c\theta & k_yk_zv\theta - k_xs\theta \\
    k_xk_zv\theta - k_ys\theta & k_yk_zv\theta + k_xs\theta & k_z^2v\theta + c\theta
  \end{bmatrix}
\]
where $v\theta \equiv 1 - c\theta$.
\rtp

The rotation matrix for a rotation about z-axis by angle $\theta$ is
\[
  R_{z,\theta} \equiv \rz{\theta}
\].
\fromlectures

\paragraph{Idea}
Consider a frame $ F_1 $ in which
\begin{enumerate}[nolistsep]
  \item The z-axis is aligned with what appears as k from global frame.
  \item The x and y axes are arbitrary perpendicular unit vectors in the plane perpendicular to its z-axis.
\end{enumerate}
By selecting an arbitrary y-axis perpendicular to z-axis, $ F_1 $ is completely known.
The rotation transformation matrix $ R_1^0 $ b/w global frame $ F_0 $ and $ F_1 $ is now completely known.

For a given vector $ v^0_a $ in $ F_0 $, we can get its representation $ v^1_a $ in $ F_1 $ using $ R_1^0 $.
We know the rotation matrix for rotation about z-axis by $\theta$.
We can use that to find rotated version of $ v^1_a $ say $ v^1_r $.
Finally we get the representation of $ v^1_r $ in $ F_0 $ viz. $ v^0_r $.

\subsubsection*{Finding $R_1^0$}
Let k be along z-axis of $ F_1 $. In general y-axis can be thought of as $ \begin{bmatrix} p_x \\ p_y \\ p_z \end{bmatrix} $.
As these are perpendicular unit vectors we have.
\[
  k_x^2 + k_y^2 + k_z^2 \equiv 1
\]
\[
  p_x^2 + p_y^2 + p_z^2 \equiv 1
\]
\[
  p_x * k_x + p_y * k_y + p_z * k_z \equiv 0
\]
As there is no restriction on the choice of y-axis we can choose the it to be in XY plane of $ F_0 $ i.e. it has the form $ \begin{bmatrix} p_x \\ p_y \\ 0 \end{bmatrix} $.
Therefore above equations become
\[
  k_x^2 + k_y^2 + k_z^2 \equiv 1
\]
\[
  p_x^2 + p_y^2 \equiv 1
\]
\[
  p_x * k_x + p_y * k_y \equiv 0
\]
Rewriting $ p_x $ in terms of $ p_y $ we have
\[
  p_x \equiv -p_y * \frac{k_y}{k_x}
\]
Substituting it back we get
\[
  (-p_y * \frac{k_y}{k_x})^2 + p_y^2 \equiv 1
\]
\[
  p_y^2 * \frac{k_y^2 + k_x^2}{k_x^2} \equiv 1
\]
We can choose the one of the square root. Therefore we get
\[
  p_y \equiv \frac{k_x}{\sqrt{k_x^2 + k_y^2}}
\]
\[
  p_x \equiv \frac{-k_y}{\sqrt{k_x^2 + k_y^2}}
\]
Therefore we have
\[
  p \equiv
  \begin{bmatrix}
  \frac{-k_y}{\sqrt{k_x^2 + k_y^2}} \\
  \frac{k_x}{\sqrt{k_x^2 + k_y^2}}  \\
  0
  \end{bmatrix}
\]
We can get the unit vector along x-axis $ t \equiv \begin{bmatrix} t_x \\ t_y \\ t_z \end{bmatrix} $ by taking a cross product
\[
  t \equiv p \times k
\]
\[
  t \equiv \begin{bmatrix} p_y k_z - p_z k_y \\ p_z k_x - p_x k_z \\ p_x k_y - p_y k_x \end{bmatrix}
\]
Substituting $ p_x, p_y, p_z $ in above equation we get
\[
  t \equiv
  \begin{bmatrix}
    \frac{k_1k_3}{\sqrt{k_1^2 + k_2^2}} \\
    \frac{k_2k_3}{\sqrt{k_1^2 + k_2^2}} \\
    -\sqrt{k_1^2 + k_2^2}
  \end{bmatrix}
\]
We have the rotation matrix
\[
  R_1^0 \equiv \begin{bmatrix} i_1i_0 & j_1i_0 & k_1i_0 \\ i_1j_0 & j_1j_0 & k_1j_0 \\ i_1k_0 & j_1k_0 & k_1k_0 \end{bmatrix}
\]
\fromlectures
Substituting columns we get
\[
  R_1^0 \equiv \begin{bmatrix} t & p & k \end{bmatrix}
\]
\[
  R_1^0 \equiv
  \begin{bmatrix}
  \frac{k_1k_3}{\sqrt{k_1^2 + k_2^2}} & \frac{-k_y}{\sqrt{k_x^2 + k_y^2}}  & k_x \\
  \frac{k_2k_3}{\sqrt{k_1^2 + k_2^2}} & \frac{k_x}{\sqrt{k_x^2 + k_y^2}}   & k_y \\
  -\sqrt{k_1^2 + k_2^2}               & 0 & k_z
  \end{bmatrix}
\]
For sanity check one can verify that the columns of matrix are orthonormal.

\subsubsection*{Rotation around $F_1$'s z-axis}
For any vector $ v^0 $ in $ F_0 $ its representation in $ F_1 $ is
\[
  v^1 \equiv R_0^1 * v^0
\]
The vector that results by rotating $ v^1 $ in $ F_1 $'s z-axis by an angle $ \theta $ is
\[
  v^1_r \equiv R_{z,\theta} * v^1
\]
\[
  v^1_r \equiv R_{z,\theta} * R_0^1 * v^0
\]
The representation of $ v^1_r $ in $ F_0 $ is
\[
  v^0_r \equiv R_1^0 * v^1_r
\]
\[
  v^0_r \equiv R_1^0 * R_{z,\theta} * R_0^1 * v^0
\]
But for any vector $ v^0 $ the vector resulted by rotation around k by $\theta$ is
\[
  v^0_r \equiv R_{k,\theta} * v^0
\]
Comparing the above two equations we have
\[
  R_{k,\theta} \equiv R_1^0 * R_{z,\theta} * R_0^1
\]
\paragraph{Gist} Aligning $ F_1 $'s z-axis with k and rotating around $ F_1 $'s z-axis by $ \theta $ is identical to rotating around k by $ \theta $.

We know that
\[
  R_1^{0^{-1}} \equiv R_1^{0^T} \equiv R_0^1
\]
\fromlectures
Therefore we have
\[
  R_1^{0^{-1}} \equiv R_{1_0^T} \equiv R_0^1 \equiv
  \begin{bmatrix}
  \frac{k_1k_3}{\sqrt{k_1^2 + k_2^2}} & \frac{k_2k_3}{\sqrt{k_1^2 + k_2^2}} & -\sqrt{k_1^2 + k_2^2} \\
  \frac{-k_y}{\sqrt{k_x^2 + k_y^2}}  & \frac{k_x}{\sqrt{k_x^2 + k_y^2}}   & 0 \\
  k_x & k_y & k_z
  \end{bmatrix}
\]

Therefore everything on the right side is known and therefore we can calculate $ R_{k,\theta} $
\[
  R_{k,\theta} \equiv R_1^0 * R_{z,\theta} * R_0^1
\]
\[
  R_{k,\theta} \equiv
  \begin{bmatrix}
  \frac{k_1k_3}{\sqrt{k_1^2 + k_2^2}} & \frac{-k_y}{\sqrt{k_x^2 + k_y^2}}  & k_x \\
  \frac{k_2k_3}{\sqrt{k_1^2 + k_2^2}} & \frac{k_x}{\sqrt{k_x^2 + k_y^2}}   & k_y \\
  -\sqrt{k_1^2 + k_2^2}               & 0 & k_z
  \end{bmatrix}
  *
  \rz{\theta}
  *
  \begin{bmatrix}
  \frac{k_1k_3}{\sqrt{k_1^2 + k_2^2}} & \frac{k_2k_3}{\sqrt{k_1^2 + k_2^2}} & -\sqrt{k_1^2 + k_2^2} \\
  \frac{-k_y}{\sqrt{k_x^2 + k_y^2}}  & \frac{k_x}{\sqrt{k_x^2 + k_y^2}}   & 0 \\
  k_x & k_y & k_z
  \end{bmatrix}
\]
Multiplying matrices and simplifying using $ k_x^2 + k_y^2 + k_z^2 \equiv 1 $ we get
\[
  R_{k,\theta} \equiv
  \begin{bmatrix}
    k_x^2(1 - c\theta) + c\theta & k_xk_y(1 - c\theta) - k_zs\theta & k_xk_z(1 - c\theta) + k_ys\theta\\
    k_xk_y(1 - c\theta) + k_zs\theta & k_y^2(1 - c\theta) + c\theta & k_yk_z(1 - c\theta) - k_xs\theta \\
    k_xk_z(1 - c\theta) - k_ys\theta & k_yk_z(1 - c\theta) + k_xs\theta & k_z^2(1 - c\theta) + c\theta
  \end{bmatrix}
\]
\[
  R_{k,\theta} \equiv
  \begin{bmatrix}
    k_x^2v\theta + c\theta & k_xk_yv\theta - k_zs\theta & k_xk_zv\theta + k_ys\theta\\
    k_xk_yv\theta + k_zs\theta & k_y^2v\theta + c\theta & k_yk_zv\theta - k_xs\theta \\
    k_xk_zv\theta - k_ys\theta & k_yk_zv\theta + k_xs\theta & k_z^2v\theta + c\theta
  \end{bmatrix}
\]
where $v\theta \equiv 1 - c\theta$.
\paragraph{Note} This formulation does not work iff $ k_x^2 + k_y^2 \equiv 0 $, i.e. $ k_x \equiv 0, k_y \equiv 0 $, which means $ k_z \equiv 1 $.
This case means that we are rotating about z-axis of $ F_0 $.
If we substitute values $ k_x \equiv 0, k_y \equiv 0, k_z \equiv 1 $ in given matrix in the question we get the rotation matrix about z-axis, thus proving the statement for this case.

Hence the required statement is proved.
\pagebreak

\subsection*{1.b}
When $\theta = 0$, $c\theta = 1, s\theta = 0, v\theta \equiv 1 - c\theta = 0$.
Substituting these in the matrix $ R_{k,\theta} $ we have
\[
  R_{k,0} \equiv
  \begin{bmatrix} 0 + 1 & 0 - 0 & 0 + 0 \\ 0 + 0 & 0 + 1 & 0 - 0 \\ 0 - 0 & 0 + 0 & 0 + 1 \end{bmatrix}
\]
\[
  R_{k,0} \equiv
  \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}
\]
This means that there is no rotation at all.
\pagebreak

\section{}
\subsection*{2.a}
A frame $F_0$ is rotated in the following order
\begin{enumerate}[nolistsep]
  \item 90 degrees around $z_0$
  \item 30 degrees around $y_0$
  \item 60 degrees around $x_0$
\end{enumerate}
\given

For fixed frame rotations in the following order $R_1, R_2, R_3$ the composite rotation matrix is
\[
  R \equiv R_3 R_2 R_1
\]
\fromlectures

Rotation matrices around x, y, z axes are
\[
  R_{x,\theta} \equiv \rx{\theta}
\]
\[
  R_{y,\theta} \equiv \ry{\theta}
\]
\[
  R_{z,\theta} \equiv \rz{\theta}
\]
\fromlectures
Therefore the composite rotation matrix for given sequence of rotations is
\[
  R \equiv
  \rx{60^\circ}
  \ry{30^\circ}
  \rz{90^\circ}
\]
Multiplying we get
\[
  R \equiv
  \begin{bmatrix}
    0 & -\frac{\sqrt{3}}{2} & \frac{1}{2} \\
    \frac{1}{2} & -\frac{\sqrt{3}}{4} & -\frac{3}{4} \\
    \frac{\sqrt{3}}{2} & \frac{1}{4} & \frac{\sqrt{3}}{4}
  \end{bmatrix}
\]
\pagebreak

\subsection*{2.b}
From Q1 we have the rotation matrix for a rotation of angle $\theta$ about a unit vector k as
\[
  R \equiv
  \begin{bmatrix} r_{11} & r_{12} & r_{13} \\ r_{21} & r_{22} & r_{23} \\ r_{31} & r_{32} & r_{33} \end{bmatrix}
  \equiv
  \begin{bmatrix}
    k_x^2v\theta + c\theta & k_xk_yv\theta - k_zs\theta & k_xk_zv\theta + k_ys\theta\\
    k_xk_yv\theta + k_zs\theta & k_y^2v\theta + c\theta & k_yk_zv\theta - k_xs\theta \\
    k_xk_zv\theta - k_ys\theta & k_yk_zv\theta + k_xs\theta & k_z^2v\theta + c\theta
  \end{bmatrix}
\]
where $v\theta \equiv 1 - c\theta$.

Observe that
\[
  r_{32} - r_{23} \equiv 2k_xs\theta
\]
\[
  r_{13} - r_{31} \equiv 2k_ys\theta
\]
\[
  r_{21} - r_{12} \equiv 2k_zs\theta
\]
\[
  \begin{bmatrix}
    r_{32} - r_{23}\\
    r_{13} - r_{31}\\
    r_{21} - r_{12}
  \end{bmatrix}
  \equiv
  \begin{bmatrix}
    2k_xs\theta\\
    2k_ys\theta\\
    2k_zs\theta
  \end{bmatrix}
  \equiv
  2s\theta
  \begin{bmatrix}
    k_x\\
    k_y\\
    k_z
  \end{bmatrix}
\]
In our case we have
\[
  \begin{bmatrix}
    r_{32} - r_{23}\\
    r_{13} - r_{31}\\
    r_{21} - r_{12}
  \end{bmatrix}
  \equiv
  2s\theta
  \begin{bmatrix}
    k_x\\
    k_y\\
    k_z
  \end{bmatrix}
  \equiv
  \begin{bmatrix} \frac{1 + 3}{4} \\ \frac{1 - \sqrt{3}}{2} \\ \frac{1 + \sqrt{3}}{2} \end{bmatrix}
  \equiv
  \begin{bmatrix} 1 \\ \frac{1 - \sqrt{3}}{2} \\ \frac{1 + \sqrt{3}}{2} \end{bmatrix}
\]
As k is unit vector the L2-norm of the above vector is
\[
  \left\lVert
  2s\theta
  \begin{bmatrix}
    k_x\\
    k_y\\
    k_z
  \end{bmatrix}
 \right\rVert_2
 \equiv
  2s\theta
  \left\lVert
  \begin{bmatrix}
    k_x\\
    k_y\\
    k_z
  \end{bmatrix}
 \right\rVert_2
 \equiv
 2s\theta
\]
Here
\[
  \left\lVert
  2s\theta
  \begin{bmatrix}
    k_x\\
    k_y\\
    k_z
  \end{bmatrix}
  \right\rVert_2
  \equiv
  \left\lVert
  \begin{bmatrix} 1 \\ \frac{1 - \sqrt{3}}{2} \\ \frac{1 + \sqrt{3}}{2} \end{bmatrix}
  \right\rVert_2
  \equiv
  \sqrt{3}
\]
Therefore
\[
  2s\theta \equiv \sqrt{3} \implies
  s\theta \equiv \frac{\sqrt{3}}{2}
\]
Also observe
\[
  tr(R) \equiv (k_x^2 + k_y^2 + k_z^2) (1 - c\theta) + 3 * c\theta
\]
\[
  c\theta \equiv \frac{tr(R) - 1}{2} \equiv \frac{(0 + \frac{\sqrt{3}}{4} - \frac{\sqrt{3}}{4}) - 1}{2} \equiv -\frac{1}{2}
\]
\[
  s\theta \equiv \frac{\sqrt{3}}{2}, c\theta \equiv -\frac{1}{2} \implies \theta = 120^\circ
\]

Substituting value of $\theta$ back we have
\[
  2s\theta
  \begin{bmatrix}
    k_x\\
    k_y\\
    k_z
  \end{bmatrix}
  \equiv
  \sqrt{3}
  \begin{bmatrix}
    k_x\\
    k_y\\
    k_z
  \end{bmatrix}
  \equiv
  \begin{bmatrix} 1 \\ \frac{1 - \sqrt{3}}{2} \\ \frac{1 + \sqrt{3}}{2} \end{bmatrix}
\]
\[
  \begin{bmatrix}
    k_x\\
    k_y\\
    k_z
  \end{bmatrix}
  \equiv
  \begin{bmatrix} \frac{1}{\sqrt{3}} \\ \frac{1 - \sqrt{3}}{2\sqrt{3}} \\ \frac{1 + \sqrt{3}}{2\sqrt{3}} \end{bmatrix}
\]
Therefore we have
\[
  k \equiv
  \begin{bmatrix} \frac{1}{\sqrt{3}} \\ \frac{1 - \sqrt{3}}{2\sqrt{3}} \\ \frac{1 + \sqrt{3}}{2\sqrt{3}} \end{bmatrix},
  \theta \equiv 120^\circ
\]
Observe the same rotation transformation can be achieved by flipping the axis unit vector and angle i.e.
\[
  k \equiv
  \begin{bmatrix} -\frac{1}{\sqrt{3}} \\ \frac{-1 + \sqrt{3}}{2\sqrt{3}} \\ \frac{-1 - \sqrt{3}}{2\sqrt{3}} \end{bmatrix},
  \theta \equiv -120^\circ
\]
\pagebreak

\section{}
A given vector $v$ is rotated about a unit vector $k$ by angle $\theta$
\given

The rotated vector $w$ is
\[
  w \equiv cos(\theta) v + sin(\theta) (k \times v) + (1 - cos(\theta)) (k.v) k
\]
\rtp
To show that rodriguez’s formula comes from equation 1 it is enough to show that equation 1 comes from rodriguez’s formula.
Consider the terms separately
\[
  cos(\theta) v \equiv
  \begin{bmatrix} v_x c\theta \\ v_y c\theta \\ v_z c\theta \end{bmatrix}
\]
Consider
\[
  k \times v \equiv
  \begin{bmatrix} k_y v_z - k_z v_y \\ k_z v_x - k_x v_z \\ k_x v_y - k_y v_x \end{bmatrix}
\]
\[
  s\theta (k \times v) \equiv
  \begin{bmatrix} s\theta (k_y v_z - k_z v_y) \\ s\theta (k_z v_x - k_x v_z) \\ s\theta (k_x v_y - k_y v_x) \end{bmatrix}
\]
Consider
\[
  k.v \equiv
  k_x v_x + k_y v_y + k_z v_z
\]
\[
  (k.v) k \equiv
  \begin{bmatrix} (k_x v_x + k_y v_y + k_z v_z) k_x \\ (k_x v_x + k_y v_y + k_z v_z) k_y \\ (k_x v_x + k_y v_y + k_z v_z) k_z \end{bmatrix}
\]
\[
  (1 - c\theta) (k.v) k \equiv
  \begin{bmatrix} (1 - c\theta) (k_x v_x + k_y v_y + k_z v_z) k_x \\ (1 - c\theta) (k_x v_x + k_y v_y + k_z v_z) k_y \\ (1 - c\theta) (k_x v_x + k_y v_y + k_z v_z) k_z \end{bmatrix}
\]
Let $1 - c\theta \equiv v\theta$
\[
  (1 - c\theta) (k.v) k \equiv
  \begin{bmatrix} v\theta (k_x v_x + k_y v_y + k_z v_z) k_x \\ v\theta (k_x v_x + k_y v_y + k_z v_z) k_y \\ v\theta (k_x v_x + k_y v_y + k_z v_z) k_z \end{bmatrix}
\]
Now adding all the terms
\[
  w
  \equiv
  cos(\theta) v + sin(\theta) (k \times v) + (1 - cos(\theta)) (k.v) k
\]
\[
  w
  \equiv
  \begin{bmatrix} v_x c\theta \\ v_y c\theta \\ v_z c\theta \end{bmatrix}
  +
  \begin{bmatrix} s\theta (k_y v_z - k_z v_y) \\ s\theta (k_z v_x - k_x v_z) \\ s\theta (k_x v_y - k_y v_x) \end{bmatrix}
  +
  \begin{bmatrix} v\theta (k_x v_x + k_y v_y + k_z v_z) k_x \\ v\theta (k_x v_x + k_y v_y + k_z v_z) k_y \\ v\theta (k_x v_x + k_y v_y + k_z v_z) k_z \end{bmatrix}
\]
Adding terms
\[
  w
  \equiv
  \begin{bmatrix}
  v_x c\theta + s\theta (k_y v_z - k_z v_y) + v\theta (k_x v_x + k_y v_y + k_z v_z) k_x \\
  v_y c\theta + s\theta (k_z v_x - k_x v_z) + v\theta (k_x v_x + k_y v_y + k_z v_z) k_y \\
  v_z c\theta + s\theta (k_x v_y - k_y v_x) + v\theta (k_x v_x + k_y v_y + k_z v_z) k_z
  \end{bmatrix}
\]
Rearranging terms we have
\[
  w
  \equiv
  \begin{bmatrix}
    (k_x^2v\theta + c\theta)v_x + (k_xk_yv\theta - k_zs\theta)v_y + (k_xk_zv\theta + k_ys\theta)v_z\\
    (k_xk_yv\theta + k_zs\theta)v_x + (k_y^2v\theta + c\theta)v_y + (k_yk_zv\theta - k_xs\theta)v_z \\
    (k_xk_zv\theta - k_ys\theta)v_x + (k_yk_zv\theta + k_xs\theta)v_y +(k_z^2v\theta + c\theta)v_z
  \end{bmatrix}
\]
Rewriting the right matrix as product of two matrices we have
\[
  w
  \equiv
  \begin{bmatrix}
    k_x^2v\theta + c\theta & k_xk_yv\theta - k_zs\theta & k_xk_zv\theta + k_ys\theta\\
    k_xk_yv\theta + k_zs\theta & k_y^2v\theta + c\theta & k_yk_zv\theta - k_xs\theta \\
    k_xk_zv\theta - k_ys\theta & k_yk_zv\theta + k_xs\theta & k_z^2v\theta + c\theta
  \end{bmatrix}
  \begin{bmatrix} v_x \\ v_y \\ v_z \end{bmatrix}
\]
\[
  w
  \equiv
  \begin{bmatrix}
    k_x^2v\theta + c\theta & k_xk_yv\theta - k_zs\theta & k_xk_zv\theta + k_ys\theta\\
    k_xk_yv\theta + k_zs\theta & k_y^2v\theta + c\theta & k_yk_zv\theta - k_xs\theta \\
    k_xk_zv\theta - k_ys\theta & k_yk_zv\theta + k_xs\theta & k_z^2v\theta + c\theta
  \end{bmatrix}
  v
\]
The latest equation is identical to equation 1.
Thus we proved that equation 1 comes from rodriguez’s formula.
To derive rodriguez’s formula from equation 1 one can just reverse the steps until now, though is a very unnatural way to think.

\subsection*{Getting rodriguez’s formula from scratch}
\subsubsection*{Perpendicular case}
Consider a case where $v$ is perpendicular to $k$.
Therefore $v$ and (the rotated vector) $w$ lie in the plane perpendicular to $k$.
Consider $k \times v$ which is perpendicular to both $k$ and $v$ and lies on plane perpendicular to $k$ as illustrated in the figures below.
\begin{figure}[h]
  \centering
  \tdplotsetmaincoords{60}{120}
  \begin{tikzpicture} [scale=3, tdplot_main_coords, axis/.style={->,blue,thick},
    vector/.style={-stealth,red,very thick},
    vector guide/.style={dashed,red,thick}]

  \coordinate (O) at (0,0,0);

  \pgfmathsetmacro{\ax}{0.707}
  \pgfmathsetmacro{\ay}{0.707}
  \pgfmathsetmacro{\az}{0}

  \coordinate (W) at (\ax,\ay,\az);
  \coordinate (V) at (1, 0, 0);

  \draw[axis] (0,0,0) -- (0,1,0) node[anchor=north west]{$k \times v$};
  \draw[axis] (O) -- (V) node[anchor=north west]{v};
  \draw[axis] (O) -- (W) node[anchor=north west]{w};
  \draw[vector] (0,0,0) -- (0,0,1) node[anchor=south]{k};

  \draw[vector guide] (\ax,\ay,0) -- (0,\ay,0);
  \draw[vector guide] (\ax,\ay,0) -- (\ax,0,0);
  \end{tikzpicture}

  \begin{tikzpicture}
  \node [] at (0.5,0.25) {$\theta$};
  \draw [thick, ->] (0,0) -- (0,5);
  \node [above] at (0,5) {$k \times v$};
  \draw [thick, ->] (0,0) -- (5,0);
  \node [right] at (5,0) {$v$};
  \node [left] at (0,0) {($k$, out of plane)};
  \draw [thick, ->] (0,0) -- (3.55,3.55);
  \node [right] at (3.55,3.55) {$w$};
  \draw [dashed, -] (3.55,0) -- (3.55,3.55);
  \node [below] at (2,0) {$\Vert v \Vert cos(\theta)$};
  \draw [dashed, -] (0,3.55) -- (3.55,3.55);
  \node [left] at (0,2) {$\Vert v \Vert sin(\theta)$};
  \end{tikzpicture}
  \caption{Perpendicular case - 3D, 2D top view}
\end{figure}

As the angle b/w $v$ and $w$ is $\theta$ and the length of rotated vector is identical to length of original vector we have
\[
  w . \hat{v} \equiv \Vert w \Vert \Vert \hat{v} \Vert cos(\theta) \equiv \Vert w \Vert cos(\theta) \equiv \Vert v \Vert cos(\theta)
\]
\[
  w . (k \times \hat{v}) \equiv \Vert w \Vert \Vert (k \times \hat{v}) \Vert cos(90 - \theta) \equiv \Vert w \Vert sin(\theta) \equiv \Vert v \Vert sin(\theta)
\]
As $k$, $v$, and $k \times v $ form a 3D basis, using the rule of vector addition we can build $w$ in terms of $v$ and $k \times v$
\[
  w \equiv cos(\theta) \Vert v \Vert \hat{v} + sin(\theta) \Vert v \Vert (k \times \hat{v})
\]
\[
  w \equiv cos(\theta) v + sin(\theta) (k \times \Vert v \Vert \hat{v})
\]
\[
  w \equiv cos(\theta) v + sin(\theta) (k \times v)
\]
Therefore we expressed rotated vector $w$ in terms of axis vector $k$, original vector v and angle $\theta$.

\subsubsection*{General case}
Now consider a case where $v$ is not perpendicular to $k$.
We can split $v$ into two parts $v_{parallel}$ which is parallel to $k$ and $v_{perpendicular}$ which is perpendicular to $k$ as illustrated in the figure below.
\begin{figure}[h]
  \centering
  \tdplotsetmaincoords{60}{120}
  \begin{tikzpicture} [scale=3, tdplot_main_coords, axis/.style={->,red,thick},
  vector/.style={-stealth,blue,very thick},
  vector guide/.style={dashed,red,thick}]

  \coordinate (O) at (0,0,0);

  \pgfmathsetmacro{\ax}{0.8}
  \pgfmathsetmacro{\ay}{0.8}
  \pgfmathsetmacro{\az}{0.8}

  \coordinate (V) at (\ax,0,\az);
  \coordinate (W) at (\ax,\ay,\az);

  \draw[axis] (0,0,0) -- (1,0,0) node[anchor=north east]{};
  \draw[axis] (0,0,0) -- (0,1,0) node[anchor=north west]{};
  \draw[axis] (0,0,0) -- (0,0,1) node[anchor=south]{$k$};

  \draw[vector] (O) -- (V);
  \node[anchor=east] at (V){$v$};
  \draw[vector] (O) -- (W);
  \node[anchor=west] at (W){$w$};
  \draw[vector]         (O) -- (\ax,\ay,0);
  \node[anchor=west] at (\ax,\ay,0){$w_{perpendicular}$};
  \draw[vector]         (O) -- (0,0,\az);
  \node[anchor=west] at (0,0,\az){$v_{parallel}$};
  \draw[vector]         (O) -- (\ax,0,0);
  \node[anchor=south] at (\ax,0,0){$v_{perpendicular}$};
  \node[anchor=north] at (0,0,0){$\theta$};

  \draw[vector guide]         (\ax, 0, 0) -- (V);
  \draw[vector guide]         (0, 0, \az) -- (V);
  \draw[vector guide]         (\ax,\ay,0) -- (W);
  \draw[vector guide]         (0,0,\az) -- (W);
  \end{tikzpicture}
  \caption{General case}
\end{figure}

Therefore
\[
  v \equiv v_{parallel} + v_{perpendicular}
\]
\[
  v_{parallel} \equiv (v . k) k
\]
\[
  v \equiv (v . k) k + v_{perpendicular}
\]
\[
  v_{perpendicular} \equiv v - (v . k) k
\]
The $v_{parallel}$ component doesn't rotate as it is in the direction of axis of rotation.
\[
  w \equiv v_{parallel} + w_{perpendicular}
\]
\[
  w \equiv (v . k) k + w_{perpendicular}
\]
The rotated vector of $v_{perpendicular}$ say $w_{perpendicular}$ can be obtained by method similar to the perpendicular case discussed earlier.
\[
  w_{perpendicular} \equiv cos(\theta) v_{perpendicular} + sin(\theta) (k \times v_{perpendicular})
\]
Substituting $v_{perpendicular}$
\[
  w_{perpendicular} \equiv cos(\theta) (v - (v . k) k) + sin(\theta) (k \times (v - (v . k) k))
\]
\[
  w_{perpendicular} \equiv cos(\theta) (v - (v . k) k) + sin(\theta) (k \times v - (v . k) (k \times k))
\]
As $k \times k \equiv 0$
\[
  w_{perpendicular} \equiv cos(\theta) (v - (v . k) k) + sin(\theta) (k \times v)
\]
Substituting $w_{perpendicular}$ back we have,
\[
  w \equiv (v . k) k + w_{perpendicular}
\]
\[
  w \equiv (v . k) k + cos(\theta) (v - (v . k) k) + sin(\theta) (k \times v)
\]
Rearranging we have
\[
  w \equiv cos(\theta) v + (1 - cos(\theta)) (v . k) k + sin(\theta) (k \times v)
\]
\[
  w \equiv cos(\theta) v + sin(\theta) (k \times v) + (1 - cos(\theta)) (v . k) k
\]
As in all the above analysis $v$ is an arbitrary vector and $k$ is an arbitrary unit vector, from the above formula the required identity is proved.

\pagebreak

\section{}
\subsection*{4.a}
The rotation matrix corresponding to a rotation of $\theta$ about a unit vector $ k \equiv (k_x, k_y, k_z)$ is
\[
  R \equiv
  \begin{bmatrix}
    k_x^2v\theta + c\theta & k_xk_yv\theta - k_zs\theta & k_xk_zv\theta + k_ys\theta\\
    k_xk_yv\theta + k_zs\theta & k_y^2v\theta + c\theta & k_yk_zv\theta - k_xs\theta \\
    k_xk_zv\theta - k_ys\theta & k_yk_zv\theta + k_xs\theta & k_z^2v\theta + c\theta
  \end{bmatrix}
\]
where $v\theta \equiv 1 - c\theta$ from Q1.

The rotation is small enough that
\[
  sin(\theta) \approx \theta
\]
\[
  cos(\theta) \approx 1
\]
\[
  \theta^2 \approx 0
\]
\given

Then,
\[
  v(\theta) \equiv 1 - cos(\theta) \equiv 0
\]

Substituting these values we have
\[
  R \equiv
  \begin{bmatrix}
    1 & -k_z\theta & k_y\theta\\
     k_z\theta & 1 & -k_x\theta \\
     -k_y\theta & k_x\theta & 1
  \end{bmatrix}
\]
\pagebreak

\subsection*{4.b}
Consider two rotations $R_1 \equiv (a, \theta)$ and $R_2 \equiv (b, \phi)$ where first term is the unit vector in fixed frame and second term is angle of rotation.
Therefore
\[
  R_1 \equiv
  \begin{bmatrix}
    1 & -a_z\theta & a_y\theta\\
     a_z\theta & 1 & -a_x\theta \\
     -a_y\theta & a_x\theta & 1
  \end{bmatrix}
  \equiv
  I + S_1
  ,
  S_1 \equiv
  \begin{bmatrix}
    0 & -a_z\theta & a_y\theta\\
     a_z\theta & 0 & -a_x\theta \\
     -a_y\theta & a_x\theta & 0
  \end{bmatrix}
\]
\[
  R_2 \equiv
  \begin{bmatrix}
    1 & -b_z\phi & b_y\phi\\
     b_z\phi & 1 & -b_x\phi \\
     -b_y\phi & b_x\phi & 1
  \end{bmatrix}
  \equiv
  I + S_2
  ,
  S_2 \equiv
  \begin{bmatrix}
    0 & -b_z\phi & b_y\phi\\
     b_z\phi & 0 & -b_x\phi \\
     -b_y\phi & b_x\phi & 0
  \end{bmatrix}
\]
where I is the 3x3 identity matrix.

Consider the composition $R_1$ after $R_2$, the equivalent composite rotation matrix shall be
\[
  R_1 R_2 \equiv (I + S_1) (I + S_2)
\]
\[
  R_1 R_2 \equiv I + S_2 + S_1 + S_1S_2
\]
\[
  R_1 R_2 \equiv I + S_2 + S_1 +
  \begin{bmatrix}
    0 & -a_z\theta & a_y\theta\\
     a_z\theta & 0 & -a_x\theta \\
     -a_y\theta & a_x\theta & 0
  \end{bmatrix}
  \begin{bmatrix}
    0 & -b_z\phi & b_y\phi\\
     b_z\phi & 0 & -b_x\phi \\
     -b_y\phi & b_x\phi & 0
  \end{bmatrix}
\]
\[
  R_1 R_2 \equiv I + S_2 + S_1 +
  \begin{bmatrix}
    c_1\theta\phi & c_2\theta\phi & c_3\theta\phi \\
    c_4\theta\phi & c_5\theta\phi & c_6\theta\phi \\
    c_7\theta\phi & c_8\theta\phi & c_9\theta\phi
  \end{bmatrix}
\]
where $c_i$ is some function of $(a_x, a_y, a_z, b_x, b_y, b_z)$. But as the rotations are small enough such that
\[
  \theta\phi \approx 0
\]
we have
\[
  {\color{green} R_1 R_2 \equiv I + S_2 + S_1}
\]

Consider the composition $R_2$ after $R_1$, the equivalent composite rotation matrix shall be
\[
  R_2 R_1 \equiv (I + S_2) (I + S_1)
\]
\[
  R_2 R_1 \equiv I + S_1 + S_2 + S_2S_1
\]
\[
  R_2 R_1 \equiv I + S_1 + S_2 +
  \begin{bmatrix}
    0 & -b_z\phi & b_y\phi\\
     b_z\phi & 0 & -b_x\phi \\
     -b_y\phi & b_x\phi & 0
  \end{bmatrix}
  \begin{bmatrix}
    0 & -a_z\theta & a_y\theta\\
     a_z\theta & 0 & -a_x\theta \\
     -a_y\theta & a_x\theta & 0
  \end{bmatrix}
\]
\[
  R_2 R_1 \equiv I + S_1 + S_2 +
  \begin{bmatrix}
    t_1\theta\phi & t_2\theta\phi & t_3\theta\phi \\
    t_4\theta\phi & t_5\theta\phi & t_6\theta\phi \\
    t_7\theta\phi & t_8\theta\phi & t_9\theta\phi
  \end{bmatrix}
\]
where $t_i$ is some function of $(a_x, a_y, a_z, b_x, b_y, b_z)$. But as the rotations are small enough such that
\[
  \theta\phi \approx 0
\]
we have
\[
  {\color{blue} R_2 R_1 \equiv I + S_1 + S_2}
\]
Hence
\[
  {\color{green} R_1R_2} \equiv {\color{blue} R_2R_1}
\]
Since $R_1, R_2$ are rotation matrices for arbitrary small rotations, small rotations commute.
\pagebreak

\section{}
\[
  q_1 \equiv a + b \hat{i} + c \hat{j} + d \hat{k}
\]
\[
  q_2 \equiv e + f \hat{i} + g \hat{j} + h \hat{k}
\]
\[
  q_3 \equiv s + t \hat{i} + u \hat{j} + v \hat{k}
\]
are three quaternions
\given

\[
  q_1(q_2q_3) \equiv (q_1q_2)q_3
\]
\rtp

The product of two quaternions $ q_1 \equiv (r_1, \vv{1}) $ and $ q_2 \equiv (r_2, \vv{2}) $ is
\[
  q_1q_2 \equiv (r_1 r_2 - \vv{1} . \vv{2}, r_1 \vv{2} + r_2 \vv{1} + \vv{1}\times\vv{2})
\]
\fromlectures

Let
\[
  q_1 \equiv a + b \hat{i} + c \hat{j} + d \hat{k} \equiv (r_1, \vv{1})
\]
\[
  q_2 \equiv e + f \hat{i} + g \hat{j} + h \hat{k} \equiv (r_2, \vv{2})
\]
\[
  q_3 \equiv s + t \hat{i} + u \hat{j} + v \hat{k} \equiv (r_3, \vv{3})
\]
where $r_i, \vv{i}$ are real and vector parts of the $i^{th}$ quaternion respectively

\subsubsection*{Expanding $q_1(q_2q_3)$}
Consider
\[
  q_1(q_2q_3) \equiv (r_1, \vv{1}) ((r_2, \vv{2})(r_3, \vv{3}))
\]
\[
  q_1(q_2q_3) \equiv (r_1, \vv{1}) (r_2r_3 - \vv{2}.\vv{3}, r_2 \vv{3} + r_3 \vv{2} + \vv{2}\times\vv{3})
\]
\[
  q_1(q_2q_3) \equiv (P, Q)
\]
where
\[
  P \equiv r_1(r_2r_3 - \vv{2}.\vv{3}) - \vv{1}.(r_2 \vv{3} + r_3 \vv{2} + \vv{2}\times\vv{3})
\]
\[
  Q \equiv  r_1(r_2 \vv{3} + r_3 \vv{2} + \vv{2}\times\vv{3})
    + (r_2r_3 - \vv{2}.\vv{3})\vv{1}
    + \vv{1} \times (r_2 \vv{3} + r_3 \vv{2} + \vv{2}\times\vv{3})
\]
Rearranging beautifully we get
\[
  q_1(q_2q_3) \equiv (P, Q)
\]
where
\[
  P \equiv r_1r_2r_3 - r_1\vv{2}.\vv{3} - r_2\vv{1}.\vv{3} - r_3\vv{1}.\vv{2} - {\color{green} \vv{1} . (\vv{2}\times\vv{3})}
\]
\[
  Q \equiv
  r_1r_2\vv{3}
  + r_1r_3\vv{2}
  + r_2r_3\vv{1}
  + r_1 \vv{2}\times\vv{3}
  + r_2 \vv{1}\times\vv{3}
  + r_3 \vv{1}\times\vv{2}
  {\color{blue}
  - (\vv{2}.\vv{3})\vv{1}
  + \vv{1} \times (\vv{2}\times\vv{3})}
\]

\subsubsection*{Expanding $(q_1q_2)q_3$}
Consider
\[
  (q_1q_2)q_3 \equiv ((r_1, \vv{1})(r_2, \vv{2}))(r_3, \vv{3})
\]
\[
  (q_1q_2)q_3 \equiv (r_1r_2 - \vv{1}.\vv{2}, r_1 \vv{2} + r_2 \vv{1} + \vv{1}\times\vv{2}) (r_3, \vv{3})
\]
\[
  (q_1q_2)q_3 \equiv (R, S)
\]
where
\[
  R \equiv (r_1r_2 - \vv{1}.\vv{2})r_3 - (r_1 \vv{2} + r_2 \vv{1} + \vv{1}\times\vv{2}).\vv{3}
\]
\[
  S \equiv
    r_3(r_1 \vv{2} + r_2 \vv{1} + \vv{1}\times\vv{2})
    + (r_1r_2 - \vv{1}.\vv{2})\vv{3}
    + (r_1 \vv{2} + r_2 \vv{1} + \vv{1}\times\vv{2}) \times \vv{3}
\]
Rearranging beautifully we get
\[
  q_1(q_2q_3) \equiv (R, S)
\]
where
\[
  R \equiv r_1r_2r_3 - r_1\vv{2}.\vv{3} - r_2\vv{1}.\vv{3} - r_3\vv{1}.\vv{2} - {\color{green} (\vv{1}\times\vv{2}).\vv{3}}
\]
\[
  S \equiv
  r_1r_2\vv{3}
  + r_1r_3\vv{2}
  + r_2r_3\vv{1}
  + r_1 \vv{2}\times\vv{3}
  + r_2 \vv{1}\times\vv{3}
  + r_3 \vv{1}\times\vv{2}
  {\color{blue}
  - (\vv{1}.\vv{2})\vv{3}
  + (\vv{1}\times\vv{2})\times\vv{3}}
\]

\subsubsection*{Equivalence}
Except the colored terms all other terms are identical.
But we know that
\[
  \vv{1}.(\vv{2}\times\vv{3}) \equiv (\vv{1}\times\vv{2}).\vv{3}
\]
from the properties of vector cross products, as it represents the signed volume of parallelepiped formed by vectors $\vv{1}, \vv{2}, \vv{3}$.
Therefore
\[
P \equiv R
\]
We also know the following triple product rule of cross products.
\[
  \vv{1} \times (\vv{2}\times\vv{3})
  \equiv
  \vv{2} (\vv{1}\vv{3})
  - \vv{3} (\vv{1}\vv{2})
\]
Expanding the colored terms in Q we have
\[
  {\color{blue}
  - (\vv{2}.\vv{3})\vv{1}
  + \vv{1} \times (\vv{2}\times\vv{3})
  }
  \equiv
  - \vv{1} (\vv{2}.\vv{3})
  + \vv{2} (\vv{1}\vv{3})
  - \vv{3} (\vv{1}\vv{2})
\]
Expanding the colored terms in S we have
\[
  {\color{blue}
  - (\vv{1}.\vv{2})\vv{3}
  + (\vv{1}\times\vv{2})\times\vv{3}
  }
  \equiv
  - (\vv{1}.\vv{2})\vv{3}
  - \vv{3}\times(\vv{1}\times\vv{2})
  \equiv
  - \vv{1} (\vv{2}.\vv{3})
  + \vv{2} (\vv{1}\vv{3})
  - \vv{3} (\vv{1}\vv{2})
\]

Therefore
\[
Q \equiv S
\]
\[
  (P, Q) \equiv (R, S)
\]
\[
  q_1(q_2q_3) \equiv (q_1q_2)q_3
\]
As $q_1, q_2, q_3$ are arbitrary quaternions, multiplication of quaternions is associative.
\end{document}


%
% 61
%
\chapter{The Theory of Riemann Integration}

\Section{4}{1}{The concept of integration.}

The reader is doubtless familiar with the idea of integration as the
operation inverse to that of differentiation; and he is equally well
aware that the integral (in this sense) of a given elementary function
is not always expressible in terms of elementary functions. In order
therefore to give a definition of the integral of a function which
shall be always available, even though it is not practicable to obtain
a function of which the given function is the differential
coefficient, we have recourse to the result that the integral* o f x)
between the limits a and h is the area bounded by the curve y =f(x),
the axis of cc and the ordinates x = a, x = b. We proceed to frame a
formal definition of integration with this idea as the starting-point.

\Subsection{4}{1}{1}{Upper and lower integrals'f.}

Let f(x) be a bounded function of x in the range a, b). Divide the
interval at the points Xi,Xo, ... Xn-iia x - x ... Xn-i b). Let U, L
be the bounds of /(a;) in the range (a, b), and let Ur, L be the
bounds of f(x) in the range (xr-i, Xr), where Xq = a, Xn=b.

Consider the sums:|:

Sn = U, (iCi - a) +Uo Xn-X,)+ ...+ Un (b - Xa-,), Sn = L, X - a) + Z/2
( 2 - i) +    + Ln (b - Xn-i).

Then U(b- a) Sn s., L b- a).

For a given n, Sn and s are bounded functions of x, x, ... n-i- Let
their lower and upper bounds § respectively be S, Sn, so that Sn, s
depend only on n and on the form of f x), and not on the particular
way of dividing the interval into n parts.

* Defined as the (elementary) function whose differential coefficient
is/(x).

t The following procedure for establishing existence theorems
concerning integrals is based on that given by Goursat, Cours d'
Analyse, i. Ch. iv. The concepts of upper and lower integrals are due
to Darboux, Ann. de I'Ecole norm. sup. (2) iv. (1875), p. 64.

+ The reader will find a figure of great assistance in following the
argument of this section. Sn and s represent the sums of the areas of
a number of rectangles which are respectively greater and less than
the area bounded by y=f(x), x-a, x-h and ?/ = 0, if this area be
assumed to exist.

§ The bounds of a function of n variables are defined in just the same
manner as the bounds of a function of a single variable \hardsubsectionref{3}{6}{2}).

%
% 62
%

Let the lower and upper bounds of these functions of n be S, s. Then

Sn > S, Sn S.

We proceed to shew that s is at most equal to S; i.e. S' s.

Let the intervals (a, x ), x-, x., ... be divided into smaller
intervals by new points of subdivision, and let

a,y,y, ... yu-i, yk = i), yk+i,  yi-i, yi = 2), yi+1,  Vm-i, h be
the end points of the smaller intervals; let U L,.' be the bounds of
/( ) in the interval y,-i, yr)-

m m

Let T,, = X yr- yr-i) UJ, t,n = t y,. - yr-i) L,!.

r=\ r=l

Since Ui, U.2, ... Uk do not exceed JJi, it follows without difficulty
that

Now consider the subdivision of (a, b) into intervals by the points
x-y, X2, ... Xn-\, and also the subdivision by a different set of
points a? x, ... x'n'-i- Let S'n',s'n' be the sums for the second
kind of sub- division which correspond to the sums *S, Sn for the
first kind of subdivision. Take all the points x, ... Xn-i] x, ...
x'n'\ y as the points y, y., ... y .

Then 8n T, t,, Sn,

and S'n' T n tm s'n' .

Hence every expression of the type Sn exceeds (or at least equals)
every expression of the type s'n'; and therefore S cannot be less
than s.

[For \ i S<s and s - S - 27] we could find an Sn and an s'n' such that
g - S<r], s - s'n'<'n and so s'n'>Sn, which is impossible.]

The bound S is called the upper integral off(x), and is written 1 f(x)
dx;

J a

s is called the lower integral, and written I / x) dx.

J a

If S = s, their common value is called the integral of f(x) taken
between the limits* of integration a and b.

The integral is written I f x)dx. .

ra rb

We define | f x)dx, when a< b, to mean - I f(x)dx. Exam'ple 1, I /
(*') + (*-') dx = \ f(x) dx+ l (x) dx.

J a J a J a

Example 2. By means of example 1, define the integral of a continuous
complex function of a real variable.

* ' Extreme values ' would be a more appropriate term but ' limits '
has the sanction of custom. 'Termini' has been suggested by Lamb,
Infinitesimal Calculus (1897), p. 207.

%
% 63
%

\Subsection{4}{1}{2}{Riemann's condition of integrability*.}

A function is said to be ' integrable in the sense of Riemann ' if
(with the notation of \hardsubsectionref{4}{1}{1}) Sn and s,i have a common limit (called
the Riemann integral of the function) when the number of intervals
x,.\ -, x ) tends to infinity in such a way that the length of the
longest of them tends to zero.

The necessa7-y and sufficient condition that a bounded function should
he integrahle is that S - Sn should teiid to zero luhen the numher of
intervals (xr-i, Xr) tends to infinity in such a way that the length
of the longest tends to zero.

The condition is obviously necessary, for if S and s,i have a common
limit n - Sn - ► as 71 - > 30 . And it is sufficient; for, since Sn
S' s s,i, it follows that if lim (Sn - Sn) = 0, then

lim *S' = lim s = S = s.

Note. A continuous function f(x) is 'integrable.' For, given e, we can
find 8 such that \ f(af) - f x")\ < (l b-a) whenever \ x' - x"\ < 8.
Take all the intervals Xg\ i, x-g) less than 8, and then Ug- Lg<€/ b -
a) and so >S' - s <e; therefore <S' - s - -0 under the circumstances
.specified in the condition of integrahility.

Corollary. If <S' and s have the same limit S for one mode of
subdivision of (a, h) into intervals of the specified kind, the limits
of .S' and of s for any other such mode of subdivision are both 8.

Example I. The product of two integi'able functions is an integrable
function.

Example 2. A function which is continuous except at a finite number of
ordinary discontinuities is integrable.

\ li f(x) have an ordinary discontinuity at c, enclose c in an
interval of length S,; given f, we can find 8 so that j f x')-f x) \
< e when i x' -x \ <8 and x, x' are not in this interval.

Then *S' -s,j f (6-a-8i) + /'Si, where k is the greatest value of \ f
x')-f x)\, when X, x' lie in the interval.

When Si- 0, y(-- |/(c + 0)-/(c-0), and hence lim (.S' -s )=0.]

 -*

Example 3. A function with limited total fluctuation and a finite
number of ordinary discontinuities is integrable. (See \hardsubsectionref{3}{6}{4} example
2.)

\Subsection{4}{1}{3}{A general theorem on integration.}

Let /(a;) be integrable, and let e be any positive number. Then it is
possible to choose S so that

n rh

t xp - Xj,\ i)f(x'p\ i) - f x)dx < 6,

p=\ J a

provided that Xy - Xp\ i- h, Xp\ i x'p\ i%Xp.

* Biemann (Ges. Math. Werke, p. 239) bases his definition of an
integral on the limit of the sum occurring in § -i-lS; but it is then
difficult to prove the uniqueness of the limit. A more general
definition of integration (which is of very great importance in the
modern theory of Functions of Real Variables) has been given by
Lebesgue, Annali di Mat. (3) vn. (1902), pp. 231-359. See also his
Lecons sur V integration (Paris, 1904).

%
% 64
%

To prove the theorem we observe that, given e, we can choose the
length of the longest interval, B, so small that S - Sn < e.

w

Also Sn> S ( - \ i)/(a?' -i) Sn,

p = l

  a

Therefore

  rb

2 xp - Xp\ )f(a;'p\,) - f(x) dx

9 = 1 J a

 s.,

  f-Jn ' n

< 6.

As an example* of the evaluation of a definite integral directly from
the theorem of this section consider I " - j, where X<1.

Jo (1- 2)2

Take S= - arc sin X and let,?,= sin s8, (0 <s8 <h tt), so that

 s+i-A's=2 sin |S cos (s+ ) 8< S;

also let Xg = sin (s + i) 8.

, P . c - - s-i sin sS - sin (5 - 1)S

Then 2 - '- = 2 \,.

s=i(i\ y2 \ j)i .=1 cos(s-A)S

= 2/9 sin 2 S

= arc sin X. sin |S/(JS) .

By taking p sufficiently large we can make

P dx I Xg-Xs-i

Jo (l\,,.2)i,s=l(l\ . '2 \ j)4

arbitrarily small.

We can also make arc sin X . < -j-| 1

arbitrarily small.

That is, given an arbitrary number f, we can make

P dx

/ i~

<e

arc sin X

by taking p sufficiently large. But the expression now under
consideration does not

depend on p; and therefore it must be zero; for if not we could take
c to be less than it,

and we should have a contradiction.

rx f g That is to say I '- - =arc sin X.

Jo (i\ .' )2

Example 1. Shew that

X 2x (n - l)x

I+COS- + COS f-...+cos -

,. 71 n n sm

Iim - - - . - - - - - - = .

n-*-'x> *'' -

Example 2. If f(x) has ordinary discontinuities at the points aj, 02,
..., then

fb ( fu -S, fa.,-S., [b 1

f x)dx = \ \ m\ \ + +...+ f x)dx\,

J a \ J a J a, +6, J ax + <c J

where the limit is taken by making 81, S2, ... §, ei, t i  f* tend
to +0 independently. * Netto, Zeitschriftfilr Math, und Phys. xl.
(1895).

%
% 65
%

Example 3. If /( ) is integrable when i x i and if, when Oj a < 6 < 6i
, we write

/ f x)dx = <i> a, b), and if/(6 + 0) exists, then

lim < (,\& + fi)-> K\&) ( o)

Deduce that, i f(x) is continuous at a and b,

d\

da

jjix) dx= -f a), -I jjix) dx=f b). Bxample 4. Prove by differentiation
that, if (f> x) is a continuous function of ./; and

dx

-y- a continuous function of t, then

at

fxi l ft fir

 < x)dx=\ \ x)'j dt.

Example 5. If /' x) and < ' x) are continuous when a x b, shew from
example 3 that

r / (x) <i> o;) dx + J'l 4>' x)f x) dx=f b) < (b) -f a) cf> (a).

Example 6. If/(.r) is integrable in the range (a, c) and 6 c, shew
that I f(x) dx

J a is a continuous function of b.

\Subsection{4}{1}{4}{J/c ?i Fa we Theorems.}

The two following general theorems are frequently useful.

(I) Let U and L be the upper and lower bounds of the integrable
function /(.r) in the range (a, b).

Then from the definition of an integral it is obvious that

J' U-f x)] dx, j ' fj(x) L) dx

are not negative; and so

U b-a)- l f x)dx L b-a).

This is known as the First Mean Value Theorem.

li' f(x) is contimious we can find a number | .such that a- b and such
that/( ) has any given value lying between U and L \hardsubsectionref{3}{6}{3}). Therefore
we can find | such that

rf x)dx = b-a)f \$).

J a

If F(x) has a continuous differential coefficient F' (x) in the range
(a, 6), we have, on

writing F' (x) for f(x),

F b)-F d) = b-a)F' )

for some value of such that a b.

Example. lif x) is continuous and ( x)' 0, shew that can be found such
that

' fix) cf> (x) dx =f (I) / % (x) dx.

a J a.

W. M. A.

%
% 66
%

(11) Let /(.? ) and 4> .v) be integrable in the range (o, b) and let
(a-) be a positive decreasing function of .r. Then Bonnefs* form of
the Second Mean Value Theorem is that a number exists such that a | 6,
and

 " f x)ci> x)dx 4> a) \ \ f x)dx. \ y'

J a J a

For, with the notation of §§ 4'1-4'13, consider the sum

p ♦ .;S'= 2 Xs-x,\ i)f x,\ )(i> x,\ ).

s=l

Writing x - x y) f x,\ i) = a,\ i, Xs-i) = 4>s-\, o + i + --- + 08 =
s, 'e have

Each term in the summation is increased by writing b for 6g\ i and
decreased by writing b for ftg\ i, if b, b be the greatest and least
of 6o, 6i, ... 6p\ i; and so b(j)(, S b(Po-

m

Therefore S lies between the greatest and least of the sums ( ) xq) 2
(xg-Xg\ i)f Xg\ i)

s=l

where m = l, 2, 3, ... p. But, given e, we can find 8 such that, when
Xg-Xg\ i<d,

p f p I

2 x, - x,\ i)f Xs i) (t> (.r,\ i) - I f(x) (f) (x) dx < e,

S=l J 0 I

m Cxra [

< (:ro) 2 X, -Xs-i)/ (X, \ i) - < ( o) / / ( ) < *- < f, s=l a I

and so, writing a, b for a'q, . p, we find that / f x)(j> x)dx lies
between the upper and

J a'

lower bounds ott < (a) I ' f .v)d.v±2e, where j may take all values
between a and ?>.

Let C and L be the upper and lower bounds of </> (a) j f(x) dx.

J a

fh

Then U+ 2e I /'(.r) < ( 0 dx' L-2e for a jjositive values of e;
therefore

r I f (x) cfi (x) dx L.

Since (j) a) I \ f(x) dx qua function of j takes all values between
its upper and lower J

bounds, there is some value, .say, of |i for which it is equal to I f
(x) (f> (x) dx. This proves the Second Mean Value Theorem.

E.rarnple. By writing ( x) -(f> b)\ in place of (f) (.v) in Bonnet's
form of the mean value theorem, .shew that if < (x) is a monotonic
function, then a number | exists such that a \$ b and

\ f x)(l> x)dx = 4> a) j f x)dx + 4) b) j f x)dx.

\addexamplecitation{Du Bois Reymond.}

* Journal de Math. xiv. (1849), p. 249. The proof given is a modified
form of an iuvestigatiou due to Holder, Gdtt. Nach. (1889), pp. 38-47.

+ By § 413 example 6, since /(.r) is bounded, I ' f(x) d.v is a
continuous function of fj.

%
% 67
%

\Section{4}{2}{Differentiation of integrals containing a parameter.}

The equation* f x, a)dx=\ dx is true if f(x, a) possesses a

ace J (I (I vCL

Riemann integral with respect to x and fa. = \ is a continuous
function of hoth-f the variables x and a.

For I- '/(., ) <fa = lim f .Aj;.\ ° + A)-/( . )

eta j a h-f-O .' a h

if this limit exists. But, by the first mean value theorem, since / is
a continuous function of a, the second integrand is fa x, a + 6h),
where

But, for any given e, a number 8 independent of x exists (since the
con- tinuity of fa is uniform]: with respect to the variable x) such
that

\ fa x, a) -fa (x, a) I < e/(6 - a), whenever | a' - a | < S.

Taking j A | < S we see that ! 6h | < 8, and so whenever \ h < 8,

[H x, a + h) -fix, a) J i *,,,, [ ., m x w m

 - -! y - J \ ' / dx- \ /a (, a) dx I fa (x, a + Oh) - / (x, a) \ dx

< e.

Therefore by the definition of a limit of a function \hardsectionref{3}{2}), lim
i'f(-. + h)-f(, .a)

h O J a h

I"*

exists and is equal to fadx.

J a

Example 1. If a, b be not constant.s but functions of a with
continuous differential coefficients, shew that

 |'/(.- a)d.v=f b, a) -/(a, ) +/ fj:.:

Example 2. If /(.r, a) is a continuous function of both variables, / f
x, a)dx is a

J a continuous function of a.

* This formula was given by Leibniz, without specifying the
restrictions laid on/(.r, a).

t (p x, y) is defined to be a continuous function of both variables
if, given e, we can find 5 such that | 4> x', y') - (/> (x, y)\ < €
whenever (x' - x)' + (y' - y)' -<S. It can be shewn by \hardsectionref{3}{6} that if
(x, y) is a continuous function of both variables at all points of a
closed region in a Cartesian diagram, it is uniformly continuous
throughout the region (the proof is almost identical with that of §
3-61). It should be noticed that, if (.r, y) is a continuous function
of each variable, it is not necessarily a continuous function of both
; as an example take

 [x,y)=. p!, 0(0,0) 1;

this is a continuous function of x and of y at (0, 0), but not of both
x and y.

X It is obvious that it would have been sufficient to assume that /
had a Riemann integral and was a continuous function of a (the
continuity being uniform with respect to x), instead of assuming that
/ was a continuous function of both variables. This is actually done
by Hobson, FuJictions of a Real Variable, p. 599.

5-2

%
% 68
%

\Section{4}{3}{Double integrals and repeated integrals.}

'Letf x, y) be a function which is continuous with regard to both of
the variables x and y, when a x h, a y - /3,

By \hardsectionref{4}{2} example 2 it is clear that

j 1 1 /( ' y) dy\ dx, j U J x, y) dx\ dy both exist. These are called
repeated integrals.

Also, as in \hardsubsectionref{3}{6}{2}, f(x, y), being a continuous function of both
variables, attains its upper and lower bounds.

Consider the range of values of x and y to be the points inside and on
a rectangle in a Cartesian diagram; divide it into nv rectangles b -
lines parallel to the axes.

Let Z7 i,, L,n, be the upper and lower bounds of f x, y) in one of
the smaller rectangles whose area is, say, Ayn,,j.', and let

71 V n V

- w - m,n -"-m,!!- n,v y -i - j,n - m,/u h, I'- j/t = 1 jj. = 1 ) = 1
;u. = 1

Then *S', >?, \,, and, as in \hardsubsectionref{4}{1}{1}, we can find numbers h,.-, s,,,
which are the lower and upper bounds of Sn,v, V" respectively, the
values of Sn,v, Sn,v depending only on the number of the rectangles
and not on their shapes; and n, s, . We then find the lower and upper
bounds S and s) respectively of,, Sn,v qua functions of n and v;
and S v S s s,, as in §411.

Also, from the uniformity of the continuity of f(x, y), given e, we
can find B such that

'J m,iJ. - Hij/i '" f>

(for all values of m and /i) whenever the sides of all the small
rectangles are less than the number h which depends only on the form
of the function f x, y) and on e.

And then >S', - Sa, < e (6 - a) (/3 - a),

and so S - s < e h - a) (/3 - a).

But S and s are independent of e, and so S = s.

The common value of S and s is called the double integral of f x, y)
and is written

f(x, y) (dxdy).

It is easy to shew that the reijeated integrals and the double
integral are all equal when f :c, y) is a continuous function of both
variables.

%
% 69
%

For let Y j, A, be the uppei- and lower bounds of

as .V varies between x -i and a:, .

Then 2 Y, (x, - x, -i) > \ f x,y)dy\ dx A, (a;,,, - x,,,\ .

"1 = 1 <' \ 3 a. ) i = l

But* 2 Ura,,.i y.-y,.-i) \,n .\ n 2 Z,,m (y/x - m-i)-

M = l /n = l

Multiplying these last inequalities by x -Xm x, using the preceding
inequalities and summing, we get

2 2 r .M,. / ]/ f x,y)dy\ dx 2 2 L,, A,;

 ( = 1 pi = l J a \ J a. ) m = l /x = l

and so, proceeding to the limit,

'S' £ [jy x,y)dy dx s.

But ' =s=l lfix,y) dxdy),

and so one of the repeated integrals is equal to the double integral.
Similarly the other repeated integral is equal to the double integral.

Corollary. If/(.v, y) be a continuous function of both variables,

\Section{4}{4}{Infinite integrals.}

If lini 1 /(.r)c?j;j exists, we denote it by f x)dx; and the limit in
question is called an infinite integral;. Examples.

,. r d'x,. (I \ \ 1

  j ( ' + a')' " b V 2 (62 + a') + 2a2y' 2a '

(3) By integrating by parts, shew that / t"e~ dt = n. \addexamplecitation{Euler.}

J

Similarly we define / f(x)dx to mean lim / f(x)dx, if this limit
exists; and

J -X a- - -o J a

/f x)dx is defined as / f(x)dx+l f .v)dx. In this last definition the
choice -00 J -<x>' J a

of a is a matter of indifference.

* The upper bound of f x, y) in the rectangle --i,, is not less than
the upper bound of /(.r, y) on that portion of the line .r = | which
lies in the rectangle.

t This phrase, due to Hardy, Proc. London Math. Soc. xxxiv. (1902), p.
16, suggests the analogy between an infinite integral and an infinite
series.

%
% 70
%

\Subsection{4}{4}{1}{Infinite integrals of continuous functions. Conditions for convergence.}

A necessary and sufficient condition for the convergence of f x)dx is

J a

that, corresponding to any positive number e, a positive number X
should exist such that f(x) dec \ < e whenever

The condition is obviously necessary; to prove that it is sufficient,
suppose

ra+n

it is satisfied; then, ii n X -a and n be a positive integer and Sn =
f(so),

. a

we have j Sn+p - Sn\ < €.

Hence, by \hardsubsectionref{2}{2}{2}, Sn tends to a limit, S; and then, if > a + n,

S-i f x)da;\ \ S-\'' ''f(a;)dx + t f(x)da;\

J a ' -a \ J a+n I

<26;

and so lim f(x) dx = S; so that the condition is sufficient.

\Subsection{4}{4}{2}{Uniformity of convergence of an infinite integral.}

The integral f x, a) dx is said to converge uniformly with regard to a

J a

in a given domain of values of a if, corresponding to an arbitrary
positive number e, there exists a number X independent of a such that

J /( > a)dx\ \ <€

for all values of a in the domain and all values of x X.

The reader will see without difficulty on comparing §§ 2'22 and 3'31
with \hardsubsectionref{4}{4}{1} that a necessary and sufficient condition that f x, a) dx
should

.' a

converge uniformly in a given domain is that, corresponding to any
positive number e, there exists a number X independent of a such that

I f(x, a)dx \ < e

\ J x' I

for all values of a in the domain whenever x" x X.

\Subsection{4}{4}{3}{Tests for the convergence of an infinite integral.}

There are conditions for the convergence of an infinite integral
analogous to those given in Chapter II for the convergence of an
infinite series.

The following tests are of special importance.

%
% 71
%

(I) Absolutely convergent integrals. It may be shewn that f x)dx

J a

certainly converges if \ f(a;) | dx does so; and the former integral
is then said to be absolutely convergent. The proof is similar to that
of \hardsubsectionref{2}{3}{2}.

Example. The comparison test. If \ f(x) g x) and / g x) dx converges,
then / f(x) dx converges absolutely.

[Note. It was observed by Dirichlet* that it is not necessary for the
convergence of I f x)dx that f x)-a'0 as x- cc : the reader may see
this by considering the function

/( ) = ( n x n + l- n + l)-' ),

f(x) = n + iyin + l-x) x- n+l) + n+l)- n + l -(n + l)- x n + l),

where n takes all integral values.

For / f(x)dx increa.'ses with and / f x)dx=l n+l)-; whence it follows

without difficulty that / f x)dx converges. But when a- = n + l -i
(?n-l)-2, y'(.t>) =; and so f(x) does not tend to zero.]

(II) The Maclaurin-Cauchyf test. Tf/(A-)>0 and/(x')-*0 steadily,

TODO

f x) dx and S /( ) converge or diverge together. 1 M = l

fm + l

For A -- /( 0 > fix) dx f m + 1 ),

J m n fn+] n+1

and SO 2 f(m) l f x)dx' 2 /(m).

  m = l J 1 wi=2

The first inequality shews that, if the series converges, the
increasing sequence / f x)dx converges \hardsectionref{2}{2}) when - -oo through
integral values, and hence it follows

fx'

without difficulty that / f(.v)dx converges when .r'-*-x; also if the
integral diverges, so does the series.

The second shews that if the series diverges so does the integral, and
if the integral converges so does the series \hardsectionref{2}{2}).

(III) Bertrand'sX test. 1 f(x) = 0 x ~' ), f x)dx converges when X <;
and \ if x) - x~' loga; " ), | f(x) dx converges when X, < 0.

. a

These results are particular cases of the comparison test given in
(I).

* Dirichlet's example was/(.r) = sin .r'-; Journal fiir Math. xvii.
(1837), p. 60. t Maclaurin Flit.vions, i. pp. 289, 290) makes a verbal
statement practically equivalent to this result. Cauchy's result is
given in his Oeuvrcs (2), vii. p. 269. X Journal de Math. vii. (1842),
pp. 38, 39.

%
% 72
%

(IV) Chartiers test for integrals involving periodic functions. If /(
) - steadily as x and if < x) dx is bounded as x <x>,

1 ' a

then f(x) (x) dx is convergent.

J a

For if the upper bound of I (.r) dx \ he A, we can choose X such that
f x)<e/2A

\ J a

when .X > A'; and then by the second mean vahie theorem, when .v" .v'
A', we have I /" " f(x) 6 (x) dx =\ f x') f(x) dx =f x') \ (f) x)dx-
cf) x) dx 2Af x') < f,

I \ / a;'  I J x' \ J a J a

which is the condition for convergence.

I ** Sill

Example I. I dt' converges.

J *'

Example 2. I a; - 1 sin x - ax) dx converges.

\Subsubsection{4}{4}{3}{1}{Tests for uniformity of convergence of an infinite integral f.}

(I) De la Vallee Poussins test . The reader will easily see by using

("00

the reasoning of \hardsubsectionref{3}{3}{4} that f x, a) dx converges uniformly with
regard

to a in a domain of values of a if \ f x, a) | < fi x), where fM x) is
independent

fee r "

of a and /jl (x) dx converges. [For, choosing X so that fx(x)dx<e

rx" when x' x' X, we have f x, a)dx < e, and the choice of X is inde-

J x'

pendent of a.]

/oo

Example. \ x' ~' e~''dx converges uniformly in any interval A, B) such
that

(II) The method of change of variable. This may be ilkist rated by an
example.

Consider / '- dx where a is real.

y " sin ax, /" " sin y,

We have / - 7- ' =, ~ 7~

] 3c' X J ax' y

   dy converges we can find Y such that / - - dy <e when y" y' Y.

y J y y

dx

< 6 whenever | a ' | F; if | a | S > 0, we therefore get

I /"*" sin ax, \ I dx \ < f

I y a;' -' I

* Journal de Math, xviii. (1853), pp. 201-212. It is remarkable that
this test for conditionally convergent integrals should have been
given some years before formal definitions of absolutely convergent
integrals.

t The results of this section and of \hardsubsectionref{4}{4}{4} are due to de la Valine
Poussin, Ann. de la Soc. Scientifique de Bruxelles, xvi. (1892), pp.
150-180.

X This name is due to Osgood.

%
% 73
%

when .'. " .// X= Y/8; and this choice of X is independent of a. So
the convergence is uniform when a S > and 'when a - 8 < 0.

Example. I j/ sm \& a:: )d > dx is uniformly convergent in any range
of real values of a. (de la Vallee Poussin.)

2- i sin zdz does not exceed a constant inde-

!

l endent uf a and .v since / z-i sin z dz converges.] J

(III) T/ie method of integration by parts.

If / / (x, a) dx <p x, a)+ X (* > ) d-''

and if ( f.r, a)-*-0 uniformly as x -X3 and /;( (.r, a)o?jp converges
uniformly with regard

J <t

to a, then obviously / f x, a) dx converges uniformly with regard to
a.

(IV) The method of decomposition.

Example. |J c\ os.r sin a |J sin (a +l) . |J sin (o - l)a. .

loth of the latter integrals converge uniformly in any closed domain
of real values of a from which the points a= ± 1 are excluded.

\Subsection{4}{4}{4}{Theorems concerning uniformly convergent infinite integrals.}
(I)
Let f x, a) dx converge uniformly luhen a lies in a domain S.

. a

'Then, if f x, a) is a continuous function of both variables ivJien x
a and a lies in S, f x, a)dx is a continuous function* of a.

J a

I r*

For, given e, we can find X independent of a, such that ' I f(x, a)dx
<e whenever X.

Also we can find 8 independent of x and a, such that \ f x,a)-f(x,a')\
< el X-a) whenever a - a.' < B.

That is to say, given e, we can find 8 independent of a, such that

f x,a.')dx-\ f x,a)dx \$ f x,a)-f x,a')]dx\

. a J a \ J a 1

+ I f x, a') dx +\ I fix, a) dx

\ Jx \ Jx

<3e,

whenever | a' - a | < S; and this is the condition for continuity.

* This result is due to Stokee. His statement is that the integral is
a continuous function of a if it does not ' converge infinitely
slowly.'

5

%
% 74
%

(II) If f x, a) satisfies the same conditions as in (I), and if a.
lies in S when A <a<B, then

I \ f x, (x)dx\ doi= \ fix, a)da[dx.

For, by \hardsectionref{4}{3},

Therefore

If

A [J a £ A

f x, a) dx r da= \ \ \ f(x, a) day dx. \ I f x, a) dx[ da- I \ i f x,
a) da)- dx

< f eda<e B-A),

J A

for all sufficiently large values of .

But, from §§ 2'1 and 4"41, this is the condition that

lim I \ i fix, a)da\ dx

should exist, and be equal to

f x, a) dx\ da. Corollary. The equation -r- \ rb .v, a)dx=l ~ dx is
true if the integral on the

da J a . J a va

right converges uniformly and the integrand is a continuous function
of both variables, when x' a and a lies in a domain >S', and if the
integral on the left is convergent.

Let A be a point of S, and let S=f x, a), so that, by \hardsubsectionref{4}{1}{3} example
3,

va

/ f x, a) da = (.r, a) - x, A).

Then / J / /(.r, a) day dx converges, that is / 4> x, a)-( ) x, A) dx
converges,

and therefore, since / cf) x, a)dx converges, so does i x, A) dx. J a
J a

I (f) x, a) dx \=j- / 0 (*-', n) - (- j -'1 )

Then

da

d da

/ \ j f x,a)daydx\

= T I \ l f(x.a)dx\ da daj A [J a- ' ' J

= fjix,a)dx=fy dx, which is the required result; the change of the
order of the integrations has been justified above, and the
differentiation of / with regard to a is justified by \hardsubsectionref{4}{4}{4} (I) and §
4-13 example 3.

%
% 75
%

\Section{4}{5}{Imjiroper integrals. Principal values.}

If I /(x) - >cc as X - a + 0, then lim f(x) dx may exist, abd is

i- + O J a+\&

written simply I f(x) dx; this limit is called an improper integral.

J a

If \ f(x) I - 00 as a; - > c, where a< c <b, then

/e-5 rb

lim I /( ) c?j: + lim I /(- O c?

S +O J a S' +oJ C+\&'

may exist; this is also written I f(x)dx, and is also called an
improper

J a

integral; it might however happen that neither of these limits exists
when 8, S' - > independently, but

lim ]/ f x)dx+i f(x)dxy exists; this is called 'Cauchy's principal
value of I f x)dx' and is written

J a

for brevity P I f(x) dx.

J a

Results similar to those of §§ 4-4-4-44 may be obtained for improper
integrals. But all that is required in practice is (i) the idea of
absolute convergence, (ii) the analogue of Bertrand's test for
convergence, (iii) the analogue of de la Vallee Poussin's test for
uniformity of convergence. The construction of these is left to the
reader, as is also the consideration of integrals in which the
integrand has an infinite limit at more than one point of the range of
integration*.

Examples. (1) / x - cos .v <ilr is an improper integral. J

- b

(2) r ./" (1 -.rf " dx is an improper integral if <X < 1, </i< 1. It
does not converge for negative values of X and /x.

dx is the principal value of an improper mtegral when

1 -A'

0<a<l. . 4-51. The inversion of the order of integration of a certain
repeated integral. ?r General conditions for the legitimacy of
inverting the order of integration when the

integrand is not continuous are difficult to obtain.

The following is a good example of the difficulties to be overcome in
inverting the order of integration in a repeated improper integral.

* For a detailed discussion of improper integrals, the reader is
referred either to Hobson's or to Pierpont's Functions of a Real
Variable. The connexion between infinite integrals and improper
integrals is exhibited by Bromwich, Infinite Series, § 164.

%
% 76
%

Let f x,y) he a continuous function of both variables, and let 0<X 1,
0</x l, < v < 1; then

This integral, which was first employed by Dirichlet, is of
importance in the theory of integral equations; the investigation
which we shall give is due to W. A. Hurwitz*.

Let x''~ i/' ~ (1 -x-yy~' f x,y) = (li x,y); and let M be the upper
bound of \ f x,y) |. Let S be any positive number less than .

Draw the triangle whose sides ave x = b, y = b, x+y = l-b\ at all
points on and inside this triangle ( x, y) is continuous, and hence,
by \hardsectionref{4}{3} corollary,

Now r~''dx 11 "'' ct> X, y) dy =l'~' dx |P"' < (, V) l + f]"' hdx+j'
'* Ldx,

where /i = / </> x, y) dy, L= (f> x, y) dy.

Jo J i-a;-6

But I /i I < r i/.r - y - 1 (1 - .r - y)" - 1 o y

since (l- -?/r-i<(l- '-S)''- .

Therefore, writing x = i\ -S)a'i, we havet

T"" /i dr I J/S',x- 1 p~ ./ - 1 ( 1 - .  - S)" - 1 c

  \& I Jo

 i/r -1 (1 - bt '- C x, - (1 -A-i)""' dx

The reader will prove similarly that Ly- 0 as 8- 0.

Hence I / o?a' i / 4) x,y)dy\= hm / t/ j / 4> x,y)dy\

= lim /

1-25 C fl-x-S

dx J: i ( ) x, y) dy

= lim

5H..0

fl-2S ( fi-y-S ]

* Annals of Mathematics, ix. (1908), p. 183.

t I a.-i ~ (l-.ri)''- dxi = £(A, ) exists if 0, j'>0 \hardsectionref{4}{5}example2).

t The repeated integral exists, and is, in fact, absolutely
convergent; for

/"i ri

writing 2/ = (1- a.-) s; and/ il/ - (1 - .r)' + ''-i cZx . I ' s' -1
(1 -s)''" £?s exists. And since the

 " fl-e - ' fl-ZS

integral exists, its value which is lim I may be written lim I

5, e O J S S O J S

%
% 77
%

by what has beeu already proved; but, by a precisely similar jjiece
of work, the last integral is

We have consequently proved the theorem in question.

Corollary. Writing = a + h-a) x, rj = h - b-a)y, we see that, if 4>
i\$j ) i con- tinuous,

//I f (|-; ~' ib-vf' iv-\$r'' a, V) dv

-J/V fli -af-Hb-rir-Hn- )"-' c >, rj)d Y

This is called Dirichlet's formula.

[Note. What are now called infinite and improper integrals Avere
defined by Cauchy, Leco?iS sur le calc. inf. 1823, though the idea of
infinite integrals seems to date from Maclaurin (1742). The test for
convergence was employed by Chartier (1853). Stokes (1847)
distinguished between 'essentially' (absolutely) and non-essentially
convergent integrals though he did not give a formal definition. Such
a definition was given by Dirichlet in 1854 and 1858 (see his
I'orlesiingen, 1904, p. 39). In the early part of the nineteenth
century improper integrals received more attention than infinite
integrals, probably because it was not fully realised that an infinite
integral is really the Iwiit of an integi'al.]

\Section{4}{6}{Complex inteyration*TODO.}

Integration with regard to a real variable x may be regarded as
integration along a particular path (namely part of the real axis) in
the Argand diagram. \ \ Qtf z), (= 7 -f iQ), be a function of a
complex variable z, which is continuous along a simple curve i in the
Argand diagram.

Let the equations of the curve be

x = x (t), tj = y it) (a t b).

Let X (a) + iy a) = Zq, x (b) + iy (b) = Z.

Then if-f x(t), y(t) have continuous difierential coefficients J Ave
define z f z)dz taken along the simple curve AB to mean

/

dx . dy Mt dt

 F + iQ)( + i' ]dt.

The 'length' of the curve AB will be defined as I \/ (--f) +( ) '

It obviously exists if -7-, -~ are continuous; we have thus reduced
the  dt dt

discussion of a complex integral to the discussion of four real
integrals, viz.

! \ A-' />!- />

dt

* A treatment of complex integration based on a different set of ideas
and not making so many assumptions concerning the curve AB will be
found in Watson's Complex Integration and Cauchy's Theorem.

f This assumption will be made throughout the subsequent work.

X Cp.\hardsubsectionref{4}{1}{3} example 4.

%
% 78
%

By \hardsubsectionref{4}{1}{3} example 4, this definition is consistent with the definition
of an integral when AB happens to be part of the real axis.

Examples, l f(z) dz= - l " f(z) dz, the paths of integration being the
same (but in opposite directions) in each integral.

/:- /.w:f-s-4f--(4'-4) *\

\Subsection{4}{6}{1}{The fundamental theorem of complex integration.}

From \hardsubsectionref{4}{1}{3}, the reader will easily deduce the following theorem :

Let a sequence of points be taken on a simple curve z Z; and let the
first n of them, rearranged in order of magnitude of their parameters,
be called i<">, gC", . . . z <"' (iTo"*' = z +i'"' = Z); let their
parameters be j"*', J"', . . . <'", and let the sequence be such that,
given any number h, we can find N such that, when n > N, +i<"' - <"' <
B, for r = 0, 1, 2, ...,n; let,."" be any point whose parameter lies
between < < '', r+i*"'; then we can make

I (,+i'") - Zr fiC/- ) - I \ f(z) dz

arbitrarily small by taking n sufficiently large.

\Subsection{4}{6}{2}{An upper limit to the value of a complex integral.}

Let M be the upper bound of the continuous function \ f(z) .

Then jJVw,.j £:/(.)sj(| + 4y)],,

 Ml, where I is the ' length ' of the curve z yZ.

That is to say, I f(z) dz cannot exceed Ml.

\Section{4}{7}{Integration of infinite series.}

We shall now shew that if S z) = u z) + ii. z)- ... is a uniformly
con- vergent series of continuous functions of z, for values of z
contained within some region, then the series

I III z) dz + I lu z) dz + ..., J c J c

(where all the integrals are taken along some path C in the region) is
con- vergent, and has for sum I S (z) dz.

J c

%
% 79
%

For, writing

>Sf Z) = Ml Z) + 2 ( ) +    + Ihi Z) + Rn Z),

we have

I S z) dz =1 u z)dz + ... -\ Un (z) dz + I R,, (z) dz.

J c J c J c J c

Now since the series is uniformly convergent, to every positive number
e there corresponds a number r independent of z, such that when n r we
have I Rn (z) I < f> for all values of z in the region considered.

Therefore if I be the length of the path of integration, we have (§
4'62)

f Rn z) J C

<el

dz

Therefore the modulus of the difference between / S z) dz and

J c n r

S I Um (z) dz can be made less than any positive number, by giving n
any

m = lJ c

sufficiently large value. This proves both that the series 2 Um z)dz
is

OT = 1 J c

convergent, and that its sum is / S(z)dz.

J c

Corollary. As in \hardsubsectionref{4}{4}{4} corollary, it may be shewn that*

0? ",, " d, .

if the series on the right converges uniformly and the series on the
left is convergent.

Example 1. Consider the series

" 'ix n n +1) 11x x -1 cos x" ?i 1+ 2 sin2 x ] 1 + n + 1)2 sin- .r '
in which x is real.

The Jith term is

2.rw cos x 2x (n + 1) cos x

1 + 71 sin"- X- 1 + (n + 1 )2 sin- x ' and the sum of n terms is
therefore

2x cos x' 2x(n + l) cos x

1+Sin2 2~ l + (7i+l)2sin2a;2*

Hence the series is absolutely convergent for all real values of x
except ± /(mrr) where ?>i = 1, 2, . . .; but

r> .,\ 2x(n+l)cosx -'"''-l+(K + l)2sin2, :2'

and if n be any integer, by taking x = n + l)~' this has the limit 2
as n <X) . The series is therefore non-uniformly convergent near x=0.

* - - ' means lira " where h- 0 along a definite simple curve; this
definition

is modified slightly in \hardsubsectionref{5}{1}{2} in the case when/(z) is an analytic
function.

%
% 80
%

Now the sum to infinity of the series is - - -, and so the integral
from to,r of ' 1 + sm-' x

the sum of the series is arc tan sin r . On the other hand, the sum of
the integrals from

to .V of the first n terms of the series is

arc tan sin .r - arc tan ( + !) sin x',

and as /i- X this tends to arc tan sin x-] - hir.

Therefore the integral of the sum of the series difiers from the sum
of the integi-als of the terms by tt.

Example 2. Discuss, in a similar manner, the series

== 2e .p l- (e-l) + e" + U'2

for real values of x.

Example 3. Discuss the series

7(1 + 11-2 + U3+...,

where

Ui = ze-'\ Un=nze-'"' - ( - 1) se-l"-!), for real values of z.

The sum of the first n terms is ?i2e~" ", so the sum to infinity is
for all real values of z. Since the terms Un are real and ultimately
all of the same sign, the convergence is absolute.

In the series

/ Uidz+ I ti.2dz+ I v.3dz + ...,

the sum of Ji. terms is -g (1 - e"" ), and this tends to the limit |
as n tends to infinity; this is not equal to the integral from to 2
of the sum of the series 2?<n-

The explanation of this discrejjancy is to be found in the
non-uniformity of the convergence near 2 = 0, for the remainder after
n terms in the series Ui + 112 + ...is - -aze~ "; and by taking z =
7i~' we can make this equal to e' '"-, which is not arbitrarily small;
the series is therefore non-uniformly convergent near z = 0.

Example 4. Compare the values of

/\ 2 tin[ dz and 2 / Undz, U=l J n=lj

where

2n z 2 n- l) z

"l+n'z )\ og n + l) l + n + -iyh'- log n + 2)'

\addexamplecitation{Trinity, 1903.}

REFERENCES.

G. F. B. Riemann, Ges. Math. Werke, pp. 239-241.

P. G. Lejeuxe-Dirichlet, Yorlesungen. (Brunswick, 1904.)

F. G. Meyer, Bestimmte Integrale. (Leipzig, 1871.)

E. GoDRSAT, Cours d Analyse (Paris, 1910, 1911), Chs. iv, xiv.

C. J. DE LA Vall e Poussix, Cours d' Analyse In fiyiite'stmale (Payis
and Louvaiu, 1914),

Ch. VI. E. W. HoBSON, Functions of a Real Variable (1907), Ch. v. T.
J. I'a. Bromwich, Theory of Infinite Series (1908), Appendix ill.

%
% 81
%

Miscellaneous Examples.

1. Shew that the integrals

I sin x )dx, I cos (.r-) dx, I x exp ( - x sin- x) dx Jo Jo Jo

converge. \addexamplecitation{Dirichlet and Du Bois Eeymoud.}

2. If a be real, the integral

f °° cos (ax),

Jo 1+ is a continuous function of a. \addexamplecitation{Stokes.}

3. Discuss the uniformity of the convergence of j x sin x - ax) dx.

Jo

3 /.rsin x -ax)dx= -f - -l-ir-j) cos (x- -ax)

/"/I a\,,,, 1 fsin(x -ax), ~\

- JU + : j " ' -" ) ' '+3°"j - x - ""-J

(de la Vallee Poussin.)

4. Shew that / ex ) [-e'< x -nx)]dx converges unifonuly in the range -
hr, hir) of values of a. \addexamplecitation{Stokes.}

r " x' dx

5. Discu.ss the convergence of I, - . when u, p, p are positive.

* Jo l+JT" |smjp|P - )/- r

(Hardy, Messenger, xxxi. (1902), p. 177.)

6. Examine the convergence of the integrals

Jo V 2 l-e'J .r ' jo X"

\addexamplecitation{Math. Trip. 1914.}

7. Shew that / - exists.

J " x' (sin x)

8. Shew that I .r -"e"" ' sin 2.rc/.r converges if a >0, a >0. (Math.
Trip. 1908.)

J a

9. If a series (7(2)= 2 (c - (? + i)sin (2i/+l) Tri:, (in which C(, =
0), converges uniformly

v=0

TT . . . . C

in an interval, shew that g z) -. is the derivative of the series/
(2)= 2 - sin 2vTrz.

sm irZ v=i V

(Lerch, Ann. de VEc. norm. sup. (3) xii. (1895), p. 351.)

10. Shew that r r... r |L i tff2- n d r r r dx,dx,...dx

converge when a>hi' and a~i + /3~i + ...+X~' < 1 respectively. (Math.
Trip. 1904.)

11. Iff x, ) be a continuous function of both.r andy in the ranges (a
x b), (a ?/ 6) except that it has ordinary discontinuities at points
on a finite number of curves, with continuously turning tangents, each
of which meets any line parallel to the coordinate axes

fb

only a finite number of times, then I f x, y) dx is a continuous
function of y.

/a, - Sj Ca.2-\&2 [b

+ 1 +...+ I fC 'j y + h)-f(x, y)]dx, where the numbers

Sj, \hardsectionref{2}{5}  fi, f2?  are so chosen as to exclude the
discontinuities ot f x, y + h) from the range of integration; Oj, 02,
... being the discontinuities off x, y).] \addexamplecitation{Bocher.}

W. M. A. 6


% Chapter 4
\chapter{Results of Calibration and \gls{3D} Reconstruction} % Main chapter title
\label{chapterCaliResultsReconstruction} % For referencing the chapter elsewhere, use \ref{sens_CalibrationSystem}
As discussed in section~\ref{perpixelDataCollection}, the per-pixel calibration method is supposed to handle both of radial dominated lens distortions and depth distortion. A two-dimensional high-order polynomial model would be employed to remove lens distortions and generate estimated (\(\gls{worldX},\, \gls{worldY}\))s from image space (\(R, \, C\))s. And the depth distortion would be removed during the per-pixel \(D\) to \(\gls{worldZ}\) mapping during 3D reconstruction. In this chapter, we will show how well the lens distortions and depth distortion are removed by compare both of intuitive image data and quantitative numerical data, before and after calibration, in both of Matlab prototypes and real-time 3D reconstructions.
%%
\section{Calibration and Analysis}
\label{sectionPrototypeTwoDtransformation}
%
\indent
Figure~\ref{MatlabPrototpyeOfHighOrder} shows the Matlab prototypes of the simulated original image, world space \(X^WY^W\) plane result after a two-dimensional \(1^{st}\) order polynomial transformation, \(2^{nd}\) order polynomial and \(4^{th}\) order polynomial transformation. With squared-shaped distributed points (\(C,\, R\))s extracted from image streams, fig.~\subref*{Original_MatlabPrototype} recovers the original distorted image in Matlab. Using a mathematical distortion (\(d\)) measurement \cite{distortionMeasurement_2012}
%
\begin{equation}
d (\%)=  e*100/L ,
\label{mathematicalDistortion}
\end{equation}%
%
\noindent
we can get the original distortion \(d_0 = (R3 - R1) / (C2 -C1) = (403 - 393) / (492 - 20) = 2.1\%\). Figure~\ref{First_MatlabPrototype} shows estimated world space \(X^WY^W\) plane after a two-dimensional \(1^{st}\) order polynomial transformation, whose distortion \(d_1 = (Y1 - Y3) / (X2 -X1) = [-3.772 - (-4.004)] / [5.713 - (-4.735)] = 2.2\%\). As we may have expected, the distortion \(d_1\) is not getting smaller at all. %
\\\indent
Figure~\ref{Second_MatlabPrototype} and Fig.~\ref{Fourth_MatlabPrototype} show the transformed world space \(X^WY^W\) plane images after the \(2^{nd}\) order and \(4^{th}\) order polynomial transformation respectively, from which we can get \(d_2 = [-3.807 - (-4.035)] / [5.779 - (-4.8)] = 2.1\%\) and \(d_4 = [-3.936 - (-3.992)] / [5.923 - (-4.928)] = 0.516\%\). %
%
\begin{figure}[!t]
\hspace*{-0.3cm}
\centering
\subfloat[Image Space][Image Space]{
\includegraphics[width=0.5\textwidth]{Original_MatlabPrototype}
\label{Original_MatlabPrototype}}
%\qquad
\subfloat[\(1^{st}\) Order][\(1^{st}\) Order]{
\includegraphics[width = 0.5\textwidth]{First_MatlabPrototype}
\label{First_MatlabPrototype}}

\subfloat[\(2^{nd}\) Order][\(2^{nd}\) Order]{
\includegraphics[width=0.5\textwidth]{Second_MatlabPrototype}
\label{Second_MatlabPrototype}}
%\qquad
\subfloat[\(4^{th}\) Order][\(4^{th}\) Order]{
\includegraphics[width = 0.5\textwidth]{Fourth_MatlabPrototype}
\label{Fourth_MatlabPrototype}}
%
\caption{\(\gls{worldX}\)\(\gls{worldY}\) Matlab Polynomial Prototype}
\label{MatlabPrototpyeOfHighOrder}
\end{figure}%
%
%
It is straightforward to tell that, \(d_4\) is much smaller than \(d_0\) and Fig.~\ref{Fourth_MatlabPrototype} intuitively shows a satisfying undistorted image. From eqn.~(\ref{secondOrderPolynomial}) and eqn.~(\ref{fourthOrderPolynomial}), we know that the second order polynomial mapping has $2\times6=12$ parameters, and the fourth order polynomial mapping has $2\times15=30$ parameters. The higher order polynomial we use, the better radial distortion we are able to correct. In the meantime, the distortion removal model will have more parameters to calculate, and need more calibrating points to train the model.%
%
%%
\\\indent
\begin{figure}[!t]
\centering
\hspace*{-0.3cm}
\subfloat[Before transformation][Before transformation]{
\includegraphics[width=0.5\textwidth, height = 0.425\textwidth]{BeforeRectification_Single_NIR}
\label{BeforeRectification_Single_NIR}}
%
\subfloat[Perspective Correction][Perspective (\(1^{st}\))]{
\includegraphics[width = 0.5\textwidth, height = 0.425\textwidth]{Perspective_QtScreenShot}
\label{Perspective_QtScreenShot}}
%
\\%\qquad
\hspace*{-0.3cm}
\subfloat[\(2^{nd}\) Order][\(2^{nd}\) Order]{
\includegraphics[width = 0.5\textwidth, height = 0.425\textwidth]{Second_QtScreenShot}
\label{Second_QtScreenShot}}
%
\subfloat[\(4^{th}\) Order][\(4^{th}\) Order]{
\includegraphics[width = 0.5\textwidth, height = 0.425\textwidth]{Fourth_QtScreenShot}
\label{Fourth_QtScreenShot}}
%
\caption{\gls{NIR} Stream High Order Polynomial Transformation}
\label{HighOrderNearIRRectification}
\end{figure}%
%
By applying those two-dimensional polynomial models into real-time streams transformation, we can get the transformed stream images. As shown in Fig.~\ref{HighOrderNearIRRectification}, the outlines of the transformed steam images are same with Matlab prototypes in Fig.~\ref{MatlabPrototpyeOfHighOrder}. It is easy to tell that the \(4^{th}\) order polynomial surface mapping is much better than the second order, and a higher order than \(4^{th}\) should be more accurate. However, as the order of the polynomial mapping goes higher, the number of parameters also get larger and larger, which costs more calculations and requires more data (coordinate-pairs) for training the transformation model. Considering that a \(5^{th}\) order polynomial mapping will have much more  parameters ($2\times21=42$) to calculate while may not enhance much accuracy, we choose the \(4^{th}\) order polynomial as the main mapping model to get \(X^WY^W\) values from \(RC\). Limited by the static dot pattern, fewer and fewer dot-clusters could be observed by the camera as the camera getting closer to the dot pattern. Practically, \(4^{th}\) order calibration is replaced by \(2^{nd}\) order to guarantee a robust software when the observed dot-clusters are too few to train the transformation model.
\\\indent
%%
%%
%% %% mapping model parameters determination
%
The two-dimensional high-order polynomial mapping model will be applied in the first calibration step of \(\gls{worldX} \gls{worldY} \gls{worldZ}+\gls{D}\) frames data collection. Figure~\ref{Data63FranesForLUT} shows 63 frames of collected \(\gls{worldX} \gls{worldY} \gls{worldZ}\), which gives an pyramid shape of a camera sensor's undistorted world space field of view. For each single pixel, its field of view is a beam, which could be mathematically expressed as equation~(\ref{kaiBeamEquationCh3}). Some sample beams are shown in Fig.~\ref{SampleBeams_NearIR}, whose beam equation parameters \(c\)/\(d\)/\(e\)/\(f\) are determined as the best-fit totally by the collected undistorted data.
\begin{figure}[t]
\centering
\includegraphics[width=0.7\textwidth, height= 0.55\textwidth]{Data63FranesForLUT}
\caption{63 Frames \gls{NIR} Calibrated \gls{3D} Reconstruction}
\label{Data63FranesForLUT}
\end{figure}%
%
%
\begin{figure}[t]
\centering
\includegraphics[width=0.6\textwidth]{SampleBeams_NearIR}
\caption{Sample Beams of Calibrated \gls{NIR} Field of View}
\label{SampleBeams_NearIR}
\end{figure}
%
%As discussed in section~\ref{sectionDataProcessLUTgeneration}, the per-pixel \(\gls{D}\) to \(\gls{worldZ}\) mapping is linear.
As for the handling of depth distortion, a pre-process of depth stream is needed. Considering that there will be irregular noises (different with the regular depth distortion) in the depth stream, especially those brought in by the defects affected by huge transitions of color (or intensity), we will find a best-fit plane for each frame based on its \(\gls{worldX} \gls{worldY} \gls{D}\) data and throw away 10\% worst pixels that are far away from the best-fit plane. Figure~\ref{depthDistortionComparisonBeforeAfterCalibration} shows 10 frames of flat-shading 3D reconstructions in Matlab for both of before and after calibration. In Fig.~\subref*{cameraFramesInWorldSpace}, the 3D reconstructions are based on camera space coordinates \(\gls{cameraX} \gls{cameraY} \gls{cameraZ}\) generated by eqn.~(\ref{proportionalBeamEqn}) and (\ref{parametersABofProportional}); which are then transformed into world space for a better comparison with the calibrated reconstruction, using best fit rotation and translation matrix based on corresponding \(\gls{worldX} \gls{worldY} \gls{worldZ}\). In Fig.~\subref*{worldFramesInWorldSpace}, the 3D reconstructions are based on world space coordinates generated by eqn.~(\ref{kaiBeamEquationCh3}) and (\ref{fromD_To_Z}). We can tell that the 10 frames in the LUT calibrated 3D reconstructions are a little bit thinner than that of raw Pin-Hole reconstructions, which means the per-pixel calibration method has positive effect on the removal of depth distortion. The depth distortion removal in real-time is shown in section~\ref{sectionRealTimeReconstruction} Fig.~\ref{depthDistortionCalibrationBeforeAfter}.

\begin{figure}[t]
\centering
\hspace*{-0.3cm}
\subfloat[Raw Pin-Hole Reconstructions in World Space         through best-fit rotation and translation]{
\includegraphics[width=0.5\textwidth]{cameraFramesInWorldSpace}
\label{cameraFramesInWorldSpace}}
%
\subfloat[Calibrated \gls{LUT} based Reconstructions]{
\includegraphics[width = 0.5\textwidth]{worldFramesInWorldSpace}
\label{worldFramesInWorldSpace}}
%
\caption{Depth Distortion, before and after Calibration}
\label{depthDistortionComparisonBeforeAfterCalibration}
\end{figure}%
%
%\clearpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Real-Time \gls{3D} Reconstruction on \gls{GPU}}
\label{sectionRealTimeReconstruction}
%
The \gls{3D} Reconstruction of undistorted \(\gls{worldX}/\gls{worldY}/\gls{worldZ}\) in real-time is the final aim of a \gls{3D} camera's calibration. In the traditional camera calibration method, which consist of one pinhole-camera matrix to generate raw world space \gls{3D} coordinates and another model for lens distortion removal, three big transformations are needed to generate the world space coordinates: from 2D distorted image space to 2D undistorted image space, then to \gls{3D} camera space, and finally to \gls{3D} world space. For every single pixel's processing, it needs 5 parameters from distortion removal model for the first step non-linear calculation, and then a $3\times3$ intrinsic matrix to get its camera space coordinates, and a $3\times4$ extrinsic matrix to finally acquire the world space coordinates. The \gls{3D} reconstruction after the traditional calibration requires a lot of calculations for every single pixel, and \emph{depth distortion} is not corrected at all.
\\\indent
%
Using the proposed per-pixel calibration method, only three linear calculations with six parameters are needed to determine the world space coordinates for every single pixel. Two parameters \(e/f\) are utilized to generate world space \(\gls{worldZ}\), as expressed in eqn.~(\ref{fromD_To_Z}). And the other four parameters \(a/b/c/d\) are applied to get \(\gls{worldX}/\gls{worldY}\) respectively based on eqn.~(\ref{kaiBeamEquationCh3}). In this way, there is no need to calculate any non-linear equation for distortions removal, and the camera space is totally left aside. Combining two equations together, the undistorted \gls{3D} world coordinates (\(\gls{worldX}, \, \gls{worldY}, \, \gls{worldZ}\)) for every single pixel could be looked up based on \(\gls{D}\) from a \(\gls{imageColumn}\)-by-\(\gls{imageRow}\)-by-\(6\) look-up table. Figure~\ref{perPixelCalibrationBeforeAfter} shows how lens distortions are moved, and Fig.~\ref{depthDistortionCalibrationBeforeAfter} shows how the \emph{depth distortion} is removed by per-pixel \(\gls{D}\) to \(\gls{worldZ}\) mapping.
\begin{figure}[t]
\centering
\hspace*{-0.3cm}
\subfloat[Raw (Distorted)]{
\includegraphics[width=0.5\textwidth, height = 0.425\textwidth]{distortedRGB}
\label{distortedRGB}}
%
\subfloat[Calibrated]{
\includegraphics[width = 0.5\textwidth, height = 0.425\textwidth]{CalibratedRGB}
\label{CalibratedRGB}}
%
\caption{Lens-Distortions Removal by Per-Pixel Calibration Method}
\label{perPixelCalibrationBeforeAfter}
\end{figure}%
%
\begin{figure}[t]
\centering
\hspace*{-0.3cm}
\subfloat[Raw]{
\includegraphics[width=0.3\textwidth, height = 0.425\textwidth]{distortedSideViewRGB}
\label{distortedSideViewRGB}}
\qquad%
\subfloat[Calibrated]{
\includegraphics[width = 0.3\textwidth, height = 0.425\textwidth]{CalibratedSideView}
\label{CalibratedSideView}}
%
\caption{Depth-Distortions Removal by Per-Pixel Calibration Method}
\label{depthDistortionCalibrationBeforeAfter}
\end{figure}%
%
%%
%
%


\section{Universal property}

\subsection{Natural numbers in set theory and category theory}

\textbf{A1} is the regular Peano's definition of natural numbers. There is
nothing new.

\textbf{A2} is more interesting to investigate. It defines natural
number set ($N$) to be the ``initial'' object of the category of all
natural-number-like sets ($X$). The essential part of a univeral
property is the unique arrow, or
\emph{factorization}. In our case, it is the $f : X \to N$. Here is an
example of an $X$ in \textbf{A2}.

\begin{example}
  $(-1) \in X \rTo^g X$ where
  $g := a \rMapsto a-1$. With this case
  $f := a \rMapsto -(a+1)$.
\end{example}

This is straightfoward, just a demonstration of what is it about.

\begin{quotation}
  The \emph{Recursion Theorem}
  \footnote{\url{https://en.wikipedia.org/wiki/Recursion#The_recursion_theorem}}
  guarantees recursively defined functions exists. Given a set $X$, an
  element of $e\in X$ and a function $g : X \to X$, the theorem states
  there is a unique function $f : N \to X$, such that
  \begin{align}
    f(0) &= e \\
    f(n+1) &= g(f(n))
  \end{align}
\end{quotation}

This is essentially defines a factorization from $N$ to $X$.

So then the proof of \textbf{A1} and \textbf{A2} are isomorphic.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "master.tex"
%%% End:


\section*{Exercises}

\begin{ex} Consider the following diagram of four circuits.
  \begin{center}
    \scalebox{0.8}{
      \begin{circuitikz}[american, scale=0.7] \draw
        (0,0) to [battery1, v^= $5\volt$~~] (0,4)
        (0,0) to [R = $2 \ohm$] (4,0)
        to [R = $5 \ohm$] (4,4)
        (0,4) to [R =$3 \ohm$] (4,4)
        (6,4) to [battery1, v_= \raisebox{1ex}{$20\volt$}] (4,4)
        (6,4) to [R = $1 \ohm$] (8,4)
        to [R = $1 \ohm$] (8,0)
        (4,0) to [R = $6 \ohm$] (8,0)
        to [R = $3 \ohm$] (8,-4)
        to [R = $2 \ohm$] (4,-4)
        to [R = $1 \ohm$] (4,0)
        (4,-4)to [R = $4 \ohm$] (0,-4)
        (0,0 )to [battery1, v_= $10\volt$~~] (0,-4)
        (2,2) node[scale=3]{$\circlearrowleft$}
        (2,2) node{$I_2$}
        (6,2) node[scale=3]{$\circlearrowleft$}
        (6,2) node{$I_3$}
        (6,-2) node[scale=3]{$\circlearrowleft$}
        (6,-2) node{$I_4$}
        (2,-2) node[scale=3]{$\circlearrowleft$}
        (2,-2) node{$I_1$}
        ;
      \end{circuitikz}
    }
  \end{center}
  The current in amperes in the four circuits is denoted by $I_1$,
  $I_2$, $I_3$, and $I_4$. It is understood that a positive
  current means a current flowing in the counterclockwise direction. If
  $I_k$ ends up being negative, then it just means the current flows
  in the clockwise direction.  In the above diagram, the top left
  circuit should give the equation
  \begin{equation*}
    2I_2 - 2I_1+5I_2 - 5I_3+3I_2=5.
  \end{equation*}
  Write equations for each of the other three circuits and then give a solution
  to the resulting system of equations.
  \begin{sol}
    The other three equations are
    \begin{eqnarray*}
      4I_1 + I_1 - I_4 + 2I_1 - 2I_2 &=& -10 \\
      6I_3 - 6I_4 + I_3 + I_3 + 5I_3 - 5I_2 &=& -20 \\
      2I_4 + 3I_4 + 6I_4 - 6I_3 + I_4 - I_1 &=& 0.
    \end{eqnarray*}
    Then the system is
    \begin{equation*}
      \begin{array}{c}
        2I_2 - 2I_1 + 5I_2 - 5I_3 + 3I_2 = 5 \\
        4I_1 + I_1 - I_4 + 2I_1 - 2I_2 = -10 \\
        6I_3 - 6I_4 + I_3 + I_3 + 5I_3 - 5I_2 = -20 \\
        2I_4 + 3I_4 + 6I_4 - 6I_3 + I_4 - I_1 = 0.
      \end{array}
    \end{equation*}
    The solution is:
    \begin{eqnarray*}
      I_1 &=& -\frac{750}{373} \\
      I_2 &=& -\frac{1421}{1119} \\
      I_3 &=& -\frac{3061}{1119} \\
      I_4 &=& -\frac{1718}{1119}.
    \end{eqnarray*}
  \end{sol}
\end{ex}

\begin{ex} Find $I_1$, $I_2$, and $I_3$, the counterclockwise currents in
  amperes in the three circuits of the following diagram.

  \begin{center}
    \scalebox{0.8}{
      \begin{circuitikz}[american, scale=0.7] \draw
        (0,0) to [battery1, v^= $10\volt$~~] (0,4)
        (0,0) to [R = $2 \ohm$] (4,0)
        to [R = $5 \ohm$] (4,4)
        (0,4) to [R =$3 \ohm$] (4,4)
        (6,4) to [battery1, v_= \raisebox{1ex}{$12\volt$}] (4,4)
        (6,4) to [R = $7 \ohm$] (8,4)
        to [R = $3 \ohm$] (8,0)
        (4,0) to [R = $1 \ohm$] (8,0)
        to [R = $4 \ohm$] (8,-4)
        to [R = $4 \ohm$] (4,-4)
        to [R = $2 \ohm$] (4,0)
        (2,2) node[scale=3]{$\circlearrowleft$}
        (2,2) node{$I_1$}
        (6,2) node[scale=3]{$\circlearrowleft$}
        (6,2) node{$I_2$}
        (6,-2) node[scale=3]{$\circlearrowleft$}
        (6,-2) node{$I_3$}
        ;
      \end{circuitikz}
    }
  \end{center}

  \begin{sol}
    We have
    \begin{eqnarray*}
      2I_1 + 5I_1 + 3I_1 - 5I_2 &=& 10 \\
      I_2 - I_3 + 3I_2 + 7I_2 + 5I_2 - 5I_1 &=& -12 \\
      2I_3 + 4I_3 + 4I_3 + I_3 - I_2 &=& 0.
    \end{eqnarray*}
    Simplifying this yields
    \begin{eqnarray*}
      10I_1 - 5I_2 &=& 10 \\
      -5I_1 + 16I_2 - I_3 &=& -12 \\
      -I_2 + 11I_3 &=& 0.
    \end{eqnarray*}
    The solution is given by
    \begin{equation*}
      I_1 = \frac{218}{295},\quad
      I_2 = -\frac{154}{295},\quad
      I_3 = -\frac{14}{295}.
    \end{equation*}

  \end{sol}
\end{ex}


\setlength{\parindent}{0pt}

\clearpage
\section{Liveness DFA rules}
(Prepared by Jai Arora)
\vspace{0.3cm}

Now here we will define the transfer function for the Liveness Analysis. Define the function $L(s,x,in/out)$ as follows:

\begin{itemize}
    \item $x$ - the variable for which we want to compute the liveness values
    \item $s$ - a program statement $s$
    \item $in/out$ - whether it is input to the statement or output to the statement i.e just before the statement or just after the statement.
    \begin{itemize}
        \item $L(s, x, in)$ = The liveness value of $x$ just before s
        \item $L(s, x, out)$ = The liveness value of $x$ just after s i.e just after statement s is executed
    \end{itemize}
\end{itemize}

As discussed before, $L(s,x,in/out) \in \{{\tt true}, {\tt false}\}~\forall s,x$.\\

From now on, the discussion is for a particular variable $x$, but it can be generalized to more than one variables. We are going to define rules for the following 2 cases:

\begin{itemize}
    \item \textbf{Case 1:} A statement $p$ has one or more successor program points. So in this case, the $out$ value of the statement $p$ is expressed as a function of $in$ values of the successor program points.
    \begin{figure}[H]
        \centering
        \includegraphics[height=3cm]{images/Module82_1.png}
    \end{figure}

    \item \textbf{Case 2:} For a given statement $s$, the $in$ value is a function of the $out$ value of that statement.
    \begin{figure}[H]
        \centering
        \includegraphics[height=3cm]{images/Module82_2.png}
    \end{figure}

\end{itemize}
It can be obseved from here that unlike Global Constant Propagation, which is a Forward Dataflow Analysis, this is a Backward Dataflow Analysis (it starts from the exit point).

\subsection{Rules for the Transfer Function:}
%Insert Images
\begin{itemize}
    \item $L(p, x, out) = glb\{L(s_i, x, in)~|~s_i$ is a successor of $p\}$\\

    If $x$ is live before any of the successors, then $x$ is live after that statement as it may get used in the downflow logic.
    \item If $s$ is of the form $... = f(...,x,...)$, then $$L(s, x, in) = {\tt true}$$ as the variable $x$ is getting used in this statement.
    \item If $s$ is of the form $x := e$, where $e$ is an expression which does not refer to $x$, then $$L(s, x, in) = {\tt false}$$ as we don't need the values of $x$ just above this statement due to $x$ being rewritten

    Note: If $e$ referred to $x$, then Rule \#2 would apply
    \item If $s$ does not refer to $x$ at all (neither updating it, nor using it), then $$L(s, x, in) = L(s, x, out)$$
\end{itemize}

These rules are exhaustive. These can be thought of as a system of equations, and our solution should satisfy all these rules.

\subsection{Liveness DFA Algorithm}
\begin{itemize}
    \item Initialize $L(s, x, in/out) = {\tt false}$ for all statements $s$ and variables $x$ (We start from a more aggresive value)
    \item Repeat until all program points satisfy Rules 1-4
    \begin{itemize}
        \item Pick a statement $s$ not satisfying one or more rules in rules 1-4 and update the corresponding $L()$ function value using the appropriate rule
    \end{itemize}
\end{itemize}

There is a guarantee that this algorithm will converge.


\gotosection{0}{2}
\subsection{Quantifiers and negation}

\begin{exercise}{1}
  \begin{enumerate}
    \item There exists a prime number such that if you divide it by 4 you have
          a remainder of 1 and it is not the sum of two squares.

    \item There exists $x \in \mathbb{R}$ and $\epsilon > 0$ such that for all
          $\delta > 0$, there exists $y \in \mathbb{R}$, if $|y - x| < \delta$,
          then $|y^2 - x^2| \geq \epsilon$.

    \item There exists $\epsilon > 0$ such that for all $\delta > 0$, there
          exist $x, y \in \mathbb{R}$ such that if $|y - x| < \delta$, then
          $|y^2 - x^2| \geq \delta$.
  \end{enumerate}
\end{exercise}

\gotosection{0}{3}
\subsection{Set theory}

\begin{exercise}{1}
  \begin{enumerate}
    \item
    $\begin{aligned}[t]
    A * B    &= (E - A) \cap (E - B) = E - (A \cup B) \\
    A \cup B &= E - (E - (A \cup B)) \\
             &= E - A * B \\
             &= (E - A * B) \cap (E - A * B) \\
             &= (A * B) * (A * B)
    \end{aligned}$

    \item
    $\begin{aligned}[t]
    A \cap B &= (E - (E - A)) \cap (E - (E - B)) \\
             &= (E - A) * (E - B) \\
             &= (A * A) * (B * B)
    \end{aligned}$

    \item
    $\begin{aligned}[t]
    E - A &= (E - A) \cap (E-A) \\
          &= A * A
    \end{aligned}$
  \end{enumerate}
\end{exercise}

\gotosection{0}{4}
\subsection{Functions}

\begin{exercise}{6}
  \begin{enumerate}
    \item
    $f$ can become one to one if it's domain is changed to $[0, \infty)$, namely, all nonnegative numbers. Then, for each $y \in [0, \infty)$, there is one and only one $x$ such that $y = f(x)$, which is $x = \sqrt{y}$.

    $f$ cannot become one to one by solely changing its codomain. As long as its codomain contains any number other than 0, say $y$, there always exist two possible $x$ such that $f(x) = y$, namely $\sqrt{y}$ and $-\sqrt{y}$. If its codomain was changed to the singleton set $\{0\}$, the domain will also be changed to $\{0\}$. Hence it's impossible to make it one to one by by solely changing its codomain.

    \item
    For any real number $x$, as long as both $x$ and $-x$ are removed from $f$'s domain, for $y \in [0, \infty), y = x^2$, there doesn't exist $x'$ of $f$'s domain such that $f(x') = y$, because both two roots of the equation $y = x^2$ are removed from $f$'s domain. Hence, $f$ becomes not onto.

    $f$ can become not onto if it's codomain is extended to contain negative real numbers. For every $y < 0$, there doesn't exist $x = \sqrt{y}$ such that $x$ is a real number.
  \end{enumerate}
\end{exercise}

\begin{exercise}{8}
  \begin{enumerate}
    \item $f^{-1}(A \cap B) = f^{-1}(A) \cap f^{-1}(B)$.

    \Proof{} For every $x \in f^{-1}(A \cap B)$, there exists $y \in A \cap B$
    such that $y = f(x)$. Because $y \in A$, $y \in B$, and $y = f(x)$,
    $x \in f^{-1}(A)$ and $x \in f^{-1}(B)$, or $x \in f^{-1}(A) \cap f^{-1}(B)$
    . Therefore, $f^{-1}(A \cap B) \subseteq f^{-1}(A) \cap f^{-1}(B)$.

    For every $x \in f^{-1}(A) \cap f^{-1}(B)$, $x \in f^{-1}(A)$ and
    $x \in f^{-1}(b)$; as a result, there exist $y \in A$ and $z \in B$ such
    that $y = z = f(x)$, or, $y \in A \cap B$. By definition, $x \in f^{-1}(A \cap B)$.
    So, $f^{-1}(A) \cap f^{-1}(B) \subseteq f^{-1}(A \cap B)$. Since two sets
    are subsets of each other, they are equal. \QED

    \item $f^{-1}(A \cup B) = f^{-1}(A) \cup f^{-1}(B)$.

    \Proof{} For every $x \in f^{-1}(A \cup B)$, there exists $y \in A \cup B$
    such that $y = f(x)$. Because $y$ is an element of either $A$ or $B$ or both
    , $x$ is the element of $f^{-1}(A)$ and $x \in f^{-1}(B)$ or both, which
    means $x \in f^{-1}(A) \cup f^{-1}(B)$. Therefore, $f^{-1}(A \cup B) \subseteq f^{-1}(A) \cup f^{-1}(B)$.

    For every $x \in f^{-1}(A) \cup f^{-1}(B)$, $x \in f^{-1}(A)$ or
    $x \in f^{-1}(b)$ or both. If $x \in f^{-1}(A)$, there exists $y \in A$
    such that $y = f(x)$; then, $y \in A \cup B$, $x \in f^{-1}(A \cup B)$ by
    definition. Similarly, if $x \in f^{-1}(B)$, $x$ will also be an element of
    $f^{-1}(A \cup B)$. So, $f^{-1}(A) \cup f^{-1}(B) \subseteq f^{-1}(A \cup B)$.
    Since two sets are subsets of each other, they are equal. \QED
  \end{enumerate}
\end{exercise}

\begin{exercise}{10}
  \begin{enumerate}
    \item Let the function \FunSS{f}{B}{C} and \FunSS{g}{A}{B} be onto.
          Then the composition $f \circ g$ is onto.

    \Proof{} For every $c \in C$: since \FunSS{f}{B}{C} is surjective, there
    exists $b \in B$ such that $f(b) = c$; since \FunSS{g}{A}{B} is surjective,
    there exists $a \in A$ such that $g(a) = b$. Therefore, for every $c \in C$,
    there exists $a \in A$ such that $(f \circ g)(a) = f(g(a)) = c$.
    Thus, $f \circ g$ is surjective, or onto. \QED

    \item Let the function \FunSS{f}{B}{C} and \FunSS{g}{A}{B} be one to one.
          Then the composition $f \circ g$ is one to one.

    \Proof{} For every $c \in C$ such that there exists $a \in A$ such that
    $f(g(a)) = c$, suppose there do exist $x, y \in A$ such that both $f(g(x)) = c$
    and $f(g(y)) = c$. Since $f$ is injective, $g(x) = g(y)$. Since $g$ is injective
    , $x = y$. Therefore, there is at most one $x$ such that $(f \circ g)(x) =
    f(g(x)) = c$. Thus, $f \circ g$ is injective, or one to one. \QED
  \end{enumerate}
\end{exercise}

\begin{exercise}{12}
  Let $F$ be a sequence of functions:
  $$\begin{array}{rcl}
      F_0 &=& \ln \\
      F_1 &=& \ln \circ \ln \\
      F_2 &=& \ln \circ \ln \circ \ln \\
      F_3 &=& \ln \circ \ln \circ \ln \circ \ln \\
      &\vdots& \\
      F_n &=& \ln \text{composed with itself $n$ times}
    \end{array}$$

    Let $X_n$ be the (natural) domain of $F_{n}$. $X_{0}$ is the domain of $\ln$
    , namely $(0, \infty)$. For each $n \in \mathbb{N}$, $F_{n+1} = F_n \circ \ln$
    , $X_{n+1}$ is the intersection of the inverse image of $X_n$ under $\ln$
    and $\ln$'s domain $(0, \infty)$. The inverse image of a set $X$ under $\ln$
    is also the image of $X$ under the inverse function of $\ln$, namely
    $exp(x) = e^x$. Note that $exp$ is a monotonically increasing function.

  \begin{enumerate}
    \item $\ln \circ \ln = F_1 = F_0 \circ \ln$.

    $X_0 = (0, \infty)$, and its image under $exp$ is $(exp(0), exp(\infty)) = (1, \infty)$.
    The natural domain of this function is $X_1 = (1, \infty) \cap (0, \infty) = (1, \infty)$.

    \item $\ln \circ \ln \circ \ln = F_2 = F_1 \circ \ln$

    $X_1 = (1, \infty)$, and its image under $exp$ is $(exp(1), exp(\infty)) = (e, \infty)$.
    The natural domain of this function is $X_2 = (e, \infty) \cap (0, \infty) = (e, \infty)$.

    \item $\ln$ composed with itself $n$ times $= F_n = F_{n - 1} \circ \ln$

    A function \FunSS{ans}{\mathbb{Z}^+}{\mathbb{R}} can be defined as:
    $$ans(x) = \left\{
    \begin{array}{lc}
    1            & x = 1 \\
    e^{ans(x-1)} & x > 1
    \end{array}
    \right.$$.

    This function is in fact the tetration of $e$:
    $$ans(x) = {^{n}e} = \underbrace{e^{e^{\cdot^{\cdot^{e}}}}}_n$$

    Assume that for every positive integer $i$, $X_i = (ans(i), \infty)$. This
    can be proven inductively as $X_1 = (ans(1), \infty)$, $X_2 = (ans(2), \infty)$,
    and $X_i = (exp(ans(i-1)), exp(\infty)) \cap (0, \infty) = (ans(i), \infty)$.
    Therefore, the natural domain of $F_n$, or $\ln$ composed with itself $n$ times,
    is $X_n = (ans(n), \infty)$.
  \end{enumerate}
\end{exercise}