Logistic映射的LISP实现
- highflybird's Blog
- 登录或注册以发表评论
关于Logistic映射,请参考集智百科词条:
这里讲得很详细。我摘抄几句:
Logistic映射,又称单峰映象,是一个二次多项式映射(递归关系),经常作为典型范例来说明复杂的混沌现象是如何从非常简单的非线性动力学方程中产生的。
生物学家罗伯特·梅 Robert May [1]在1976年的一篇论文中推广了这一映射,[2]它在一定程度上是一个时间离散的人口统计模型,类似于皮埃尔·弗朗索瓦·韦胡斯特 Pierre Francois Verhulst 首次提出的方程。
Logistic映射的数学表达式表示为:
\[\displaystyle{x(t+1)=\mu x(t)(1-x(t))}\]
美国物理学家费根鲍姆从中发现了费根鲍姆常数(第一常数),这是一个普适的常数,一个很重要的常数。
其大小 \( \delta \approx 4.66920 16091 02990 67185 32038 20466 20161 72581 85577 47576 86327 45651 34300 4134.....\)
我用AutoLISP简单实现了logistic映射,代码如下:
;;; Logistic混沌映射的LISP实现 (defun Logistic (r x0 / i xn x) (setq i 0) (setq x x0) (while (and (< i 50) (not (equal x (setq xn (* r x (- 1 x))) 1e-8))) (setq x xn) (setq i (1+ i)) ) (entmakeX (list '(0 . "POINT") (list 10 r x 0))) ) ;;; 测试程序 (defun c:tt (/ r0 x0) (setq r0 0.0) (repeat 401 (setq x0 1e-8) (repeat 1001 (logistic r0 x0) (setq x0 (+ x0 0.001)) ) (setq r0 (+ r0 0.01)) ) (princ) )
生成的图像大致如下:
更精美的图形可以用C++编写,下面是核心代码:
void Fractal::Logistic(int sx1,int sy1,int sx2,int sy2,CDC* pMemDC) { double x(0),xx(0),y(0),yy(0),cx(0),cy(0); m_isBusy = true; for (int i = sx1; i <= sx2; i++) { for(int j = sy1;j <= sy2; j++) { x = cxmin+i*dx; y = cymin+j*dy; xx = x; yy = x*y*(1-y); int n = 0; while( fabs(y-yy) > 1e-14 && n < maxIter) { y = yy; yy = x*y*(1-y); n++; } int k = (y-cymin)/dy; fPutPixel(i,k,n,H0,S0,L0,pMemDC,grad); } } }
生成的图像: