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.
(Equation 1)
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started