Question: Coding Language: C++ This problem asks to use C++ to calculate membership of a given Mandelbrot for a given region of complex space. (Equation 1)

Coding Language: C++

This problem asks to use C++ to calculate membership of a given Mandelbrot for a given region of complex space.

Coding Language: C++ This problem asks to use C++ to calculate membership (Equation 1)

of a given Mandelbrot for a given region of complex space. (Equation

The following is the "number class from a previous laboratory" that should be implemented for the Mandelbrot set:

#include

#include

#include

using namespace std;

class Complex {

double real, imag;

public:

Complex()

{

real = 0;

imag = 0;

}

Complex(double r, double i)

{

real = r;

imag = i;

}

void setVals(double r, double i)

{

real = r;

imag = i;

}

double getReal() // Return real part

{

return real;

}

double getImag() // Return imaginary part

{

return imag;

}

double getMag() // Return magnitude

{

double z;

z = sqrt(real * real + imag * imag);

return z;

}

Complex operator+(Complex c)

{

Complex ans;

ans.real = real + c.real;

ans.imag = imag + c.imag;

return ans;

}

Complex operator-(Complex c)

{

Complex ans;

ans.real = real - c.real;

ans.imag = imag - c.imag;

return ans;

}

Complex operator*(Complex c)

{

Complex ans;

ans.real = real * c.real - imag * c.imag;

ans.imag = imag * c.imag + imag * c.real;

return ans;

}

Complex operator/(Complex c)

{

Complex ans, z3;

z3.real = c.real / (c.real*c.real + c.imag*c.imag);

z3.imag = -c.imag / (c.real*c.real + c.imag*c.imag);

ans.real = real * z3.real - imag * z3.imag;

ans.imag = real * z3.imag + imag * z3.real;

return ans;

}

};

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!