for function f (x) =λsin (πx), λ∈ (0,1], use MATLAB to calculate the value of iteration x=f (x) as λ grows, the code is as follows:
function Y=diedai (f,a,x1)
n=32;
Y=zeros (n,1);
For I=1:1e4
X2=f (A,X1);
x1=x2;
Y (mod (i,n) +1) =x2;
End
End
%[email protected] (a,x) a*x* (1-x);
[Email protected] (a,x) A*sin (pi*x);
%x0=0.1;
Hold on;
For x0=-1:0.05:1
For A=0:0.01:1
Y=diedai (f,a,x0);
For count=1:32
Plot (A,y (count), ' K. ');
Hold on;
End
End
End
The resulting image is as follows: where the horizontal axis is λ, the longitudinal axes are X
It can be seen that as λ gradually increases, there are times when the bifurcation of the cycle.
It can be seen from the figure that the first fork value is around 0.3, the second is between 0.73 and 0.75, the third is between 0.8 and 0.85, and chaos occurs around 0.86. Next write the code to calculate the fork value, the code is as follows:
Format long;
x0=0.1;
For a=0.3182:0.0000001:0.3183
Y=diedai (f,a,x0);
If Max (y) >0.001
Disp (a);
Break
End
End
Get the first fork value of about 0.3182298
Format long;
x0=0.1;
For a=0.7199:0.000001:0.72
Y=diedai (f,a,x0);
If Max (y)-min (y) >0.001
Disp (a);
Break
End
End
Get a second fork value of about 0.719911
Format long;
x0=0.1;
For a=0.8332:0.000001:0.8333
Y=diedai (f,a,x0);
If ABS (Y (+)-y ()) >0.001
Disp (a);
Break
End
End
Get a third fork value of about 0.833267
Using the Feigenbaum constant to estimate the third fork value, we get 0.805939
Fractal chart
Zhou Evergreen
Draw Mandelbrot Fractal chart, mainly uses three functions: Iter=mandelbrot1 (X0,y0,maxiter), used to calculate whether the convergence after the iteration, the equation z=z2+z0. C=color (Iter,maxiter) calculates the color value and returns [R G B]. DRAW_MANDELBROT1 is used to draw images.
function Iter=mandelbrot1 (x0,y0,maxiter)
x=x0;
Y=y0;
For I=1:1:maxiter
if (x*x+y*y) >=4
Iter=i;
Break
Else
tem=x*x-y*y+x0;
Y=x*y*2+y0;
X=tem;
End
Iter=i;
End
End
--------------------------------------------------------------------------------------------------------
function C=color (iter,maxiter)
If Iter==maxiter
c=[1,0,0];
Else
C1=abs (mod ((iter*20+255), 510)-255);
C2=abs (mod ((iter*15+85+255), 510)-255);
C3=abs (mod ((iter*30+171+255), 510)-255);
C=[C1/255,C2/255,C3/255];
End
End
-------------------------------------------------------------------------------------------------------
function draw_mandelbrot1
For Y=0:ymax
For X=0:xmax
Xt=2*r*x/xmax+x0-r;
Yr=r*ymax/xmax;
Yt=2*yr*y/ymax+y0-yr;
ITER=MANDELBROT1 (Xt,yt,maxiter);
%c=color (Iter,maxiter);
C=color (Iter,maxiter);
Plot (Xt,yt, '. ', ' color ', c);
Hold on;
End
End
End
Enter DRAW_MANDELBROT1 ( -0.5,300,0,200,2,300) and the resulting image is as follows:
The color of the convergent part is also drawn, drawing the Julia Fractal chart, mainly using three functions [Xlist,ylist,iter]=julia1 (X0,Y0,MAXITER,JX0,JY0), C=color2 (Iter,maxiter,xlist, Ylist), Draw_julia1 (X0,xmax, Y0,ymax, r,maxiter,jx0,jy0). Where julia1 uses the equation Z ' =z2+zm to iterate, z0=x0+j*y0,zm=jx0+j*jy0; returns to ITER for the number of iterations, COLOR2 based on different ITER, and X, y values, calculated c=[r G b],draw_ Julia1 the drawing.
Enter Draw_julia1 (0,300,0,200,1.6,50,-0.78888,0.212325) in MATLAB to get
The code is as follows:
function [Xlist,ylist,iter]=julia1 (X0,Y0,MAXITER,JX0,JY0)
Xlist (1) =x0;
Ylist (1) =y0;
m=256;
Lnln_m=log (ABS (log (M)));
xbck=0;
ybck=0;
x=x0;
Y=y0;
For I=1:maxiter
if (x*x+y*y>=m)
% Iter=i;
Break
End
Xbck=x;
Ybck=y;
tem=x*x-y*y+jx0;
Y=x*y*2+jy0;
X=tem;
Xlist (i+1) =x;
Ylist (i+1) =y;
End
If I~=maxiter
Lnln_z=log (ABS (log (x*x+y*y)));
Lnln_zbak=log (ABS (log (XBCK*XBCK+YBCK*YBCK)));
iter=i-2-(Lnln_z-lnln_m)/(Lnln_z-lnln_zbak);
Else
Iter=i;
End
End
----------------------------------------------------------------------------------------------------
function C=color2 (iter,maxiter,xlist,ylist)
% Xlist=xylist (1:length (xylist)/2);
% ylist=xylist (Length (xylist)/2:length (xylist));
[Email protected] (x) (Sin (x*2*pi/510-pi*0.5) +1) *0.5*255;
If Iter==maxiter
X=xlist (Maxiter);
Y=ylist (Maxiter);
Z=SQRT (X*x+y*y);
Zd=z-sqrt (Xlist (maxIter-1) *xlist (maxIter-1) +ylist (maxIter-1) *ylist (maxIter-1));
R1=sincolorf (z*2000);
G1=sincolorf (y*x*1000);
B1=sincolorf (zd*1000);
% Errcolor (1) =errcolor (1) +r1;
% Errcolor (2) =errcolor (2) +g1;
% Errcolor (3) =errcolor (3) +b1;
Else
R1=sincolorf (ITER*20);
G1=sincolorf (iter*15+85);
B1=sincolorf (iter*30+171);
% Errcolor (1) =errcolor (1) +r1;
% Errcolor (2) =errcolor (2) +g1;
% Errcolor (3) =errcolor (3) +b1;
End
% Result_r=ftcolor (Errcolor (1));
% Result_b=ftcolor (Errcolor (2));
% Result_g=ftcolor (Errcolor (3));
r=r1/255;
g=g1/255;
b=b1/255;
C=[r G B];
End
--------------------------------------------------------------------------------------------------------------- --------------
function Draw_julia1 (X0,xmax, Y0,ymax, r,maxiter,jx0,jy0)
For Y=1:ymax
For X=1:xmax
Xt=2*r*x/xmax+x0-r;
Yr=r*ymax/xmax;
Yt=2*yr*y/ymax+y0-yr;
[Xlist,ylist,iter]=julia1 (XT,YT,MAXITER,JX0,JY0);
% xylist=[xlist Ylist];
C=color2 (iter,maxiter,xlist,ylist);
Plot (Xt,yt, '. ', ' color ', c);
Hold on;
%drawnow;
End
End
End
It can be seen that by color2 the color in the convergent region can be calculated, the more colorful fractal map, but overall, because of the lack of knowledge, it is difficult to find a suitable color scheme.
Matlab chaotic, fractal