I have a programming assignment that requires me to create a bit of code that ch
ID: 640976 • Letter: I
Question
I have a programming assignment that requires me to create a bit of code that checks to see if a set of numbers is within the mandlebrot set, if it is to print out a * if not to print a space and to write the whole thing to a file in C.
Ive got the majority of the code written to do this however I cannot seem to write the function to check of the coordinates are in the set here is the flow chart that describes the function.
Any help writing the function would be appreciated.
Edit : MAXx = 10 , MAXCOUNT = 500
Explanation / Answer
int isinMandelbrot(int x, int y){
int max = 10;
int maxcount = 500;
int xc = x;
int yc = y;
int count = 0;
do{
int xtemp = (xc * xc) - (yc * yc) + x;
int ytemp = (2 * xc * yc) + y;
xc = xtemp;
yc = ytemp;
count++;
}while(count <= maxcount);
double z = sqrt(pow(xc, 2) + pow(yc, 2));
if(z <= max){
return 0;
}
else{
return 1;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.