Magic Fractal art (4): Julia set and Mandelbrot set

Source: Internet
Author: User

Consider the function f (z) = Z ^ 2-0.75. After the z0 value is fixed, we can iteratively calculate a series of Z values: z1 = f (z0), Z2 = f (z1 ), z3 = f (Z2 ),.... For example, when z0 = 1, we can iterate one by one:
Z1 = f (1.0) = 1.0 ^ 2-0.75 = 0.25
Z2 = f (0.25) = 0.25 ^ 2-0.75 =-0.6875
Z3 = f (-0.6875) = (-0.6875) ^ 2-0.75 =-0.2773
Z4 = f (-0.2773) = (-0.2773) ^ 2-0.75 =-0.6731
Z5 = f (-0.6731) = (-0.6731) ^ 2-0.75 =-0.2970
...
It can be seen that the Z value is always within a certain range and will eventually converge to a certain value.
But when z0 = 2, the situation is different. After several iterations, we will immediately find that the Z value eventually tends to be infinite:
Z1 = f (2.0) = (2.0) ^ 2-0.75 = 3.25
Z 2 = f (3.25) = (3.25) ^ 2-0.75 = 9.8125
Z 3 = f (9.8125) = (9.8125) ^ 2-0.75 = 95.535
Z 4 = f (95.535) = (95.535) ^ 2-0.75 = 9126.2
Z 5 = f (9126.2) = (9126.2) ^ 2-0.75 = 83287819.2
...
After calculation, we can draw the following conclusion: When z0 belongs to [-1.5, 1.5], the Z value will never exceed a certain range. When z0 is less than-1.5 or greater than 1.5, the Z value will eventually become infinite.
Now, we extend this function to the entire range of plural numbers. For the plural z0 = x + Iy, different x values and y values are taken. Function Iteration results are different: for some z0 values, function values are restricted within a certain range; for some other z0, the function value is infinitely divergent. Because the plural number corresponds to the point on the plane, we can use a Plane Chart to represent which z0 function values eventually tend to be infinite and which z0 function values do not eventually tend to be infinite. We use dark gray to indicate that the function value will not be infinitely z0; for other z0, we use different colors to differentiate different divergence speeds. Because the function value must be divergent when | z |> 2, the divergence speed is defined as: Make | z | less iterations than 2, the faster the divergence speed. This graphic can be programmed to draw. Like the last time, I used Pascal, because I would not operate on C graphics. A mm is going to have a birthday. I will send the picture I programmed to her ^_^

{$ASSERTIONS+}

uses graph;

type
   complex=record
      re:real;
      im:real;
   end;

operator * (a:complex; b:complex) c:complex;
begin
   c.re := a.re*b.re - a.im*b.im;
   c.im := a.im*b.re + a.re*b.im;
end;

operator + (a:complex; b:complex) c:complex;
begin
   c.re := a.re + b.re;
   c.im := a.im + b.im;
end;

var
   z,c:complex;
   gd,gm,i,j,k:integer;
begin
   gd:=D8bit;
   gm:=m640x480;
   InitGraph(gd,gm,'');
   Assert(graphResult=grOk);

   c.re:=-0.75;
   c.im:=0;
   for i:=-300 to 300 do
   for j:=-200 to 200 do
   begin
      z.re:=i/200;
      z.im:=j/200;
      for k:=0 to 200 do
      begin
         if sqrt(z.re*z.re + z.im*z.im) >2 then break
         else z:=(z*z)+c;
      end;
      PutPixel(i+300,j+200,k)
   end;

   readln;
   CloseGraph;
end.

The code is compiled in Windows XP SP2 and FPC 2.0. Please report whether the program is running normally (someone told me that the drawing program I wrote was not compiled ). Here, the program runs as follows:

This beautiful fragment shows the Julia set at f (z) = Z ^ 2-0.75. Consider the plural function f (z) = Z ^ 2 + C. Different plural functions correspond to different Julia sets. That is to say, every time you get a different C, you can get a different Julia set fragment graph. What's surprising is that every fragment graph is so beautiful. The following six images show different points of the C-worth fragment. You may not believe that such a simple constructor can generate such a beautiful image. You can change the value of the C variable in the code above to verify it in person.

C = 0.45,-0.1428

C = 0.285, 0.01

C = 0.285, 0

C =-0.8, 0.156

C =-0.835,-0.2321

C =-0.70176,-0.3842

Similarly, we fix z0 = 0, so the Function Iteration results vary for different complex numbers of C. Because the complex number C corresponds to the point on the plane, we can use a plane image to represent a complex number C, function f (z) = Z ^ 2 + C whether the iteration starts from z0 = 0 to infinity. We also use different colors to express different divergence speeds. The final result is the Mandelbrot set fractal image:

As mentioned above, a fragment graph can be infinitely recursive, and its complexity does not disappear as the scale decreases. The magic of the Mandelbrot set is that you can zoom in on this fractal image, and you may see different scenes at different scales. If you zoom in to a certain point, you can see a smaller scale of the Mandelbrot set, which proves that the Mandelbrot set is self-similar. The following 15 images demonstrate a scale-up process of the Mandelbrot set. You can see the fragment of different styles in this process.

You can find many small programs on the Internet to enlarge the Mandelbrot set. You can also write a program to change the code given above.
Be honest, please refer to the source

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.