Question: 16.7 Homework 4a : Mandelbrot Iterations c++ Classes -> Structs Classes -> Class Classes -> Classes and Objects The Mandelbrot Set (https://en.wikipedia.org/wiki/Mandelbrot_set) The Mandelbrot set

16.7 Homework 4a : Mandelbrot Iterations c++ Classes -> Structs Classes -> Class Classes -> Classes and Objects The Mandelbrot Set (https://en.wikipedia.org/wiki/Mandelbrot_set) The Mandelbrot set is a fractal defined as the set of points on the complex plane such that a particular iterated function on them does not "diverge". For a given complex number c, the iterated function is as follows: f_0(c) = (0 + 0i) f_n(c) = f_{n-1}(c)^2 + c where the squaring in step 2 is done by complex number multiplication. It is known that if at any point during the iteration |f_n(c)|becomes greater than 2, that the function will eventually diverge. Thus, a common visualization technique is to iterate until |f_n(c)| is greater than two, up to some maximum number of iterations, say 256. Pseudocode for this is given below: int mandelbrotIteration(Complex c, maxIterations) { Complex z = 0 + 0i; for i=0 to maxIerations z = z*z + c; if |z| > 2 return i; return maxIterations; } Problem 4a : Mandelbrot Iterations Write a class called Complex that encapsulates a complex number with the following functionality: It should have two double variables for the real and imaginary coefficients of the number. Make a constructor that takes two double values for the real and imaginary coefficients of the number. Make a length method that returns the distance of the number from the origin (length(a+bi) = sqrt(aa + bb)) Overload the +, =, and * operators for your class to operate properly on complex numbers. Overload the >> operator so you can print out complex numbers. Write a program that will take the real and imaginary coefficients of a complex number, store them using your Complex number class, and then perform the Mandelbrot iteration on it. The program should terminate the iterations when the length of the z is greater than 2, or when 255 iterations are completed. When the program stops iterating, it should print how many iterations were performed along with the value of the iterate (z in the pseudocode above). For your output of the final z value, print 4 digits after the decimal point. Sample program run Enter the coefficients of a complex number: 0 1.5 Num iterations: 2 Final value: (-2.2500 + 1.500i) Things to remember: For this assignment, it is not sufficient to get the right output. You must define a Complex class and use it to do the calculations. Your Complex class implementation must include a .h and .cpp file.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!