{"id":16714426,"url":"https://github.com/newdefectus/mandelbrot","last_synced_at":"2025-03-15T07:40:49.983Z","repository":{"id":70480376,"uuid":"158275364","full_name":"NewDefectus/mandelbrot","owner":"NewDefectus","description":null,"archived":false,"fork":false,"pushed_at":"2019-04-05T10:25:52.000Z","size":640,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-21T22:35:26.218Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NewDefectus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-19T18:57:57.000Z","updated_at":"2019-04-05T10:25:54.000Z","dependencies_parsed_at":"2023-03-11T08:39:48.542Z","dependency_job_id":null,"html_url":"https://github.com/NewDefectus/mandelbrot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NewDefectus%2Fmandelbrot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NewDefectus%2Fmandelbrot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NewDefectus%2Fmandelbrot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NewDefectus%2Fmandelbrot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NewDefectus","download_url":"https://codeload.github.com/NewDefectus/mandelbrot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243701312,"owners_count":20333616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T21:04:57.342Z","updated_at":"2025-03-15T07:40:49.977Z","avatar_url":"https://github.com/NewDefectus.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Interactive Mandelbrot Set\nA user-friendly, satisfying view of the Mandelbrot set fractal, with:\n* Smooth drag-and-drop navigation\n* Paths of the iterating function f\u003csub\u003ec\u003c/sub\u003e(z)\n* Julia sets\n* A customizable palette\n* Support for mobile devices and touchscreens\n\n## What is the Mandelbrot set?\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eComplex numbers\u003c/b\u003e\u003c/summary\u003e\n\nTo understand what the Mandelbrot set is, it's important to first understand the numbers that make it up. These numbers, called\n**complex numbers**, are a little different from the usual \"normal\" numbers. They can be defined as the sum of two parts:\n\n1. The *real part*, which can be any \"normal\" number, including whole numbers (7), fractions (\u0026frac12;), irrationals (\u0026pi;) and so on.\n\n2. The *imaginary part*, which, again, can be any \"normal\" number, except always multiplied by the square root of -1.\n\nThe imaginary part is the confusing bit. There seemingly isn't any number which can be the square root of -1, that is, be equal to -1\nwhen multipled by itself, since any positive number times itself is positive, and any negative number times itself is also positive, right?\nBut the key here is to ignore that fact and simply pretend that such a number exists, even though it's counterintuitive. We call\nthis number the **imaginary unit**, or **i**.\n\nAn example of a complex number is the number *2 + 3i*. The real part, in this case, is simply *2*, while the imaginary part is *3i*,\nor three times the imaginary unit.\n\nTo represent these numbers like we would on a number line, we must not only use a horizontal axis, but also a vertical one, to represent\nthe imaginary part of the numbers. Combining the two axes, we get a two-dimensional plane, which we call the **complex plane**.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eThe Mandelbrot set\u003c/b\u003e\u003c/summary\u003e\n\nAt its core, the Mandelbrot set may be defined as the collection of all complex numbers with a certain special property, explained below:\n\nLet's create a function called f(z). Its input will be *z*, which is some complex number, and its output will be equal to\n\u003e z\u003csup\u003e2\u003c/sup\u003e + c\n\nc is another complex number, but it is not an input; instead it's some constant that we can change as we wish.\n\nIf we plug the number 0 into f(z), it's quite clear that the value we will get is c:\n\u003e f(0) = 0\u003csup\u003e2\u003c/sup\u003e + c = 0 + c = c\n\nNext, let's plug that value once again into f(z):\n\u003e f(c) = c\u003csup\u003e2\u003c/sup\u003e + c\n\nAnd do it again:\n\u003e f(c\u003csup\u003e2\u003c/sup\u003e + c) = (c\u003csup\u003e2\u003c/sup\u003e + c)\u003csup\u003e2\u003c/sup\u003e + c = c\u003csup\u003e4\u003c/sup\u003e + 2c\u003csup\u003e3\u003c/sup\u003e + c\u003csup\u003e2\u003c/sup\u003e + c\n\nAnd again:\n\u003e f(c\u003csup\u003e4\u003c/sup\u003e + 2c\u003csup\u003e3\u003c/sup\u003e + c\u003csup\u003e2\u003c/sup\u003e + c) = (c\u003csup\u003e4\u003c/sup\u003e + 2c\u003csup\u003e3\u003c/sup\u003e + c\u003csup\u003e2\u003c/sup\u003e + c)\u003csup\u003e2\u003c/sup\u003e + c =\nc\u003csup\u003e8\u003c/sup\u003e + 4c\u003csup\u003e7\u003c/sup\u003e + 6c\u003csup\u003e6\u003c/sup\u003e + 6c\u003csup\u003e5\u003c/sup\u003e + 5c\u003csup\u003e4\u003c/sup\u003e + 2c\u003csup\u003e3\u003c/sup\u003e + c\u003csup\u003e2\u003c/sup\u003e + c\n\nIt's a little difficult to see where these values are going without plugging in actual values, so let's try a few simple numbers.\nFor c = 2, the sequence looks like this:\n\u003e f(0) = 0\u003csup\u003e2\u003c/sup\u003e + 2 = 2\n\u003e\n\u003e f(2) = 2\u003csup\u003e2\u003c/sup\u003e + 2 = 4 + 2 = 6\n\u003e\n\u003e f(6) = 6\u003csup\u003e2\u003c/sup\u003e + 2 = 36 + 2 = 38\n\u003e\n\u003e f(38) = 38\u003csup\u003e2\u003c/sup\u003e + 2 = 1,444 + 2 = 1,446\n\nAnd so on. Without plugging in any more values, we can already see that these values will just get bigger and bigger,\ngenerally going towards infinity.\n\nFor c = -1, however, the sequence is different:\n\u003e f(0) = 0\u003csup\u003e2\u003c/sup\u003e + (-1) = 0 + (-1) = -1\n\u003e\n\u003e f(-1) = (-1)\u003csup\u003e2\u003c/sup\u003e + (-1) = 1 + (-1) = 0\n\u003e\n\u003e f(0) = 0\u003csup\u003e2\u003c/sup\u003e + (-1) = 0 + (-1) = -1\n\u003e\n\u003e f(-1) = (-1)\u003csup\u003e2\u003c/sup\u003e + (-1) = 1 + (-1) = 0\n\u003e\n\u003e f(0) = 0\u003csup\u003e2\u003c/sup\u003e + (-1) = 0 + (-1) = -1\n\nNow, the values just jump between 0 and -1 over and over, not really going anywhere. This is the special property that numbers in\nthe Mandelbrot set exhibit: if the sequence that the function f(z) = z\u003csup\u003e2\u003c/sup\u003e + c produces when its values are plugged into itself\nagain and again remains bounded, that is, it does not get bigger and bigger, it is inside of the Mandelbrot set.\n\nAs I've said before, the Mandelbrot set is made up of complex numbers, so let's try plugging some of those in.\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eHow to work out the complex arithmetic\u003c/b\u003e\u003c/summary\u003e\n\nIn order to square a complex number, as the function requires, we simply work it out algebraically. For any complex number a + bi:\n\u003e (a + bi)\u003csup\u003e2\u003c/sup\u003e = a\u003csup\u003e2\u003c/sup\u003e + 2abi + b\u003csup\u003e2\u003c/sup\u003ei\u003csup\u003e2\u003c/sup\u003e\n\nSince i is the square root of -1, we can replace i\u003csup\u003e2\u003c/sup\u003e with just -1:\n\u003e a\u003csup\u003e2\u003c/sup\u003e + 2abi + b\u003csup\u003e2\u003c/sup\u003ei\u003csup\u003e2\u003c/sup\u003e = a\u003csup\u003e2\u003c/sup\u003e + 2abi - b\u003csup\u003e2\u003c/sup\u003e\n\nWhich we can simplify down to a new complex number:\n\u003e (a\u003csup\u003e2\u003c/sup\u003e - b\u003csup\u003e2\u003c/sup\u003e) + (2ab)i\n\nFinally, to add a complex number to another complex number, we just add the real parts together and the complex parts together:\n\n\u003e (a\u003csup\u003e2\u003c/sup\u003e - b\u003csup\u003e2\u003c/sup\u003e) + (2ab)i + (a + bi) = (a\u003csup\u003e2\u003c/sup\u003e - b\u003csup\u003e2\u003c/sup\u003e + a) + (2ab + b)i\u003c/details\u003e\n\n\u0026nbsp;\n\nFor example, c = 2 + 3i:\n\u003e f(0) = 0\u003csup\u003e2\u003c/sup\u003e + 2 + 3i = 2 + 3i\n\u003e\n\u003e f(2 + 3i) = (2 + 3i)\u003csup\u003e2\u003c/sup\u003e + 2 + 3i = -3 + 15i\n\u003e\n\u003e f(-3 + 15i) = (-3 + 15i)\u003csup\u003e2\u003c/sup\u003e + 2 + 3i = -214 - 87i\n\u003e\n\u003e f(-214 - 87i) = (-214 - 87i)\u003csup\u003e2\u003c/sup\u003e + 2 + 3i = 38229 + 37239i\n\nAgain, these values just grow bigger and bigger, occasionally becoming negative, although since we're looking at the absolute value\nof these numbers, growing towards negative infinity should be regarded the same as growing towards positive infinity.\n\nBut if, say, c = 0.2 + 0.3i:\n\u003e f(0) = 0\u003csup\u003e2\u003c/sup\u003e + 0.2 + 0.3i = 0.2 + 0.3i\n\u003e\n\u003e f(0.2 + 0.3i) = (0.2 + 0.3i)\u003csup\u003e2\u003c/sup\u003e + 0.2 + 0.3i = 0.15 + 0.42i\n\u003e\n\u003e f(0.15 + 0.42i) = (0.15 + 0.42i)\u003csup\u003e2\u003c/sup\u003e + 0.2 + 0.3i = 0.0461 + 0.426i\n\u003e\n\u003e f(0.0461 + 0.426i) = (0.0461 + 0.426i)\u003csup\u003e2\u003c/sup\u003e + 0.2 + 0.3i = 0.02064921 + 0.3392772i\n\nIt's a little less certain than when c was -1, but if we plot these points on the complex plane, we actually get a spiral:\n\n\u003cimg src=\"examples/0.2+0.3i_path.jpg\"\u003e\u003c/img\u003e\n\nSo we can conclude quite confidently that when c = 0.2 + 0.3i, the sequence does not grow to infinity. Therefore, 0.2 + 0.3i belongs\nto the Mandelbrot set.\n\nAs it turns out, the Mandelbrot set does not contain just a few numbers; it contains infinitely many numbers. That is, there are infinitely\nmany values of c for which the sequence does not grow to infinity. There are also infinitely many values of c for which the sequence\n*does* grow to infinity. The key is that the values in the Mandelbrot set happen to all lie within one connected and beautiful fractal,\nwhich, when plotted on the complex plane, looks more or less like this:\n\n\u003cimg src=\"icon.png\"\u003e\u003c/img\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJulia sets\u003c/b\u003e\u003c/summary\u003e\n\nA Julia set is another set of complex numbers, but its definition is different than that of the Mandelbrot set. Instead of having the variable c be any of the numbers\non the complex plane, c is now some fixed constant that is the same for every point on the plane, and instead of beginning all the sequences from 0, each sequence will\nbegin with a different complex number on the plane.\n\u003c/details\u003e\n\n## How to use\nClick/tap and drag the screen to navigate the complex plane. Use the mouse wheel (or pinch) to zoom in and out.\nKeyboard keys may also be used (WASD, arrow keys, plus/minus); hold Shift to accelerate movement.\n\nA white pointer can be moved about the screen, with a configurable coordinate at the top-left corner indicating its position on the plane.\nThe pointer may be locked or unlocked in place at any moment by right-clicking (or lightly tapping the screen); this will allow you to\nview the path of the coordinate's function and its graphical representation on the plane.\n\n\u003cimg src=\"examples/path_menu.png\"\u003e\u003c/img\u003e\n\nSettings can be accessed by clicking the icon at the top-right corner; here, you may configure the resolution of the generated image and the\nmaximum number of iterations for the site to calculate, as well as generate a Julia set from the coordinate of the pointer (this can also be done by pressing J).\n\nYou can also choose the palette of your liking from the 3 default options,\nor upload a special image file from your PC to be used as a palette (first row from the top is read from left to right).\nBelow the palettes is an option to color the complex plane continuously or discretely.\n\n\u003cimg src=\"examples/palette_settings.png\"\u003e\u003c/img\u003e\n\nTo share or save your current screen, simply copy the page's current URL; the position and scaling parameters will be reloaded\nonce the link is opened again.\n\n\u003cimg src=\"examples/url.png\"\u003e\u003c/img\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewdefectus%2Fmandelbrot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnewdefectus%2Fmandelbrot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnewdefectus%2Fmandelbrot/lists"}