tino
tino

Reputation: 11

Why are the colors of my Mandelbrot set crooked looking and not nice and symmetric?

I am wondering why is the background of my Mandelbrot set not as nice as the background on the other picture. Also, why does the Mandelbrot set still show up if I set the number 4 in the if statement of iterationChecker to any other number bigger than 4?

Mandelbrot set, and the background looks crooked:

crooked

I want the background to look like this:

desire

Upvotes: 0

Views: 127

Answers (1)

James_D
James_D

Reputation: 209418

The iteration count is slightly off because of a typo in the condition for counting iterations to escape:

public int iterationChecker(double cr, double ci) {
    int iterationsOfZ = 0;
    double zr = 0.0;
    double zi = 0.0;

    //while (iterationsOfZ < maximumIterations && (zr * zr) + (zi + zi) < 4){

    while (iterationsOfZ < maximumIterations && (zr * zr) + (zi * zi) < 4){
        double oldZr = zr;
        zr = (zr * zr) - (zi * zi) + cr;
        zi = 2 * (oldZr * zi) + ci;
        iterationsOfZ++;
    }
    return iterationsOfZ;
}

Also, why does the Mandelbrot set still show up if I set the number 4 in the if statement of iterationChecker to any other number bigger than 4?

A point c is considered to be in the Mandelbrot set if the sequence defined by z(n+1) = z(n)^2 + c (with z(0)=0) is bounded for all n.

It's easy enough to prove that if |c|>2 then c is not in the Mandelbrot set, and for |c|<=2, that if |z(n)| > 2 for any n, then the sequence z(n) is unbounded, and hence if |z(n)| > 2 (i.e. |z|^2=zr^2+zi^2 > 4) then c is not in the Mandelbrot set.

So the strategy is to iterate z -> z^2 + c, and if |z|^2>4 at any point conclude z is not in the Mandelbrot set. Of course, if you choose any k>4, then if |z|^2 > k, then it's also true that |z|^2 > 4, and z is not in the Mandelbrot set.

Finding z with |z|^2 > 4 is called "escaping", and the number of iterations until escape determines the color. If you reach some maximum number of iterations (you chose 50) without escaping, then you assume c is "close to" or inside the Mandelbrot set and color it black.

So changing the escape level to another number bigger than 4 might change the colors, but it will not change it by much: the absolute value of |z(n)| grows as n^2 from that point. So you would have to increase the escape threshold by a lot to make a difference of more than 1 or 2 in the time to escape.

Upvotes: 5

Related Questions