diff --git a/.gitignore b/.gitignore index a71b8d6d..5c3e32eb 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ doc/source/_build/ # Files generated by setupegg.py mpmath.egg-info/ +.eggs # Coverage-related files .coverage diff --git a/doc/source/functions/elliptic.txt b/doc/source/functions/elliptic.txt index f8d2e1d6..5b314ec4 100644 --- a/doc/source/functions/elliptic.txt +++ b/doc/source/functions/elliptic.txt @@ -91,6 +91,11 @@ Jacobi elliptic functions Modular functions ...................... +:func:`eta` +^^^^^^^^^^^^^^^ +.. autofunction:: mpmath.eta(tau) + :func:`kleinj` ^^^^^^^^^^^^^^^ .. autofunction:: mpmath.kleinj(tau=None, **kwargs) + diff --git a/mpmath/__init__.py b/mpmath/__init__.py index b00e3f3f..180555cb 100644 --- a/mpmath/__init__.py +++ b/mpmath/__init__.py @@ -47,6 +47,7 @@ qbarfrom = mp.qbarfrom ellipfun = mp.ellipfun jtheta = mp.jtheta kleinj = mp.kleinj +eta = mp.eta qp = mp.qp qhyper = mp.qhyper diff --git a/mpmath/functions/elliptic.py b/mpmath/functions/elliptic.py index 22af200f..912765c3 100644 --- a/mpmath/functions/elliptic.py +++ b/mpmath/functions/elliptic.py @@ -64,6 +64,33 @@ between the various parameters (:func:`~mpmath.qfrom`, :func:`~mpmath.mfrom`, from .functions import defun, defun_wrapped +@defun_wrapped +def eta(ctx, tau): + r""" + Returns the Dedekind eta function of tau in the upper half-plane. + + >>> from mpmath import * + >>> mp.dps = 25; mp.pretty = True + >>> eta(1j); gamma(0.25) / (2*pi**0.75) + (0.7682254223260566590025942 + 0.0j) + 0.7682254223260566590025942 + >>> tau = sqrt(2) + sqrt(5)*1j + >>> eta(-1/tau); sqrt(-1j*tau) * eta(tau) + (0.9022859908439376463573294 + 0.07985093673948098408048575j) + (0.9022859908439376463573295 + 0.07985093673948098408048575j) + >>> eta(tau+1); exp(pi*1j/12) * eta(tau) + (0.4493066139717553786223114 + 0.3290014793877986663915939j) + (0.4493066139717553786223114 + 0.3290014793877986663915939j) + >>> f = lambda z: diff(eta, z) / eta(z) + >>> chop(36*diff(f,tau)**2 - 24*diff(f,tau,2)*f(tau) + diff(f,tau,3)) + 0.0 + + """ + if ctx.im(tau) <= 0.0: + raise ValueError("eta is only defined in the upper half-plane") + q = ctx.expjpi(tau/12) + return q * ctx.qp(q**24) + def nome(ctx, m): m = ctx.convert(m) if not m: