LoginSignup
1
0

マンデルブロの指数変化に伴う面積の変化

Last updated at Posted at 2024-03-12

過去に投稿した記事から時を経て、Processingの複素数ライブラリを得たので、指数部を小数にした場合の面積検証。

マンデルブロの指数変化に伴う面積

z_{n+1}=z_n^2+c

上記式について、指数部2を変化させたときの、発散する面積について、その変化を追ってみた。
なお、解像度と繰り返し回数は高くないため、精度は高くありません。
2から増やしていった場合の極限は3.14...多分。
2から減らしていった場合も掲載。

image.png
image.png

processing
import complexnumbers.*;

double d=2.0d;
int count=0;

void setup() {
  size(256, 256);
}

void draw() {
  loadPixels();
  int py=0;
  for (double y = -1.75d; y < 1.75d; y += 3.5d/256.0d)
  {
    int px=0;
    for (double x = -2.0d; x < 1.5d; x += 3.5d/256.0d)
    {
      Complex z = new Complex(0, 0);
      Complex c = new Complex(x, y);
      for (int n = 0; n < 256; n++)
      {
        //z = z.pow(f);
        z = myPow(z, d);
        z = z.add(c);

        if (z.abs() > 2)
        {
          pixels[(int)(py*width+px)] = color(n*10%256);
          n=0;
          break;
        }
        if (n == 255)
        {
          pixels[(int)(py*width+px)] = color(0, 0, 255);
          count++;
        }
      }
      px++;
    }
    py++;
  }
  updatePixels();
  text(str((float)d), 5, 10);
  text(str(count),5,25);
  double area=3.5*3.5*(count/65536d);
  text(str((float)area),5,40); 
  println(d+","+count+","+area);
  //saveFrame("mandelFP#####.png");
  d+=0.1000000000000000000000000d;
  count=0;
}

Complex myPow(Complex c, double n) {
  double r = c.abs();
  double th = c.arg();
  double prn = Math.pow(r, n);
  double re = prn*(Math.cos(n*th));
  double im = prn*(Math.sin(n*th));
  return new Complex(re, im);
}

指数部1000000で3.1417542
image.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0