Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7724657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:44:40+00:00 2026-06-01T04:44:40+00:00

So I read up this article: http://www.wikihow.com/Plot-the-Mandelbrot-Set-By-Hand But I’m stuck at step 7. I’m

  • 0

So I read up this article: http://www.wikihow.com/Plot-the-Mandelbrot-Set-By-Hand
But I’m stuck at step 7. I’m drawing the set in javascript canvas.

All I need is basicly the C value I guess.

for (var y = 0; y < ImageHeight; y++) {
    for (var x = 0; x < ImageWidth; x++) {

        // Pixel-Position for ImageObject
        var xy = (x + y * image.width) * 4;

        // Convert Image-Dimension to a radius of 2
        var xi = ((x / ImageWidth) * 4) - 2;
        var yi = ((y / ImageHeight) * 4) - 2;

        for (var n = 0; n < MaxIterations; n++) {

            // Complex number stuff..?
            z = (xi*xi) + (yi*yi) + c;
            c = 0; // Somethig with z ..?

            if (z < 4) {

                image.data[xy] = inner_color[0];
                image.data[xy+1] = inner_color[1];
                image.data[xy+2] = inner_color[2];
                image.data[xy+3] = Math.round(n * cdiff);

            } else {

                image.data[xy] = outer_color[0];
                image.data[xy+1] = outer_color[1];
                image.data[xy+2] = outer_color[2];
                image.data[xy+3] = Math.round(n * cdiff);

                break;
            }
        }
    }
}

I also read up a lot about imaginary numbers and stuff, but I didn’t quite understood how to calculate with them. And they seem somehow useless to me because you’d have to convert them back to real numbers anyways to do logic operations in javascript for example.

Here is what it looks like: [removed]
If you remove the 2 at the end of the url, you see another version where I just rewrote a little c++ snippit.
But zooming is somehow weird, which is why I want to write it all on my own..

I understood the basic concept of the mandelbrot set creation but as I said the complex part is troubling me. Is there maybe an even simpler explanation out there ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:44:42+00:00Added an answer on June 1, 2026 at 4:44 am

    You have to understand this first:

    z = z^2 + c
    

    Let’s break it down.

    Both z and c are complex numbers (and a recent question taught me to emphasize this, they have fractional digits, and can look like this: c=-0.70176-0.3842i). Complex numbers can have a part that is ‘not real’, the proper term is imaginary part, and you write a single complex number in the form:

    (a + bi) which is the same as: (a + b*i)

    If b is 0, then you have a a + 0i which is simply a so without an imaginary part you have a real number.

    Your link does not mention the most important property of a complex number, especially a property of its imaginary part that i == sqrt(-1). On the field of Real numbers there is no such thing as a square root of a negative number and that’s where complex numbers come in and allow you to have the square root of -1. Let’s raise i to the power of 2: i^2 == -1, magick!

    The imaginary part (i) has to be either handled by you (the special square-ing) or the programming language you work with will offer a Complex type which handles it for you.

    Now back to expanding z^2:

    z == (a+bi), therefore z^2 == (a+bi)^2 so z^2 == (a^2 + bi^2 + 2*a*bi).

    Let’s break this down as well:

    • a^2 => this is simple, it is a real number
    • bi^2 => The tricky part. This is really b^2*i^2. And we got here an i^2, which is -1 and that makes it b^2*-1 or : -b^2. So this is also a real number.
    • 2*a*b*i => this will be the imaginary part

    Result: z^2 = (a^2-b^2+2*a*bi)

    Example (a bit over-detailed. You can think of it as the first iteration in your loop):

    z = (5 + 3i)
    z^2 = (5 + 3i)^2
        = (5^2 + 3^2*i^2 + 2*5*3i)
        = (25 + 9i^2 + 30i)
        = (25 + 9*-1 + 30i)
        = (25 - 9 + 30i)
        = (16 + 30i)
    

    Now if you understand the iteration and the multiplication of complex numbers, some words on Mandelbrot (and on the c value):

    When you want to create a Mandelbrot set, you are really looking for points on the complex plane, that never goes to infinity if iterated over – say 50 times – with the iteration discussed above. The Mandelbrot set is the black part of the usually seen “Mandelbrot” pictures and not the shiny, colored part.

    Mandelbort set, taken from Wikipedia

    The usual workflow is this:

    • choose a point on the complex plane, say (1.01312 + 0.8324i) => this will be the value of c !
    • before the first iteration put (0, 0i) into z then iterate over a number of times as stated before => z = z^2 + c. Yes, you are squaring a point and adding that same point to it, this is a very important attribute of the Mandelbrot set. For a starter do this 50 times. This will give you a complex number as result.
    • if any part of the resulting complex number (either the Real, or the Imaginary) is equal to, or larger than 2, then we assume this point would go to infinity and we consider this point not being part of the Mandelbrot set*. This is the case when you need to color the point (this is the colorful part of the Mandelbrot set). If both part of the complex number are less than 2, we assume the point would never go to infinity (even if iterated over zillion times), and consider this point as part of the Mandelbrot set and its color will be black.
    • repeat (choose the next point, put its value into c, put zero into z and calculate)

    *actually, verifying if a point is part of the set is a bit more complicated, but this works well for prototypes

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just read this article: http://www.acunetix.com/websitesecurity/upload-forms-threat.htm which discusses some of the security risks involved
I have a silly question. I read this article about std::exception http://www.cplusplus.com/doc/tutorial/exceptions/ On catch
Recently I've read this article: http://www.smashingmagazine.com/2009/09/25/svn-strikes-back-a-serious-vulnerability-found/ Developers of many popular sites like apache.org, php.net
I read this great article about best-practice for EJB-JNDI mapping : http://www.ibm.com/developerworks/websphere/library/bestpractices/increase_app_portability.html The notion
I read this article here http://www.codeproject.com/KB/web-security/RolesFormsAuthorization.aspx What is the limitation of Membership that would
I read this article, the parts of Intellisense and Generated Code: http://www.charlespetzold.com/etc/DoesVisualStudioRotTheMind.html Do you
I've just read about @Resource annotation from this article ( http://www.infoq.com/articles/spring-2.5-part-1 ) and wish
I have read from this article http://codahale.com/how-to-safely-store-a-password/ and it says using a salt isn't
Okay so I read this post http://facebook.stackoverflow.com/questions/10373897/deleting-a-previosly-posted-article-with-opengraph-or-check-if-said-article-has but I'm using the news.reads action type.
I've recently read an article http://www.ravelrumba.com/blog/static-cookieless-domain/ about Serving Static Content from a Cookieless Domain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.