11
$\begingroup$

Could someone explain why I get those ugly graphics ..

enter image description here

..trying to use fractals in mathematica 8 ?

I'd also like to know if it is possible to draw 2D fractals in Mathematica


My configuration is:

  • Windows 7 64 bits
  • Intel Pentium P600
  • RAM 4Go
  • ATI Mobility Radeon HD5470
$\endgroup$
2
  • $\begingroup$ Does this only happen when rendering the fractal or with any 3D graphics in Mathematica? Have you upgraded your graphics drivers to their latest version? If you haven't, it's something worth doing. $\endgroup$
    – Szabolcs
    Commented Feb 27, 2012 at 21:16
  • $\begingroup$ Related: mathematica.stackexchange.com/questions/104 $\endgroup$ Commented Aug 25, 2012 at 5:06

3 Answers 3

12
$\begingroup$

I think the lower quality you see has to do with the downscaling of the image. It is generated at 512x512 pixels which you can check if you right mouse click on the image, but it isn't displayed that way. So, if I change this to:

OpenCLFractalRender3D[ImageSize -> 512]

I get

Mathematica graphics.

As to your second question: of course you can use Mathematica to generate 2D fractals. It has a rich set of drawing primitives. Examples can be found in the manual (for instance, here).

$\endgroup$
3
  • $\begingroup$ When I do this command, I get nothing -- just "OpenCLFFractalRender3D[ImageSize->512" written, ideas why? How to get the picture? $\endgroup$
    – hhh
    Commented Mar 18, 2013 at 19:31
  • $\begingroup$ @hhh This may be an installation/drfiver/graphics card issue. Currently, I have troubles running this command in Mathematica 9. In v8, installed on the same PC, everything is OK. You may try some of the installation guides in the CUDAlink tutorial. $\endgroup$ Commented Mar 18, 2013 at 21:42
  • $\begingroup$ Additionally, you have to run Needs["CUDALink`"] before that command. What helped me in a reinstallation of the CUDA resources using CUDAResourcesInstall[Update -> True]. $\endgroup$ Commented Mar 18, 2013 at 21:48
12
$\begingroup$

You can certainly draw 2D fractals, eg the Mandelbrot set

ClearAll[mnd]
mnd = Compile[{{m, _Integer}, {n, _Integer}, {steps, _Integer},
{maxiter, _Integer}, {xmax, _Real}},
   Block[{z, c, iters = 0},
    z = c = -xmax + 2.*xmax*n/steps - 0.5 + I*(-xmax + 2.*xmax*m/steps);
    While[(iters < maxiter) && (Abs@z < 2),
     iters++;
     z = z^2 + c
     ];
    Sqrt[iters/maxiter]
    ],
   {{z, _Complex}, {c, _Complex}}
   ];

ListContourPlot[
 Table[
  mnd[m, n, 200, 200, 1],
  {m, 1, 200}, {n, 1, 200}
  ],
 Frame -> False
 ]

Mathematica graphics

or the Hofstadter butterfly

ClearAll[matrix];
matrix[p_,q_,nu_:0]:=Module[
    {sigma},
    sigma=p/q;
    N@SparseArray[
        {{m_,m_} -> 2Cos[2Pi*m*p/q + nu], {i_,j_}/;Abs[i-j] == 1 -> 1},{q,q}]]

ClearAll[attachsigma]
attachsigma[sigma_,lst_]:={sigma,#}&/@lst

fracs = Table[p/q, {q, 2, 80}, {p, 2, q}] // Flatten // 
   DeleteDuplicates;
pq = {Numerator@#, Denominator@#} & /@ fracs;
(ens = Eigenvalues[#] & /@ (matrix[#[[1]], #[[2]]] & /@ pq);) // Timing
pts = Flatten[#, 1] &@MapThread[attachsigma, {fracs, ens}];
plot = Graphics[
  {PointSize[0.001], Point[pts]},
  AspectRatio -> 1,
  ImageSize -> Full
  ]

enter image description here

$\endgroup$
2
  • $\begingroup$ Ok, thanks for your answers. (sorry about the link, i can't post images yet because i'm new) $\endgroup$ Commented Feb 27, 2012 at 22:44
  • $\begingroup$ I am not sure if this is complete Hofstadter butterfly? :) $\endgroup$
    – Shamina
    Commented Mar 12, 2021 at 18:13
4
$\begingroup$

And if disk or screen space is at a premium, have a look at Stephan Leibbrandt´s lovely Mandelbrot oneliner using just 130 characters:

Oneliner Competition 2011

Notebook of the winning entries... quite handy to view with the CDF plugin.

$\endgroup$
1
  • $\begingroup$ Excellent. I especially enjoyed William Wu's entry... $\endgroup$
    – acl
    Commented Feb 28, 2012 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.