/****************************************************************************** * Compilation: javac Mand.java * Execution: java Mand fraction * * % java Mand -1/2 0 * ******************************************************************************/ public class Mand { // return number of iterations to check if c = a + ib is in Mandelbrot set public static int mand(RationalComplex z0, int max) { BigRational FOUR = new BigRational(4, 1); RationalComplex z = z0; StdOut.println(z); for (int t = 0; t < max; t++) { // if (z.normSquared().compareTo(FOUR) > 0) return t; z = z.times(z).plus(z0); StdOut.println(z); } return max; } public static void main(String[] args) { BigRational x = new BigRational(args[0]); BigRational y = new BigRational(args[1]); RationalComplex z = new RationalComplex(x, y); mand(z, 512); } }