File:Julia set for z^2-0.101096363845622 +0.956286510809142*I.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (3,200 × 3,200 pixels, file size: 1.53 MB, MIME type: image/png)

Captions

Captions

Julia set for z^2-0.101096363845622 +0.956286510809142*I

Summary

[edit]
Description
English: Julia set for z^2-0.101096363845622 +0.956286510809142*I. Parametr c is a Misiurewicz point, so Julia set is a dendrite ( connected , without interior points). Algorithms: distance estimation (DEM/J), see also derivative), slope for exterior. PPM file ( binary P6 portable pixmap) is created with pipeline
Date
Source Own work
Author Soul windsurfer

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

c src code

[edit]
#include <complex.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <omp.h> //OpenM

/*
fork of 
mandelbrot-book how to write a book about the Mandelbrot set by Claude Heiland-Alle
https://code.mathr.co.uk/mandelbrot-book/blob/HEAD:/book/

https://stackoverflow.com/questions/77135883/why-do-my-functions-not-work-in-parallel


gcc j.c -lm -Wall -fopenmp

./a.out >ed.ppm   // P6 = binary Portable PixMap see https://en.wikipedia.org/wiki/Netpbm#File_formats


*/



complex double examples [6] = {-0.101096363845622 +0.956286510809142*I, 0.397391822296541  +0.133511204871878*I, I, -0.0649150006787816892861875745218343125883 +0.76821968591243610206311097043854440463 *I, -0.239026451915233+0.415516996006582*I, 0};

const double pi = 3.141592653589793;
int q = 2 ; // degree of multibrot set

/*
 
complex double f(complex double z, int q){ return cpow(z,q) + c;}
complex double d(complex double z, int q) {return q*cpow(z, q-1); }

*/
complex double f(complex double z, complex double c){ return z*z + c;} // multibrot z^q + c
complex double d(complex double z) {return 2*z; } // q*z^{q-1}




double cnorm(double _Complex z) // https://stackoverflow.com/questions/6363247/what-is-a-complex-data-type-and-an-imaginary-data-type-in-c
{
  return creal(z) * creal(z) + cimag(z) * cimag(z);
}

void hsv2rgb(double h, double s, double v, int *red, int *grn, int *blu) {
  double i, f, p, q, t, r, g, b;
  int ii;
  if (s == 0.0) { r = g = b = v; } else {
    h = 6 * (h - floor(h));
    ii = i = floor(h);
    f = h - i;
    p = v * (1 - s);
    q = v * (1 - (s * f));
    t = v * (1 - (s * (1 - f)));
    switch(ii) {
      case 0: r = v; g = t; b = p; break;
      case 1: r = q; g = v; b = p; break;
      case 2: r = p; g = v; b = t; break;
      case 3: r = p; g = q; b = v; break;
      case 4: r = t; g = p; b = v; break;
      default:r = v; g = p; b = q; break;
    }
  }
  *red = fmin(fmax(255 * r + 0.5, 0), 255);
  *grn = fmin(fmax(255 * g + 0.5, 0), 255);
  *blu = fmin(fmax(255 * b + 0.5, 0), 255);
}

int main()
{
  const int aa = 4;
  const int w = 800 * aa;
  const int h = 800 * aa;
  const int n = 1024;
  const double r = 2;
  const double px = r / (h/2);
  const double r2 = 25 * 25;
  unsigned char *img = malloc(3 * w * h);
  
  double _Complex c = examples[q-2];

  #pragma omp parallel for schedule(dynamic)
  for (int j = 0; j < h; ++j)
  {
    
        
    double y = (h/2 - (j + 0.5)) / (h/2) * r;
    for (int i = 0; i < w; ++i)
    {
      double x =  (i + 0.5 - w/2) / (h/2) * r; // for q=2 add -0.5
      double _Complex z = x + I * y;
      double _Complex dz = 1.0; // first derivative of zn with respect to z
      
      
      int k;
      for (k = 0; k < n; ++k)
      { 
        // 
        dz = d(z)*dz ;
        z = f(z,c);
        
        if (cnorm(z) > r2)
          break;
      }
      
      // color
      double hue = 0, sat = 0, val = 1; // interior color = white
      
      if (k < n) 
      { // exterior and boundary color
        double _Complex de = 2 * z * log(cabs(z)) / dz;
        hue = fmod(1 + carg(de) / (2 * pi), 1); // ? slope of de
        sat = 0.25;
        val = tanh(cabs(de) / px / aa);
      }
      
      // hsv to rgb conversion
      int red, grn, blu;
      hsv2rgb(hue, sat, val, &red, &grn, &blu);
      // save rgb color to array
      img[3*(j * w + i)+0] = red;
      img[3*(j * w + i)+1] = grn;
      img[3*(j * w + i)+2] = blu;
    }
  }
  
  //
  printf("P6\n%d %d\n255\n", w, h);
  fwrite(img, 3 * w * h, 1, stdout);
  free(img);
  
  
  return 0;
}

File history

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

Date/TimeThumbnailDimensionsUserComment
current09:02, 21 September 2023Thumbnail for version as of 09:02, 21 September 20233,200 × 3,200 (1.53 MB)Soul windsurfer (talk | contribs)Uploaded own work with UploadWizard

There are no pages that use this file.

File usage on other wikis

Metadata