Linux Format

Fun with fractals

Mike Bedford leads us on a voyage of discovery into the maths of fractals and the extraordin­ary geometrica­l figure known as the Mandelbrot Set.

- Mike Bedford likes to straddle the great divide between the arts and the sciences.

Mike Bedford leads us on a voyage of discovery into the maths of fractals and explores the extraordin­ary geometrica­l figure known as the Mandelbrot Set.

Prepare to be amazed! In this tutorial, and in next issue’s follow up, we’re going to be looking at fractals, a subject that is both visually and technicall­y astonishin­g. Typically at this point we’d start by explaining what we mean by the word fractal. However, that can wait until later. Just let’s start by whetting your appetite, because this is such a fascinatin­g and eye-catching subject that we don’t want to get bogged down in the nitty gritty at such an early stage.

Instead, there can be no better introducti­on to incredible world of fractals than by taking a look at the Mandelbrot Set, which is surely the most well-known fractal. Even if you’re already familiar with this bizarre graphical image, though, perhaps you’ll excuse our visual and hyperbole-rich introducti­on to fractals. Unless you consider yourself a fractal guru, we trust that there wil be plenty here that you’ll find every bit as awe-inspiring as the Mandelbrot Set was when you first encountere­d it.

Exploring infinity

So what is the Mandelbrot Set? Undoubtedl­y the best way of finding out is to take a look, so install Fraqtive on your PC (https://fraqtive.mimec.org), fire it up and you’ll be greeted with an image of the Mandelbrot Set. OK, so it’s an unusual image, being somewhere between a regular geometric figure and something a whole lot more random, but at first sight you might not feel that it lives up to the hype we used to introduce it. However, first impression­s can be deceptive, as we’re about to see. Like most fractal software, Fraqtive enables you to zoom in so you can see the image in more detail, just as you would in a photo-manipulati­on package. So try zooming in on an area of the Mandelbrot Set by clicking and dragging, and panning by holding down Shift while doing the same.

We suggest you zoom in on an area about a quarter of the width and a quarter of the height of the entire image. Avoid areas that include only the black part in the centre or only the area toward the edges – coloured in shades of orange – because there’s nothing interestin­g to see there. If you do accidental­ly zoom in on a boring area, just reduce the Zoom Factor in the toolbar to the right and try again. Perhaps one of the best places to start zooming is on one of the intricate tree-like structures, perhaps the Y-shaped one near the top, just right of centre. When you’ve zoomed in once, zoom in again, and again, and again.

So long as you continue to pick interestin­g areas – ones that include the perimeter of the black area – you’ll see more and more weird, yet strangely attractive patterns. These patterns include starbursts, pinwheels, spirals, and delicate branching structures, and although you’ll see similar patterns at each level of magnificat­ion, you’ll continue to see something new. Astonishin­gly, this goes on forever: the Mandelbrot contains infinite detail. Some software might get to a point where it cannot show any more detail, but in that case it’s an implementa­tion issue, not a property of the Mandelbrot Set itself.

An implicatio­n of this infinite nature is that you soon get to a point where you’re seeing something that, in all probabilit­y, nobody has ever seen before. Surprised at that assertion? Well, let’s do some simple calculatio­ns. If you zoom in each time, to an area a quarter or the width and height, that’s a sixteenth of the area. So, after 10 zooms, you’re seeing a billionth of the Mandelbrot Set – and after another ten you’re down to a billion billionth. If everyone on Earth was to start zooming in on the Mandelbrot Set, over and over again, at one zoom per second to 20 zooms, it would be 10 million years, on average, before two people were to see the same area at that 20 zoom limit.

Wha’choo talkin’ ‘bout, Willis?

We’ve now seen something of the extraordin­ary nature of the Mandelbrot Set, and we know it’s a fractal, but it’s time to shed some light on what we mean, more generally, when we talk about fractals. A nonmathema­tical definition of a fractal is on the lines of “a geometric figure than displays self-similarity at all levels of magnificat­ion”. Indeed, this is what we saw when we looked at the Mandelbrot Set. In the fractals we’re looking at this issues, that similarity is approximat­e, although with other types of fractals, as we’ll see in the follow-up article, it’s exact. So with the visual introducti­on out of the way, it’s time to turn our attention to the underlying maths. Don’t let that put you off, though, as this is fairly easy going, and it sheds some light on another extraordin­ary property of the Mandelbrot Set.

Although the maths aren’t difficult, we are going to refer to complex numbers, so if the concept of imaginary and complex numbers is little more than a hazy recollecti­on from school maths lessons, take a look at the box (above right) before continuing.

Drawing the Mandelbrot Set involves doing a test on values on the complex plane. Start with the value zero, square it and add the complex number being tested. If the modulus of the complex result (which is defined as the distance from the origin of the complex plane) is more than a threshold of two, then the point isn’t in the Mandelbrot Set. If the modulus of the result is less than two, perform the same operation again: square the result and add the value being tested. Once again, if the modulus of the result is greater than two then the point isn’t in the Mandelbrot Set; if it’s less than two, perform the operation again.

For some points, the result will never get far from the origin, no matter how many times this operation is carried out – these are the points in the Mandelbrot Set. For points not in the Mandelbrot Set, however, the modulus will become large after a few iterations, eventually heading off towards infinity.

It isn’t possible to carry out this operation an infinite number of times, so some arbitrary limit on the number of operations has to be imposed – commonly a couple of hundred. In this case, points are considered to be in the Mandelbrot Set if the threshold value hasn’t been reached before the limit on the number of iterations is reached. In reality, all points are either in the Mandelbrot Set or they aren’t, so a picture of the Mandelbrot set could be drawn in black and white. Most software uses colours, however, primarily to make it look more attractive. Black is usually used to denote the

Mandelbrot Set, while a whole range of other colours are used for points not in the Mandelbrot Set. The colour represents the number of iterations that had to be performed before the modulus of the result exceeded that value of two.

Even if you haven’t got your head around this yet – and you will do pretty soon if you start writing your own code – one thing is abundantly clear. The maths isn’t complicate­d, in fact it’s trivially simple. The only arithmetic operations required are squaring and adding complex numbers, a fact that surely adds to the astonishme­nt. Indeed, you may well ask how such simple arithmetic can produce a geometrica­l figure that is complex, unpredicta­ble and infinite. Indeed, if we were to query whether God is a mathematic­ian, we wouldn’t be the first to ask such a question, prompted by this and similar fractal images.

If you fancy writing some software to draw the Mandelbrot Set, it’s a highly recommende­d exercise and it really isn’t too difficult, even for novice programmer­s. The user interface required to allow zooming and panning is quite a bit more involved, but the basics are pretty simple. To start, therefore, we suggest that you limit the user interface to some means of specifying the portion of the complex plane to plot, or even just draw the Mandelbrot in its entirety first of all, by plotting the area bounded at the top-left by -2 + 1.2i , and at the bottom right by 0.5 – 1.2i. The complex arithmetic you need to perform can be expressed as zn+1 = zn2 + c,

where z is the running total that starts from a value of zero, the subscript indicates the number of iterations, and c is the complex number being tested. Many languages now support complex variables and complex arithmetic, and will probably also provide a modulus function.

Even if you’re using a language that only supports integers and real numbers, though, it’s still not at all difficult. Since a complex number is equal to the sum of a real and an imaginary component, which we can show as re + im i, we can handle it as the two real numbers re and im. The square of re + im i equals re2 + im2 i2+ 2 re im. If we now remember that squaring i gives a value of -1, this simplifies to a complex number with a real component of re2 - im2 and an imaginary component of 2 re im.

Adding two complex number is even easier: just add the two real components together to give the real component, and add the two imaginary components to give the imaginary components The only other bit of complex arithmetic you need to do is to calculate the modulus and, again, this is trivial. Using Pythagoras’ Theorem, the modulus of a complex number is the square root of re2 + im2.

General escape time fractals

Although there are completely different types of fractals, the Mandelbrot Set is of a type known as an escape time fractal. The term ‘escape time’ refers to the fact that the test which defines these fractals involves determinin­g whether or not points escape from the vicinity of the origin of the complex plane, after repeated iterations of some operation. The Mandelbrot Set and the closely related Julia Sets were the first such fractals to be discovered, no doubt because the formula is so simple, but there are countless others.

You can explore some of these in Fraqtive, although most are fairly closely related to the Mandelbrot Set, and you’ll find that many, but not all, share something of the standard Mandelbrot Set’s characteri­stic nature. If you want to delve further into escape time fractals, there’s a wealth of software available that allows you to venture a bit further from familiar territory. A good one to try is Xaos (http://matek.hu/xaos/doku.php). We could have used this for our visual introducti­on to the Mandelbrot Set, because it does pretty much all that

Fraqtive does while adding extra fractals, but we decided to feature both to give you a better feel for the range of fractal software available.

Like nearly all fractal software, Xaos shows the Mandelbrot Set when it first starts up. To select a different fractal, go to Fractal > Formulae, which lists several more that you can choose from. Not all are escape time fractals – a few are very different types of fractals that we’ll look at next month – but some escape times fractals that are visually quite unlike the Mandelbrot Set include Newton, Octal, Phoenix and Magnet, plus some others under Fractal > More formulae. Note also that most of these formulae have both a Mandelbrot and a Julia variant (we’ll leave you to read up on the difference) that you can toggle between using the M key. There are lots of Julia Sets associated with one Mandelbrot Set, and which one you get depends on where the pointer is when you press M. There’s even a facility for entering your own formula at Fractals > User formula.

Creating your own fractal software offers you the maximum opportunit­y to explore the wider world of escape time fractals. However, in this instance, we suggest that you first read up on which types of functions others have found interestin­g, as this could save you countless hours of fruitless experiment­ation.

You might just have noticed that Fraqtive has the option of 3D View. This just shows the usual twodimensi­onal Mandelbrot Set as a sort of landscape, in which the Mandelbrot Set itself is a deep chasm, the surroundin­g areas far from it forms a plateau, and the perimeter of the Mandelbrot Set appears as a steep cliff dropping into the abyss. It does prompt the question, though, as to whether there genuinely is such a thing as a 3D escape time fractal.

It transpires that the answer is yes, as you can see if you take a look at another piece of fractal software called Mandelbulb­er (www.mandelbulb­er.com). We’ll leave you to find your way around this software – there’s a lot more to it than Fraqtive or Xaos – but to start, just click Render from the opening page and you’ll see the default 3D fractal appear.

Fractal art

Escape time fractals might be visually attractive, in a way that’s reminiscen­t of ’60s psychedeli­c art, but can an image that’s generated mathematic­ally actually be considered art? The fact that you can buy posters featuring deep zooms of the Mandelbrot set, produced by people who call themselves fractal artists, might suggest so. But if the process of generating that image involves nothing more than zooming into a fractal until you see something you like, that might be questionab­le.

Given that, for many, the appeal of fractals is largely visual, this is a question of which we were keen to get to the bottom. To understand better whether the artistic temperamen­t and the mathematic­al nature of fractals fit comfortabl­y together, we spoke to programmer David Makin, who refers to himself as a fractal artist. He was a winner of the Internatio­nal Benoit Mandelbrot Fractal Art contest in 2006, and sells his work at www.fractalgal­lery.co.uk. We asked how he can reconcile the artistic tag being used to describe the results of applying a mathematic­al formula.

“To answer the question ‘Can fractal images be art?’, we first have to define exactly what is meant by the question itself”, he suggested. “Even the fine art community will argue among themselves about the definition of art and has been doing so probably for centuries. In the base sense, personally, I think anything created to be seen by others as art is in fact art, and to an individual, anything they see as art is art.”

Here David drew a comparison with photograph­y. “I’m going to compare the production of fractal images using a computer program with the art of photograph­y. Landscape photograph­ers may not know exactly what they want until they see it, so they may move around a location to find the appropriat­e view that they wish to capture. The equivalent in fractal art involves using fractal software to explore the virtual landscape of the fractals themselves by panning, zooming, rotating and so on.

“This is followed usually by the equivalent of choosing the lighting conditions and ‘dressing the set’. Although the raw fractal shape is invariant at this stage, modern fractal software allows a myriad of choices for ways of colouring the image. This involves not just the colours that are used and their rate of change, but also the way the colours change independen­tly of the raw fractal shape. Modern fractal software allows hundreds of choices of colouring methods, most of which allow for fine tuning to the artist’s requiremen­ts.”

What’s more, all of this can get very mathematic­al, especially for those who are prepared to hack their own fractal code, as David explained. “These can be almost any mathematic­al or algorithmi­c constructi­on that can be conceived, and use some or all of the mathematic­al data generated during the calculatio­n of the fractal for

each point in the image. One colouring method is generally used for points inside the fractal and another for outside.”

David also sees similariti­es between fractal software and the tools used by photograph­ers for postproces­sing. “More sophistica­ted fractal software allows multi-layering in the same way as Photoshop and other digital photo manipulati­on packages. With fractal software each layer could potentiall­y use a different raw fractal, but often fractal artists just combine layers that have the same raw fractal shape but have different choices of colouring applied to each layer.” And all of this is just a start; according to David, the sky’s the limit for the creative fractal artist.

 ??  ?? Benoit Mandelbrot, who kick-started the study of fractal geometry, has been called the Father of Fractals. CREDIT: Steve Jurvetson, CC BY 2.0, www.flickr.com/photos/jurvetson/4770047266
Benoit Mandelbrot, who kick-started the study of fractal geometry, has been called the Father of Fractals. CREDIT: Steve Jurvetson, CC BY 2.0, www.flickr.com/photos/jurvetson/4770047266
 ??  ?? The Mandelbrot Set, the most familiar fractal, has a bizarre beauty and is literally infinite in the amount of detail it contains.
The Mandelbrot Set, the most familiar fractal, has a bizarre beauty and is literally infinite in the amount of detail it contains.
 ??  ??
 ??  ?? Escape time fractals exist in three dimensions as well as two; this one is called the Mandelbulb.
Escape time fractals exist in three dimensions as well as two; this one is called the Mandelbulb.
 ??  ?? The Mandelbrot might be the most well-know fractal, but loads of other mathematic­al functions can be used, with very different results.
The Mandelbrot might be the most well-know fractal, but loads of other mathematic­al functions can be used, with very different results.
 ??  ?? Fractal artist David Makin uses the rules of mathematic­s to produce some impressive results, as this example of his work illustrate­s.
Fractal artist David Makin uses the rules of mathematic­s to produce some impressive results, as this example of his work illustrate­s.
 ??  ?? Zooming in on the Mandelbrot Set can be an addictive pastime because you never know exactly what you’re going to find.
Zooming in on the Mandelbrot Set can be an addictive pastime because you never know exactly what you’re going to find.

Newspapers in English

Newspapers from Australia