Physics 5  Scientific Computing                             

The Root Finding Route to Chaos

 

Read the article, The Root Finding Route to Chaos.

Develop a C++ class named Complex for working with complex numbers.  This class should provide for

·         A constructor.

·         A print function that will print out the complex number as a + bi.

·         Overloaded operators for +,-,* and /.

·         A modulus operator taking a complex number a + bi  and returning a2 + b2.

·         A square root function that will accept a complex number and use the Babylonian algorithm to produce one of its square roots.

·         A cube root function that will accept a complex number and use the Babylonian algorithm to produce one of its cube roots.

Finally implement the algorithm given in pseudocode in The Root Finding Route to Chaos Article using the Dark GDK to produce the fractal of basins of attraction shown in the article.
Be sure to scale appropriately to capture the image in your window.

for each pixel P

begin

  Z := user-coordinates(P)     {seed root search}

  color := background

  count := 0

  repeat

  Z := (2* Z + 8 / ( Z * Z ) ) / 3

       count :=count + 1

  if |Z - root1| < error then color := color1 else  

  if |Z - root2| < error then color := color2 else

  if |Z - root3| < error then color := color3

     until (color != background) or (enough < count)

     apply color to P

   end

Submit your work as a zip file name <your initials>_GDK004.zip containing the .h and .cpp files for your project.