Jump to content

File:Mandelbrot Set Image 114.png

This is a Quality image. Click here for more information.
From Wikimedia Commons, the free media repository
Original file (2,160 × 2,160 pixels, file size: 4.75 MB, MIME type: image/png)

Captions

Captions

Mandelbrot set, Re = -1.7490037929066902375293496792130819738566202119645487337660933175955569168211068192, Im = -0.0002488602025309725942925161073918179803704231449356277752462860384818910358956358, Width = 1.07e-78

Summary

[edit]
Description
Русский: Множества Мандельброта, Re = -1.7490037929066902375293496792130819738566202119645487337660933175955569168211068192, Im = -0.0002488602025309725942925161073918179803704231449356277752462860384818910358956358, Ширина = 1.07e-78
English: Mandelbrot set, Re = -1.7490037929066902375293496792130819738566202119645487337660933175955569168211068192, Im = -0.0002488602025309725942925161073918179803704231449356277752462860384818910358956358, Width = 1.07e-78
Беларуская: Мноства Мандэльброта, Re = -1.7490037929066902375293496792130819738566202119645487337660933175955569168211068192, Im = -0.0002488602025309725942925161073918179803704231449356277752462860384818910358956358, Шырыня = 1.07e-78
Date
Source Own work
Author Aokoroko
Other versions
Source code (C++)
InfoField
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>
#include <atomic>
#include <omp.h>
#include <cstdio>
#include <iomanip>
#include <gmp.h>
#include <mpfr.h>

using namespace std;

const double PI = 3.14159265358979323846;
const mpfr_prec_t MPFR_BITS = 5000;

#pragma pack(push, 1)
struct BMPHeader {
    uint16_t type{0x4D42};
    uint32_t size{0};
    uint16_t reserved1{0};
    uint16_t reserved2{0};
    uint32_t offBits{54};
    uint32_t structSize{40};
    int32_t  width{0};
    int32_t  height{0};
    uint16_t planes{1};
    uint16_t bitCount{24};
    uint32_t compression{0};
    uint32_t sizeImage{0};
    int32_t  xpelsPerMeter{2834};
    int32_t  ypelsPerMeter{2834};
    uint32_t clrUsed{0};
    uint32_t clrImportant{0};
};
#pragma pack(pop)

struct ComplexDouble {
    double re;
    double im;
};

int main() {
    string absc_str, ordi_str, size_str;
    absc_str = "-1.7490037929066902375293496792130819738566202119645487337660933175955569168211068192"; 
    ordi_str = "-0.0002488602025309725942925161073918179803704231449356277752462860384818910358956358"; 
    size_str = "1.07e-78";
    
    const int targetW = 2160;
    const int targetH = 2160;
    const int scale = 8;
    const int rawW = targetW * scale;
    const int rawH = targetH * scale;
    const int frame = 190;
    
    cout << "Step 1: Calculating Reference Orbit using Perturbation..." << endl;
    mpfr_t rx, ry, zr, zi, zr2, zi2, tmp, sz, st;
    mpfr_inits2(MPFR_BITS, rx, ry, zr, zi, zr2, zi2, tmp, sz, st, NULL);
    mpfr_set_str(rx, absc_str.c_str(), 10, MPFR_RNDN);
    mpfr_set_str(ry, ordi_str.c_str(), 10, MPFR_RNDN);
    mpfr_set_str(sz, size_str.c_str(), 10, MPFR_RNDN);
    mpfr_div_ui(st, sz, rawW, MPFR_RNDN);
    double step_d = mpfr_get_d(st, MPFR_RNDN);
    
    double ref_rec_d = mpfr_get_d(rx, MPFR_RNDN);
    double ref_imc_d = mpfr_get_d(ry, MPFR_RNDN);
    
    vector<ComplexDouble> ref_orbit_double(50005);
    mpfr_set_ui(zr, 0, MPFR_RNDN);
    mpfr_set_ui(zi, 0, MPFR_RNDN);
    mpfr_set_ui(zr2, 0, MPFR_RNDN);
    mpfr_set_ui(zi2, 0, MPFR_RNDN);
    uint32_t ref_i = 0;
    bool escaped = false;
    
    while (ref_i < 50000) {
        ref_orbit_double[ref_i].re = mpfr_get_d(zr, MPFR_RNDN);
        ref_orbit_double[ref_i].im = mpfr_get_d(zi, MPFR_RNDN);
        mpfr_mul(tmp, zr, zi, MPFR_RNDN);
        mpfr_mul_ui(zi, tmp, 2, MPFR_RNDN);
        mpfr_add(zi, zi, ry, MPFR_RNDN);
        mpfr_sub(zr, zr2, zi2, MPFR_RNDN);
        mpfr_add(zr, zr, rx, MPFR_RNDN);
        mpfr_mul(zr2, zr, zr, MPFR_RNDN);
        mpfr_mul(zi2, zi, zi, MPFR_RNDN);
        if (escaped) {
            ref_i++;
            break;
        }
        mpfr_add(tmp, zr2, zi2, MPFR_RNDN);
        if (mpfr_cmp_d(tmp, 40000.0) >= 0) {
            escaped = true;
        }
        ref_i++;
    }
    ref_orbit_double[ref_i].re = mpfr_get_d(zr, MPFR_RNDN);
    ref_orbit_double[ref_i].im = mpfr_get_d(zi, MPFR_RNDN);
    uint32_t max_valid_ref_iter = ref_i; 
    mpfr_clears(rx, ry, zr, zi, zr2, zi2, tmp, sz, st, NULL);
    
    uint8_t pal[256][3];
    for (int a = 0; a < 255; ++a) {
        pal[a][0] = (uint8_t)round(127.0 + 127.0 * cos(2.0 * PI * a / 255.0));
        pal[a][1] = (uint8_t)round(127.0 + 127.0 * sin(2.0 * PI * a / 255.0));
        pal[a][2] = (uint8_t)round(127.0 + 127.0 * sin(2.0 * PI * a / 255.0));
    }
    pal[255][0] = 255; pal[255][1] = 255; pal[255][2] = 255;
    
    cout << "Step 2: Stream rendering Mandelbrot Set Image 114.bmp (" << targetW << "x" << targetH << ")..." << endl;
    int rowSize = (targetW * 3 + 3) & ~3;
    BMPHeader header;
    header.width = targetW;
    header.height = targetH;
    header.sizeImage = rowSize * targetH;
    header.size = header.sizeImage + 54;
    ofstream f("Mandelbrot Set Image 114.bmp", ios::binary);
    f.write(reinterpret_cast<char*>(&header), 54);
    vector<uint8_t> rowBuffer(rowSize);
    
    for (int y = 0; y < targetH; ++y) {
        #pragma omp parallel for schedule(dynamic)
        for (int x = 0; x < targetW; ++x) {
            uint32_t rSum = 0, gSum = 0, bSum = 0;
            const ComplexDouble* ref_ptr = ref_orbit_double.data();
            
            for (int j = 0; j < scale; ++j) {
                size_t b = (size_t)y * scale + j;
                double delta_imc = (double)((long long)b - (rawH / 2)) * step_d;
                
                for (int i = 0; i < scale; ++i) {
                    size_t a = (size_t)x * scale + i;
                    double delta_rec = (double)((long long)a - (rawW / 2)) * step_d;
                    
                    uint32_t index = 0;    
                    double delta_re = 0.0; 
                    double delta_im = 0.0;
                    double z_re = 0.0;     
                    double z_im = 0.0;
                    uint32_t iter = 0;
                    bool has_re_based = false;
                    
                    while (iter < 50000) {
                        if ((z_re * z_re + z_im * z_im) >= 40000.0) {
                            break;
                        }
                        
                        if (index >= max_valid_ref_iter) {
                            if (!has_re_based) {
                                break; 
                            } else {
                                double ld_cx = ref_rec_d + delta_rec;
                                double ld_cy = ref_imc_d + delta_imc; 
                                while (iter < 50000 && (z_re * z_re + z_im * z_im) < 40000.0) {
                                    double old_re = z_re;
                                    double old_im = z_im;
                                    z_re = old_re * old_re - old_im * old_im + ld_cx;
                                    z_im = 2.0 * old_re * old_im + ld_cy;
                                    iter++;
                                }
                                break;
                            }
                        }
                        
                        if ((z_re * z_re + z_im * z_im) < (delta_re * delta_re + delta_im * delta_im)) {
                            index = 0; 
                            delta_re = z_re;
                            delta_im = z_im;
                            has_re_based = true;
                        }
                        
                        for (int k = 0; k < 2; ++k) {
                            double Ur = ref_ptr[index].re;
                            double Ui = ref_ptr[index].im;
                            double next_delta_im = 2.0 * Ur * delta_im + 2.0 * Ui * delta_re + 2.0 * delta_re * delta_im + delta_imc;
                            delta_re = 2.0 * Ur * delta_re - 2.0 * Ui * delta_im + delta_re * delta_re - delta_im * delta_im + delta_rec;
                            delta_im = next_delta_im;
                            index++;
                        }
                        z_re = ref_ptr[index].re + delta_re;
                        z_im = ref_ptr[index].im + delta_im;
                        iter += 2; 
                    }
                    
                    int final_t = 50000 - iter;
                    uint8_t t = (final_t == 0) ? 255 : (uint8_t)(final_t % 254);
                    int colorIdx = (t == 255) ? 255 : (t - frame + 255) % 255;
                    bSum += pal[colorIdx][0];
                    gSum += pal[colorIdx][1];
                    rSum += pal[colorIdx][2];
                }
            }                
            int outIdx = x * 3;
            rowBuffer[outIdx + 0] = (uint8_t)(bSum >> 6);
            rowBuffer[outIdx + 1] = (uint8_t)(gSum >> 6);
            rowBuffer[outIdx + 2] = (uint8_t)(rSum >> 6);
        }
        f.write(reinterpret_cast<const char*>(rowBuffer.data()), rowSize);
        if ((y + 1) % 10 == 0 || y == targetH - 1) {
            cout << "Progress: " << (y + 1) << "/" << targetH << "\r" << flush;
        }
    }
    f.close();
    cout << "\nDone! Mandelbrot Set Image 114.bmp successfully saved." << endl;
    return 0;
}

Technical details

[edit]
  • High-Precision Reference: The 5000-bit reference trajectory is computed exactly once per zoom layer.
  • Hardware-Native Performance: Blazing-fast math for billions of pixels utilizing hardware-native double registers.
  • When using double-precision floating-point numbers (on the order of 10-15, perturbation theory only allows you to zoom down to the 10-308 level-no further.
  • Innovative Algorithm: Revolutionary Reference Reset to Zero implementation.
  • True 8x8 SSAA: Pristine, anti-aliased image quality with 64 independent samples per pixel.
  • OpenMP Multi-threading: High-speed parallel computing to maximize CPU utilization.
  • Software: C++ (compiled with g++), GNU C++ Compiler.
[edit]

Notes

[edit]

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

This image has been assessed using the Quality image guidelines and is considered a Quality image.

العربية  جازايرية  беларуская  беларуская (тарашкевіца)  български  বাংলা  català  čeština  Cymraeg  Deutsch  Schweizer Hochdeutsch  Zazaki  Ελληνικά  English  Esperanto  español  eesti  euskara  فارسی  suomi  français  galego  עברית  हिन्दी  hrvatski  magyar  հայերեն  Bahasa Indonesia  italiano  日本語  Jawa  ქართული  Qaraqalpaqsha  한국어  kurdî  кыргызча  Latina  Lëtzebuergesch  lietuvių  македонски  മലയാളം  मराठी  Bahasa Melayu  Nederlands  ਪੰਜਾਬੀ  Norfuk / Pitkern  polski  português  português do Brasil  rumantsch  română  русский  sicilianu  slovenčina  slovenščina  shqip  српски / srpski  svenska  தமிழ்  తెలుగు  ไทย  Tagalog  toki pona  Türkçe  українська  oʻzbekcha / ўзбекча  vèneto  Tiếng Việt  中文  中文(简体)  中文(繁體)  +/−

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current13:21, 20 July 2026Thumbnail for version as of 13:21, 20 July 20262,160 × 2,160 (4.75 MB)Aokoroko (talk | contribs)Uploaded own work with UploadWizard

The following 58 pages use this file:

File usage on other wikis

The following other wikis use this file:

Metadata