Results 1 to 5 of 5

Thread: Lscript and fractals

  1. #1

    Lscript and fractals

    Having worked in Ultrafractal for years, I am now exploring how Lightwave can do things for me.

    I only just started studying Lscript yesterday, but to my horror, I found that it cannot handle complex numbers, which are the bread and butter of fractal algorithms.

    Am I correct? If so, is there a known workaround?

    Sorry if this is an obviousd questions, but I thought this forum was the best place to ask..

    Jos Leys

  2. #2
    Well, any computer language cannot handle complex numbers.
    Here's the hint: use separate variables for real and imaginary.
    As an example, Mandelbrot's set:

    z --> z*z + c

    z = x + i*y
    z*z = x*x + 2*i*x*y + i*i*y*y = x*x - y*y + 2*i*x*y

    z_real = x*x - y*y
    z_imag = 2*x*y

    new_z_real = z_real + c_real
    new_z_imag = z_imag + c_imag

    I hope it helps.

  3. #3
    Splitting into real and imaginary parts works for simple formulas, but how about a formula like:

    (z^3+sin(3*z))/(log(z)+tan(z)) or anything as 'complex' as this..

    These things can get very complicated!

    Anyway, thanks for your input!


  4. #4


    Here is a small bunch of hints:

    sin(x+iy): re = sin(x)cosh(y); im = cos(x)sinh(y)
    cos(x+iy): re = cos(x)cosh(y); im = -sin(x)sinh(y)
    tg(x+iy): re = sin(2x)/(cos(2x)+cosh(2y)
    im = sinh(2y)/(cos(2x)+cosh(2y))
    where 're' is the real part, and 'im' is imaginary

    I believe you can implement complex numbers in LScript in a way. Actually, I find your problem very challenging. If you give me the details, I am willing to help.

    Also, here are some link, maybe you will find them useful:

    Numerical Recipes, a book in PDF with examples:

    Useful algorithms, including fractals:

    Science world, including mathematics:


  5. #5
    Yes, you are right, there are formulae for all complex functions to split into real and imaginary. However it is just too cumbersome to work it all out. One of my algorithms has the following:


    which is the definition of two arrays. All variables are complex. I then need to repeatedly multiply the matrices and the inverse matrices. Can you imagine the complexity of continuously splitting into real and imaginary?

    I do appreciate your interest...



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts