Not knowing what the Mandelbrot equation was, I did a
Google search and landed
here.
So you have to generate iterations of complex numbers based on the Mandelbrot equation, Z = Z
^{2} + C.
What I would do is define a class, ComplexNumber. It would have two instance variables (
real and
imaginary), a constructor that you would define, and methods like:
public double magnitude() {...}
public ComplexNumber add( ComplexNumber c ) {...}
public ComplexNumber multiply( ComplexNumber c ) {...}
public ComplexNumber squared() {...}
public
String toString() {...}
public boolean isReal() {...}
Stuff like that. Then I would write a separate driver class to do your dirty work here. Something like
ComplexNumber constant = new ComplexNumber( -0.2, 0.8 );
ComplexNumber z = new ComplexNumber( 0.0, 0.0 );
for ( int i = 0; i < 100; ++i ) {
z = ( z.squared() ).add( constant );
System.out.println( z );
}
My two cents' worth,
Art