blancmange function

There are two curious aspects to this function, and the first of these is its name. Indeed, it was this that first aroused my interest in discovering a little more about this somewhat obscure function. Sadly, the fractal nature of the graph prevents me from rendering an even remotely accurate picture of it in ASCII art, but rest assured that there is something of a similarity to a cross-section through eponymous blancmange - two smooth, curved peaks that intersect in the middle. To me, this is a function with rare beauty. It is also known as the Takagi fractal curve, although I wouldn't advocate this personally.

On the more mathematical side, this is a classic example of a pathological function, being both continuous and yet nowhere differentiable. "How can this be?" perhaps you ask. Suffice to say, there's something fractal going on here. The function is built up by an iteratedbatrachion, which tend towards the final nowhere-differentiable function.

The actual formula for these iterations is as follows: For the nth iteration, there will be N + 1 points, for N = 2n. In other words, the number of points more or less doubles with each iteration - hence by the sixth iteration, with 65 points, we have a fairly good approximation to the shape of the completed graph. For each iteration,leta run from n back to 1, in increments of -1, and b from 0 to N - 1 in increments of 2a.

Now set B( 0 ) = B( N ) = 0, "tieing" both ends of the interval 0 to N to the x-axis. Now for the calculation: