The post lab 7 assignment involves creating a fractal by performing calculations with complex numbers. So, for this sub-post-lab assignment you will implement a complex number class. The file Complex.java contains a class that represents a complex number. It has instance data, a constructor, and a toString method. You will need to implement methods for addition, multiplication and absolute value.
Two complex numbers are multiplied using the equation:
(a + bi)(c + di) = (ac - bd) + (bc + ad)i
Two complex numbers are added using the equation:
(a + bi) + (c + di) = (a + c) + (b + d)i
The absolute value of a complex number is computed using:
|a + bi| = √(a2+b2)
The Complex class also has a method called quadPolyBound
. This method computes the number of iterations of the quadratic polynomial function that can be completed with this complex number before its absolute value exceeds the specified bound. The quadratic polynomial function sometimes does not have any bound. In order to prevent infinite recursion or loops, the method should stop testing if the number of iterations exceeds the specified maximum.
The quadratic polynomial function can be defined recursively as:
cn+1 = cn2 + c0
Use the JUnit testing file ComplexTest.java to test your code and use Checkstyle to verify formatting.
Submission: Tar and submit your code on the course Inquire site.