Question
The Mandelbrot Set Plot the FORMAL (black-and-white) Mandelbrot Set, using this iterative equation: z = z^2+ cwhere z starts at zero, and c is a
The Mandelbrot Set
Plot the FORMAL (black-and-white) Mandelbrot Set, using this iterative equation: z = z^2+ cwhere z starts at zero, and c is a complex number that ranges from - 2 to 1 in the real component and- 1 to 1 in the imaginary component. If that iterative process does not escape to infinity, then that complex number belongs to the Mandelbrot set. Note that rather than testing whether any given iteration really escapes to infinity (and therefore is not formally a part of the Mandelbrot set), you can actually just check whether the number goes above 2. (That is, if the value gets past 2, then the iterative process WILL escape to infinity.)
The following English instructions should be translated into matlab code:
clear all your variables
clear the figure window
make a matrix of zeros that has 300 rows and 200 columns,
and call it Mandelbrot.
Start a for loop for the Real component going from -2 to 1 in steps of .01
Start a for loop for the Imaginary component going from -1 to 1 in steps of .01 (thus Real and Imag can also later be used for indexing cells in Mandelbrot)
Set the starting value of z to zero
Set zs to zero (this will collect your z values)
Start a for loop where n (the iteration counter) goes from 1 to 100
Enter the Mandelbrot equation here,
z = z^2+ c, making sure you treat c complex.
Save that recent z value as the nth element in zs.
End the n for loop
If all of zss values are not going to escape to infinity,
Then change the zero to a one in that cell of the Mandelbrot matrix (you will need to modify the Real and Imag numbers to use them as indices)
end that if statement
end the Imag for loop
end the Real for loop
set your colormap to three ones and three zeros
use the image command to plot a transposed version of the Mandelbrot matrix (you may need to multiply Mandelbrot by 2 for this colormap) (and you might want to set the x and y axes, in the image command, to be presented as- 2 to 1 in steps of .01 and 1 to-1 in steps of-.01, respectively.)
set your axis to be equal, so that the plot has commensurate x and y dimensions.
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