Looking for a function $f$ that is $n$-differentiable, but $f^{(n)}$ is not continuous

I am looking for a real valued function of real variable that is $n$-differentiable, but whose $n$th derivative is not continuous.

This is my function: $f_n(x) = x^{n+1} \cdot \sin{\frac{1}{x}}$, if $x \neq 0$ and 0, if $x=0$. $n\in \{0,1,2,\ldots\}$ For example, if $n=0$, $f_0$ it's continuous and non diferentiable in $0$.


Once you do it for the first derivative, indefinitely integrate $n-1$ times. Your original function is continuous (since differentiable), so it is integrable.


Let $n$ be a positive integer and let

$$f(x) = x^{2n} \cdot \sin\left(\frac{1}{x}\right)$$ $$f(0) = 0$$

Then mathematical induction can be used to prove: (a) The $n$th derivative of $f(x)$ exists for each value of $x$. (b) The $n$th derivative $f(x)$ is not continuous at $x = 0$.

Let $n$ be a positive integer and let

$$g(x) = x^{2n+1} \cdot \sin\left(\frac{1}{x}\right)$$ $$g(0) = 0$$

Then mathematical induction can be used to prove: (a) The $n$th derivative of $g(x)$ is continuous at each value of $x$. (b) The $(n+1)$st derivative of $g(x)$ does not exist at $x = 0$.

More generally, let $a$, $b$ be positive real numbers, let $n$ be a positive integer, and define $h(x)$ by:

$$h(x) = x^a \cdot \sin\left(\frac{1}{x^b}\right)$$ $$h(0) = 0$$

  1. The $n$th derivative of $h(x)$ exists for all values of $x$ if and only if $a > n + (n-1)b$.

  2. The $n$th derivative of $h(x)$ is bounded on every bounded interval if and only if $a \geq n + nb$.

  3. The $n$th derivative of $h(x)$ is continuous at each point if and only if $a > n + nb$.

To prove these statements, you can use mathematical induction to prove that the $n$th derivative of $h(x)$ has the form

$$P_{n}(x) \cdot \cos\left(\frac{1}{x^b}\right) + Q_{n}(x) \cdot \sin\left(\frac{1}{x^b}\right),$$

where $P_n$ and $Q_n$ are polynomials such that at least one of them has a lowest degree term that is a NONZERO multiple of $x^{a-n-nb}$ and neither has a lower degree term. [The added emphasis on nonzero is because this becomes vital for the "only if" halves of the statements above.] To prove the "if" halves, you may want to incorporate into the induction statement the fact that the $n$th derivative at $x = 0$ is zero.


I think you want $f_n(x) = x^{2n} \sin(1/x)$.


Your function works for $n=1$ but not for $n=2$.

For $n=1$, the function is everywhere differentiable, and it holds $f'_1(x) = 2x \sin(1/x) - \cos(1/x)$ for $x \neq 0$, and $f'_1 (0) = 0$; hence $f'_1 $ is not continuous at $0$.

For $n=2$, on the other hand, the function is everywhere differentiable but not twice differentiable on $\mathbb{R}$. Indeed, $f'_2$ is given by $$ f'_2 (x) = 3x^2 \sin (1/x) - x\cos (1/x),\;\; x \neq 0, $$ and $$ f'_2 (0) = 0. $$ However, for $h \neq 0$, $$ \frac{{f'_2 (h) - f'_2 (0)}}{{h - 0}} = \frac{{3h^2 \sin (1/h) - h\cos (1/h)}}{h} = 3h\sin (1/h) - \cos (1/h). $$ So, letting $h \to 0$, this shows that $f'_2$ is not differentiable at $0$. Hence $f_2$ is not twice differentiable.