Docsity

Fractals: Dimensions, Julia and Mandelbrot Sets, Complex Numbers, and Event Programming, Assignments of Physics

Partial preview of the text

Download Fractals: Dimensions, Julia and Mandelbrot Sets, Complex Numbers, and Event Programming and more Assignments Physics in PDF only on Docsity!

Lec6 – More fractals

  • Dimensions ...
  • Julia and Mandelbrot fractals
  • Event driven programming
  • Arrays

Next 2 weeks

  • I will be away for the next 2 weeks and Prof. Jen Schwarz will be taking over.
  • She is an expert in the physics of percolation theory which is closely related to fractals. Teach you some of this.
  • The course will function the same way - lectures on Tuesdays, lab on Thursdays with a Thursday homework.

Julia sets

Consider the very simple non-linear map

xn+1 = x^2 n − 3 4 For most starting values of x the final x = ∞! In fact x only remains bounded if |x| < 3 / 2 See by drawing graphs of y = x and y = x^2 − (^34)

  • The boundary between the two regions in x (diverging and non-diverging) is called the Julia set of the map and contains seem- ingly 2 points x = −^32 and x = (^32)
  • Things much more interesting if we allow ourselves to consider complex numbers

Complex numbers

Summary:

  • Complex number has 2 parts – real and imaginary z = x + iy
  • Needed to give answer to question: what is square root of a negative number.
  • Add/subtract by adding/subtracting corre- sponding parts
  • Multiply out using usual rules and collect terms together with the simple rule i^2 = − 1
  • Magnitude |z| =

√ (x^2 + y^2 )

Maps of complex numbers

Consider previous map for complex numbers

zn+1 = zn ∗ zn −

  • What is now the region in which |z| diverges under iteration of the map?
  • The region of convergence is called the filled-in Julia set B and the boundary be- tween between diverging and non-diverging sets is the Julia set of the map.
  • Remarkably it is a fractal !!
  • The boundary is rough on all scales.

Arrays in python

  • Similar to lists eg x[2] is 2nd element of an array x
  • Restricted to reals and integers. eg

x = array([2, 2], F loat)

x = zeros(5, Int)

  • Allows one to use powerful fast functions to do array processing eg.

x = y + 0. 1 adds 0.1 to all elements of arrays x and y which must (obviously) be of the same size and shape.

Zooming ...

  • Julia sets as seen from the complex plane look quite fractal – that is they exhibit lots of structure at small scales. One way to see this more clearly would be examine some portion under high magnification.
  • Would be nice to be able to zoom in ....
  • This can be done picking out some point and recomputing the Julia set on a small region around that point.
  • This point can be selected by clicking with the mouse.
  • Requires new event programming techniques.

Event programming

#event loop while(1): #look for mouse clicks/drags if scene.mouse.events: my_event=scene.mouse.getevent()

if left click increase scale factor

if my_event.press==’left’ scale_factor=zoom #get screen coordinates target=my_event.pos ...

More fractals – Mandelbrot

  • Can play a new game. Set initial z=0 and it- erate the Julia set map with variable “con- stant ” a.
  • New famous fractal – the Mandelbrot frac- tal