Saturday, 27 February 2010

Fractals with Octave: Original Function Studied by Gaston Julia

The story so far

After another long pause, here is the sixth instalment of this series on fractals with Octave. In this article, we have a look at the complex series that started is all, the one that Gaston Julia was interested in.

Once Upon A Time: The Original Fractal Function

The classic Mandelbrot set we all know and love is derived from quite a simple series, described in the very first article of this series. Gaston Julia was interested in a slightly more complex series, as explained by Paul Bourke:

zn+1=z4 + z3/(z-1) + z2/(z3+4z2+5) + c

The initial condition is:


The Mandelbrot Set

We can produce a Mandelbrot set of that equation with the mandelbrot function that we created in previous articles.

octave:1> Mj=mandelbrot(-1.4+1.05i,1.4-1.05i,320,64,
> @(z,c) z.^4.+z.^3./(z-1)+z.^2./(z.^3.+4*z.^2.+5).+c;
octave:2> imagesc(Mj)

And here is the result:

Original Julia Series, Mandelbrot Set

We can then zoom on the bottom right corner of that image.

octave:1> Mjz=mandelbrot(0.25-0.65i,0.45-0.8i,320,64,
> @(z,c) z.^4.+z.^3./(z-1)+z.^2./(z.^3.+4*z.^2.+5).+c;
octave:2> imagesc(Mjz)

Original Julia Series, Mandelbrot Set x10

And again.

octave:1> Mjzz=mandelbrot(0.378-0.725i,0.398-0.74i,320,64,
> @(z,c) z.^4.+z.^3./(z-1)+z.^2./(z.^3.+4*z.^2.+5).+c;
octave:2> imagesc(Mjzz)

Original Julia Series, Mandelbrot Set x100

And again!

octave:1> Mjzzz=mandelbrot(0.3863-0.7314i,0.3883-0.7329i,320,64,
> @(z,c) z.^4.+z.^3./(z-1)+z.^2./(z.^3.+4*z.^2.+5).+c;
octave:2> imagesc(Mjzzz)

Original Julia Series, Mandelbrot Set x1000

The Julia Set

Now, let's have a look at the Julia set for the same series and for c=0.3873-0.7314i, which is the point towards which we zoomed on in the Mandelbrot set.

octave:1> Jj=julia(-1.2+1.6i,1.2-1.6i,240,64,0.3873-0.7314i,
> @(z,c) z.^4.+z.^3./(z-1)+z.^2./(z.^3.+4*z.^2.+5).+c;
octave:2> imagesc(Jj)

Original Julia Set, c=0.3873-0.7314i

Let's zoom into that picture.

octave:1> Jjz=julia(0.2+0.1i,0.4-0.05i,320,64,0.3873-0.7314i,
> @(z,c) z.^4.+z.^3./(z-1)+z.^2./(z.^3.+4*z.^2.+5).+c;
octave:2> imagesc(Jjz)

Original Julia Set, c=0.3873-0.7314i, x10

And again.

octave:1> Jjzz=julia(0.366+0.09i,0.386+0.075i,320,64,0.3873-0.7314i,
> @(z,c) z.^4.+z.^3./(z-1)+z.^2./(z.^3.+4*z.^2.+5).+c;
octave:2> imagesc(Jjzz)

Original Julia Set, c=0.3873-0.7314i, x100

And again!

octave:1> Jjzzz=julia(0.366+0.09i,0.386+0.075i,320,64,0.3873-0.7314i,
> @(z,c) z.^4.+z.^3./(z-1)+z.^2./(z.^3.+4*z.^2.+5).+c;
octave:2> imagesc(Jjzzz)

Original Julia Set, c=0.3873-0.7314i, x1000

The End

This is the last article in this series. I hope you've enjoyed it, even if it took me a very long time to finish it. Have a play with the Octave functions described throughout the articles, modify them, improve them, there's a lot of fun stuff to do and amazing pictures to create with fractals.

Wednesday, 24 February 2010

The Art of Database Analysis

Take a complex database schema, apply a bit of python to produce an SVG graph and you can come up with weird and wonderful pictures:

Database Bullseye

Database Bullseye

If anybody is interested in the python code I used to create that graph, please ask. The more complicated and convoluted the database, the better the picture.

Friday, 5 February 2010

Raising elephants on a ThinkPad T42 and an EeePC 701

A magic key

If you look at your computer keyboard, you probably have a key labelled SysRq somewhere, either on its own or as a secondary function of another key such as PrtSc. You probably never use it but if you run Linux, it's a magic key that enables you to perform low level commands even when the computer is completely stuck. A particularly useful combination of such commands uses the mnemonic Raising Elephants Is So Utterly Boring.

Finding SysRq

That's the theory. In practice, it can be difficult to find out what exact key combination triggers SysRq on your particular computer and whether you need to press SysRq and the command key at the same time or whether you can press SysRq first, release and then press the command key. To find out, switch to a text virtual terminal, by pressing Ctrl+Alt+F1. You will then be presented with a full screen black console with a login prompt. Don't worry, you can switch back to your normal screen by pressing Ctrl+Alt+F7 at any time. Log in with your user name and password. For this to work, we first need to check that support for SysRq is compiled in your kernel. To do this, enter the following command:

$ cat /boot/config-`uname -r` | grep CONFIG_MAGIC_SYSRQ

If the result is as shown above, SysRq is compiled in your kernel. Next, we need to make sure it's enabled:

$ cat /proc/sys/kernel/sysrq

If it is enabled, you should get 1 as an answer. If you get 0, it's not enabled, if you get anything else, it's partially enabled. The full list of values can be found in the sysrq.c documentation. If it all enabled, it should be possible to try it out by sending a command directly to the SysRq trigger:

$ sudo su -
$ echo h > /proc/sysrq-trigger

You need to be root to do this, hence the sudo su - to start with. When you do this, you should see the SysRq held text printed out to the console. After that, revert to your own user immediately to avoid any risk of doing something bad to your computer: root is very powerful and it's therefore very easy to do something bad by accident. So type this command to revert to your own user:

$ exit

Now it's a case of trying all possible key combination with the h command to find out what your SysRq key is. If you have a full SysRq key, typing Alt+SysRq+h should display the same help message as above. If that's the case, you're done. Otherwise try any number of combinations of the keys Shift, Ctrl, Alt, AltGr or Fn with one of the keys SysRq, PrtSc, Insert, Delete, ScrLk and key h until you find what combination produces the help message. Once you've found it, log out by typing exit and revert to your standard virtual terminal by pressing Ctrl+Alt+F7

SysRq on a ThinkPad T42 and an EeePC 701

On my IBM ThinkPad T42, the SysRq key combination is AltGr+PrtSc so to get the help text, I would do AltGr+PrtSc+h. On my EeePC 701, the combination is Fn+Alt+Del, which means I have to press four keys at the same time to get the SysRq help text: Fn+Alt+Del+h! Luckily it's a small keyboard. On both machines, I have to press all 3 or 4 keys at the same time.