Saturday, 31 May 2014

Colouring The Inside #2

And taking the idea of the last post to Julia sets produces some wonderful images.

Try it yourself with Xaos!

Friday, 30 May 2014

Colouring The Inside

The most common visualisations of the Mandelbrot set have the set itself coloured black, and the regions outside coloured. The colouring scheme usually reflect how quickly the points outside the set diverge.

But what would happen if we applied similar logic to colouring the inside of the set, and left the outside black?

The following images show the results. They provide an interesting insight into the dynamics of the set. It's a perspective you don't often see.

 You can create these yourself using Xaos by setting the in-colouring and out-colouring options.

I personally love the liquid metal look of some of the images!

Monday, 26 May 2014

Last Interview with Benoit Mandelbrot

The last interview with Benoit Mandelbot himself, who disocered the Mandelbrot Set and coined term fractal.

Benoit is much respected for having the determination to explore outside the mainstream, and it paid off.

Saturday, 24 May 2014

Beautiful BBC Documentary on Fermat's Last Theorem

The BBC has put up some of its best Horizon documentaries online to watch again.

I would recommend everyone to watch the beautifully made, and at times, emotional documentary on Fermat's Last Theorem and Andrew Wiles' jounrey to crack it.

The BBC does a fantastic job of giving us a taste of the stunning simplicity of the Theorem, the intricate battles of mind and will to prise open insights and make connections across the fields of mathematics, and the very human travails. The story of a quiet unassuming man who hid a determination and passion to solve the deceptively simple Theorem that had eludes so many for so long.

Inspiring! I'd recommend all students watch it!

If you can't receive IPlayer, because you're outside the UK, there's a version on YouTube too:

Thursday, 22 May 2014

Sunday, 18 May 2014

Complex Numbers Explained

Impenetrable Jargon

I really displike how too many thngs in mathematics are not explained clearly and simply. Too often really cool things are kept out of the reach of normal people - because the explanations are written in some alien inaccessible language.

What the mathematics community need to realise is - writing stuff in a language only a few of them understand is not big and it's not clever. I'm not impressed.

What is clever - what is hard - is being able to explain those ideas so that the maximum number of people can understand and appreciate them. That should be the measure of success.

If research grants and teaching salaries were based on this measure I wonder how quickly the profession, and the texts it publishes, would change?

Anyway, I'm going to try to demystify complex numbers.

Complex Numbers Are Not Complex

Complex numbers are not complex. That's a really unfortunate name which scares people. It's an accident of history. They should have been called composite or 2-part numbers, or anything that doesn't put barriers up straight away.

Normal numbers, like 2, 3, 4.5, 9.332 are 1-dimensional. That is they describe one thing and only one thing. They could be the length of a rope, or the time it took to finish a race. They can't describe two things at the same time. That is, you can't use a single 1-dimensional number to describe both the width and length of a swimming pool - you have have to have two numbers, one for the width and one for the length.

Complex numbers are 2-dimensional. They have 2 parts. These two parts are independent of each other. One part can do what it likes and is not in any way influenced or constrained by the other. The two parts of a complex numebr are like apples and oranges. You can't mix them up, an apple will always be an apple and not an orange. This is an important thing to keep im mind when we combine complex numbes later.

The following shows the two parts of a complex number. They just happen to be called the real part and the imaginary part. Again, don't let these names put you off, they have been settled on without anyone really considering the best names for these parts.

We could have written these two parts in a different way. For example, (2,3) or (2,3i) or (3i,2) or even (3i+2) ... but the convention is (2+3i) and sometimes without the brackets when it is clear enough what we mean 2+3i. Again, this is just a convention that we arrived at through history becuase it worked well for lots of people. If you are an engineer, you may have seen the symbol j used instead of i. That's ok becuase those engineers often use i to mean other things - they use j to avoid ambiguity. So they might write (2+3j), but most people use i.

What are these numbers good for? Well they are in fact really useful for lots of things in science and engineering, not just for making fractal images!

For now let's just notice that these 2-part complex numbers are very similar to coordinates locating points on a flat 2-dimensional surface. Just like a map grid reference or the familiar (x,y) coordinates when we work with graphs. We can in fact think of comlex numbers as points on a flat surface becuase they have two independent parts. Look at the following diagram and you'll see they aren't that different to the normal (x,y) coordinates for points on a graph.

The first diagram shows the complex number (3+2i). You can see the horizonal distance is 3 and th evertical distance is 2. This is just like (3,2) on the more familiar (x,y) graphs. The second digram shows (-2-2i) which is just like (-2,-2) on (x,y) graphs.

Ok so complex numbers can very easily represent points on a flat surface, just like (x,y) graph coordinates.

That was easy enough!

Add, Subtract, Multiply with Complex Numbers

What about the normal rules of arithmetic? Adding, subtracting, multiplying? Do they make sense for these strange objects we seem to have invented called complex numbers? Let's deal with adding and subtracting first because they are really easy.

Adding complex numbers is really really really easy! Remember when we said the real and imaginary parts of a complex number are like apples and oranges. We said that these were independent because and you can't change an apple into an orange, and the number of apples doesn't influence the number of oranges at all. Well that's really handy. Because if we want to add two complex numbers we simply add up all the apples from the two numbers to tell us how many apples should be in the answer. The same for oranges. Another way os saying this is that we combine the real and imaginary parts separately.So (2+3i) added to (4+5i) means we combine the 2 and 4 (real parts) and also combine the 3 and 5 (imaginary parts). The answer is (6+8i).

If you're still struggling, think of adding the 2 apples to the 4 apples to make 6 apples. Then adding 3 oranges to the 5 organges to make 8 oranges. These are the two parts of the answer:

(2 apples, 3 oranges) + (4 apples, 5 oranges) = (6 applies, 8 oranges)
(2 + 3i) + (4 +5i) = (6 + 8i)

TIP: Did you know that Google can do maths with complex numbers for you. Try it! Type (2+3i) + (4+5i) into the Google search box and you'll get the answer!

What about subtraction? It's the same. You combine the independent real and imagines parts by subtracting them instead of adding them. Or if you prefer, you subtract the apples, then you subtract the oranges. So (2+3i) - (4+5i) = (-2 -2i). Yes, these have negative parts because 2-4 is -2, and 3-5 is also -2. Again Google can do this too.

Actually this is just like adding and subtracting the familiar (x,y) coordinate vectors if you know about those already.

What about multiplication? This is again just like the normal maths that we know, exceot for one tiny special difference. In fact, to make sure no-one is put off by special differences, we'll tell you know that this single tiny difference is the ONLY difference you need to know about. Once you get it, there are no more hidden suprises later on. That single difference is the only thing you need to remember when working wih complex numbers

So how do we multiply complex numbers? Well remember the familiar matrix multiplication? Multiplying (a + b) by (c + d) was done my multiply each combination of things inside the brackets. So to make the answer you'd have to work out a*c, a*d, b*c and b*d ... and once you'd done all t he laborious work you'd collect terms that were similar.

Let's illustrate this with an example (2x + 3y) * (4x + 5y). We've chosen to include x and y bits because of we didn't the example would be too easy and not illustrate collecting like terms: (2+3) * (4+5) is just 5*9 which is just 45. So let's expand those brackets out. The bits we will collect are 2x*4x, 2x*5y, 3y*4x and 3y*5y. Nothing new here, just what we would normally do. Do the multiplications and we get 8x2 + 10xy + 12xy + 15y2. We have collected all the similar terms yet, there are "xy" bits. Once we've tidied it all up we get 8x2 + 22xy + 15y2. Notice there are 3 kinds of animal here, the x2 bit, the y2 bit and the xy bit. We can't simplify any further because the xy bit can't become x2 as  they are indepdnent different animals - just like apples and oranges are independent.

Noe let's do this familiar multiplication of brackets with complex numbers. Let's try (2+3i) * (4+5i). The answer will have to have the combinations 2*4, 2*5i, 3i*4 and 3i*5i. Lets do the multiplications to get 8 + 10i + 12i + 15i2. Let's carry on tidying up by collecting the similar terms to get 8 + 22i + 15i2. This just like the example above which used x and y instead of real and imaginary parts - that's why we get the same numbers 8, 22, 15.

So (2+3i) * (4+5i) gives 8 + 22i + 15i2. But we don't stop there. That one single special rule we mentioned for complex numbers allows us to replace the i2 with something simpler.

The rule is i2= -1.

So i*i an always be replaced by -1. You don't have to but it helps simplify the expressions. This is a bit magical - combining two imaginary bits creates a real bit. The oranges multiplied together became a negative apple!

Before you think complex numbers will have all sort os such crazy exceptions and rules - stop worrying now. That's the only rule you have to know - and it's really easy to remember.

So if we apply it to the expression we replace 15i2 by -15 .... to get the final answer: (2+3i) * (4+5i) = 8 - 15 + 22i or more simply (-7 + 22i). Again you can check with Google.

That's it! Easy peasy!

We didn't do division because it's just a tinsy bit more complex in terms of messing about with algebra and doens't introduce new ideas, so we left it out to avoid distraction.


You can find a fuller explanation, slower in pace, and with more examples in the ebook.

Friday, 16 May 2014

Python: Smallest Jump from Idea to Code

In Make Your Own Mandelbrot we chose Python as the computer language to learn, and then use to calculate and plot the fractals.

There are many reasons Python is good for you to learn.

Python is easy to learn, and you can get quite far with it before you start hitting advanced or difficult concepts. But most people don't get to that point, and don't need to. Becuase the big chunk of Python that most people learn is more than enough to do useful things with.

Python has a huge following. And it is very popular. You'll find it in games, application servers, and powering huge global infrastructures. It's particularly popular in the science and data fields.

The new wave of children learning computing using the Raspberry Pi are programming in Python.

But for me, there is one special reason I love Python. And I hope you'll love it too for the same reason.

For people who are lucky enough to be able to program in several languages, Python is often the first one used to try out an idea or make an early prototype.

Why is this? It's because the leap from human idea to computer code is often smallest with Python.

The leap from human idea to computer code is often smallest with Python.
 Too many other languages have barriers between your idea and code, stuff that gets in the way, distracts you from just trying your idea. Fragile syntax, special rules that trip you up, lots of boilerplate code that you seem to have to type agan and again. Python mostly stays out of the way.

Just for fun, here's a family free of languages from O'Reilley. It's a little old but still interesting. You can see Python's parents and cousins!

Tuesday, 13 May 2014

Animated Dive Into The Mandelbrot Fractal (XaoS)

A really good fractal explorer that I recommend in the guide is XaoS. There are amy good ones, and many that are free and open source, so what's so good about this one?

XaoS is free and open source, and runs on a variety of operating systems (Windows, Mac OS X, Linux, BSD, DOS and more). You can get it from here.

It is fast - but so are many others.

What XaoS is really good at is zooming into the Mandelbrot fractal so fluidly that the effect is an animation of you fluidly diving deeper and deeper.into the fractal with detail appearing without a glitch. See for yourself with the following videos.

This is actually amazing, given how computationally intensive it is to calculate just one frame of such a video. I recall how in the 1980s it took hours on a home computer to calculate even a low resolution single frame.

Saturday, 10 May 2014

I Will Not Let An Exam Result Decide My Fate

I am passionate about teaching, sharing, mentoring, imparting knowledge, wisdom, and an ability to think and learn yourself.

Some recent feedback from the teaching community got me thinking much more about teaching children by meeting them where they are. Not preaching down to them from some
irrelevant podium of outdated assumptions.

I came across this stunning piece by Spoken Words, called I Will Not Let An Exam Result Decide My Fate.

I urge all teachers to listen and reflect. These are young people extremely eqolouently expressing the gaping holes of education models, measures of success or capability, the dangers of lazy adherence to outdated notions of worth. They davastate our assumptions.

And this is an opportunity to reconnect, not to get defensive and tell them they're wrong. Reconnect because they have shown what needs fixing.

They want and love education, just not our teaching.

Friday, 9 May 2014

Works Even on Monochrome Kindle Readers

I went into a shop to see if the book worked well on an old monochrome Kindle reader. It did!

Wednesday, 7 May 2014

The Mandelbrot Recipe

Sometimes you just want the recipe for making a Mandelbrot fractal, presented in easy to understand steps, with a diagram illustrating how it all works. Here it is... click on the image to get a fuller view.

1. Pick a rectangle on the complex plane.
If you select the rectangle with bottom left corner at (-2.25 -1.5i) and top right corner at (0.75 + 1.5i) you’ll get a good view of the Mandelbrot set. If you chose a rectangle that’s far away from the centre of the Mandelbrot, or is completely within the set, then you won’t see anything interesting.

2. Each point in this rectangle is a complex number representing c, the parameter of our iterated function.
You should pick a reasonable number of points, evenly spaced out. Too many and you’ll have lots of unnecessary calculations to do without adding much detail. Too few points and you’ll have gaps in your plot and insufficient detail.

3. For each of these points, c, iterate the function z2 +c many times.

The complex number z starts at zero, or more properly (0 + 0i). Keep a note of the completed iterations.

4. Stop iterating when either (i) you’ve reached the maximum number of iterations you’ve set yourself, or (ii) the magnitude of the function output grows more than four.
If the magnitude grows greater than 4, the point has diverged and you don’t need to keep calculating further iterations as they’ll diverge further, and may even grow so big as to cause an error in your calculator or computer.
If you’ve reached the maximum iterations, the point c very likely doesn’t diverge.

5. Colour the point c using the number of iterations reached to indicate either (i) the rate of divergence, or (ii) non-divergence for points within the set.
Remember that we have an upper limit on the number of iterations. If it is reached then the iterations did not diverge and so the point is likely to be within the Mandelbrot set. If the iterations are prematurely stopped because the magnitude of z has broken the limit we set of 4, then the orbit does diverge, and the iteration count we did reach indicates how slow or fast the divergence happens. A small iteration count means a rapid divergence.
You could chose other colouring schemes if you wanted to experiment.

Monday, 5 May 2014

Teaching Mathematics

I had an interesting challenge from the teaching community for which I'm grateful. I want to thank the person for taking the time to share his/her views.

It was suggested the guide too easily calls the work children must do as "boring" and that this is unhelpful.

I agree we shouldn't disparage the hard work children must do to pick up the skills they'll need in later life. Multiplying out brackets is important. So is trigonometry.

But I think tihs challenge - gratefully received though it is - misses the point slightly. That the vast majority of people don't associate mathematics with words like "exciting", "beautiful", "surprising".

I was very lucky - extremely lucky - to have had some teachers and mentors who encouraged me to see beyond the rigmorale of mathematics as it was presented to me all those years ago - and to investigate genuinely cool things like fractals, chaos, the golden ratio and fibonacci series in nature and art, the mystery of prime numbers.

My challenge back is this - if you can make trigonomtry something truly exciting, and make matrix multiplication something children look forward to - then you're doing the right thing, and I have a lot to learn from you.

Sorry to but it so bluntly - but it is NOT good enough to drag the kids through the core material whether they like it or not. We can and must be more ambitious. The problem is not with kids not beign interested or appreciating mathematics. It is the teaching.

Saturday, 3 May 2014

Kindle ebook FREE for 1 day!

Get the "Make Your Own Mandelbrot" kindle ebook FREE for 1 day, tomorrow Sunday 4th May.

Grab it while you can!

Thursday, 1 May 2014

Twitter @myomandelbrot

We're now on Twitter too .. come join the discussion @myomandelbrot

And an excuse to post a great 3D image developed using super simple Python code developed in the guide.