### Project 16 - Newton Chaos

 deliverable Newton.java due Before 11:59pm Wed Mar 16th project id newtonchaos

Your task is exercise 3.2.32 of the text book. Chaos with Newton's method. StdDraw doc, StdDraw.jar (Complex.java)

Case 1: The polynomial f(z) = z4 - 1 has four roots: at 1, -1, i, and -i. We can find the roots using Newton's method in the complex plane:

The method converges to one of the four roots, depending on the starting point Z0.

Using this method write a complex client Newton that takes a command-line argument N and colors pixels in an N by- N canvas by mapping the pixels complex points in a regularly spaced grid in the square of size 2 centered at the origin. (Complex.java)

Iterate using the newton method 100 times and color of each pixel according to which of the four roots the corresponding point( the pixel coordinate) converges, i.e

white if it converges to 1+0i

red if it converges to -1+0i

blue if it converges to 0+1i

green if it converges to 0+-1i

black if no convergence after 100 iterations

Convergence is s the approach toward a definite value. When we iterate if the value approach to one of the roots i.e if it is within +/- 0.001 range of one of the roots, then we say the value converges.

N.B.: Set the scale of your canvas between -1 and 1.

` public static void setXscale(double min, double max)  public static void setYscale(double min, double max) `

Choose a starting point Zo ( x , y )

Note: For drawing the picture use StdDraw.java . you can use the following format to draw picture for the corresponding pixels,
public static void point(double x, double y).
Also, at the start of the program call StdDraw.show(0) and then call show() again at the end of the program to avoid drawing every pixel individually.

Case 2: it should be easy for the program to plot given a different polynomial and its roots.
Similarly, the polynomial f(z) = z3 - 1 has three roots: at 1, -0.5-i*0.866, and -0.5+i*0.866. We can find the roots using Newton's method in the complex plane:
the roots of f(z) are calculated as follows.

For this polynomial we have 3 roots, so use the following colors:

green if it converges to -0.5, 0.866i

red if it converges to -0.5, -0.866i

blue if it converges to 1 + 0i

black if no convergence after 100 iterations

Sample Input:
java Newton 500 1

Sample Output:

Sample Input:
java Newton 500 2

Sample Output:

ċ
Complex.java
(2k)
James McLane,
Mar 18, 2014, 5:45 AM
Ċ
Lab 16.pdf
(362k)