使用Python组合九倍尖multibrot和九型

问题描述

我的工作Python和胶乳(优选矢量图形TikZ /渐近线/ PGF / MetaPost的/ GeoGebra,以该顺序),其通过在终端上运行的简单代码生成此动画代码

下面是thread on Tex.SE在其中绘制Mandelbrot集的几种方法进行了讨论,但我不能够修改的数学方程在乳胶一样容易在Python。因此,我切换到Python和产生高分辨率的输出作为接近矢量图形尽可能(〜2000 DPI)。我想作为一般定义为可能得出multibrots。例如,当 d 为负时。

Enneabrot

Enneabrot-animation

下面的代码,由this Mandelbrot (dimension=2) project在GitHub和我需要创建该分形项目的高维版本,如Triabrot(尺寸= 4),Pentabrot(尺寸= 6),Heptabrot(尺寸=采取8)和Enneabrot(通过在定义Mandelbrot集递归方程改变指数尺寸= 10)。换句话说代替Z_,{N + 1} = z_n * z_n + Z_0为曼德尔布罗分形,我们定义为维度中的变量d,然后将方程式为d维Multibrot将Z_ {N + 1} = z_n ^d + z_0 和每个这样的方程将在其稳定区的图中产生 d-1 尖点。要了解更多关于这个问题,看这两个YouTube视频:Times Tables by MathologerMandelbrot Set by Numberphile

有必要改变轴线的输出,在每个补丁;出现这种情况是因为分形在复平面上移动,我们需要待着我们的镜头通过Python来观看。我们可以用其他什么公式?也许axisFix =((d ^ 2-4)/ d)/ 10?在此提出的公式中,d ^ 2-4是那里,因为我想被向右在中心处打印的分形曼德尔布罗(d = 2)分别在打印没有任何位移。因此,轴平移的价值将为零。这是有趣的,因为它也是零为d = -2,这意味着我们还必须想看看方程式像Z_ {N + 1} = z_n ^ { - 2.0} + Z_0。的目标是找到最平滑的函数f(d),使得f(2)= 0和通过增加d的通过小尺寸的增量(0.01-0.1)的值和打印曼德尔布罗(阈值的输出使一个动画,密度,尺寸)函数定义这里为动画。平滑器功能,在演示幻灯片的动画幻灯片过渡的平滑。

import numpy as np
import matplotlib.pyplot as plt
# counts the number of iterations until the function diverges or
# returns the iteration threshold that we check until
def countIterationsUntildivergent(c,threshold,d):
    z = complex(0,0)
    for iteration in range(threshold):
# here is the recurrence relation z_{n+1} = z_n^d + z_0,used for 
# drawing d-1-dimensional Mandelbrot creatures (growing fractals)
        z = z**d + c
        if abs(z) > 4:
            break
            pass
        pass
    return iteration

# takes the iteration limit before declaring function as convergent and
# takes the density of the atlas
# create atlas,plot mandelbrot set,display set
def mandelbrot(threshold,density,d):
# it is necessary to change the axis for every patch of outputs;
# this happens because the fractals move in the complex plane
# and we need to move along our lens to watch them through Python
## what other formulas Could we use? Maybe axisFix = ((d^2-4)/d)/10?
## d^2-4 is there because I want the Mandelbrot fractal (d=2)
## to be right there were it is printed without any replacement
## so the value of the axis translation would be zero. This is
## funny because it is also zero for d=-2 which means that
## we must also be trying to look at equations like
### z_{n+1}=z_n^{-2.0} + z_0
### the goal is to find the smoothest function
### f(d) such that f(2)=0 and make an animation 
### by increasing the value of d by increments of small size (0.01-0.1)
### and printing the output of the mandelbrot function defined here
### as an animation. The smoother the function,the smoother
### the transition of slides in the animation
    axisFix = d/10 
    # location and size of the atlas rectangle
    realAxis = np.linspace(-2.25+axisFix,0.75+axisFix,density)
    imaginaryAxis = np.linspace(-1.5,1.5,density)
    # realAxis = np.linspace(-0.22,-0.219,1000)
    # imaginaryAxis = np.linspace(-0.70,-0.699,1000)
    realAxisLen = len(realAxis)
    imaginaryAxisLen = len(imaginaryAxis)

    # 2-D array to represent mandelbrot atlas
    atlas = np.empty((realAxisLen,imaginaryAxisLen))

    # color each point in the atlas depending on the iteration count
    for ix in range(realAxisLen):
        for iy in range(imaginaryAxisLen):
            cx = realAxis[ix]
            cy = imaginaryAxis[iy]
            c = complex(cx,cy)
            atlas[ix,iy] = countIterationsUntildivergent(c,d)
            pass
        pass

    # plot and display mandelbrot set
    fig1 = plt.gcf()
    plt.axis('off')
    # plt.savefig('mandel.eps',format='eps')
    plt.imshow(atlas.T,interpolation="nearest")
    # plt.show()
    output_name = str(d)+'.pdf'
    fig1.savefig(output_name,format='pdf',bBox_inches='tight',dpi=2000)

# time to party!!
dimensions = np.arange(10,100) / 10
# for d in dimensions:
#     mandelbrot(120,1000,d)

# Enneabrot
mandelbrot(120,10)
# Heptabrot
mandelbrot(120,8)
# Pentabrot
mandelbrot(120,6)
# Triabrot
mandelbrot(120,4)
# Mandelbrot
mandelbrot(120,2)

解决方法

下面是结果,由于雅利安Hemmati用于通过与十维曼德尔布罗分形合并灵魂的九型编辑的最终照片。

Enneabrot animation

我需要一个 Python 和 LaTeX(最好是矢量图形 TikZ/Asymptote/PGF/Metapost/GeoGebra,按顺序)通过在终端上运行简单的代码来生成这个动画。我们可以很容易地改变参数,使一个Heptabrot(d = 8),Pentabrot(d = 6),或甚至一个Triabrot(d = 4)。我附上代码使用Python绘制Enneabrot(d = 10)和我已经修改this code通过Danyaal Rangwala和定义一个新的变量d(尺寸)在递归方程计算平衡的精确区,用于将溶液了,这最终揭示Enneabrot作为最后数我试图用于产生这种分形的(从开始d = 1.0,含有0.1 incrementations高达d = 10.0)。

下面我将发布的曼德尔布罗分形(d = 2)的输出端以及所述分形我上面所定义:Enneabrot(d = 10),Heptabrot(d = 8),Pentabrot(d = 6),或甚至一个Triabrot(d = 4)。其它图中的这个下一个版本按照answer

曼德尔布罗(d = 2) Mandelbrot


Triabrot(d = 4) Triabrot


Pentabrot(d = 6) Pentabrot


Heptabrot(d = 8) Heptabrot


Enneabrot(d = 10) Enneabrot