跳轉到內容

分形/複平面迭代/離散拉格朗日描述符

來自華夏公益教科書,開放世界的開放書籍

連續時間動力系統(拉格朗日描述流的方法)[1] [2] [3] [4] 是分析相空間結構的一種方法。這裡[5] [6] [7] [8] 該方法擴充套件到離散動力系統:複平面上的開放對映。



完整原始碼在公共頁面上(點選影像)

關鍵詞

[編輯 | 編輯原始碼]

復對映

[編輯 | 編輯原始碼]

對映


黎曼球面

[編輯 | 編輯原始碼]

黎曼球面上的點


立體投影逆變換

[編輯 | 編輯原始碼]
從北極到球體下方平面的立體投影的 3D 圖示

立體投影逆變換將複平面的點 對映到黎曼球面上的點


所以



 
 



向量 -範數(也稱為 -範數)是[9]


其中

  • 數字 p 是實數 。它被稱為冪。它會影響奇點(如朱利亞集等分形特徵)附近的梯度的陡峭程度

p-範數用於度量對映 f 在黎曼球面上連續迭代之間的距離

離散拉格朗日描述符 = DLD

[編輯 | 編輯原始碼]
  The simple idea is to compute the p-norm version of Lagrangian descriptors, not for the points on the complex plane, but for their projections on the Riemann sphere in the extended complex plane.
  ... in the complex mappings that we consider in this work, the functions that define the dynamics are not invertible, and therefore we will only keep the forward part of the definition.  

DLD

  • 是一個標量值
  • 累積軌道的 p-範數(= 包含有關軌道歷史的資訊),因此揭示了朱利亞集內部和外部的結構
 summing is what the original paper does ( pauldelbrot)

其中

  • N 是固定迭代次數
  • 是複平面上有界子集 D 上選取的任何初始條件
  • 是黎曼球面上的一個點:
 "averaging keeps the coloring stable if maxiters is changed but can lead to low variation over the image" pauldelbrot

對於複平面上的每個點 z

  • 計算 DLD(標量值)
  • 顏色與 DLD 成比例

子步驟:計算 z 的 DLD

  • 在對映 f 下迭代點 z = 計算 zn
  • 將每個點 zn 從複平面對映到黎曼球面(反立體投影)
  • 對於每個 zn 計算被加數
  • ... (待辦事項)

程式碼

[編輯 | 編輯原始碼]

UltraFractal

[編輯 | 編輯原始碼]
DLD {
; Based on https://arxiv.org/pdf/2001.08937.pdf
; ucl file for UltraFractal by pauldelbrot
init:
  float sum = 0.0
  float lastx = 0.0
  float lasty = 0.0
  float lastz = 0.0
  int i = 0
loop:
  float d = |#z|
  float dd = 1/(d + 1)
  ; Riemann sphere coordinates = (xx, yy,zz)
  float xx = 2*real(#z)*dd
  float yy = 2*imag(#z)*dd
  float zz = (d - 1)*dd     
  :
  IF (i > 0)
    sum = sum + (xx - lastx)^@power + (yy - lasty)^@power + (zz - lastz)^@power
  ENDIF
  i = i + 1
  lastx = xx
  lasty = yy
  lastz = zz
final:
  #index = sum/(i - 1)
default:
  title = "Discrete Langrangian Descriptors"
  param power
    caption = "Power"
    default = 0.25
    hint = "Affects the steepness of the gradient near singularities (fractal features like a Julia set)"
    min = 0.0
  endparam
}
  " Here's the latest version I've been using in UF. It handles escaping points with no-bail formulae via the isInf/isNaN test (puts the Riemann sphere point at the north pole for those), allows averaging or summing (summing is what the original paper does, whereas averaging keeps the coloring stable if maxiters is changed but can lead to low variation over the image), and can use or not use absolute values on the differences being summed." pauldelbrot
DLD {
; Based on https://arxiv.org/pdf/2001.08937.pdf
; ucl file for UltraFractal by pauldelbrot
init:
  float sum = 0.0
  float lastx = 0.0
  float lasty = 0.0
  float lastz = 0.0
  int i = 0
loop:
  float d = |#z|
  float dd = 1/(d + 1)
  float xx = 2*real(#z)*dd
  float yy = 2*imag(#z)*dd
  float zz = (d - 1)*dd     ; Riemann sphere coordinates
  IF (isInf(d) || isNaN(d))
    ; Infinity, or thereabouts
    xx = 0
    yy = 0
    zz = 1
  ENDIF
  IF (i > 0)
    IF(@qabs)
      sum = sum + abs(xx - lastx)^@power + abs(yy - lasty)^@power + abs(zz - lastz)^@power
    ELSE
      sum = sum + (xx - lastx)^@power + (yy - lasty)^@power + (zz - lastz)^@power
    ENDIF
  ENDIF
  i = i + 1
  lastx = xx
  lasty = yy
  lastz = zz
final:
  IF(@qsum)
    #index = sum
  ELSE
    #index = sum/(i - 1)
  ENDIF
default:
  title = "Discrete Langrangian Descriptors"
  param power
    caption = "Power"
    default = 0.25
    hint = "Affects the steepness of the gradient near singularities (fractal features like a Julia set)"
    min = 0.0
  endparam
  param qsum
    caption = "Sum"
    default = false
    hint = "Averages if false, sums if true."
  endparam
  param qabs
    caption = "Abs differences"
    default = false
  endparam
}

Fragmentarium

[編輯 | 編輯原始碼]

基於 UF 程式碼的程式碼,由 3Dickulus 為 GLSL 修改和最佳化[10]

#include "Complex.frag"
#include "MathUtils.frag"
#include "Progressive2D.frag"
#info Unveiling Fractal Structure with Lagrangian Descriptors
#info https://fractalforums.org/fractal-mathematics-and-new-theories/28/unveiling-the-fractal-structure-of-julia-sets-with-lagrangian-descriptors/3376/msg20446#msg20446

#group Lagrangian

// Number of iterations
uniform int  Iterations; slider[1,200,1000]
uniform vec3 RGB; slider[(0,0,0),(0.0,0.4,0.7),(1,1,1)]
uniform bool Julia; checkbox[false]
uniform vec2 JuliaXY; slider[(-2,-2),(-0.6,1.3),(2,2)]
uniform float p; slider[0,.6,1]

/* partial pnorm
   input: z, c, p
   output ppn
*/

float ppnorm( vec2 z, vec2 c, float p){

	vec3 s0,s1; // for 2 points on the Riemann sphere
	float d; // denominator
	float ds;

	// map from complex plane to riemann sphere
	// z
	d = z.x*z.x + z.y*z.y + 1.0;
	s0 = vec3(2.0*z,(d-2.0))/d;
	// zn
	d = c.x*c.x + c.y*c.y + 1.0;
	s1 = vec3(2.0*c,(d-2.0))/d;
	// sum
	vec3 ss = pow(abs(s1 - s0),vec3(p));
   ds = ss.x+ss.y+ss.z;

	return ds;
}

// DLD = Discret Lagrangian Descriptior
float lagrangian( vec2 z, vec2 c, float p ){

	int i; // number of iteration
	float d = 0.0; // DLD = sum

	for (i=0; i<Iterations; ++i){
		d += ppnorm(z, c, p); // sum z
		z = cMul(z,z) +c; // complex iteration
		if (cAbs(z) > 1e19 ) break; // exterior : upper limit of float type
	}

	d /= float(i); // averaging not summation

	return d;
}

vec3 color(vec2 c) {
	vec2 z = Julia ? c : vec2(0.,0.);
	if(Julia) c = JuliaXY;
	float co = lagrangian( z, c, p );
	return .5+.5*cos(6.2831*co+RGB);
}

#preset Default
Center = -0.724636541,0.025224931
Zoom = 0.64613535
EnableTransform = false
RotateAngle = 0
StretchAngle = 0
StretchAmount = 0
Gamma = 2.2
ToneMapping = 1
Exposure = 1
Brightness = 1
Contrast = 1
Saturation = 1
AARange = 2
AAExp = 1
GaussianAA = true
Iterations = 20
RGB = 0,0.4,0.7
p = 0.1444322
Julia = false
JuliaXY = -1.05204872,0
Bailout = 1000
#endpreset

#preset Basilica
Center = -0.025346913,-0.013859176
Zoom = 0.561856826
EnableTransform = false
RotateAngle = 0
StretchAngle = 0
StretchAmount = 0
Gamma = 2.2
ToneMapping = 1
Exposure = 1
Brightness = 1
Contrast = 1
Saturation = 1
AARange = 2
AAExp = 1
GaussianAA = true
Iterations = 20
RGB = 0,0.4,0.7
p = 0.1444322
Julia = true
JuliaXY = -1.05204872,0
Bailout = 1000
#endpreset
/* partial pnorm 
   input: z , zn = f(z), p
   output ppn

*/
double ppnorm( complex double z, complex double zn, double p){

	double s[2][3]; // array for 2 points on the Riemann sphere
	int j; 
	double d; // denominator 
	double x; 
	double y;
	
	double ds;
	double ppn = 0.0;
	
	// map from complex plane to riemann sphere
	// z
	x = creal(z);
	y = cimag(z);
	d = x*x + y*y + 1.0;
	
	s[0][0] = (2.0*x)/d;
	s[0][1] = (2.0*y)/d;  
	s[0][2] = (d-2.0)/d; // (x^2 + y^2 - 1)/d
	
	// zn
	x = creal(zn);
	y = cimag(zn);
	d = x*x + y*y + 1.0;
	s[1][0] = (2.0*x)/d;
	s[1][1] = (2.0*y)/d;  
	s[1][2] = (d-2.0)/d; // (x^2 + y^2 - 1)/d
	
	// sum 
	for (j=0; j <3; ++j){
		ds = fabs(s[1][j] - s[0][j]);
		ppn += pow(ds,p); // |ds|^p
		}
	return ppn;
}

// DLD = Discret Lagrangian Descriptior
double lagrangian( complex double z0, complex double c, int iMax, double p ){

	int i; // number of iteration
	double d = 0.0; // DLD = sum
	double ppn; // partial pnorm
	complex double z = z0;
	complex double zn; // next z
	
	
	if (cabs(z) < AR || cabs(z +1)< AR) return 5.0; // for z= 0.0 d = inf
	
	
	for (i=0; i<iMax; ++i){
	
        zn = z*z +c; // complex iteration
		ppn = ppnorm(z, zn, p);
		d += ppn; // sum
		//
		z = zn; 
		
		if (cabs(z) > ER ) break; // exterior : big values produces NAN error in ppnorm computing 
		if (cabs(z) < AR || cabs(z +1)< AR) 
			{ // interior
				d = -d;
				break; 
				
			}
		}
	 
	d =  d/((double)i); // averaging not summation
	if (d<0.0) {// interior
		d = 2.5 - d;
	}
	return d; 
}

unsigned char ComputeColorOfDLD(complex double z){

 	
  	int iColor;
  	double d;

  	d = lagrangian(z,c, N,p);
  	iColor = (int)(d*255)  % 255; // color is proportional to d
  
  
  return (unsigned char) iColor;
}

參考文獻

[編輯 | 編輯原始碼]
  1. C. Mendoza,A. M. Mancho。海洋流動的隱藏幾何結構。物理評論快報 105 (2010),3,038501-1-038501-4。
  2. A. M. Mancho,S. Wiggins,J. Curbelo,C. Mendoza。拉格朗日描述符:揭示一般時間相關動力系統相空間結構的方法。非線性科學與數值模擬通訊。18 (2013) 3530-3557
  3. C. Lopesino,F. Balibrea-Iniesta,V. J. García-Garrido,S. Wiggins,A. M. Mancho。拉格朗日描述符的理論框架。分岔與混沌國際期刊 27, 1730001 (2017)。
  4. 維基百科中的流動場拉格朗日描述
  5. C. Lopesino,F. Balibrea,S. Wiggins,A.M. Mancho。二維、面積守恆自對映和非自對映的拉格朗日描述符。非線性科學與數值模擬通訊 27 (1-3) (2015) 40-51。
  6. V. J . Garcia Garrido。用拉格朗日描述符揭示朱利亞集的分形結構。 https://arxiv.org/abs/2001.08937
  7. V. J. García-Garrido,F. Balibrea-Iniesta,S. Wiggins,A. M. Mancho,C. Lopesino。用拉格朗日描述符檢測貓對映的相空間結構。規則與混沌動力學 23, (6) 751-766 (2018)。
  8. G. G. Carlo 和 F. Borondo。開放對映的拉格朗日描述符 Phys. Rev. E 101, 022208 (2020)
  9. 維基百科中的 Lp 空間,當 0<p <1 時
  10. fractalforums.org: lagrangian-descriptors-fragment-code

V. J. García-Garrido。用拉格朗日描述符揭示朱利亞集的分形結構。《非線性科學與數值模擬通訊》第 91 卷 (2020) 105417。

華夏公益教科書