Mpmath is a Python library for arbitrary-precision floating-point arithmetic. For general information about mpmath, see the project website http://mpmath.org
In [ ]:
# import python packages here...
In [ ]:
import mpmath
TODO
In [ ]:
mpmath.plot([mpmath.cos, mpmath.sin], [-4, 4])
In [ ]:
mpmath.plot(lambda x: mpmath.exp(x) * mpmath.li(x), [1, 4])
By default, the complex argument (phase) is shown as color (hue) and the magnitude is show as brightness.
You can also supply a custom color function (color). This function should take a complex number as input and return an RGB 3-tuple containing floats in the range 0.0-1.0.
In [ ]:
mpmath.cplot(lambda z: z, [-10, 10], [-10, 10])
Use the points argument to increase the resolution.
In [ ]:
mpmath.cplot(lambda z: z, [-10, 10], [-10, 10], points=100000)
In [ ]:
mpmath.cplot(mpmath.gamma, [-10, 10], [-10, 10], points=100000)
In [ ]:
f = lambda z: (z * 2 - 1)*(z + 2 - mpmath.j)**2 / (z * 2 + 2 - 2 * mpmath.j)
mpmath.cplot(f, [-5, 5], [-3, 3], points=100000)
In [ ]:
f = lambda x, y: mpmath.sin(x+y) * mpmath.cos(y)
mpmath.splot(f) #, [-mpmath.pi, mpmath.pi], [-mpmath.pi, mpmath.pi])
In [ ]:
r, R = 1, 2.5
f = lambda u, v: [r*mpmath.cos(u), (R+r*mpmath.sin(u))*mpmath.cos(v), (R+r*mpmath.sin(u))*mpmath.sin(v)]
mpmath.splot(f) #, [0, 2*mpmath.pi], [0, 2*mpmath.pi])