\documentclass{report}

\input{preamble}
\input{macros}
\input{letterfonts}

\usepackage{tikz}
\usepackage{tikz-3dplot}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pgfplots}
\usepackage{smartdiagram}
\usepackage{xcolor}
\usepackage{forest}
\usepgfplotslibrary{colormaps}
\usepgfplotslibrary{groupplots}
\usepgfplotslibrary{polar}
\pgfplotsset{compat=newest}
\tikzset{>=latex}
\usepackage{siunitx}
\usepackage[outline]{contour} % glow around text
\usetikzlibrary{angles,quotes} % for pic
\contourlength{1.3pt}
\usetikzlibrary{math}
\usepackage{ifthen}
\tikzset{>=latex} % for LaTeX arrow head
\usepackage{xcolor}
\colorlet{veccol}{green!70!black}
\colorlet{vcol}{green!70!black}
\colorlet{xcol}{blue!85!black}
\colorlet{projcol}{xcol!60}
\colorlet{unitcol}{xcol!60!black!85}
\colorlet{unitcol2}{vcol!60!black!85}
\colorlet{myblue}{blue!70!black}
\colorlet{myred}{red!70!black}
\tikzstyle{vector}=[->,very thick,xcol]
\tikzstyle{mydashed}=[dash pattern=on 2pt off 2pt]
\def\tick#1#2{\draw[thick] (#1) ++ (#2:0.1) --++ (#2-180:0.2)} %0.03*\xmax
\usesmartdiagramlibrary{additions}

\title{\Huge{CASMA 225}\\Calc 3}
\author{\huge{Giacomo Cappelletto}}
\date{4/9/24}

\begin{document}


\maketitle
\newpage
\pdfbookmark[section]{\contentsname}{toc}
\tableofcontents
\pagebreak

\chapter{Vector Valued Functions $f:\mathbb{R} \rightarrow \mathbb{R}^n$}

\section{Review}

\subsection{Basics}

\dfn{Notation}{

	\begin{center}
		Drawn Vectors: $\vec{v}$ \\
		Typed Vectors: \bf{v}
	\end{center}

}

\dfn{Velocity}{

	\begin{center}
		Magnitude of the velocity: $ \abs{\vec{v}} $
		\\
		Direction of the velocity: $dir(\vec{v})$
	\end{center}
}

\dfn{Heads and Tails}{

	\begin{center}
		\begin{tikzpicture}[scale=1.5]

			% Draw the vector
			\draw[->, thick] (0,0) -- (4,2) node[midway, above] {Vector $\vec{v}$};

			% Draw the tail label
			\filldraw[black] (0,0) circle (2pt);
			\node[below left] at (0,0) {Tail};

			% Draw the head label
			\filldraw[black] (4,2) circle (2pt);
			\node[above right] at (4,2) {Head};

		\end{tikzpicture}
	\end{center}
}

\nt{Scalar is like a 1 directional vector, either positive or negative, and its magnitude is the absolute value of the scalar}

\subsection{Notation}
\dfn{Positive y axis}{

	\begin{center}
		\begin{tikzpicture}[scale=2]

			% Draw the x, y, and z axes
			\draw[->, thick] (0,0,0) -- (1.5,0,0) node[anchor=north east] {$x$};
			\draw[->, thick] (0,0,0) -- (0,1.5,0) node[anchor=south east] {$y$}; % Positive y-axis
			\draw[->, thick] (0,0,0) -- (0,0,1.5) node[anchor=south] {$z$};

			% Positive y-axis with label
			\draw[->, thick, blue] (0,0,0) -- (0,1.2,0) node[midway,right] {Positive $y$-axis};

			% Draw a point at the origin
			\filldraw[black] (0,0,0) circle (1pt) node[anchor=south east] {Origin};

		\end{tikzpicture}
	\end{center}
}

\dfn{Standard Basis Vecotrs}{
	In an $n$-dimensional space $\mathbb{R}^n$, the standard basis vectors are a set of $n$ vectors where each vector has a 1 in one component and 0 in all other components. These vectors are denoted as $\mathbf{e}_i$ for $i = 1, 2, \dots, n$.

	The $i$-th standard basis vector in $\mathbb{R}^n$ is written as:

	\[
		\mathbf{e}_i =
		\begin{pmatrix}
			0                                       \\
			0                                       \\
			\vdots                                  \\
			1 \quad \text{(in the $i$-th position)} \\
			\vdots                                  \\
			0
		\end{pmatrix}
	\]

	For example, in $\mathbb{R}^3$ (three-dimensional space), the standard basis vectors are:

	\[
		\mathbf{e}_1 = \begin{pmatrix} 1 \\ 0 \\ 0 \end{pmatrix}, \quad
		\mathbf{e}_2 = \begin{pmatrix} 0 \\ 1 \\ 0 \end{pmatrix}, \quad
		\mathbf{e}_3 = \begin{pmatrix} 0 \\ 0 \\ 1 \end{pmatrix}.
	\]

	These vectors span the entire vector space $\mathbb{R}^n$, meaning any vector $\mathbf{v} \in \mathbb{R}^n$ can be written as a linear combination of the standard basis vectors:

	\[
		\mathbf{v} = v_1 \mathbf{e}_1 + v_2 \mathbf{e}_2 + \dots + v_n \mathbf{e}_n,
	\]

	where $v_1, v_2, \dots, v_n$ are the components of the vector $\mathbf{v}$.
}

\section{Operations}

\subsection{Dot Product}
\dfn{Dot (Scalar)Product Definitons}{
	The \textbf{scalar product} (or \textbf{dot product}) of two vectors \( \mathbf{a} \) and \( \mathbf{b} \) in \( \mathbb{R}^n \) is defined as:
	\[
		\mathbf{a} \cdot \mathbf{b} = a_1b_1 + a_2b_2 + \dots + a_nb_n
	\]
	In \( \mathbb{R}^3 \), for vectors \( \mathbf{a} = \begin{pmatrix} a_1 \\ a_2 \\ a_3 \end{pmatrix} \) and \( \mathbf{b} = \begin{pmatrix} b_1 \\ b_2 \\ b_3 \end{pmatrix} \), the dot product is:
	\[
		\mathbf{a} \cdot \mathbf{b} = a_1b_1 + a_2b_2 + a_3b_3
	\]
	The dot product can also be expressed in terms of the magnitudes of \( \mathbf{a} \) and \( \mathbf{b} \) and the angle \( \theta \) between them:
	\[
		\mathbf{a} \cdot \mathbf{b} = |\mathbf{a}| |\mathbf{b}| \cos \theta
	\]
	The dot product is a scalar quantity and is zero when the vectors are orthogonal (perpendicular).
	\\
	Useful to find the angle between the two vectors being dot produced together,

}

\thm{Dot Product Proof}{
	We are given the vectors $\vec{v}$ and $\vec{w}$, and we want to express the dot product in terms of their magnitudes and the angle between them.

	Start with the relationship:

	\[
		\vec{x} = \vec{v} - \vec{w}
	\]

	\begin{center}
		\begin{tikzpicture}[scale=1.5]
			% Draw vectors
			\draw[->, thick] (0,0) -- (3,0) node[anchor=north east] {$\vec{w}$};
			\draw[->, thick] (0,0) -- (1.5,2) node[anchor=south east] {$\vec{v}$};
			\draw[->, thick] (3,0) -- (1.5,2) node[anchor=south west] {$\vec{x} = \vec{v} - \vec{w}$};

			% Label the angle theta
			\draw (0.7,0) arc[start angle=0,end angle=53,radius=0.7];
			\node at (0.85,0.3) {$\theta$};

			% Draw point labels
			\node at (-0.1,-0.1) {O};
			\node at (3.2,-0.1) {A};
			\node at (1.5,2.2) {B};
		\end{tikzpicture}
	\end{center}

	The above diagram illustrates the vectors $\vec{v}$, $\vec{w}$, and their difference $\vec{x} = \vec{v} - \vec{w}$, forming a triangle. The angle $\theta$ is between $\vec{v}$ and $\vec{w}$.

	The magnitude squared of $\vec{x}$ is:

	\[
		|\vec{x}|^2 = |\vec{v}|^2 + |\vec{w}|^2 - 2|\vec{v}||\vec{w}|\cos\theta
	\]

	This is the expansion of the law of cosines.

	Now, from the equation:

	\[
		|\vec{x}|^2 = \sqrt[2]{\left( (v_x - w_x)^2 + (v_y - w_y)^2 \right)}^2
	\]

	We conclude:

	\[
		|\vec{x}|^2 = |\vec{v}|^2 + |\vec{w}|^2 - 2 (\vec{v} \cdot \vec{w})
	\]

	Thus, we can express the dot product $\vec{v} \cdot \vec{w}$ as:

	\[
		\vec{v} \cdot \vec{w} = |\vec{v}||\vec{w}|\cos\theta
	\]
}

\subsection{Applications}

\nt{
	The dot product of two vectors $\vec{v} \cdot \vec{w}$ can take different values, leading to various interpretations of the relationship between the vectors. Below is a table describing some key cases:

	\begin{center}
		\begin{tabular}{|c|c|c|}
			\hline
			\textbf{Dot Product Value}                    & \textbf{Interpretation}         & \textbf{Relationship Between Vectors}                                                         \\
			\hline
			$\vec{v} \cdot \vec{w} = 0$                   & $\cos\theta = 0$                & Vectors are \textbf{perpendicular} (orthogonal), $\theta = 90^\circ$                          \\
			\hline
			$\vec{v} \cdot \vec{w} > 0$                   & $0 < \theta < 90^\circ$         & Vectors form an \textbf{acute angle}, pointing in the same general direction                  \\
			\hline
			$\vec{v} \cdot \vec{w} < 0$                   & $90^\circ < \theta < 180^\circ$ & Vectors form an \textbf{obtuse angle}, pointing in opposite general directions                \\
			\hline
			$\vec{v} \cdot \vec{w} = |\vec{v}||\vec{w}|$  & $\cos\theta = 1$                & Vectors are \textbf{parallel} and point in the \textbf{same direction}, $\theta = 0^\circ$    \\
			\hline
			$\vec{v} \cdot \vec{w} = -|\vec{v}||\vec{w}|$ & $\cos\theta = -1$               & Vectors are \textbf{parallel} but point in \textbf{opposite directions}, $\theta = 180^\circ$ \\
			\hline
		\end{tabular}
	\end{center}
}

\dfn{Vector Product (Cross Product)}{
	The \textbf{vector product} (or \textbf{cross product}) of two vectors \( \mathbf{a} \) and \( \mathbf{b} \) in \( \mathbb{R}^3 \) is a vector \( \mathbf{c} \) that is perpendicular to both \( \mathbf{a} \) and \( \mathbf{b} \), and its magnitude is given by:
	\[
		|\mathbf{c}| = |\mathbf{a} \times \mathbf{b}| = |\mathbf{a}| |\mathbf{b}| \sin \theta
	\]
	where \( \theta \) is the angle between \( \mathbf{a} \) and \( \mathbf{b} \). The cross product is calculated as:
	\[
		\mathbf{a} \times \mathbf{b} = \begin{vmatrix}
			\hat{i} & \hat{j} & \hat{k} \\
			a_1     & a_2     & a_3     \\
			b_1     & b_2     & b_3
		\end{vmatrix} = (a_2b_3 - a_3b_2)\hat{i} - (a_1b_3 - a_3b_1)\hat{j} + (a_1b_2 - a_2b_1)\hat{k}
	\]
	The result of a cross product is a vector perpendicular to the plane formed by \( \mathbf{a} \) and \( \mathbf{b} \), with a direction given by the right-hand rule.
}

\dfn{Vector Projections} {
% Vector projection diagram

\begin{center}
	\begin{tikzpicture}
		% Draw vector w
		\draw[->, thick] (0,0) -- (6,0) node[anchor=north] {$\mathbf{w}$};

		% Draw vector u
		\draw[->, thick] (0,0) -- (5,3) node[anchor=south] {$\mathbf{u}$};

		% Projection line
		\draw[dashed] (5,3) -- (5,0) node[anchor=north] {};

		% Angle theta
		\draw[thick] (1.5,0) arc (0:30:1.5);
		\node at (1.7,0.3) {$\theta$};

		% Label projection of u on w
		\draw[->] (0,-0.3) -- (5,-0.3) node[midway,below] {$\text{proj}_{\mathbf{w}}\mathbf{u}$};
	\end{tikzpicture}
\end{center}

\[
	\text{scal}_{\mathbf{w}}\mathbf{u} = |\mathbf{u}| \cdot \cos\theta = \frac{\mathbf{w} \cdot \mathbf{u}}{|\mathbf{w}|}
\]

\[
	\text{proj}_{\mathbf{w}} \mathbf{u} = |\mathbf{u}| \cos \theta \left( \frac{\mathbf{w}}{|\mathbf{w}|} \right)
\]

\[
	\text{proj}_{\mathbf{w}} \mathbf{u} = \left( \frac{\mathbf{w} \cdot \mathbf{u}}{\mathbf{w} \cdot \mathbf{w}} \right) \mathbf{w}
\]
}

\section{Matrix Determinants}

\dfn{Matrix Representation}{
	A matrix is a collection of numbers arranged in a grid format, where each element is positioned based on its row and column. A general $m \times n$ matrix is written as:
	\[
		M =
		\begin{pmatrix}
			a_{11} & a_{12} & \cdots & a_{1n} \\
			a_{21} & a_{22} & \cdots & a_{2n} \\
			\vdots & \vdots & \ddots & \vdots \\
			a_{m1} & a_{m2} & \cdots & a_{mn} \\
		\end{pmatrix}
	\]
	For example, a $2 \times 2$ matrix is given by:
	\[
		M = \begin{pmatrix} a & b \\ c & d \end{pmatrix}
	\]
	A $3 \times 3$ matrix is:
	\[
		M = \begin{pmatrix} a & b & c \\ d & e & f \\ g & h & i \end{pmatrix}
	\]
	Matrices can be considered as a collection of vectors where each row or column can represent a vector.
}

\nt{\textbf{Vector Representation} \\
	A matrix can also be viewed as a collection of vectors. For instance, a $3 \times 3$ matrix can be interpreted as:
	\[
		M = \begin{pmatrix}
			\vec{v_1} = \langle a, b, c \rangle \\
			\vec{v_2} = \langle d, e, f \rangle \\
			\vec{v_3} = \langle g, h, i \rangle
		\end{pmatrix}
	\]
	where each row (or column) is treated as a vector in space.
}

\dfn{Determinant of a $2 \times 2$ Matrix}{
	The determinant of a $2 \times 2$ matrix is given by:
	\[
		\text{det}(M) = \det\begin{pmatrix} a & b \\ c & d \end{pmatrix} = ad - bc
	\]
	The determinant represents the signed area of the parallelogram formed by the vectors corresponding to the rows (or columns) of the matrix.


	\begin{center}
		\begin{tikzpicture}
			% Define the vectors
			\draw[->, thick] (0,0) -- (2,1) node[right] {$\vec{v_1} = \langle a, b \rangle$};
			\draw[->, thick] (0,0) -- (1,2) node[above] {$\vec{v_2} = \langle c, d \rangle$};

			% Draw the parallelogram
			\draw[dashed] (2,1) -- (3,3);
			\draw[dashed] (1,2) -- (3,3);

			% Label the area
			\node at (1.5, 1.5) {$A = |\det(M)|$};
		\end{tikzpicture}
	\end{center}

}

\nt{\textbf{Geometric Interpretation} \\
	For a $2 \times 2$ matrix, the determinant represents the area $A$ of the parallelogram formed by the two vectors $\vec{v_1} = \langle a, b \rangle$ and $\vec{v_2} = \langle c, d \rangle$. The magnitude of the determinant gives the area of this parallelogram, and the sign of the determinant indicates the orientation (whether the vectors are ordered clockwise or counterclockwise).
}

\dfn{Determinant of a $3 \times 3$ Matrix}{
	The determinant of a $3 \times 3$ matrix is calculated as:
	\[
		\text{det}(M) = \det \begin{pmatrix}
			a & b & c \\
			d & e & f \\
			g & h & i
		\end{pmatrix}
		= a \det \begin{pmatrix} e & f \\ h & i \end{pmatrix}
		- b \det \begin{pmatrix} d & f \\ g & i \end{pmatrix}
		+ c \det \begin{pmatrix} d & e \\ g & h \end{pmatrix}
	\]
	The determinant represents the signed volume of the parallelepiped formed by the three vectors corresponding to the rows (or columns) of the matrix.
	\begin{center}
		\begin{tikzpicture}
			% Define the 3D vectors
			\draw[->, thick] (0,0,0) -- (2,0,0) node[below right] {$\vec{v_1} = \langle a, b, c \rangle$};
			\draw[->, thick] (0,0,0) -- (0,2,0) node[above left] {$\vec{v_2} = \langle d, e, f \rangle$};
			\draw[->, thick] (0,0,0) -- (0,0,2) node[above] {$\vec{v_3} = \langle g, h, i \rangle$};

			% Draw the parallelepiped
			\draw[dashed] (2,0,0) -- (2,2,0) -- (2,2,2) -- (2,0,2) -- cycle;
			\draw[dashed] (0,2,0) -- (2,2,0);
			\draw[dashed] (0,0,2) -- (2,0,2);
			\draw[dashed] (0,2,2) -- (2,2,2);

			% Label the volume
			\node at (1,1,1.5) {$V = |\det(M)|$};
		\end{tikzpicture}
	\end{center}

}

\nt{\textbf{Geometric Interpretation for $3 \times 3$} \\
	In the $3 \times 3$ case, the determinant represents the volume $V$ of the parallelepiped formed by three vectors $\vec{v_1}, \vec{v_2}, \vec{v_3}$, and the sign indicates whether the orientation is right-handed or left-handed. The magnitude gives the volume.
}

\section{Matrix multiplication with 2D Vectors}

\dfn{Vector Matrix Multiplication}{

	\[
		M = \begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix}, \quad
		V = \begin{pmatrix} V_1 \\ V_2 \end{pmatrix}
	\]

	\[
		\hat{\mathbf{j}}M = \langle a_{11}V_1 + a_{12}V_2, a_{21}V_1 + a_{22}V_2 \rangle
	\]

	Given:
	\[
		\hat{i} = \langle 1, 0 \rangle \quad \hat{j} = \langle 0, 1 \rangle
	\]

	We can compute:
	\[
		iM = \langle a_{11}, a_{12} \rangle = a_1
	\]
	\[
		jM = \langle a_{21}, a_{22} \rangle = a_2
	\]

	Where:
	\[
		\mathbf{V} = V_1 \hat{i} + V_2 \hat{j}
	\]
	\[
		\hat{\mathbf{V}}M = \left( V_1 \hat{i} + V_2 \hat{j} \right) M
	\]
	\[
		= V_1 \hat{i} M + V_2 \hat{j} M
	\]
	\[
		= V_1 \mathbf{a}_1 + V_2 \mathbf{a}_2
	\]

}

\nt{
	\centering
	\includegraphics[width=0.5\textwidth]{graphicalvm.png} % Adjust the width as needed
	\par\vspace{1em} % Adds a small space after the image
}

\subsection{Effect on Area}

\dfn{$2D$}{
The original point \( (1,1) \) is transformed by the matrix \( M \). This transformation impacts the area and orientation as follows:

\[
	M = \begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix}
\]

The area after transformation is given by the determinant of the matrix:

\[
	\text{Area} = \det(M)
\]
Where the determinant is calculated as:
\[
	\det(M) = a_{11}a_{22} - a_{12}a_{21}
\]

The determinant also determines the orientation:
\[
	\det(M) = \begin{cases}
		A  & \text{if } a_1 \text{ to } a_2 \text{ is counterclockwise} \\
		-A & \text{otherwise}
	\end{cases}
\]

In the example, the original vectors \( a_1 \) and \( a_2 \) form an area, and the determinant will tell us if the vectors are oriented in a clockwise or counterclockwise fashion.

If the determinant is negative, the orientation is clockwise, as illustrated:

\[
	\det \left( \begin{pmatrix} a_1 & a_2 \end{pmatrix} \right) < 0
\]

Thus, in this case, the transformation results in a clockwise orientation.
}

\section{Matrix multiplication with 3D Vectors}

\dfn{$3D$}{
	The matrix \( M \) for a 3D transformation is given as:

	\[
		M = \begin{pmatrix}
			a_{11} & a_{12} & a_{13} \\
			a_{21} & a_{22} & a_{23} \\
			a_{31} & a_{32} & a_{33}
		\end{pmatrix}
		\quad
		\text{where} \quad
		\vec{V} = \langle V_1, V_2, V_3 \rangle
	\]

	The transformation of vector \( \vec{V} \) under matrix \( M \) is:

	\[
		\hat{\vec{V}} M = \langle (a_{11} V_1 + a_{12} V_2 + a_{13} V_3), (a_{21} V_1 + a_{22} V_2 + a_{23} V_3), (a_{31} V_1 + a_{32} V_2 + a_{33} V_3) \rangle
	\]

	This can be written in terms of the basis vectors as:
	\[
		\left( V_1 \hat{i} + V_2 \hat{j} + V_3 \hat{k} \right) M = V_1 \vec{a}_1 + V_2 \vec{a}_2 + V_3 \vec{a}_3
	\]

}

\dfn{orientation and Volume}{
	- If the determinant of matrix \( M \) is negative, the system is **left-handed**, i.e.,
	\[
		\det(M) = -V
	\]
	- The determinant of the matrix \( M \) gives the **volume** of the parallelepiped spanned by the vectors \( a_1, a_2, a_3 \):

	\[
		\det(M) = \text{Volume}(V)
	\]

	The volume \( V \) is given by:
	\[
		V = \begin{cases}
			+V & \text{if } \vec{a}_1, \vec{a}_2, \vec{a}_3 \text{ are right-handed (RHS)} \\
			-V & \text{otherwise (left-handed)}
		\end{cases}
	\]
}

\section{Cross Product and Volumes}

\dfn{Cross Product and Volumes}{
	The volume of a parallelepiped defined by three vectors \( \vec{u}, \vec{v}, \vec{w} \) is given by:
	\[
		\text{V} = \vec{u} \cdot (\vec{v} \times \vec{w})
	\]
}

\subsection{Link to Matrix Determinants}

\dfn{Cross Product and Matrix Determinants}{
	\textbf{Since:}
	\[
		\vec{u} \cdot (\vec{v} \times \vec{w}) = \det \begin{pmatrix} \vec{u} & \vec{v} & \vec{w} \end{pmatrix}
	\]

	\[
		\det \begin{pmatrix}
			u_1 & u_2 & u_3 \\
			v_1 & v_2 & v_3 \\
			w_1 & w_2 & w_3
		\end{pmatrix}
		=
		u_1 \det \begin{pmatrix} v_2 & v_3 \\ w_2 & w_3 \end{pmatrix}
		- u_2 \det \begin{pmatrix} v_1 & v_3 \\ w_1 & w_3 \end{pmatrix}
		+ u_3 \det \begin{pmatrix} v_1 & v_2 \\ w_1 & w_2 \end{pmatrix}
	\]

	\[
		= \vec{u} \cdot
		\left(
		\hat{i} \begin{vmatrix} v_2 & v_3 \\ w_2 & w_3 \end{vmatrix}
		- \hat{j} \begin{vmatrix} v_1 & v_3 \\ w_1 & w_3 \end{vmatrix}
		+ \hat{k} \begin{vmatrix} v_1 & v_2 \\ w_1 & w_2 \end{vmatrix}
		\right)
	\]

	\[
		= \vec{u} \cdot \det \begin{pmatrix} \hat{i} & \hat{j} & \hat{k} \\ v_1 & v_2 & v_3 \\ w_1 & w_2 & w_3 \end{pmatrix}
	\]

	\[
		= \vec{u} \cdot (\vec{v} \times \vec{w})
	\]

	\textbf{Therefore:}

	\[
		\vec{v} \times \vec{w} = \det \begin{pmatrix} \hat{i} & \hat{j} & \hat{k} \\ v_1 & v_2 & v_3 \\ w_1 & w_2 & w_3 \end{pmatrix}
	\]
}

\section {Cross Product Polynomial Multiplication}

\dfn{Properties}{

	\[
		\hat{i} \times \hat{j} = \hat{k}, \quad \hat{j} \times \hat{k} = \hat{i}, \quad \hat{k} \times \hat{i} = \hat{j}
	\]

	\[
		\hat{j} \times \hat{i} = -\hat{k}, \quad \hat{i} \times \hat{i} = \hat{j} \times \hat{j} = \hat{k} \times \hat{k} = 0
	\]
}

\ex{Example: Cross Product}{
	Let \( \vec{v} = 2\hat{i} - \hat{j} - 3\hat{k} \) and \( \vec{w} = \hat{i} + \hat{j} + \hat{k} \). The cross product \( \vec{v} \times \vec{w} \) is computed as:

	\[
		\vec{v} \times \vec{w} = \left( 2\hat{i} - \hat{j} - 3\hat{k} \right) \times \left( \hat{i} + \hat{j} + \hat{k} \right)
	\]

	Expanding the cross product term by term:

	\[
		= 2\hat{i} \times \hat{i} + 2\hat{i} \times \hat{j} + 2\hat{i} \times \hat{k}
		- \hat{j} \times \hat{i} - \hat{j} \times \hat{j} - \hat{j} \times \hat{k}
		- 3\hat{k} \times \hat{i} - 3\hat{k} \times \hat{j} - 3\hat{k} \times \hat{k}
	\]

	Using the cross product identities:

	\[
		= 0 + 2\hat{k} + 2(-\hat{j})
		- (-\hat{k}) + 0 - \hat{i}
		- 3\hat{j} + 3\hat{i} + 0
	\]

	Combining like terms:

	\[
		= (3\hat{i} - \hat{i}) + (-2\hat{j} - 3\hat{j}) + (2\hat{k} + \hat{k})
	\]

	\[
		= 2\hat{i} - 5\hat{j} + 3\hat{k}
	\]

	Thus, the final result is:

	\[
		\vec{v} \times \vec{w} = 2\hat{i} - 5\hat{j} + 3\hat{k}
	\]
}

\section{Torque}

\dfn{Torque and Angular Momentum}{
	Continue with Torque
}


\section{Parametric Equations}

\dfn{Parametric Equations}{
	A parametric equation expresses a set of quantities as explicit functions of an independent parameter. In a two-dimensional case, a parametric equation for a curve can be represented as:
	\[
		\langle x,y  \rangle t = \langle f(t), g(t) \rangle
	\]
	and in three dimensions as:
	\[
		\langle x, y, z \rangle t = \langle f(t), g(t), h(t) \rangle
	\]
}

\nt{
	For example, consider the curve in the plane given by the equation \( y = f(x) = x^2 + 1 \). This describes a parabola in Cartesian coordinates.
}

\thm{Parametric unit circle in Cartesian coordinates}{
	A unit circle in parametric form can be represented as:
	\[
		x^2 + y^2 = 1
	\]
	which corresponds to the parametric equations:
	\[
		\langle x,y  \rangle t = \langle \cos(t), \sin(t) \rangle
	\]
}

\subsection{Examples}

\nt{
	The parametric equation:
	\[
		\langle x,y  \rangle t = \langle 4 \cos(t), 3 \sin(t) \rangle
	\]
	At specific values of \( t \), we can compute the points:
	\[
		t = 0 \implies \langle 4, 0 \rangle
	\]
	\[
		t = \frac{\pi}{2} \implies \langle 0, 3 \rangle
	\]
	\[
		t = \pi \implies \langle -4, 0 \rangle
	\]
	\[
		t = \frac{3\pi}{2} \implies \langle 0, -3 \rangle
	\]
}

\dfn{Parametric for a Helix}{
	\[
		\langle x(t), y(t), z(t) \rangle = \langle 4 \cos(t), 3 \sin(t), 0.1t \rangle
	\]
}

% The figure needs to be outside the definition environment
\begin{figure}[!htbp]
	\centering
	\vspace*{10pt}
	\begin{tikzpicture}
		\begin{axis}[mesh,
				samples=100,
				xlabel={$x$},
				ylabel={$y$},
				zlabel={$z$},
				view={60}{30},
				grid=both,
			]
			\addplot3 [
				domain=0:10,
				samples=50,
			]
			({4*cos(deg(x))}, {3*sin(deg(x))}, {0.1*x});
		\end{axis}
	\end{tikzpicture}
	\caption{3D plot of a parametric helix.}
	\label{fig:3dplot}
\end{figure}

\thm{Parametric Equation of a Line}{
	The parametric equation of a line can be expressed as:
	\[
		\langle x, y, z \rangle t = \mathbf{OP} + \mathbf{V}t
	\]
	Where:
	\begin{itemize}
		\item \( \mathbf{OP} = \langle x_0, y_0, z_0 \rangle \) is the position vector to the initial point \( P \),
		\item \( \mathbf{V} = \langle v_x, v_y, v_z \rangle \) is the direction vector of the line.
	\end{itemize}
}

\qs{3D Parametric Equation of a Line}{
	\begin{itemize}
		\item \( \mathbf{OP} = \langle 1, 2, 3 \rangle \) is the position vector to the initial point \( P \),
		\item \( \mathbf{V} = \langle 1, 1, 1 \rangle \) is the direction vector of the line.
	\end{itemize}
	Thus, the parametric equation of the line becomes:
	\[
		\langle x(t), y(t), z(t) \rangle = \langle 1, 2, 3 \rangle + t \langle 1, 1, 1 \rangle
	\]
	\[
		x(t) = 1 + t, \quad y(t) = 2 + t, \quad z(t) = 3 + t
	\]
	Or simply:
	\[
		\langle x, y, z \rangle t = \langle 1+t, 2+t, 3+t \rangle
	\]

}

\sol


% The figure for the parametric line
\begin{figure}[!htbp]
	\centering
	\vspace*{10pt}
	\begin{tikzpicture}
		\begin{axis}[mesh,
				samples=100,
				xlabel={$x$},
				ylabel={$y$},
				zlabel={$z$},
				view={60}{30},
				grid=both,
			]
			% Plot the parametric line
			\addplot3 [
				domain=0:10,
				samples=50,
				thick,
				color=blue,
			]
			({1 + x}, {2 + x}, {3 + x});

			% Mark the initial point OP = (1, 2, 3)
			\addplot3 [
				only marks,
				mark=ball,
				mark size=3pt,
				color=red,
			]
			coordinates {(1, 2, 3)};

			% Label the initial point
			\node at (axis cs:1, 2, 3) [anchor=west] {P (1, 2, 3)};

			% Plot the vector from the origin
			\addplot3 [
				-stealth,
				thick,
				color=green,
			]
			coordinates {(0, 0, 0) (1, 2, 3)};

			% Label the vector
			\node at (axis cs:0.5, 1, 1.5) [anchor=east] {OP};

			% Mark another point on the line for t = 3, (4, 5, 6)
			\addplot3 [
				only marks,
				mark=ball,
				mark size=3pt,
				color=red,
			]
			coordinates {(4, 5, 6)};

			% Label the point
			\node at (axis cs:4, 5, 6) [anchor=west] {Point (4, 5, 6)};
		\end{axis}
	\end{tikzpicture}
	\caption{3D plot of a parametric line with vector OP and points.}
	\label{fig:3dlineplot}
\end{figure}


\section{Distance from a Point to a Line}

\dfn{Parametric Equation of the Line}{
	The line is represented by:
	\[
		\mathbf{l} = \mathbf{OP} + t \mathbf{V}
	\]
	Where:
	\begin{itemize}
		\item \( \mathbf{OP} \) is the position vector of a point on the line,
		\item \( \mathbf{V} \) is the direction vector of the line.
	\end{itemize}
}

\thm{Distance from a Point to a Line}{
	The distance \( d \) from a point \( Q \) to the line \( l \) is given by:
	\[
		d = \frac{| \mathbf{V} \times \mathbf{PQ} |}{| \mathbf{V} |}
	\]
	Where:
	\begin{itemize}
		\item \( \mathbf{PQ} \) is the vector from point \( P \) on the line to the point \( Q \),
		\item \( \mathbf{V} \times \mathbf{PQ} \) is the cross product of the direction vector \( \mathbf{V} \) and the vector \( \mathbf{PQ} \).
	\end{itemize}
}

\subsection{Example}

\qs{Find the distance from the point \( Q = (3, 4, 0) \) to the line \( l \) given by the parametric equation}{
	\[
		\mathbf{l} = \langle t, 1, 2t \rangle = \langle 0, 1, 0 \rangle + t \langle 1, 0, 2 \rangle
	\]
	with point \( P = (0, 1, 0) \) and direction vector \( \mathbf{V} = \langle 1, 0, 2 \rangle \).
}

\sol
The vector \( \mathbf{PQ} \) from \( P = (0, 1, 0) \) to \( Q = (3, 4, 0) \) is:
\[
	\mathbf{PQ} = \langle 3, 4, 0 \rangle - \langle 0, 1, 0 \rangle = \langle 3, 3, 0 \rangle
\]
Now, we compute the cross product \( \mathbf{V} \times \mathbf{PQ} \):
\[
	\mathbf{V} \times \mathbf{PQ} = \begin{vmatrix}
		\hat{i} & \hat{j} & \hat{k} \\
		1       & 0       & 2       \\
		3       & 3       & 0       \\
	\end{vmatrix}
	= \hat{i}(0 - 6) - \hat{j}(0 - 6) + \hat{k}(3 - 0) = \langle -6, -6, 3 \rangle
\]
Next, calculate the magnitude of the cross product:
\[
	|\mathbf{V} \times \mathbf{PQ}| = \sqrt{(-6)^2 + (-6)^2 + 3^2} = \sqrt{36 + 36 + 9} = \sqrt{81} = 9
\]
The magnitude of the direction vector \( \mathbf{V} \) is:
\[
	|\mathbf{V}| = \sqrt{1^2 + 0^2 + 2^2} = \sqrt{1 + 4} = \sqrt{5}
\]
Finally, the distance \( d \) is:
\[
	d = \frac{9}{\sqrt{5}} = \frac{9\sqrt{5}}{5}
\]


\section{Intersection of Two Parametric Lines}

\dfn{Intersection of Parametric Lines}{
	To find the intersection point of two parametric lines, we need to equate their parametric equations and solve for the parameters.
}

\qs{Find the intersection of the lines \( l_1 \) and \( l_2 \) given by the parametric equations}{
	\[
		l_1 = \langle x, y \rangle (t) = \langle 0, 1 \rangle + t \langle 1, 0 \rangle
	\]
	\[
		l_2 = \langle 1, 1 \rangle + s \langle -2, 1 \rangle
	\]
}

\sol
Equating the two parametric equations:
\[
	\langle 0, 1 \rangle + t \langle 1, 0 \rangle = \langle 1, 1 \rangle + s \langle -2, 1 \rangle
\]
This gives the system of equations:
\[
	0 + t = 1 - 2s
\]
\[
	1 + 0 = 1 + s
\]

From the second equation, we find:
\[
	s = 0
\]

Substitute \( s = 0 \) into the first equation:
\[
	t = 1
\]

Thus, the lines intersect when \( t = 1 \) and \( s = 0 \).

The intersection point is:
\[
	\langle 0, 1 \rangle + 1 \cdot \langle 1, 0 \rangle = \langle 1, 1 \rangle
\]
Therefore, the lines intersect at \( (1, 1) \).

\section{Planes}

\dfn{Plane Equation}{
	Given a point \(P_0 = (x_0, y_0, z_0)\) on the plane and a normal vector \(\vec{n} = \langle a, b, c \rangle\), the equation of the plane can be expressed as:
	\[
		a(x - x_0) + b(y - y_0) + c(z - z_0) = 0
	\]
}

\nt{\textbf{Vector Form} \\
	Alternatively, the plane equation can also be derived using the dot product form:
	\[
		\overrightarrow{PQ} \cdot \vec{n} = 0
	\]
	Where \(P = (x_0, y_0, z_0)\) and \(Q = (x, y, z)\). This leads to the scalar equation of the plane.
}

\thm{Equation of a Plane}{
	If a plane passes through the point \(P_0 = (x_0, y_0, z_0)\) and has a normal vector \(\vec{n} = \langle a, b, c \rangle\), the equation of the plane is:
	\[
		a(x - x_0) + b(y - y_0) + c(z - z_0) = 0
	\]
}

\qs{Example}{
	Given the point \(P_0 = (1, -2, 3)\) and the normal vector \(\vec{n} = \langle -2, -4, -6 \rangle\), find the equation of the plane.
}

\sol
Using the plane equation \(a(x - x_0) + b(y - y_0) + c(z - z_0) = 0\), substitute \(a = -2\), \(b = -4\), \(c = -6\), and \(P_0 = (1, -2, 3)\):
\[
	-2(x - 1) - 4(y + 2) - 6(z - 3) = 0
\]
Expanding this equation:
\[
	-2x + 2 - 4y - 8 - 6z + 18 = 0
\]
Simplifying:
\[
	-2x - 4y - 6z + 12 = 0
\]
Or:
\[
	2x + 4y + 6z = 12
\]

\section{Vector Valued Functions}

\dfn{Parametric Curves}{
	A parametric curve is defined as:
	\[
		\vec{r}(t) = \langle x(t), y(t), z(t) \rangle = \langle f(t), h(t), g(t) \rangle
	\]
	where \(t\) is a real number as input, and the output is a vector.
}

\qs{Example}{
	Let \(\vec{r}(t) = \langle t^2, t+1, \sqrt{t - 2} \rangle\). Determine the domain of \(\vec{r}(t)\).
}

\sol
The domain of \(\vec{r}(t)\) is \(t \geq 2\).


\dfn{Limits of Vector Functions}{
	The limit of a vector function \(\vec{r}(t)\) as \(t \to a\) can be visualized geometrically as the vector approaching a point \(\vec{L}\). If the magnitude of the difference between \(\vec{L}\) and \(\vec{r}(t)\) approaches zero, we can define:
	\[
		\lim_{t \to a} \vec{r}(t) = \vec{L} \quad \text{if} \quad \lim_{t \to a} |\vec{L} - \vec{r}(t)| = 0
	\]
}


\begin{center}
	\begin{minipage}{0.32\textwidth}
		\begin{tikzpicture}
			% Axes
			\draw[->] (-2, 0) -- (2, 0) node[right] {};
			\draw[->] (0, -2) -- (0, 2) node[above] {};

			% Vectors from origin
			\draw[->] (0,0) -- (1.5, 0.8) node[right] {$\vec{r}(t_1)$};
			\draw[->] (0,0) -- (0.8, 1.5) node[above right] {$\vec{r}(t_2)$};
			\draw[->] (0,0) -- (1.6, 1.2) node[right] {$\vec{r}(t_n)$};
			\draw[->] (0,0) -- (1.1, 0.5) node[right] {$\vec{L}$};
		\end{tikzpicture}
	\end{minipage}%
	\begin{minipage}{0.32\textwidth}
		\begin{tikzpicture}
			% Triangle
			\draw[->] (0, 0) -- (2, 0) node[right] {$\vec{L}$};
			\draw[->] (0, 0) -- (1.5, 1.5) node[above right] {$\vec{r}(t)$};
			\draw[dashed] (1.5, 1.5) -- (2, 0);

			% Distance label
			\node at (1.8, 1.0) {$|\vec{L} - \vec{r}(t)|$};
		\end{tikzpicture}
	\end{minipage}
\end{center}


\nt{Component-wise Limits \\
	The limit of a vector function can be evaluated by taking the limit of each of its components:
	\[
		\lim_{t \to a} \vec{r}(t) = \langle \lim_{t \to a} x(t), \lim_{t \to a} y(t), \lim_{t \to a} z(t) \rangle
	\]
}

\qs{Example}{
	Consider the vector function \(\vec{r}(t) = \langle \frac{t^2 + 2t + 1}{t + 1}, t, t - 2 \rangle\), as \(t \to -1\).
}

\sol
The limits of each component as \(t \to -1\) are:

\[
	\lim_{t \to -1} \vec{r}(t) = \langle 0, -1, -3 \rangle
\]

\pagebreak

\section{Calculus and Vector Valued Functions}

\subsection{Derivative}

\thm{Derivative of vector functions}{
	Consider the vector-valued function in 3D:
	\[
		\vec{r}(t) = \langle f(t), g(t), h(t) \rangle
	\]
	where \( f(t), g(t) \), and \( h(t) \) are differentiable functions. The derivative of \( \vec{r}(t) \) is defined as:
	\[
		\vec{r}'(t) = \lim_{h \to 0} \frac{\vec{r}(t+h) - \vec{r}(t)}{h}
	\]

	Expanding \( \vec{r}(t+h) - \vec{r}(t) \):
	\[
		\vec{r}(t+h) - \vec{r}(t) = \langle f(t+h), g(t+h), h(t+h) \rangle - \langle f(t), g(t), h(t) \rangle
	\]
	This gives us:
	\[
		\vec{r}(t+h) - \vec{r}(t) = \langle f(t+h) - f(t), g(t+h) - g(t), h(t+h) - h(t) \rangle
	\]

	Thus, the derivative becomes:
	\[
		\vec{r}'(t) = \lim_{h \to 0} \left\langle \frac{f(t+h) - f(t)}{h}, \frac{g(t+h) - g(t)}{h}, \frac{h(t+h) - h(t)}{h} \right\rangle
	\]

	Since \( f(t), g(t) \), and \( h(t) \) are differentiable, we apply the definition of derivatives for each component:
	\[
		\vec{r}'(t) = \left\langle \lim_{h \to 0} \frac{f(t+h) - f(t)}{h}, \lim_{h \to 0} \frac{g(t+h) - g(t)}{h}, \lim_{h \to 0} \frac{h(t+h) - h(t)}{h} \right\rangle
	\]
	\[
		\vec{r}'(t) = \langle f'(t), g'(t), h'(t) \rangle
	\]

	Therefore, the derivative of the vector-valued function \( \vec{r}(t) \) in 3D is:
	\[
		\boxed{\vec{r}'(t) = \langle f'(t), g'(t), h'(t) \rangle}
	\]
}

\dfn{Vector Representation}{

	Let \( \vec{r}(t) \) be a vector-valued function that describes the position of a particle over time \( t \):
	\[
		\vec{r}(t) = \langle x(t), y(t), z(t) \rangle
	\]
	where \( x(t), y(t), z(t) \) are differentiable functions. The following terms describe important properties of the function:



	\begin{enumerate}
		\item \textbf{Position} at time \( t \): \( \vec{r}(t) \)
		\item \textbf{Velocity} (tangent vector) \( \vec{r}'(t) = \langle x'(t), y'(t), z'(t) \rangle \)
		\item \textbf{Speed} \( |\vec{r}'(t)| \), the magnitude of the velocity.
		\item \textbf{Acceleration} \( \vec{r}''(t) = \langle x''(t), y''(t), z''(t) \rangle \)

	\end{enumerate}
}

\dfn{Unit Tangent Vector}{

	The unit tangent vector is given by:
	\[
		\hat{T}(t) = \frac{\vec{r}'(t)}{|\vec{r}'(t)|}
	\]
	This is the unit vector in the direction of the velocity vector \( \vec{r}'(t) \), which represents the direction of motion.
}

\qs{Example}{
	Consider the following vector-valued function:
	\[
		\vec{r}(t) = \langle 1 + t^2, 2 + t^2, 3 + t^2 \rangle
	\]
	Taking the derivative:
	\[
		\vec{r}'(t) = \langle 2t, 2t, 2t \rangle
	\]
	This describes a line with a constant acceleration:
	\[
		\vec{r}''(t) = \langle 2, 2, 2 \rangle
	\]
}

\begin{tikzpicture}
	% The curve of position
	\draw[thick] (0,0) to[out=70,in=180] (4,4) to[out=0,in=160] (8,1);

	% Time labels
	\node at (0, 0) [below] {$t = 0$};
	\node at (4, 4) [above] {$t = 1$};
	\node at (8, 1) [right] {$t = 3$};

	% Velocity arrow at t=1
	\draw[->, magenta, thick] (4, 4) -- (6.5, 4) node[above right] {$\vec{r}'(t)$};

	% Acceleration arrow at t=3
	\draw[->, blue, thick] (8, 1) -- (9.5, 1.5) node[above] {$\vec{r}''(t)$};

	% Labels for position, velocity, acceleration
	\node at (3, 2) [green] {$\vec{r}(t)$};
	\node at (6, 5) [magenta] {Velocity $\vec{r}'(t)$};
	\node at (8.5, 0.5) [blue] {Acceleration $\vec{r}''(t)$};
\end{tikzpicture}

\dfn{Derivatives of Parametric Curves in terms of $t$}{

	Given a parametric curve defined by:
	\[
		x = f(t), \quad y = g(t)
	\]
	where \(t\) is the parameter, we want to find the derivative \(\frac{dy}{dx}\), which represents the slope of the tangent to the curve at any point \(t\).

	\textbf{Step 1: Finding the Derivatives of \(x\) and \(y\) with respect to \(t\)}
	To find \(\frac{dy}{dx}\), we need to find both \(\frac{dx}{dt}\) and \(\frac{dy}{dt}\). These are given by:
	\[
		\frac{dx}{dt} = f'(t), \quad \frac{dy}{dt} = g'(t)
	\]

	\textbf{Step 2: Using the Chain Rule}
	The derivative \(\frac{dy}{dx}\) can be found by using the chain rule as follows:
	\[
		\frac{dy}{dx} = \frac{\frac{dy}{dt}}{\frac{dx}{dt}}
	\]
	Substituting the expressions for \(\frac{dx}{dt}\) and \(\frac{dy}{dt}\), we obtain:
	\[
		\frac{dy}{dx} = \frac{g'(t)}{f'(t)}
	\]

	\textbf{Step 3: Simplifying the Result}
	The expression \(\frac{dy}{dx}\) provides the slope of the curve at any point \(t\) in terms of the parameter.
}

\ex{Consider the parametric equations:}{

	\[
		x = 6 \sin t, \quad y = 6 \cos t
	\]

	To find \(\frac{dy}{dx}\), we calculate the derivatives with respect to \(t\):
	\[
		\frac{dx}{dt} = 6 \cos t, \quad \frac{dy}{dt} = -6 \sin t
	\]

	Then, we apply the formula:
	\[
		\frac{dy}{dx} = \frac{\frac{dy}{dt}}{\frac{dx}{dt}} = \frac{-6 \sin t}{6 \cos t}
	\]

	Simplifying the expression:
	\[
		\frac{dy}{dx} = -\tan t
	\]

	Therefore, the slope of the tangent line to the parametric curve at any point \(t\) is:
	\[
		\frac{dy}{dx} = -\tan t
	\]
}

\dfn{Chain Rule Derivation}{
	\[
		\frac{dy}{dt} = \frac{dy}{du} \cdot \frac{dx}{dt} \quad \Rightarrow \quad \frac{dy}{dx} = \frac{\frac{dy}{dt}}{\frac{dx}{dt}}
		\quad \Rightarrow \quad \frac{dy}{dx} = \frac{du}{dt}
	\]
}

\qs{Example}{
	Slope of
	\[
		\vec{r}(t) = \langle \cos(t), \sin(t) \rangle
	\]

	At \( t = \frac{\pi}{3} \):

}

\sol

\[
	\cos\left(\frac{\pi}{3}\right) = \frac{1}{2}, \quad \sin\left(\frac{\pi}{3}\right) = \frac{\sqrt{3}}{2}
\]


\[
	\vec{r}'(t) = \langle -\sin(t), \cos(t) \rangle
\]


At \( t = \frac{\pi}{3} \):

\[
	\vec{r}'\left(\frac{\pi}{3}\right) = \langle -\frac{\sqrt{3}}{2}, \frac{1}{2} \rangle
\]

Slope Calculation
\[
	\text{slope} = \frac{\frac{-1}{2}}{\frac{-\sqrt{3}}{2}} = \frac{1}{\sqrt{3}} = \frac{\sqrt{3}}{3}
\]

Vector Notation
\[
	\vec{r}'(t) = \langle -\sin(t), \cos(t) \rangle \quad \text{so} \quad \vec{r}'\left(\frac{\pi}{3}\right) = \langle -\frac{\sqrt{3}}{2}, \frac{1}{2} \rangle
\]

\subsection{Chain Rule}

\dfn{Chain Rule for VV}{

	Let $g : \mathbb{R} \to \mathbb{R}$ and $\vec{r}(t)$ be a vector function. The derivative of the composition of functions is:

	\[
		\frac{d}{dt}[g(\vec{r}(t))] = g'(\vec{r}(t)) \cdot \vec{r}'(t)
	\]

	where $g'(\vec{r}(t))$ is the derivative of $g$ with respect to the vector function $\vec{r}(t)$ and $\vec{r}'(t)$ is the derivative of the vector function $\vec{r}(t)$ with respect to $t$. This rule is useful for differentiating scalar functions composed with vector-valued functions.

}

\qs{Example}{

\[
	\vec{r}(t) = \langle \cos^2 t, -3t + \cos^3 t \rangle = \dot{\vec{r}}(g(t))
\]
\[
	y = \cos t, \quad \vec{r} = \langle t^2, -3t, 3t^3 \rangle
\]
\[
	g' = -\sin t, \quad \dot{\vec{r}} = \langle 2t, 3t^2 \rangle
\]

Thus, the derivative is:

\[
\vec{s}(t) = \frac{d}{dt} \left( g(y(t)) \vec{r}(g(t)) \right) = g'(t) \cdot \dot{\vec{r}}(g(t))
\]

\[
= -\sin t \cdot \langle 2\cos t, 3\cos^2 t \rangle
\]

}

\subsection{Product Rule}

\dfn{Product rule for VV}{

	Let $g(t): \mathbb{R} \to \mathbb{R}$, $\vec{r}(t): \mathbb{R} \to \mathbb{R}^n$, and $\vec{s}(t): \mathbb{R} \to \mathbb{R}^n$ be vector functions. Then, the product rule is:

	\[
		\frac{d}{dt} \left( g(t) \vec{r}(t) \right) = g'(t) \vec{r}(t) + g(t) \dot{\vec{r}}(t)
	\]

	For vector dot products:

	\[
		\frac{d}{dt} \left( \vec{r}(t) \cdot \vec{s}(t) \right) = \vec{r}'(t) \cdot \vec{s}(t) + \vec{r}(t) \cdot \vec{s}'(t)
	\]

	For vector cross products:

	\[
		\frac{d}{dt} \left( \vec{r}(t) \times \vec{s}(t) \right) = \vec{r}'(t) \times \vec{s}(t) + \vec{r}(t) \times \vec{s}'(t)
	\]

}

\subsection{Integrals}

\dfn{Integral of Vector-Valued Functions}{

Let $\vec{r}(t): [a,b] \to \mathbb{R}^n$ be a continuous vector-valued function. The definite integral of $\vec{r}(t)$ over the interval $[a,b]$ is defined as:

\[
	\int_a^b \vec{r}(t) \, dt = \langle \int_a^b r_1(t) \, dt, \int_a^b r_2(t) \, dt, \dots, \int_a^b r_n(t) \, dt \rangle
\]

where $\vec{r}(t) = \langle r_1(t), r_2(t), \dots, r_n(t) \rangle$. This means that the integral of a vector-valued function is the vector whose components are the integrals of the respective component functions.

For example, if $\vec{r}(t) = \langle f(t), g(t), h(t) \rangle$, then:

\[
	\int_a^b \vec{r}(t) \, dt = \langle \int_a^b f(t) \, dt, \int_a^b g(t) \, dt, \int_a^b h(t) \, dt \rangle
\]

This can be extended to cases where $\vec{r}(t)$ represents the position of a particle over time, and the integral represents the net displacement of the particle over the interval $[a,b]$.

}

\qs{Find the integral of the vector-valued function}{Calculate the integral of the vector-valued function \(\vec{r}(t) = \langle t^2, \sin t, e^t \rangle\) over the interval \(t \in [0, 1]\).}

\sol

The vector-valued function is given as:

\[
	\vec{r}(t) = \langle t^2, \sin t, e^t \rangle
\]

We can integrate each component of the vector separately over the interval \([0, 1]\):

\[
	\int_0^1 \vec{r}(t) \, dt = \langle \int_0^1 t^2 \, dt, \int_0^1 \sin t \, dt, \int_0^1 e^t \, dt \rangle
\]

Now, solving each integral:

1. For \(\int_0^1 t^2 \, dt\):

\[
	\int_0^1 t^2 \, dt = \left[ \frac{t^3}{3} \right]_0^1 = \frac{1^3}{3} - \frac{0^3}{3} = \frac{1}{3}
\]

2. For \(\int_0^1 \sin t \, dt\):

\[
	\int_0^1 \sin t \, dt = \left[ -\cos t \right]_0^1 = -\cos(1) + \cos(0) = 1 - \cos(1)
\]

3. For \(\int_0^1 e^t \, dt\):

\[
	\int_0^1 e^t \, dt = \left[ e^t \right]_0^1 = e^1 - e^0 = e - 1
\]

Thus, the result of the integral is:

\[
	\int_0^1 \vec{r}(t) \, dt = \langle \frac{1}{3}, 1 - \cos(1), e - 1 \rangle
\]

\qs{Find the position vector of a ball in 3D space}{A ball is thrown from the origin with an initial velocity vector \(\vec{v}(0) = \langle 1, 3, 5 \rangle\) m/s, and experiences a constant acceleration vector \(\vec{a}(t) = \langle 0, 0, -10 \rangle\) m/s\(^2\). Find the position vector \(\vec{r}(t)\) of the ball at any time \(t\).}

\sol

The velocity vector \(\vec{v}(t)\) is found by integrating the acceleration vector \(\vec{a}(t)\):

\[
	\vec{v}(t) = \int_0^t \vec{a}(s) \, ds + \vec{v}(0)
\]

Given that \(\vec{a}(t) = \langle 0, 0, -10 \rangle\), we integrate each component:

\[
	\vec{v}(t) = \int_0^t \langle 0, 0, -10 \rangle \, ds + \langle 1, 3, 5 \rangle
\]
\[
	= \langle 0, 0, -10t \rangle + \langle 1, 3, 5 \rangle
\]
\[
	\vec{v}(t) = \langle 1, 3, 5 - 10t \rangle
\]

Now, to find the position vector \(\vec{r}(t)\), we integrate the velocity vector \(\vec{v}(t)\):

\[
	\vec{r}(t) = \int_0^t \vec{v}(s) \, ds
\]
\[
	= \int_0^t \langle 1, 3, 5 - 10s \rangle \, ds
\]

Integrating each component:

1. For the first component:
\[
	\int_0^t 1 \, ds = t
\]

2. For the second component:
\[
	\int_0^t 3 \, ds = 3t
\]

3. For the third component:
\[
	\int_0^t (5 - 10s) \, ds = \left[ 5s - 5s^2 \right]_0^t = 5t - 5t^2
\]

Thus, the position vector is:

\[
	\vec{r}(t) = \langle t, 3t, 5t - 5t^2 \rangle
\]

\pagebreak

\section{Arc Length}

The arc length of a smooth curve given by a vector-valued function can be calculated using an integral. Let the position vector of a curve be represented as:
\[
	\vec{r}(t) = \langle f(t), g(t), h(t) \rangle,
\]
where \(t\) is the parameter over some interval \([a, b]\).

\dfn{Arc Length Formula}{
	The arc length \(L\) of the curve \(\vec{r}(t)\) over the interval \([a, b]\) is given by:
	\[
		L = \int_a^b \left| \vec{r}'(t) \right| \, dt,
	\]
	where \(\vec{r}'(t)\) is the derivative of the position vector, representing the velocity vector of the curve.

	To find \(\left| \vec{r}'(t) \right|\), we use the following:
	\[
		\left| \vec{r}'(t) \right| = \sqrt{\left( f'(t) \right)^2 + \left( g'(t) \right)^2 + \left( h'(t) \right)^2}.
	\]

	Therefore, the arc length formula can be explicitly written as:
	\[
		L = \int_a^b \sqrt{\left( f'(t) \right)^2 + \left( g'(t) \right)^2 + \left( h'(t) \right)^2} \, dt.
	\]
}

\qs{Example: Eagle Spiraling}{
	Consider an example where an eagle is spiraling in space, and its position at time \(t\) (in minutes) is given by:
	\[
		\vec{r}(t) = \langle 250 \cos(t), 250 \sin(t), 100t \rangle \quad \text{(in feet)}.
	\]
}

\sol

To find the velocity vector, we differentiate each component of \(\vec{r}(t)\):
\[
	\vec{r}'(t) = \langle -250 \sin(t), 250 \cos(t), 100 \rangle \quad \text{(in feet per minute)}.
\]

The magnitude of the velocity vector \(\left| \vec{r}'(t) \right|\) is:
\[
	\left| \vec{r}'(t) \right| = \sqrt{(-250 \sin(t))^2 + (250 \cos(t))^2 + (100)^2}.
\]
Simplifying, we obtain:
\[
	\left| \vec{r}'(t) \right| = \sqrt{250^2 \sin^2(t) + 250^2 \cos^2(t) + 100^2}.
\]

Using the Pythagorean identity \(\sin^2(t) + \cos^2(t) = 1\), we find:
\[
	\left| \vec{r}'(t) \right| = \sqrt{250^2 + 100^2} = \sqrt{62500 + 10000} = \sqrt{72500} \approx 269.3 \quad \text{(feet per minute)}.
\]

Therefore, the speed of the eagle is approximately \(269.3\) feet per minute.

\qs{Calculating Distance Over Time}{Find the total distance over 10 minutes}

\sol

To find the total distance traveled by the eagle over a period of 10 minutes, we compute the arc length:
\[
	\text{Distance} = \int_0^{10} \left| \vec{r}'(t) \right| \, dt = \int_0^{10} 269.3 \, dt.
\]

Evaluating the integral:
\[
	\text{Distance} = 269.3 \cdot (10 - 0) = 2693 \text{ feet}.
\]

Thus, over 10 minutes, the eagle travels approximately 2693 feet.

\dfn{Arc Length Function}{
	The arc length function, denoted by \(S(t)\), is defined as:
	\[
		S(t) = \text{distance traveled along the curve from } t = a.
	\]
	It is given by the integral:
	\[
		S(t) = \int_a^t \left| \vec{r}'(s) \right| \, ds.
	\]
	This function essentially converts the vector quantity \(\vec{r}(t)\) into a 1-dimensional scalar that measures the total distance traveled without considering direction.

	The arc length function \(S(t)\) effectively flattens the vector \(\vec{r}(t)\) into a scalar by integrating the magnitude of the velocity vector \(\vec{r}'(s)\) over the interval \([a, t]\).
}

\ex{Application: Reparametrization by Arc Length}{
One common use of the arc length function is to reparametrize the curve so that it is traveled at unit speed.

Given the inverse function of \(S(t)\), denoted as \(S^{-1}(t)\), we wish to compare:
\[
	\vec{r}\left( S^{-1}(t) \right) \quad \text{with} \quad \vec{r}(t).
\]


If \(S(t)\) is given by:
\[
	S(t) = \int_a^t \left| \vec{r}'(p) \right| \, dp,
\]
then \(S'(t) = \left| \vec{r}'(t) \right|\).

To differentiate \(\vec{r}(S^{-1}(t))\), we use the chain rule:
\[
	\frac{d}{dt} \vec{r}(S^{-1}(t)) = \frac{1}{S'(S^{-1}(t))} \vec{r}'(S^{-1}(t)).
\]

Since \(S'(S^{-1}(t)) = \left| \vec{r}'(S^{-1}(t)) \right|\), we have:
\[
	\frac{d}{dt} \vec{r}(S^{-1}(t)) = \frac{\vec{r}'(S^{-1}(t))}{\left| \vec{r}'(S^{-1}(t)) \right|}.
\]
This shows that the derivative of \(\vec{r}(S^{-1}(t))\) is a unit vector, implying that \(\vec{r}(S^{-1}(t))\) describes the same curve as \(\vec{r}(t)\), but at unit speed.

By reparametrizing the curve with respect to arc length, we achieve a uniform traversal of the curve at constant unit speed. The transformation \(\vec{r}(S^{-1}(t))\) provides a way to describe the geometry of the curve without the influence of varying speed.

}

\qs{Worked Example}{
Consider the position of an eagle as it spirals upward over time. The position vector \(\vec{r}(t)\) is given by:
\[
	\vec{r}(t) = \langle 250 \cos(t), 250 \sin(t), 100t \rangle \quad \text{(in feet)},
\]
where \(t\) is in minutes.

\subsection*{Step 1: Find the Speed of the Eagle}
The velocity vector is obtained by differentiating the position vector:
\[
	\vec{r}'(t) = \langle -250 \sin(t), 250 \cos(t), 100 \rangle.
\]

The speed is the magnitude of the velocity vector:
\[
	\left| \vec{r}'(t) \right| = \sqrt{(-250 \sin(t))^2 + (250 \cos(t))^2 + 100^2} = \sqrt{62500 + 10000} = 269.3 \quad \text{(feet per minute)}.
\]

\subsection*{Step 2: Arc Length Function \(S(t)\)}
To find the arc length function \(S(t)\), which represents the distance traveled along the curve from \(t = 0\) to \(t = t\):
\[
	S(t) = \int_0^t \left| \vec{r}'(p) \right| \, dp.
\]
Since the speed is constant:
\[
	S(t) = \int_0^t 269.3 \, dp = 269.3 t.
\]

Thus, at time \(t\), the eagle has traveled \(269.3 t\) feet.

\subsection*{Step 3: Reparametrize by Arc Length}
The inverse of the arc length function \(S(t)\), denoted as \(S^{-1}(t)\), is given by:
\[
	S^{-1}(t) = \frac{t}{269.3}.
\]

Now, to reparametrize the curve by arc length, we substitute \(S^{-1}(t)\) into the original position vector \(\vec{r}(t)\):
\[
\vec{r}(S^{-1}(t)) = \left\langle 250 \cos\left( \frac{t}{269.3} \right), 250 \sin\left( \frac{t}{269.3} \right), 100 \frac{t}{269.3} \right\rangle.
\]

\subsection*{Interpretation}
This reparametrization gives the position of the eagle as a function of the distance traveled (in feet), rather than as a function of time. It provides a way to describe the motion of the eagle along the curve such that the eagle is moving at a constant speed of 1 foot per unit of time.

}

\section{Curvature of a Vector-Valued Function}
Curvature is a measure of the "sharpness" or "bendiness" of a curve. For a smooth curve given by a vector-valued function \(\vec{r}(t)\), the curvature at a point is related to how quickly the direction of the curve is changing.

\subsection{Osculating Circle}
The concept of curvature is closely tied to the idea of an \textbf{osculating circle}. At any point on the curve, the osculating circle is the circle that best approximates the curve's curvature at that point. This circle:
- Has the same tangent as the curve \(\vec{r}(t)\) at the point \(\vec{r}(t_0)\).
- Its radius is a measure of the "tightness" of the curve's bend at that point.

The radius of the osculating circle is denoted as:
\[
	R(t),
\]
where \(R(t)\) is the radius of curvature of the curve at time \(t\).

\subsection{Curvature \(\kappa(t)\)}
The curvature \(\kappa(t)\) of the curve \(\vec{r}(t)\) at the point \(\vec{r}(t_0)\) is defined as the reciprocal of the radius of the osculating circle:
\[
	\kappa(t) = \frac{1}{R(t)}.
\]
A smaller radius \(R(t)\) indicates a tighter bend and thus a larger curvature \(\kappa(t)\), whereas a larger radius corresponds to a gentler curve and smaller curvature.

The osculating circle provides a geometric interpretation of curvature, serving as the best circular approximation to the curve at any given point. The curvature \(\kappa(t)\) quantifies how sharply the curve bends at that point, with the relationship:
\[
	\kappa(t) = \frac{1}{R(t)}.
\]

\dfn{Osculating Circle of a Straight Line}{

	A straight line is a curve with no curvature. Thus, the curvature \(\kappa(t)\) of a straight line is zero at all points. To understand why, consider the definition of the osculating circle.


	For any curve \(\vec{r}(t)\), the osculating circle at a point \(\vec{r}(t_0)\) is defined as the circle that "best fits" the curve at that point. Mathematically, this means:
	\[
		\kappa(t) = \lim_{\Delta t \to 0} \frac{\text{change in angle}}{\text{arc length}},
	\]
	where \(\kappa(t)\) is the curvature of the curve. However, for a straight line, the change in angle is always zero, so:
	\[
		\kappa(t) = 0.
	\]

	Since curvature is the reciprocal of the radius of the osculating circle \(R(t)\), a zero curvature implies an infinite radius:
	\[
		R(t) = \frac{1}{\kappa(t)} \to \infty.
	\]
	Therefore, the osculating circle of a straight line is effectively a circle with infinite radius, meaning it is "flattened" into a straight line.

}

\subsection*{Diagram}
Below is a diagram to illustrate the concept of the osculating circle of a straight line:

\begin{center}
	\begin{tikzpicture}[scale=1.2]
		% Draw the straight line
		\draw[thick] (-3, 0) -- (3, 0) node[right] {\(\vec{r}(t)\)};

		% Draw the tangent vector at the point
		\draw[->, thick] (0, 0) -- (1, 0) node[above] {Tangent};

		% Mark a point on the line
		\filldraw (0, 0) circle (2pt) node[below] {\(\vec{r}(t_0)\)};

		% Draw the large osculating circle (only a visible arc to suggest a large radius)
		\draw[dashed] (5, 0) arc[start angle=0, end angle=180, radius=5];

		% Label the osculating circle
		\node at (0, 3.2) {Osculating circle (large radius)};
	\end{tikzpicture}
\end{center}

The dashed arc represents the osculating circle with an infinitely large radius, approximating the straight line at \(\vec{r}(t_0)\).

To approach the concept of osculating circles for vector-valued functions, we break down the analysis into four key points:

\subsection*{1. Tangent Vector at \(t_0\)}
The tangent vector to the curve at time \(t_0\) is given by:
\[
	\vec{T}(t) = \frac{\vec{r}'(t)}{\left| \vec{r}'(t) \right|}.
\]
This vector is the unit tangent vector at any point on the curve.

\subsection*{2. If \(\vec{r}(t)\) Describes a Circle}
Suppose that \(\vec{r}(t)\) describes a circular path. In this case:
\begin{itemize}
	\item The vector \(\vec{r}(t)\) is always parallel to the radius of the circle.
	\item The velocity vector \(\vec{r}'(t)\) is also perpendicular to \(\vec{r}(t)\).
\end{itemize}

\begin{center}
	\begin{tikzpicture}[scale=1.2]
		% Draw the circle
		\draw[thick] (0,0) circle (2.1);

		% Draw the position vector
		\draw[->, thick, green] (0,0) -- (1.5,1.5) node[above right] {\(\vec{r}(t)\)};

		% Draw the radius (position vector)
		\draw[dashed] (0,0) -- (1.5,1.5) node[below right] {Radius};

		% Draw the tangent vector
		\draw[->, thick] (1.5,1.5) -- (0.2, 3) node[above] {\(\vec{r}'(t)\)};

		% Mark the center of the circle
		\filldraw (0,0) circle (2pt) node[left] {Center};
	\end{tikzpicture}
\end{center}

\subsection*{3. Acceleration Vector \(\vec{a}(t)\)}
For a circular path, the acceleration vector \(\vec{a}(t)\) points toward the center of the circle. Hence,
\[
	\vec{a}(t) \text{ is opposite to } \vec{r}(t) \text{ and directed towards the center}.
\]
This implies:
\[
	\vec{a}(t) \perp \vec{r}'(t), \quad \vec{a}(t) \perp \vec{T}(t).
\]

\subsection*{4. Constant Speed and Perpendicularity}
Suppose that \(\vec{r}(t)\) describes a curve with constant speed:
\[
	\left| \vec{r}'(t) \right| = C, \quad C \in \mathbb{R}.
\]

For both 2D and 3D, the curve will either be a circle or a sphere with a fixed radius. The velocity and acceleration vectors, \(\vec{r}'(t)\) and \(\vec{a}(t)\), maintain a perpendicular relationship:
\[
	\vec{r}(t) \cdot \vec{v}(t) = 0.
\]

\begin{center}
	\begin{minipage}{0.45\textwidth}
		\centering
		\subsection*{2D Circle}
		\begin{tikzpicture}[scale=1.5]
			% Draw the circle
			\draw[thick] (0, 0) circle (1);

			% Draw the radius vector
			\draw[->, thick, green] (0, 0) -- (0.7, 0.7) node[above right] {\(\vec{r}(t_0)\)};

			% Draw and label the axes
			\draw[->, thick] (-1.5, 0) -- (1.5, 0) node[right] {$x$};
			\draw[->, thick] (0, -1.5) -- (0, 1.5) node[above] {$y$};
		\end{tikzpicture}
	\end{minipage}%
	\hfill
	\begin{minipage}{0.45\textwidth}
		\centering
		\subsection*{3D Sphere}
		\begin{tikzpicture}
			\begin{axis}[
					xlabel={$x$},
					ylabel={$y$},
					zlabel={$z$},
					view={60}{30},
					grid=both,
					domain=-1:1,
					zmin=-1, zmax=1,
					axis equal,
				]
				% Use spherical coordinates to draw a sphere
				\addplot3[
					surf,
					colormap/cool,
					domain=0:360,
					domain y=0:180,
					samples=50,
					samples y=50,
					z buffer=sort
				]
				({sin(y)*cos(x)}, {sin(y)*sin(x)}, {cos(y)});
			\end{axis}
		\end{tikzpicture}
	\end{minipage}
\end{center}

\subsection{Deriving the Perpendicularity}
Let \(\vec{v}(t) = \vec{r}'(t)\) be the velocity vector. Then:
\[
	\vec{r}'(t) \cdot \vec{v}(t) = \vec{r}'(t) \cdot \vec{r}'(t) = \frac{1}{2} \frac{d}{dt} \left( \vec{r} \cdot \vec{r} \right).
\]
Differentiating:
\[
	= \frac{1}{2} \frac{d}{dt} \left( |\vec{r}'(t)|^2 \right) = \frac{1}{2} \frac{d}{dt} C^2 = 0,
\]
since \(C\) is constant.

Therefore, if \(\left| \vec{r}'(t) \right| = C\), then:
\[
	\vec{v}(t) \perp \vec{r}(t).
\]

\section{Calculating Curvature}

\subsection{Case 1: $\vec{r}(t)$ travels at unit speed around a circle}

We consider the position vector $\vec{r}(t)$ traveling at unit speed around a circle of radius $R$.

\[
	\vec{r}(t) = \left\langle R \cos\left(\frac{t}{R}\right), R \sin\left(\frac{t}{R}\right), 0 \right\rangle
\]

The velocity vector $\vec{v}(t)$ is then the derivative of the position vector:

\[
	\vec{v}(t) = \vec{r}'(t) = \left\langle -\sin\left(\frac{t}{R}\right), \cos\left(\frac{t}{R}\right), 0 \right\rangle
\]

Note that the magnitude of the velocity vector is 1 (unit speed):

\[
	|\vec{v}(t)| = 1
\]

The acceleration vector $\vec{a}(t)$, which is the second derivative of the position vector, is given by:

\[
	\vec{a}(t) = \vec{r}''(t) = \left\langle -\frac{1}{R} \cos\left(\frac{t}{R}\right), -\frac{1}{R} \sin\left(\frac{t}{R}\right), 0 \right\rangle
\]

\dfn{The curvature $\kappa(t)$ of the circle }{

	The magnitude of the acceleration vector (centripetal acceleration) is:

	\[
		\kappa(t) = |\vec{r}''(t)| = \frac{1}{R}
	\]

}

\begin{center}
	\begin{tikzpicture}
		% Circle
		\draw[thick] (0,0) circle (2);
		\draw[thick, ->] (0,0) -- (2,0) node[midway, below] {$R$};
		\draw[thick, ->] (0,0) -- (1.4,1.4) node[midway, right] {$\vec{r}(t)$};
		% Axes
		\draw[->] (-2.5,0) -- (2.5,0) node[right] {$x$};
		\draw[->] (0,-2.5) -- (0,2.5) node[above] {$y$};
		\draw[->, thick] (1.4,1.4) arc (45:85:2.0) node[above right] {$\kappa(t) = \frac{1}{R}$};
	\end{tikzpicture}
\end{center}

\nt{
	\begin{itemize}
		\item $\vec{r}(t)$ represents the position of a point moving around a circle of radius $R$.
		\item The velocity vector $\vec{v}(t)$ is orthogonal to $\vec{r}(t)$ and has a constant magnitude, indicating uniform circular motion.
		\item The acceleration vector $\vec{a}(t)$ points towards the center of the circle (centripetal acceleration) and its magnitude is inversely proportional to the radius $R$, showing that a smaller radius corresponds to a greater acceleration.
		\item The curvature $\kappa(t)$ is defined as the reciprocal of the radius of the circle, $\frac{1}{R}$.
	\end{itemize}
}

\subsection{Case 2: General Curve with Unit Speed}

Consider a curve given by the position vector $\vec{r}(t)$, which travels at unit speed along a general curve. This means that the magnitude of the velocity vector is constant:
\[
	|\vec{v}(t)| = 1.
\]
Since the speed is constant, the acceleration vector $\vec{a}(t)$ is orthogonal to the velocity vector:
\[
	\vec{v}(t) \cdot \vec{a}(t) = 0.
\]

This implies that all changes in $\vec{a}(t)$ are perpendicular to the direction of motion (velocity), which aligns with the properties of motion at unit speed.

\clm{Acceleration and the Osculating Circle}{}{
	The acceleration vector $\vec{a}(t)$ is directed towards the center of curvature of the curve at each point, and its magnitude is related to the curvature. In fact, the acceleration "matches" the behavior of the osculating circle at that point. The osculating circle is the circle that best approximates the curve locally, and its radius of curvature $R$ is inversely proportional to the curvature.
}

\thm{Curvature and Acceleration}{

	The curvature $\kappa(t)$ of the curve at time $t$ is defined as the magnitude of the acceleration vector:
	\[
		\kappa(t) = |\vec{a}(t)|.
	\]

	This provides a measure of how sharply the curve is bending at any given point. Since the speed is unitary, the curvature directly corresponds to the acceleration's magnitude.

}

\ex{Matching the Curve with Its Osculating Circle}{

	The osculating circle at a point on the curve is chosen so that its first and second derivatives match the curve's first and second derivatives, respectively:
	\[
		\text{Choose circle } \vec{C}(t) \text{ such that } \vec{C}'(t) \text{ and } \vec{C}''(t) \text{ match } \vec{r}'(t) \text{ and } \vec{r}''(t).
	\]

	This ensures that the circle is the best local approximation to the curve at that point, providing insight into the curve's behavior through the curvature.

}


\subsection{Case 3: General Curve with Variable Speed}

In this case, we analyze a general curve with a variable speed. Unlike the previous case, the magnitude of the velocity vector is not constant:
\[
	|\vec{v}(t)| \neq 1.
\]

This implies that the curve's speed is not uniform, and therefore, the analysis of the curvature will require a different approach.

\par

Let \( s(t) \) be the arc length parameter, which is a function of \( t \). The position vector can be reparameterized in terms of arc length:
\[
	\vec{r}(s^{-1}(t)),
\]
where \( s^{-1}(t) \) is the inverse function of \( s(t) \).

\thm{Calculating Curvature \( \kappa(t) \)}{

To find the curvature, we introduce a parameter \( t_0 \), which satisfies \( t_0 = s^{-1}(t) \). Thus, we have:
\[
	s^{-1}(t_0) = t.
\]
The curvature \( \kappa(t) \) is then given by:
\[
	\kappa(t) = \left| \frac{d}{d t_0} \vec{T}(s^{-1}(t_0)) \right|,
\]
where \( \vec{T}(t) \) is the unit tangent vector.

This can be rewritten as:
\[
\kappa(t) = \left| \frac{\frac{d}{d t} \vec{r}(s^{-1}(t))}{|\vec{r}'(s^{-1}(t))|} \right| = \left| \frac{\vec{T}'(s^{-1}(t_0))}{|\vec{r}'(s^{-1}(t_0))|} \right|.
	\]

	The final expression for the curvature is:
	\[
		\boxed{\kappa(t) = \frac{|\vec{T}'(t)|}{|\vec{r}'(t)|}}
	\]
	where \( \vec{T}(t) = \frac{\vec{r}'(t)}{|\vec{r}'(t)|} \) is the unit tangent vector to the curve. \\
	Alternatively, the curvature can be found with

	\[
		\boxed{\kappa (t) = \frac{\lvert \vec{a} \times \vec{v} \rvert}{\lvert \vec{v} \rvert^3}, \quad \kappa (t) = \frac{1}{\lvert \vec{v} \rvert} \left\lvert \frac{d\vec{T}}{dt} \right\rvert, \quad \kappa (t) = \lvert \frac{d\vec{T}}{ds} \rvert}
	\]

	if \(y = f(x)\)  can be parametrized as
	\[
		\vec{r}(t) = \langle t, f(t), 0 \rangle,
	\]
	where
	\[
		x'(t) = 1, \quad x''(t) = 0.
	\]
	This parametrization gives the curvature \(\kappa\) of the curve as
	\[
		\boxed{\kappa (t)= \frac{\lvert y''(x) \rvert}{\left( 1 + (y'(x))^2 \right)^{3/2}}.}
	\]
}

\section{Components of Acceleration}


\begin{center}
	\begin{tikzpicture}

		% Curve and points
		\draw[thick] (0,0) .. controls (2,3) and (3,1.5) .. (6,1);
		\node[right] at (6,1) {$\vec{r}(t)$};

		% Acceleration vector and components
		\draw[->, thick, purple] (3,1.5) -- (5,2) node[midway, below] {$\vec{a}(t)$};
		\draw[->, thick, red] (3,1.5) -- (4,0.5) node[midway, left] {$\vec{a}_\perp(t)$};

		% Tangent and normal vectors
		\draw[->, thick, blue] (3,1.5) -- (4.5,3) node[above] {$\hat{T}(t)$};
		\draw[->, thick, green] (3,1.5) -- (3.5,2.5) node[right] {$\hat{N}(t)$};

		% Descriptive text boxes
		\node[draw=blue, text=blue] at (0,-1.5) {$|\vec{a}_\perp(t)| = \frac{|\vec{v}(t) \times \vec{a}(t)|}{|\vec{v}(t)|} = |\vec{v}(t)|^2 \cdot \kappa(t)$};
		\node[draw=green, text=green] at (6,-1.5) {$|\vec{a}_\parallel(t)| = \frac{d}{dt}|\vec{v}(t)| = \frac{d^2}{dt^2} \int_0^t |\vec{v}(p)| dp = \frac{d^2}{dt^2} s(t)$};

		% Labels for centripetal and speed change
		\node[draw=red, text=red] at (-3,-3) {$\vec{a}_\perp(t) =$ centripetal acceleration};
		\node[draw=green, text=green] at (6,-3) {$\vec{a}_\parallel(t) =$ speed change};

		% Final equation box
		\node[draw=purple, text=purple] at (0,-4.5) {$\vec{a}(t) = |\vec{a}_\perp(t)| \cdot \frac{\vec{T}'(t)}{|\vec{T	}'(t)|} + |\vec{a}_\parallel(t)| \cdot \frac{\vec{r}'(t)}{|\vec{r}'(t)|}$};

		% Comment on missing component
		\node[align=left] at (7,-4.5) {\textit{Missing a third component of motion}};
	\end{tikzpicture}
\end{center}


\section{Binormal Vector}
\dfn{Binormal Vector}{
	The \textbf{binormal vector} $\vec{B}$ is defined as:
	\[
		\vec{B} = \vec{T} \times \vec{N} = \frac{\vec{v} \times \vec{a}}{|\vec{v} \times \vec{a}|}
	\]
	where:
	\begin{itemize}
		\item $\vec{T}$ is the unit tangent vector to the curve, given by:
		      \[
			      \vec{T} = \frac{\vec{r}'(t)}{|\vec{r}'(t)|}
		      \]
		\item $\vec{N}$ is the unit normal vector to the curve, and it is defined as:
		      \[
			      \vec{N} = \frac{\vec{T}'(t)}{|\vec{T}'(t)|}
		      \]
	\end{itemize}
	The binormal vector $\vec{B}$ represents the direction to exit the current plane of motion described by the vectors $\vec{T}$ and $\vec{N}$.
}

\subsection{Change in the Plane of Motion}

The rate of change of the binormal vector is given by:
\[
	\frac{d\vec{B}}{dt} = \text{change in the plane of motion}
\]

Applying the derivative product rule to $\vec{B} = \vec{T} \times \vec{N}$:
\[
	\frac{d}{dt} (\vec{T} \times \vec{N}) = \frac{d\vec{T}}{dt} \times \vec{N} + \vec{T} \times \frac{d\vec{N}}{dt}
\]
Since:
\[
	\vec{N} = \frac{\vec{T}'(t)}{|\vec{T}'(t)|}
\]
it follows that:
\[
	\vec{T} \cdot \vec{N} = 0
\]
and thus:
\[
	\frac{d\vec{B}}{dt} \text{ is orthogonal to both } \vec{T} \text{ and } \vec{N}
\]

\subsection{Torsion and its Relation to the Binormal Vector}

Since $\vec{N}$ is a unit vector, the vector $\vec{B}'$ is parallel to $\vec{N}$:
\[
	\frac{d\vec{B}}{dt} = -\tau \vec{N}
\]
where $\tau$ is the \textbf{torsion} of the plane of movement.

\nt{
	If $\tau > 0$, the motion is on the plane of movement; if $\tau < 0$, the motion is in the opposite direction.
}

To find $\tau$, take the dot product of both sides with $\vec{N}$:
\[
	\frac{d\vec{B}}{dt} \cdot \vec{N} = -\tau (\vec{N} \cdot \vec{N}) = -\tau
\]
Thus, at unit speed:
\dfn{Torsion $\tau$ at unit speed}{
	\[
		\tau = -\frac{\frac{d\vec{B}}{dt} \cdot \vec{N}}{|\vec{N}|} = -\frac{d\vec{B}}{dt} \cdot \vec{N}
	\]
}

\subsection{General Case and Torsion Formula}

For the general case, replace $\vec{r}(t)$ with $\vec{r}(s^{-1}(t))$, where $s(t)$ is the arc-length parameterization.

The derivative of $\vec{B}$ in the general case is given by:
\[
	\frac{d\vec{B}(s^{-1})}{d(t_0)} = \frac{\vec{B}'(s^{-1}(t_0))}{|\vec{r}'(s^{-1}(t_0))|}
\]
or simply:
\[
	\frac{d\vec{B}(t)}{dt} = \frac{\vec{B}'(t) \cdot \vec{N}(t)}{|\vec{r}'(t)|}
\]
The general formula for torsion $\tau$ becomes:

\dfn{General form for torsion $\tau$}{
	\[
		\tau = \frac{\vec{B}'(t) \cdot \vec{N}(t)}{|\vec{r}'(t)|}
	\]
	.
}

\subsection{Expressing the Binormal Vector with Velocity and Acceleration}

The binormal vector $\vec{B}$ can be expressed as:
\[
	\vec{B} = \frac{\vec{v} \times \vec{a}}{|\vec{v} \times \vec{a}|}
\]
where $\vec{v}$ is the velocity vector and $\vec{a}$ is the acceleration vector.

The torsion $\tau$ is given by:
\[
	\tau = \frac{(\vec{v} \times \vec{a}) \cdot \vec{a}'}{|\vec{v} \times \vec{a}|^2}
\]

\nt{
	The centripetal acceleration determines the curvature of the path.
}
\ex{Finding the Torsion of a Helix Path}{

	Consider the helix parameterized by:
	\[
		\vec{r}(t) = \langle \cos t, \sin t, t \rangle
	\]

	The first derivative (velocity vector) is:
	\[
		\vec{r}'(t) = \langle -\sin t, \cos t, 1 \rangle
	\]
	with magnitude:
	\[
		|\vec{r}'(t)| = \sqrt{2}
	\]

	The unit tangent vector $\vec{T}(t)$ is:
	\[
		\vec{T}(t) = \frac{\vec{r}'(t)}{|\vec{r}'(t)|} = \left\langle -\frac{\sin t}{\sqrt{2}}, \frac{\cos t}{\sqrt{2}}, \frac{1}{\sqrt{2}} \right\rangle
	\]

	The derivative of the tangent vector is:
	\[
		\vec{T}'(t) = \left\langle -\frac{\cos t}{\sqrt{2}}, -\frac{\sin t}{\sqrt{2}}, 0 \right\rangle
	\]
	and its magnitude is:
	\[
		|\vec{T}'(t)| = \frac{1}{\sqrt{2}}
	\]

	The curvature $\kappa(t)$ is given by:
	\[
		\kappa(t) = \frac{|\vec{T}'(t)|}{|\vec{r}'(t)|} = \frac{\frac{1}{\sqrt{2}}}{\sqrt{2}} = \frac{1}{2}
	\]
	Hence, the radius of curvature $R(t)$ is:
	\[
		R(t) = \frac{1}{\kappa(t)} = 2
	\]

	The normal vector $\vec{N}(t)$ is:
	\[
		\vec{N}(t) = \frac{\vec{T}'(t)}{|\vec{T}'(t)|} = \left\langle -\cos t, -\sin t, 0 \right\rangle
	\]
	which points towards the center of the curvature.

	The normal acceleration $a_N$ is:
	\[
		a_N = |\vec{r}'(t)|^2 \cdot \kappa = 1 \quad \text{(constant, points towards the center)}
	\]

	The tangential acceleration is:
	\[
		a_T = s''(t), \quad s(t) = t \sqrt{2}, \quad s'(t) = \sqrt{2}
	\]

	The binormal vector $\vec{B}$ is given by:
	\[
		\vec{B} = \vec{T} \times \vec{N} = \frac{1}{\sqrt{2}} \langle \sin t, -\cos t, 0 \rangle
	\]

	The derivative of the binormal vector is:
	\[
		\vec{B}' = \frac{1}{\sqrt{2}} \langle \cos t, \sin t, 0 \rangle = -\frac{1}{\sqrt{2}} \vec{N} \implies \tau = \frac{\vec{B}' \cdot \vec{N}}{|\vec{r}'(t)|} = \frac{1}{2}
	\]

	Therefore, the torsion $\tau$ is:
	\[
		\tau = \frac{\kappa}{\sqrt{2}} = \frac{1}{2}
	\]

}

\chapter{Functions of Multiple Random Variables $f:\mathbb{R} ^ n \rightarrow \mathbb{R}$}

\section{Plotting Multiple Random Variable Functions}

Consider a function $f(x, y) = z$. We aim to plot functions in 3D.

\subsection*{Example}
\[
	f(x, y) = x^2 + y^2
\]

\begin{itemize}
	\item When $y = 0$, $f(x, 0) = x^2$.
	\item When $x = 0$, $f(0, y) = y^2$.
\end{itemize}

\begin{center}
	\begin{tikzpicture}
		\begin{axis}[
				view={45}{45},
				xlabel={$x$},
				ylabel={$y$},
				zlabel={$z$},
				grid=major,
				colormap/cool,
			]
			\addplot3[surf, domain=-2:2, domain y=-2:2]
			{x^2 + y^2};
		\end{axis}
	\end{tikzpicture}
\end{center}

For this surface:
\begin{itemize}
	\item If $z = 0$, $(x, y) = (0, 0)$.
	\item If $z = 1$, $x^2 + y^2 = 1$, which represents a \textbf{circle}.
	\item If $z > 0$, $x^2 + y^2 = z$, representing a circle with radius $\sqrt{z}$ in the $xy$-plane.
\end{itemize}

The vertical line test still applies: a vertical line intersects the surface at at most 1 point.

\begin{center}
	\begin{tikzpicture}
		\begin{axis}[
				axis lines = middle,
				domain=-2:2,
				y domain=-2:2,
				view={60}{30},
				samples=20,
				samples y=20,
				colormap/cool,
			]
			\addplot3[surf, opacity=0.5] {x^2 + y^2};
			\addplot3[thick, domain=0:2*pi, samples y=0]
			({cos(deg(x))}, {sin(deg(x))}, {1}) node[above] {Circle at $z = 1$};
		\end{axis}
	\end{tikzpicture}
\end{center}

\subsection*{Sphere by Self Equation}

A sphere cannot be represented as a function in the form $f(x, y) = z$. This is because it fails the vertical line test; a vertical line may intersect the sphere at multiple points.

\begin{center}
	\begin{tikzpicture}
		\begin{axis}[
				axis lines = middle,
				view={45}{30},
				grid=major,
				axis equal
			]
			% Draw the sphere using parametric equations
			\addplot3[
				surf,
				domain=0:360,
				y domain=0:180,
				samples=20,
				samples y=20,
				opacity=0.4,
				colormap/cool,
			]
			({sin(y)*cos(x)}, {sin(y)*sin(x)}, {cos(y)});
			% Vertical line test
			\addplot3[
				thick,
				domain=-1.5:1.5,
				samples y=0,
			]
			({0}, {0}, {x}) node[right] {Vertical line fails test};
		\end{axis}
	\end{tikzpicture}
\end{center}

\section{Domain of Multiple Random Variable Functions}


\dfn{Domain}{The domain of $f(x, y)$ is the set of pairs $(x, y) \in \mathbb{R}^2$ such that $f(x, y)$ is defined.}
\ex{Example of finding domain}{
	Let
	\[
		f(x, y) = \sqrt{4 - x^2 - y^2}
	\]
	To ensure that $f(x, y)$ is defined, the expression inside the square root must be non-negative:
	\[
		4 - x^2 - y^2 \geq 0 \implies x^2 + y^2 \leq 4
	\]

	This inequality describes a disk of radius 2 centered at the origin $(0, 0)$.

	\begin{center}
		\begin{tikzpicture}
			% Draw the domain as a disk
			\begin{axis}[
					axis equal,
					xlabel = {$x$},
					ylabel = {$y$},
					axis lines = middle,
					xmin = -3, xmax = 3,
					ymin = -3, ymax = 3,
					grid = major
				]
				% Disk with radius 2
				\addplot[draw=black, fill=blue!20, fill opacity=0.5, domain=0:2*pi, samples=100]
				({2*cos(deg(x))}, {2*sin(deg(x))});
				% Origin marker
				\node at (axis cs:0, 0) [circle, fill=black, inner sep=1.5pt] {};
				\node[below right] at (axis cs:0, 0) {$(0, 0)$};
			\end{axis}
		\end{tikzpicture}
	\end{center}

	Therefore, the domain of $f(x, y)$ is:
	\[
		\{(x, y) \in \mathbb{R}^2 \mid x^2 + y^2 \leq 4\}
	\]
}


\section{Range of Multiple Random Variable Functions}

\dfn{Range}{
	The range of a function $f(x, y)$ is the set of all $z$ such that $z = f(x, y)$ for some input $(x, y)$.
}

\ex{Example of finding the range}{
	Consider the function
	\[
		f(x, y) = \sqrt{4 - x^2 - y^2}
	\]
	Evaluating $f$ at the origin:
	\[
		f(0, 0) = \sqrt{4 - 0^2 - 0^2} = 2
	\]
	The maximum value of $f$ is 2. To find the minimum, consider the boundary of the domain:
	If $x^2 + y^2 = 4$, then
	\[
		f(x, y) = \sqrt{4 - (x^2 + y^2)} = \sqrt{4 - 4} = 0
	\]

	Therefore, the range of $f(x, y)$ is:
	\[
		\{ z \in [0, 2] \}
	\]
}

\ex{Another example}{
	Let
	\[
		f(x, y) = x^2 + y^2
	\]
	Since $f(x, y) \geq 0$ for all $(x, y) \in \mathbb{R}^2$, the range of $f(x, y)$ is:
	\[
		\{ z \mid z \geq 0 \}
	\]
}

\section{Level Curves of Functions of Two Variables}

\dfn{Level Curves}{
	Level curves (or contour lines) of a function $f(x, y)$ are curves in the $xy$-plane along which the function takes a constant value. For a given value $c$, a level curve is the set of points $(x, y)$ such that:
	\[
		f(x, y) = c
	\]
}

\ex{Example of level curves}{
	Consider the function:
	\[
		f(x, y) = x^2 + y^2
	\]
	To find the level curves for this function, set $f(x, y)$ equal to a constant $c$:
	\[
		x^2 + y^2 = c
	\]
	These curves are circles centered at the origin with radius $\sqrt{c}$.

	\begin{center}
		\begin{tikzpicture}
			% Draw level curves as circles
			\begin{axis}[
					axis equal,
					xlabel = {$x$},
					ylabel = {$y$},
					axis lines = middle,
					xmin = -3, xmax = 3,
					ymin = -3, ymax = 3,
					grid = major,
					ticks=none
				]
				% Level curve for c = 1
				\addplot[blue, thick, domain=0:2*pi, samples=100]
				({sqrt(1)*cos(deg(x))}, {sqrt(1)*sin(deg(x))});
				\node[above right] at (axis cs: 1, 0.5) {$c = 1$};

				% Level curve for c = 2
				\addplot[red, thick, domain=0:2*pi, samples=100]
				({sqrt(2)*cos(deg(x))}, {sqrt(2)*sin(deg(x))});
				\node[above right] at (axis cs: 1.5, 1.5) {$c = 2$};

				% Level curve for c = 3
				\addplot[green, thick, domain=0:2*pi, samples=100]
				({sqrt(3)*cos(deg(x))}, {sqrt(3)*sin(deg(x))});
				\node[below right] at (axis cs: 2.3, -0.5) {$c = 3$};
			\end{axis}
		\end{tikzpicture}
	\end{center}


	In this case, each level curve is a circle centered at the origin. The radius of each circle is $\sqrt{c}$, indicating that as the value of $c$ increases, the radius of the level curve also increases.

}

\section{Limits of Two-Variable Functions}

\dfn{Limit of a Two-Variable Function}{
	Let $f(x, y)$ be a function of two variables. The limit of $f(x, y)$ as $(x, y)$ approaches $(a, b)$ is denoted as:
	\[
		\lim_{(x, y) \to (a, b)} f(x, y) = L
	\]
	This means that as the point $(x, y)$ gets arbitrarily close to $(a, b)$, the function values $f(x, y)$ approach the value $L$. For the limit to exist, the function must approach the same value $L$ regardless of the path taken to reach $(a, b)$.
}

\dfn{Formal Definition}{

	\[
		\lim_{(x,y) \to (a,b)} f(x,y) = L
	\]
	if for any \( \varepsilon > 0 \), there exists a constant \( \delta > 0 \) such that:
	\[
		|f(x,y) - L| < \varepsilon
	\]
	whenever \( (x, y) \) are in the domain of \( f \) and:
	\[
		|(x,y) - (a,b)| < \delta
	\]

}

\subsection*{Visualizing Limits}

The concept of limits for two-variable functions can be visualized in 3D, where $f(x, y)$ is represented as a surface over the $xy$-plane. The behavior of the function as $(x, y)$ approaches a point $(a, b)$ corresponds to how the surface approaches a specific height, $L$.

\begin{center}
	\begin{tikzpicture}
		\begin{axis}[
				view={45}{45},
				xlabel={$x$},
				ylabel={$y$},
				zlabel={$z$},
				domain=-2:2,
				domain y=-2:2,
				grid=major,
				colormap/cool,
			]
			% A sample function to visualize limit
			\addplot3[surf, opacity=0.7] {1 - (x^2 + y^2)};
			\addplot3+[mark=*, only marks] coordinates {(0,0,1)};
			\node at (axis cs: 0, 0, 1.2) [above] {$(a, b, L)$};
		\end{axis}
	\end{tikzpicture}
\end{center}

In this diagram, the surface represents a function $f(x, y)$, and the point $(a, b, L)$ is the limit we are trying to approach.

\ex{Example of a Limit}{
	Consider the function:
	\[
		f(x, y) = \frac{x^2 - y^2}{x^2 + y^2}
	\]
	We want to find
	\[
		\lim_{(x, y) \to (0, 0)} f(x, y)
	\]

	Evaluating the limit along different paths:
	\begin{itemize}
		\item Along the path $y = 0$, we have $f(x, 0) = \frac{x^2}{x^2} = 1$.
		\item Along the path $x = 0$, we have $f(0, y) = \frac{-y^2}{y^2} = -1$.
	\end{itemize}

	Since the limit depends on the path taken to approach $(0, 0)$, the limit does not exist.

	\begin{center}
		\begin{tikzpicture}
			\begin{axis}[
					view={45}{45},
					xlabel={$x$},
					ylabel={$y$},
					zlabel={$z$},
					domain=-1:1,
					domain y=-1:1,
					grid=major,
					colormap/hot,
				]
				% The surface of the function to visualize path-dependent behavior
				\addplot3[surf, opacity=0.7] {(x^2 - y^2)/(x^2 + y^2)};
			\end{axis}
		\end{tikzpicture}
	\end{center}

	This diagram shows how the function behaves differently along different paths toward the origin, resulting in no single limit.

}

\ex{Example of a Limit that Exists}{
	Consider the function:
	\[
		f(x, y) = x^2 + y^2
	\]
	We want to find
	\[
		\lim_{(x, y) \to (0, 0)} f(x, y)
	\]

	Since $f(x, y) = x^2 + y^2$, regardless of the path taken to approach $(0, 0)$, the value of $f(x, y)$ approaches $0$. Therefore,
	\[
		\lim_{(x, y) \to (0, 0)} f(x, y) = 0.
	\]

	\begin{center}
		\begin{tikzpicture}
			\begin{axis}[
					view={45}{45},
					xlabel={$x$},
					ylabel={$y$},
					zlabel={$z$},
					domain=-2:2,
					domain y=-2:2,
					grid=major,
					colormap/viridis,
				]
				% A simple surface where the limit exists
				\addplot3[surf, opacity=0.7] {x^2 + y^2};
				\addplot3+[mark=*, only marks] coordinates {(0,0,0)};
				\node at (axis cs: 0, 0, 0.2) [above] {$(0, 0, 0)$};
			\end{axis}
		\end{tikzpicture}
	\end{center}

}

\subsection{Limits by substituting with function $f:\mathbb{R} \rightarrow \mathbb{R}$}

\ex{Changing $g(x)$}{

	For a function $f(x, y)$, the limit as $(x, y)$ approaches a point $(a, b)$ must be the same regardless of the path taken to approach $(a, b)$.

	Consider the function:
	\[
		f(x, y) = \frac{3xy^2}{x^2 + y^4}
	\]
	We wish to find:
	\[
		\lim_{(x, y) \to (0, 0)} f(x, y)
	\]
	This limit initially appears to be of the form $\frac{0}{0}$, indicating an indeterminate form.

	To proceed, we evaluate the limit along different paths. Let’s test two paths to see if the limit is consistent.

	\subsection*{Path 1: Linear Path $y = mx$}
	Substitute $y = mx$ into $f(x, y)$:
	\[
		f(x, y) = \frac{3x(mx)^2}{x^2 + (mx)^4} = \frac{3m^2 x^3}{x^2 + m^4 x^4}
	\]
	Then, consider the limit as $x \to 0$:
	\[
		\lim_{x \to 0} \frac{3m^2 x^3}{x^2 + m^4 x^4}
	\]
	Factor out $x^2$ in the denominator:
	\[
		= \lim_{x \to 0} \frac{3m^2 x}{1 + m^4 x^2} = 0
	\]

	\subsection*{Path 2: Parabolic Path $y = m\sqrt{x}$}
	Substitute $y = m\sqrt{x}$ into $f(x, y)$:
	\[
		f(x, y) = \frac{3x(m\sqrt{x})^2}{x^2 + (m\sqrt{x})^4} = \frac{3m^2 x^2}{x^2 + m^4 x^2}
	\]
	Then, consider the limit as $x \to 0$:
	\[
		\lim_{x \to 0} \frac{3m^2 x^2}{(m^4 + 1)x^2} = \lim_{x \to 0} \frac{3m^2}{m^4 + 1} = \frac{3m^2}{m^4 + 1} \neq 0
	\]

	Since the limit depends on the path taken (0 for the linear path and $\frac{3m^2}{m^4 + 1}$ for the parabolic path), the limit does not exist:
	\[
		\lim_{(x, y) \to (0, 0)} f(x, y) \text{ DNE (Does Not Exist)}
	\]
}

\subsection{Limits by substituting with Vector Valued Functions $f:\mathbb{R} \rightarrow \mathbb{R}^n$}

\ex{Substituting $< g_1(t), g_2(t) > $}{
	Since a 1 to 1 function $g(t)$ must pass the vertical line test, it is a limiting way to approach the point at which we want to compute the limit of a two variable function. Using a vector valued function will remove this limitation and enable us to approach from any direction.

	For a function $f(x, y)$, the limit as $(x, y)$ approaches a point $(a, b)$ must be the same regardless of the path taken to approach $(a, b)$.

	Consider the function:
	\[
		f(x, y) = \frac{3xy^2}{x^2 + y^4}
	\]
	We wish to find:
	\[
		\lim_{(x, y) \to (0, 0)} f(x, y)
	\]
	This limit initially appears to be of the form $\frac{0}{0}$, indicating an indeterminate form.

	To proceed, we evaluate the limit along different paths. Let’s test two paths to see if the limit is consistent.

	\subsection*{Path 1: Parametric Linear Path $\vec{r}(t) = \langle t, mt \rangle$}

	Substitute $\vec{r}(t) = \langle t, mt \rangle$ into $f(x, y)$:
	\[
		f(x, y) = \frac{3(t)(mt)^2}{t^2 + (mt)^4} = \frac{3m^2 t^3}{t^2 + m^4 t^4}
	\]
	Then, consider the limit as $t \to 0$:
	\[
		\lim_{t \to 0} \frac{3m^2 t^3}{t^2 + m^4 t^4}
	\]
	Factor out $t^2$ in the denominator:
	\[
		= \lim_{t \to 0} \frac{3m^2 t}{1 + m^4 t^2} = 0
	\]

	\subsection*{Path 2: Parametric Parabolic Path $\vec{r}(t) = \langle t^2, m\sqrt{t} \rangle$}

	Substitute $\vec{r}(t) = \langle t^2, m\sqrt{t} \rangle$ into $f(x, y)$:
	\[
		f(x, y) = \frac{3(t^2)(m\sqrt{t})^2}{(t^2)^2 + (m\sqrt{t})^4} = \frac{3m^2 t^3}{t^4 + m^4 t^2}
	\]
	Then, consider the limit as $t \to 0$:
	\[
		\lim_{t \to 0} \frac{3m^2 t^3}{t^4 + m^4 t^2}
	\]
	Factor out $t^2$ in the denominator:
	\[
		= \lim_{t \to 0} \frac{3m^2 t}{t^2 + m^4} = \frac{3m^2}{m^4} = \frac{3}{m^2} \neq 0
	\]

	Since the limit depends on the path taken (0 for the linear path and $\frac{3}{m^2}$ for the parabolic path), the limit does not exist:
	\[
		\lim_{(x, y) \to (0, 0)} f(x, y) \text{ DNE (Does Not Exist)}
	\]

}

\ex{Other Example}{

	$$f(x,y)=\frac{\sqrt[2]{x+y} + ln(\sqrt[2]{x+y})}{x+y}$$

	\[
		f(x,y) =
		\begin{cases}
			\frac{\sqrt[2]{x+y} + ln(\sqrt[2]{x+y})}{x+y} & \text{if } x,y \neq 0 \\
			L                                             & \text{if } x=y=0      \\
		\end{cases}
	\]

	If

	$$g(t)=<g_1(t),g_2(t)>$$

	where $g_1(t) = t, g_2(t)=\sqrt{t}$

	and

	$$h(s) = \frac{\sqrt[2]{s} + ln(\sqrt[2]{s})}{s}$$

	then

	$$f(x,y) = h(g_1(x),g_2(y))$$

}

\section{Tips for Finding Limits of Two-Variable Functions (2VF)}

\subsection{Polynomials are Continuous}
Polynomials in two variables are always continuous everywhere in their domain. For example:
\[
	f(x, y) = 3x^2 + 2y^2 + 3x^4 + 1
\]
is continuous for all $(x, y) \in \mathbb{R}^2$.

\subsection{Compositions of Continuous Functions are Continuous}
If $g(t)$ is a function of one variable and continuous at $t = 0$, and $f(x, y)$ is a continuous function of two variables, then $g(f(x, y))$ is also continuous at any point where $f(x, y)$ is defined. For example:
\[
	g(t) =
	\begin{cases}
		\frac{\sqrt{1 + t} - 1}{t} & \text{if } t \neq 0 \\
		e                          & \text{if } t = 0
	\end{cases}
\]
is continuous everywhere.

Now consider the function:
\[
	f(x, y) = x y^2
\]
Since $f(x, y)$ is continuous, the composition $g(f(x, y))$ is also continuous. Specifically:
\[
	g(f(x, y)) =
	\begin{cases}
		\frac{\sqrt{1 + x y^2} - 1}{x y^2} & \text{if } x y^2 \neq 0 \\
		e                                  & \text{if } x y^2 = 0
	\end{cases}
\]
This composition is continuous.

\subsection{Rational Functions}
A rational function $f(x, y) = \frac{P(x, y)}{Q(x, y)}$ is continuous at all points where the denominator $Q(x, y) \neq 0$. For example:
\[
	f(x, y) = \frac{3x y^2}{x^2 + y^4}
\]
is continuous wherever $x^2 + y^4 \neq 0$.

\nt{\textbf{Tip on Factoring and Simplifying} \\
	To find the limit of a rational function, try factoring and simplifying the expression. This can help identify points of discontinuity or removable singularities.
}

\subsection{Special Limits: Squeeze Theorem}
The Squeeze Theorem can be used for two-variable functions. If:
\[
	h(x, y) \leq f(x, y) \leq g(x, y)
\]
and both $h(x, y)$ and $g(x, y)$ approach the same limit $L$ as $(x, y) \to (a, b)$, then:
\[
	\lim_{(x, y) \to (a, b)} f(x, y) = L
\]

\subsection{Use of Polar Coordinates}
For limits involving two-variable functions, converting to polar coordinates can often simplify the problem. Let:
\[
	x = r \cos \theta, \quad y = r \sin \theta
\]
Then, $f(x, y)$ becomes a function of $r$ and $\theta$, which can be easier to analyze as $r \to 0$. This is particularly useful when the limit depends on the distance from the origin.

\subsection{Testing Multiple Paths}
When checking if a limit exists, test multiple paths (e.g., $y = mx$, $y = m\sqrt{x}$, $x = 0$, $y = 0$). If the limit differs for any path, then the limit does not exist. However, if all paths give the same result, it is likely that the limit exists (though more thorough testing is required for rigor).

\subsection{Continuity of Common Functions}
Most standard functions (e.g., trigonometric, exponential, logarithmic) are continuous within their domains. If they are composed with continuous functions of $x$ and $y$, the result is continuous as well.

\subsection{Rational functions}
Consider a rational function of two variables in the form:

\[
	\frac{h(x, y)}{g(x, y)}
\]

where \( h(x, y) \) and \( g(x, y) \) are polynomials. The behavior of the limit of this function as \( (x, y) \to (a, b) \) can be classified into three cases:

\subsection{Case 1: \( g(a, b) \neq 0 \)}

If the denominator \( g(x, y) \) is non-zero at the point \( (a, b) \), i.e., \( g(a, b) \neq 0 \), then the function is continuous at \( (a, b) \). In this case, we have:

\[
	\lim_{(x, y) \to (a, b)} \frac{h(x, y)}{g(x, y)} = \frac{h(a, b)}{g(a, b)}.
\]

Thus, the limit exists and equals the value of the function at the point \( (a, b) \).

\subsection{Case 2: \( g(a, b) = 0 \) and \( h(a, b) \neq 0 \)}

If the denominator \( g(x, y) \) equals zero at \( (a, b) \) but the numerator \( h(x, y) \) does not, i.e., \( h(a, b) \neq 0 \), then the limit does not exist. Intuitively, this is because the denominator tends to zero while the numerator tends to a non-zero constant, leading to a blow-up of the function.

\[
	\lim_{(x, y) \to (a, b)} \frac{h(x, y)}{g(x, y)} \quad \text{does not exist}.
\]

\subsection{Case 3: \( h(a, b) = g(a, b) = 0 \)}

If both the numerator and the denominator are zero at \( (a, b) \), i.e., \( h(a, b) = g(a, b) = 0 \), we have an indeterminate form \( \frac{0}{0} \). In this case, we try to simplify the expression by factoring out the common terms in \( h(x, y) \) and \( g(x, y) \).

\ex{Example}{

	Consider the function:

	\[
		\frac{x^2 - y^2}{x - y}.
	\]

	At the point \( (1, 1) \), both the numerator and the denominator are zero:

	\[
		h(1, 1) = g(1, 1) = 0.
	\]

	We factor the numerator:

	\[
		x^2 - y^2 = (x - y)(x + y).
	\]

	Now, cancel the common factor \( x - y \) in the numerator and denominator:

	\[
		\frac{x^2 - y^2}{x - y} = x + y.
	\]

	Thus, the limit simplifies to:

	\[
		\lim_{(x, y) \to (1, 1)} \frac{x^2 - y^2}{x - y} = \lim_{(x, y) \to (1, 1)} (x + y) = 1 + 1 = 2.
	\]

	Hence, by removing the common factor, the limit can be computed as \( 2 \).
}

\subsection{Case 4: \( h(a, b) = g(a, b) = 0 \) still}

Try several Vector Valued functions, trying to make the denominator small or big compared to the numerator

\ex{Large denominator}{
	\[
		\quad \lim_{(x,y) \to (0,0)} \frac{x^2 y}{x^2 + y^2}
	\]
	One possible path: Let \( y = 0 \),
	\[
		\frac{x^2 (0)}{x^2 + 0^2} = \frac{0}{x^2} = 0
	\]

	Now try a different path: Let \( x = 0 \),
	\[
		\frac{0^2 y}{0^2 + y^2} = \frac{0}{y^2} = 0
	\]

	\noindent \textbf{Parametric form:}
	\[
		\lim_{t \to 0} f(r_1(t), r_2(t)) = \lim_{t \to 0} f(0,t) = \lim_{t \to 0} \frac{0^2 t}{0^2 + t^2} = \lim_{t \to 0} 0 = 0
	\]

	Thus, the limit is \( 0 = 0 \).
}

\ex{Small denominator}{

	\[
		x = -y^2 + y^n, \quad \text{where } n > 2
	\]
	(for \( y \) small)

	\[
		\lim_{t \to 0} f(t^2 + t^n, t) = \frac{(t^4 - 2t^{n+2} + t^{2n}) t}{t^2 + t^n + t^2} = \lim_{t \to 0} \frac{t^5 - 2t^{n+3} + t^{2n+1}}{t^n} \quad (n=5)
	\]
	Simplifying:
	\[
		n = 5: \quad \lim_{t \to 0} \left(1-2t^3 + t^6 \right) = 1
	\]

}

\subsection{Case 5: Still getting the same limit}

\ex{Trying}{
	Let $\lim_{(x,y) \to (0,0)} = \frac{xy^2}{x^2+y^2}$. \\
	If we divide by $y^2$ we get
	\[
		\lim_{(x, y) \to (0,0)} \frac{xy^2}{x^2+y^2} = \lim_{(x, y) \to (0,0)} \frac{x}{(\frac{x^2}{y^2})+1} = 0
	\]
}


\section{Properties of Limits of Two-Variable Functions}

Let $f(x, y)$ and $g(x, y)$ be two functions of two variables such that:
\[
	\lim_{(x, y) \to (a, b)} f(x, y) = L_1, \quad \lim_{(x, y) \to (a, b)} g(x, y) = L_2
\]
Then, the following properties hold:

\subsection{Scaling by a constant:}
\[
	\lim_{(x, y) \to (a, b)} [k f(x, y)] = k L_1, \quad \text{where } k \text{ is any real constant}
\]

\subsection{Addition of functions:}
\[
	\lim_{(x, y) \to (a, b)} [f(x, y) + g(x, y)] = L_1 + L_2
\]

\subsection{Multiplication of functions:}
\[
	\lim_{(x, y) \to (a, b)} [f(x, y) g(x, y)] = L_1 L_2
\]

\subsection{Division of functions:}
\[
	\lim_{(x, y) \to (a, b)} \left[ \frac{f(x, y)}{g(x, y)} \right] = \frac{L_1}{L_2}, \quad \text{provided } L_2 \neq 0
\]

\subsection{Other}

\[
	\lim_{(x,y) \to (a,b)} \left( f(x,y) \right)^n = L^n \quad (n = 0,1,2,3,\dots)
\]
\[
	\lim_{(x,y) \to (a,b)} \left( f(x,y) \right)^{1/n} = L^{1/n} \quad \text{if } n \text{ is even, } L \geq 0
\]

\section{Partial Derivatives}

\dfn{Partial Derivative of random two variable function }{

	\[
		\frac{\partial}{\partial x} f(x,y) = lim_{h \to 0} \frac{f(x+h,y)-f(x,y)}{h}
	\]

	\[
		\frac{\partial}{\partial y} f(x,y) = lim_{h \to 0} \frac{f(x,y+h)-f(x,y)}{h}
	\]

}

\ex{Example of application of partial derivatives}{

	\begin{center}
		\begin{tikzpicture}
			\begin{axis}[
					colormap/cool,
					grid=both,
					domain=-2:2,
					domain y=-2:2,
					enlargelimits=false,
					xlabel=$x$,
					ylabel=$y$,
					zlabel={$f(x,y) = x^4 - 2x^2 - y^4 + 2y^2$},
					samples=50,
					z buffer=sort
				]
				\addplot3[surf] {x^4 - 2*x^2 - y^4 + 2*y^2};
			\end{axis}
		\end{tikzpicture}
	\end{center}

	The partial derivative of a function \( f(x, y) \) with respect to \( x \) at a point \( P = (x_0, y_0) \) is defined as:

	\[
		f_x(x_0, y_0) = \lim_{h \to 0} \frac{f(x_0 + h, y_0) - f(x_0, y_0)}{h}
	\]

	Similarly, the partial derivative with respect to \( y \) at \( P = (x_0, y_0) \) is:

	\[
		f_y(x_0, y_0) = \lim_{k \to 0} \frac{f(x_0, y_0 + k) - f(x_0, y_0)}{k}
	\]

	For the function \( f(x, y) = x^4 - 2x^2 - y^4 + 2y^2 \), the partial derivatives are:

	\[
		f_x(x, y) = 4x^3 - 4x, \quad f_y(x, y) = -4y^3 + 4y
	\]

}

\subsection{Differentiability}

\thm{Conditions for Differentiability}{Consider a function $f(x, y)$, and we aim to analyze the differentiability at a point $(a, b)$.

	To say that $f(x, y)$ is differentiable at the point $(a, b)$, the following conditions must hold:

	\begin{enumerate}
		\item The partial derivatives $f_x(a, b)$ and $f_y(a, b)$ must exist.
		\item We must have the following expression for the increment of $f$ at $(a, b)$:
		      \[
			      f(a + \Delta x, b + \Delta y) - f(a, b) = \Delta x f_x(a, b) + \Delta y f_y(a, b) + \epsilon_1(\Delta x) \Delta x + \epsilon_2(\Delta y) \Delta y
		      \]
		      where $\epsilon_1(\Delta x) \to 0$ as $\Delta x \to 0$ and $\epsilon_2(\Delta y) \to 0$ as $\Delta y \to 0$.
	\end{enumerate}

	This form shows that the change in the function can be approximated by the linear part involving the partial derivatives, with the higher-order terms represented by $\epsilon_1$ and $\epsilon_2$, which tend to zero.
}

\subsection*{Graphical Interpretation}

Consider the following illustration of the change in the function $f$:

\[
	\text{Elevation of } f(a, b) \to f(a + \Delta x, b + \Delta y)
\]

The increment of $f$ is given by:
\[
	f(a + \Delta x, b + \Delta y) - f(a, b)
\]

Using the definition of differentiability, we can decompose this increment as follows:

\[
	\Delta f = \Delta x f_x(a, b) + \Delta y f_y(a, b)
\]

Graphically, this can be interpreted as moving along the tangent plane at the point $(a, b)$ in the direction of $\Delta x$ and $\Delta y$. The elevation changes linearly based on the partial derivatives.

For the function to be differentiable at $(a, b)$, we require that:

\[
	\lim_{\Delta x \to 0} \epsilon_1(\Delta x) = 0, \quad \lim_{\Delta y \to 0} \epsilon_2(\Delta y) = 0
\]

These conditions ensure that the error terms involving $\epsilon_1$ and $\epsilon_2$ vanish as the changes $\Delta x$ and $\Delta y$ become small, ensuring a linear approximation near the point $(a, b)$.

\subsection{Open and Closed Sets}

Consider the set $R$ defined by:

\[
	R: y < x, \quad x^2 + y^2 < 1
\]

The set $R$ is open if we can draw it using **dashed lines**, indicating that the boundary is not included in the set. If we have a set of solutions to inequalities with strict inequalities (e.g., $<$ or $>$), the set is typically **open**.

If $R$ is defined by inequalities involving $\leq$ or $\geq$, then the set is **closed**.

\subsection*{Example of Open and Closed Sets}

Let $R_1$ be defined as:

\[
	R_1: x^2 + y^2 < 1 \quad \text{(open)}
\]

Let $S$ be defined as:

\[
	S: y < x \quad \text{(open)}
\]

We can also consider the closed sets:

\[
	R_2: x^2 + y^2 \leq 1 \quad \text{(closed)}
\]

\[
	S: y \leq x \quad \text{(closed)}
\]

Below are illustrations of open and closed sets. Dotted lines indicate that the boundary is **not included** (open), while solid lines indicate the boundary **is included** (closed).

\begin{center}
	\begin{tikzpicture}
		% Open set R: x^2 + y^2 < 1
		\draw[dashed] (0,0) circle (2);
		\node at (-2.5, 2.2) {$R_1$: $x^2 + y^2 < 1$};

		% Closed set R: x^2 + y^2 <= 1
		\draw (5,0) circle (2);
		\node at (8.5, 2.2) {$R_2$: $x^2 + y^2 \leq 1$};

		% Open set y < x
		\draw[dashed] (-3,-3) -- (3, 3);
		\node at (-3, 2.7) {Open $S: y < x$};

		% Closed set y <= x
		\draw (2, -3) -- (8, 3);
		\node at (8, 2.7) {Closed $S: y \leq x$};
	\end{tikzpicture}
\end{center}

\subsection{Conditions for Differentiability}

A function $f(x, y)$ is differentiable at $(a, b)$ if:

\begin{enumerate}
	\item The partial derivatives $f_x(a, b)$ and $f_y(a, b)$ exist.
	\item The following limit holds:
	      \[
		      f(a + \Delta x, b + \Delta y) - f(a, b) = \Delta x f_x(a, b) + \Delta y f_y(a, b) + \Delta x \epsilon_1(\Delta x) + \Delta y \epsilon_2(\Delta y)
	      \]
	      where $\epsilon_1(\Delta x) \to 0$ as $\Delta x \to 0$ and $\epsilon_2(\Delta y) \to 0$ as $\Delta y \to 0$.
\end{enumerate}

\thm{Sufficient Conditions for Differentiability}{

	A sufficient condition for differentiability is the following theorem:

	If there exists an open set $D$ containing $(a, b)$ such that $f_x(x, y)$ and $f_y(x, y)$ exist at all points in $D$, and if $f_x(a, b)$ and $f_y(a, b)$ are continuous at $(a, b)$, then $f(x, y)$ is differentiable at $(a, b)$.
}

\ex{Differentiability of a Given Function}{

	Consider the function:

	\[
		f(x, y) = e^{xy} + x^3 y
	\]

	We want to check whether this function is differentiable at any point $(a, b)$. First, we compute the partial derivatives:

	\[
		f_x(x, y) = y e^{xy} + 3x^2 y
	\]
	\[
		f_y(x, y) = x e^{xy} + x^3
	\]

	For any point $(a, b)$, both $f_x(a, b)$ and $f_y(a, b)$ exist in $\mathbb{R}^2$ and are continuous at $(a, b)$ because the terms $e^{xy}$, $x^3$, and $y$ are all continuous on $\mathbb{R}^2$.

	Thus, according to the theorem for differentiability, we conclude that:

	\[
		f(x, y) \text{ is differentiable at } (a, b)
	\]
}

\ex{Discontinuity of a Function}{

	Consider the function:

	\[
		f(x, y) =
		\begin{cases}
			\frac{3xy}{x^2 + y^2} & \text{if } (x, y) \neq (0, 0) \\
			0                     & \text{if } (x, y) = (0, 0)
		\end{cases}
	\]

	We are interested in determining whether this function is continuous and differentiable at the point $(0, 0)$.

	\subsection*{Continuity Check}

	We first evaluate $f(0, 0)$:

	\[
		f(0, 0) = 0
	\]

	Next, we compute the limit of $f(x, y)$ as $(x, y) \to (0, 0)$. To do this, we examine the limit along two different paths:

	\[
		r_1(t) = \langle t, 0 \rangle
	\]
	Along this path, we have:

	\[
		\lim_{t \to 0} f(t, 0) = \lim_{t \to 0} \frac{3t \cdot 0}{t^2 + 0^2} = 0
	\]

	Now consider the path:

	\[
		r_2(t) = \langle t, t \rangle
	\]
	Along this path, we compute:

	\[
		\lim_{t \to 0} f(t, t) = \lim_{t \to 0} \frac{3t \cdot t}{t^2 + t^2} = \frac{3t^2}{2t^2} = \frac{3}{2}
	\]

	Since the limits along different paths do not agree (one is $0$, and the other is $\frac{3}{2}$), we conclude that:

	\[
		f(x, y) \text{ is not continuous at } (0, 0)
	\]

	Thus, even though the partial derivatives $f_x$ and $f_y$ exist at $(0, 0)$, the function is not continuous, and therefore, $f(x, y)$ is not differentiable at $(0, 0)$.
}

\begin{center}
	\begin{tikzpicture}
		% Path r_1: along x-axis
		\draw[->, thick] (-2,0) -- (2,0);
		\node at (2.5, 0) {$r_1(t) = \langle t, 0 \rangle$};

		% Path r_2: diagonal line
		\draw[->, thick] (-2,-2) -- (2,2);
		\node at (2.5, 2) {$r_2(t) = \langle t, t \rangle$};

		% Mark origin
		\filldraw[red] (0, 0) circle (2pt);
		\node at (-0.2, -0.2) {$(0,0)$};

		% Labels
		\node at (0.5, -0.5) {Limit $0$};
		\node at (1.5, 1.5) {Limit $\frac{3}{2}$};
	\end{tikzpicture}
\end{center}

\thm{Differentiability Implies Continuity}{

	If $f(x, y)$ is differentiable at $(a, b)$, then $f(x, y)$ is also continuous at $(a, b)$. This is an important result that will help us analyze the next example.

}


\section{Directional Derivative}

Let $\mathbf{u} = \langle u_1, u_2 \rangle$ be a unit vector, i.e., $|\mathbf{u}| = 1$. The directional derivative of $f(x, y)$ at the point $(a, b)$ in the direction of $\mathbf{u}$ is defined as:

\[
	D_{\mathbf{u}} f(a, b) = \lim_{h \to 0} \frac{f(a + h u_1, b + h u_2) - f(a, b)}{h}
\]

This represents the slope of the hill that you are traveling on in the direction of $\mathbf{u}$.

If $f(x, y)$ is differentiable at $(a, b)$, we know that the function $f$ satisfies the following approximation:

\[
	f(a + \Delta x, b + \Delta y) - f(a, b) = \Delta x f_x(a, b) + \Delta y f_y(a, b) + \Delta x \epsilon_1(\Delta x) + \Delta y \epsilon_2(\Delta y)
\]

where $\epsilon_1(\Delta x) \to 0$ as $\Delta x \to 0$ and $\epsilon_2(\Delta y) \to 0$ as $\Delta y \to 0$.

\subsection{Derivation of the Directional Derivative}

Substituting $\Delta x = h u_1$ and $\Delta y = h u_2$, the directional derivative becomes:

\[
	\lim_{h \to 0} \frac{h u_1 f_x(a, b) + h u_2 f_y(a, b) + h u_1 \epsilon_1(h) + h u_2 \epsilon_2(h)}{h}
\]

Simplifying the expression:

\[
	= u_1 f_x(a, b) + u_2 f_y(a, b) + u_1 \epsilon_1(h) + u_2 \epsilon_2(h)
\]

As $h \to 0$, the terms $u_1 \epsilon_1(h)$ and $u_2 \epsilon_2(h)$ tend to $0$, so we are left with:

\[
	D_{\mathbf{u}} f(a, b) = u_1 f_x(a, b) + u_2 f_y(a, b)
\]

This can be expressed compactly as the dot product:

\[
	D_{\mathbf{u}} f(a, b) = \langle f_x(a, b), f_y(a, b) \rangle \cdot \mathbf{u}
\]

\dfn{Definition of the Gradient}{
	The gradient of $f(x, y)$ at the point $(a, b)$ is defined as the vector:

	\[
		\nabla f(a, b) = \langle f_x(a, b), f_y(a, b) \rangle
	\]

	The directional derivative is then the dot product of the gradient and the direction vector $\mathbf{u}$:

	\[
		D_{\mathbf{u}} f(a, b) = \nabla f(a, b) \cdot \mathbf{u}
	\]

	Thus, the gradient gives the direction of the steepest ascent of the function, and the directional derivative gives the rate of change of the function in the direction of $\mathbf{u}$.

}


\section{Application of the Gradient}

The gradient $\nabla f(a, b)$ plays an important role in determining the behavior of the function in various directions.

\subsection{Directional Derivative and the Gradient}

If $f$ is differentiable at $(a, b)$, then for any unit vector $\mathbf{u}$, the directional derivative of $f$ in the direction of $\mathbf{u}$ is given by:

\[
	D_{\mathbf{u}} f(a, b) = \nabla f(a, b) \cdot \mathbf{u}
\]

This formula can be used to determine how the function changes as we move in the direction of $\mathbf{u}$.

\subsection{Dot Product and Angle}

We know from vector calculus that:

\[
	\mathbf{u} \cdot \mathbf{v} = |\mathbf{u}| |\mathbf{v}| \cos \theta
\]

Thus, for the directional derivative:

\[
	D_{\mathbf{u}} f(a, b) = |\nabla f(a, b)| |\mathbf{u}| \cos \theta
\]

where $\theta$ is the angle between the gradient vector $\nabla f(a, b)$ and the direction vector $\mathbf{u}$.

\begin{itemize}
	\item If $\theta > \frac{\pi}{2}$, then $\mathbf{u}$ points downhill (negative directional derivative).
	\item If $0 < \theta < \frac{\pi}{2}$, then $\mathbf{u}$ points uphill (positive directional derivative).
\end{itemize}

\subsection{Maximum and Minimum Values of the Directional Derivative}

The directional derivative $D_{\mathbf{u}} f(a, b)$ is maximized when $\theta = 0^\circ$, which means that $\mathbf{u}$ points in the direction of the steepest ascent. This happens when $\mathbf{u}$ is in the same direction as $\nabla f(a, b)$:

\[
	\nabla f(a, b) \text{ points towards the direction of steepest ascent.}
\]

Conversely, the directional derivative is minimized when $\theta = 180^\circ$, which means $\mathbf{u}$ points in the direction of steepest descent. In this case:

\[
	-\nabla f(a, b) \text{ points towards the direction of steepest descent.}
\]

This forms the foundation of gradient descent algorithms, where the negative gradient is used to find minimum values.

\subsection{Tangent to a Level Curve}

Consider a level curve of the form $f(x, y) = c$. The vector $\nabla f(a, b)$ is perpendicular to the level curve at the point $(a, b)$, which implies that any vector $\mathbf{u}$ tangent to the level curve satisfies:

\[
	D_{\mathbf{u}} f(a, b) = 0
\]

This means that if $\mathbf{u}$ is tangent to the level curve, the directional derivative is zero, implying that there is no change in the value of the function along that curve.

Below is a diagram representing the gradient and the tangents to the level curves:

\begin{center}
	\includegraphics[scale=0.5]{levelcurves.png}
\end{center}

\section{Tangent Planes}

\subsection{Tangent Line for Single Variable Functions}

For a function of a single variable, the equation of the tangent line at a point \(f(a)\) is given by:
\[
	y = f'(a)(x - a) + f(a)
\]
This represents the line that touches the curve \(y = f(x)\) at the point \((a, f(a))\), and the slope of this line is determined by the derivative \(f'(a)\).

\subsection{Tangent Plane for Two Variable Functions}

For functions of two variables, i.e. \(f(x, y)\), the tangent plane at a point \(P(a, b, c)\) on the surface can be described. Let the function be \(f(a, b) = c\), and we define a point \(P(a, b, c)\) that lies on the surface at the tangent point.

The tangent plane equation is derived using partial derivatives and parameter vectors.

\textbf{Parameter Vector Representation}

Let the point on the surface be \(P = (a, b, c)\) and consider small increments in \(x\) and \(y\), denoted \(\Delta x\) and \(\Delta y\), respectively. The change in the function value \(\Delta z\) due to these increments can be approximated using the partial derivatives. The tangent plane is spanned by vectors in the \(x\) and \(y\) directions, leading to:
\[
	\vec{v} = \langle v_1, v_2 \rangle
\]
where:
\[
	v_1 = \frac{\partial f}{\partial x}(a, b) \quad \text{and} \quad v_2 = \frac{\partial f}{\partial y}(a, b)
\]
The equation of the plane then involves computing how much \(z\) increments based on \(x\) and \(y\), giving us the tangent plane equation:
\[
	z = c + \nabla f(a, b) \cdot \langle x - a, y - b \rangle
\]
where \(\nabla f(a, b)\) represents the gradient vector of the function \(f(x, y)\) at the point \((a, b)\).

\dfn{The Tangent Plane Equation}{

	The explicit equation of the tangent plane can be written as:
	\[
		\frac{\partial f}{\partial x}(a, b)(x - a) + \frac{\partial f}{\partial y}(a, b)(y - b) + z - c = 0
	\]
	This expresses how the surface locally behaves near the point \((a, b, c)\), and the coefficients of \(x - a\) and \(y - b\) are given by the partial derivatives of \(f\) at \((a, b)\).
}

\ex{1}{
	We are tasked with finding the tangent plane of the surface \( z = f(x, y) = \sin(x) \cdot e^y \) at the point \( \left( \frac{\pi}{2}, 0, 1 \right) \). The general form of the equation of a tangent plane to a surface \( z = f(x, y) \) is given by:

	\[
		\frac{\partial f}{\partial x}(a, b)(x - a) + \frac{\partial f}{\partial y}(a, b)(y - b) + z - c = 0
	\]

	We will follow the steps below to compute the tangent plane:

	\begin{enumerate}

		\item \textbf{Find the point of tangency \( (a, b, c) \):}

		      The point of tangency is given as \( \left( \frac{\pi}{2}, 0, 1 \right) \), so:
		      \[
			      a = \frac{\pi}{2}, \quad b = 0, \quad c = 1
		      \]

		\item \textbf{Compute the partial derivative with respect to \(x\):}

		      The partial derivative of \( f(x, y) = \sin(x) \cdot e^y \) with respect to \( x \) is:

		      \[
			      \frac{\partial f}{\partial x}(x, y) = \cos(x) \cdot e^y
		      \]

		      At the point \( \left( \frac{\pi}{2}, 0 \right) \), this becomes:

		      \[
			      \frac{\partial f}{\partial x} \left( \frac{\pi}{2}, 0 \right) = \cos\left( \frac{\pi}{2} \right) \cdot e^0 = 0 \cdot 1 = 0
		      \]

		\item \textbf{Compute the partial derivative with respect to \(y\):}

		      The partial derivative of \( f(x, y) = \sin(x) \cdot e^y \) with respect to \( y \) is:

		      \[
			      \frac{\partial f}{\partial y}(x, y) = \sin(x) \cdot e^y
		      \]

		      At the point \( \left( \frac{\pi}{2}, 0 \right) \), this becomes:

		      \[
			      \frac{\partial f}{\partial y} \left( \frac{\pi}{2}, 0 \right) = \sin\left( \frac{\pi}{2} \right) \cdot e^0 = 1 \cdot 1 = 1
		      \]

		\item \textbf{Substitute into the tangent plane equation:}

		      Using the general form of the tangent plane equation and substituting \( a = \frac{\pi}{2} \), \( b = 0 \), \( c = 1 \), as well as the values of the partial derivatives \( \frac{\partial f}{\partial x}(a, b) = 0 \) and \( \frac{\partial f}{\partial y}(a, b) = 1 \), we have:

		      \[
			      0 \cdot (x - \frac{\pi}{2}) + 1 \cdot (y - 0) + z - 1 = 0
		      \]

		      Simplifying the equation:

		      \[
			      y + z - 1 = 0
		      \]

		\item \textbf{Final equation of the tangent plane:}
		      Thus, the equation of the tangent plane at \( \left( \frac{\pi}{2}, 0, 1 \right) \) is:

		      \[
			      y + z - 1 = 0
		      \]

	\end{enumerate}

}

\begin{center}
	\begin{tikzpicture}
		\begin{axis}[
				colormap/cool,
				grid=both,
				enlargelimits=false,
				samples=50,
				z buffer=sort,
				view={60}{30},
				xlabel=$x$, ylabel=$y$, zlabel=$z$,
				domain=-3:6,
				y domain=-3:3,
				zmin=-5, zmax=5, % Set z-range to about 10 units total
				xmin=-3, xmax=6, % Set x-range to about 10 units total
				ymin=-3, ymax=3, % Set y-range to about 10 units total
			]
			% Plot the surface z = sin(x) * exp(y)
			\addplot3[surf] {sin(deg(x)) * exp(y)};
			% Plot the tangent plane z = exp(y)
			\addplot3[surf, opacity=0.6, color=red!80, fill opacity=0.3]
			{1+y};
		\end{axis}
	\end{tikzpicture}
\end{center}

\subsection{Implicit Case}

When dealing with implicit functions such as \(f(x, y) = D\), the process involves implicit differentiation to find the slope of the tangent line. For example, given an equation of the form:
\[
	x^2 + y^2 = 4
\]
we differentiate implicitly to obtain the tangent line equation. The process is as follows:
\[
	\frac{dy}{dx} = -\frac{F_x}{F_y}
\]
For the given equation \(x^2 + y^2 = 4\), we compute:
\[
	\frac{dy}{dx} = -\frac{x}{y}
\]
leading to the equation of the tangent line:
\[
	y - b = -\frac{F_x}{F_y}(x - a)
\]

\dfn{Tangent Line for Implicit Functions}{

	Finally, for the tangent line in the implicit case, we use the gradient \(\nabla f(a, b)\) to express the equation of the tangent line:
	\[
		\nabla f(a, b) \cdot \langle x - a, y - b \rangle = 0
	\]
	This represents a line tangent to the curve at the point \((a, b)\) on the implicit function.
}

\subsection{Level Surfaces and Tangent Planes}

A \textbf{level surface} is represented by the equation \( w = f(x, y, z) \), where \(w\) is a constant, indicating a 3D surface embedded in 4D space. For example:
\[
	f(x, y, z) = D, \quad D \in \mathbb{R}
\]
This represents a 2D surface in 3D space. An example is the implicit equation:
\[
	x^2 + y^2 + z^2 = 4
\]
which describes a sphere of radius 2 in 3D space.

\dfn{Level Curves Tangent Plane}{
	The tangent plane to the surface is given by:
	\[
		\nabla F(a, b, c) \cdot \langle x - a, y - b, z - c \rangle = 0
	\]
	where \(\nabla F(a, b, c)\) is the gradient of the function \(F\) at the point \((a, b, c)\).
}

\subsection{Summary of Cases}

\begin{center}
	\begin{tabular}{|c|c|}
		\hline
		\textbf{Curve/Surface} & \textbf{Equation}                                                     \\
		\hline
		\( y = f(x) \)         & \( y = f'(a)(x - a) + f(a) \)                                         \\
		\( z = f(x, y) \)      & \( z = c + \nabla f(a, b) \cdot \langle x - a, y - b \rangle \)       \\
		\( F(x, y, z) = D \)   & \( \nabla F(a, b, c) \cdot \langle x - a, y - b, z - c \rangle = 0 \) \\
		\hline
	\end{tabular}
\end{center}

\ex{1}{

	Consider the surface given by:
	\[
		z = f(x, y) = x^2 y^2 - 2x
	\]
	At the point \((1, 3, 7)\), we compute the gradient:
	\[
		\nabla f(x, y) = \langle y^2 2x - 2, x^2 2y \rangle
	\]
	At the point \((1, 3)\):
	\[
		\nabla f(1, 3) = \langle 9 - 2, 6 \rangle = \langle 7, 6 \rangle
	\]
	The equation of the tangent plane is:
	\[
		7(x - 1) + 6(y - 3) + z - 7 = 0
	\]
	Simplifying this gives:
	\[
		7(x - 1) + 6(y - 3) + z = 7
	\]
}

\ex{2}{

	Now, consider the implicit surface given by:
	\[
		F(x, y, z) = x^3 - 3y + z^2 = 8
	\]
	At the point \((1, 2, 3)\), the gradient is:
	\[
		\nabla F(x, y, z) = \langle 3x^2, -3, 2z \rangle
	\]
	At the point \((1, 2, 3)\), this evaluates to:
	\[
		\nabla F(1, 2, 3) = \langle 3, -3, 6 \rangle
	\]
	The tangent plane equation is:
	\[
		3(x - 1) - 3(y - 2) + 6(z - 3) = 0
	\]
	Simplifying:
	\[
		3(x - 1) - 3(y - 2) + 6(z - 3) = 0
	\]
	\[
		3(x - 1) - 3(y - 2) + 6(z - 3) = 0
	\]
	This describes the tangent plane to the surface at the given point.
}

\section{Applications of Tangent Planes}

\subsection{Linear Approximation}

In many cases, we know the value of the function \( f(a, b) \) at a particular point and want to estimate the value of \( f(x, y) \) near that point. We use the linear approximation formula for this estimation:
\[
	f(x, y) \approx f(a, b) + \nabla f(a, b) \cdot \langle x - a, y - b \rangle
\]
where \( \nabla f(a, b) \) is the gradient of the function \( f \) at the point \((a, b)\).



\tdplotsetmaincoords{70}{130}
%

\begin{center}
	\begin{tikzpicture}[tdplot_main_coords]
		% functions
		\tikzmath{function funcion(\x,\y) {return (\x*\x+3*\y*\y)*e^(-\x*\x-\y*\y);};} % the function $z = f(x,y)$
		\tikzmath{function derivadax(\x,\y) {return -2.0*\x*(-1.0 + \x * \x + 3.0 * \y * \y) * exp(-\x*\x - \y*\y);};}	% $f_{x}$
		\tikzmath{function derivaday(\x,\y) {return -2.0*\y*(-3.0 + \x * \x + 3.0 * \y * \y) * exp(-\x*\x - \y*\y);};}	% $f_{y}$
		% equation of the plane
		\tikzmath{function plano(\x,\y) {return derivadax(\xcero,\ycero)*(\x-\xcero)+derivaday(\xcero,\ycero)*(\y-\ycero)+\zcero;};}
		%	
		\pgfmathsetmacro{\dominio}{0.75*pi}	% domain for plotting
		\pgfmathsetmacro{\step}{\dominio/50.0} % step size
		\pgfmathsetmacro{\max}{\dominio}
		\pgfmathsetmacro{\xi}{-\dominio}
		\pgfmathsetmacro{\xf}{\dominio}
		\pgfmathsetmacro{\xe}{\xf+\step}
		\pgfmathsetmacro{\xs}{\xi+\step}
		\pgfmathsetmacro{\yi}{-\dominio}
		\pgfmathsetmacro{\yf}{\dominio}
		\pgfmathsetmacro{\ys}{\yi+\step}
		\pgfmathsetmacro{\ye}{\yf+\step}
		\pgfmathsetmacro{\h}{1}
		%  size of the tangent plane
		\pgfmathsetmacro{\size}{1.5}
		% Point of tangency $(\x_{0}, y_{0}, z_{0})$
		\pgfmathsetmacro{\xcero}{1.125} 
		\pgfmathsetmacro{\ycero}{1.5} 
		\pgfmathsetmacro{\zcero}{funcion(\xcero,\ycero)}
		\pgfmathsetmacro{\dx}{1.0}
		\pgfmathsetmacro{\dy}{1.0}
		\pgfmathsetmacro{\zplanoxi}{plano(\xcero,\ycero)}
		\pgfmathsetmacro{\zplanoxf}{plano(\xcero+\dx,\ycero)}
		\pgfmathsetmacro{\zplanoyi}{plano(\xcero,\ycero)}
		\pgfmathsetmacro{\zplanoyf}{plano(\xcero,\ycero+\dx)}
		\pgfmathsetmacro{\zplanoxyf}{plano(\xcero+\dx,\ycero+\dx)}
		% Region where the tangent plane is shown
		\pgfmathsetmacro{\Ax}{\xcero-\size}
		\pgfmathsetmacro{\Ay}{\ycero-\size}
		\pgfmathsetmacro{\Bx}{\xcero+\size}
		\pgfmathsetmacro{\By}{\ycero-\size}
		\pgfmathsetmacro{\Cx}{\xcero+\size}
		\pgfmathsetmacro{\Cy}{\ycero+\size}
		\pgfmathsetmacro{\Dx}{\xcero-\size}
		\pgfmathsetmacro{\Dy}{\ycero+\size}
		% Vertices of the tangent plane
		\pgfmathsetmacro{\Az}{plano(\Ax,\Ay)}
		\pgfmathsetmacro{\Bz}{plano(\Bx,\By)}
		\pgfmathsetmacro{\Cz}{plano(\Cx,\Cy)}
		\pgfmathsetmacro{\Dz}{plano(\Dx,\Dy)}
		%
		\pgfmathsetmacro{\zmax}{funcion(-\max,-\max)}
		\pgfmathsetmacro{\zorigen}{funcion(0,0)}
		\pgfmathsetmacro{\zplano}{plano(0,0)}
		% Plot the graph in the third and second quadrants 
		% The graph of $z = f(x,y)$: third quadrant
		\foreach \x in {\xi,\xs,...,0}{
			\draw[cyan,opacity=0.75] plot[domain=\yi:0,smooth,variable=\t] ({\x},{\t},{funcion(\x,\t)});
		}
		\foreach \y in {\yi,\ys,...,0}{
			\draw[cyan,opacity=0.75] plot[domain=\yi:0,smooth,variable=\t] ({\t},{\y},{funcion(\t,\y)});
		}
		% negative part of the coordinate axis
		\draw[thick] (\xi-0.25,0,0) -- (0,0,0); % x axis
		\draw[thick] (0,\yi-0.25,0,0) -- (0,0,0); % y axis
		\foreach \x in {-1,1}
			\draw[thick] (\x,0,0.05) -- (\x,0,-0.05) node [below] {$\x$};
		\foreach \y in {-1,1}
			\draw[thick] (0,\y,0.05) -- (0,\y,-0.05) node [below] {$\y$};
		\foreach \z/\posicion in {0/below left}
			\draw[thick] (0,0.05,\z) -- (0,-0.05,\z) node [\posicion] {$\z$};
		% The graph of $z = f(x,y)$: second quadrant
		\foreach \x in {\xi,\xs,...,0}{
			\draw[cyan,opacity=0.75] plot[domain=0:\yf,smooth,variable=\t] ({\x},{\t},{funcion(\x,\t)});
		}
		\foreach \y in {0,\step,...,\yf}{
			\draw[cyan,opacity=0.75] plot[domain=\xi:0,smooth,variable=\t] ({\t},{\y},{funcion(\t,\y)});
		}
		% The graph of $z = f(x,y)$: fouth quadrant
		\foreach \x in {0,\step,...,\xf}{
			\draw[cyan,opacity=0.75] plot[domain=\yi:0,smooth,variable=\t] ({\x},{\t},{funcion(\x,\t)});
		}
		\foreach \y in {\yi,\ys,...,0}{
			\draw[cyan,opacity=0.75] plot[domain=0:\yf,smooth,variable=\t] ({\t},{\y},{funcion(\t,\y)});
		}	
		% coordinate axis
		\draw[thick] (0,0,0) -- (0,\yf+0.5,0); % Eje y
		\draw[thick,->] (0,0,0) -- (\xf+1.0,0,0) node [below] {$x$};
		\draw[thick,->] (0,\yf,0) -- (0,\yf+0.5,0) node [right] {$y$};
		\draw[thick] (0,0,0) -- (0,0,\zplano,0);
		\foreach \z/\posicion in {1/above right}
			\draw[thick] (0,0.05,\z) -- (0,-0.05,\z) node [\posicion] {$\z$};
		% The graph of $z = f(x,y)$: first quadrant
		\foreach \x in {0,\step,...,\xf}{
			\draw[cyan,opacity=0.75] plot[domain=0:\yf,smooth,variable=\t] ({\x},{\t},{funcion(\x,\t)});
		}
		\foreach \y in {0,\step,...,\yf}{
			\draw[cyan,opacity=0.75] plot[domain=0:\yf,smooth,variable=\t] ({\t},{\y},{funcion(\t,\y)});
		}	
		% plot of $z = f(x,y)$ for $y$ constant
		\draw[blue,thick] plot[domain=-\dominio:\dominio,smooth,variable=\t,samples=100] ({\t},{\ycero},{funcion(\t,\ycero)});
		% plot of $z = f(x,y)$ for $x$ constant
		\draw[blue,thick] plot[domain=-\dominio:\dominio,smooth,variable=\t,samples=100] ({\xcero},{\t},{funcion(\xcero,\t)});
		% the edge of the plane
		\fill[yellow,opacity=0.5] (\Ax,\Ay,\Az) -- (\Bx,\By,\Bz) -- (\Cx,\Cy,\Cz) -- (\Dx,\Dy,\Dz) -- (\Ax,\Ay,\Az);
		\draw[gray,dash dot dot] (\Ax,\Ay,\Az) -- (\Bx,\By,\Bz) -- (\Cx,\Cy,\Cz) -- (\Dx,\Dy,\Dz) -- (\Ax,\Ay,\Az);
		% The point of tangency
		\fill[blue] (\xcero,\ycero,\zcero) circle (1pt);		
		% Last part of the $z$ axis
		\draw[thick,->] (0,0,\zplano) -- (0,0,\max) node[above] {$z = f(x,y)$}; 
		% Increment $\Delta x$
		\draw[red,thin] (\xcero,\ycero,\zcero) 
			-- (\xcero+\dx,\ycero,\zcero) 
			-- (\xcero+\dx,\ycero,\zplanoxf) node[left,midway] {\footnotesize$f_{x}(x,y)\cdot \Delta x$}
			-- (\xcero,\ycero,\zcero);
		% Increment $\Delta y$
		\draw[red,thin] (\xcero,\ycero,\zcero) 
			-- (\xcero,\ycero+\dy,\zcero) 
			-- (\xcero,\ycero+\dy,\zplanoyf) node[right,midway] {\footnotesize$f_{y}(x,y)\cdot \Delta y$}
			-- (\xcero,\ycero,\zcero);
		% Total increment for $z$
		\draw[red,thin] (\xcero,\ycero,\zcero) -- (\xcero+\dx,\ycero,\zcero) -- (\xcero+\dx,\ycero+\dy,\zcero) -- (\xcero,\ycero+\dy,\zcero) -- (\xcero,\ycero,\zcero);
		\draw[red,thin] (\xcero+\dx,\ycero,\zplanoxf) -- (\xcero+\dx, \ycero+\dy, \zplanoxyf) -- (\xcero,\ycero+\dy,\zplanoyf);
		\draw[red,thin] (\xcero+\dx, \ycero+\dy, \zplanoxyf) -- (\xcero+\dx, \ycero+\dy, \zcero);
	\end{tikzpicture}
	%
\end{center}

\ex{Linear Approximation of \( \sin(x y) \)}{

	Let \( f(x, y) = \sin(x y) \). We want to estimate \( f(0.8, 0.25) \) using linear approximation.

	\begin{enumerate}
		\item First, find \( f(a, b) = f(\pi/2, 0.2) \). Since \( \sin(\frac{\pi}{2} \cdot 0.2) \approx 0.985 \), we get:
		      \[
			      f(a, b) = \sin \left( \frac{\pi}{2} \times 0.2 \right) \approx 0.985
		      \]
		\item The gradient \( \nabla f(x, y) \) is given by:
		      \[
			      \nabla f(x, y) = \langle y \cos(x y), x \cos(x y) \rangle
		      \]
		      At \( (\frac{\pi}{2}, 0.2) \), we calculate the partial derivatives:
		      \[
			      \nabla f\left(\frac{\pi}{2}, 0.2\right) = \langle 0.2 \cos(1), \frac{\pi}{2} \cos(1) \rangle
		      \]
		      Using \( \cos(1) \approx 0.5403 \), we have:
		      \[
			      \nabla f\left(\frac{\pi}{2}, 0.2\right) = \langle 0.1081, 0.8474 \rangle
		      \]
		\item Now, estimate \( f(0.8, 0.25) \) using the formula for linear approximation:
		      \[
			      f(0.8, 0.25) \approx f\left(\frac{\pi}{2}, 0.2\right) + \nabla f\left(\frac{\pi}{2}, 0.2\right) \cdot \langle 0.8 - \frac{\pi}{2}, 0.25 - 0.2 \rangle
		      \]
		      Simplifying:
		      \[
			      f(0.8, 0.25) \approx 0.985 + \langle 0.1081, 0.8474 \rangle \cdot \langle -0.014, 0.05 \rangle
		      \]
		      \[
			      f(0.8, 0.25) \approx 0.985 + (-0.0015 + 0.0424)
		      \]
		      \[
			      f(0.8, 0.25) \approx 0.985 + 0.0409 = 1.0259
		      \]
	\end{enumerate}

}

\subsection{Finding Approximate Solutions to Equations}

To find approximate solutions to equations, we can apply linearization techniques similar to the above. For instance, if we know a point \((a, b, c)\) and want to estimate the solution for \(f(x, y, z)\), we use the following approximation:
\[
	f(x, y, z) \approx f(a, b, c) + \nabla f(a, b, c) \cdot \langle x - a, y - b, z - c \rangle
\]
where \(\nabla f(a, b, c)\) is the gradient of the function at the point \((a, b, c)\).

\ex{Finding the Root of \( f(z) = z e^z + 1.02 z - e^z - 0.2 \)}{
	To find approximate solutions to equations, we can apply linearization techniques similar to the above. For instance, if we know a point \((a, b, c)\) and want to estimate the solution for \(f(x, y, z)\), we use the following approximation:
	\[
		f(x, y, z) \approx f(a, b, c) + \nabla f(a, b, c) \cdot \langle x - a, y - b, z - c \rangle
	\]
	where \(\nabla f(a, b, c)\) is the gradient of the function at the point \((a, b, c)\).

	\subsection{Example: Linearizing \( f(x,y,z) = z\ln(z) + xz - e^{yz} \)}

	Consider the function \( f(x, y, z) = z\ln(z) + xz - e^{yz} \). We want to find an approximate solution around the point \( (x, y, z) = (1, 0, 1) \).

	First, we calculate the value of the function at this point:
	\[
		f(1, 0, 1) = 1 \ln(1) + 1 \cdot 1 - e^{0 \cdot 1} = 0 + 1 - 1 = 0.
	\]

	Next, we compute the gradient \( \nabla f(x, y, z) \) at the point \( (1, 0, 1) \). The gradient is given by:
	\[
		\nabla f(x, y, z) = \left( \frac{\partial f}{\partial x}, \frac{\partial f}{\partial y}, \frac{\partial f}{\partial z} \right).
	\]

	\noindent
	The partial derivatives are calculated as follows:
	\[
		\frac{\partial f}{\partial x} = z, \quad \frac{\partial f}{\partial y} = -z e^{yz}, \quad \frac{\partial f}{\partial z} = \ln(z) + 1 + x - y e^{yz}.
	\]

	Evaluating these at \( (x, y, z) = (1, 0, 1) \):
	\[
		\frac{\partial f}{\partial x}(1, 0, 1) = 1, \quad \frac{\partial f}{\partial y}(1, 0, 1) = -1, \quad \frac{\partial f}{\partial z}(1, 0, 1) = \ln(1) + 1 + 1 = 2.
	\]

	Thus, the gradient at \( (1, 0, 1) \) is:
	\[
		\nabla f(1, 0, 1) = (1, -1, 2).
	\]

	Using the linear approximation formula:
	\[
		f(x, y, z) \approx f(1, 0, 1) + \nabla f(1, 0, 1) \cdot \langle x - 1, y, z - 1 \rangle,
	\]
	we substitute the values:
	\[
		f(x, y, z) \approx 0 + (1)(x - 1) + (-1)(y) + (2)(z - 1).
	\]

	Simplifying:
	\[
		f(x, y, z) \approx x - 1 - y + 2(z - 1).
	\]
	\[
		f(x, y, z) \approx x + 2z - y - 3.
	\]

	Thus, the linearized approximation of \( f(x, y, z) \) around \( (1, 0, 1) \) is:
	\[
		f(x, y, z) \approx x + 2z - y - 3.
	\]

}

\subsection{Differentials}

\thm{Differentials approximation using gradient}{

	Suppose \( z = f(x, y) \), then
	\[
		\Delta z = f(x + \Delta x, y + \Delta y) - f(x, y)
	\]
	can be approximated by
	\[
		\Delta z \approx \nabla f(x, y) \cdot \langle \Delta x, \Delta y \rangle
	\]
	which expands to
	\[
		\Delta z = f_x(x, y) \Delta x + f_y(x, y) \Delta y
	\]
	where \( f_x(x, y) \) and \( f_y(x, y) \) are the partial derivatives of \( f \) with respect to \( x \) and \( y \), respectively.

}

\ex{Example}{

	Consider the volume \( V \) of a cone, given by
	\[
		V = \frac{\pi}{2} r^2 h
	\]
	where \( r \) is the radius and \( h \) is the height of the cone. If \( r \) decreases by 1.5\% and \( h \) increases by 2.2\%, what is the percentage change in \( V \)?

	First, find the change in volume \( \Delta V \) using the differential approximation:
	\[
		\Delta V = V_r \Delta r + V_h \Delta h
	\]
	where \( V_r \) and \( V_h \) are the partial derivatives of \( V \) with respect to \( r \) and \( h \). We have:
	\[
		V_r = \pi r h, \quad V_h = \frac{\pi}{2} r^2
	\]
	Thus,
	\[
		\frac{\Delta V}{V} = \frac{\pi r h \Delta r}{\frac{\pi}{2} r^2 h} + \frac{\frac{\pi}{2} r^2 \Delta h}{\frac{\pi}{2} r^2 h}
		= \frac{2 \Delta r}{r} + \frac{\Delta h}{h}
	\]

	Substituting the percentage changes:
	\[
		\frac{\Delta V}{V} = 2 \left( \frac{-1.5}{100} \right) + \left( \frac{2.2}{100} \right)
		= -0.03 + 0.022 = -0.008
	\]

	Thus, the volume decreases by $0.8\%$.

}


\section{Chain Rule in Functions of several random variables  $ f:\mathbb{R} ^ n \rightarrow \mathbb{R} $ }


\clm{Differentiation of functions}{}{
	Let $z$ be a differentiable function of $x$ and $y$ on an interval domain, where $x$ and $y$ are differentiable functions of $t$ on interval $I$. Then:

	\[
		\frac{dz}{dt} = \frac{\partial z}{\partial x} \frac{dx}{dt} + \frac{\partial z}{\partial y} \frac{dy}{dt}
	\]

	We sum the rates of change of $z$ through $x$ and $y$.
}

\dfn{Single Variable}{
	For single-variable functions, we use $\frac{d}{dt}$; for multiple variables, we use $\frac{\partial}{\partial t}$.
}


\begin{center}
	\begin{forest}
		[$z$
			[$\frac{\partial z}{\partial x}$
					[$x$
							[$\frac{dx}{db}$
									[$t$]
								]
						]
				]
				[$\frac{\partial z}{\partial y}$
					[$y$
							[$\frac{dy}{db}$
									[$t$]
								]
						]
				]
		]
	\end{forest}
\end{center}

\clm{Three Variables}{}{
	If $z$ is a function of $x$, $y$, and $t$, we have:

	\[
		\frac{dz}{dt} = \frac{\partial z}{\partial x} \frac{dx}{dt} + \frac{\partial z}{\partial y} \frac{dy}{dt} + \frac{\partial z}{\partial t}
	\]
}


\begin{center}
	\begin{forest}
		[$w$
			[$\frac{\partial w}{\partial y}$
					[$y$
							[$\frac{dy}{db}$
									[$t$]
								]
						]
				]
				[$\frac{\partial w}{\partial x}$
					[$x$
							[$\frac{dx}{db}$
									[$t$]
								]
						]
				]
				[$\frac{\partial w}{\partial z}$
					[$z$
							[$\frac{dz}{db}$
									[$t$]
								]
						]
				]
		]
	\end{forest}
\end{center}

\ex{Example 1}{
	Given $z = x \sin(y), \; x = t^2, \; y = t^3$:

	\[
		\frac{\partial z}{\partial x} = \sin(y), \quad \frac{\partial z}{\partial y} = x \cos(y)
	\]
	\[
		\frac{dx}{dt} = 2t, \quad \frac{dy}{dt} = 3t^2
	\]

	Therefore,

	\[
		\frac{dz}{dt} = \sin(t^3)(2t) + t^2 \cos(t^3)(3t^2) = 2t \sin(t^3) + 3t^4 \cos(t^3)
	\]

	\begin{center}
		\begin{forest}
			[$z$
				[$\frac{\partial z}{\partial x}$
						[$x$
								[$\frac{dx}{dt}$
										[$t$]
									]
							]
					]
					[$\frac{\partial z}{\partial y}$
						[$y$
								[$\frac{dy}{dt}$
										[$t$]
									]
							]
					]
			]
		\end{forest}
	\end{center}

}

\ex{Example 2}{
	Given $V = x y z, \; x = e^t, \; y = 2t + 3, \; z = \sin(t)$:

	\[
		\frac{\partial V}{\partial x} = yz, \quad \frac{\partial V}{\partial y} = xz, \quad \frac{\partial V}{\partial z} = xy
	\]
	\[
		\frac{dx}{dt} = e^t, \quad \frac{dy}{dt} = 2, \quad \frac{dz}{dt} = \cos(t)
	\]

	Therefore,

	\[
		\frac{dV}{dt} = yz \cdot e^t + xz \cdot 2 + xy \cdot \cos(t)
	\]
	Substituting:

	\[
		\frac{dV}{dt} = (2t+3)\sin(t) \cdot e^t + (e^t)\sin(t) \cdot 2 + (e^t)(2t+3) \cdot \cos(t)
	\]

	\begin{center}
		\begin{forest}
			[$V$
				[$\frac{\partial V}{\partial x}$
						[$x$
								[$\frac{dx}{dt}$
										[$t$]
									]
							]
					]
					[$\frac{\partial V}{\partial y}$
						[$y$
								[$\frac{dy}{dt}$
										[$t$]
									]
							]
					]
					[$\frac{\partial V}{\partial z}$
						[$z$
								[$\frac{dz}{dt}$
										[$t$]
									]
							]
					]
			]
		\end{forest}
	\end{center}

}

\clm{Two Independent Variables}{}{
	If $z = f(x, y), x = g(s,t), y = h(s,t)$, then:

	\[
		\frac{dz}{ds} = \frac{\partial z}{\partial x} \frac{\partial x}{\partial s} + \frac{\partial z}{\partial y} \frac{\partial y}{\partial s}
	\]

	\[
		\frac{dz}{dt} = \frac{\partial z}{\partial x} \frac{\partial x}{\partial t} + \frac{\partial z}{\partial y} \frac{\partial y}{\partial t}
	\]

}

\begin{center}
	\begin{forest}
		[z
				[x
						[s]
						[t]
				]
				[y
						[s]
						[t]
				]
		]
	\end{forest}
\end{center}

\clm{Implicit Differentiation}{}{
	Let $f$ be a differentiable function on its domain, and suppose $f(x,y) = 0$ defines $y$ as a differentiable function of $x$. Provided $F_y \neq 0$, we have:

	\[
		\frac{dy}{dx} = - \frac{F_x}{F_y}
	\]

	\ex{Example}{
		Given:
		\[
			\frac{dy}{dx} \; \text{if} \; y e^{xy} - 2 = 0
		\]

		We have:
		\[
			F_x = y^2 e^{xy}, \quad F_y = xy e^{xy} + e^{xy}
		\]

		Therefore:
		\[
			\frac{dy}{dx} = -\frac{y^2 e^{xy}}{xy e^{xy} + e^{xy}} = \frac{-y^2}{x + y}
		\]
	}
}

\section{Maximum and Minimum of 2 Variable Functions $f:\mathbb{R} \rightarrow \mathbb{R}^2$ }

\subsection{Critical Points}

A \emph{critical point} of a function \( f(x, y) \) is a point \( (a, b) \in \mathbb{R}^2 \) such that:
\begin{enumerate}
	\item \( \nabla f(a, b) = \vec{0} \), i.e., the gradient of \( f \) at \( (a, b) \) is the zero vector $<0,0$.
	\item The partial derivatives \( f_x(a, b) \) and \( f_y(a, b) \) both exist.
\end{enumerate}

At a critical point, there are three possible types:
\begin{enumerate}
	\item \emph{Local minimum}: The function value increases as we move away from \( (a, b) \) in all directions.
	\item \emph{Local maximum}: The function value decreases as we move away from \( (a, b) \) in all directions.
	\item \emph{Saddle point}: The function behaves such that in some directions, it increases, while in others, it decreases.
\end{enumerate}

\subsection{Definitions}
\begin{enumerate}
	\item \( f(a, b) \) is a \emph{local maximum} if there exists an open disc \( D \), such that for all \( (x, y) \in D \), \( f(a, b) \geq f(x, y) \).
	\item \( f(a, b) \) is a \emph{local minimum} if the same condition holds, but with \( f(a, b) \leq f(x, y) \).
	\item A \emph{saddle point} exists if, for any neighborhood around \( (a, b) \), there exist points \( (x_1, y_1) \) and \( (x_2, y_2) \) such that \( f(a, b) > f(x_1, y_1) \) and \( f(a, b) < f(x_2, y_2) \).
\end{enumerate}

\subsection{Visual Representation of Maxima, Minima and Saddle Points}

\begin{tikzpicture}
	\begin{groupplot}[
			group style={
					group name=my plots,
					group size=3 by 1,
					horizontal sep=1.5cm,
				},
			colormap/hot,
			mesh/ordering=y varies, % Add mesh/gridlines
			grid=major, % Add gridlines to the axesP
			width=6cm,
			height=6cm,
			xlabel=$x$, ylabel=$y$, zlabel=$z$,
			domain=-2:2,
			samples=50,
		]

		% Plot 1: z = x^2 + y^2 (Local Minima)
		% Plot 1: z = x^2 + y^2 (Local Minima)
		\nextgroupplot[title={$z = x^2 + y^2$}, zmax=4, zmin=0]
		\addplot3[surf] {x^2 + y^2};
		\node at (axis cs:-1.5,1.5,-0.5) [below] {Local Minima};

		% Plot 2: z = -x^2 - y^2 (Local Maxima)
		\nextgroupplot[title={$z = -x^2 - y^2$}, zmax=0, zmin=-4]
		\addplot3[surf] {-x^2 - y^2};
		\node at (axis cs:-1.5,1.5,-3.5) [below] {Local Maxima};

		% Plot 3: z = x^2 - y^2 (Saddle Point)
		\nextgroupplot[title={$z = x^2 - y^2$}, zmax=4, zmin=-4]
		\addplot3[surf] {x^2 - y^2};
		\node at (axis cs:-1.5,1.5,-3.5) [below] {Saddle Point};

	\end{groupplot}
\end{tikzpicture}

\subsection{Second Derivative Test}
The second derivative test is used to classify critical points by examining the Hessian matrix. The Hessian matrix, \( H(x, y) \), contains the second-order partial derivatives of \( f(x, y) \):
\[
	H(x, y) = \begin{bmatrix}
		f_{xx}(x, y) & f_{xy}(x, y) \\
		f_{yx}(x, y) & f_{yy}(x, y)
	\end{bmatrix}
\]
We evaluate the determinant of the Hessian, \( \text{det}(H) = f_{xx}(x, y) f_{yy}(x, y) - \left( f_{xy}(x, y) \right)^2 \), and use the following rules:
\begin{enumerate}
	\item If \( \text{det}(H) > 0 \) and \( f_{xx}(a, b) > 0 \), then \( f(a, b) \) is a \emph{local minimum}.
	\item If \( \text{det}(H) > 0 \) and \( f_{xx}(a, b) < 0 \), then \( f(a, b) \) is a \emph{local maximum}.
	\item If \( \text{det}(H) < 0 \), then \( (a, b) \) is a \emph{saddle point}.
	\item If \( \text{det}(H) = 0 \), the test is \emph{inconclusive}.
\end{enumerate}

\ex{Example}{
	Consider the function:
	\[
		f(x, y) = x^3 - 3x + y^3 - 3y
	\]
	To find the critical points, we calculate the gradient:
	\[
		\nabla f(x, y) = \begin{bmatrix} 3x^2 - 3 \\ 3y^2 - 3 \end{bmatrix}
	\]
	Setting \( \nabla f(x, y) = 0 \), we solve:
	\[
		3x^2 - 3 = 0 \quad \Rightarrow \quad x = \pm 1
	\]
	\[
		3y^2 - 3 = 0 \quad \Rightarrow \quad y = \pm 1
	\]
	Thus, the critical points are \( (1, 1), (1, -1), (-1, 1), (-1, -1) \).

	Next, we calculate the Hessian matrix:
	\[
		H(x, y) = \begin{bmatrix}
			6x & 0   \\
			0  & -6y
		\end{bmatrix}
	\]
	The determinant of the Hessian is:
	\[
		\text{det}(H) = -36xy
	\]
	For the critical points:
	\begin{itemize}
		\item \( (1, 1) \): \( \text{det}(H) = 36 \), so this is a saddle point.
		\item \( (1, -1) \): \( \text{det}(H) = -36 \), and since \( f_{xx}(1, 1) = 6 \), this is a local minimum.
		\item \( (-1, 1) \): \( \text{det}(H) = -36 \), and since \( f_{xx}(-1, -1) = -6 \), this is a local maximum.
		\item \( (-1, -1) \): \( \text{det}(H) = 36 \), so this is a saddle point.
	\end{itemize}
}

\begin{center}
	\begin{tikzpicture}
		\begin{axis}[
				colormap/hot,
				width=10cm,
				height=10cm,
				xlabel=$x$, ylabel=$y$, zlabel=$z$,
				domain=-3:3,
				samples=50,
				samples y=50,
				zmax=8, zmin=-8,
				mesh/ordering=y varies, % Add mesh/gridlines
				grid=major, % Add gridlines to the axesP
				view={250}{60}, % Adjusting the view angle for better perspective
				scatter/classes={a={mark=*,blue}} % For marking points
			]
			\addplot3[surf, mesh/cols=50] {x^3 - 3*x + y^3 - 3*y};
			\addplot3[only marks, mark=*, color=red] coordinates {
					(1,1,-4) % z = -4
					(-1,1,0) % z = 0
					(1,-1,0) % z = 0
					(-1,-1,4) % z = 4
				};
			\node at (axis cs:1,1,-4) [anchor=north east,fill=white] {\tiny $(1,1)$ MIN};
			\node at (axis cs:-1,1,0) [anchor=north west,fill=white] {\tiny $(-1,1)$ SADDLE};
			\node at (axis cs:1,-1,0) [anchor=south east,fill=white] {\tiny $(1,-1)$ SADDLE};
			\node at (axis cs:-1,-1,4) [anchor=south west,fill=white] {\tiny $(-1,-1)$ MAX};

		\end{axis}
	\end{tikzpicture}
\end{center}

\subsection{Connection Between the Second Derivative Test and Eigenvalues of the Hessian}

The Second Derivative Test is closely related to the eigenvalues of the Hessian matrix. To understand this connection, we need to explore the geometric interpretation of eigenvalues and how they inform us about the curvature of a function at a critical point.

Given a Hessian matrix \( H(x, y) \), we can compute its eigenvalues, \( \lambda_1 \) and \( \lambda_2 \). These eigenvalues describe the principal curvatures of the function in the directions of the corresponding eigenvectors. Here's the relationship between the eigenvalues and the nature of the critical point:

\begin{enumerate}
	\item If both eigenvalues \( \lambda_1 > 0 \) and \( \lambda_2 > 0 \), the function \( f(x, y) \) is \emph{locally convex} at the critical point, meaning the graph of the function curves upwards in all directions. This corresponds to a \textbf{local minimum}.
	\item If both eigenvalues \( \lambda_1 < 0 \) and \( \lambda_2 < 0 \), the function is \emph{locally concave}, meaning the graph curves downwards in all directions. This corresponds to a \textbf{local maximum}.
	\item If one eigenvalue is positive and the other is negative (\( \lambda_1 \lambda_2 < 0 \)), the function exhibits a \emph{saddle point}. The function curves upwards in the direction corresponding to the positive eigenvalue and downwards in the direction corresponding to the negative eigenvalue.
	\item If any eigenvalue is zero (\( \lambda_1 = 0 \) or \( \lambda_2 = 0 \)), the Second Derivative Test is \emph{inconclusive}. In this case, higher-order terms or a more detailed analysis is required to classify the critical point.
\end{enumerate}

\subsection{Intuition from Linear Algebra}
Eigenvalues of the Hessian matrix tell us about the principal directions in which the function is changing at a critical point. Consider the Hessian as a local quadratic approximation of the function at a point, where the eigenvalues reflect how steep the function’s graph is along particular directions. Specifically:
\begin{itemize}
	\item Positive eigenvalues correspond to directions where the function increases, resembling an upward-parabola shape.
	\item Negative eigenvalues correspond to directions where the function decreases, resembling a downward-parabola.
	\item Mixed signs for the eigenvalues indicate a saddle-like behavior, where some directions exhibit maxima and others minima.
\end{itemize}

Thus, checking the signs of the eigenvalues is an alternative way to interpret the Second Derivative Test in terms of curvature.

\ex{Example}{
	Let’s revisit the example \( f(x, y) = x^3 - 3x + y^3 - 3y \) and calculate the Hessian matrix at one of the critical points. For the critical point \( (1, 1) \), we have:
	\[
		H(1, 1) = \begin{bmatrix}
			6 & 0 \\
			0 & 6
		\end{bmatrix}
	\]
	The eigenvalues of this Hessian are \( \lambda_1 = 6 \) and \( \lambda_2 = 6 \), both positive, which confirms that \( (1, 1) \) is a local minimum as expected from the Second Derivative Test.

	For the critical point \( (1, -1) \), the Hessian is:
	\[
		H(1, -1) = \begin{bmatrix}
			6 & 0  \\
			0 & -6
		\end{bmatrix}
	\]
	The eigenvalues are \( \lambda_1 = 6 \) and \( \lambda_2 = -6 \), confirming that \( (1, -1) \) is a saddle point, as one direction curves upward and the other downward.
}

\section{Absolute Extrema}

For a function \( f \) defined on a region \( R \) in \( \mathbb{R}^2 \), a point \( (a, b) \) in \( R \) is an \emph{absolute maximum} of \( f \) if \( f(a, b) \geq f(x, y) \) for any \( (x, y) \) in \( R \). Similarly, \( (a, b) \) is an \emph{absolute minimum} if \( f(a, b) \leq f(x, y) \) for any \( (x, y) \) in \( R \).

\thm{Extreme Value Theorem}{
	If \( R \) is closed and bounded, and if \( f \) is continuous on \( R \), then the absolute extrema of \( f \) on \( R \) can be found by examining:
	\begin{enumerate}
		\item Critical points of \( f \) (for local extrema within \( R \)),
		\item Boundary values of \( f \) on \( R \).
	\end{enumerate}
}

\ex{Example Extreme Value Theorem}{
	Consider the function \( V(\ell, w) = \ell w (96 - \ell - w) \), where \( R = \{ (\ell, w) \mid \ell \geq 0, w \geq 0, \ell + w \leq 96 \} \).

	\begin{enumerate}
		\item Since \( R \) is closed, we can apply the Extreme Value Theorem:
		      \begin{enumerate}
			      \item Find local maxima by setting \( \nabla V(\ell, w) = 0 \).
			      \item Evaluate \( V \) on the boundary of \( R \).
		      \end{enumerate}
	\end{enumerate}

	To find critical points:
	\[
		V(\ell, w) = \ell w (96 - \ell - w)
	\]
	The partial derivatives are:
	\[
		\frac{\partial V}{\partial \ell} = w(96 - 2\ell - w), \quad \frac{\partial V}{\partial w} = \ell(96 - \ell - 2w)
	\]
	Setting these to zero, we get:
	\[
		\begin{cases}
			w(96 - 2\ell - w) = 0 \\
			\ell(96 - \ell - 2w) = 0
		\end{cases}
	\]
	This yields critical points at \( (\ell, w) = (32, 32) \).\\

	On the boundary of \( R \):
	\begin{enumerate}
		\item \( \ell = 0 \): Then \( V = 0 \) for any \( w \).
		\item \( w = 0 \): Then \( V = 0 \) for any \( \ell \).
		\item \( \ell + w = 96 \): Substitute \( w = 96 - \ell \) into \( V(\ell, w) = \ell (96 - \ell) (96 - \ell - (96 - \ell)) = \ell(96 - \ell)^2 \).
	\end{enumerate}

	\begin{center}
		\begin{tikzpicture}[scale=0.05]
			% Draw the axes
			\draw[->] (0, 0) -- (100, 0) node[right] {\( \ell \)};
			\draw[->] (0, 0) -- (0, 100) node[above] {\( w \)};

			% Draw the boundary line l + w = 96
			\draw[thick] (0,96) -- (96,0);
			\node[above right] at (50, 50) {\( \ell + w = 96 \)};

			% Label points
			\filldraw[black] (96,0) circle (1.5pt) node[below] {\( (96, 0) \)};
			\filldraw[black] (0,96) circle (1.5pt) node[left] {\( (0, 96) \)};
			\filldraw[black] (0,0) circle (1.5pt) node[below left] {\( (0, 0) \)};

			% Shade the feasible region
			\fill[gray, opacity=0.2] (0, 0) -- (0, 96) -- (96, 0) -- cycle;

			% Label the region
			\node at (40, 40) {\( R \)};
		\end{tikzpicture}
	\end{center}

	Solving this, we find that \( V(32, 32) = 32 \cdot 32 \cdot 32 = 32768 \), which is the maximum value on \( R \).\\

	To confirm the local maximum at \( (32, 32) \), we compute the Hessian:
	\[
		H(\ell, w) = \begin{bmatrix} -2w & 96 - \ell - w \\ 96 - \ell - w & -2\ell \end{bmatrix}
	\]
	At \( (32, 32) \), the Hessian determinant is:
	\[
		\det(H) = (-2 \times 32)^2 - (96 - 32 - 32)^2 = (64 \times 64) - (32 \times 32) = 32768 > 0
	\]
	Thus, \( V(\ell, w) \) has a local maximum at \( (32, 32) \).
}
\ex{Another Example}{
	Consider \( f(x, y) = 4 - x^2 - y^2 \) on \( R = \{ (x, y) \mid -1 \leq x \leq 1, x^2 + y^2 < 1 \} \). Here, \( R \) is an open region without boundaries.\\

	The maximum of \( f(x, y) \) occurs at \( (0, 0) \), where \( f(0, 0) = 4 \). There is no absolute minimum because for points approaching the boundary (e.g., \( x \approx 0.99 \)), \( f(x, y) \) approaches \( -\infty \).

	Thus, in \( R \), there is no absolute minimum value for \( f \), illustrating the importance of the region's closedness and boundedness for the Extreme Value Theorem to apply.
}

\section{Lagrange Multiplier Method}

\subsection{General Procedure}

To maximize or minimize \( f(x, y) \) subject to a constraint \( g(x, y) = 0 \), follow these steps:

\begin{enumerate}
	\item \textbf{Identify Critical Points:} A point \( (x', y') \) is a critical point if:
	      \begin{itemize}
		      \item There exists \( \lambda \in \mathbb{R} \) such that \( \nabla f(x', y') = \lambda \nabla g(x', y') \) (using the \emph{method of Lagrange multipliers}).
		      \item \( g(x', y') = 0 \).
	      \end{itemize}

	\item \textbf{Evaluate Cases for Critical Points:}
	      \begin{enumerate}
		      \item \textbf{Case 1:} The constraint region \( R \) is bounded and has no endpoints.
		            \begin{itemize}
			            \item In this case, assuming continuity of \( f \), any local extrema within \( R \) are also absolute extrema.
			            \item Select critical points \( (x', y') \) and evaluate \( f \) at these points.
		            \end{itemize}

		      \item \textbf{Case 2:} The constraint region \( R \) is bounded and has endpoints.
		            \begin{itemize}
			            \item Example: \( x^2 - 4y^2 \leq 0 \) with \( -1 \leq x \leq 1 \).
			            \item Absolute extrema may occur at local extrema or endpoints.
			            \item Check critical points and also evaluate \( f \) at the boundary endpoints.
		            \end{itemize}

		      \item \textbf{Case 3:} The constraint region \( R \) is unbounded or does not include all endpoints.
		            \begin{itemize}
			            \item Example: \( x^2 - 4y^2 \) unbounded or \( x^2 + y^2 - 4 = 0 \) with \( -2 \leq x \leq 2 \).
			            \item It may be possible that absolute extrema do not exist.
			            \item Find any critical points and evaluate \( f(x) \) as \( x \rightarrow \pm \infty \) if applicable.
		            \end{itemize}
	      \end{enumerate}
\end{enumerate}

\ex{Lagrange Multiplier Method}{
	We aim to find the absolute extrema of the function \( f(x, y) = x - 2y \) subject to the constraint \( g(x, y) = x^2 + y^2 = 4 \).\\
	To find the extrema, we use the method of Lagrange multipliers, where we seek points where \( \nabla f = \lambda \nabla g \).

	The gradients of \( f \) and \( g \) are:
	\[
		\nabla f(x, y) = \begin{bmatrix} 1 \\ -2 \end{bmatrix}, \quad \nabla g(x, y) = \begin{bmatrix} 2x \\ 2y \end{bmatrix}
	\]
	Setting \( \nabla f = \lambda \nabla g \), we have:
	\[
		\begin{cases}
			1 = \lambda \cdot 2x \\
			-2 = \lambda \cdot 2y
		\end{cases}
	\]
	This simplifies to:
	\[
		\lambda = \frac{1}{2x} = \frac{-1}{y} \Rightarrow y = -2x
	\]

	Substitute \( y = -2x \) into the constraint \( g(x, y) = x^2 + y^2 = 4 \):
	\[
		x^2 + (-2x)^2 = 4 \Rightarrow x^2 + 4x^2 = 4 \Rightarrow 5x^2 = 4 \Rightarrow x = \pm \frac{2}{\sqrt{5}}
	\]
	Then, \( y = -2x \) gives \( y = \pm \frac{4}{\sqrt{5}} \). So the points are:
	\[
		\left( \frac{2}{\sqrt{5}}, -\frac{4}{\sqrt{5}} \right) \quad \text{and} \quad \left( -\frac{2}{\sqrt{5}}, \frac{4}{\sqrt{5}} \right)
	\]

	Calculate \( f(x, y) \) at the points:
	\[
		f\left( \frac{2}{\sqrt{5}}, -\frac{4}{\sqrt{5}} \right) = \frac{2}{\sqrt{5}} + \frac{8}{\sqrt{5}} = \frac{10}{\sqrt{5}} = 2\sqrt{5}
	\]
	\[
		f\left( -\frac{2}{\sqrt{5}}, \frac{4}{\sqrt{5}} \right) = -\frac{2}{\sqrt{5}} - \frac{8}{\sqrt{5}} = -\frac{10}{\sqrt{5}} = -2\sqrt{5}
	\]
	Thus, the \textbf{absolute maximum} is \( 2\sqrt{5} \) and the \textbf{absolute minimum} is \( -2\sqrt{5} \).\\

	Below is a diagram showing the constraint \( x^2 + y^2 = 4 \) as a circle and the level curves of \( f(x, y) = x - 2y \), specifically showing the two tangent level curves at \( z = \pm \frac{10}{\sqrt{5}} \) that represent the maximum and minimum values.

	\begin{center}
		\begin{tikzpicture}[scale=1.5]
			% Draw the constraint circle x^2 + y^2 = 4
			\draw[thick] (0,0) circle (2);
			\node at (2.2, 0) {\( x^2 + y^2 = 4 \)};

			% Draw the level curves of f(x, y) = x - 2y
			\draw[dashed, domain=-2:2] plot({\x}, {(\x - 10/sqrt(5))/2});
			\node[above right] at (1.788854382, -2) {\( x - 2y = \frac{10}{\sqrt{5}} \)};

			\draw[dashed, domain=-2:2] plot({\x}, {(\x + 10/sqrt(5))/2});
			\node[below right] at (1.788854382, 2) {\( x - 2y = -\frac{10}{\sqrt{5}} \)};

			% Draw the points of maximum and minimum
			\filldraw[black] (0.894427191, -1.788854382) circle (0.05);
			\node[below right] at (0.894427191, -1.788854382) {\( \left( \frac{2}{\sqrt{5}}, -\frac{4}{\sqrt{5}} \right) \)};

			\filldraw[black] (-0.894427191, 1.788854382) circle (0.05);
			\node[above left] at (-0.894427191, 1.788854382) {\( \left( -\frac{2}{\sqrt{5}}, \frac{4}{\sqrt{5}} \right) \)};
		\end{tikzpicture}
	\end{center}
}

\ex{Example: Finding Extrema of \( f(x, y) = e^{x+y} \) with Constraint}{
	Consider maximizing or minimizing \( f(x, y) = e^{x+y} \) subject to the constraint \( g(x, y) = x^2 + xy + y^2 - 9 = 0 \).

	\begin{enumerate}
		\item Using the method of Lagrange multipliers, we set up the system:
		      \[
			      \nabla f(x, y) = \lambda \nabla g(x, y)
		      \]
		      which gives:
		      \[
			      \begin{cases}
				      e^{x+y} = \lambda (2x + y) \\
				      e^{x+y} = \lambda (x + 2y)
			      \end{cases}
		      \]

		\item Dividing the equations, we get:
		      \[
			      \frac{2x + y}{x + 2y} = 1 \Rightarrow x = y
		      \]
		\item Substitute \( x = y \) into the constraint \( x^2 + xy + y^2 = 9 \):
		      \[
			      x^2 + x^2 + x^2 = 9 \Rightarrow 3x^2 = 9 \Rightarrow x = \pm \sqrt{3}, \quad y = \pm \sqrt{3}
		      \]
		\item The critical points are \( ( \sqrt{3}, \sqrt{3} ) \) and \( ( -\sqrt{3}, -\sqrt{3} ) \).

		\item Evaluating \( f(x, y) \) at these points:
		      \[
			      f(\sqrt{3}, \sqrt{3}) = e^{2\sqrt{3}}, \quad f(-\sqrt{3}, -\sqrt{3}) = e^{-2\sqrt{3}}
		      \]

		\item Thus, the maximum value is \( e^{2\sqrt{3}} \) and the minimum value is \( e^{-2\sqrt{3}} \).
	\end{enumerate}
}

\ex{Example: Finding Extrema of \( f(x, y) = x - y \) with Constraint}{
	Consider the function \( f(x, y) = x - y \) with the constraint \( g(x, y) = x^2 + y^2 - 3 x y - 20 = 0 \).

	\begin{enumerate}
		\item The gradients are:
		      \[
			      \nabla f(x, y) = \begin{bmatrix} 1 \\ -1 \end{bmatrix}, \quad \nabla g(x, y) = \begin{bmatrix} 2x - 3y \\ 2y - 3x \end{bmatrix}
		      \]

		\item Set \( \nabla f = \lambda \nabla g \):
		      \[
			      \begin{cases}
				      1 = \lambda (2x - 3y) \\
				      -1 = \lambda (2y - 3x)
			      \end{cases}
		      \]

		\item Solving this system, we find critical points at \( (2, -2) \) and \( (-2, 2) \).

		\item Evaluating \( f(x, y) \) at these points:
		      \[
			      f(2, 1) = 1, \quad f(-2, -1) = -1
		      \]

		\item Therefore, the maximum value is \( 1 \) and the minimum value is \( -1 \).
	\end{enumerate}

	By observing the level curves diagram, we can see that the given points do not maximise/minimise the function, as any other line where \( x-y < \pm 4 \) would further increase/decrease the function.

}

\begin{center}
	\begin{tikzpicture}
		\begin{axis}[
				axis lines=middle,
				grid=both,
				xmin=-50, xmax=50,
				ymin=-50, ymax=70,
				xlabel={$x$},
				ylabel={$y$},
				every axis x label/.style={at={(current axis.right of origin)}, anchor=west},
				every axis y label/.style={at={(current axis.above origin)}, anchor=south},
				width=10cm, height=10cm,
				samples=200,
				domain=-50:50
			]

			% Plot of x - y = -4
			\addplot[domain=-50:50, green, thick] {x + 4};
			\node[anchor=south west] at (axis cs:-40,-44) {$x - y = -4$};

			% Plot of x - y = 4
			\addplot[domain=-50:50, red, thick] {x - 4};
			\node[anchor=south west] at (axis cs:40,36) {$x - y = 4$};

			% Approximate implicit plot for x^2 + y^2 - 3xy - 20 = 0 using parametric plot
			\addplot[black, thick, samples=200, domain=-50:50]
			({x}, {(3*x + sqrt(3*x*x + 80))/2});
			\addplot[black, thick, samples=200, domain=-50:50]
			({x}, {(3*x - sqrt(3*x*x + 80))/2});
			\node[anchor=north west] at (axis cs:30,55) {$x^2 + y^2 - 3xy - 20 = 0$};

		\end{axis}
	\end{tikzpicture}
\end{center}


\section{Multiple Integration}

\nt{
	The integral
	\[
		\int_a^b f(x) \, dx = A
	\]
	represents the area under the curve \( f(x) \) from \( a \) to \( b \), where \( A \) can also be approximated as
	\[
		A \approx \sum_{i=1}^N f(x_i) \Delta x.
	\]
}

\nt{
To find the volume under a surface \( z = f(x, y) \) over a region \( R = [a, b] \times [c, d] \), we use the double integral
\[
	\iint_R f(x, y) \, dA.
\]
This can be approximated by summing over small subregions within \( R \):
\[
	\iint_R f(x, y) \, dA = \lim_{\Delta \to 0} \sum_{i=1}^m \sum_{j=1}^n f(x_i, y_j) \Delta x \, \Delta y.
\]
}

\thm{Continuity and Limits of Double Integrals}{
	If the limit
	\[
		\lim_{(x, y) \to (a, b)} f(x, y)
	\]
	exists for all points \( (a, b) \) in \( R \), then \( f(x, y) \) is continuous over \( R \), and the order of integration can be changed under Fubini's theorem.
}

\nt{
	Consider dividing \( R \) into \( n \) subregions, each with area \( \Delta A_{ij} \) and height \( f(x_i, y_j) \). Then, the volume \( V \) is approximated as
	\[
		V \approx \sum_{i=1}^m \sum_{j=1}^n f(x_i, y_j) \Delta x \, \Delta y,
	\]
	where \( n \) is the number of boxes in the \( x \)-direction and \( m \) is the number in the \( y \)-direction. Taking the limit as \( \Delta x, \Delta y \to 0 \) gives
	\[
		V = \iint_R f(x, y) \, dA.
	\]
}

\dfn{Double Integral Definition}{
The double integral of \( f(x, y) \) over \( R = [a, b] \times [c, d] \) is defined by
\[
	\iint_R f(x, y) \, dA = \lim_{n \to \infty} \sum_{i=1}^n \sum_{j=1}^n f(x_i, y_j) \Delta A_{ij}.
\]
}

\thm{Fubini's Theorem}{
	The order of integration does not affect the result of the double integral. Thus,
	\[
		\iint_R f(x, y) \, dA = \int_a^b \left( \int_c^d f(x, y) \, dy \right) dx = \int_c^d \left( \int_a^b f(x, y) \, dx \right) dy.
	\]
}

\ex{Example of Double Integral Calculation}{
Calculate the volume under \( f(x, y) = 4 + x + y^2 \) over the region \( R = [-1, 1] \times [0, 2] \):
\[
	\iint_R f(x, y) \, dA = \int_{-1}^1 \int_0^2 (4 + x + y^2) \, dy \, dx.
\]
Evaluating the inner integral with respect to \( y \),
\[
	\int_0^2 (4 + x + y^2) \, dy = 4y + xy + \frac{y^3}{3} \Big|_0^2 = 8 + 2x + \frac{8}{3}.
\]
Then, integrating with respect to \( x \),
\[
	\int_{-1}^1 \left( 8 + 2x + \frac{8}{3} \right) dx = \left( 8 + \frac{8}{3} \right) \cdot 2 = \frac{32}{3}.
\]
Thus, the volume \( V = \frac{32}{3} \).
}

\ex{Example: Integration Over a Rectangular Domain}{
	Evaluate
	\[
		\int_0^2 \int_0^1 \frac{x y}{1 + x^2} \, dx \, dy.
	\]

	Using substitution \( u = x^2 \) with \( du = 2x \, dx \), we find
	\[
		\int_0^2 \int_0^1 \frac{x y}{1 + x^2} \, dx \, dy = \int_0^2 y \left( \int_0^1 \frac{x}{1 + x^2} \, dx \right) dy = \int_0^2 y \left[ \frac{1}{2} \ln(1 + x^2) \right]_0^1 \, dy.
	\]
	Simplifying, we get
	\[
		V = \int_0^2 y \cdot \frac{\ln(2)}{2} \, dy = \frac{\ln(2)}{2} \int_0^2 y \, dy = \frac{\ln(2)}{2} \cdot \frac{y^2}{2} \Big|_0^2 = \ln(2).
	\]
}

\subsection{Non-Rectangular Domains}

\nt{
	Consider \( R = \{ (x, y) : a \leq x \leq b, g_1(x) \leq y \leq g_2(x) \} \), where the boundaries are given by functions \( y = g_1(x) \) and \( y = g_2(x) \).
}

\ex{Example: Non-Rectangular Domain Integration}{
	Suppose \( R = \{ (x, y) : -1 \leq x \leq 1, x^2 \leq y \leq 2 - x^2 \} \).
	We wish to evaluate
	\[
		\int_R (x+y) \, dA.
	\]
	We split \( R \) into two regions, \( R_1 \) and \( R_2 \), with bounds given by
	\[
		R_1 = \{ (x, y) : -1 \leq x \leq 1, x^2 \leq y \leq 2 - x^2 \}.
	\]
	Evaluating each integral, we obtain
	\[
		V = \int_{-1}^1 \left( \int_{x^2}^{2 - x^2} (x + y) \, dy \right) dx.
	\]

	On solving, we get
	\[
		V = \int_{-1}^1 \left( \int_{x^2}^{2 - x^2} (x + y) \, dy \right) dx = \ldots = \frac{8}{35}.
	\]
}

\begin{center}
	\begin{tikzpicture}
		% Define axes
		\draw[->] (-2,0) -- (2,0) node[right] {\( x \)};
		\draw[->] (0,-0.5) -- (0,3) node[above] {\( y \)};

		% Draw the curves
		\draw[thick, domain=-1:1, samples=100] plot (\x, {\x*\x}) node[right] {\( y = x^2 \)};
		\draw[thick, domain=-1:1, samples=100] plot (\x, {2 - \x*\x}) node[above] {\( y = 2 - x^2 \)};

		% Shade the region between curves
		\fill[gray, opacity=0.2] (-1,1) parabola bend (0,0) (1,1) -- (1,2) parabola bend (0,2) (-1,2) -- cycle;
	\end{tikzpicture}
\end{center}

\nt{
	When changing the order of integration, try dividing the region into smaller regions to make integration simpler.
}

\subsection{Volume Between Surfaces}

\nt{
	To find the volume of a sphere using double integrals, consider the surface
	\[
		x^2 + y^2 + z^2 = 1.
	\]
	Then \( z = \pm \sqrt{1 - x^2 - y^2} \), and we can set up the integral as
	\[
		V = 2 \iint_R \sqrt{1 - x^2 - y^2} \, dA,
	\]
	where \( R = \{ (x, y) : -1 \leq x \leq 1, -\sqrt{1 - x^2} \leq y \leq \sqrt{1 - x^2} \} \).
}

\begin{center}
	\begin{tikzpicture}
		% Define axes
		\draw[->] (-2,0) -- (2,0) node[right] {\( x \)};
		\draw[->] (0,-2) -- (0,2) node[above] {\( y \)};

		% Draw the circle for the sphere projection
		\draw[thick] (0,0) circle (1.5);
		\node[below left] at (1.5,0) {\( x^2 + y^2 = 1 \)};

		% Label the region
		\fill[gray, opacity=0.2] (0,0) circle (1.5);
		\node at (0,0) {\( R \)};
	\end{tikzpicture}
\end{center}

\ex{Example: Volume Between Surfaces}{
	Calculate the volume between the surfaces \( z = \sqrt{1 - x^2 - y^2} \) and \( z = -\sqrt{1 - x^2 - y^2} \):
	\[
		V = \iint_R \left( \sqrt{1 - x^2 - y^2} - (-\sqrt{1 - x^2 - y^2}) \right) \, dA = 2 \iint_R \sqrt{1 - x^2 - y^2} \, dA.
	\]
	Setting up the limits as before, we integrate over \( R \) to find the volume of the sphere.
}

\section{Applications of Double Integrals}

\subsection{Area of a Surface}

\dfn{Area of a Surface with Double integrals}{

	When calculating the area of a surface where the height of the surface in 3D space is constantly 1, the area of the surface is numerically equal to the volume under the surface. Thus, by setting the height \( f(x, y) = 1 \) over a given region \( R \), the area of \( R \) can be computed using a double integral, which effectively measures the "volume" under the constant surface.

	\[
		\text{Area of } R = \iint_R f(x, y) \, dA = \iint_R 1 \, dA
	\]
}

\ex{Example}{ Calculate the area of the region \( R = \{ (x, y) : x^2 + y^2 \leq 1 \} \), which is the unit disk in the \( xy \)-plane.

	\[
		\iint_R dA = \int_{-1}^1 \int_{-\sqrt{1 - x^2}}^{\sqrt{1 - x^2}} dy \, dx
	\]

	Calculating,
	\[
		= 2 \int_{-1}^1 \sqrt{1 - x^2} \, dx
	\]

	Using substitution, let \( x = \cos \theta \), we get:
	\[
		= 2 \int_0^\pi \sin^2 \theta \, d\theta = \pi
	\]

	Thus, the area of \( R \) is \( \pi \).
}


\begin{center}
	\begin{tikzpicture}
		\begin{axis}[
				width=12cm,
				height=12cm,
				view={135}{30},
				xlabel=$x$,
				ylabel=$y$,
				zlabel=$z$,
				zmin=0,
				xmin=-1.2, xmax=1.2,
				ymin=-1.2, ymax=1.2,
				grid=major,
				colormap/cool,
			]

			% Main cylinder surface
			\addplot3[
				surf,
				samples=50,
				domain=-1:1,
				y domain=-1:1,
				restrict expr to domain={x^2+y^2}{0:1},
				opacity=0.8,
			]
			{1};  % Height is constant at z=1

			% Bottom circle at z=0
			\addplot3[
				domain=0:360,
				samples=100,
				thick,
				color=black,
			]
			({cos(x)},{sin(x)},{0});

			% Top circle at z=1
			\addplot3[
				domain=0:360,
				samples=100,
				thick,
				color=black,
			]
			({cos(x)},{sin(x)},{1});

			% Cross-section curves
			\addplot3[
				color=red,
				thick,
				domain=-1:1,
				samples=50,
			]
			({x},{0},{1});

			\addplot3[
				color=blue,
				thick,
				domain=-1:1,
				samples=50,
			]
			({0},{x},{1});

			% Height indicator lines
			\foreach \x in {0.2,0.4,0.6,0.8} {
					\addplot3[
						dashed,
						color=gray,
					] coordinates {
							(\x,0,0)
							(\x,0,1)
						};
				}

			% Vertical lines at corners for better visibility
			\addplot3[thick, color=black] coordinates {(1,0,0) (1,0,1)};
			\addplot3[thick, color=black] coordinates {(-1,0,0) (-1,0,1)};
			\addplot3[thick, color=black] coordinates {(0,1,0) (0,1,1)};
			\addplot3[thick, color=black] coordinates {(0,-1,0) (0,-1,1)};

			% Add legend
			\addlegendentry{$z=1$ (Cylinder surface)}
			\addlegendentry{Region $R$}
			\addlegendentry{$x$-cross section}
			\addlegendentry{$y$-cross section}

		\end{axis}
	\end{tikzpicture}
\end{center}


\subsection{Average Value of a Function}

\dfn{Average Value of a Function}{
	The average value of a function \( f(x, y) \) over a region \( R \) is defined as the total value of \( f(x, y) \) over \( R \) divided by the area of \( R \). This can be expressed using double integrals as follows:

	\[
		\overline{f} = \frac{1}{\text{Area of } R} \iint_R f(x, y) \, dA = \frac{1}{\iint_R dA} \iint_R f(x, y) \, dA
	\]
}
\ex{Example}{
	Find the average value of \( f(x, y) = \sqrt{1 - x^2 - y^2} \) over the region \( R = \{ (x, y) : x^2 + y^2 \leq 1 \} \).

	First, calculate the area of \( R \):
	\[
		\text{Area of } R = \iint_R dA = \pi.
	\]

	Now, calculate the integral of \( f(x, y) \) over \( R \):
	\[
		\iint_R \sqrt{1 - x^2 - y^2} \, dA.
	\]

	Using polar coordinates, where \( x = r \cos \theta \) and \( y = r \sin \theta \), we have \( dA = r \, dr \, d\theta \):
	\[
		= \int_0^{2\pi} \int_0^1 \sqrt{1 - r^2} \cdot r \, dr \, d\theta.
	\]

	Breaking down the integral,
	\[
		= 2\pi \int_0^1 r \sqrt{1 - r^2} \, dr.
	\]

	Using the substitution \( u = 1 - r^2 \) (with \( du = -2r \, dr \)),
	\[
		= 2\pi \int_1^0 \sqrt{u} \cdot \left(-\frac{du}{2}\right) = \pi \int_0^1 \sqrt{u} \, du.
	\]

	Evaluating the integral,
	\[
		= \pi \int_0^1 u^{1/2} \, du = \pi \left[ \frac{u^{3/2}}{3/2} \right]_0^1 = \pi \cdot \frac{2}{3} = \frac{2\pi}{3}.
	\]

	Therefore, the average value of \( f(x, y) \) over \( R \) is
	\[
		\overline{f} = \frac{\frac{2\pi}{3}}{\pi} = \frac{2}{3}.
	\]
}


\begin{center}
	\begin{tikzpicture}
		\begin{axis}[
				width=12cm,
				height=12cm,
				view={135}{30},
				xlabel=$x$,
				ylabel=$y$,
				zlabel=$z$,
				zmin=0,
				xmin=-1.2, xmax=1.2,
				ymin=-1.2, ymax=1.2,
				grid=major,
				colormap/cool,
			]

			% Main surface plot
			\addplot3[
				surf,
				samples=50,
				domain=-1:1,
				y domain=-1:1,
				restrict expr to domain={x^2+y^2}{0:1},
				opacity=0.8,
			]
			{sqrt(1-x^2-y^2)};

			% Boundary circle at z=0
			\addplot3[
				domain=0:360,
				samples=100,
				thick,
				color=black,
			]
			({cos(x)},{sin(x)},{0});

			\addplot3[
				color=red,
				thick,
				domain=-1:1,
				samples=50,
			]
			({x},{0},{sqrt(max(0,1-x^2))});

			\addplot3[
				color=blue,
				thick,
				domain=-1:1,
				samples=50,
			]
			({0},{x},{sqrt(max(0,1-x^2))});

			% Height indicator lines
			\foreach \x in {0.2,0.4,0.6,0.8} {
					\addplot3[
						dashed,
						color=gray,
					] coordinates {
							(\x,0,0)
							(\x,0,{sqrt(1-\x^2)})
						};
				}

			% Add legend
			\addlegendentry{$f(x,y)=\sqrt{1-x^2-y^2}$}
			\addlegendentry{Region $R$}
			\addlegendentry{$x$-cross section}
			\addlegendentry{$y$-cross section}

		\end{axis}
	\end{tikzpicture}
\end{center}

\section{Derivation of Triple Integrals through Riemann Sums}

To derive the concept of a triple integral, we start by considering a bounded, three-dimensional region \( D \subset \mathbb{R}^3 \) over which we wish to integrate a continuous function \( f(x, y, z) \). The idea is to approximate the "volume" under the surface defined by \( f(x, y, z) \) over \( D \) by partitioning \( D \) into smaller subregions, summing up values of \( f \) at chosen points within these subregions, and then taking the limit as the partitions become finer.

\subsection{Partitioning the Region}

1. Let \( D \) be divided into \( n \times m \times l \) subregions, each of volume \( \Delta V_{ijk} = \Delta x_i \Delta y_j \Delta z_k \), where:
\[
	\Delta x_i = x_{i+1} - x_i, \quad \Delta y_j = y_{j+1} - y_j, \quad \Delta z_k = z_{k+1} - z_k
\]

2. In each subregion, choose a point \( (x_i^*, y_j^*, z_k^*) \) where \( f \) will be evaluated. The function value at each of these points, \( f(x_i^*, y_j^*, z_k^*) \), approximates the "height" over the corresponding volume element.

\subsection{Forming the Riemann Sum}

With these chosen points and partition, the Riemann sum for \( f \) over the region \( D \) is given by:
\[
	\sum_{i=1}^n \sum_{j=1}^m \sum_{k=1}^l f(x_i^*, y_j^*, z_k^*) \Delta x_i \Delta y_j \Delta z_k.
\]

As the partitions become finer, i.e., \( \Delta x_i, \Delta y_j, \Delta z_k \to 0 \) for all \( i, j, k \), the sum approaches the exact "volume" under \( f \) over \( D \), which we denote as the triple integral:
\[
	\iiint_D f(x, y, z) \, dV = \lim_{n, m, l \to \infty} \sum_{i=1}^n \sum_{j=1}^m \sum_{k=1}^l f(x_i^*, y_j^*, z_k^*) \Delta x_i \Delta y_j \Delta z_k.
\]

Thus, the triple integral represents the limit of the Riemann sum as the volume elements \( \Delta V_{ijk} \) become infinitesimally small.

\section{Triple Integrals Intuitions and Applications}

\[
	\int f(x) \, dx \rightarrow \text{Area} \quad \int\int f(x,y) \, dA \rightarrow \text{Volume under } f(x,y)
\]
\[
	\iiint f(x,y,z) \, dV \rightarrow \text{Volume under solid } w = f(x,y,z)
\]

\subsection{Integrals Represent Products}
\[
	\text{Examples:}
\]
\[
	\text{Length } = F = P \cdot A \quad \Rightarrow \quad \iint_R P(x,y) \, dA
\]
\[
	\text{Mass } = \rho \cdot V \quad \Rightarrow \quad m = \iiint_D \rho(x,y,z) \, dV
\]

\ex{Mass of a Rock}{
	Suppose a rock with uniform density $\rho$ and volume $V$. Then
	\[
		m = \rho V
	\]
	If $\rho$ is non-uniform, how do you find the mass?

	Suppose $\rho(x,y,z)$ is given by $p(x,y,z)$ over the support of $D$, then
	\[
		m = \iiint_D p(x,y,z) \, dV
	\]
	where \( D \subseteq \mathbb{R}^3 \) is the region occupied by the rock.
}
\ex{Volume}{
	Note $A \subseteq \mathbb{R}^2$, then
	\[
		\text{Volume of } D \text{ in } \mathbb{R}^3
	\]
	is
	\[
		V = \iiint_D \, dV
	\]
}

\ex{Example 3: Probability Densities}{
	Let $x, y, z$ be variables representing random quantities. You can find $f(x,y,z)$ called a Probability Density Function (P.D.F.) where
	\[
		P((x,y,z) \in D) = \iiint_D f(x,y,z) \, dV
	\]
}
\dfn{Bounds of Integration for triple integrals}{
	Suppose \( D = \{ (x,y,z) : a \leq x \leq b, \, g(x) \leq y \leq h(x), \, G(x,y) \leq z \leq H(x,y) \} \),
	where the bounds of \( y \) depend on \( x \) and the bounds of \( z \) depend on \( x \) and \( y \).

	Then
	\[
		V = \iiint_D f(x,y,z) \, dV = \int_a^b \int_{g(x)}^{h(x)} \int_{G(x,y)}^{H(x,y)} f(x,y,z) \, dz \, dy \, dx
	\]
}

\ex{PDF in 3 Continous Random Variables}{
Three customers wait \( x, y, z \) minutes.

\[
	f(x,y,z) = \begin{cases}
		10^3 e^{-(x+y+z)} \cdot \frac{1}{10} & \text{if } x, y, z \geq 0 \\
		0                                    & \text{otherwise}
	\end{cases}
\]

\paragraph{(1) Probability that \( (x,y,z) \in D \):}
\[
	P((x,y,z) \in D) = \iiint_D 10^3 e^{-(x+y+z)} \cdot \frac{1}{10} \, dV
\]

\paragraph{(2) Probability that customers wait at most 5 minutes:}
\[
	D = [0,5] \times [0,5] \times [0,5]
\]
\[
	P = \iiint_D 10^3 e^{-(x+y+z)} \cdot \frac{1}{10} \, dx \, dy \, dz = 0.061 = 6.1\%
\]

\paragraph{(3) Probability that \( 0 \leq x \leq y \leq z \leq 20 \):}
Define
\[
	P = \{ (x,y,z) : 0 \leq x \leq y \leq z \leq 20 \}
\]
1. Find the domain of \( x \) in \( D \):
\[
	0 \leq x \leq 20
\]
2. Fix some \( x = x_0 \), define \( R = \{ (y,z) : 0 \leq x_0 \leq y \leq 20 \} \).
3. Marginalize \( y \) in \( R \):
\[
	x \leq y \leq 20
\]
4. Marginalize \( z \) in \( R \):
\[
	y \leq z \leq 20
\]

Thus,
\[
	D = [0,20] \times [x,20] \times [y,20]
\]
\[
	P = \int_0^{20} \int_x^{20} \int_y^{20} 10^3 e^{-(x+y+z)} \cdot \frac{1}{10} \, dz \, dy \, dx
\]
}

\thm{Fubini’s Theorem Extended to Triple Integrals}{
Fubini’s Theorem allows us to evaluate triple integrals as iterated integrals by integrating one variable at a time. If \( f(x,y,z) \) is continuous on a rectangular region \( D = [a,b] \times [c,d] \times [e,f] \), then
\[
	\iiint_D f(x,y,z) \, dV = \int_a^b \int_c^d \int_e^f f(x,y,z) \, dz \, dy \, dx.
\]

This can also be rearranged in different orders of integration:
\[
	\iiint_D f(x,y,z) \, dV = \int_c^d \int_a^b \int_e^f f(x,y,z) \, dx \, dz \, dy,
\]
and similarly for other orders, depending on the bounds and convenience for computation.
}


\ex{Example of Setting up the Integral with Bounds}{
	Find the integral \( \iiint_D x y z \, dV \) where \( D = \{(x, y, z) \, | \, x + y + z \leq 1, \, x, y, z \geq 0\} \).

	To determine the bounds for integration, we analyze the region \( D \) defined by \( x + y + z \leq 1 \) with \( x, y, z \geq 0 \).

	\begin{enumerate}
		\item First, we set up the bounds for \( x \):
		      \[
			      0 \leq x \leq 1
		      \]
		      since \( x \) is bounded below by \( 0 \) and, based on the constraint \( x + y + z \leq 1 \), cannot exceed \( 1 \).

		\item Given a fixed \( x = x_0 \), we find the bounds for \( y \):
		      \[
			      0 \leq y \leq 1 - x_0
		      \]
		      since for any fixed \( x \), \( y \) is bounded below by \( 0 \) and must satisfy \( y + z \leq 1 - x_0 \).

		\item For a fixed \( x = x_0 \) and \( y = y_0 \), we find the bounds for \( z \):
		      \[
			      0 \leq z \leq 1 - x_0 - y_0
		      \]
		      since \( z \) is bounded below by \( 0 \) and must satisfy the remaining part of the inequality, \( z \leq 1 - x_0 - y_0 \).
	\end{enumerate}

	With these bounds, we can now write the integral as:
	\[
		\iiint_D x y z \, dV = \int_0^1 \int_0^{1 - x} \int_0^{1 - x - y} x y z \, dz \, dy \, dx
	\]
}


\ex{Volume of a Solid Bounded by Planes}{
	Find the volume \( V \) of the solid bounded by \( x = 0 \), \( y = 2 \), \( z = 0 \), and \( 2 - x - 4y - z = 0 \).

	Define the region \( D = \{(x, y, z) \, | \, x \geq 0, y \leq 2, z \geq 0, z \leq 2 - x - 4y\} \).

	The volume \( V \) is given by
	\[
		V = \iiint_D 1 \, dV
	\]

	\textbf{Step-by-Step Bounds Determination}:

	\begin{enumerate}
		\item Start by determining the bounds for \( z \):
		      \begin{itemize}
			      \item The minimum value of \( z \) is \( 0 \) since \( z \geq 0 \).
			      \item The maximum value of \( z \) is determined by the plane \( z = 2 - x - 4y \), so \( 0 \leq z \leq 2 - x - 4y \).
		      \end{itemize}

		\item Next, determine the bounds for \( y \) given a fixed \( z \):
		      \begin{itemize}
			      \item The plane \( y = 2 \) limits \( y \) from above, so \( y \leq 2 \).
			      \item Rearranging the inequality \( 2 - x - 4y \geq 0 \) gives \( y \leq \frac{2 - x - z}{4} \).
			      \item Therefore, for a fixed \( z \), \( y \) ranges from \( 0 \) to \( \min \left(2, \frac{2 - x - z}{4} \right) \).
		      \end{itemize}

		\item Finally, determine the bounds for \( x \):
		      \begin{itemize}
			      \item Since \( x \geq 0 \), the minimum value of \( x \) is \( 0 \).
			      \item From the inequality \( z = 2 - x - 4y \geq 0 \), rearranging gives \( x \leq 2 - 4y - z \), so \( x \leq 1 \).
		      \end{itemize}
	\end{enumerate}

	Based on these bounds, the volume integral can be set up as:
	\[
		V = \int_0^1 \int_{0}^{2 - x} \int_0^{2 - x - 4y} 1 \, dz \, dy \, dx
	\]
}

\begin{figure}[h!]
	\centering
	\tdplotsetmaincoords{70}{110} % Set view angle
	\begin{tikzpicture}[tdplot_main_coords, scale=3]

		% Draw axes
		\draw[thick,->] (0,0,0) -- (2.5,0,0) node[anchor=north east]{$x$};
		\draw[thick,->] (0,0,0) -- (0,2.5,0) node[anchor=north west]{$y$};
		\draw[thick,->] (0,0,0) -- (0,0,2.5) node[anchor=south]{$z$};

		% Plot the plane 2 - x - y = z as a surface
		\filldraw[opacity=0.3, fill=blue] (0,2,0) -- (2,0,0) -- (0,0,2) -- cycle;
		\node at (0.7,0.7,0.8) [anchor=north] {$2 - x - y = z$};

		% Plot the parabolic surface y = z^2
		\foreach \z in {0.2,0.4,...,1.4}{
				\draw[opacity=0.4, red] plot[domain=0:\z*\z, samples=50] ({0}, {(\z*\z)}, {\z});
			}
		\node at (0,1,1.5) [anchor=west, red] {$y = z^2$};

		% Plot the boundary planes x=0 and z=0
		\filldraw[opacity=0.3, fill=green] (0,0,0) -- (0,2,0) -- (0,0,2) -- cycle;
		\filldraw[opacity=0.3, fill=orange] (0,0,0) -- (2,0,0) -- (0,2,0) -- cycle;

		% Highlight the intersection region
		\fill[opacity=0.5, yellow] (0,0,0) -- (0,1,1) -- (0,0.5,0.5) -- cycle;

		% Add labels for boundary planes
		\node at (0.1,2,0) [anchor=east, green] {$x = 0$};
		\node at (2,0.1,0) [anchor=north, orange] {$z = 0$};

	\end{tikzpicture}
	\caption{Volume bounded by $x=0$, $z=0$, $y=z^2$, and $2 - x - y = z$.}
\end{figure}


\ex{Problem with Multiple Surfaces}{
	The solid common to the cylinders bounded by \( z = \sin x \) and \( z = \sin y \) over the region
	\[
		R = \{ (x, y) : 0 \leq x \leq \pi, \; 0 \leq y \leq \pi \}.
	\]
	We define the domain \( D \) as
	\[
		D = \{ (x, y, z) : (x, y) \in R, \; 0 \leq z \leq \min(\sin x, \sin y) \}.
	\]

	To solve this problem, we will:

	\begin{enumerate}
		\item Consider one-fourth of the volume under the intersection of the two cylinders, taking advantage of symmetry.
		\item Identify the bounding conditions for \( z \) in each quadrant.
		\item Set up and compute the triple integral over \( D \) to find the volume.
	\end{enumerate}

	Given the symmetry, we restrict our analysis to the region
	\[
		0 \leq x \leq \frac{\pi}{2}, \quad 0 \leq y \leq \frac{\pi}{2}.
	\]
	In this quadrant, \( z \) is bounded by \( \min(\sin x, \sin y) \), which means \( z \leq \sin y \) in the region \( R_1 \), where \( \sin y \leq \sin x \).

	For region \( R_2 \) (where \( \sin x \leq \sin y \)), we have \( z \leq \sin x \). By observing symmetry, the volume in each quadrant contributes equally, so we can calculate the volume in this restricted region and multiply by 4.

	The bounds for \( x \) and \( y \) are:
	\[
		0 \leq y \leq \pi, \quad y \leq x \leq \pi - y.
	\]
	Thus, we set up the volume integral as follows:
	\[
		V = 4 \int_0^{\pi/2} \int_0^{\sin y} \int_y^{\pi - y} \, dx \, dy \, dz.
	\]

	Evaluating the integral:
	\[
		V = 4 \int_0^{\pi/2} \int_0^{\sin y} \left( \int_y^{\pi - y} dx \right) \, dy \, dz.
	\]

	Upon computation, this integral yields:
	\[
		V = \pi - 2.
	\]


	The key idea was to leverage the symmetry of the intersection region, focusing on one-fourth of the area and then scaling up by a factor of 4. By analyzing the geometry, we found that \( z \) was bounded by \( \sin y \) in region \( R_1 \). From there, the triple integral was computed over \( x \), \( y \), and \( z \) to yield the final volume of the region.
}

\begin{center}
	\begin{tikzpicture}
		\begin{axis}[
				width=12cm,
				height=12cm,
				view={60}{45},
				xlabel=$x$,
				ylabel=$y$,
				zlabel=$z$,
				xmin=0, xmax=3.1416,
				ymin=0, ymax=3.1416,
				zmin=0, zmax=1.2,
				grid=major,
				colormap/cool,
				xtick={0, 1.5708, 3.1416},
				xticklabels={$0$, $\frac{\pi}{2}$, $\pi$},
				ytick={0, 1.5708, 3.1416},
				yticklabels={$0$, $\frac{\pi}{2}$, $\pi$},
				samples=50,
				domain=0:3.1416,
				y domain=0:3.1416,
				trig format=rad,
			]

			% Surface for z = sin(x)
			\addplot3[
				surf,
				samples=50,
				domain=0:3.1416,
				y domain=0:3.1416,
				opacity=0.8,
			]
			{sin(x)};

			% Surface for z = sin(y)
			\addplot3[
				surf,
				samples=50,
				domain=0:3.1416,
				y domain=0:3.1416,
				opacity=0.8,
			]
			{sin(y)};

			% Boundary lines
			\addplot3[
				domain=0:3.1416,
				samples=50,
				thick,
				color=black,
			]
			({x},{0},{0});
			\addplot3[
				domain=0:3.1416,
				samples=50,
				thick,
				color=black,
			]
			({x},{3.1416},{0});
			\addplot3[
				domain=0:3.1416,
				samples=50,
				thick,
				color=black,
			]
			({0},{y},{0});
			\addplot3[
				domain=0:3.1416,
				samples=50,
				thick,
				color=black,
			]
			({3.1416},{y},{0});

			% Cross-section curves
			\addplot3[
				color=red,
				thick,
				domain=0:3.1416,
				samples=50,
			]
			({x},{1.5708},{sin(x)});

			\addplot3[
				color=blue,
				thick,
				domain=0:3.1416,
				samples=50,
			]
			({1.5708},{y},{sin(y)});

			% Height indicator lines
			\foreach \x in {0.5,1,1.5} {
					\addplot3[
						dashed,
						color=gray,
					] coordinates {
							(0,\x,0)
							(3.1416,\x,0)
						};
					\addplot3[
						dashed,
						color=gray,
					] coordinates {
							(\x,0,0)
							(\x,3.1416,0)
						};
				}

			% Add legend
			\addlegendentry{$z = \sin(x)$}
			\addlegendentry{$z = \sin(y)$}
			\addlegendentry{Boundaries}
			\addlegendentry{$x$-cross section}
			\addlegendentry{$y$-cross section}

		\end{axis}
	\end{tikzpicture}
\end{center}

\section{Polar Coordinate System}

\dfn{Polar Coordinates Overview}{
	The polar coordinate system is a two-dimensional coordinate system in which each point on a plane is determined by a distance from a reference point (often called the origin or pole) and an angle from a reference direction (usually the positive \( x \)-axis). The two coordinates are:

	\begin{itemize}
		\item \( r \): the radial distance from the origin to the point.
		\item \( \theta \): the angular coordinate, representing the angle in radians (or degrees) between the positive \( x \)-axis and the line connecting the origin to the point.
	\end{itemize}

	A point \( P \) in the plane can therefore be represented in polar coordinates as \( (r, \theta) \).
}

\dfn{Relationship Between Cartesian and Polar Coordinates}{
	In Cartesian coordinates, a point \( P \) can be represented as \( (x, y) \). We can convert between Cartesian and polar coordinates with the following relations:

	\begin{align*}
		x      & = r \cos \theta                   \\
		y      & = r \sin \theta                   \\
		r      & = \sqrt{x^2 + y^2}                \\
		\theta & = \arctan\left(\frac{y}{x}\right)
	\end{align*}

	These equations allow for the translation of a point's position between Cartesian and polar forms, showing the adaptability of the polar system for various types of analyses, especially when working with circular or rotational symmetry.
}

\begin{center}
	\begin{minipage}{0.45\textwidth}
		\centering
		\begin{tikzpicture}[scale=0.7]
			% Cartesian coordinate system diagram
			\node at (0, 4.5) {\textbf{Cartesian Coordinates}};

			% Draw axes
			\draw[->] (-4, 0) -- (4, 0) node[anchor=north] {\( x \)};
			\draw[->] (0, -4) -- (0, 4) node[anchor=west] {\( y \)};

			% Draw point and line
			\coordinate (P) at (3,2); % Point P at (3,2)
			\draw[thick] (-4,-8/3) -- (4,8/3); % Line through origin and point (slope 2/3)

			% Mark point P
			\filldraw (P) circle (2pt) node[anchor=south west] {\( P(x, y) = (3, 2) \)};

			% Draw dashed lines to x and y axes for clarity
			\draw[dashed] (P) -- (3,0) node[anchor=north] {3};
			\draw[dashed] (P) -- (0,2) node[anchor=east] {2};
		\end{tikzpicture}
	\end{minipage}%
	\hspace{0.05\textwidth} % Space between the two diagrams
	\begin{minipage}{0.45\textwidth}
		\centering
		\begin{tikzpicture}[scale=0.7]
			% Polar coordinate system diagram
			\node at (0, 4.5) {\textbf{Polar Coordinates}};

			% Draw polar grid
			\foreach \r in {1, 2, 3, 4} {
					\draw[cyan, thin] (0,0) circle (\r);
				}
			\foreach \a in {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330} {
					\draw[cyan, thin] (0,0) -- (\a:4);
				}

			% Draw axis lines with labels
			\draw[->, thick] (-4.5,0) -- (4.5,0) node[anchor=north] {\( x \)};
			\draw[->, thick] (0,-4.5) -- (0,4.5) node[anchor=west] {\( y \)};

			% Draw point and radial line
			\coordinate (O) at (0,0);
			\coordinate (P) at (3,2); % Point P in polar coordinates (approx r=3.6, theta=33.69 degrees)
			\draw[->, thick] (O) -- (P) node[midway, anchor=south east] {\( r \)};
			\filldraw (P) circle (2pt) node[anchor=south west] {\( P(r, \theta) \)};

			% Draw angle arc
			\draw[->] (0.8,0) arc [start angle=0, end angle=33.69, radius=0.8];
			\node at (1,0.2) {\( \theta \)};

			% Label r and theta
			\node at (P) [anchor=north] {\( (r \approx 3.6, \theta \approx 33.69^\circ) \)};
		\end{tikzpicture}
	\end{minipage}
\end{center}

\begin{center}
	\begin{tikzpicture}[scale=0.7] % Adjust the scale here to resize the diagram
		% Draw concentric circles
		\foreach \r in {1, 2, 3, 4, 5} {
				\draw[cyan, thin] (0,0) circle (\r);
			}

		% Draw radial lines and angle labels
		\foreach \a in {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330} {
				\draw[cyan, thin] (0,0) -- (\a:5);
				\node at (\a:5.5) {\a$^\circ$};
			}

		% Draw axis lines with labels
		\draw[->, thick] (-5.5,0) -- (5.5,0) node[anchor=north] {\( x \)};
		\draw[->, thick] (0,-5.5) -- (0,5.5) node[anchor=west] {\( y \)};

		% Draw radial line for the point P
		\coordinate (O) at (0,0);
		\coordinate (P) at (2,2); % Set r=4 and angle=60 degrees
		\draw[->, thick] (O) -- (P) node[midway, anchor=south east] {\( r \)};
		\filldraw (P) circle (2pt) node[anchor=south west] {\( P(r, \theta) \)};

		% Draw angle arc
		\draw[->] (0.8,0) arc [start angle=0, end angle=60, radius=0.8];
		\node at (1,0.2) {\( \theta \)};

		% Alternative representations
		\node at (-5, 3.7) {Alternative notation: \( (-r, \theta + \pi) \)};
		\node at (-5, 4.2) {Alternative notation: \( (r, \theta + 2\pi) \)};
	\end{tikzpicture}
\end{center}
\textit{Diagram illustrating the polar coordinate system with concentric circles and angular lines, showing a point \( P \) represented as \( (r, \theta) \) and alternative notations.}

\nt{
	An interesting feature of polar coordinates is that a single point \( P \) can have multiple equivalent representations. For instance, the point \( (r, \theta) \) can also be expressed as \( (-r, \theta + \pi) \) by reversing the radial direction and adjusting the angle. Additionally, due to the periodic nature of angles, adding any integer multiple of \( 2\pi \) to \( \theta \) results in the same point, i.e., \( (r, \theta + 2\pi k) \) for integer \( k \).
}

\ex{Applications of Polar Coordinates}{
	Polar coordinates are particularly useful in problems involving symmetry around a central point, such as in physics for modeling circular motion, waves, and fields. They simplify equations and visualizations in cases where Cartesian coordinates might be cumbersome.
}

\section{Basic Equations}

\subsection{Ellipse}
\[
	\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1
\]
For parametric representation:
\[
	x = a \cos \theta, \quad y = b \sin \theta
\]

\subsection{Line}
\[
	r(\theta) = \frac{b}{\sin \theta - \cos \theta}
\]
where \( y = mx + b \).

\subsection{Cardioid}
The equation for a cardioid:
\[
	r(\theta) = 1 + \cos \theta
\]
Transformations:
\[
	r = 1 + \cos \theta \Rightarrow r = x + \cos \theta
\]
\[
	r = r \cos \theta \Rightarrow x = \cos \theta
\]

\section{Slope of a Curve}

For a function \( r = f(\theta) \):
\[
	\text{slope} = \frac{dy}{dx} = \frac{\frac{dy}{d\theta}}{\frac{dx}{d\theta}}
\]
Using parametric form \( r(\theta) = f(\theta) \), then
\[
	x(\theta) = f(\theta) \cos \theta, \quad y(\theta) = f(\theta) \sin \theta
\]
Therefore,
\[
	\frac{dy}{d\theta} = f'(\theta) \sin \theta + f(\theta) \cos \theta
\]


\[
	\frac{dx}{d\theta} = f'(\theta) \cos \theta - f(\theta) \sin \theta
\]

\dfn{Slope or function with Polar Coordinates}{
		$$\frac{\frac{dy}{d\theta}}{\frac{dx}{d\theta}} = \frac{dy}{dx} = \frac{f'(\theta) \sin \theta + f(\theta) \cos \theta}{f'(\theta) \cos \theta - f(\theta) \sin \theta}$$
}

\ex{Example: Slope of Cardioid}{
	For the cardioid \( r = 1 + \cos \theta \),
	\[
		f(\theta) = 1 + \cos \theta, \quad f'(\theta) = -\sin \theta
	\]
	Then,
	\[
		\text{slope} = \frac{-\sin \theta (\sin \theta) + (1 + \cos \theta) \cos \theta}{-\sin \theta \cos \theta - (1 + \cos \theta) \sin \theta}
	\]
	Simplifying,
	\[
		\text{slope} = -\frac{\cos^2 \theta}{\sin \theta (2 \cos \theta + 1)}
	\]

	To determine where the slope is undefined, we examine the denominator:

	\[
		\text{slope} = -\frac{\cos^2 \theta}{\sin \theta (2 \cos \theta + 1)}
	\]

	The slope is undefined when the denominator is zero.

	\subsection*{At \(\theta = \pi\):}
	\[
		\sin \pi = 0 \quad \text{and} \quad \cos \pi = -1
	\]
	\[
		\sin \pi \cdot (2 \cos \pi + 1) = 0 \cdot (2 \cdot (-1) + 1) = 0
	\]
	Thus, the slope is undefined at \(\theta = \pi\).

	\subsection*{At \(\theta = \frac{3\pi}{4}\):}
	\[
		\sin \frac{3\pi}{4} = \frac{\sqrt{2}}{2} \quad \text{and} \quad \cos \frac{3\pi}{4} = -\frac{\sqrt{2}}{2}
	\]
	\[
		\sin \frac{3\pi}{4} \cdot \left(2 \cos \frac{3\pi}{4} + 1\right) = \frac{\sqrt{2}}{2} \cdot \left(-\sqrt{2} + 1\right) = 0
	\]
	Thus, the slope is also undefined at \(\theta = \frac{3\pi}{4}\).


	\begin{center}
		\begin{tikzpicture}
			\begin{polaraxis}[
					legend style={at={(1.1,1.1)}, anchor=north west}
				]
				% Plot the curve r = 1 + cos(theta)
				\addplot+[domain=0:360, samples=50, thick, blue] (x, {1 + cos(x)});

				% Highlight the points at theta = 135 and 180 degrees with different colors
				\addplot+[only marks, mark=*, mark size=2pt, red] coordinates {(135, {1 + cos(135)})};
				\addlegendentry{$\theta = \frac{3\pi}{4}$}

				\addplot+[only marks, mark=*, mark size=2pt, green] coordinates {(180, {1 + cos(180)})};
				\addlegendentry{$\theta = \pi$}

			\end{polaraxis}
		\end{tikzpicture}
	\end{center}

	The slope at \( \theta = \frac{3\pi}{4} \) does not exist in the usual Cartesian sense. Here’s why:

	\begin{enumerate}
		\item Radial Line: At \( \theta = \frac{3\pi}{4} \), the line connecting the point \( \left(1 + \cos\left(\frac{3\pi}{4}\right), \frac{3\pi}{4}\right) \) to the origin is a radial line. Radial lines in polar coordinates point directly toward or away from the origin, meaning they lack a well-defined Cartesian slope.

		\item Slope in Polar Coordinates: In polar coordinates, the concept of "slope" differs from Cartesian coordinates. We can calculate \( \frac{dr}{d\theta} \) at \( \theta = \frac{3\pi}{4} \), but this does not correspond to a Cartesian slope.

		\item Alternative Interpretation: Converting \( r = 1 + \cos(\theta) \) to Cartesian form and calculating derivatives would show a vertical tangent at \( \theta = \frac{3\pi}{4} \), indicating an undefined slope.
	\end{enumerate}

}

\section{Deriving the Integral for Area Under a Curve in Polar Coordinates}

To find the area under a curve defined in polar coordinates using Riemann sums, we follow these steps:

In Cartesian coordinates, the area under a curve from \( x = a \) to \( x = b \) is given by:
\[
	\int_a^b f(x) \, dx
\]
In polar coordinates, a point is represented by \( (r, \theta) \), where \( r \) is the radial distance from the origin, and \( \theta \) is the angle from the positive \( x \)-axis. To calculate the area under a curve \( r = f(\theta) \) between two angles \( \theta = \alpha \) and \( \theta = \beta \), we use sectors of circles.

For a small angle \( d\theta \), the area of a sector with radius \( r \) is approximately:
\[
	dA \approx \frac{1}{2} r^2 \, d\theta
\]
This comes from the area formula for a sector, \( \frac{1}{2} r^2 \theta \), with a small change in angle \( d\theta \).

To find the total area under the curve \( r = f(\theta) \) from \( \theta = \alpha \) to \( \theta = \beta \), we can divide the interval \( [\alpha, \beta] \) into \( n \) small subintervals, each of width \( \Delta \theta = \frac{\beta - \alpha}{n} \).

In each subinterval \( [ \theta_i, \theta_{i+1} ] \), we approximate the radius \( r \) by \( f(\theta_i) \), where \( \theta_i \) is a sample point in that interval. The area of each small sector is then approximately:
\[
	\Delta A_i \approx \frac{1}{2} f(\theta_i)^2 \Delta \theta
\]

The total area \( A \) is the sum of the areas of these small sectors:
\[
	A \approx \sum_{i=0}^{n-1} \frac{1}{2} f(\theta_i)^2 \Delta \theta
\]

As we take the limit where \( n \to \infty \) and \( \Delta \theta \to 0 \), this Riemann sum becomes an integral:
\[
	A = \lim_{n \to \infty} \sum_{i=0}^{n-1} \frac{1}{2} f(\theta_i)^2 \Delta \theta = \int_{\alpha}^{\beta} \frac{1}{2} f(\theta)^2 \, d\theta
\]

Thus, the area under the curve \( r = f(\theta) \) in polar coordinates from \( \theta = \alpha \) to \( \theta = \beta \) is:
\[
	\boxed{A = \int_{\alpha}^{\beta} \frac{1}{2} f(\theta)^2 \, d\theta}
\]

This is the formula for the area in polar coordinates, derived using the concept of Riemann sums.

\ex{Example: Circle \( r = a \)}{
	\[
		A = \frac{1}{2} \int_0^{2 \pi} a^2 \, d\theta = \pi a^2
	\]
}


\ex{Two curves}{

\begin{center}
	\begin{tikzpicture}[scale=2]
		% Define angles for the interval [theta_1, theta_2]
		\def\thetaone{30}    % Start angle
		\def\thetatwo{120}   % End angle

		% Draw the radial grid (optional for reference)
		\foreach \r in {0.5, 1, 1.5, 2} {
				\draw[cyan, thin] (0,0) circle (\r);
			}

		% Draw angular lines at theta_1 and theta_2
		\draw[dashed] (0,0) -- (\thetaone:2.5);
		\draw[dashed] (0,0) -- (\thetatwo:2.5);

		% Label angles
		\node at (\thetaone:2.6) {\( \theta_1 \)};
		\node at (\thetatwo:2.6) {\( \theta_2 \)};

		% Define the functions f(theta) and g(theta) as polar plots
		% f(theta) - Outer curve
		\draw[thick, blue, domain=\thetaone:\thetatwo, samples=100, variable=\t]
		plot ({\t}:{1 + 0.5*cos(\t)});
		\node at (70:1.5) {\( f(\theta) \)};

		% g(theta) - Inner curve
		\draw[thick, red, domain=\thetaone:\thetatwo, samples=100, variable=\t]
		plot ({\t}:{0.5 + 0.3*cos(\t)});
		\node at (70:0.8) {\( g(\theta) \)};

		% Shade the area between the two curves
		\fill[blue!30, opacity=0.5, domain=\thetaone:\thetatwo, samples=100, variable=\t]
		plot ({\t}:{1 + 0.5*cos(\t)}) --
		plot[domain=\thetatwo:\thetaone, samples=100] ({\t}:{0.5 + 0.3*cos(\t)}) -- cycle;

		% Add label for the shaded area
		\node at (80:1.2) {\( A = \frac{1}{2} \int_{\theta_1}^{\theta_2} \left( f(\theta)^2 - g(\theta)^2 \right) \, d\theta \)};
	\end{tikzpicture}
\end{center}

For two curves \( r = f(\theta) \) and \( r = g(\theta) \):
\[
	A = \int_{\theta_1}^{\theta_2} \frac{1}{2} f(\theta)^2 \, d\theta - \int_{\theta_1}^{\theta_2} \frac{1}{2} g(\theta)^2 \, d\theta
\]
which simplifies to
\[
A = \frac{1}{2} \int_{\theta_1}^{\theta_2} (f(\theta)^2 - g(\theta)^2) \, d\theta
\]

}

\section{Arc Length in Polar Coordinates}

The position vector in polar coordinates is given by:
\[
	\vec{r}(t) = \langle f(\theta) \cos\theta, f(\theta) \sin\theta \rangle
\]

The magnitude of the derivative of the position vector is:
\[
	|\vec{r}'(t)| = \sqrt{ \left( f'(\theta) \cos\theta - f(\theta) \sin\theta \right)^2
		+ \left( f'(\theta) \sin\theta + f(\theta) \cos\theta \right)^2 }
\]

Simplifying, this becomes:
\[
	|\vec{r}'(t)| = \sqrt{ \left( f'(\theta) \right)^2 + \left( f(\theta) \right)^2 }
\]

The arc length \(S_r\) is then calculated as:
\[
	S_r = \int_{\theta_1}^{\theta_2} \sqrt{\left(f'(\theta)\right)^2 + \left(f(\theta)\right)^2} \, d\theta
\]


\ex{Circle of Radius \(a\)}{

	\textbf{Example:} Let \(r(\theta) = a\), where:
	\[
		r'(\theta) = 0, \quad r(\theta) = a
	\]
	The arc length is:
	\[
		S = \int_0^{2\pi} \sqrt{a^2} \, d\theta = a \int_0^{2\pi} 1 \, d\theta = 2\pi a
	\]
}


\section{Multivariate Case}

The double integral over a region \(R\):
\[
	\iint_R f(x, y) \, dA
\]
If converted to polar coordinates:
\[
	\iint_R f(x, y) \, dA = \iint_R f(r\cos\theta, r\sin\theta) \, r \, dr \, d\theta
\]

\ex{Volume under \(z = 9 - x^2 - y^2\):}{

	\[
		R = \{(x, y): x^2 + y^2 \leq 9\}
	\]
	In polar coordinates:
	\[
		R = \{(r, \theta): 0 \leq \theta \leq 2\pi, 0 \leq r \leq 3\}
	\]

	The function in polar coordinates:
	\[
		f(r, \theta) = 9 - r^2
	\]

	The volume is then:
	\[
		\int_R f(r, \theta) \, dA = \int_0^{2\pi} \int_0^3 r(9 - r^2) \, dr \, d\theta
	\]

	\begin{center}
		\begin{tikzpicture}
			\begin{axis}[
					view={40}{30},
					axis lines=middle,
					xlabel={$x$},
					ylabel={$y$},
					zlabel={$z$},
					zmin=0, zmax=10, xmin=-4, xmax=4, ymin=-4, ymax=4,
					samples=50
				]
				\addplot3[
					domain=0:360,
					y domain=0:3,
					surf,
					colormap/viridis
				]
				({y*cos(x)},{y*sin(x)},{9-y^2});
			\end{axis}
		\end{tikzpicture}
	\end{center}

	\textbf{Simplified Polar Volume Calculation:}
	\[
		\int_R f(r, \theta) \, dA = \int_0^{2\pi} \int_0^3 r(9 - r^2) \, dr \, d\theta
	\]

}

\section{General Procedure for Polar Integration}

Given a region \( R = \{(r, \theta): \theta_1 \leq \theta \leq \theta_2, \, q(\theta) \leq r \leq h(\theta)\} \), the volume is calculated as:
\[
	V = \iint_R f(r, \theta) \, dA = \int_{\theta_1}^{\theta_2} \int_{q(\theta)}^{h(\theta)} r f(r, \theta) \, dr \, d\theta
\]
where the area element is \( \Delta A = r \, \Delta r \, \Delta \theta \).

\ex{Example: Region Outside \(r = \frac{1}{2}\) and Inside \(r = 1 + \cos\theta\)}{

\textbf{The bounds are:}
\[
	\frac{1}{2} \leq r \leq 1 + \cos\theta
\]
\[
	-\frac{2\pi}{3} \leq \theta \leq \frac{2\pi}{3}
\]

\textbf{Cosine conditions are determined by:}
\[
	\cos\theta = -\frac{1}{2}, \quad \theta = -\frac{2\pi}{3}, \, \frac{2\pi}{3}
\]

The integral for the volume is:
\[
	\iint_R q(r, \theta) \, dA = \int_{-\frac{2\pi}{3}}^{\frac{2\pi}{3}} \int_{\frac{1}{2}}^{1+\cos\theta} r \, q(r, \theta) \, dr \, d\theta
\]


\begin{center}
    \begin{tikzpicture}
        \begin{polaraxis}[
                legend style={at={(1.1,1.1)}, anchor=north west}
            ]
            % Plot the curve r = 1 + cos(theta)
            \addplot+[domain=0:360, samples=50, thick, blue] (x, {1 + cos(x)});
            \addlegendentry{$r = 1 + \cos\theta$}

            \addplot+[domain=0:360, samples=20, thick, red] ({x},{0.5});
            \addlegendentry{$r = \frac{1}{2}$}

        \end{polaraxis}
    \end{tikzpicture}
\end{center}
}


\section{Cylindrical Coordinate Axes}
\begin{center}
	\tdplotsetmaincoords{60}{110}
	\begin{tikzpicture}[scale=4, tdplot_main_coords]
		\coordinate (O) at (0,0,0);
		\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
		\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
		\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};
		\tdplotsetcoord{P}{1}{30}{60}
		\draw plot [mark=*, mark size=0.2] (P) node [right] {\scriptsize$(r,\phi,z)$};
		\draw[dashed] (O) -- (P);
		\draw[->, thick, color=black] (O) -- (Pxy) node [below right] {$r$};
		\draw[dashed, color=black] (P) -- (Pxy);
		\tdplotdrawarc{(O)}{0.2}{0}{60}{anchor=north}{$\theta$}
		\draw[dashed, color=black] (P) -- (Pz) node [below left] {$z$};
	\end{tikzpicture}
\end{center}


\ex{Cylinders and Cones Example}{
	\textbf{Cylinders:}
	\[
		r = 1, \quad v = 2
	\]

	\textbf{Cones:}
	\[
		z = \frac{\sqrt{3}}{3}r, \quad z = \sqrt{3}r
	\]

	\textbf{Ranges:}
	\begin{itemize}
		\item \(r\) is bounded by the cylinders: \(1 \leq r \leq 2\)
		\item \(z\) is bounded by the cones: \(\frac{\sqrt{3}}{3}r \leq z \leq \sqrt{3}r\)
		\item \(\theta\) is unbounded: \(0 \leq \theta \leq 2\pi\)
	\end{itemize}

	\textbf{Volume:}
	\[
		V = \int_0^{2\pi} \int_1^2 \int_{\frac{\sqrt{3}}{3}r}^{\sqrt{3}r} r \, dz \, dr \, d\theta
	\]
	(Simplify to evaluate)
}

\section{Spherical Coordinate Axes}


The relationships between Cartesian coordinates \((x, y, z)\) and spherical coordinates \((\rho, \phi, \theta)\) are as follows:
\dfn{Polar -  Spherical Relationships}{
	\[
		x = \rho \cos\phi \cos\theta
	\]
	\[
		y = \rho \cos\phi \sin\theta
	\]
	\[
		z = \rho \sin\phi
	\]

	\noindent Conversely, the spherical coordinates can be expressed in terms of Cartesian coordinates as:
	\[
		\rho = \sqrt{x^2 + y^2 + z^2}
	\]
	\[
		\phi = \tan^{-1}\left(\frac{z}{\sqrt{x^2 + y^2}}\right)
	\]
	\[
		\theta = \tan^{-1}\left(\frac{y}{x}\right)
	\]

	\noindent The volume element in spherical coordinates is:
	\[
		dV = \rho^2 \sin\phi \, d\rho \, d\phi \, d\theta
	\]

	\noindent The integral of a function \(f(x, y, z)\) in spherical coordinates becomes:
	\[
		\iiint_P f(x, y, z) \, dV = \iiint_P f\big(\rho \cos\phi \cos\theta, \rho \cos\phi \sin\theta, \rho \sin\phi\big) \rho^2 \sin\phi \, d\rho \, d\phi \, d\theta
	\]
}

\begin{center}
	% Spherical Coordinates
	\tdplotsetmaincoords{60}{110}
	\begin{tikzpicture}[scale=4, tdplot_main_coords]
		\coordinate (O) at (0,0,0);
		\draw[thick,->] (0,0,0) -- (1,0,0) node[anchor=north east]{$x$};
		\draw[thick,->] (0,0,0) -- (0,1,0) node[anchor=north west]{$y$};
		\draw[thick,->] (0,0,0) -- (0,0,1) node[anchor=south]{$z$};
		\tdplotsetcoord{P}{1}{30}{60}
		\draw plot [mark=*, mark size=0.2] (P) node [right] {\scriptsize$(\rho,\theta,\phi)$};
		\draw[->, thick] (O) -- (P) node [midway, below right] {$\rho$};
		\draw[dashed, color=black] (O) -- (Pxy);
		\draw[dashed, color=black] (P) -- (Pxy);
		\tdplotdrawarc{(O)}{0.2}{0}{60}{anchor=north}{$\theta$}
		\tdplotsetthetaplanecoords{60}
		\tdplotdrawarc[tdplot_rotated_coords]{(0,0,0)}{0.4}{0}%
		{30}{anchor=south}{$\phi$}
	\end{tikzpicture}

\end{center}

\section{Shapes Represented in Spherical Coordinates}

\subsection{Overview of Spherical Coordinates}
\begin{itemize}
    \item \textbf{Definition}: Spherical coordinates \((r, \theta, \phi)\) are defined as:
    \begin{itemize}
        \item \(r\): Radial distance from the origin.
        \item \(\theta\): Polar angle (angle from the positive \(z\)-axis, \(0 \leq \theta \leq \pi\)).
        \item \(\phi\): Azimuthal angle (angle in the \(xy\)-plane from the positive \(x\)-axis, \(0 \leq \phi < 2\pi\)).
    \end{itemize}
    \item \textbf{Conversion to Cartesian coordinates}:
    \[
    x = r \sin\theta \cos\phi, \quad y = r \sin\theta \sin\phi, \quad z = r \cos\theta
    \]
\end{itemize}

\subsection{Shapes in Spherical Coordinates}


\begin{multicols}{2}


\subsubsection{1. Sphere}
\textbf{Equation}: \(r = R\) \\
\textbf{Description}: A sphere of radius \(R\) centered at the origin. \\
\textbf{Representation}: Independent of \(\theta\) and \(\phi\).

\begin{center}
	\begin{tikzpicture}
	\begin{axis}[view={60}{30}, axis equal, width=5cm, height=5cm, colormap/cool, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}]
		\addplot3[surf, samples=50, domain=0:pi, y domain=0:2*pi]
		({sin(deg(x))*cos(deg(y))}, {sin(deg(x))*sin(deg(y))}, {cos(deg(x))});
	\end{axis}
	\end{tikzpicture}
	\end{center}

\subsubsection{2. Half-Sphere}
\textbf{Equation}: \(r = R, \, 0 \leq \theta \leq \frac{\pi}{2}\) \\
\textbf{Description}: Upper half of a sphere centered at the origin, constrained by the polar angle.

\begin{center}
	\begin{tikzpicture}
	\begin{axis}[view={60}{30}, axis equal, width=5cm, height=5cm, colormap/cool, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}]
		\addplot3[surf, samples=40, domain=0:pi/2, y domain=0:2*pi]
		({sin(deg(x))*cos(deg(y))}, {sin(deg(x))*sin(deg(y))}, {cos(deg(x))});
	\end{axis}
	\end{tikzpicture}
	\end{center}


\subsubsection{3. Spherical Shell}
\textbf{Equation}: \(R_1 \leq r \leq R_2\) \\
\textbf{Description}: A hollow spherical region with inner radius \(R_1\) and outer radius \(R_2\).

\begin{center}
	\begin{tikzpicture}
	\begin{axis}[view={60}{30}, axis equal, width=5cm, height=5cm, colormap/cool, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}]
		\addplot3[surf, samples=40, domain=0:pi, y domain=0:2*pi, opacity=0.5]
		({1.5*sin(deg(x))*cos(deg(y))}, {1.5*sin(deg(x))*sin(deg(y))}, {1.5*cos(deg(x))});
		\addplot3[surf, samples=40, domain=0:pi, y domain=0:2*pi, opacity=0.5]
		({2*sin(deg(x))*cos(deg(y))}, {2*sin(deg(x))*sin(deg(y))}, {2*cos(deg(x))});
	\end{axis}
	\end{tikzpicture}
	\end{center}

\subsubsection{4. Cone}
\textbf{Equation}: \(\theta = \theta_0\) \\
\textbf{Description}: A cone with its vertex at the origin, opening angle \(2\theta_0\), symmetric around the \(z\)-axis. \\
\textbf{Constraints}: \(r > 0\), \(\phi\) varies from \(0\) to \(2\pi\).

\begin{center}
	\begin{tikzpicture}
	\begin{axis}[view={60}{30}, axis equal, width=5cm, height=5cm, colormap/cool, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}]
		\addplot3[surf, samples=40, domain=0:2*pi, y domain=0:2]
		({y*sin(deg(pi/4))*cos(deg(x))}, {y*sin(deg(pi/4))*sin(deg(x))}, {y*cos(deg(pi/4))});
	\end{axis}
	\end{tikzpicture}
	\end{center}

\subsubsection{5. Circular Disc (in the \(xy\)-Plane)}
\textbf{Equation}: \(r = R, \, \theta = \frac{\pi}{2}\) \\
\textbf{Description}: A circular disc of radius \(R\) centered on the origin in the \(xy\)-plane.

\begin{center}
	\begin{tikzpicture}
	\begin{axis}[view={0}{90}, axis equal, width=5cm, height=5cm, colormap/cool, xlabel={$x$}, ylabel={$y$}]
		\addplot3[surf, samples=40, domain=0:2*pi, y domain=0:1, z buffer=sort]
		({y*cos(deg(x))}, {y*sin(deg(x))}, {0});
	\end{axis}
	\end{tikzpicture}
	\end{center}



\subsubsection{6. Cylinder}
\textbf{Equation}: \(r \sin\theta = a\) \\
\textbf{Description}: A cylinder of radius \(a\) around the \(z\)-axis. \\
\textbf{Constraints}:
\begin{itemize}
    \item \(0 \leq \phi < 2\pi\),
    \item \(r \cos\theta\) is unbounded (representing the \(z\)-coordinate).
\end{itemize}

\begin{center}
	\begin{tikzpicture}
	\begin{axis}[view={60}{30}, axis equal, width=5cm, height=5cm, colormap/cool, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}]
		\addplot3[surf, samples=40, domain=0:2*pi, y domain=-1:1]
		({cos(deg(x))}, {sin(deg(x))}, {y});
	\end{axis}
	\end{tikzpicture}
	\end{center}


\subsubsection{7. Torus (Approximation)}
\textbf{Equation}: \(r = R + r_0 \sin\theta\) \\
\textbf{Description}: A torus with major radius \(R\) and minor radius \(r_0\), approximately represented in spherical coordinates. \\
\textbf{Constraints}:
\begin{itemize}
    \item \(\phi\) varies from \(0\) to \(2\pi\),
    \item Specific parametric constraints apply.
\end{itemize}
\begin{center}
	\begin{tikzpicture}
	\begin{axis}[view={60}{30}, axis equal, width=5cm, height=5cm, colormap/cool, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}]
		\addplot3[surf, samples=40, domain=0:2*pi, y domain=0:2*pi]
		({(2 + cos(deg(y)))*cos(deg(x))}, {(2 + cos(deg(y)))*sin(deg(x))}, {sin(deg(y))});
	\end{axis}
	\end{tikzpicture}
	\end{center}


\subsubsection{8. Plane}
\textbf{Equation}: \(\theta = \text{constant}\) or \(\phi = \text{constant}\) \\
\textbf{Description}:
\begin{itemize}
    \item \(\theta = \text{constant}\): A conical plane cutting through the origin at a fixed polar angle.
    \item \(\phi = \text{constant}\): A vertical plane slicing through the \(z\)-axis at a fixed azimuthal angle.
\end{itemize}

\begin{center}
	\begin{tikzpicture}
	\begin{axis}[view={60}{30}, axis equal, width=5cm, height=5cm, colormap/cool, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}]
		\addplot3[surf, samples=40, domain=-2:2, y domain=-2:2]
		({x}, {y}, {tan(deg(45))*x});
	\end{axis}
	\end{tikzpicture}
	\end{center}


\subsubsection{9. Lemniscate Shape}
\textbf{Equation}: \(r = a \sin\theta \sin2\phi\) \\
\textbf{Description}: A figure-eight or lemniscate shape in spherical coordinates.

\begin{center}
	\begin{tikzpicture}
	\begin{axis}[view={60}{30}, axis equal, width=5cm, height=5cm, colormap/cool, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}]
		\addplot3[surf, samples=40, domain=0:pi, y domain=0:2*pi]
		({sin(deg(x))*cos(deg(y))}, {sin(deg(x))*sin(deg(y))}, {sin(deg(x))*sin(deg(2*y))});
	\end{axis}
	\end{tikzpicture}
	\end{center}


\subsubsection{10. Wave-like Surfaces}
\textbf{Equation}: \(r = R + A \cos(k\theta)\) \\
\textbf{Description}: Oscillating surface around a spherical shell, useful in representing waves or perturbations on a sphere.

\begin{center}
	\begin{tikzpicture}
	\begin{axis}[view={60}{30}, axis equal, width=5cm, height=5cm, colormap/cool, xlabel={$x$}, ylabel={$y$}, zlabel={$z$}]
		\addplot3[surf, samples=40, domain=0:pi, y domain=0:2*pi]
		({(2 + 0.5*cos(deg(5*x)))*sin(deg(x))*cos(deg(y))},
		 {(2 + 0.5*cos(deg(5*x)))*sin(deg(x))*sin(deg(y))},
		 {(2 + 0.5*cos(deg(5*x)))*cos(deg(x))});
	\end{axis}
	\end{tikzpicture}
	\end{center}

\end{multicols}


\section{Change of Variable for Double and Triple Integrals}

\subsection*{Polar Coordinates}
\[
	\iint_D f(x, y) \, dx \, dy \rightarrow \iint_S f(r\cos\theta, r\sin\theta) \, r \, dr \, d\theta
\]

\subsection*{Cylindrical Coordinates}
\[
	\iiint_D f(x, y, z) \, dx \, dy \, dz \rightarrow \iiint_S f(r\cos\theta, r\sin\theta, z) \, r \, dr \, d\theta \, dz
\]

\subsection*{Spherical Coordinates}
\[
	\iiint_D f(x, y, z) \, dx \, dy \, dz \rightarrow \iiint_S f(\rho\sin\phi\cos\theta, \rho\sin\phi\sin\theta, \rho\cos\phi) \, \rho^2 \sin\phi \, d\rho \, d\phi \, d\theta
\]

\thm{Intuition Behind Change of Variables}{
We use a \textbf{mapping} \( T \) to transform coordinates in one space \( S \) to another \( R \). This is particularly useful when integrating over regions that are easier to describe in new coordinates (e.g., circular or spherical regions).

For example:
\[
	S = [0, 2\pi] \times [0, 2], \quad T(r, \theta) = (r\cos\theta, r\sin\theta)
\]

Here, the mapping \( T \) converts a point in \( S \) into a point in \( R \).


\subsection*{Area Differential Transformation}
Consider a small differential area element in the original space:
\[
	dA = |\det(J)| \, du \, dv
\]
where \( J \) is the \textbf{Jacobian matrix}, and \( |\det(J)| \) accounts for how the transformation scales area.
}

\dfn{Jacobian Matrix}{
	The Jacobian matrix represents the linear transformation of the mapping \( T \) at a given point:
	\[
		J = \begin{bmatrix}
			\frac{\partial x}{\partial u} & \frac{\partial x}{\partial v} \\
			\frac{\partial y}{\partial u} & \frac{\partial y}{\partial v}
		\end{bmatrix}
	\]

	For a transformation \( T(u, v) = (g(u, v), h(u, v)) \), the determinant of \( J \) is:
	\[
		\det(J) =
		\begin{vmatrix}
			\frac{\partial g}{\partial u} & \frac{\partial g}{\partial v} \\
			\frac{\partial h}{\partial u} & \frac{\partial h}{\partial v}
		\end{vmatrix}
		= \frac{\partial g}{\partial u} \cdot \frac{\partial h}{\partial v} - \frac{\partial g}{\partial v} \cdot \frac{\partial h}{\partial u}
	\]

}

\subsection*{Geometric Interpretation}
\begin{itemize}
	\item \textbf{Local Stretching/Scaling:} \( |\det(J)| \) gives the local scaling factor of the area due to the transformation.
	\item \textbf{Orientation:} The sign of \( \det(J) \) indicates whether the orientation is preserved or flipped.
\end{itemize}

\ex{Polar Coordinates}{
	For the transformation \( T(r, \theta) = (r\cos\theta, r\sin\theta) \), the Jacobian matrix is:
	\[
		J = \begin{bmatrix}
			\cos\theta & -r\sin\theta \\
			\sin\theta & r\cos\theta
		\end{bmatrix}
	\]

	The determinant is:
	\[
		\det(J) = \begin{vmatrix}
			\cos\theta & -r\sin\theta \\
			\sin\theta & r\cos\theta
		\end{vmatrix}
		= r(\cos^2\theta + \sin^2\theta) = r
	\]

	Thus, the area differential in polar coordinates becomes:
	\[
		dx \, dy = r \, dr \, d\theta
	\]

}

\dfn{General Formula for Transforming Integrals}{
	If \( T: S \rightarrow R \) is a transformation with Jacobian determinant \( |\det(J)| \), then the integral transforms as:
	\[
		\iint_R f(x, y) \, dx \, dy = \iint_S f(T(u, v)) \, |\det(J)| \, du \, dv
	\]

}

\dfn{Intuition for Higher Dimensions}{
	In three dimensions, the Jacobian matrix extends to account for the transformation of volume elements:
	\[
		J = \begin{bmatrix}
			\frac{\partial x}{\partial u} & \frac{\partial x}{\partial v} & \frac{\partial x}{\partial w} \\
			\frac{\partial y}{\partial u} & \frac{\partial y}{\partial v} & \frac{\partial y}{\partial w} \\
			\frac{\partial z}{\partial u} & \frac{\partial z}{\partial v} & \frac{\partial z}{\partial w}
		\end{bmatrix}
	\]

	The volume scaling factor is given by \( |\det(J)| \), and the integral transforms as:
	\[
		\iiint_R f(x, y, z) \, dx \, dy \, dz = \iiint_S f(T(u, v, w)) \, |\det(J)| \, du \, dv \, dw
	\]

}

\section{Non-overlapping from Mapping \( T \)}

\thm{Non-overlapping Condition}{
	For any two points \( Q \) and \( P \):
	\[
		T(Q) \neq T(P) \quad \text{(This would result in overlapping areas in the domain \( R \))}
	\]
	However, boundaries (e.g., \( y = 2x \)) can overlap as long as the bounded region is distinct.
}

\ex{Integral Transformation Example}{
	Evaluate:
	\[
		\iint_R 2x(y - 2x) \, dA
	\]
	where \( R \) is the parallelogram with vertices \((0, 0), (0, 1), (2, 4), (2, 3)\).

	Steps:
	\begin{enumerate}
		\item \textbf{Choose a Transformation:} Select a mapping \( T \) to simplify the integral.
		\item \textbf{Define the Mapping:}
		      \[
			      x = u, \quad y = 2x + v = 2u + v
		      \]
		      Substituting:
		      \[
			      (x, y) \rightarrow (u, v)
		      \]

		\item \textbf{Boundary Equations:}
		      \[
			      0 \leq x \leq 2 \quad \Rightarrow \quad 0 \leq u \leq 2
		      \]
		      \[
			      0 \leq y - 2x < 1 \quad \Rightarrow \quad 0 \leq v < 1
		      \]

		\item \textbf{Region:}
		      \[
			      S = [0, 2] \times [0, 1]
		      \]

		\item \textbf{Transform the Integrand:}
		      \[
			      f(T(x, y)) = 2u(v)
		      \]

		\item \textbf{Jacobian Calculation:}
		      \[
			      J = \begin{bmatrix}
				      x_u & x_v \\
				      y_u & y_v
			      \end{bmatrix}
			      = \begin{bmatrix}
				      1 & 0 \\
				      2 & 1
			      \end{bmatrix}, \quad \det(J) = 1 \cdot 1 - 2 \cdot 0 = 1
		      \]

		\item \textbf{Transformed Integral:}
		      \[
			      \iint_R 2x(y - 2x) \, dA = \int_0^2 \int_0^1 2uv \, du \, dv
		      \]
	\end{enumerate}
}

\section{Integral Transformation for a Parallelogram Region}

\ex{Example of Transformation}{
	Evaluate:
	\[
		\iint_R 2x(y - 2x) \, dA
	\]
	where \( R \) is the parallelogram defined by the vertices \((0, 0), (0, 1), (2, 4), (2, 3)\).

	\subsection*{Steps:}
	\begin{enumerate}
		\item \textbf{Choose a Transformation:} Select a transformation \( T \) that simplifies the integral.
		\item \textbf{Define \( x, y \) in terms of \( u, v \):}
		      \[
			      x = u, \quad y = 2x + v = 2u + v
		      \]
		      Substituting:
		      \[
			      (x, y) \rightarrow (u, v)
		      \]
		      Here, \( u \) corresponds to \( x \), and \( v = y - 2x \).

		\item \textbf{Boundary Equations:}
		      \[
			      0 \leq x \leq 2 \quad \Rightarrow \quad 0 \leq u \leq 2
		      \]
		      \[
			      0 \leq y - 2x < 1 \quad \Rightarrow \quad 0 \leq v < 1
		      \]

		\item \textbf{Region in \( u, v \):}
		      \[
			      S = [0, 2] \times [0, 1]
		      \]
		      This maps the parallelogram \( R \) into a rectangle \( S \) in the \( u, v \)-plane.

		\item \textbf{Transform the Integrand:}
		      Substituting \( x = u \) and \( y - 2x = v \):
		      \[
			      f(T(x, y)) = 2u(v)
		      \]

		\item \textbf{Jacobian Calculation:}
		      The Jacobian matrix for the transformation \( T \) is:
		      \[
			      J = \begin{bmatrix}
				      x_u & x_v \\
				      y_u & y_v
			      \end{bmatrix}
			      = \begin{bmatrix}
				      1 & 0 \\
				      2 & 1
			      \end{bmatrix}
		      \]
		      The determinant of \( J \) is:
		      \[
			      \det(J) = 1 \cdot 1 - 2 \cdot 0 = 1
		      \]

		\item \textbf{Transformed Integral:}
		      Using the transformation and the Jacobian determinant:
		      \[
			      \iint_R 2x(y - 2x) \, dA = \int_0^2 \int_0^1 2uv \, du \, dv
		      \]
		      The transformed integral simplifies the computation significantly.
	\end{enumerate}
}

\section{Integral Transformation for a Triangular Region}

\ex{Example of Transformation}{
	Evaluate:
	\[
		\iint_R (x - u)\sqrt{x - 2y} \, dA
	\]
	where \( R \) is the triangular region bounded by the lines \( y = 0 \), \( x - 2y = 0 \), and \( x = y + 1 \).

	\subsection*{Steps:}
	\begin{enumerate}
		\item \textbf{Region Definition:}
		      The region \( R \) is defined by:
		      \[
			      y = 0, \quad x - 2y = 0, \quad x = y + 1
		      \]
		      The boundaries in \( x \) and \( y \) are:
		      \[
			      0 \leq x \leq 2, \quad 0 \leq y \leq \frac{x}{2}, \quad x \leq y + 1
		      \]

		\item \textbf{Define Transformation:}
		      Let:
		      \[
			      u = x - 2y, \quad v = x - y
		      \]
		      Substituting:
		      \[
			      x = v + u, \quad y = v - u
		      \]

		\item \textbf{Boundaries in New Coordinates:}
		      Using the transformation:
		      \begin{align*}
			      u & = x - 2y \quad \Rightarrow \quad 0 \leq u \leq 1 \\
			      v & = x - y \quad \Rightarrow \quad u \leq v \leq 1
		      \end{align*}

		      The transformed region \( S \) is bounded by \( u = 0 \), \( v = 1 \), and \( v - u = 1 \).

		\item \textbf{Jacobian Calculation:}
		      The Jacobian matrix for the transformation \( T(u, v) \) is:
		      \[
			      J = \begin{bmatrix}
				      \frac{\partial x}{\partial u} & \frac{\partial x}{\partial v} \\
				      \frac{\partial y}{\partial u} & \frac{\partial y}{\partial v}
			      \end{bmatrix}
			      = \begin{bmatrix}
				      1  & 1 \\
				      -2 & 1
			      \end{bmatrix}
		      \]
		      The determinant of \( J \) is:
		      \[
			      \det(J) = (1)(1) - (1)(-2) = 1 + 2 = 3
		      \]

		\item \textbf{Transform the Integral:}
		      Using the transformation and Jacobian determinant:
		      \[
			      \iint_R (x - u)\sqrt{x - 2y} \, dA = \int_0^1 \int_0^v \sqrt{u} \cdot 3 \, du \, dv
		      \]
		      Simplify:
		      \[
			      \int_0^1 \int_0^v \sqrt{u} \, du \, dv = \int_0^1 \left[ \frac{2}{3} u^{3/2} \right]_0^v dv
			      = \int_0^1 \frac{2}{3} v^{3/2} dv
		      \]
		      \[
			      = \left[ \frac{2}{3} \cdot \frac{2}{5} v^{5/2} \right]_0^1 = \frac{4}{15}.
		      \]
		      The result is:
		      \[
			      \iint_R (x - u)\sqrt{x - 2y} \, dA = \frac{4}{15}.
		      \]
	\end{enumerate}
}


\chapter{Vector Fields $f:\mathbb{R}^n \rightarrow \mathbb{R}^n$}


\section{Vector Fields}

A \textbf{vector field} is a function $\vec{F}$ that takes points in $\mathbb{R}^2$ or $\mathbb{R}^3$ and outputs a vector in $\mathbb{R}^2$ or $\mathbb{R}^3$:
\[
	\vec{F} : \mathbb{R}^n \to \mathbb{R}^n, \quad \vec{F}(x, y, z) = \langle q(x, y, z), w(x, y, z), t(x, y, z) \rangle.
\]

\subsection{Properties}
\begin{itemize}
	\item Continuous if $q, w, t$ are continuous.
	\item Differentiable if $q, w, t$ are differentiable.
	\item Domain is the intersection of domains of $q, w, t$.
\end{itemize}

\subsection{Applications}
\begin{itemize}
	\item Water and wind currents.
	\item Gravitational, electric, and magnetic fields.
	\item Human circulation, heat propagation.
	\item Modeling through partial differential equations.
\end{itemize}

\subsection{Drawing a Vector Field}
At each point in the domain of $\vec{F}$, draw a vector whose:
\begin{itemize}
	\item Direction is parallel to $\vec{F}(x, y)$.
	\item Length is proportional to the magnitude of $\vec{F}(x, y)$.
\end{itemize}

\ex{$\vec{F}(x, y) = \frac{ \langle x, y \rangle }{\left\lvert \langle x, y \rangle \right\rvert ^3 } $}{
	\begin{center}
		\begin{tikzpicture}
			\begin{axis}[%
					view     = {0}{90}, % for a view 'from above'
					domain   = -2:2,
					y domain = -2:2,
					xtick    = {-2,...,2},
					ytick    = {-2,...,2},
					colormap/viridis,
					colorbar,
					colorbar style = {
							ylabel = {Vector Length}
						}
				]
				\addplot3[
					point meta = {(x^2 + y^2)^(-1/2)}, % length of the vector
					quiver = {
							u = {x/(x^2+y^2)^(3/2)},
							v = {y/(x^2+y^2)^(3/2)},
							scale arrows = 0.1,
						},
					quiver/colored = {mapped color},
					-stealth,
					samples = 16
				] (x, y, 0);
			\end{axis}
		\end{tikzpicture}
	\end{center}
}

\ex{ $\vec{F}(x, y) = \langle -y, x \rangle$ }{
	\begin{center}
		\begin{tikzpicture}
			\begin{axis}[
				xmin = -4, xmax = 4,
				ymin = -4, ymax = 4,
				zmin = 0, zmax = 1,
				axis equal image,
				xtick distance = 1,
				ytick distance = 1,
				view = {0}{90},
				scale = 1.25,
				title = {\bf Vector Field $F = [-y,x]$},
				height=7cm,
				xlabel = {$x$},
				ylabel = {$y$},
				colormap/viridis,
				colorbar,
				colorbar style = {
						ylabel = {Vector Length}
					}
				]
				\addplot3[
					point meta = {sqrt(x^2+y^2)},
					quiver = {
							u = {-y},
							v = {x},
							scale arrows = 0.25,
						},
					quiver/colored = {mapped color},
					-stealth,
					domain = -4:4,
					domain y = -4:4,
				] {0};
			\end{axis}
		\end{tikzpicture}
	\end{center}
}

\section{Gradient Vector Fields}

A \textbf{gradient vector field} $\nabla \varphi(x, y)$ is a vector field:
\[
	\vec{F}(x, y) = \nabla \varphi \quad \text{where } \varphi \text{ is a potential function.}
\]

If $\varphi$ exists, $\vec{F}$ is called a \textbf{conservative field}.

\ex{ $\varphi = -\frac{x^2 + y^2}{2}$ }{
	\[
		\vec{F}(x, y) = \nabla \varphi = \langle -x, -y \rangle
	\]
	\begin{center}
		\begin{center}
			\begin{tikzpicture}
				\begin{axis}[
					xmin = -4, xmax = 4,
					ymin = -4, ymax = 4,
					zmin = 0, zmax = 1,
					axis equal image,
					xtick distance = 1,
					ytick distance = 1,
					view = {0}{90},
					scale = 1.25,
					title = {\bf Vector Field $F = [-y,x]$},
					height=7cm,
					xlabel = {$x$},
					ylabel = {$y$},
					colormap/viridis,
					colorbar,
					colorbar style = {
							ylabel = {Vector Length}
						}
					]
					\addplot3[
						point meta = {sqrt(x^2+y^2)},
						quiver = {
								u = {x},
								v = {-y},
								scale arrows = 0.25,
							},
						quiver/colored = {mapped color},
						-stealth,
						domain = -4:4,
						domain y = -4:4,
					] {0};
				\end{axis}
			\end{tikzpicture}
		\end{center}
	\end{center}
}


\section{Line Integrals}

\subsection*{Scalar Case}
For a scalar function \( f(x, y) \), the line integral over a curve \( C \) is defined as:
\[
	A = \int_C f(x, y) \, ds
\]
where \( ds = |\mathbf{r}'(t)| dt \), with \( \mathbf{r}(t) \) being the parameterization of \( C \).

If \( \mathbf{r}(t) = (x(t), y(t)) \), then:
\[
	ds = \sqrt{\left( \frac{dx}{dt} \right)^2 + \left( \frac{dy}{dt} \right)^2} \, dt
\]

This allows us to rewrite the line integral as:
\[
	\int_C f(x, y) \, ds = \int_a^b f(\mathbf{r}(t)) |\mathbf{r}'(t)| \, dt
\]

\ex{Example: Average Temperature on a Plate}{
	Suppose we have a plate located in \( R = \{(x, y) : x^2 + y^2 \leq 4 \}\), where the temperature at any point \( (x, y) \) is \( T(x, y) = 100 (x^2 + y^2) \). Find the average temperature over the boundary of \( R \).

	\begin{enumerate}
		\item \textbf{Parameterize the Boundary:}
		      The boundary \( C \) of \( R \) is a circle of radius \( 2 \), centered at the origin. Parameterize \( C \) as:
		      \[
			      \mathbf{r}(t) = (2\cos t, 2\sin t), \quad 0 \leq t \leq 2\pi
		      \]
		      Then:
		      \[
			      |\mathbf{r}'(t)| = \sqrt{(-2\sin t)^2 + (2\cos t)^2} = 2
		      \]

		\item \textbf{Average Temperature:}
		      The average temperature is given by:
		      \[
			      \text{Average Temperature} = \frac{\int_C T(x, y) \, ds}{\int_C ds}
		      \]
		      Compute the numerator:
		      \[
			      \int_C T(x, y) \, ds = \int_0^{2\pi} 100 \cdot 4 \cdot 2 \, dt = 800\pi
		      \]
		      Compute the denominator (arc length of \( C \)):
		      \[
			      \int_C ds = \int_0^{2\pi} 2 \, dt = 4\pi
		      \]
		      Thus:
		      \[
			      \text{Average Temperature} = \frac{800\pi}{4\pi} = 200
		      \]
	\end{enumerate}
}

\subsection*{Oriented Curves}
An oriented curve \( C \) includes a direction along the curve. For example, when calculating work done by a force \( \mathbf{F} \) along a curve, the direction matters.

\ex{Example: Work}{
	Work done by a force \( \mathbf{F}(x) \) is given by:
	\[
		W = \int_a^b F(x) \, dx
	\]
	For a spring with force \( F(x) = -kx \), the work done to stretch the spring from \( x = a \) to \( x = b \) is:
	\[
		W = \int_a^b -kx \, dx = -\frac{k}{2} \left[ b^2 - a^2 \right]
	\]
}

\section{Vector Line Integrals}

\ex{Example: Earth's Gravitational Field}{
	The Earth's gravitational field exerts a force \( \mathbf{F}(\mathbf{r}) \) on an object, pulling it toward the origin. Suppose an object travels along a path \( C \). The work done by \( \mathbf{F} \) is:
	\[
		W = \int_C \mathbf{F} \cdot d\mathbf{r}
	\]
	If \( \mathbf{F}(\mathbf{r}) = \frac{-Gm}{|\mathbf{r}|^3} \mathbf{r} \), parameterize \( C \) as \( \mathbf{r}(t) \), and compute:
	\[
		\mathbf{F}(\mathbf{r}) = -\frac{Gm}{|\mathbf{r}|^3} \mathbf{r}, \quad d\mathbf{r} = \mathbf{r}'(t) \, dt
	\]
	Then:
	\[
		W = \int_a^b \mathbf{F}(\mathbf{r}(t)) \cdot \mathbf{r}'(t) \, dt
	\]

	If \( C \) is along the z-axis from \( (0, 0, 1) \) to \( (0, 0, 4) \), parameterize:
	\[
		\mathbf{r}(t) = (0, 0, t), \quad 1 \leq t \leq 4
	\]
	Then:
	\[
		W = \int_1^4 -\frac{Gm}{t^2} \cdot 1 \, dt = -Gm \int_1^4 \frac{1}{t^2} \, dt
	\]
	\[
		W = -Gm \left[ -\frac{1}{t} \right]_1^4 = -Gm \left( -\frac{1}{4} + 1 \right) = Gm \left( \frac{3}{4} \right)
	\]
}

\section{Fundamental Theorem of Line Integrals}

\thm{Fundamental Theorem of Line Integrals}{
	If \( \mathbf{F} \) is a vector field that can be expressed as \( \mathbf{F} = \nabla \phi \), then given an oriented curve \( C \) from \( P \) to \( Q \):
	\[
		\int_C \mathbf{F} \cdot d\mathbf{r} = \phi(Q) - \phi(P)
	\]
}

\ex{Example}{
	Let \( \phi(x, y, z) = \frac{-G}{\sqrt{x^2 + y^2 + z^2}} \), and \( \mathbf{F} = \nabla \phi \). Compute:
	\[
		\int_C \mathbf{F} \cdot d\mathbf{r}
	\]
	from \( (a, a, a) \) to \( (1, 1, 1) \):
	\[
		\phi(x, y, z) = \frac{-G}{\sqrt{x^2 + y^2 + z^2}}, \quad \Delta \phi = \phi(1, 1, 1) - \phi(a, a, a)
	\]
	\[
		\phi(a, a, a) = \frac{-G}{\sqrt{3a^2}} = \frac{-G}{a\sqrt{3}}, \quad \phi(1, 1, 1) = \frac{-G}{\sqrt{3}}
	\]
	Thus:
	\[
		\int_C \mathbf{F} \cdot d\mathbf{r} = \phi(1, 1, 1) - \phi(a, a, a) = \frac{-G}{\sqrt{3}} - \left( \frac{-G}{a\sqrt{3}} \right)
	\]
	\[
		= \frac{G}{\sqrt{3}} \left( 1 - \frac{1}{a} \right)
	\]
}

\section{Vector Line Integrals and Gradient Fields}

\subsection{Vector Line Integral for a Curve \( C \)}
Given a vector field \( \mathbf{F}(x, y) = (P(x, y), Q(x, y)) \) and an oriented curve \( C \), the vector line integral is defined as:
\[
	\int_C \mathbf{F} \cdot d\mathbf{r} = \int_C P \, dx + Q \, dy
\]
where:
\[
	d\mathbf{r} = (dx, dy), \quad \mathbf{F} \cdot d\mathbf{r} = P \, dx + Q \, dy.
\]

If \( C \) is parameterized as \( \mathbf{r}(t) = (x(t), y(t)) \), where \( t \in [a, b] \), then:
\[
	\int_C \mathbf{F} \cdot d\mathbf{r} = \int_a^b \mathbf{F}(\mathbf{r}(t)) \cdot \mathbf{r}'(t) \, dt = \int_a^b \left[ P(x(t), y(t)) \frac{dx}{dt} + Q(x(t), y(t)) \frac{dy}{dt} \right] dt
\]

\ex{Example: Compute a Vector Line Integral}{
	Let \( \mathbf{F}(x, y) = (x, x^2 + y) \) and let \( C \) be the curve defined by \( \mathbf{r}(t) = (t, t^2) \), where \( t \in [1, 3] \).

	\textbf{Steps:}
	\begin{enumerate}
		\item \textbf{Parameterize \( C \):}
		      From the parameterization, we have:
		      \[
			      x(t) = t, \quad y(t) = t^2, \quad \mathbf{r}'(t) = \left(\frac{dx}{dt}, \frac{dy}{dt}\right) = (1, 2t)
		      \]

		\item \textbf{Evaluate \( \mathbf{F}(\mathbf{r}(t)) \cdot \mathbf{r}'(t) \):}
		      Substitute \( x(t) \) and \( y(t) \) into \( \mathbf{F}(x, y) \):
		      \[
			      \mathbf{F}(\mathbf{r}(t)) = (t, t^2 + t^2) = (t, 2t^2)
		      \]
		      Then:
		      \[
			      \mathbf{F}(\mathbf{r}(t)) \cdot \mathbf{r}'(t) = t \cdot 1 + (2t^2) \cdot (2t) = t + 4t^3
		      \]

		\item \textbf{Compute the Integral:}
		      \[
			      \int_C \mathbf{F} \cdot d\mathbf{r} = \int_1^3 (t + 4t^3) \, dt
		      \]
		      Split the integral:
		      \[
			      \int_1^3 (t + 4t^3) \, dt = \int_1^3 t \, dt + \int_1^3 4t^3 \, dt
		      \]
		      Compute each term:
		      \[
			      \int_1^3 t \, dt = \left[\frac{t^2}{2}\right]_1^3 = \frac{9}{2} - \frac{1}{2} = 4
		      \]
		      \[
			      \int_1^3 4t^3 \, dt = 4 \left[\frac{t^4}{4}\right]_1^3 = \left[81 - 1\right] = 80
		      \]
		      Thus:
		      \[
			      \int_C \mathbf{F} \cdot d\mathbf{r} = 4 + 80 = 84
		      \]
	\end{enumerate}
}

\subsection{Gradient Fields and Fundamental Theorem of Line Integrals}
If \( \mathbf{F} \) is a gradient field, meaning \( \mathbf{F} = \nabla \phi \), then the line integral over a curve \( C \) depends only on the endpoints of \( C \). Specifically:
\[
	\int_C \mathbf{F} \cdot d\mathbf{r} = \phi(B) - \phi(A)
\]
where \( A \) and \( B \) are the start and end points of \( C \).

\textbf{Intuition:}
\begin{itemize}
	\item The integral \( \int_C \mathbf{F} \cdot d\mathbf{r} \) represents the difference in potential between the endpoints of \( C \).
	\item The path taken does not matter; only the values of \( \phi \) at \( A \) and \( B \) are relevant.
\end{itemize}

\ex{Example: Gradient Field Integral}{
	Let \( \mathbf{F} = \nabla \phi \), where \( \phi(x, y) = x^2 + xy \). Compute:
	\[
		\int_C \mathbf{F} \cdot d\mathbf{r}
	\]
	where \( C \) is any curve starting at \( A = (1, 2) \) and ending at \( B = (3, 4) \).

	\textbf{Solution:}
	\begin{enumerate}
		\item Compute \( \phi(A) \) and \( \phi(B) \):
		      \[
			      \phi(A) = (1)^2 + (1)(2) = 1 + 2 = 3
		      \]
		      \[
			      \phi(B) = (3)^2 + (3)(4) = 9 + 12 = 21
		      \]

		\item Apply the Fundamental Theorem:
		      \[
			      \int_C \mathbf{F} \cdot d\mathbf{r} = \phi(B) - \phi(A) = 21 - 3 = 18
		      \]
	\end{enumerate}
}

\section{Gradient Vector Fields and Closed Curves}

\subsection{Definition of a Closed Curve}
A curve \( C \) is said to be \textbf{closed} if its start and end points are the same, i.e., \( A = B \).

For a closed curve \( C \), the following property holds:
\[
\int_C \mathbf{F} \cdot d\mathbf{r} = 0 \quad \text{if } \mathbf{F} \text{ is a gradient vector field}.
\]

If \( \mathbf{F} = \nabla \phi \), then:
\[
\int_C \mathbf{F} \cdot d\mathbf{r} = \phi(A) - \phi(A) = 0.
\]

This implies that \textbf{the line integral of a gradient field over a closed curve is always zero}.

\subsection{How to Identify a Gradient Vector Field}
To determine whether a vector field \( \mathbf{F} = (P(x, y), Q(x, y)) \) is a gradient field:
\begin{itemize}
    \item \( \mathbf{F} \) must be defined on a region \( R \) that is \textbf{connected} and \textbf{simply connected} (no holes in \( R \)).
    \item \( P(x, y) \) and \( Q(x, y) \) must satisfy the condition:
    \[
    \frac{\partial P}{\partial y} = \frac{\partial Q}{\partial x}.
    \]
\end{itemize}

\textbf{Theorem:} If \( \mathbf{F} \) satisfies the above conditions, then \( \mathbf{F} \) is a gradient vector field, and there exists a scalar function \( \phi(x, y) \) such that \( \mathbf{F} = \nabla \phi \).

\subsection{Finding the Potential Function \( \phi(x, y) \)}
To find \( \phi(x, y) \), follow these steps:
\begin{enumerate}
    \item Check if \( \mathbf{F} \) satisfies \( \frac{\partial P}{\partial y} = \frac{\partial Q}{\partial x} \).
    \item Assume \( \phi(x, y) \) exists and satisfies:
    \[
    \frac{\partial \phi}{\partial x} = P(x, y), \quad \frac{\partial \phi}{\partial y} = Q(x, y).
    \]
    \item Integrate \( P(x, y) \) with respect to \( x \) to find a partial expression for \( \phi(x, y) \):
    \[
    \phi(x, y) = \int P(x, y) \, dx + h(y),
    \]
    where \( h(y) \) is an arbitrary function of \( y \).
    \item Differentiate the result with respect to \( y \), and equate it to \( Q(x, y) \) to find \( h'(y) \):
    \[
    \frac{\partial \phi}{\partial y} = \frac{\partial}{\partial y} \left[ \int P(x, y) \, dx + h(y) \right] = Q(x, y).
    \]
    Solve for \( h(y) \).
    \item Substitute \( h(y) \) back into \( \phi(x, y) \) to obtain the full potential function.
\end{enumerate}

\ex{Example: Finding the Potential Function}{
Given \( \mathbf{F} = (2xy, x^2 + 2y) \), determine if \( \mathbf{F} \) is a gradient field and, if so, find \( \phi(x, y) \).

\textbf{Step 1: Check the Condition.}
\[
\frac{\partial P}{\partial y} = \frac{\partial}{\partial y} (2xy) = 2x, \quad \frac{\partial Q}{\partial x} = \frac{\partial}{\partial x} (x^2 + 2y) = 2x.
\]
Since \( \frac{\partial P}{\partial y} = \frac{\partial Q}{\partial x} \), \( \mathbf{F} \) is a gradient field.

\textbf{Step 2: Integrate \( P(x, y) \) with Respect to \( x \).}
\[
\phi(x, y) = \int P(x, y) \, dx = \int 2xy \, dx = x^2y + h(y),
\]
where \( h(y) \) is an arbitrary function of \( y \).

\textbf{Step 3: Differentiate with Respect to \( y \).}
\[
\frac{\partial \phi}{\partial y} = \frac{\partial}{\partial y} \left( x^2y + h(y) \right) = x^2 + h'(y).
\]

\textbf{Step 4: Equate to \( Q(x, y) \).}
\[
x^2 + h'(y) = x^2 + 2y \quad \Rightarrow \quad h'(y) = 2y.
\]

\textbf{Step 5: Solve for \( h(y) \).}
\[
h(y) = \int 2y \, dy = y^2 + C.
\]

\textbf{Step 6: Write the Final Potential Function.}
\[
\phi(x, y) = x^2y + y^2 + C.
\]
}

\section{Non-Gradient Vector Fields and Green's Theorem}

\subsection{Non-Gradient Vector Fields}
For a vector field \( \mathbf{F} = (P(x, y), Q(x, y)) \), if:
\[
\frac{\partial P}{\partial y} \neq \frac{\partial Q}{\partial x},
\]
then \( \mathbf{F} \) is \textbf{not a gradient vector field}.

To measure the \textbf{rotation} of \( \mathbf{F} \), we compute the \textbf{curl} of \( \mathbf{F} \), defined as:
\[
\text{curl}(\mathbf{F}) = \frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}.
\]
The curl describes the tendency of \( \mathbf{F} \) to "rotate" around a point.

\ex{Example: Interpreting the Curl}{
Suppose \( \mathbf{F}(x, y) \) represents the velocity of a fluid. If:
\[
\frac{\partial Q}{\partial x} > \frac{\partial P}{\partial y},
\]
then \( \text{curl}(\mathbf{F}) > 0 \), indicating counterclockwise rotation of the fluid flow. Conversely, if:
\[
\frac{\partial Q}{\partial x} < \frac{\partial P}{\partial y},
\]
then \( \text{curl}(\mathbf{F}) < 0 \), indicating clockwise rotation of the fluid flow.

Consider a case where \( Q_x = 1 \) and \( P_y = 0 \). This means \( \text{curl}(\mathbf{F}) = 1 \), indicating counterclockwise rotation.
}

\subsection{Green's Theorem}
Green's Theorem provides a relationship between a line integral over a closed curve \( C \) and a double integral over the region \( R \) enclosed by \( C \). 

\textbf{Theorem:}
Let \( C \) be a positively oriented, simple, closed curve enclosing a region \( R \). If \( \mathbf{F} = (P, Q) \) is a continuously differentiable vector field, then:
\[
\int_C \mathbf{F} \cdot d\mathbf{r} = \int_C P \, dx + Q \, dy = \iint_R \left( \frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y} \right) \, dA.
\]

\textbf{Intuition:}
Green's Theorem states that the circulation of \( \mathbf{F} \) along the boundary \( C \) equals the sum of the curl of \( \mathbf{F} \) over the area \( R \). It connects the local rotation of \( \mathbf{F} \) (through curl) to its global behavior along the curve \( C \).

\ex{Example: Application of Green's Theorem}{
Let \( \mathbf{F} = (-3y, 3x) \), and let \( R \) be the triangle with vertices \( (0, 0), (1, 0), (0, 2) \), oriented counterclockwise. Compute \( \int_C \mathbf{F} \cdot d\mathbf{r} \) using Green's Theorem.

\textbf{Solution:}
\begin{enumerate}
    \item Compute the Curl of \( \mathbf{F} \):
    \[
    \text{curl}(\mathbf{F}) = \frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y} = 3 - (-3) = 6.
    \]

    \item Set up the Double Integral over \( R \):
    The region \( R \) is the triangle with vertices \( (0, 0), (1, 0), (0, 2) \). Its boundaries can be described by:
    \[
    0 \leq x \leq 1, \quad 0 \leq y \leq 2 - 2x.
    \]
    Using Green's Theorem:
    \[
    \int_C \mathbf{F} \cdot d\mathbf{r} = \iint_R \text{curl}(\mathbf{F}) \, dA = \iint_R 6 \, dA.
    \]

    \item Compute the Double Integral:
    \[
    \iint_R 6 \, dA = \int_0^1 \int_0^{2 - 2x} 6 \, dy \, dx.
    \]
    First, integrate with respect to \( y \):
    \[
    \int_0^{2 - 2x} 6 \, dy = 6y \Big|_0^{2 - 2x} = 6(2 - 2x).
    \]
    Now integrate with respect to \( x \):
    \[
    \int_0^1 6(2 - 2x) \, dx = \int_0^1 (12 - 12x) \, dx = \left[ 12x - 6x^2 \right]_0^1.
    \]
    Evaluate:
    \[
    \left[ 12(1) - 6(1)^2 \right] - \left[ 12(0) - 6(0)^2 \right] = 12 - 6 = 6.
    \]

    \item Final Answer:
    \[
    \int_C \mathbf{F} \cdot d\mathbf{r} = 6.
    \]
\end{enumerate}
}

\section{Line Integrals and Area}

\subsection*{Area Using Line Integrals}
For a vector field \( \mathbf{F} = (-y, x) \), the curl is given by:
\[
\text{curl}(\mathbf{F}) = \frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y} = 1.
\]
If \( C \) is a closed curve oriented counterclockwise, enclosing a region \( R \), the area of \( R \) can be computed using the following line integrals:
\[
\text{Area}(R) = \iint_R 1 \, dA = \int_C \mathbf{F} \cdot d\mathbf{r}.
\]
The parametrized curve \( C \) is expressed as \( \mathbf{r}(t) = (x(t), y(t)) \), with:
\[
\mathbf{F} \cdot d\mathbf{r} = P \, dx + Q \, dy.
\]

\subsection*{Alternative Formulas for Area}
Using line integrals:
\[
\text{Area}(R) = \int_C x \, dy = -\int_C y \, dx = \frac{1}{2} \int_C (x \, dy - y \, dx).
\]
These expressions are equivalent and depend on how \( C \) is parameterized.

\ex{Example: Area of an Ellipse}{
Consider an ellipse parameterized by:
\[
\mathbf{r}(t) = (a\cos t, b\sin t), \quad t \in [0, 2\pi].
\]
Here, \( a \) and \( b \) are the semi-major and semi-minor axes, respectively.

\textbf{Steps:}
\begin{enumerate}
    \item Compute \( x \, dy \):
    \[
    x = a\cos t, \quad dy = \frac{d}{dt}(b\sin t) \, dt = b\cos t \, dt.
    \]
    Thus:
    \[
    x \, dy = a\cos t \cdot b\cos t \, dt = ab\cos^2 t \, dt.
    \]

    \item Compute \( y \, dx \):
    \[
    y = b\sin t, \quad dx = \frac{d}{dt}(a\cos t) \, dt = -a\sin t \, dt.
    \]
    Thus:
    \[
    y \, dx = b\sin t \cdot (-a\sin t) \, dt = -ab\sin^2 t \, dt.
    \]

    \item Compute \( x \, dy - y \, dx \):
    \[
    x \, dy - y \, dx = ab\cos^2 t \, dt - (-ab\sin^2 t \, dt) = ab(\cos^2 t + \sin^2 t) \, dt = ab \, dt.
    \]

    \item Compute the Line Integral:
    \[
    \text{Area}(R) = \frac{1}{2} \int_0^{2\pi} ab \, dt = \frac{1}{2} ab \int_0^{2\pi} 1 \, dt = \frac{1}{2} ab \cdot 2\pi = \pi ab.
    \]
\end{enumerate}

\textbf{Conclusion:}
The area of the ellipse is:
\[
\text{Area}(R) = \pi ab,
\]
where \( a \) and \( b \) are the semi-major and semi-minor axes.
}

\subsection*{Summary}
The area of a region \( R \) enclosed by a curve \( C \) can be computed using line integrals in multiple equivalent ways:
\begin{itemize}
    \item Directly using \( \int_C \mathbf{F} \cdot d\mathbf{r} \), where \( \mathbf{F} = (-y, x) \).
    \item Using \( \int_C x \, dy \) or \( -\int_C y \, dx \).
    \item Using the symmetric formula:
    \[
    \text{Area}(R) = \frac{1}{2} \int_C (x \, dy - y \, dx).
    \]
\end{itemize}

\section{Flux of a Vector Field}

\subsection*{Definition of Flux}
Flux represents the flow of a vector field \( \mathbf{F} = (f, g) \) across an oriented curve \( C \). It measures how much of \( \mathbf{F} \) passes through \( C \) in the normal direction.

The flux of \( \mathbf{F} \) across \( C \) is defined as:
\[
\text{Flux} = \int_C \mathbf{F} \cdot \mathbf{n} \, ds,
\]
where:
\begin{itemize}
    \item \( \mathbf{n} \) is the unit normal vector to the curve \( C \).
    \item \( ds \) is the arc length differential.
\end{itemize}

For a parameterized curve \( \mathbf{r}(t) = (x(t), y(t)) \), where \( t \in [a, b] \), the unit normal vector is given by:
\[
\mathbf{n} = \frac{1}{|\mathbf{r}'(t)|} (-y'(t), x'(t)).
\]
Thus:
\[
\mathbf{F} \cdot \mathbf{n} = \frac{1}{|\mathbf{r}'(t)|} \left[f(x(t), y(t)) (-y'(t)) + g(x(t), y(t)) x'(t)\right].
\]



\subsection*{Flux in Simplified Form}
If the curve \( C \) is parameterized, the flux integral can be simplified as:
\[
\int_C \mathbf{F} \cdot \mathbf{n} \, ds = \int_a^b \left[f(x(t), y(t)) y'(t) - g(x(t), y(t)) x'(t)\right] dt.
\]
Or equivalently:
\[
\int_C \mathbf{F} \cdot \mathbf{n} \, ds = \int_C f \, dy - g \, dx.
\]



\subsection*{Green's Theorem Applied to Flux}
By applying Green's Theorem, the flux of \( \mathbf{F} = (f, g) \) across \( C \) can also be related to a double integral over the region \( R \) enclosed by \( C \):
\[
\int_C \mathbf{F} \cdot \mathbf{n} \, ds = \iint_R \text{div}(\mathbf{F}) \, dA,
\]
where:
\[
\text{div}(\mathbf{F}) = \frac{\partial f}{\partial x} + \frac{\partial g}{\partial y}.
\]
This shows that the flux across the boundary \( C \) is equal to the total divergence of \( \mathbf{F} \) inside \( R \).



\ex{Example: Flux Around a Circle}{
Let \( \mathbf{F}(x, y) = (x, y) \), and let \( C \) be the circle \( x^2 + y^2 = 1 \) parameterized by:
\[
\mathbf{r}(t) = (\cos t, \sin t), \quad t \in [0, 2\pi].
\]

\textbf{Step 1: Parameterize the Flux Integral.}
The unit normal vector to \( C \) is given by:
\[
\mathbf{n} = (-\sin t, \cos t),
\]
and \( \mathbf{F}(\mathbf{r}(t)) = (\cos t, \sin t) \). Then:
\[
\mathbf{F} \cdot \mathbf{n} = \cos t (-\sin t) + \sin t (\cos t) = 0.
\]

\textbf{Step 2: Apply Green's Theorem.}
Using Green's Theorem:
\[
\int_C \mathbf{F} \cdot \mathbf{n} \, ds = \int_R \text{div}(\mathbf{F}) \, dA.
\]
The divergence of \( \mathbf{F} = (x, y) \) is:
\[
\text{div}(\mathbf{F}) = \frac{\partial x}{\partial x} + \frac{\partial y}{\partial y} = 1 + 1 = 2.
\]

The area of the circle is:
\[
\text{Area}(R) = \pi \cdot 1^2 = \pi.
\]

Thus:
\[
\int_C \mathbf{F} \cdot \mathbf{n} \, ds = \int_R 2 \, dA = 2 \cdot \pi = 2\pi.
\]

\textbf{Final Answer:}
The flux across the circle is:
\[
\text{Flux} = 2\pi.
\]
}

\end{document}