Complex numbers

Mathematica knows how to handle complex numbers. A complex number is a number of the form z=a+ib, where i is one of the two complex roots of (Sqrt[-1]) . The real part of z is Re(z)=a, the imaginary part of z is Im(z)=b. Every complex number z=a+ib can be identified to the point (a,b) in the xy-plane. The absolute value of z is just the length of the line segment from the point (a,b) to the point (0,0), that is, |z| = (Sqrt[(a^2)+(b^2)]).

Re[z] real part 
Im[z] imaginary part
Conjugate[z] complex conjugate 
Abs[z] absolute value |z| = (Sqrt[(a^2)+(b^2)]). 
Arg[z] the argument ϕ from the polar representation of the complex number z = |z|(e^(iϕ)) .

Fractals - Julia sets

Quadratic polynomials

Let c be a complex number and consider the quadratic polynomial p(z) = (z^2)+c. We would like to study the dynamics of the polynomial p, which means understanding the behavior of various points under successive iterations of p (i.e. z, p(z), p(p(z)), p(p(p(z))), ... , (p^(°n))(z), ...).

Definitions
U = {z in ℂ, | (p^(°n))(z)| → ∞ as n → ∞ }              
K = {z in ℂ, | (p^(°n))(z)| does not tend to ∞ as n → ∞ }   
J  =  ∂K =  ∂U  the topological boundary of the sets K and U.

Julia sets
The set U is called the escaping set of the polynomial p. All points from the set U converge to infinity under forward iterations of the polynomial. One can prove that U is an unbounded open set. The complement of the escaping set U is the set K. All points from K remain bounded under forward iterations of the polynomial p. The set K is called the filled-in Julia set of the polynomial p. The set K is compact (closed and bounded). The set J is called the Julia set of the polynomial p. This is a fractal set and it is where the chaotic behavior of the polynomial takes places.

An example
Find the filled-in Julia set K, Julia set J, and the escaping set for the polynomial p(z)= (z^2).

Some properties
The filled-in Julia set K is connected if and only if the Julia set J is connected.
If the filled-in Julia set K does not have any interior, then K is equal to J.

Theorem
The Julia set J is connected if and only if the unique critical point 0 of the polynomial p(z) belongs to K.

Theorem
If the Julia set J is connected then it is totally disconnected, that is J is a Cantor set.

Plotting the orbit of a point

Let c be a fixed complex number and consider the polynomial p(z)=z^2+c. 
Definition: Choose any complex number z. The set L={z, p(z), p(p(z)), p(p(p(z))), ... , (p^(°n))(z), ...} is called the orbit of the point z.

We define a function Orbit[c_,z0_] to compute the orbit of a complex number z0 under successive iterations of the polynomial p(z)=z^2+c. We define an empty list L = {}. Then we add to L the successive iterates of the initial point z0, using the function AppendTo[...]. This function takes two parameters, AppendTo[L, x], and Includes a new value, x, at the end of the list L.

Clear[Orbit]
Orbit[c_,z0_]:=Module[{z=z0,zmax=2,k, L={}},
For[k=0,k<4000&&Abs[z]<zmax, k++,z=(z^2)+c; AppendTo[L,{Re[z], Im[z]}]];
L]

c=N[(1/2) (E^(2 I (Sqrt[2]) π))-(1/4) (E^(4 I (Sqrt[2]) π))]; (* this is the chosen c for the function z^2+c *)
L=Orbit[c, 0];  (* now we compute the orbit of 0 under the function z^2+c *)
R=ListPlot[L]  (* and finally we plot the orbit *)

Functional Iteration Constructs

Many programs you write (in dynamical systems, but not only!) will involve operations that need to be iterated several times. Nest[..] and NestList[...] are powerful constructs for doing this. 
Nest [f,x,n] - applies function f n times to x.
NestList [f,x,n] - makes a list of each successive nesting of f. 
NestWhile[f,x,test] - applies the function f repeatedly until applying test to the result no longer yields True.
NestWhileList[f,x,test] - generates the list {x,f[x],f[f[x]],…}, stopping when applying test to the result no longer yields True.

Nest[f,x,5]

NestList[f,x,5]

Here is a function which divides a number by 2. NestWhileList[...] repeatedly applies the function divide2 until the result is no longer an even number.

divide2[n_]:=n/2
NestWhileList[divide2,123456,EvenQ]

Plotting the orbit of a point (using NestList[..])

Given a complex number z, we can use NestList[..] to generate the set L={z, p(z), p(p(z)), p(p(p(z))), ... , (p^(°n))(z), ...}. Then we use ListPlot[..] to plot it.

c=N[(1/2) (E^(2 I (Sqrt[2]) π))-(1/4) (E^(4 I (Sqrt[2]) π))];
p[z_]:=z^2+c
L=NestList[p,0,100000];
L2=Table[{Re[L[[k]]], Im[L[[k]]]}, {k,1,Length[L]}];
R=ListPlot[L2]

Plotting the Julia set of a polynomial

Clear[Julia]
Julia[c_,z0_]:=Module[{z=z0,zmax=2,k},
For[k=0,k<100&&Abs[z]<zmax, k++,z=(z^2)+c];
k]

c=-1;
DensityPlot[Julia[c, x+I y],{x,-1.7,1.7},{y,-1,1},Mesh->False,PlotPoints->100, MaxRecursion->4, AspectRatio->1]

DensityPlot[Julia[-0.719-0.25I,x+I y],{x,-1.5,1.5},{y,-1,1},Mesh->False,PlotPoints->100, MaxRecursion->4]

Mathematica has its own functions for plotting Julia sets of quadratic polynomials.
JuliaSetPlot[c] plots the Julia set of the quadratic polynomial z^2+c.

l=Exp[2*Pi*I* Sqrt[2]];
c= l/2-l^2/4;
P=JuliaSetPlot[c, PlotLegends->Automatic]

Show[{P,R}]

JuliaSetPlot[-0.77+0.22I, PlotLegends->Automatic]

JuliaSetPlot[-0.77+0.22I, ColorFunction->None,PlotStyle->Opacity[0.2,Black]]

Properties of the Julia set

We see from the pictures that a point Po belongs to the Julia set if and only if dynamics in a neighborhood of Po displays sensitive dependence on initial conditions, so that nearby initial conditions lead to wildly different behavior after a large (or sometimes not so large) number of iterations.

Definition. A point z in called a fixed point of the polynomial p if p(z)=z, that is z^2+c=z. The quadratic polynomial has at fixed points (counting multiplicities). 
Definition. A fixed point z is called
attracting if |p’(z)|<1 (the derivative of the polynomial at z has absolute value strictly smaller than 1). 
repelling  if |p’(z)|>1.
indifferent if |p’(z)|=1.
Definition. A point z is called a periodic point of the polynomial p is there exists a positive integer n>0 such that (p^(°n))(z)=z.

Properties

All periodic points belong to the filled - in Julia set K.
All repelling periodic points belong to the Julia set J.
All attracting periodic points belong to the interior of the filled-in Julia set that is, they belong to K-J. A quadratic polynomial can have at most one cycle that is attracting or indifferent.

The Julia set is the closure of the repelling periodic points of the polynomial p.

For any point z in the Julia set J, the backward orbit of z, {z, (p^(-1))(z), (p^(°-n))(z)}, is dense in the Julia set.

The Mandelbrot Set

The set of parameter values c for which the (filled-in) Julia set J is connected is called the Mandelbrot set. It can be shown to be equal to the set of all complex numbers c for which the iterations starting at the critical point z0=0 are bounded.

Mathematica has its own functions for plotting the Mandelbrot set.

MandebrotSetPlot[...] - plots the Mandelbrot set 
MandelbrotSetPlot[{(Subscript[z, min]),(Subscript[z, max])}] - plots the portion of the Mandelbrot set inside the rectangle with corners (Subscript[z, min]) and (Subscript[z, max]).

MandelbrotSetPlot[]

Properties:
The Mandelbrot set is connected. It is still an open question whether the Mandelbrot set is locally connected.

c=-0.123+0.745I;
GraphicsRow[{MandelbrotSetPlot[Epilog ->{Red,PointSize[Medium],Point[{Re[c],Im[c]}]}],
JuliaSetPlot[c]},ImageSize->Large]