The Julia set in the image above is actually only the red parts.
The yellow and blue parts are points near to the Julia set but not in
it. Julia sets are determined by the convergence or divergence of
infinite series, one for each point in the plane. A given Julia set
is defined by a single complex parameter **a**+**b***i*.
For the Julia set shown above that parameter is **0.36237** +
**0.32***i*. We will start by giving the algorithm for
finding which points are in or out of a Julia set. Aside from
neglecting the issue of how to shade the colors it is the algorithm
used to generate the picture above. If you're really anxious to know
how the coloring was done read the article on cosine coloring.

## Julia set membership algorithm. |

Choose the parameter mu=a+b |

The two-color version of the algorithm may actually make it easier to see the Julia set.

Let's think about what the algorithm is doing. For each point
(x,y) in the view window we are using, we turn (x,y) into the complex
number z=x+*i*y. We let z be the first number in a series. We
get the next number in the series by squaring the current value and
adding in Julia parameter mu. We keep doing this until either (i) the
size |z| of the current number is bigger than 2 or (ii) we run out of
iterations relative to the limit we chose. If the size of the current
number is bigger than 2 then the original point (x,y) really is
outside of the Julia set. If not then it may be a member of the Julia
set or we just may have set the limit too low to detect that (x,y) is
outside. This means the algorithm gives us an *approximate*
Julia set. The higher we set the iteration limit, the better picture
of the Julia set we get. Let's take a look at the Julia set we've
been working with for several different limits on the number of
iterations.

10 iterations | 20 iterations | 40 iterations |

80 iterations | 160 iterations | 320 iterations |

We get a new sort of look between 40 and 80 and again between 80 and 160. The first two pictures on the page were done with an iteration limit of 600. The highest number of iterations isn't always the best. Often the approximate Julia set has distinct interesting appearances for different levels of zoom.

The Julia membership algorithm given above is for a very specific
complex function, **f(z)=z*z+mu**. In fact you can generate a
Julia set for any complex function. The two above are for very
different functions. The left Julia set is for a polynomial function
with four roots: r1=**1**-**0.1***i*,
r2=**0.1**-**1***i*, r3=**-1**+**0.1***i*, and
r4=**-0.1**+**1***i*. There isn't a mu, we just let the
four roots specify the function. Written out the function is
**g(z)=(z-r1)*(z-r2)*(z-r3)*(z-r4)**. This function gets plugged
into the Julia set membership algorithm in place of **z*z+mu**.

The right Julia set comes from a complex cosine function with
parameter mu=**-0.8075**+**-0.8075***i*. To do this you
not only need to put in the complex cosine, but change the test to see
if the point has escaped. Let's rebuild the algorithm with the
complex cosine function in it with the right escape limit. You can
put any function into the place of the complex cosine. All that
happens in this case is that z*z becomes cos(z) and |z|<2 becomes
|z|<12 in the test. You need to do some fiddling around to find the
right distance for the escape test if you change the function.

## Julia set membership algorithm II. |

Choose the parameter mu=a+b |

One final note on coloring. The complex cosine Julia set is not
using cosine coloring. Instead the colors are a function of the
iteration number where the shade of red, blue, and green are all have
intensity proportional to the square of the sine of the number of
iterations. This technique is called *periodic palette*
coloring.