Giter Site home page Giter Site logo

jacobi-theta-function-fortran's Introduction

Jacobi Theta functions for fortran

Fortran code for jacobi theta funcitons.

The code implements

$$\theta_3(z,\tau) = \sum_{n=-\infty}^{\infty} e^{\imath \pi \tau n^2} e^{\imath 2 \pi n z}$$

For and extensive list of properties, see the NIST DLMF website. Keep howeer in mind that this uses the convention that ads an extra $\pi$ to z compaared no NIST. This means that here $\theta_3(z+1,\tau) = \theta_3(z,\tau)$ wheas NIST has $\theta_3(z+\pi,\tau) = \theta_3(z,\tau).$

The main file jacobitheta.f90 is stand alone and can be included using use jacobitheta.

Most of the rest of the files exists to test the implementation. Run the test with make test.

All four basic jacobi theta functions are implemented

theta1(z,tau)
theta2(z,tau)
theta3(z,tau)
theta4(z,tau)

as well as the gernalized jacobi theta function thetagen(a,b,z,tau) as

$$\theta_{a,b}(z,\tau) = \sum_{n=-\infty}^{\infty} e^{\imath \pi \tau (n+a)^2} e^{\imath 2 \pi (n+a) (z+b)}$$

where

theta1(z,tau)=thetagen(.5,.5,z,tau)
theta2(z,tau)=thetagen(.5, 0,z,tau)
theta3(z,tau)=thetagen( 0, 0,z,tau)
theta4(z,tau)=thetagen( 0,.5,z,tau)

The code automatically implements modular transformations that ensures im(tau) > 1 and |re(tau)| < 1/2.

The code also has the option to compute the logarithm of the theta functions using

logtheta1(z,tau)
logtheta2(z,tau)
logtheta3(z,tau)
logtheta4(z,tau)
logthetagen(a,b,z,tau)

and this is actually the form used when performing modular transformations.

A special tanks to Stéphane Laurent for pointin out a few bugs when working on an R-implementation of the theta-funcitons.

jacobi-theta-function-fortran's People

Contributors

fremling avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

jacobi-theta-function-fortran's Issues

my C++ implementation gives wrong result

Hello,

Thank you for this repo. I tried to translate your Fortran code to C++ and I don't get the correct result. I'm a bit puzzled by these two lines:

!!Reduce  -0.5 < Re(z) < 0.5
zuse = mod(real(z),1.d0) + iunit*aimag(z)

The modulo 1 operation gives -1 < Re(z) < 1, no?

I tried with z=1+i and tau=0.5i. The correct result is 0.28269-1.293911i and this is really not what I get.

Reached 1000 iterations

Hello,

I found a value for which the 1000 iterations are attained when calculating theta2: $$z=0 \quad \text{and} \quad \tau = 0.7792256 +10^{-7}i.$$

This is really a edge case: with tau = 0.78 + 1e-7, this works.

There's a formula linking theta(z, tau) and theta(z/tau, -1/tau), and one can get the result with this formula. One can see the presence of the edge case once again, because the imaginary part of -1/tau is 1.646924e-07.

Wrong value of theta3

Hello @fremling

I'm trying to port your new code to Haskell and my implementation does not return the correct values. So I'm wondering whether I did a mistake or there's a mistake in your code. Could you please check a value? For example:
$$\log(\theta_3(z = 1+i, \tau = 1+i)) \approx 3.051207+3.141593i.$$
This is the correct value (checked with Wolfram and my R implementation). But with my Haskell implementation, I find the conjugate value: 3.051207 - 3.141593i. Could you please tell me which value you find when you'll have 5 minutes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.