MHB Piecewise function: differentiable but not continuously differentiable

Click For Summary
The discussion revolves around the differentiability of the piecewise function defined in two variables. The function is shown to have partial derivatives at the origin, but these derivatives are not continuous, indicating that the function is differentiable at that point but not continuously differentiable. Participants emphasize the need to verify the existence and continuity of partial derivatives in a neighborhood around the origin to establish differentiability. The conversation includes clarifications on the definitions of differentiability and continuity, as well as the necessity of calculating limits to confirm these properties. Ultimately, the conclusion is reached that while the function is differentiable at (0,0), it is not continuously differentiable due to the discontinuity of the partial derivatives.
mathmari
Gold Member
MHB
Messages
4,984
Reaction score
7
Hey! :giggle:

We have the function $$f(x,y)=\begin{cases}x^2\sin\left (\frac{1}{x}\right )+y^2\sin\left (\frac{1}{y}\right ) & \text{ if } xy\neq 0 \\ x^2\sin\left (\frac{1}{x}\right ) & \text{ if } x\neq 0, y=0 \\ y^2\sin\left (\frac{1}{y}\right ) & \text{ if } x= 0, y\neq 0 \\ 0 & \text{ if } (x,y)=(0,0)\end{cases}$$

I want to calculate the partial derivatives $\frac{\partial{f}}{\partial{x}}$ and$\frac{\partial{f}}{\partial{y}}$ for each point $(x,y)\in \mathbb{R}^2$.

For that do we have the following?
$$\frac{\partial{f}}{\partial{x}}=\begin{cases}2x\sin\left (\frac{1}{x}\right )-\cos\left (\frac{1}{x}\right ) & \text{ if } xy\neq 0 \\ 2x\sin\left (\frac{1}{x}\right )-\cos\left (\frac{1}{x}\right ) & \text{ if } x\neq 0, y=0 \\ 0 & \text{ if } x= 0, y\neq 0 \\ 0 & \text{ if } (x,y)=(0,0)\end{cases}=\begin{cases}2x\sin\left (\frac{1}{x}\right )-\cos\left (\frac{1}{x}\right ) & \text{ if } x\neq 0 \\ 0 & \text{ if } x= 0 \end{cases}$$
$$\frac{\partial{f}}{\partial{y}}=\begin{cases}2y\sin\left (\frac{1}{y}\right )-\cos\left (\frac{1}{y}\right ) & \text{ if } xy\neq 0 \\ 0 & \text{ if } x\neq 0, y=0 \\ 2y\sin\left (\frac{1}{y}\right )-\cos\left (\frac{1}{y}\right ) & \text{ if } x= 0, y\neq 0 \\ 0 & \text{ if } (x,y)=(0,0)\end{cases}=\begin{cases}2y\sin\left (\frac{1}{y}\right )-\cos\left (\frac{1}{y}\right ) & \text{ if } y\neq 0 \\ 0 & \text{ if } y= 0 \end{cases}$$
Is everything correct? Or can we not just differentiate each part of the piecewise function?

To show that $f$ is in $(0,0)$ differentiable but not continuously differentiable do we do the following?

Since we have found the partial derivatives at $(0,0)$ it follows that $f$ is differentiable in $(0,0)$.
Then we have to show that $f_x$ and $f_y$ are not continuous in $(0,0)$ which would mean that $f$ is not continuously differentiable in $(0,0)$.

Is that correct?

:unsure:
 
Physics news on Phys.org
mathmari said:
Is everything correct? Or can we not just differentiate each part of the piecewise function?
Hey mathmari!

Looks good to me. (Nod)

mathmari said:
To show that $f$ is in $(0,0)$ differentiable but not continuously differentiable do we do the following?

Since we have found the partial derivatives at $(0,0)$ it follows that $f$ is differentiable in $(0,0)$.
I'm afraid that does not follow. (Shake)
Perhaps check the propositions with respect to partial derivatives and (total) differentiability? 🤔

mathmari said:
Then we have to show that $f_x$ and $f_y$ are not continuous in $(0,0)$ which would mean that $f$ is not continuously differentiable in $(0,0)$.
If we can show the first part, then the second part does indeed follow. 🤔
 
To show that the function is diferentiable in (0,0) do we have to show that for all vectors $v=(v_x, v_y)^T$ it holds that $$\lim_{v\rightarrow 0}\frac{f(v_x, v_y)-f(0,0)-\langle \nabla f(0,0), (v_x, v_y)\rangle}{\|(v_x, v_y)\|} =0$$ and for the second part, that it is not continuous diferentiable do ee calculate the limit of the partial derivatives $$\lim_{x\rightarrow 0}f_x(x,0) \text{ and } \lim_{x\rightarrow 0}f_y(0,y) $$ ? :unsure:
 
mathmari said:
To show that the function is diferentiable in (0,0) do we have to show that for all vectors $v=(v_x, v_y)^T$ it holds that $$\lim_{v\rightarrow 0}\frac{f(v_x, v_y)-f(0,0)-\langle \nabla f(0,0), (v_x, v_y)\rangle}{\|(v_x, v_y)\|} =0$$

That is close to the definition, but let's check wiki:

A function $f$ of several real variables is said to be differentiable at a point $x_0$ if there exists a linear map $J$ such that

$$\lim_{{h}\to {0}} \frac{\|{f}({x_0}+{h}) - {f}({x_0}) - {J}{(h)}\|}{\| {h} \|} = 0.$$

The same section also lists a couple of propositions:
If a function is differentiable at $x_0$, then all of the partial derivatives exist at $x_0$, and the linear map $J$ is given by the Jacobian matrix.

If all the partial derivatives of a function exist in a neighborhood of a point $x_0$ and are continuous at the point $x_0$, then the function is differentiable at that point $x_0$.

However, the existence of the partial derivatives (or even of all the directional derivatives) does not in general guarantee that a function is differentiable at a point.
So we can use the definition and show that $J$ exists at (0,0). :unsure:

Or alternatively we can show that the partial derivatives exist in a neighborhood of (0,0) and are continuous at (0,0). 🤔

mathmari said:
and for the second part, that it is not continuous diferentiable do we calculate the limit of the partial derivatives $$\lim_{x\rightarrow 0}f_x(x,0) \text{ and } \lim_{x\rightarrow 0}f_y(0,y) $$ ?

Not quite. That is not even enough to show that $f$ is differentiable. (Shake)

Instead we can find the total derivative $Df$ of $f$ and prove that it is continuous.
That is $\lim\limits_{x\to 0} Df(x) = Df(0)$. 🤔
 
Last edited:
Klaas van Aarsen said:
Or alternatively we can show that the partial derivatives exist in a neighborhood of (0,0) and are continuous at (0,0). 🤔

For this way, do we do the following?

The set $\mathbb{R}^2\setminus \{(0,0)\}$ is open, so $f$ is continuously partially differentiable there.
Let $h \in \mathbb{R}\setminus \{0\}$ and $j \in \{1, 2\}$. Then we get \begin{equation*}\frac{f\left ((0,0)+he_j\right )-f(0,0)}{h}=\frac{f\left (he_j\right )-0}{h}=\frac{f\left (he_j\right )}{h}\end{equation*}
For $j=1$ :
\begin{equation*}\frac{f\left (he_1\right )}{h}=\frac{f\left (h(1,0)\right )}{h}=\frac{f(h,0)}{h}=\frac{h^2\sin \left (\frac{1}{h}\right )}{h}=h\sin \left (\frac{1}{h}\right )\rightarrow 0\end{equation*}
For $j=2$ :
\begin{equation*}\frac{f\left (he_2\right )}{h}=\frac{f\left (h(0,1)\right )}{h}=\frac{f(0,h)}{h}=\frac{h^2\sin \left (\frac{1}{h}\right )}{h}=h\sin \left (\frac{1}{h}\right )\rightarrow 0\end{equation*}
So $f$ is in $(0, 0)$ partially differentiable with \begin{equation*}\frac{\partial{f}}{\partial{x}}(0,0)=\frac{\partial{f}}{\partial{y}}(0,0)=0\end{equation*}
Since the partial derivatives exist in $(0,0)$ and they are continuous in that point it follows that the function is differentiable in the origin.

But $f_x$ is not continuous since $\frac{1}{n}\rightarrow 0$ but $f_x\left (\frac{1}{n}\right )=\frac{2}{n}\sin (n)-\cos (n)$ doesn't converge to $0$. So $f$ is not continuously differentiable.Is that correct? :unsure:
 
mathmari said:
For this way, do we do the following?

The set $\mathbb{R}^2\setminus \{(0,0)\}$ is open, so $f$ is continuously partially differentiable there.

How does that follow from the fact that the particular restriction of the domain is open? :unsure:

We do have that the partial derivatives that you have calculated are well defined everywhere on that open set. 🤔

mathmari said:
...
So $f$ is in $(0, 0)$ partially differentiable with \begin{equation*}\frac{\partial{f}}{\partial{x}}(0,0)=\frac{\partial{f}}{\partial{y}}(0,0)=0\end{equation*}

Yep. (Nod)

mathmari said:
Since the partial derivatives exist in $(0,0)$ and they are continuous in that point it follows that the function is differentiable in the origin.

How does that follow? :unsure:

We need to verify that the partial derivatives exist in a neighborhood of $(0,0)$. 🤔
And additionally that they are continuous in (0,0).
To verify continuity of $f_x$ in $0$, we need to verify that $\lim\limits_{(x,y)\to 0} f_x(x,y)=f_x(0,0)$. And the same for $f_y$. 🤔

mathmari said:
But $f_x$ is not continuous since $\frac{1}{n}\rightarrow 0$ but $f_x\left (\frac{1}{n}\right )=\frac{2}{n}\sin (n)-\cos (n)$ doesn't converge to $0$. So $f$ is not continuously differentiable.
Is that correct?
Yes. Moreover, $f$ is not differentiable at $0$ either. 🤔
 
Klaas van Aarsen said:
We need to verify that the partial derivatives exist in a neighborhood of $(0,0)$. 🤔

How do we show that? :unsure:
 
mathmari said:
How do we show that?

You have calculated the partial derivatives everywhere in $\mathbb R^2$, which is a neighborhood of (0,0).
They are well defined on that neighborhood.
Therefore the partial derivatives exist in a neighborhood of (0,0). 🧐
 
Klaas van Aarsen said:
And additionally that they are continuous in (0,0).
To verify continuity of $f_x$ in $0$, we need to verify that $\lim\limits_{(x,y)\to 0} f_x(x,y)=f_x(0,0)$. And the same for $f_y$. 🤔

We have that $$\lim\limits_{(x,y)\to 0} f_x(x,y)=\lim\limits_{(x,y)\to 0} \left (2x\sin\left (\frac{1}{x}\right )-\cos\left (\frac{1}{x}\right )\right )$$ But according to Wolfram this limitis indeterminate ( Wolfram ), would that mean that it is not equal to $f_x(0,0)$ ? :unsure:
 
  • #10
mathmari said:
We have that $$\lim\limits_{(x,y)\to 0} f_x(x,y)=\lim\limits_{(x,y)\to 0} \left (2x\sin\left (\frac{1}{x}\right )-\cos\left (\frac{1}{x}\right )\right )$$ But according to Wolfram this limitis indeterminate ( Wolfram ), would that mean that it is not equal to $f_x(0,0)$ ?
Indeed.
So $f_x$ is not continuous. 🤔
 
  • #11
Klaas van Aarsen said:
Indeed.
So $f_x$ is not continuous. 🤔

Ah since $f_x$ is not continuous, we get that $f$ is not continuously differentiable, right?

But how do we get that $f$ is differentiable? From post #5 we get that $f$ is partially differentiable in $(0,0)$. How do we get the differentiability?

:unsure:
 
  • #12
mathmari said:
Ah since $f_x$ is not continuous, we get that $f$ is not continuously differentiable, right?

But how do we get that $f$ is differentiable? From post #5 we get that $f$ is partially differentiable in $(0,0)$. How do we get the differentiability?
Indeed.
Suppose we go back to the definition of differentiability that I quoted in post #4. Can we use it to prove differentiability?
It means we have to do what you suggested in post #3. 🤔
 
  • #13
Klaas van Aarsen said:
Suppose we go back to the definition of differentiability that I quoted in post #4. Can we use it to prove differentiability? 🤔

Do you mean the definition with the map $J$ ? :unsure:
 
  • #14
mathmari said:
Do you mean the definition with the map $J$ ?
Yes.
And if it exists, we also know that $J$ is equal to the Jacobian matrix at (0,0), which is the same as $\nabla f(0,0)=( f_x(0,0), f_y(0,0) )$. 🤔
 
  • #15
Klaas van Aarsen said:
Yes.
And if it exists, we also know that $J$ is equal to the Jacobian matrix at (0,0), which is the same as $\nabla f(0,0)=( f_x(0,0), f_y(0,0) )$. 🤔

So do we have to check if $$\lim_{{h}\to {0}} \frac{\|{f}((0,0)+(h_1, h_2)) - {f}(0,0) - \nabla f(0,0)\|}{\| {h} \|} = 0$$ ? We have that \begin{align*}\lim_{{h}\to {0}} \frac{\|{f}(h_1, h_2) - 0 -( f_x(0,0), f_y(0,0) )\|}{\| {h} \|} &=\lim_{{h}\to {0}} \frac{\|{f}(h_1, h_2) -( 0, 0) \|}{\| {h} \|} =\lim_{{h}\to {0}} \frac{\|{f}(h_1, h_2) \|}{\| {h} \|}=\lim_{{h}\to {0}} \frac{\|h_1^2\sin\left (\frac{1}{h_1}\right )+h_2^2\sin\left (\frac{1}{h_2}\right ) \|}{\| {h} \|} \\ & =\lim_{{h}\to {0}} \frac{h_1^2\sin\left (\frac{1}{h_1}\right )+h_2^2\sin\left (\frac{1}{h_2}\right ) }{\sqrt{h_1^2+h_2^2}} \end{align*} Is that correct so far?:unsure:
 
  • #16
mathmari said:
So do we have to check if $$\lim_{{h}\to {0}} \frac{\|{f}((0,0)+(h_1, h_2)) - {f}(0,0) - \nabla f(0,0)\|}{\| {h} \|} = 0$$ ? We have that \begin{align*}\lim_{{h}\to {0}} \frac{\|{f}(h_1, h_2) - 0 -( f_x(0,0), f_y(0,0) )\|}{\| {h} \|} &=\lim_{{h}\to {0}} \frac{\|{f}(h_1, h_2) -( 0, 0) \|}{\| {h} \|} =\lim_{{h}\to {0}} \frac{\|{f}(h_1, h_2) \|}{\| {h} \|}=\lim_{{h}\to {0}} \frac{\|h_1^2\sin\left (\frac{1}{h_1}\right )+h_2^2\sin\left (\frac{1}{h_2}\right ) \|}{\| {h} \|} \\ & =\lim_{{h}\to {0}} \frac{h_1^2\sin\left (\frac{1}{h_1}\right )+h_2^2\sin\left (\frac{1}{h_2}\right ) }{\sqrt{h_1^2+h_2^2}} \end{align*} Is that correct so far?
It should be:
$$\lim_{{h}\to {0}} \frac{\|{f}((0,0)+(h_1, h_2)) - {f}(0,0) - \nabla f(0,0) \cdot (h_1, h_2)\|}{\| {h} \|} = 0$$
but otherwise it is correct since $\nabla f(0,0) = (0, 0)$. 🤔
 
  • #17
Klaas van Aarsen said:
It should be:
$$\lim_{{h}\to {0}} \frac{\|{f}((0,0)+(h_1, h_2)) - {f}(0,0) - \nabla f(0,0) \cdot (h_1, h_2)\|}{\| {h} \|} = 0$$
but otherwise it is correct since $\nabla f(0,0) = (0, 0)$. 🤔

Ah yes (Tmi)

But how can we calculate the last limit? I got stuck right now. I thought maybe taking out of the root of the denominator the term $|h_1|$ but I am not sure if that helps. :unsure:
 
  • #18
mathmari said:
But how can we calculate the last limit? I got stuck right now. I thought maybe taking out of the root of the denominator the term $|h_1|$ but I am not sure if that helps. :unsure:
Suppose we switch to polar coordinates?
That is, we substitute $h_1=r\cos\phi$ and $h_2=r\sin\phi$.
Then we can let $r\to 0$. 🤔
 
  • #19
Oh, btw, we haven't substituted $f(h_1,h_2)$ correctly. :eek:
We can't assume that $h_1h_2\ne 0$. Instead we should consider the different cases. 🤔
 
  • #20
Klaas van Aarsen said:
Oh, btw, we haven't substituted $f(h_1,h_2)$ correctly. :eek:
We can't assume that $h_1h_2\ne 0$. Instead we should consider the different cases. 🤔

Ahh ok!

For the case $h_1h_2\neq 0$ we have then that:
\begin{align*}\lim_{{h}\to {0}} \frac{h_1^2\sin\left (\frac{1}{h_1}\right )+h_2^2\sin\left (\frac{1}{h_2}\right ) }{\sqrt{h_1^2+h_2^2}}&=\lim_{{r}\to {0}} \frac{r^2\cos^2\phi\sin\left (\frac{1}{r\cos \phi}\right )+r^2\sin^2\phi\sin\left (\frac{1}{r\sin \phi}\right ) }{\sqrt{r^2\cos^2\phi+r^2\sin^2\phi}}\\ & =\lim_{{r}\to {0}} \frac{r^2\cos^2\phi\sin\left (\frac{1}{r\cos \phi}\right )+r^2\sin^2\phi\sin\left (\frac{1}{r\sin \phi}\right ) }{\sqrt{r^2\left
(\cos^2\phi+\sin^2\phi\right )}} \\ & =\lim_{{r}\to {0}} \frac{r^2\cos^2\phi\sin\left (\frac{1}{r\cos \phi}\right )+r^2\sin^2\phi\sin\left (\frac{1}{r\sin \phi}\right ) }{\sqrt{r^2}}
\\ & =\lim_{{r}\to {0}} \frac{r^2\cos^2\phi\sin\left (\frac{1}{r\cos \phi}\right )+r^2\sin^2\phi\sin\left (\frac{1}{r\sin \phi}\right ) }{r}\\ & =\lim_{{r}\to {0}}\left (r\cos^2\phi\sin\left (\frac{1}{r\cos \phi}\right )+r\sin^2\phi\sin\left (\frac{1}{r\sin \phi}\right )\right ) \end{align*} How can we continue? :unsure:
 
  • #21
The cosines and sines are bounded between -1 and +1 aren't they? 🤔
 
  • #22
So we have
$$0 \le \lim_{{r}\to {0}}\left |r\cos^2\phi\sin\left (\frac{1}{r\cos \phi}\right )+r\sin^2\phi\sin\left (\frac{1}{r\sin \phi}\right )\right | \le \lim_{r\to 0} |2r| = 0\\
\implies \lim_{{r}\to {0}}\left (r\cos^2\phi\sin\left (\frac{1}{r\cos \phi}\right )+r\sin^2\phi\sin\left (\frac{1}{r\sin \phi}\right )\right ) = 0
$$
🤔

Now let's take a step back and see if we can simplify.
We can write:
$$\lim_{h\to 0} \frac{\|f(h) - f(0,0) - \nabla f(0,0)\cdot h\|}{\|h\|} = \lim_{h\to 0} \frac{\|f(h) - 0 - (0,0)\cdot h\|}{\|h\|}
=\lim_{h\to 0} \frac{\|f(h)\|}{\|h\|}$$

and we have
\begin{align*}\|f(x,y)\| &=
\left\|\begin{cases}x^2\sin\left (\frac{1}{x}\right )+y^2\sin\left (\frac{1}{y}\right ) & \text{ if } xy\neq 0 \\ x^2\sin\left (\frac{1}{x}\right ) & \text{ if } x\neq 0, y=0 \\ y^2\sin\left (\frac{1}{y}\right ) & \text{ if } x= 0, y\neq 0 \\ 0 & \text{ if } (x,y)=(0,0)\end{cases}\right\| \\
&= \begin{cases}\left|x^2\sin\left (\frac{1}{x}\right )+y^2\sin\left (\frac{1}{y}\right )\right| & \text{ if } xy\neq 0 \\
\left|x^2\sin\left (\frac{1}{x}\right )\right| & \text{ if } x\neq 0, y=0 \\
\left|y^2\sin\left (\frac{1}{y}\right )\right| & \text{ if } x= 0, y\neq 0 \\
\left|0\right| & \text{ if } (x,y)=(0,0)\end{cases} \\
&\le\begin{cases}x^2+y^2 & \text{ if } xy\neq 0 \\
x^2 & \text{ if } x\neq 0, y=0 \\
y^2 & \text{ if } x= 0, y\neq 0 \\
0 & \text{ if } (x,y)=(0,0)\end{cases}\\
&= x^2+y^2\end{align*}
🤔
 

Similar threads

Replies
11
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K