Only once differentiable

Consider the Weierstrass function (https://en.wikipedia.org/wiki/Weierstrass_function); call that $f$. Define $$ F(x) = \int_0^x f(t) ~dt $$ Then $F$ is once differentiable everywhere, but twice differentiable nowhere.

I know that this includes an integral, but to be honest, it's hard to avoid that, at least if you want the derivative of your function to not only exist, but be continuous. (It doesn't have to be continuous, but writing down a function where it isn't is probably even messier...and I'm certainly not going to attempt it.)

Any function that's continuously-differentiable everywhere is expressible as an integral. And the integrand in that case, for any function that's everywhere not-twice-differentiable, must be a function that's continuous everywhere but differentiable nowhere ... and the Weierstrass function is the classic example of such a function.

Indeed, if you look carefully at that function's construction, you'll see why it's so tough to create such a thing, and recognize that this is pretty much "the easy case", believe it or not.

Small addendum

Looking back at the definition of the W-function, it's written as a series...which we can integrate term by term. So I guess my revised answer is this, using the Weierstrass function with $a = 9/10$ and $b = 7$, and eliminating an irrelevant factor of $\pi$:

Let $$ G(x) = \sum_{n=0}^\infty \frac{9^n}{10^n 7^n} \sin(7^n \pi x) $$

Then $G$ is continuous and everywhere differentiable, but nowhere twice-differentiable.

Of course, proving that $G$ is once-but-not-twice differentiable is still pretty tough ... but at least you've got a concrete answer to your question. If you read Spivak's Calculus, you can work through a very nice exposition of the Weierstrass function in one of the later chapters, and you'll be able to do the requisite proof when you're finished with that chapter.

Final Informal Remarks

Why isn't there a "simple expression" for such a function, without integrals, or infinite sums? Well, a "simple expression" (in my mind) has only finitely many operations (addition, subtraction, composition, etc.), and the building blocks we like to use are generally continuous and non-constant, and mostly (aside from $x \mapsto |x|$) differentiable. So while you can get a function that's not differentiable at a countable set of points via something like $x \mapsto |\sin(x)|$, in general such "simple expressions" will be non-differentiable on a tiny set. I suppose that with the right tools and energy you could formulate some kind of proof that finite combinations of a particular set of "basic" functions lead to non-differentiability on at most a set of measure zero. Of course, once you allow "cases" functions (like the characteristic function of the rationals), things can get far worse...but if you're hoping for a "formula" like the ones in algebra I, you're probably not going to find an everywhere-nondifferentiable function among them.


I don't think there is a really simple counterexample if you want that $f''$ exists nowhere. The Weierstraß function is a continuous function that is nowhere differentiable. Its antiderivative satisfies the desired conditions.

There are simpler examples for functions that are once differentiable, but don't have a second derivative at a single point. One such function is $f(x) = x \cdot |x|$, whose derivative $f'(x) = 2|x|$ is not differentiable at $0$.