# Why isn't the Weierstrass function $\sum_{n=0}^\infty a^n \cos(b^n\pi x)$ differentiable?

There is a famous example of a function that has no derivative: the Weierstrass function:

But just by looking at this equation - I can't seem to understand why exactly the Weierstrass Function does not have a derivative?

I tried looking at a few articles online (e.g. https://www.quora.com/Why-isnt-the-Weierstrass-function-differentiable), but I still can't seem to understand what prevents this function from having a derivative?

For example, if you expand the summation term for some very large (finite) value of $$n$$: $$f(x) = a \cos(b\pi x) + a^2\cos(b^2\pi x) + a^3\cos(b^3\pi x) + ... + a^{100}\cos(b^{100}\pi x)$$ What is preventing us from taking the derivative of $$f(x)$$? Is the Weierstrass function non-differentiable only because it has "infinite terms" - and no function with infinite terms can be differentiated?

For a finite value of $$n$$, is the Weierstrass function differentiable?

Thank you!

• Any truncated version of the series will be differentiable (it is a finite sum of differentiable functions). There are many examples where infinite function series are differentiable (analytic functions for example). If you assume for example $ab<1$ for the Weierstrass function instead of $ab>1+\frac{3\pi}{2}$, it will be differentiable.
– Gary
Jan 17, 2022 at 5:43
• The finite series is differentiable everywhere as a finite sum of differentiable terms. The infinite series clearly converges absolutely when $0<a<1$ as each term is less than $a^n$ and you can compare to a geometric series. But the derivative of each term is $-(ab)^n \pi \sin(b^n \pi x)$ and that can cause problems when $ab>1$. On the face of it, there is the question of what happens when $x=0$ (or any integer) and that is a deeper question leading to the $ab>1+\frac{3\pi}{2}$ requirement Jan 18, 2022 at 9:18

Nothing is preventing us from taking the derivative of any finite partial sum of this series. This is a trigonometric polynomial and it has derivatives of all orders.

However, this infinite sum represents the pointwise limit of such trigonometric polynomials. A pointwise limit of differentiable functions has no obligation to be differentiable.

On the other hand, the sheer fact that this function is an infinite sum doesn’t automatically imply that it’s nowhere differentiable. An infinite power series or infinite trigonometric series may be differentiable everywhere, differentiable nowhere, or differentiable in some places and not others.

To check if a function is differentiable at a point $$x_0$$, you must determine if the limit $$\lim_{h\to 0}(f(x_0+h)-f(x_0))/h$$ exists. If it doesn’t, the function isn’t differentiable at $$x_0$$.

There are various theorems which help us bypass the need for doing this directly. For example, we can show that the composition of differentiable functions is differentiable, and that various elementary functions are differentiable everywhere, which lets us conclude that things like $$\cos(17x^2)-e^x$$ are differentiable everywhere.

One of these shortcuts applies when you have infinite sums with uniformly convergent derivatives. This very important result allows us to conclude that many functions defined by infinite series do indeed have derivatives, and those derivatives are what you’d expect. But this doesn’t apply here, since this sum does not have uniformly convergent derivatives.

And once again, this fact alone isn’t enough to show that the function is nowhere differentiable. To show that, you have to roll up your sleeves and work out inequalities that apply everywhere and prevent the limit above from existing. This is done carefully here, for example.

As other answers have pointed out, while the partial sums of the function converge, the partial sums of the derivatives do not. To see this, I just did a quick calculation. Let $$f_m(x)$$ be the partial sums, $$f_m(x) = \sum_{n=0}^m a^n \cos(b^n \pi x)$$ For the first few partial sums with $$a=0.6$$ and $$b=7$$ it looks like

Let's look at the convergence at a few select points, arbitrarily chosen

We see it fairly rapidly converges to the asymptotic values. Taking these same points, let's look at the convergence of the first derivative, $$f'_m(x)$$. I'm going to plot the absolute value so you can see what's going on (note the logarithmic scale on the vertical axis)

Clearly the partial sums of the first derivatives do not converge! In fact they diverge exponentially fast.

• The parameters you have chosen do not meet the condition $ab > 1+ \frac{3}{2} \pi$, so the function you are working with is smoother (and potentially differentiable, but I doubt it) than the intended function(s). On the other hand, the graph in OP's image has $a = 1/2$, $b = 3$, so is also tamer than the intended functions. Jan 18, 2022 at 17:03
• @kai This fails to answer the question "WHY?" Jan 18, 2022 at 20:18

In order to calculate the derivative of a function at a given point (e.g. $$x=0$$), you just need to keep zooming on this point until the curve gets smooth:

Oh, wait...

• This is a good visual explanation. Fractal it is! Jan 18, 2022 at 23:58

It's not that it is an infinite sum, any analytic function can be written as an infinite sum by definition and is differentiable.

The issue is that the function has the nature of a fractal, at every zoom level it continues have sharp changes in direction. So yes, at any finite level you can take a derivative at most points, because a finite level doesn't have the infinite zoom that prevents a local derivative from existing.

Remember, the derivative is a local existence of a limit, $$f(x)$$ is differentiable at $$a$$ if for some small neighborhood around $$a$$,

$$\frac {f(x)-f(a)}{x-a}$$

stays close to a value. But this function will obtain all different kinds of slopes in any tiny neighborhood...you just have to zoom in far enough to see the jagged behavior.

While others have given answers saying that a pointwise limit of differentiable functions needn’t be differentiable, here is a simple example explaining why that is true.
One can find a limit of smooth functions which converge to the absolute value function which is not differentiable at $$0$$, as shown by the following image:

The value of an infinite series is defined to be the limit of the values of its partial sums: $$\sum_{n=0}^\infty f(n) = \lim_{N \rightarrow \infty} \sum_{n=0}^N f(n) \text{.}$$ so the right thing to do when trying to understand the convergence of the given series and its termwise derivative is to look at what the partial sums do as we add more and more terms.

Let's do that. Let's pick $$a = 1/2$$ and $$b = 13$$ (the smallest odd integer that satisfies $$ab > 1 + \frac{3}{2}\pi$$). (Aside: the image in your question has $$a = 1/2$$, $$b = 3$$, so is a picture of a much too tame function.) Let's define $$W_N = \sum_{n=0}^N (1/2)^n \cos( 13^n \pi x) \text{,}$$ the sum of the first $$N$$ terms. Also, since $$W_N$$ is a finite sum, we can find its derivative by differentiating term-by-term. (This doesn't always work for infinite sums because the (outside) limit for the derivative and the (inside) limit for the sum don't necessarily commute -- swapping the order of the limits can give different results. So more care must be taken when that happens.) $$W_N' = -\sum_{n=0}^N (1/2)^n 13^n \pi \sin(13^n \pi x)$$

Before we go to pictures, let's take a second to see what is already present. In $$W_N$$, the coefficient of the trig function is $$(1/2)^n$$. Since $$0 < a < 1$$, successive powers of $$a$$ get smaller -- successive cosines mix in with smaller and smaller amplitudes. Every time we increment $$N$$, the new term is dwarfed by each preceding term, so it's plausible that the function given by the sequence of partial sums settles into some limit function by making smaller and smaller adjustments as we add more terms.

However, the coefficients of the sines in $$W_N'$$, $$(13/2)^n\pi$$, are increasing faster than the powers of $$\left(1 + \frac{3}{2}\pi\right) = 5.7123{\dots}$$. This means each new sinusoid has amplitude at least 5-times larger (in fact, $$13/2$$-times larger) than the preceding one -- every time we increment $$N$$, the new term dwarfs the sum of all the preceding terms. This means the $$W_N'$$ do not settle in towards some function; instead oscillating with rapidly greater amplitude and frequency, failing to settle toward a limit.

Here's $$W_5(x)$$ on $$[-3/2,3/2]$$ and then on $$[0,1/25\,000]$$ (to show the contribution from the last term).

Now let's look at $$W_5'$$ on the same intervals.

We see that the narrow wiggles caused by the fifth term in the series are producing derivatives that flail from $$-40\,000$$ to $$40\,000$$ everywhere, with tiny variations from the previous terms.

Let's get the same four pictures for six terms.

For the function, $$W_6(x)$$, the sixth term adjusted the function values by $$\pm 0.02$$ or less. For the derivative, the narrow ripples now have the derivative flailing from almost $$-300\,000$$ to almost $$300\,000$$ with very high frequency.

And the pattern continues as we take more terms -- $$W_N$$ approaches a continuous function and $$W_N'$$ tries harder and harder to make its graph go through every point on the plane.

The basic concept used in constructing the Weierstrass function is that when you have $$\sum r^n$$, this converges for $$|r|<1$$ and diverges for $$|r|\ge1$$. So if you can get a function that involves $$\sum r^n$$ with $$|r|<1$$, and whose derivative increases $$|r|$$ above $$1$$, then the derivative will diverge.

When we take the derivative of $$a^n\cos(b^n\pi x)$$, we get $$-a^nb^n\pi\sin(b^n\pi x)$$, or $$-(ab)^n\pi\sin(b^n\pi x)$$. So before the derivative, our $$r$$ is $$a$$, but after the derivative it's $$ab$$. So ignoring the trigonometric functions, if $$|a|<1$$ and $$|ab|\ge1$$, the function converges and the derivative diverges. The trigonometric functions complicate it somewhat, making us need $$|ab|$$ to be greater than $$1+\frac 32 \pi$$, but the basic idea survives.

Merely having a function defined in terms of an infinite series doesn't mean that we can't take the derivative, it simply introduces the issue that the derivative might not converge. There are plenty of these functions that we can take the derivative of; if you've seen Taylor or Fourier series, you'll see plenty of examples of functions with well-defined derivatives. For instance, the derivative of $$e^{2x}=\sum_{n=0}^{\infty}\frac{(2x)^n}{n!}$$ is $$\sum_{n=0}^{\infty}\frac{2(2x)^n}{n!}=2e^{2x}$$.

If you take the derivative of a sawtooth wave, you get a square wave. Both of these waves have Fourier series, but the Fourier series for the square wave has repeated discontinuities. Each of these discontinuities are just points, and the derivative is still well-defined in the intervals between them. You can think of the Weierstrass function as being similar to a sum of an infinite number sawtooth waves, so that each interval, no matter how small, contains a point where the at least one of the sawtooth waves has a derivative that doesn't converge, and thus the derivative doesn't exist anywhere.