Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help with Mandelbrot set!! ... Question: Some help editing this code for Mandelb

ID: 3821511 • Letter: H

Question

Help with Mandelbrot set!! ...

Question: Some help editing this code for Mandelbrot Set!! W...

Bookmark

Edit question

Some help editing this code for Mandelbrot Set!! When I run it right now, it is only printing ###### when it should be printing 1s and 0s. I have the functions mandelbrot.h and mandelbrot.c and these functions work correcly.

The requirments:

In main.c, for all point c in the area from (-2.0, -1.12) to (0.47, 1.12), we can check the corresponding mandelbrot(15) to see if it is in the Mandelbrot set. If it is in the set, which means that |mandelbrot(15)| is smaller than 10000, we print a '1' or '#'; otherwise, we print a '0' or ' '(an empty space). Therefore, we can actually print an image of the Mandelbrot set. For example, you can check 40*30 points with a double for loop in a rectangular area. That is, we start in x direction from -2.0 with step size (0.47-(-2))/40 = 0.06175 to 0.47, and in y direction from -1.12 with step size (1.12-(-1.12))/30 = 0.077 to 1.12. You may notice that this arrangement will be an up-side-down image, but the image is symmetric, so we can ignore this problem.  You can google images on Mandelbrot, and see the Mandelbrot set images with very fine points at the screen resolution with vivid colors.

It also should ask the user to put in a number,n

My code:

#include
#include "complex.h"
#include "mandelbrot.h"


int main (void)

{
complex_t c;
for (c.imag = -2.0; c.imag < -1.12; c.imag+=0.06175)
{
for (c.real = 0.47; c.real < 1.12; c.real+=0.077)
{
if (abs_complex(mandelbrot(15,c)).real > 10000)
{
printf("1");
}
else
{
printf("#");
}
}
printf(" ");   
}
return (0); }

Explanation / Answer

#include
#include "complex.h"
#include "mandelbrot.h"

int main (void)
{
complex_t c;
for (c.imag = -2.0; c.imag < -1.12; c.imag+=0.06175)
{
for (c.real = 0.47; c.real < 1.12; c.real+=0.077)
{
float val=10000;
if (abs_complex(mandelbrot(15,c)).real < val)
{
printf("1");
}
else
{
printf("#");
}
}
printf(" ");   
}
return (0); }

//try this if you have any problem then comment me thanks

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote