{"id":19529671,"url":"https://github.com/sds100/mandelbrotset","last_synced_at":"2026-05-01T21:05:10.088Z","repository":{"id":256569918,"uuid":"131489387","full_name":"sds100/MandelbrotSet","owner":"sds100","description":"A C# Windows Forms application to view the Mandelbrot Set.","archived":false,"fork":false,"pushed_at":"2018-06-22T16:08:05.000Z","size":135,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T02:42:41.747Z","etag":null,"topics":["csharp","dotnet","mandelbrot","mandelbrot-fractal","mandelbrot-sets","mandelbrot-viewer","windows-forms","zoomable"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sds100.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-04-29T11:37:13.000Z","updated_at":"2018-06-22T16:08:07.000Z","dependencies_parsed_at":"2024-09-11T20:17:13.549Z","dependency_job_id":"5572bdbf-7cfb-48f3-a9e0-f3392b0be6bb","html_url":"https://github.com/sds100/MandelbrotSet","commit_stats":null,"previous_names":["sds100/mandelbrotset"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/sds100/MandelbrotSet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds100%2FMandelbrotSet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds100%2FMandelbrotSet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds100%2FMandelbrotSet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds100%2FMandelbrotSet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sds100","download_url":"https://codeload.github.com/sds100/MandelbrotSet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sds100%2FMandelbrotSet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32512691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["csharp","dotnet","mandelbrot","mandelbrot-fractal","mandelbrot-sets","mandelbrot-viewer","windows-forms","zoomable"],"created_at":"2024-11-11T01:26:50.852Z","updated_at":"2026-05-01T21:05:10.064Z","avatar_url":"https://github.com/sds100.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MandelbrotSet\nA C# Windows Forms application to view the Mandelbrot Set.  \n  \n## Roadmap\n- [ ] Add rulers to the bottom and left side.\n- [ ] Export .png image of a user desired portion of the Mandelbrot Set with a custom resolution  \n  \n## Understanding the code  \n\nThis is mainly for me so if I ever come back to this project, I can understand what my crazy mind was thinking. You can also read it to learn (maybe) about complex numbers and the Mandelbrot Set. \n\n\u003e ### What is a complex number?\n\u003e A complex number is a number expressed in the form a + bi where *a* and *b* are real numbers and *i* is an \"imaginary number\". For example 7 + 3*i* where *i* could be ![](https://latex.codecogs.com/svg.latex?\\sqrt{-1})\n\n\u003e ### The algorithm\n\u003e ![](https://latex.codecogs.com/svg.latex?Z_%7Bn\u0026plus;1%7D%3DZ_%7Bn%7D%5E%7B2%7D\u0026plus;C)  \n\u003e *Z* and *C* are complex numbers.\n\nFor example, where ![](https://latex.codecogs.com/svg.latex?Z_%7B1%7D) (the first iteration of Z) and C are ![](https://latex.codecogs.com/svg.latex?%283%20\u0026plus;%204i%29)...\n\n![](https://latex.codecogs.com/svg.latex?Z_%7B2%7D%3DZ_%7B1%7D%5E%7B2%7D%20\u0026plus;%20C)  \n![](https://latex.codecogs.com/svg.latex?Z_%7B2%7D%3D%283\u0026plus;4i%29%5E%7B2%7D%20\u0026plus;%20%283\u0026plus;4i%29)  \n![](https://latex.codecogs.com/svg.latex?Z_%7B2%7D%3D%283\u0026plus;4i%29%283\u0026plus;4i%29%20\u0026plus;%20%283\u0026plus;4i%29)  \n![](https://latex.codecogs.com/svg.latex?Z_%7B2%7D%3D9\u0026plus;12i\u0026plus;12i\u0026plus;16i%5E%7B2%7D\u0026plus;%283\u0026plus;4i%29)  \n![](https://latex.codecogs.com/svg.latex?Z_%7B2%7D%3D9\u0026plus;24i\u0026plus;16i%5E%7B2%7D\u0026plus;%283\u0026plus;4i%29)  \n\n![](https://latex.codecogs.com/svg.latex?16i%5E2%20%3D%20-16) because...  \n![](https://latex.codecogs.com/svg.latex?16i%5E2%20%3D%2016%5Csqrt%7B-1%7D%5E2)  \n![](https://latex.codecogs.com/svg.latex?%3D%2016%20*%20-1)  \n![](https://latex.codecogs.com/svg.latex?%3D%20-16)  \n\nTherefore...  \n\n![](https://latex.codecogs.com/svg.latex?Z_%7B2%7D%3D9\u0026plus;24i-16\u0026plus;%283\u0026plus;4i%29)  \n![](https://latex.codecogs.com/svg.latex?Z_%7B2%7D%3D-7\u0026plus;24i\u0026plus;%283\u0026plus;4i%29)  \n![](https://latex.codecogs.com/svg.latex?Z_%7B2%7D%3D-7\u0026plus;24i\u0026plus;3\u0026plus;4i)  \n![](https://latex.codecogs.com/svg.latex?Z_%7B2%7D%3D-4\u0026plus;28i)\n\n![](https://latex.codecogs.com/svg.latex?%28-4\u0026plus;28i%29) is then substituted back into the formula.\n\n### How do you write the algorithm in code?\n\nThe type of variable we choose to store Z and C as massively affects how far we can zoom in before bands start appearing down the screen. This happens because the limits of floating point precision are met. By using BigDecimal (in C#), we can overcome this but it is MUCH slower.\n\n*i* can be represented by it's coefficient.\n\n```c#\n    while (z_real * z_real + z_im * z_im \u003c 4 \u0026\u0026 iteration \u003c MAX_ITERATIONS)\n    {\n      double z_real_tmp = (z_real * z_real) - (z_im * z_im) + c_real;\n\n      z_im = 2 * z_real * z_im + c_im;\n      z_real = z_real_tmp;\n    }\n```\n\n![](https://latex.codecogs.com/svg.latex?Z%7B_%7Br%7D%7D) (z_real) is calculated from ![](https://latex.codecogs.com/svg.latex?Z%7B_%7Br%7D%7D%5E%7B2%7D%20-%20Z%7B_%7Bi%7D%7D%5E%7B2%7D%20\u0026plus;%20C_%7Br%7D)\n  \nand\n  \n![](https://latex.codecogs.com/svg.latex?Z%7B_%7Bi%7D%7D) (z_im) is calculated from ![](https://latex.codecogs.com/svg.latex?2*Z_%7Br%7D*Z_%7Bi%7D\u0026plus;C_%7Bi%7D). because...  \n  \nThe formula in its most basic terms is... ![](https://latex.codecogs.com/svg.latex?%28a\u0026plus;bi%29%28a\u0026plus;bi%29\u0026plus;a\u0026plus;bi) which simplifies to...  \n![](https://latex.codecogs.com/svg.latex?a%5E%7B2%7D\u0026plus;2abi\u0026plus;bi%5E%7B2%7D\u0026plus;a\u0026plus;bi)  \n![](https://latex.codecogs.com/svg.latex?a%5E%7B2%7D-b%5E%7B2%7D\u0026plus;2abi\u0026plus;a\u0026plus;bi)  \n![](https://latex.codecogs.com/svg.latex?a%5E%7B2%7D-b%5E%7B2%7D\u0026plus;a\u0026plus;2abi\u0026plus;bi)\n\nThe real terms ![](https://latex.codecogs.com/svg.latex?%28a%5E%7B2%7D-b%5E%7B2%7D\u0026plus;a%29) are grouped together to calculate ![](https://latex.codecogs.com/svg.latex?Z%7B_%7Br%7D%7D). ![](https://latex.codecogs.com/svg.latex?%28a%5E%7B2%7D-b%5E%7B2%7D\u0026plus;a%29) is the same as ![](https://latex.codecogs.com/svg.latex?Z%7B_%7Br%7D%7D%5E%7B2%7D%20-%20Z%7B_%7Bi%7D%7D%5E%7B2%7D%20\u0026plus;%20C_%7Br%7D).  \nThe complex terms ![](https://latex.codecogs.com/svg.latex?%282abi\u0026plus;bi%29) are grouped together to calculate ![](https://latex.codecogs.com/svg.latex?Z%7B_%7Bi%7D%7D). ![](https://latex.codecogs.com/svg.latex?%282abi\u0026plus;bi%29) is the same as ![](https://latex.codecogs.com/svg.latex?2*Z_%7Br%7D*Z_%7Bi%7D\u0026plus;C_%7Bi%7D).  \n\n\n### Using a ComplexNumber class\n```c#\n  // Convert the pixel coordinate to the equivalent coordinate on the given portion of the complex plane.\n  double c_real = ((pixelCoords.X - bitmapWidth / 2) * planeWidth / bitmapWidth)\n      + planeCentre.X;\n\n  double c_im = ((pixelCoords.Y - bitmapHeight / 2) * planeHeight / bitmapWidth)\n      + planeCentre.Y;\n\n  var z = new ComplexNumber(0,0);\n  var c = new ComplexNumber(c_real, c_im);\n            \n  int iteration = 0;\n  \n  while (z.Normal \u003c 4 \u0026\u0026 iteration \u003c MAX_ITERATIONS)\n  {\n      z = z * z + c;\n\n      iteration++;\n  }\n```\n\n### How do you multiply two complex numbers?\nFor example, If we multiply out these brackets and simplify where *i* = ![](https://latex.codecogs.com/svg.latex?%5Cinline%20%5Csqrt%7B-1%7D)\n\n![](https://latex.codecogs.com/svg.latex?%5Cinline%20%284%20\u0026plus;%203i%29%282%20\u0026plus;%202i%29)  \n![](https://latex.codecogs.com/svg.latex?%5Cinline%208%20\u0026plus;%208i%20\u0026plus;%206i%20\u0026plus;%206i%5E%7B2%7D)  \n![](https://latex.codecogs.com/svg.latex?%5Cinline%208%20\u0026plus;%2014i%20\u0026plus;%206i%5E%7B2%7D)  \n\nAnd since we know that *i* is an imaginary number which is is the square-root of a real number.  \n![](https://latex.codecogs.com/svg.latex?%5Cinline%206i%5E%7B2%7D)  \n= ![](https://latex.codecogs.com/svg.latex?%5Cinline%206%5Csqrt%7B-1%7D%5E%7B2%7D)  \n= ![](https://latex.codecogs.com/svg.latex?%5Cinline%206%20*%20-1)  \n= ![](https://latex.codecogs.com/svg.latex?%5Cinline%20-6)\n\nTherefore...  \n![](https://latex.codecogs.com/svg.latex?%5Cinline%208%20\u0026plus;%2014i%20\u0026plus;%206i%5E%7B2%7D)  \n= ![](https://latex.codecogs.com/svg.latex?%5Cinline%208%20\u0026plus;%2014i%20-6)  \n= ![](https://latex.codecogs.com/svg.latex?%5Cinline%202%20\u0026plus;%2014i)\n\nThere we go!  \n![](https://latex.codecogs.com/svg.latex?%5Cinline%20%284%20\u0026plus;%203i%29%282%20\u0026plus;%202i%29) = ![](https://latex.codecogs.com/svg.latex?%5Cinline%202%20\u0026plus;%2014i)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsds100%2Fmandelbrotset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsds100%2Fmandelbrotset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsds100%2Fmandelbrotset/lists"}