Final Project - Texas A&M Universitympilant/math614/Student... · Final Project Uma Chidambaram...
Transcript of Final Project - Texas A&M Universitympilant/math614/Student... · Final Project Uma Chidambaram...
Math 614
Final Project
Uma Chidambaram
Statement of the Problem
Michael Barnsley led the development of fractal compression in 1987. The most widely
known practical fractal compression algorithm was invented by Barnsley and Alan Sloan.
One of the most common ways of generating fractals is as the fixed attractor set of an
iterated function system.
Affine Linear Mapping: Affine linear mappings are the composition of a linear
mapping together with a translation. If F is a linear transformation with every point in the
plane and Q is a point, then the mapping: ,)()( QPFP +=ω where P is any point in the
plane, is said to be affine linear. Affine linear mapping help describe contractions
involving positioning in the plane. F is given by a matrix and Q is given by a pair of
coordinates (e, f), an affine linear mapping ω is given by six numbers,
fdc
eba if P = (x, y) and ),()( vuP =ω then
.
,
fdycxv
ebyaxu
++=++=
IFS and the Hutchinson Operator: Let Nωωω ,......,, 21 be N contractions of
the plane. Define a mapping -- the Hutchinson operator – as follows: let A (an image) be
any subset of the plane. The collage obtained by applying the N contractions to A and
assembling the results can be expressed by the collage mapping:
W (A) = ).(........)()( 21 AAA Nωωω ∪∪∪
1
Let A0 be an initial set (image), then we obtain: Ak+1 = W ( Ak ), k = 0, 1, 2, ….
a sequence of sets (images), by repeatedly applying W. An IFS generates a sequence
which tends towards a final image, ∞A which is an attractor of the IFS, and is left
invariant by the IFS: W ( ∞A ) = ∞A .
The Attractor of a Contractive Mapping
A mapping f is a contraction of the metric space X, provided that there is a constant c,
,10 ≤≤c such that for all x, y in X one has that ).,())(),(( yxcdyfxfd ≤ The
constant c is called the contraction factor for f . Let a0, a1, a2,…. be a sequence of
elements from complete metric space X defined by an+1 = f (an). The following holds
true:
(1) There is a unique attractor .lim nn aa ∞→∞ = (2) ∞a is invariant, .)( ∞∞ = aaf
(3) We can predict or estimate how fast the feedback system will arrive close to ∞a
when it is started at a0 within a prescribed accuracy.
Tuning of random number generators If we want probabilities pk, k = 1,….,N, we
define: I1 = [0, p1) ; I2 = [p1, p1+p2); . ; .
Ik = [p1+ p2+….+ pk-1, p1 + p2 +…+ pk); . ; .
IN = [p1 + p2 +…+ pN-1, 1]
choose event k provided the random number ri is in the interval Ik.
With a random number generator it is easy to simulate a biased die. Given probabilities
p1, p2 and p3, we define three intervals
I1 = [0, p1), I2 = [p1, p1 + p2), and I3 = [p1+ p2, 1].
2
Consider an IFS with rotations and three similarity transformations, with scaling factor of
½. The resulting copies are assembled, with N = 10000 and equal probabilities (twin
Christmas tree)
0 0.2 0.4 0.6 0.8 10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
The Cantor maze with three transformations (rotation and scaling) and one of which is a
similarity. The attractor is related to the Cantor set. N = 30,000.
0 0.2 0.4 0.6 0.8 10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
3
Ice Crystal with four transformations including scaling and translation, N = 30,000.
Equal probability is not good for these transformations as we can see.
0 0.2 0.4 0.6 0.8 10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
A dragon with three fold symmetry (rotation), and scaling factor s = 3
1.
0 0.2 0.4 0.6 0.8 10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
4
Crystal with five similarity transformations (scaling and translation): We can see the
Koch curves in the attractor. N = 10,000 and equal probability.
0 0.2 0.4 0.6 0.8 10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Tree with five transformations
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
5
Barnsley’s fern with four transformation, N = 30000. Equal probability is not a good
choice for the fern.
0 0.2 0.4 0.6 0.8 10
0.2
0.4
0.6
0.8
1
Modified Random Iterated Function Systems
The modified random IFS is obtained by applying the transformations to a single point
instead of an image and is given by the same N affine-linear contractions
Nωωω ,......,, 21
and some (positive) probabilities
p1, p2, ….., pN > 0,
where
11
=∑=
N
iip
6
Let s1, s2, s3, …. be a sequence of random numbers which are chosen from the set {1,2,
…,N} independently and with probability pk for the event si = k. Assume z0 is a fixed
point of one of the transformations (eg., 001 )( zz =ω ); then
(1) all points of the sequence ),....(),(, 1220110 zzzzz ss ωω == lie in the
attractor A∞.
(2) the sequence z0, z1, z2,… almost surely fills out the attractor A∞ densely. The
attractor is invariant under the Hutchinson operator
).(...)()( 1 XXXH Nωω ∪∪= Let P be any point of A∞, and its address t1t2…
where }.,....1{ Nti ∈ The point P is contained in all sets
,...2,1),(.....21 == ∞ mAA tmttm ωωω . We have ...321 ⊃⊃⊃ AAA and the
diameter of Am decreases to zero as m increases. Knowing the contractions ratios
c1,..,cN of the transformations ,....,1 Nωω these diameters can be estimated. We
have ).())(( BdiamcBdiam ii ≤ω The diameter of Am can be bounded:
).(.....))(...()( 211 ∞∞ ≤= AdiamcccAdiamAdiam tmtttmtm ωω We can get
from any point of A∞, arbitrarily close to P when playing sufficiently long.
Derivation of the transformations for the Sierpinski Triangle (Random IFS)
A first Chaos game generates the Sierpinski gasket. Suppose the marker points have
coordinates P1 = (a1,b1), P2 = (a2,b2), P3 = (a3,b3). The current game point is zk = (xk, yk),
and the random event is the number n (1, 2, or 3). The next game point is
),,()( 111 +++ == kkknk yxzz ω
where
7
.
2
1
2
1
,2
1
2
1
1
1
nkk
nkk
byy
axx
+=
+=
+
+
In terms of matrix the affine linear transformation nω is given by
n
n
b
a
2
12
1
2
10
02
1
With nnn PP =)(ω , the marker points are fixed. The chaos game can be played with the
following algorithm: Pick z0 arbitrarily in the plane. For k = 0, 1, 2, … set
),(1 kskk zz ω=+ where sk is chosen randomly (with equal probability) from the set {1,
2, 3} and plot zk+1. In step k, sk keeps track of the random choice (throwing of the die).
The sequence s0, s1, s2,…., together with the initial point z0, is a complete description of
the chaos game. Unbiased dice is best for the Sierpinski gasket.
8
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1 1
2 3
For N = 30000 and unequal probabilities (biased die):
9
Chaos Game and Self-Similarity for Julia Sets (continued from mid term)
When points from the escape set close to the Julia set are iterated using the rule
,)( 21 czzfz nncn +==+ they move away from the Julia set and approach infinity. Thus,
we may call the Julia set a repeller with regard to czzfz nncn +==+2
1 )( . Determine the
inverse map: Hence ,21 czz nn +=+ ,22
1 ayxx nnn +−=+ and ,21 byxy nnn +=+
where nnn iyxz += and .ibac += To find the inverse map, we find expressions for xn
and yn in terms of xn+1 and yn+1. Now ,122 axyx nnn −=− + and
.)()(4)()( 21
21
22222222 byaxyxyxyx nnnnnnnn −+−=+−=+ ++ Hence
21
21
22 )()( byaxyx nnnn −+−+=+ ++ since 022 >+ nn yx . Suppose that
21
21 )()( byaxu nn −+−= ++ and .1 axv n −= + Then
vuxn +±= and .2
1
n
nn x
byy
−= +
In terms of computation, xn should not be 0.
Suppose the roots of the former equations are x1 + iy1 and x2 + iy2. If ,1 vux += then
vuy −=1 if y > b, or vuy −−=1 if y < b. The other root is then given by
vux +−=2 and y2 = -y1.
We find the repelling fixed point of the Julia set directly by solving the equation:
02 =+− czz . For c = -0.5+0.5i gives solutions
.275.0408.0
,275.0408.1
2,1
1,1
iz
iz
+−=−=
10
z2 is an attracting fixed point and not a point on the Julia set. z1 is a repeller and is in the
Julia set. We compute the absolute values
.984.0550.0816.0|550.0816.0||2|
869.2550.0816.2|550.0816.2||2|
222,1
221,1
=+=+−=
=+=−=
iz
and
iz
z1,1 is repelling and z1,2 is attracting.
The fixed point is repelling if the modulus |z| is greater than 1/2. For a = -0.5, b = 0.5 and
a = -1, b = 0.4 we get the repelling fixed points at
EDU>> ifs_julia(-0.5,0.5); EDU>> ifs_julia(-1, 0.4);
isunstable = isunstable =
2.8706 3.2829
which are the initial points for the iteration. Julia sets are self-similar and invariant under
forward and backward iteration.
11
-1.2 -0.8 -0.4 0 0.4 0.8 1.2
-0.8
-0.4
0
0.4
0.8
Re z
Im z
12
For a = -1, b = 0.4:
-1.6 -1.2 -0.8 -0.4 0 0.4 0.8 1.2 1.6
-0.8
-0.4
0
0.4
0.8
Re z
Im z
Conclusion
The observation by Mandelbrot [Mand 1982] of the existence of a “Geometry of Nature”
has led us to think in a new scientific way about the edges of clouds, the profiles of the
13
tops of forests on the horizon, and the intricate moving arrangement of the feathers on the
wings of a bird as it flies. The mathematical topics of chaos and fractals are timely, and
many ideas in these fields were first conceived during the students' lifetimes. They are
applicable in fields as diverse as medicine, business, geology, art, and music have
adopted ideas from these areas. And they are beautiful---there is something in the
gorgeous computer generated images of objects such as the Mandelbrot set, Julia sets, the
Koch snowflake, and others that capture students' interest and enthusiasm.
References:
Peitgen, Jurgens, & Saupe. (1992). Fractals for the Classroom (part one).
Peitgen, Jurgens, & Saupe. (1992). Fractals for the Classroom (part two).
Robert L.Devaney. (1992). First Course in Chaotic Dynamical Systems.
Michael Barnsley. (1988). Fractals Everywhere.
Chaos in the Classroom. (1995). Retrieved April 28, 2009, from:
http://math.bu.edu/DYSYS/chaos-game/chaos-game.html
Sierpinski Fractals. (2004). Retrieved April 28, 2009, from:
http://www.student.kuleuven.ac.be/~m0216922/CG/sierpinski.html
Fractals. (1983). Retrieved April 28, 2009, from:
http://chaos.swarthmore.edu/courses/SOC002a/Fractals_1.pdf
Iterated function system. (2009, April 25). Retrieved April 30, 2009, from Wikipedia:
http://en.wikipedia.org/wiki/Iterated_function_system
Appendix: Chaos Game: Sierpinski trianglefunction chaosgame(N) % N = number of iterationsclose all;
14
% Create a new figure window, axes, and scale the axes.fig1=figure;ax1=axes;axis([0,1,0,1]) % Place a message to select points on the screen.txt1=text(.1,.5,'Select three points vertices with the mouse.'); % This command allows to select vertices with the mouse.[x,y]=ginput(3);A=[x(1);y(1)];B=[x(2);y(2)];C=[x(3);y(3)]; % Delete the text message.delete(txt1) % Plot and label vertices selected by user.text(A(1),A(2),'1')text(B(1),B(2),'2')text(C(1),C(2),'3') % Place a text message on the screen.txt2=text(.1,.5,'Select initial point.'); % This command allows to select initial point with the mouse.x=ginput(1);x=x(:); % Makes x a column vector % Delete the text messagedelete(txt2);
% Reserve space for the N points (2 by 1 column vectors) X=zeros(2,N); % Main loop for i=1:N % The function rand produces a random number between 0 and 1. r=rand; % Roll the die if r<1/3 x=mid(x,A); % 1 was rolled. Find midpoint of current point and 1. X(:,i)=x; % store the result for plotting elseif r<2/3 x=mid(x,B); % 2 was rolled. Find midpoint of current point and 2. X(:,i)=x; % store the result for plotting else x=mid(x,C); % 3 was rolled. Find midpoint of current point and 3. X(:,i)=x; % store the result for plotting end % end ifend
15
line(X(1,:),X(2,:),'Color','c',... 'linestyle','none',... 'marker','.'); function u = mid(x, vertex)% Find the midpoint of the segment joining current point and vertex.u=0.5*(x + vertex);
Twin Christmas Tree with three similarity transformations and scaling factor ½.function ifs_1(N)% N = number of iterations% A, B, C, D, E and F = parameters for the IFS figure A = [0.0,0.0,0.5];B = [-0.5,0.5,0.0];C = [0.5,-0.5,0.0];D = [0.0,0.0,0.5];E = [0.5,0.5,0.25];F = [0.0,0.5,0.5];% probabilityP = [1/3,2/3,1];
% initialize two matrices for plot X = zeros(N,2);Y = zeros(N,2); p = plot(X,Y,'.','Erasemode','none','MarkerSize',6);axis([0,1,0,1])axis square
% Main loop for n = 1:N r = rand(1); if r <= P(1) k = 1; elseif r <= P(2) k = 2; else k = 3; end % Transformations X(n+1,:) = A(k)*X(n) + B(k)*Y(n) + E(k); Y(n+1,:) = C(k)*X(n) + D(k)*Y(n) + F(k);end
% plotline(X(:,1),Y(:,2),'Color','c',... 'linestyle','none',... 'marker','.',... 'markersize',1)
Cantor Maze with three transformations and one similarity
16
% parameters of the IFS figureA = [0.333,0.0,0.0];B = [0.0,0.333,-0.333];C = [0.0,1.0,1.0];D = [0.333,0.0,0.0];E = [0.333,0.666,0.333];F = [0.6666,0.0,0.0];% probabilityP = [1/3,2/3,1];
Dragon with threefold symmetry
% parameters of the IFS figureA = [0.0,0.0,0.0];B = [0.577,0.577,0.577];C = [-0.577,-0.577,-0.577];D = [0.0,0.0,0.0];E = [0.0951,0.4413,0.0952];F = [0.5893,0.7893,0.9893];% probabilityP = [1/3,2/3,1];
Ice Crystal with four transformations
function ifs_4(N) % N = number of iterations% parameters of the IFS figureA = [0.255,0.255,0.255,0.370];B = [0.0,0.0,0.0,-0.642];C = [0.0,0.0,0.0,0.642];D = [0.255,0.255,0.255,0.370];E = [0.3726,0.1146,0.6306,0.6356];F = [0.6714,0.2232,0.2232,-0.0061];% probabilityP = [1/4,2/4,3/4,1]; %initialize two matrices for plotX = zeros(N,2);Y = zeros(N,2); p = plot(X,Y,'.','Erasemode','none','MarkerSize',6);axis([0,1,0,1])axis square %Main loopfor n = 1:N r = rand(1); if r <= P(1) k = 1; elseif r <= P(2) k = 2; elseif r <= P(3) k = 3; else
17
k = 4; end % Transformations X(n+1,:) = A(k)*X(n) + B(k)*Y(n) + E(k); Y(n+1,:) = C(k)*X(n) + D(k)*Y(n) + F(k); end%plotline(X(:,1),Y(:,2),'Color','g',... 'linestyle','none',... 'marker','.',... 'markersize',1)
Barnsley’s fern with four transformations% parameters of the IFS figureA = [0.849,0.197,-0.150,0.0];B = [0.037,-0.226,0.283,0.0];C = [-0.037,0.226,0.260,0.0];D = [0.849,0.197,0.237,0.160];E = [0.075,0.400,0.575,0.500];F = [0.1830,0.0490,-0.0840,0.000];% probabilityP = [1/4,2/4,3/4,1];
Crystal with five similarity transformationsfunction ifs_3(N) % N = number of iterations% parameters of the IFS figureA = [0.382,0.382,0.382,0.382,0.382];B = [0.0,0.0,0.0,0.0,0.0];C = [0.0,0.0,0.0,0.0,0.0];D = [0.382,0.382,0.382,0.382,0.382];E = [0.3072,0.6033,0.0139,0.1253,0.4920];F = [0.6190,0.4044,0.4044,0.0595,0.0595];% probabilityP = [1/5,2/5,3/5,4/5,1]; %initialize two matrices for plotX = zeros(N,2);Y = zeros(N,2); p = plot(X,Y,'.','Erasemode','none','MarkerSize',6);axis([0,1,0,1])axis square %Main loopfor n = 1:N r = rand(1); if r <= P(1) k = 1; elseif r <= P(2) k = 2; elseif r <= P(3)
18
k = 3; elseif r <= P(4) k = 4; else k = 5; end % Transformations X(n+1,:) = A(k)*X(n) + B(k)*Y(n) + E(k); Y(n+1,:) = C(k)*X(n) + D(k)*Y(n) + F(k); end%plotline(X(:,1),Y(:,2),'Color','m',... 'linestyle','none',... 'marker','.',... 'markersize',1)
Tree with five transformations% parameters of the IFS figureA = [0.195,0.462,-0.058,-0.035,-0.637];B = [-0.488,0.414,-0.070,0.070,0.0];C = [0.344,-0.252,0.453,-0.469,0.0];D = [0.443,0.361,-0.111,-0.022,0.501];E = [0.4431,0.2511,0.5976,0.4884,0.8562];F = [0.2452,0.5692,0.0969,0.5069,0.2513];% probabilityP = [1/5,2/5,3/5,4/5,1];
Barnsley’s fern: Modified Random Iterated Function Systems
function fern(N)
% N = Number of iterations.close all; % Initialize figure window and axesfig1=figure;ax1=axes; % Initialize space to hold the sequence of points% X1, X2, ..., XNX=zeros(N,2); % The initial value X1 = [0.5,0.5].X(1,:)=[0.5,0.5];
% main loop.for k=1:N-1 r=rand; if r<.01 X(k+1,:)=T(X(k,:),0,0,0,.16,0,0); elseif r<.86 X(k+1,:)=T(X(k,:),.85,.04,-.04,.85,0,1.6); elseif r<.93
19
X(k+1,:)=T(X(k,:),.2,-.26,.23,.22,0,1.6); else X(k+1,:)=T(X(k,:),-.15,.28,.26,.24,0,.44); endend plot(X(:,1),X(:,2),'.','Color','g','markersize',1)
% The transformation Transaxis off function Trans=T(X,a,b,c,d,e,f)Trans=zeros(1,2);Trans(1)=a*X(1)+b*X(2)+e;Trans(2)=c*X(1)+d*X(2)+f;
Chaos Game for Julia Set
function ifs_julia(a, b)%a, b = real and imaginary part of the complex number;close all;%number of iterationsk = 20; N = 2^k;%initialize matrices for real and imaginary values being storedx = zeros(1,N); y = zeros(1,N);x1 = zeros(1,N); y1 = zeros(1,N); x(1) = real(0.5+sqrt(0.25-(a+i*b)));y(1) = imag(0.5+sqrt(0.25-(a+i*b))); %print value when there is a repellerisunstable = 2*abs(x(1)+i*y(1)) hold on%main loop for n = 1:N x1 = x(n); y1 = y(n); u = sqrt((x1-a)^2+(y1-b)^2)/2;v = (x1-a)/2; u1 = sqrt(u+v);v1=sqrt(u-v); x(n+1) = u1;y(n+1)=v1; if y(n) < b y(n+1) = -y(n+1); end if rand < 0.5 x(n+1) = -u1; y(n+1) = -y(n+1); endend fsize = 15; %plotplot(x,y,'k.',’Color’,’r’,'MarkerSize',1)set(gca,'xtick',[-1.6:0.4:1.6],'Color','m','FontSize', fsize)set(gca,'ytick',[-1.2:0.4:1.2],'Color','m','FontSize', fsize)
20
%label the plotxlabel('Re z','FontSize', fsize)ylabel('Im z', 'FontSize', fsize)hold off
21