[Math] Is it possible to create an infinitely differentiable piecewise function

calculuspiecewise-continuity

The following piecewise function is continuous, but not differentiable:
$$f(x) = \begin{cases}x, & x\leq0 \\
-x, & x\geq 0\end{cases}$$

This piecewise function is differentiable, but has a discontinuity in its second derivative:
$$g(x) = \begin{cases} 0, & x\leq0\\ x^2, & x\geq0\end{cases}$$

It seems that no matter how "smooth" a piecewise function appears to be, there will always be some discontinuity in one of its derivatives. My guess is that this is because one of the sides will drop to zero before the other, and you even end up with $0 = \text{some nonzero constant}$. (Like in my second example; the second derivative is $0$ and $2$.) If the two have the same magnitude and drop to zero at the same time, either they have a different constant $x^0$ term, meaning they are not continuous; they have a different $x^n$ term, which will eventually drop to $x^0$, resulting in the previous case; or they have no differences and it isn't really a piecewise function at all.

However, this is only valid for finite polynomials.

Is it possible to create a piecewise function so that all of its derivatives are continuous? If not, like I suspect, what are some proofs of this fact other than the outline I gave? And what does this mean for the nature of functions and continuity — it almost seems to imply that a very small section of a function can "force" the rest of the curve into a single, locked state.

Best Answer

The canonical example is the function $$f(x) = \begin{cases}e^{-\frac{1}{x}}, & x>0 \\ 0, & x\leq 0\end{cases}$$

See here for more discussion of this function.

Related Question