Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The solution for HW6 is in the link below. thank you. I need the Mandelbrot.c and Mandelbrot.h to get the Mandelbrot set image. http://www.chegg.com/homework-help/questions-and-answers/project-practice-multiple-components-compilation-recursion-structure-extension-hw6-mandelb-q20199425 The

image text in transcribed

The solution for HW6 is in the link below. thank you. I need the Mandelbrot.c and Mandelbrot.h to get the Mandelbrot set image.

http://www.chegg.com/homework-help/questions-and-answers/project-practice-multiple-components-compilation-recursion-structure-extension-hw6-mandelb-q20199425

The Mandelbrot Set The Mandelbrot set is a set of all complex numbers c that satisfy the following condition: the absolute value of mandelbrot(n) remains bounded when n (a natural number 0, 1, 2,...) tends to infinity where mandelbrot(n)-mandelbrot(n-1)*mandelbrot(n-1) +c; mandelbrot(0) Here the addition and multiplication are complex number addition and multiplication. Specifically, for our project, if the absolute value of mandelbrot(15), mandelbrot(15)l, is smaller than 10000 for a given c, then c is in the Mandelbrot set. If we consider a c as a 2D coordinates on a plane, the points in the rectangular area from (-2.0, -1.12) to (0.47, 1.12) will contain the Mandelbrot set. Our goal is to calculate an array of points that covers the Mandelbrot set in this area and display the array. If a point is in the Mandelbrot set, we display a l or# ; otherwise, we display a 0 or an cmpty space You may save the area in a file so the area may contain many more points beyond your display. Implementation details 1) If you haven't completed HW6, you will nced to finish it without any problcm before starting this project. We need to usc the complcx numbcr addition, multiplication, and absolute valuc functions in this project. 2) Let's extend HW6 to include mandelbrot.c, which implement the recursive function "complex t mandelbrot(int n)". In general, you should avoid using global variables, so the recursive function has to carry anothcr input valuc, c, and mandclbrot(c, n) chccks whethcr c bclongs to the Mandclbrot sct. In othcr words, your function should be mandclbrot(complex t c, int n) instcad. Optionally for the purpose of lcarning, you may define a global variable e in main.c, and use "extern" in mandelbrot.h to make it visible in mandelbrot.c, so you can just use mandelbrot(n). 3) mandelbrot(n) uses complex number addition and multiplication, so you should include "complex.h" in mandelbrot.e to allow mandelbrot(n) to access complex functions. In the recursive function, Imandclbrot(n)l can be quite largc bcyond thc computcr's rcpresentation. Thcrcfore, in the recursion, if mandelbrot(n-l)l is bigger than 10000, your recursion should consider that it is not bounded alrcady, so you rcturn mandelbrot(n)- (10000, 10000) instcad of the calculated number to indicate that current e is not in the Mandelbrot set. Also, in the recursion, mandelbrot(n-1) is calculated twicc, which is rcally wasting computing cffort, so you should just calculate it oncc for cfficicncy 4) In order for main.c to sce the recursive function, you need to include "mandelbrot.h". Bccausc you usc complex numbers in main.c, you nced to includc "complex.h" in main.c as well. Bccausc mandelbrot function uses structure, so you should have "complex.h" included ahcad of"mandclbrot.h" In main c, for all point c n the area from (-2.0,-?12 ) to (0.47 1 12), we can check the corresponding mandelbrot(15) to see if it is in the Mandelbrot se. If it is in the set, which means that mandelbrot 15 ?s smaller than 10000, we print a l'or "; otherwise, we print a ? 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. If you want, as an option, which is not required for this project, you may save the image in a two dimensional array of characters first. Better yet, you can save this image in a file, so you can check out a much larger image in the file with many more points. The final executable is called mandelbrot. Make sure your Makefile will compile and generate the three object files, and link them together with correct dependencies. The Mandelbrot Set The Mandelbrot set is a set of all complex numbers c that satisfy the following condition: the absolute value of mandelbrot(n) remains bounded when n (a natural number 0, 1, 2,...) tends to infinity where mandelbrot(n)-mandelbrot(n-1)*mandelbrot(n-1) +c; mandelbrot(0) Here the addition and multiplication are complex number addition and multiplication. Specifically, for our project, if the absolute value of mandelbrot(15), mandelbrot(15)l, is smaller than 10000 for a given c, then c is in the Mandelbrot set. If we consider a c as a 2D coordinates on a plane, the points in the rectangular area from (-2.0, -1.12) to (0.47, 1.12) will contain the Mandelbrot set. Our goal is to calculate an array of points that covers the Mandelbrot set in this area and display the array. If a point is in the Mandelbrot set, we display a l or# ; otherwise, we display a 0 or an cmpty space You may save the area in a file so the area may contain many more points beyond your display. Implementation details 1) If you haven't completed HW6, you will nced to finish it without any problcm before starting this project. We need to usc the complcx numbcr addition, multiplication, and absolute valuc functions in this project. 2) Let's extend HW6 to include mandelbrot.c, which implement the recursive function "complex t mandelbrot(int n)". In general, you should avoid using global variables, so the recursive function has to carry anothcr input valuc, c, and mandclbrot(c, n) chccks whethcr c bclongs to the Mandclbrot sct. In othcr words, your function should be mandclbrot(complex t c, int n) instcad. Optionally for the purpose of lcarning, you may define a global variable e in main.c, and use "extern" in mandelbrot.h to make it visible in mandelbrot.c, so you can just use mandelbrot(n). 3) mandelbrot(n) uses complex number addition and multiplication, so you should include "complex.h" in mandelbrot.e to allow mandelbrot(n) to access complex functions. In the recursive function, Imandclbrot(n)l can be quite largc bcyond thc computcr's rcpresentation. Thcrcfore, in the recursion, if mandelbrot(n-l)l is bigger than 10000, your recursion should consider that it is not bounded alrcady, so you rcturn mandelbrot(n)- (10000, 10000) instcad of the calculated number to indicate that current e is not in the Mandelbrot set. Also, in the recursion, mandelbrot(n-1) is calculated twicc, which is rcally wasting computing cffort, so you should just calculate it oncc for cfficicncy 4) In order for main.c to sce the recursive function, you need to include "mandelbrot.h". Bccausc you usc complex numbers in main.c, you nced to includc "complex.h" in main.c as well. Bccausc mandelbrot function uses structure, so you should have "complex.h" included ahcad of"mandclbrot.h" In main c, for all point c n the area from (-2.0,-?12 ) to (0.47 1 12), we can check the corresponding mandelbrot(15) to see if it is in the Mandelbrot se. If it is in the set, which means that mandelbrot 15 ?s smaller than 10000, we print a l'or "; otherwise, we print a ? 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. If you want, as an option, which is not required for this project, you may save the image in a two dimensional array of characters first. Better yet, you can save this image in a file, so you can check out a much larger image in the file with many more points. The final executable is called mandelbrot. Make sure your Makefile will compile and generate the three object files, and link them together with correct dependencies

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What laws protect authors rights in the works they create?

Answered: 1 week ago