(* You should be able to copy and paste this text file directly into Mathematica. These notes will be interpreted as commented code. *) (* For problems 1-3: Code for plotting Julia sets *) quadjuliaset[c_, reslevel_] := JuliaSetPlot[c, PlotLegends -> Automatic, ImageResolution -> reslevel] (* Plots the Julia set with default escape-time colorings for the quadratic function q_c(z) = z^2 + c, with the legend for comparing colorings to the number of iterates required to escape, with resolution level reslevel. A resolution level of 500 is usually good enough to see the detail *) quadjuliaset[-0.1 + 0.7 I, 500] (* This will plot the Julia set for the value of c in problem 1a *) quadjuliaset[1/2 E^(I/GoldenRatio) - 1/4 * E^(2I/GoldenRatio), 500] (* This will plot the Julia set for the value of c in problem 3b *) (* For problems 1-4: Code for plotting the Mandelbrot set *) MandelbrotSetPlot[{-0.4 + 0.5 I, 0.1 + 1.2 I}, ImageResolution->500] (* This plots the portion of the Mandelbrot set ranging from the lower left corner -0.4+0.5i to upper right corner 0.1+1.2i *) (* To increase the plot detail, increase ImageResolution *) mandelbrotbox[center_, width_] := MandelbrotSetPlot[{center - (1 + I) width/2, center + (1 + I) width/2}, ImageResolution -> 500] (* This plots the Mandelbrot set centered at the indicated point with the given frame size *) (* To increase the plot detail, increase ImageResolution *) mandelbrotbox[-0.1+0.7I, 0.9] (* Plots the Mandelbrot set on the box centered at -0.1 + 0.7I, the value in question 1a, with width 0.9. To get a good picture of the desired bulb, you can zoom in and out by adjusting the width, and then once you have identified which bulb you want, you can recenter the picture to see all of it. *) (* For problem 5: Code for plotting the multibrot set *) multibrotpoints[n_] := With[{multibrot = Block[{z = #, c = #}, Catch@Do[If[Abs[z] > 2, Throw@i]; (* To change the escape criterion, change 2 to the desired value *) z = z^n + c, (* To plot a different family, simply change the function here *) {i, 100}]] &}, (* To change the number of iterations used, change 100 to the desired value *) Compile[{}, Table[multibrot[x - y I], (* The minus sign is needed because otherwise the plot will be upside-down *) {y, -1.5, 1.5, 0.005}, (* To change the y-range or step size, adjust these values *) {x, -1.5, 1.5, 0.005}]]]; (* To change the x-range or step size, adjust these values *) (* This computes an array of integers, indicating the number of iterates required to escape under the given map *) multibrotset[n_] := ArrayPlot[multibrotpoints[n][], FrameTicks -> {{{0, 1.5}, {100, 1}, {200, 0.5}, {300, 0}, {400, -0.5}, {500, -1}, {600, -1.5}}, {{0, -1.5}, {100, -1}, {200, -0.5}, {300, 0}, {400, 0.5}, {500, 1}, {600, 1.5}}}, FrameLabel -> {Re, Im}, RotateLabel -> False, PlotLabel -> StringJoin["Multibrot set for p(z) = z^", ToString[n], " +c"]] (* This plots the array and shows the multibrot set M_n, with manual labeling of the frame to indicate the coordinate values *) multibrotset[3] (* This plots the cubic multibrot set *) multibrotlobe[n_] := ParametricPlot[{r Cos[t] - r^n Cos[n*t], r Sin[t] - r^n Sin[n*t]}, {r, 0, n^(-1/(n - 1))}, {t, 0, 2 Pi}, PlotStyle -> Opacity[1]] (* This plots the central lobe of the multibrot set *) multibrotcurve[n_] := ParametricPlot[{n^(-1/(n - 1)) Cos[t] - n^(-n/(n - 1)) Cos[n*t], n^(-1/(n - 1)) Sin[t] - n^(-n/(n - 1)) Sin[n*t]}, {t, 0, 2 Pi}, PlotStyle -> Directive[Red, Opacity[1]]] (* This plots the boundary curve of the multibrot set, in red *) Show[multibrotlobe[3], multibrotcurve[3]] (* This plots the central lobe in blue together with its boundary curve in red *) multibrotcurvesc[n_] := ParametricPlot[{300, 300} + 200*{n^(-1/(n - 1)) Cos[t] - n^(-n/(n - 1)) Cos[n*t], n^(-1/(n - 1)) Sin[t] - n^(-n/(n - 1)) Sin[n*t]}, {t, 0, 2 Pi}, PlotStyle -> Directive[Red, Opacity[1]]] multibrotlobesc[n_] := ParametricPlot[{300, 300} + 200*{r Cos[t] - r^n Cos[n*t], r Sin[t] - r^n Sin[n*t]}, {r, 0, n^(-1/(n - 1))}, {t, 0, 2 Pi}, PlotStyle -> Opacity[1]] multibrotlobeplot[n_]:= Show[multibrotset[n], multibrotlobesc[n], multibrotcurvesc[n]] (* This plots the nth multibrot set with the central lobe drawn in blue and its boundary curve drawn in red. The shift and rescaling of the lobe and curve are needed because of the way ArrayPlot draws the points for the multibrot set *) multibrotlobeplot[3] (* This plots the cubic multibrot set together with its central lobe drawn in blue and the boundary of the central lobe in red)