\section{Partial Derivatives}
In this section, we work with functions $f(x_1,...,x_n)$ of $n$ real variables. 

\begin{definition}
The \textbf{partial derivative} $f$ with respect to $x_j$ is the function $f_j (x_1,...,x_n)$ of $n$ real variables, defined via the formula
$$
f_j (x_1,...,x_n) = \lim_{h \rightarrow 0} \frac{1}{h} \Big( f(x_1,...,x_{j-1}, x_j + h, x_{j+1},...,x_n) - f(x_1,...,x_n)\Big)
$$
\end{definition}

In words, the partial derivative $f_j$ is calculated by holding all variables $x_i$ with $i \neq j$ fixed, and evaluating the (single-variable) derivative in the $x_j$ variable.  The simplest case is when $f$ is a function of two variables.

\begin{example}
Suppose that $f(x,y)$ is a function of two real variables.  Then, the partial derivatives $f_1 (x,y)$ and $f_2 (x,y)$ are
\begin{align*}
f_1 (x,y) &= \lim_{h \rightarrow 0} \frac{1}{h}(f(x+ h, y) - f(x,y)),\\
f_2 (x,y) &= \lim_{h \rightarrow 0} \frac{1}{h} (f(x, y + h) - f(x,y)).
\end{align*}
\end{example}

For the partial derivative $f_j$ to exist, the limit in the definition above has to exist.  Notice that these are \textit{single-variable limits} because all variables except the $x_j$ variable are held fixed.

It is important to realize that there are multiple ways of writing partial derivatives. For example,  if $f = f(x_1,...,x_n)$, we may write
$$
f_j (x_1,...,x_n) = \frac{\partial f}{\partial x_j} (x_1,...,x_n) = D_j f (x_1, ...,x_n) = D_{x_j} f (x_1,...,x_n).
$$
Often, if $f = f(x,y)$ is a function of $2$ variables, you will see the notation
$$
f_x (x,y) = f_1 (x,y) = \frac{\partial f}{\partial x} = \textrm{ etc.},
$$
and similarly for  functions $f(x,y,z)$ of $3$ variables. To indicate the evaluation of the derivative at a given point $(a,b)$, we will use notation such as
$$
f_x (a,b) = f_1 (a,b) = \frac{\partial f}{\partial x}(a,b)=\frac{\partial f}{\partial x}\Big|_{(x,y)=(a,b)}  = \textrm{ etc.},
$$
Most of the time, notation does not matter. However, there will be times later in this course when some choices of notation are preferable to others in terms of clarity or convenience. We will make note when such a situation arises.

\begin{example}
Consider the functions $f(x,y) = x^2 y - 3 \cos x$ and $g(x,y,z) = x e^{y z^2}$.  Then, the partial derivatives of $f$ are
$$
f_1 (x,y) = \frac{\partial}{\partial x} (x^2 y - 3 \cos x) = 2 x y + 3 \sin x
$$
$$
f_2 (x,y) = \frac{\partial}{\partial y} (x^2 y - 3 \cos x) = x^2
$$
and the partial derivatives of $g(x,y,z)$ are
$$
\frac{\partial g}{\partial x} (x,y,z) = e^{y z^2}
$$
$$
\frac{\partial g}{\partial y} (x,y,z) = xe^{y z^2} \cdot z^2
$$
$$
\frac{\partial g}{\partial z} (x,y,z) = xe^{y z^2} \cdot (2yz).
$$
Notice: to evaluate $\frac{\partial g}{\partial y}$ and$\frac{\partial g}{\partial z}$, we had to apply the Chain Rule to $e^{yz^2}$.
\end{example}

Since partial derivatives are defined as derivatives with respect to a single variable, the usual rules from single-variable calculus (sum, product, quotient, the Chain Rules) apply here as long as we are only differentiating in that one variable.


\subsection{Partial Derivatives and Continuity}  While partial derivatives follow the same single-variable differentiation rules,  there are distinct differences between partial derivatives of multivariable functions and derivatives of single-variable functions.

One stark contrast: a function $f(x_1,...x_n)$ with $n \geq 2$ can have some of its partial derivatives exist at a point $P$ in $\mathbb{R}^n$, and yet still fail to be continuous at $P$.
Why is this? Consider the case $n = 2$, so that $f = f(x,y)$.  To calculate $\frac{\partial f}{\partial x}$ and $\frac{\partial f}{\partial y}$ at $(a,b)$ in $\mathbb{R}^2$, we need only know the values $f(x,b)$ and $f(a,y)$ for $x$ ``close enough'' to $a$ and $y$ ``close enough'' to $b$.  Thus, the partial derivatives and their associated limits are defined along specific paths: the lines $(x,b)$ and $(a,y)$ in $\mathbb{R}^2$.  However, the partial derivatives provide no information about the limit $\lim_{(x,y) \rightarrow (a,b)} f(x,y)$ along other paths. For example,  the linear path $x-a=y-b$ is avoided by the limits defining $f_1$ and $f_2$. 

Let us consider an extended example to illustrate this idea.

\begin{example}
Let $f$ be the piecewise-defined function
$$
f(x,y) =
\begin{cases}
\frac{xy}{x^2 + y^2}, \quad (x,y) \neq (0,0) \\
0, \quad \quad \, \, \, \; (x,y) = (0,0)
\end{cases}
$$

We claim that
\begin{enumerate}
\item $f_1 (0,0) = f_2 (0,0) = 0$

\medskip

\item $\lim_{(x,y) \rightarrow (0,0)} f(x,y)$ does not exist.
\end{enumerate}
In particular, this means that $f$ has both partial derivatives $f_1$ and $f_2$ at the origin, and yet it is not continuous there.  
\end{example}

Let us prove each claim in the example.

\begin{proof}[Proof of Claim 1]
We show that $f_1 (0,0) = 0$. The proof of $f_2 (0,0) = 0$ is almost identical and is left to the student.

First, notice that it is \textbf{not} sufficient to differentiate $f(x,y)$ away from the origin and then evaluate at $(0,0)$.  This is due to the fact that the formula for $f$ away from the origin is not well-defined at the origin. Instead, we are forced to return to the definition of the partial derivative and the associated limit along the line $(x,y) = (x,0)$.

However,  for any point $(x,0)$ in $\mathbb{R}^2$,  we have
$$
f(x,0) =
\begin{cases}
\frac{0}{x^2 + 0^2}=0, \quad & x \neq 0 \\
0, \quad \quad \, \, \; &x = 0,
\end{cases}
$$
so that we actually have $f(x,0) = 0$ for \textbf{all} $x$ real.  Hence,
$$
\frac{\partial f}{\partial x} (0,0) = \frac{\partial}{\partial x} (0)\Big|_{x=0} = 0.
$$
If you want to be pedantic, you can show this directly from the limit definition of $f_1(0,0)$. Namely
$$
f_1 (0,0) = \lim_{h \rightarrow 0^+} \frac{1}{h}(f(h,0) - f(0,0)) = \lim_{h \rightarrow 0^+} \frac{1}{h}(0 - 0) = \lim_{h \rightarrow 0^+} 0= 0.
$$
So, $f_1 (0,0) = 0$, as claimed.
\end{proof}

\begin{proof}[Proof of Claim 2]
We show that $\lim_{(x,y) \rightarrow (0,0)} f(x,y)$ does not exist. In particular, $f(x,y)$ fails to be continuous at the origin.

To prove this,  let us consider the limit $(x,y) \rightarrow (0,0)$ along the linear path $(x, 0)$. From the first part of the formula for $f$,  when $x\neq  0$, we have
$$
f(x,0) = \frac{0}{x^2 + 0^2} = 0 \rightarrow 0 \textrm{ as } x \rightarrow 0.
$$
Now, consider the limit $(x,y) \rightarrow (0,0)$ along the linear path $(x,y) = (x,x)$ for real $x$ satisfying $x\neq 0$.  Then
$$
f(x,x) = \frac{x \cdot x}{x^2 + x^2} = \frac{1}{2} \rightarrow \frac{1}{2} \textrm{ as } x \rightarrow 0.
$$
Since the limits along different trajectories do not match, the double limit
does not exist.
\end{proof}

Another geometric perspective on the previous example comes from examining the level curves of $f(x,y)$.  Let us use the polar coordinates $(x,y) = (r \cos \theta, r \sin \theta)$; notice that $(x,y) = (0,0)$ corresponds to $r = 0$ in this coordinate system.  Then, for any $r > 0$, we have
$$
f(x,y) = f(r \cos \theta, r \sin \theta) = \frac{(r \cos \theta)( r \sin \theta)}{r^2} =  \cos \theta \sin \theta  =\frac{1}{2} \sin ( 2 \theta)
$$
and $f(0,0) = 0$.  A diagram of the level curves is given below.


\begin{figure}[H]\label{23fig1}
\centering
\includegraphics[width= .8\textwidth]{23fig1.png}
\caption{The level curves of the function $f$ defined in Example 1.4 are lines through the origin.}
\end{figure}

The partial derivatives $f_1 (0,0)$ and $f_2 (0,0)$ are based only on the information for the lines $y = 0$ and $x = 0$ (respectively).  These correspond to the bold black lines in the previous figure.


\section*{Worked Problems}

\begin{enumerate}[1.]

\item 
{\it Let $\displaystyle f(x,y)=\frac{x^3-2y^3}{x^2+4y^2}$ if $(x,y)\neq (0,0)$, and $f(0,0)=0$.
Calculate the partial derivatives of $f$ at $(0,0)$ using the definition
of partial derivatives.}

\bigskip

We have $f(x,0)=\frac{x^3}{x^2}=x$ for $x\neq 0$, and
$f(0,y)=\frac{-2y^3}{4y^2}=-\frac{y}{2}$ for $y\neq 0$. 
Hence 
$$f_1(0,0)=\lim_{h\to 0} \frac{f(h,0)-f(0,0)}{h}=\lim_{h\to 0} \frac{h-0}{h}=1,$$
$$f_2(0,0)=\lim_{h\to 0} \frac{f(0,h)-f(0,0)}{h}=\lim_{h\to 0} \frac{-\frac{h}{2}-0}{h}=-\frac{1}{2}.$$

\bigskip


\item {\it 
Let 
$$f(x,y)=\left\{\begin{matrix}
\displaystyle{\frac{xy^3}{x^2+y^2}}&\hbox{ if }(x,y)\neq (0,0)\\
0&\hbox{ if }(x,y)=(0,0)\\
\end{matrix}
\right.
$$

(a) 
Does $f$ have a limit at $(0,0)$? Justify your answer.}

\bigskip


Since $|x|\leq \sqrt{x^2+y^2}$ and $|y|\leq \sqrt{x^2+y^2}$, we have for all
$(x,y)\neq (0,0)$
$$
\left|\frac{xy^3}{x^2+y^2}\right|\leq \frac{(x^2+y^2)^2}{x^2+y^2}=x^2+y^2.
$$
Since $x^2+y^2\to 0$ as $(x,y)\to (0,0)$, the function has limit 0 at that point. 


\bigskip

{\it (b)
Find $\displaystyle{\frac{\partial f}{\partial x}(0,0)}$ and 
$\displaystyle{\frac{\partial f}{\partial y}(0,0)}$, or else explain why they do not exist.}


\bigskip

We have $f(x,0)=0$ for all $x$ and $f(0,y)=0$ for all $y$, so that 
$f_x(0,0)=0$ and $f_y(0,0)=0$.
  



\end{enumerate}

\section*{Practice Problems}
\begin{enumerate}[1.]


\item{ 
Let
$$f(x,y)=\left\{\begin{matrix}
\displaystyle{\frac{\sin^3 x}{x^2 + y^2}}&\hbox{ if }(x,y)\neq (0,0)\\[2ex]
0&\hbox{ if }(x,y)=(0,0)\\
\end{matrix}
\right.
$$
Find the first order partial derivatives of $f$ at $(0,0)$ using the definition of partial derivatives.
}


\bigskip


\item
{ Let 
$$f(x,y)=\left\{\begin{matrix}
\displaystyle{\frac{x^3+xy-y^3}{x^2+y^2}}&\hbox{ if }(x,y)\neq (0,0)\\[2ex]
0&\hbox{ if }(x,y)=(0,0)\\
\end{matrix}
\right.
$$
Find $\displaystyle{\frac{\partial f}{\partial x}(0,0)}$ and 
$\displaystyle{\frac{\partial f}{\partial y}(0,0)}$.}

\end{enumerate}





