Hey guys,

I haven't been doing any interesting projects lately (besides class projects, which aren't very interesting). So, as an exercise I decided to tackle mandelbrot sets. It's actually been quite simple and the majority of my code was representing Complex numbers. My program is the inefficiency I am running into.

I am wondering how to make a quicker method to test for convergence. Here is what I've got:

To actually construct the set, I've used this simple piece of codeCode:`private boolean converges(ComplexNum input){`

int count = 0;

ComplexNum start = input;

ComplexNum zCurrent = new ComplexNum();

ComplexNum zNext = new ComplexNum();

while(zCurrent.getReal() < 2 && zCurrent.getImaginary() < 2

&& count < 45){

zNext = zCurrent.mult(zCurrent);

zNext = zNext.add(input);

zCurrent = zNext;

++count;

}

if(zCurrent.getReal() < 2 && zCurrent.getImaginary() < 2){

return true;

}

return false;

}

Once the set is generated I simply draw an oval for each item in the set.Code:`public void generateSet(){`

for(double i = -2; i < 2; i += .001){

for(double j = -2; j < 2; j+= .001){

ComplexNum current = new ComplexNum(i, j);

if(converges(current)){

set.add(current);

}

}

}

}

Picture for anyone interested:

Attachment 3791

Thanks in advance.