曼德勃罗集(Mandelbrot Set)

先来膜拜一下大神!



曼德勃罗(Benoit B. Mandelbrot),数学家、经济学家,分形理论的创始人。1924年生于波兰华沙;1936年随全家移居法国巴黎,在那里经历了动荡的二战时期;1948年在帕萨迪纳获得航空硕士学位;1952年在巴黎大学获得数学博士学位;曾经是普林斯顿、日内瓦、巴黎的访问教授,哈佛大学的“数学实践讲座”的教授,IBM公司的研究成员和会员。

简介

Mandelbrot Set 被称为”魔鬼的聚合物“, “上帝的指纹”.
根据公式

Zn+1=Zn+C

对于每一个C,从Z = 0 + 0j开始计算,如果Zn 收敛,则C在集合中。对于所有C组成的集合,称为Mandelbrot Set。

下面来看看Mandelbrot Set长什么样吧

这里写图片描述
这里写图片描述
这里写图片描述
魔征了:o :o :o :o
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

代码

最后放上拙码一份

#!/usr/bin/env python3

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm

'''
Mandelbrot集
'''

# C: 复数
def get_degree(C, maxIteration):
    Z = C
    for i in range(0, maxIteration):
        if abs(Z) > 2: break
        Z = Z**2 + C

    return i

# P: 复数, d: 范围
def mandelbrot_plot(P, d):
    x0, x1, y0, y1 = P[0] - d, P[0] + d, P[1] - d, P[1] + d
    y, x = np.ogrid[y0:y1:800j, x0:x1:800j]

    c = x + y * 1j

    mandelbrot_set = np.frompyfunc(get_degree, 2, 1)(c, 300).astype(np.float)

    plt.imshow(mandelbrot_set, extent=[x0, x1, y0, y1])

    plt.gca().axis('off')
    plt.show()

if __name__ == '__main__':
    plt.figure(figsize=(9, 9))
    #mandelbrot_plot((-0.5, 0), 1.5)
    #mandelbrot_plot((0.408602, 0.322581), 0.02)
    #mandelbrot_plot((0.406738, 0.321649), 0.004)
    #mandelbrot_plot((0.404401, 0.319584), 0.012)
    #mandelbrot_plot((0.399025, 0.321304), 0.012)
    #mandelbrot_plot((0.402588,  0.325519), 0.003)
    mandelbrot_plot((0.403231, 0.324479), 0.00005)
    #mandelbrot_plot((-1.15237, 0.27957), 0.03)
    #mandelbrot_plot((-1.12291, 0.27914), 0.02)
    #mandelbrot_plot((0.2, 0.6), 0.5)
发布了52 篇原创文章 · 获赞 25 · 访问量 10万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章