How can I make my own fractals?

  • Thread starter pierce15
  • Start date
  • Tags
    Fractals
In summary, a fractal generator may be able to generate a similar fractal to the Mandelbrot set, but an expert is needed to optimize the equation.
  • #1
pierce15
315
2
Hello everyone. You probably all know about the Mandelbrot set. I am not here to ask questions about the set itself, but how I can graph fractals similar to it. Is there a program where I can input my own equations? Or would I have to be a java expert to do so? The fractals that I want to make are similar to the Mandelbrot set: I want the computer to color a point black if the point converges after a number of iterations and I want to color the points that do not converge according to escape time.

By the way, I don't know the first thing about programming/computer science.
 
Physics news on Phys.org
  • #2
http://www.dmoz.org/Science/Math/Chaos_and_Fractals/Software
 
  • #3
Great link, that one. Thanks Borek.
 
  • #4
Borek said:
http://www.dmoz.org/Science/Math/Chaos_and_Fractals/Software

Would you recommend any of these in particular for a mac? I downloaded a few and most of them only allow you to examine preset functions. Do any of them allow you to input your own functions?

Also, I am worried that even if I find a decent fractal generator, it may not be able to do what I want. I am interested in generating a fractal where, in the style of the mandelbrot set, a point z is colored black if it converges for ##z^z^z...## and it is colored based on escape time if it diverges.
 
Last edited:
  • #5
Sorry, can't help you further.
 
  • #6
I don't understand anything about fractals, so be careful with this.

This is a few lines written in Mathematica which I think tries to do what you are asking for. It creates a square matrix of z^z^z... as long as the z^z^z are within a distance of 2 from the origin. Some wiki page said that was the criteria for escaping to infinity. It only builds a tower of z^z^z... 20 levels high before it bails out and assumes it will never escape. Then it displays a plot of that table. It does this over -2<=a<=2, -2<=b<=2 with steps of .01 for a and b. Norm[] is a function that calculates the distance from the origin to a point.

In[1]:= ArrayPlot[
Table[n = 0; z = a + I*b; r = z;While[Norm[r] < 2. && n < 20, r = r^z; n++]; n,{a, -2., 2., .01}, {b, -2., 2., .01}]
]

Out[1]= <plot snipped and attached>

I assumed your equation wouldn't be fractal because it seemed too simple to me. The first half dozen times I tried this I got a round black disk and thought I was right. Then I changed something to try to make this more readable and got a black sheet. That seemed wrong and I changed all kinds of things before I got the attached image. This may still be wrong, but you need someone who knows a lot more than I do to tell if this is right or not.

If I have errors in this and someone can explain how I am supposed to fix it then I would try to do that.

Mathematica is not free. For some it isn't even cheap. But it does run on Mac. If you ask very very nicely you can get a free trial version that works for a couple of weeks or a month. If you arranged to have nothing else to do and didn't sleep and you saw how to ask questions about Mathematica so you quickly got good answers then you might be able to learn a lot and get a lot of fractal images from various equations done before your trial expired. I would suggest getting an introductory book on Mathematica and learning as much as you can before you ask for your trial so that you don't spend your limited trial time frustrated with little problems instead of getting good pictures done. I don't think the trial let's you save files, so you may be limited to capturing the images on the screen.

If you want a few more images of this changing the location, the resolution, the maximum number of steps or zooming in on part of this then I would offer to do a few more experiments to help you get ready to start doing this yourself.

If after your trial you decide Mathematica is the tool for you then there are somewhat reasonably priced versions for home use. Add the price of a couple of books that will help you learn how to use it and you can try to learn to do fractals and lots of other things.

One other caution. As you see, Mathematica can be very flexible and you can change the function you use as well as anything else, but such flexibility sometimes comes at the price of speed. The simple example I showed will be substantially slower than a carefully optimized program written by an expert. It is sometimes possible to speed up Mathematica calculations, but that often requires more knowledge than a beginner can easily find.
 

Attachments

  • zfrac.jpg
    zfrac.jpg
    22.9 KB · Views: 508
Last edited:
  • #7
Bill Simpson said:
I don't understand anything about fractals, so be careful with this.

This is a few lines written in Mathematica which I think tries to do what you are asking for. It creates a square matrix of z^z^z... as long as the z^z^z are within a distance of 2 from the origin. Some wiki page said that was the criteria for escaping to infinity. It only builds a tower of z^z^z... 20 levels high before it bails out and assumes it will never escape. Then it displays a plot of that table. It does this over -2<=a<=2, -2<=b<=2 with steps of .01 for a and b. Norm[] is a function that calculates the distance from the origin to a point.

In[1]:= ArrayPlot[
Table[n = 0; z = a + I*b; r = z;While[Norm[r] < 2. && n < 20, r = r^z; n++]; n,{a, -2., 2., .01}, {b, -2., 2., .01}]
]

Out[1]= <plot snipped and attached>

I assumed your equation wouldn't be fractal because it seemed too simple to me. The first half dozen times I tried this I got a round black disk and thought I was right. Then I changed something to try to make this more readable and got a black sheet. That seemed wrong and I changed all kinds of things before I got the attached image. This may still be wrong, but you need someone who knows a lot more than I do to tell if this is right or not.

If I have errors in this and someone can explain how I am supposed to fix it then I would try to do that.

Mathematica is not free. For some it isn't even cheap. But it does run on Mac. If you ask very very nicely you can get a free trial version that works for a couple of weeks or a month. If you arranged to have nothing else to do and didn't sleep and you saw how to ask questions about Mathematica so you quickly got good answers then you might be able to learn a lot and get a lot of fractal images from various equations done before your trial expired. I would suggest getting an introductory book on Mathematica and learning as much as you can before you ask for your trial so that you don't spend your limited trial time frustrated with little problems instead of getting good pictures done. I don't think the trial let's you save files, so you may be limited to capturing the images on the screen.

If you want a few more images of this changing the location, the resolution, the maximum number of steps or zooming in on part of this then I would offer to do a few more experiments to help you get ready to start doing this yourself.

If after your trial you decide Mathematica is the tool for you then there are somewhat reasonably priced versions for home use. Add the price of a couple of books that will help you learn how to use it and you can try to learn to do fractals and lots of other things.

One other caution. As you see, Mathematica can be very flexible and you can change the function you use as well as anything else, but such flexibility sometimes comes at the price of speed. The simple example I showed will be substantially slower than a carefully optimized program written by an expert. It is sometimes possible to speed up Mathematica calculations, but that often requires more knowledge than a beginner can easily find.

Thanks a lot! That thing looks really cool! What did you change about the equation?
 
  • #8
piercebeatz said:
Thanks a lot! That thing looks really cool! What did you change about the equation?

I tried to use what I thought your equation was, that was to check z, z^z, z^z^z, z^z^z^z,... until that was either a distance of 2 or more away from the origin or until it had a stack of 20 exponents and I bailed out.

The fumbling around was trying to make the example as simple and understandable as I possibly could, so you or others could hopefully understand it and point out any mistakes.

If you are fairly sure what the equation should be then you might be able to calculate the result for some particular value of z. If you let me know what the values for z and powers of z are then I could see if I'm getting the same result you are. That might help expose mistakes.
 
  • #9
I have a program that generates the Mandelbrot Set on my http://schnitzld.appspot.com/projects/1 [Broken]. It's written in JavaScript and uses the new HTML 5 canvas tag. The source is cobbled together from a couple of other programs that I have referenced, and I have grand plans for it that include a much better color palette and much deeper zoom. You can view the source.

I'm posting it because the program is actually very simple, and the platform (JavaScript/HTML5) is available to most anyone with a computer, without downloading any extra software. All of the meaningful code is inside the drawMandelbrot() function and all it does is set some initial parameters and then with a system of three loops, iterates over every x,y coordinate on the canvas (that's two loops, for all x, for all y) and then runs an inner loop (for i until max_iterations) to determine whether the complex number that defines that x,y coordinate (i.e 1 + 2i is x,y coord 1,2) is part of the set or not. The maths is very easy, and the program is too.

As for generating other fractals, I have a program called ChaosPro but to be honest, I haven't used it much, or recently. I believe you can load new formulas as files and use it to generate your own, but you would have to investigate that yourself.
 
Last edited by a moderator:
  • #10
Bill Simpson said:
I tried to use what I thought your equation was, that was to check z, z^z, z^z^z, z^z^z^z,... until that was either a distance of 2 or more away from the origin or until it had a stack of 20 exponents and I bailed out.

The fumbling around was trying to make the example as simple and understandable as I possibly could, so you or others could hopefully understand it and point out any mistakes.

If you are fairly sure what the equation should be then you might be able to calculate the result for some particular value of z. If you let me know what the values for z and powers of z are then I could see if I'm getting the same result you are. That might help expose mistakes.

You've got the idea, that's exactly what I want to do. How long did that take your computer to render? By the way, I was not even sure if it would be a fractal. I had no knowledge going into this what it might look like.

Edit: My math teacher suggested that I find a way to do this by iterations. I'll spare you the ugly work, but here is the value of ##(a+bi^{(c+di)}##:
$$(a+bi^{(c+di)}=(a^2+b^2)^{c/2}e^{-d*\text{arctan}(b/a)}\text{cis}(d*\text{ln}(a^2+b^2)/2)\text{cis}(c*\text{arctan}(b/a))$$

Thus, the iteration is:

$$a+bi \to (a+bi^{(c+di)}=(a^2+b^2)^{c/2}e^{-d*\text{arctan}(b/a)}\text{cis}(d*\text{ln}(a^2+b^2)/2)\text{cis}(c*\text{arctan}(b/a))$$

c+di is the complex number whose convergence we are testing. a+bi is the number that is obtained from an iteration. Thus, for the initial iteration, a+bi=c+di.
 
Last edited:
  • #11
For the simple example I showed: about 35 seconds.
Cut the step size in half, so 4x the points, and raise exponents to 40: about 5 minutes 40 seconds.

I'm not sure whether doing the repeated multiplies would be slower than doing the arctan and cis and log or not.
 
  • #12
Can I see the higher quality version?
 
  • #13
Doesn't look much different to me
 

Attachments

  • zfrac2.jpg
    zfrac2.jpg
    22.3 KB · Views: 413
  • #14
This is great. It appears, at the bottom left and right of the set, that points outside the radius of 2 converge. Could you make try making the set bounded by a circle of radius 3?
 
Last edited:
  • #15
I still have no idea whether this is correct or not.
I'm guessing the wiki "diverges for x>2" may only apply for repeated squaring and not for your exponentiating

In[1]:= ArrayPlot[
Table[n=0;z=a+I*b;r=z;While[Norm[r]<3.&&n<20,r=r^z;n++];n,{a,-3.,3.,.01},{b,-3.,3.,.01}]
]

Out[1]= plotSnipped

In[2]:= Export["zfrac3.jpg",%,ImageResolution->200]

Out[2]= zfrac3.jpg
 

Attachments

  • zfrac3.jpg
    zfrac3.jpg
    25.7 KB · Views: 462
  • #16
Do you know what it means if an area is grayer than another area? Is that based on escape time?
 
  • #17
The darker it is the more z's in z^z^z^z... were needed before the value of that became greater than 2 (or 3).

So out side the circle of radius 2 (or 3) is white because it took zero exponents to be greater than 2 (or 3), in other words z was already enough.

The slightly darker shade just inside the circle took one exponent, z^z to escape. The next darker shade in the "bands" on the "wings" took two exponents, z^z^z to escape.

The black center did not escape in 20 (or 40) exponents.
 
  • #18
around the one and a half second mark in Mathcad 15 on a Dell Dimension 521 (Athlon 54 dual-core 2.5 GHz with 4GiB RAM running Windows 7 32-bit) - the lighter the image, the quicker the escape. Around one second for an n=64 standard Mandelbrot over the same x and y ranges.

attachment.php?attachmentid=54495&stc=1&d=1357517664.jpg
 

Attachments

  • phys - 13 01 06 fractal 01.jpg
    phys - 13 01 06 fractal 01.jpg
    20.6 KB · Views: 783
  • #19
NemoReally said:
around the one and a half second mark in Mathcad 15 on a Dell Dimension 521 (Athlon 54 dual-core 2.5 GHz with 4GiB RAM running Windows 7 32-bit) - the lighter the image, the quicker the escape. Around one second for an n=64 standard Mandelbrot over the same x and y ranges.

That's interesting that yours rendered much more quickly than Bill's... Do you think that it is because your program is faster?

I'm considering investing in a math program solely for creating original fractals like this one (although good graphing abilities and other features wouldn't hurt). Should I get the Mathematica student edition? Any other recommendations?

Thanks
 
  • #20
piercebeatz said:
That's interesting that yours rendered much more quickly than Bill's... Do you think that it is because your program is faster?
Depends what you mean by 'program'. I'm using Mathcad, a completely different application. I think the Mathcad program I showed is equivalent to the Mathematica one which implies that Mathcad is faster, but it may be that the Mathematica Table function is slower than an equivalent Mathematica For program.

I'm considering investing in a math program solely for creating original fractals like this one (although good graphing abilities and other features wouldn't hurt). Should I get the Mathematica student edition? Any other recommendations?

Thanks

If you're going to solely create fractals, then I'd recommend a specialized fractal application. If you want a generalized application then it would be helpful to know what else you would want to do. Mathematica SE seems like a very good choice. However, I use Mathcad because it's a good general purpose mathematical application that allows the user to use near-standard maths notation to write equations and display/graph results on the same 'piece of paper'. The image I posted is exactly as the Mathcad worksheet looks, including the fractal plot (*).

Have a look at http://www.ptc.com/product/mathcad/ - you can download an evaluation copy and the user forum http://communities.ptc.com/community/mathcad is a pretty good place to ask for advice.

-------------------

(*) The gray dotted line that goes across the plot is where the page boundary would be if I'd printed the worksheet as is - I'd move stuff around to avoid this if I was actually going to print it. The image below shows a variant of the program in which I'd shuffled the 'regions' further up the page. It also illustrates another feature of Mathcad, that is the ability to write programs across the page as well as down the page. Mathcad evaluates left-to-right then top-to-bottom. Consequently, the second function f supersedes the first definition resulting in a Mandelbrot like figure (note the power of z is 2.1 rather than 2, hence the bident rather than the single prong along the negative x-axis).

attachment.php?attachmentid=54506&stc=1&d=1357548127.jpg
 

Attachments

  • phys - 13 01 06 fractal 02.jpg
    phys - 13 01 06 fractal 02.jpg
    18.3 KB · Views: 759
  • #21
NemoReally said:
Depends what you mean by 'program'. I'm using Mathcad, a completely different application. I think the Mathcad program I showed is equivalent to the Mathematica one which implies that Mathcad is faster, but it may be that the Mathematica Table function is slower than an equivalent Mathematica For program.



If you're going to solely create fractals, then I'd recommend a specialized fractal application. If you want a generalized application then it would be helpful to know what else you would want to do. Mathematica SE seems like a very good choice. However, I use Mathcad because it's a good general purpose mathematical application that allows the user to use near-standard maths notation to write equations and display/graph results on the same 'piece of paper'.

Do you know of any specialized fractal programs? Also, is it possible to color the fractals that you render in Mathcad? Do you know if this is possible for Mathematica?
 
  • #22
I assumed from the wording of the posts before I got into this that the original poster was a beginner, didn't know a lot about this and just wanted to get started. What I originally provided in Mathematica was intended to be as simple as possible so that a beginner might be able to understand it. I carefuly and intentionally put nothing more in that than absolutely necessary. There are things that could be added that would speed it up, but with additional complexity to have to understand.

If the original question had been "I have years of experience, how can I make this go fast?" then my answer might have been very different.

Take a look at
http://mathematica.stackexchange.com/questions/104/speeding-up-this-fractal-generating-code
and see how this speeds up the process by orders of magnitude. I can understand some of that, but I have not yet been able to see how to incorporate your fractal function. Those folks are usually way beyond my skill level.

To answer your question about color, change my original simple code thus

ArrayPlot[Table[n = 0; z = a + I*b; r = z; While[Norm[r] < 3. && n < 20, r = r^z; n++]; n, {a, -3., 3., .01}, {b, -3., 3., .01}], ColorFunction ->Hue, ColorFunctionScaling -> True]

While I really hesitate to describe in "market terms", everything comes at some price. If you want to change the way a result looks you have to pay some price to accomplish that, if you want to make something faster you have to pay some price to accomplish that. The price may be small or not.

As a general rule of thumb I expect that if figuring out how to get something sort of working takes x then figuring out how to get it really exactly working precisely correctly takes between two and ten x more, getting a graphic result display that sort of shows what is going on takes another x, getting the graphics correct to show what is going on takes two to five x more and getting the graphics to be exactly precisely they way that you want them in every detail takes five to twenty x more and possibly even infinity times x more for some people.

I don't want to diminish your motivation or excitement. However you might keep this in mind. Every math operation, +,-,*,/,^ creates a bit more error. If you only do a small number of those operations then you only get a small amount of additional error. If you do lots and lots and lots of those operations you get more and more and more error. Fractal calculations do few operations in some places. Those places are almost always a single simple color. Fractal calculations do vast vast numbers of operations in some places. Those places are almost always where the complicated patterns and colors appear. Thus I propose that it is possible that almost everything about fractals is little or nothing more than a graphical display of floating point calculation error. There is a lot more that could be written to support this, but this is probably long enough already and saying anything against the myth of fractals is perhaps a lost cause anyway.
 

Attachments

  • zfrac4.jpg
    zfrac4.jpg
    38.1 KB · Views: 507
Last edited:
  • #23
piercebeatz said:
Do you know of any specialized fractal programs? Also, is it possible to color the fractals that you render in Mathcad? Do you know if this is possible for Mathematica?
a. I'm afraid I don't know of any specialized fractal programs - Googling should give you a list.
b. Yes, see image below. It makes use of a short function mono2colr (not displayed) that indexes the count into a colour map. Note that I've changed the function to raise z to the cube root of a for this example - gives it a slightly Escher look, IMO.
c. Yes, Bill Simpson has already answered this one.

attachment.php?attachmentid=54532&stc=1&d=1357607514.jpg
 

Attachments

  • phys - 13 01 07 fractal 02.jpg
    phys - 13 01 07 fractal 02.jpg
    28.9 KB · Views: 579
  • #24
Bill, like I said, I don't know anything about computer science, so you were correct about your assumptions. When I get the chance, I'm going to invest in the Mathematica student edition and continue to play around with these fractals (and maybe one day write an award winning essay!).
 

1. What is a fractal?

A fractal is a geometric figure that has a repeating pattern at different scales. This means that as you zoom in or out on a fractal, you will see the same pattern repeated over and over again.

2. What software do I need to make my own fractals?

There are many software options available for creating fractals. Some popular choices include Mandelbulb 3D, Ultra Fractal, and Apophysis. Many of these programs are available for free online.

3. How do I create a fractal?

The process of creating a fractal varies depending on the software being used. However, the basic steps involve selecting a fractal formula, adjusting parameters such as zoom level and color, and then rendering the image. It may take some experimentation and practice to get the desired results.

4. Can I make my own fractals without any programming knowledge?

Yes, there are many fractal software programs that do not require any programming knowledge. However, having a basic understanding of mathematical concepts such as complex numbers and recursion can be helpful in creating more complex and unique fractals.

5. Are there any resources available for learning about fractal creation?

Yes, there are many online tutorials, forums, and communities dedicated to fractal creation. You can also find books and articles that discuss the mathematics behind fractals and how to create them. Additionally, many fractal software programs have built-in help and tutorials to guide you through the process.

Similar threads

Replies
4
Views
523
Replies
6
Views
833
  • General Discussion
Replies
6
Views
2K
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
503
  • Beyond the Standard Models
Replies
5
Views
2K
Replies
4
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
26
Views
3K
Replies
10
Views
870
Replies
1
Views
631
Back
Top