[R] Fractals in R and having fun! (and more persp and color)

ucgamdo@ucl.ac.uk ucgamdo at ucl.ac.uk
Thu Sep 18 18:28:59 CEST 2003


Hi Martin,

   Thanks a lot for pointing your function out to me. I tried it, and
indeed it is very fast. I will have a close look at the asymmetry problem
in my own code, although this sounds pretty bizarre to me, I mean, I
realised that there was some asymmetry but I didn't really payed attention
to that. I think that the high number of iterations that can be achieved
with your function will be the solution to obtaining 'smoother' slopes in
the perspective plot (i.e. the outer regions that rise progressively
towards the set). If you come with any ideas on how to improve that
perspective let me know. I think I'll have a go to the c code.

Thanks,
Mario.

At 10:21 18/09/03 +0200, you wrote:
>
>    Mario> Well, I started playing with fractals in R, and wrote
>    Mario> a function to generate de Mandelbrot set, which might
>    Mario> be of interest to some people
>
>    Mario>
###################################################################
>    Mario> # Mandelbrot set
>    Mario>
###################################################################
>
>    Mario> mandelbrot <- function(x = c(-3.0, 1.0),   # x coordinates
>    Mario>                        y = c(-1.8, 1.8),   # y coordinates
>    Mario>                        b = .05,            # by 'steps'
>    Mario>                        iter = 20)          # maximum number of
iterations
>
>    <..................>
>    <..................>
>    <..................>
>
>Well, only a bit more than year ago I had posted my version of
>mandelbrot() and a drawing function, see
>
>   http://finzi.psych.upenn.edu/R/Rhelp02a/archive/5898.html
>
>   [ I have a slightly updated version of the R code, that is now
>     available as ftp://stat.ethz.ch/U/maechler/R/Mandelbrot.R
>   ]
>
>which is an order of magnitude more efficient than yours (22 x
>faster for your "b = 0.01", *1), *2)
>and with an iterImage() function for drawing its result in
>several (simple) color schemes.
>I agree that the proper solution would *definitely* use C code!
>
>Your idea of using persp() -- while seen frequently in fractal books,
>is new ``for R'' however, and nice!  Thank you.
>
>
>Regards,
>Martin
>
>*1) mainly because I only have the iteration loop
>    and do the rest vectorized, but also because I have a check
>    for symmetry and make use of it when appropriate
>
>*2) For speed comparison, note that I use 10 x more iterations
>    and a much higher resolution by default
>
>*3) When I do the comparison, I see that your function's result
>    slightly differs from mine -- not for the Mandelbrot set
>    itself, but for the very ``outer points'' (the dark orange
>    ones in the image plot). Your result is
>    asymmetric and hence can't be quite correct.
>
>




More information about the R-help mailing list