Raster images of Julia sets

Here we will make pretty pictures of Julia sets. For the values of (x,y) that did not break out, we set a color based on the minimum value of x2+y2 achieved during the iteration. For values of (x,y) that did break out, we set a color based on the last value of (x,y) before the breakout. The choice of color scheme is purely for aesthetics, you are welcome to experiment with your own choices. Download julia.c . Compile with either the gnu C compiler:

gcc -o juliac julia.c -lm

or some other C compiler on your system, usually invoked as:

cc -o juliac julia.c -lm

To get the above default image, in PPM format, simple execute juliac with not command line arguments.

juliac accepts up to 6 arguments from the command line. The first three are: width, height and magnification. This is the same as using the defaults:

juliac 600 400 10 
You may want to try these:
juliac 1200 800 10 
juliac 1000 800 2 

Your may want to try out your own artistic skills by applying some alternative color schemes. If you post your graphics on your web page, you should post your graphics in either .png or .jpg format. You may find it interesting to experiment with:

convert fromc.ppm -quality 50 a.jpg
convert fromc.ppm -quality 90 b.jpg
Then compare the file size and appearance of a.jpg and b.jpg.

If you read the online documentation for convert , you will find that .png also accepts the -quality parameter. But for .png, is for the quality of the compression, not the image. Next try

convert fromc.ppm -quality 50 a.png
convert fromc.ppm -quality 100 b.png
convert fromc.ppm  c.png
Then compare the file size and appearance of the files. They should look exactly the same.
convert a.png a.ppm 
convert c.png c.ppm
diff a.ppm c.ppm
The will probably find that the diff statement returns nothing; meaning the files are identical. PNG is a lossless compression.

Don't know C? Here is a C tutorial, and a C++ tutorial.


A Fortran 90 version is also available. Download both julia.f90 , and fractal.input. Compile with

f90 -o juliaf julia.f90

juliaf does not accept arguments from the command line, rather they are input in the namelist file fractal.input. Run as

juliaf < fractal.input 

To display the time required for execution, try this:

time juliac 
time juliaf < fractal.input 

On my linux desktop, I found a user time of 0.32 seconds for both. Don't know Fortran? Here is a list of Fortran tutorials, if you are interested.


Slower Python programs are also available here:

It was expected that pure python version julia.py would be very slow. Without the array extensions (Numeric or numpy), we expect a scripting language perform poorly with "number crunching". But the performance with array extensions, julian.py, was also surprisingly poor.