# Is it possible to create an infinitely differentiable piecewise function?

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.

• In the complex plane things are close to what you are imagining. If a function is differentiable once it is differentiable infinitely many times, it is equal to its Taylor series out to the radius of convergence, etc. In the reals, all bets are off, as the classic bump function demonstrates – Ross Millikan May 10 '17 at 4:53

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