Search code examples
pythonnumpympmath

Implementation of derivatives of Jacobi theta function


I am looking for an implementation of the derivative of the Jacobi theta functions for python. I found this

http://mpmath.googlecode.com/svn/trunk/doc/build/functions/elliptic.html#jtheta

However, the derivative is computed with respect to the wrong argument. I want the derivative with respect to q, and not z. Does anyone know the best way to obtain this? Just taking the derivative numerically with a finite difference does not work very well (the ODE solver which I use crashes when I do this).

(Actually I only want it also for the special case z=0, if that is possible. Same question for the E4 Eisenstein series would also suffice)

Thanks!


Solution

  • This relation should help you: http://functions.wolfram.com/EllipticFunctions/EllipticTheta2/13/01/0002/ https://en.wikipedia.org/wiki/Theta_function#A_solution_to_heat_equation

    def jtheta_dq(n, z, q):
        # cf. http://functions.wolfram.com/EllipticFunctions/EllipticTheta2/13/01/0002/
        return -mpmath.jtheta(n, z, q, 2)/(4*q)