I used Mathematica to create the graphics for my previous two posts because SciPy didn’t have the functions I needed. In particular, elliptic integrals and elliptic functions in SciPy only take real-valued arguments, but I needed to use complex arguments. Also, I needed theta functions, which are not in SciPy at all.

I thought mpmath might have the functions I wanted, and indeed it does.

Function names are slightly different between mpmath and SciPy. For example, the `ellipe`

function in mpmath is overloaded to compute the complete elliptic integral of the first kind if given one argument and the incomplete counterpart if given two arguments.

The mpmath library works with arbitrary precision by default, and returns its own numeric types. But you can prefix a function with `fp.`

in order to get a Python floating point value back. For example,

>>> import mpmath as mp >>> mp.ellipe(1+1j, 1) mpc(real='1.2984575814159773', imag='0.63496391478473613') >>> mp.fp.ellipe(1+1j, 1) (1.2984575814159773+0.634963914784736j)