\section{More on Differentiability}
\begin{enumerate}[1.]

\item
{\it (In this question, you have to use the definitions of partial derivatives and
differentiability.) 
Let
$$f(x,y)=\left\{\begin{matrix}
\displaystyle{\frac{x^3-\sin^3 x}{x^2 + y^2}}&\hbox{ if }(x,y)\neq (0,0)\\
0&\hbox{ if }(x,y)=(0,0)\\
\end{matrix}
\right.
$$

(a) Find the first order partial derivatives of $f$ at $(0,0)$. }



\bigskip

Using that $\lim_{x\to 0}\frac{\sin x}{x}=1$, we get
\begin{align*}
f_1(0,0)&=\lim_{x\to 0} \frac{f(x,0)-f(0,0)}{x}
=\lim_{x\to 0} \frac{x^3 - \sin^3 x}{x^3}
\\
&= \lim_{x\to 0} \Big(1-\frac{\sin^3 x}{x^3}\Big) = 1-1 =0,
\\
f_2(0,0)&=\lim_{y\to 0} \frac{f(0,y)-f(0,0)}{y}
=\lim_{y\to 0} \frac{0}{y^3}=0.
\end{align*}


\bigskip

{\it (b)  Is $f$ differentiable at $(0,0)$? Prove your answer.}

\bigskip


Based on part (a), the linear approximation to $f$ at $(0,0)$ is $L(x,y)=0$.
For $f$ to be differentiable at $(0,0)$, we need
\begin{align*}
\lim_{(x,y)\to (0,0)} \frac{f(x,y)-L(x,y)}{\sqrt{x^2+y^2}}
= \lim_{(x,y)\to (0,0)} \frac{x^3-\sin^3x}{(x^2+y^2)^{3/2}}=0.
\end{align*}
We have
\begin{align*}
\lim_{(x,y)\to (0,0)} \left| \frac{x^3-\sin^3x}{(x^2+y^2)^{3/2}} \right|
\leq \lim_{(x,y)\to (0,0)} \left| \frac{x^3-\sin^3x}{x^3} \right|
\end{align*}
and that limit is $0$ as in part (a). Therefore the function is 
differentiable.


\bigskip


\item {\it 
(a) Prove that there exist positive constants $c,C$ (independent of $x,y$) such that}
 $$
 c(x^2+y^2) \leq x^2 - xy + 4 y^2 \leq C (x^2+y^2).
 $$

 
 \bigskip

Since $x^2+y^2-2xy=(x-y)^2\geq 0$, we have $-2xy\geq -(x^2+y^2)$, so that
$$
x^2 - xy + 4 y^2 \geq x^2 - \frac{x^2+y^2}{2} + 4y^2 = \frac{x^2+7y^2}{2}
\geq \frac{1}{2} (x^2+y^2).
$$
Similarly, since $x^2+y^2+2xy=(x+y)^2\geq 0$, we have $-2xy \leq x^2+y^2$, so that
$$
x^2 - xy + 4 y^2 \leq x^2 + \frac{x^2+y^2}{2} + 4y^2 = \frac{3x^2+9y^2}{2}
\leq \frac{9}{2} (x^2+y^2).
$$

\bigskip

{\it (b) 
Let 
$$f(x,y)=\left\{\begin{matrix}
\displaystyle{\frac{xy^3}{x^2- xy+ 4 y^2}}&\hbox{ if }(x,y)\neq (0,0)\\
0&\hbox{ if }(x,y)=(0,0)\\
\end{matrix}
\right.
$$
Prove that $f$ is differentiable at $(0,0)$. (Hint: You have to use the definition
of differentiability. You may also have to use the estimate from (a).) }




\bigskip

We have $f(x,0)=\frac{0}{x^2}=0$ for $x\neq 0$, and
$f(0,y)=\frac{0}{4y^2}=0$ for $y\neq 0$. 
Combining this with $f(0,0)=0$, we get $f(x,0)=0$ and
$f(0,y)=0$ for all $x,y$. Differentiating in $x$ and $y$ respectively, we get
$f_1(0,0) = f_2(0,0) =0$. Hence the linear approximation at $(0,0)$ is $L(x,y)=0$.

For differentiability, we need 
$$
\lim_{(x,y)\to(0,0)} \frac{f(x,y)-L(x,y)}{|(x,y)-(0,0)|}
= \lim_{(x,y)\to(0,0)} \frac{f(x,y)}{\sqrt{x^2+y^2}}=0.
$$
We have for $x \neq 0$, $y \neq 0$,

\begin{equation*}
\frac{f(x,y)}{\sqrt{x^2+y^2}} = \frac{xy^3}{(x^2- xy+ 4 y^2)\sqrt{x^2+y^2}}
\end{equation*}
Using the estimate from (a), we get
$$
\Bigg| \frac{xy^3}{(x^2- xy+ 4 y^2)\sqrt{x^2+y^2}}\Bigg| 
\leq 
 \Bigg| \frac{2xy^3}{(x^2+ y^2)^{3/2}}\Bigg| 
\leq 
\Bigg| \frac{2xy^3}{(y^2)^{3/2}}\Bigg| 
=2|x|\to 0
$$
as $x\to 0$.
Hence 
$\displaystyle \frac{f(x,y)}{\sqrt{x^2+y^2}} \to 0$ as $(x,y)
\to (0,0)$, so that $f$ is differentiable at $(0,0)$.

\bigskip

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

\bigskip

We have $f(x,0)=\frac{x^3}{x^2}=x$ for $x\neq 0$, and $f(0,y)=-\frac{y^3}{y^2}=-y$ for $y\neq 0$. SInce
these formulas match $f(0,0)=0$, we have $f(x,0)=x$ and $f(0,y)=-y$ for all $x,y$. Therefore
$f_1(0,0)=1$ and $f_2(0,0)=-1$.

\bigskip

{\it (b) 
Is $f(x,y)$ differentiable at $(0,0)$? Prove your answer. }

\bigskip

Let $x=y$, then $f(x,x)=\frac{2x^2}{2x^2}=1$. As $x\to 0$, this does not approach $f(0,0)=1$. This means
that $f$ is not continuous at $(0,0)$ and therefore not differentiable at $(0,0)$.

\medskip

(Note: if $f$ were continuous at $(0,0)$, this proof would not work, but that would still not mean differentiability at $(0,0)$. You would have to check the limit in the definition of differentiability.)

\bigskip



{\it \item
Let
$$f(x,y)=\begin{cases}
\displaystyle{\frac{(x-e^x+1)y^2}{x^2 + y^2}}&\hbox{ if }(x,y)\neq (0,0)\\
0&\hbox{ if }(x,y)=(0,0)\\
\end{cases}
$$
Is $f$ differentiable at $(0,0)$? Prove your answer.}

\bigskip

We start by computing $L(x,y)$, the linear approximation to $f$ at $(0,0)$. We have $f(x,0)=0$ for all $x\in\rr$, so $f_x(0,0)=0$. Similarly, $f(0,y)=0$ for all $y\in\rr$, so $f_y(0,0)=0$. Hence $L(x,y)=0$ for all $(x,y)$. To determine whether $f$ is differentiable at $(0,0)$, we need to check whether 
\begin{equation*}
\lim_{(x,y)\to(0,0)} \frac{f(x,y)}{(x^2+y^2)^{1/2}}=0.
\end{equation*}
We compute
\begin{align*}
\left| \frac{f(x,y)}{(x^2+y^2)^{1/2}} \right| &= \frac{|x-e^x+1|\,y^2}{(x^2 + y^2)^{3/2}}\\
&\le \frac{|x-e^x+1|(x^2+y^2)}{(x^2 + y^2)^{3/2}}\\
&= \frac{|x-e^x+1|}{(x^2 + y^2)^{1/2}}\\
&\le \left| \frac{x-e^x+1}{x} \right|\\
&= \left| 1 - \frac{e^x-1}{x} \right|.
\end{align*}
But
\begin{equation*}
\lim_{x\to 0} \left( 1 - \frac{e^x-1}{x} \right) = 1 - \lim_{x\to 0} \frac{e^x-1}{x} = 1 - 1 =0.
\end{equation*}
The last limit can be checked for example using l'Hopital's rule:
$$
 \lim_{x\to 0} \frac{e^x-1}{x}=  \lim_{x\to 0} \frac{e^x}{1}= e^0 = 1.
$$
By the Squeeze Theorem,
\begin{equation*}
\lim_{(x,y)\to(0,0)} \frac{f(x,y)}{(x^2+y^2)^{1/2}}=0.
\end{equation*}
Therefore $f$ is differentiable at $(0,0)$.


\bigskip


\item
{\it Let
$$f(x,y)=\begin{cases}
\displaystyle{x^2\sin(1/y)}&\hbox{ if }y\neq 0\\
0&\hbox{ if } y=0\\
\end{cases}
$$
Prove that:
\medskip

(a)   $f$ is differentiable at $(0,0)$  
(you will have to use the definition of differentiability).}

\medskip




We have $f(x,0)=\frac{0}{x^2}=0$ for all $x$ by the second part of the formula, and
$f(0,y)=0$ for $y\neq 0$ by the first part. 
Combining this with $f(0,0)=0$, we get $f(x,0)=0$ and
$f(0,y)=0$ for all $x,y$. Differentiating in $x$ and $y$ respectively, we get
$f_1(0,0) = f_2(0,0) =0$. Hence the linear approximation at $(0,0)$ is $L(x,y)=0$.

For differentiability, we need 
$$
\lim_{(x,y)\to(0,0)} \frac{f(x,y)-L(x,y)}{|(x,y)-(0,0)|}
= \lim_{(x,y)\to(0,0)} \frac{f(x,y)}{\sqrt{x^2+y^2}}=0.
$$
We have for $y \neq 0$,
\begin{equation*}
\Bigg| \frac{f(x,y)}{\sqrt{x^2+y^2}} \Bigg| = \Bigg| \frac{x^2\sin(1/y)}{\sqrt{x^2+y^2}}\Bigg| \leq 
\sqrt{x^2+y^2},
\end{equation*}
using that $x^2 \leq x^2+y^2$ and $|\sin(1/y)|\leq 1$.
Since $f(x,0)=0\leq |x|$, we actually have $|\frac{f(x,y)}{\sqrt{x^2+y^2}}|\leq \sqrt{x^2+y^2}$ for all $(x,y)$. But
$\sqrt{x^2+y^2} \to 0$ as $x\to 0$.
By the Squeeze Theorem, 
$\displaystyle \frac{f(x,y)}{\sqrt{x^2+y^2}} \to 0$ as $(x,y)
\to (0,0)$, so that $f$ is differentiable at $(0,0)$.


\bigskip

{\it (b)  $f$ is not continuous in any neighbourhood of $(0,0)$. (For every neighbourhood of $(0,0)$, prove that there is a point in that neighbourhood where $f$ is not continuous.)}

\medskip

Let $r>0$, and let $B_r=B_r(0,0)=\{(x,y): x^2+y^2<r^2$. We have to prove that there is a point in $B_r$ where $f$ is not continuous. We will show that this is true at the point $(r/2,0)\in B_r$.

Consider the limit $\lim_{(x,y)\to (r/2,0)} f(x,y)$. Along the path where $x=r/2$ and $y\to 0$, we get
$$
\lim_{y\to 0} x^2\sin(1/y) = x^2\lim_{y\to 0}\sin(1/y),
$$
but the last limit does not exist by single-variable calculus. Therefore $f$ is not continuous at $(r/2,0)$.





\bigskip

\item {\it Let
$$f(x,y)=\begin{cases}
xy &\hbox{ if }x,y \hbox{ are both rational,}\\
-xy &\hbox{ if at least one of }x,y\hbox{ is irrational.}\\
\end{cases}
$$

(a) Find all points where $f$ is continuous. Prove your answer using the epsilon-delta definition of continuity. (You may have to consider several cases separately.)}

\medskip

The function is continuous at the points $(a,0)$ and $(0,b)$ with $a,b\in\rr$ arbitrary, and is not continuous at any other points.

\medskip
\noindent
{\bf Proof that $f$ is continuous at $(a,0)$:} Let $\epsilon>0$. We have to prove that there is a $\delta>0$ such that
$$
\sqrt{(x-a)^2+y^2}< \delta \ \ \Rightarrow \ \ |f(x,y)-f(a,0)|<\epsilon.
$$
We have $f(a,0)=0$, regardless of whether $a$ is rational or not, and
$$
|f(x,y)-f(a,0)|=|f(x,y)|=|xy|.
$$
Let $\sqrt{(x-a)^2+y^2}< \delta$, with $\delta>0$ to be chosen in a moment. Then $|y|<\delta$ and $|x-a|<\delta$ so that $|x|< |a|+\delta$.
Therefore 
$$
|xy|\leq (|a|+\delta)\delta .
$$
\begin{itemize}
\item If $a=0$, let $\delta =\sqrt{\epsilon}$, then $|xy|<\delta^2=\epsilon$, so we have a $\delta>0$ that works in this case. 
\item If $a\neq 0$, let $\delta=\min(|a|,\epsilon/2|a|)$. Then
$$
|xy|< (2|a|)(\epsilon/2|a|)=\epsilon,
$$
and we are also done in this case.
\end{itemize}

\medskip
\noindent
{\bf Proof that $f$ is continuous at $(0,b)$:} since $f(x,y)=f(y,x)$, the proof is identical to the above.


\medskip
\noindent
{\bf Proof that $f$ is not continuous at $(a,b)$ with $a\neq 0$ and $b\neq 0$:} We will use that any neighbourhood of $(a,b)$ contains both points $(x,y)$ with $x,y$ rational and $(x,y)$ with $x,y$ irrational. To prove this, let $r>0$. Each of the intervals $(a-r/2,a+r/2)$ and $(b-r/2,b+r/2)$ contains both rational and irrational points. Therefore the square
$$
Q_r=(a-r/2,a+r/2)\times (b-r/2,b+r/2)
$$
contains both points $(x,y)$ with $x,y$ rational and $(x,y)$ with $x,y$ irrational. But $Q_r\subset B_r(a,b)$, because for $(x,y)\in Q_r$ we have
$$
\sqrt{(x-a)^2+(y-b)^2}\leq \sqrt{(r/2)^2+(r/2)^2} = \sqrt{r^2/2}=\frac{r}{\sqrt{2}}<r.
$$
Let $\epsilon=|ab|>0$, and let $\delta>0$. Let $r=\min(\delta,|x|,|y|)$.
\begin{itemize}
\item If $a,b$ are both rational, choose a point $(x,y)\in B_r(a,b)\subseteq B_\delta(a,b)$ such that $x,y$ are both irrational. Then $f(a,b)=ab\neq 0$, and $f(x,y)=-xy$ has the opposite sign from $f(a,b)$, so that $|f(x,y)-f(a,b)|\geq |f(a,b)|=\epsilon$.

\item Similarly, if at least one of $a,b$ is irrational, choose a point $(x,y)\in B_r(a,b)\subseteq B_\delta(a,b)$ such that $x,y$ are both rational. Then $f(a,b)=-ab\neq 0$, and $f(x,y)=xy$ has the opposite sign from $f(a,b)$, so that $|f(x,y)-f(a,b)|\geq |f(a,b)|=\epsilon$.
\end{itemize}




\medskip




{\it (b)  Find all points where $f$ is differentiable. Prove your answer. (You may have to consider several cases separately, and you will have to use the definition of differentiability at least once. Epsilon-delta proofs are not required in this part, but may be useful depending on how you solve the question.)}

\medskip

If $f$ is not continuous at $(a,b)$, then it is not differentiable at $(a,b)$. Therefore $f$ is not differentiable at any $(a,b)$ with $a\neq 0$ and $b\neq 0$.

At points $(a,0)$ and $(0,b)$ with $a,b\in\rr$, we have to do some further testing. Since $f(x,y)=f(y,x)$, we will focus on the points $(a,0)$, and then switch the variables to get the answer for $(0,b)$.
We first note that $f(x,0)=0$ for all $x$, so that $f_1(a,0)=0$. For the rest of the calculation, we
consider the following cases.

\begin{itemize}
\item If $a$ is rational but $a\neq 0$, we try to evaluate $f_2(a,0)$:
\begin{align*}
f_2(a,0)&= \lim_{h\to 0} \frac{1}{h}(f(a,h)-f(a,0))\\
&= \lim_{h\to 0} \frac{1}{h}f(a,h)\\
&= \lim_{h\to 0} \frac{1}{h}\begin{cases}
ah & \hbox{ if }h \hbox{ is rational},
\\
-ah & \hbox{ if }h \hbox{ is irrational}
\end{cases}
\\
&= \lim_{h\to 0} \begin{cases}
a & \hbox{ if }h \hbox{ is rational},
\\
-a & \hbox{ if }h \hbox{ is irrational}.
\end{cases}
\end{align*}
This limit does not exist, hence $f$ is not differentiable here.

\item If $a$ is irrational, we have
\begin{align*}
f_2(a,0)&= \lim_{h\to 0} \frac{1}{h}(f(a,h)-f(a,0))\\
&= \lim_{h\to 0} \frac{1}{h}f(a,h)\\
&= \lim_{h\to 0} \frac{-ah}{h}=-a.
\end{align*}
Therefore the tentative linear approximation is $L(x,y)=0+0\cdot (x-a)+(-a)y=-ay$. We check the differentiability condition. Consider the limit 
\begin{align*}
\lim_{
(x,y)\to (a,b)}
 \frac{|f(x,y)-L(x,y)|}{\sqrt{(x-a)^2+y^2}}
&= \lim_{(x,y)\to (a,b)}
 \frac{|xy+ay|}{\sqrt{(x-a)^2+y^2}}\\
 &= \lim_{(x,y)\to (a,b)}
 \frac{|x+a||y|}{\sqrt{(x-a)^2+y^2}}.
\end{align*}
Let $x,y$ be rational numbers such that $0<y<|a|/2$ and $|x-a|<y$. Then
$$
|x+a|=|(x-a)+2a|\geq |2a|-|x-a|\geq |2a|-|y|\geq 3|a|/2
$$
and
$$
\sqrt{(x-a)^2+y^2}\leq\sqrt{y^2+y^2}=\sqrt{2}\,y,
$$
so that
$$
 \frac{|x+a||y|}{\sqrt{(x-a)^2+y^2}}
 \geq \frac{(3|a|/2)y}{\sqrt{2}\,y}=\frac{3|a|}{2\sqrt{2}}.
$$
Therefore the limit as $(x,y)\to (0,0)$ is not 0, and the function is not differentiable here.

\item Finally, let $a=0$. Since $f(x,0)=f(0,y)=0$, we have $f_1(0,0)=f_2(0,0)=0$ and $L(x,y)=0$. We check the differentiability condition:
\begin{align*}
\lim_{(x,y)\to (a,b)}
 \frac{|f(x,y)-L(x,y)|}{\sqrt{x^2+y^2}}
&= \lim_{(x,y)\to (a,b)}
 \frac{|xy|}{\sqrt{x^2+y^2}}\\
&= \lim_{(x,y)\to (a,b)}
 |x| \frac{|y|}{\sqrt{x^2+y^2}}\\
&\leq  \lim_{(x,y)\to (a,b)}
 |x| =0.
 \end{align*}
The function is differentiable here.
\end{itemize}

Hence $f(x,y)$ is differentiable at $(0,0)$.





\end{enumerate}
