Mandelbrot集
发布日期:2021-07-01 02:13:24 浏览次数:2 分类:技术文章

本文共 1224 字,大约阅读时间需要 4 分钟。

曼德勃罗特集是人类有史以来做出的最奇异,最瑰丽的几何图形,曾被称为“上帝的指纹”。 这个点集均出自公式:Zn+1=(Zn)2+C,对于非线性迭代公式Zn+1=(Zn)2+C,所有使得无限迭代后的结果能保持有限数值的复数C的集合,构成曼德勃罗集。

# /usr/bin/python# -*- coding:utf-8 -*-import numpy as npimport matplotlib.pyplot as pltimport matplotlib.cm as cmdef divergent(c):    z = 0    i = 0    while i < 100:        z = z**2 + c        if abs(z) > 2:            break        i += 1    return idef draw_mandelbrot(center_x, center_y, size):    x1, x2 = center_x - size, center_x + size    y1, y2 = center_y - size, center_y + size    x, y = np.mgrid[x1:x2:500j, y1:y2:500j]    c = x + y * 1j    divergent_ = np.frompyfunc(divergent, 1, 1)    mandelbrot = divergent_(c)    mandelbrot = mandelbrot.astype(np.float64)    # ufunc返回PyObject数组    print(size, mandelbrot.max(), mandelbrot.min())    plt.pcolormesh(x, y, mandelbrot, cmap=cm.jet)    plt.xlim((np.min(x), np.max(x)))    plt.ylim((np.min(y), np.max(y)))    plt.savefig(str(size)+'.png')    plt.show()if __name__ == '__main__':    draw_mandelbrot(0, 0, 2)    interested_x = 0.33987    interested_y = -0.575578    interested_x, interested_y = 0.27322626, 0.595153338    for size in np.logspace(0, -3, 4, base=10):        print(size)        draw_mandelbrot(interested_x, interested_y, size)

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

转载地址:https://maoli.blog.csdn.net/article/details/89528847 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:在python实现快速傅里叶变换FFT与频域滤波
下一篇:三、pandas_datareader金融数据

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年05月06日 17时10分25秒