# Fractals using Mathematica

• Oct 20th 2010, 01:45 PM
Antti
Fractals using Mathematica
I'd like to get fractals out of these functions:

$f(z) = (1 + (-1)^z) \frac{z}{4} + (1 - (-1)^z) \frac{3 z + 1}{2}$

$g(z) = \frac{z}{4} (1 + cos[\pi z]) + \frac{3 z + 1}{16} (1 - cos[\pi z]) (3 - \sqrt{2} cos[(2 z - 1) \frac{\pi}{4}])$

$h(z) = \frac{1}{4} (2 + 7 z - (2 + 5 z) cos[\pi z])$

What I got now looks like this (for one of the equations), and though it can be used to generate some pretty pictures it isn't quite what I want (need). What I would like to see is something like this: Julia Set -- from Wolfram MathWorld

Code:

collatz = Compile[{{z, _Complex}}, Module[{x = z, i = 0, s = 10.^5, vic = 10.^5 + 0.0 I, maxit = 100}, While[i < maxit && Abs[x] < s, i++; x = 1/4 (2 + 7 x - (2 + 5 x) Cos[\[Pi] x]); If[Abs[x] < Abs[vic], vic = Abs[x], vic];]; vic]] sol = Table[ collatz[x + I y], {x, 1.5, 2.5, .003}, {y, -0.5, 0.5, .003}] // Chop; ListDensityPlot[sol, Mesh -> False, ColorFunction -> (Hue)]
Any help would be highly appreciated.