Fractal solution, Plotting complex plane in Matlab
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEja-XXLbUQfftaML-44-b2naSC0_s30tdtXmJDckRyZZ-ctVsQF0ceSSpiCnG9j4nj-khpIVxh5OspTzvKfsL9wYByoIF_3x1kctSpwpRu6Sg9LbtsQI72m0PB9u2Qlnwfi6gns/s320/fig.jpg)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhpC0roB9aLEB8MJmyo5fQtn05aVLBUIKwoudAN9tpvHlJuT6R8iRRdbzYxJyt0jeqmz1MjBMcgIogicLK6k6zPPj3YMTsCv8C8LrjGKeKX4YL1Bx6Ebb-TL9ggST6LPwhhGVym/s320/fhk2p42.jpg)
The following is a solution set for a function f(z) =z^4+8iz^2-25. The roots of the function are
2-i, -2+i, -1+2i and 1-2i
The color shows which values will converge to the solution in the complex place
The complete matlab program is as below
% Using Newton Basin method to plot in complex plane
% The complex function is z^4+8iz^2-25
% There are 4 roots 2-i, -2+i, -1+2i and 1-2i of the above function
% It shows how starting with different points root converge
tol =.01;
a=0;
b=2;
c=0;
d=2;
m=1000;
n=1000;
x=linspace(a,b,m); % Setting up the x axis Coordinate System a to b
y=linspace(c,d,n); % Setting up the y axis Coordinate System c to d
z1=2-i; % root 1
z2=-2+i; % root 2
z3=-1+2i; % root 3
z4=1-2i; % root 4
lmax=20;
r=ones(n,m); % Setting a n*m matrix to be all 1
for j=1:n
for k=1:m
z=x(k)+i*y(n-j+1); % Generating the complex number, Note n-j+1
if z == 0;
z = tol;
endif
for l = 1:lmax % Newton iteration
zz = (3*z^4+8*i*z^2+25)/(4*z^3+16*i*z); % Newton's Formula for Iteration
if abs(z-zz) < tol
if abs(z-z1) < tol
r(j,k) =1; %Red
elseif abs(z-z2)
elseif abs(z-z3)
elseif abs(z-z4) < tol
r(j,k) = 42; %Deep Blue
endif
break
else
z=zz;
endif
endfor
endfor
endfor
colormap('hsv')
image(r)
axis square
axis off
0 Comments:
Post a Comment
<< Home