Mandelbrot

From PyPedia
Jump to: navigation, search

Contents

[edit] Documentation

Visualization of the Mandelbrot fractal

References

[edit] Parameters

Iterations:
Points:
Escape radius:
Center Re:
Center Im:

<inputs>
<param name="ITERATIONS" value="50" type="eval" label="Iterations: "/>
<param name="POINTS" value="80000" type="eval" label="Points:"/>
<param name="ESCAPE_RADIUS" value="8" type="eval" label="Escape radius:"/>
<param name="RE" value="[-2.5, 1.5]" type="eval" label="Center Re:"/>
<param name="IM" value="[-1.5, 1.5]" type="eval" label="Center Im:"/>
</inputs>


[edit] Return

None

[edit] See also

[edit] Code

"""
This script uses the cplot function in mpmath to plot the Mandelbrot set.
By default, the fp context is used for speed. The mp context could be used
to improve accuracy at extremely high zoom levels.
"""

import mpmath
import cmath

def Mandelbrot(ITERATIONS = 50, POINTS = 90000, ESCAPE_RADIUS = 8, 
		RE = [-2.5, 1.5], IM = [-1.5, 1.5]):
	ctx = mpmath.fp

	# A pretty subplot
	#RE = [-0.96, -0.80]
	#IM = [-0.35, -0.2]

	def mandelbrot(z):
		c = z
		for i in xrange(ITERATIONS):
			zprev = z
			z = z*z + c
			if abs(z) > ESCAPE_RADIUS:
				return ctx.exp(1j*(i + 1 - ctx.log(ctx.log(abs(z)))/ctx.log(2)))
		return 0

	ctx.cplot(mandelbrot, RE, IM, points=POINTS)
	print Convert_plot_to_HTML()

	return None

[edit] Code

def Mandelbrot():
	pass

[edit] Unit Tests

def uni1():
	return True

[edit] Development Code

def Mandelbrot():
	pass

[edit] Permissions

[edit] Documentation Permissions

Kantale

[edit] Code Permissions

Kantale

[edit] Unit Tests Permissions

Kantale

[edit] Permissions Permissions

Kantale

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox