public static int iterate(Complex z0) {
		Complex z = new Complex(z0);
		if (mandelbrot){
			//Iterates the passed complex z after the formula z_next = z^2 +z0
			for (int i = 0; i < maxIterations; i++) {
				if (z.abs() > 2.0) {
					return i;
				}
				z = z.times(z).plus(z0);
			}
			return maxIterations;
			
		} else {
			//Iterates the passed complex z after the formula z_next = z^2 + c
			//c is the complex number for which the Julia set is found
			for (int i = 0; i < maxIterations; i++) {
				if (z.abs() > 2.0) {
					return i;
				}
				z = z.times(z).plus(juliaConstant);
			}
			return maxIterations;
		}
	}