JensGrabner / mpmath-2

Automatically exported from code.google.com/p/mpmath
Other
3 stars 0 forks source link

Derivative of Jacobi Theta #214

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Evaluate the derivative of the Jacobi theta 

         jtheta(1, 0, exp(j*pi*tau), 1) 

     across the line Real(tau) = -1 or Real (tau) = 1 in the upper half plane. It appears to have 
     a discontinuity here.

What is the expected output? What do you see instead?

     There should not be a discontinuity.

What version of the product are you using? On what operating system?

     On OSX 10.6, python 2.6.1, mpmath 0.14.

Please provide any additional information below.

     Thanks for all the good work. I see you are implementing a q-factorial, 
     is this appearing in the current version? I still cannot get mpmath to plot stuff,
     if you point me to a site to help with this I would be grateful.
     Thanks again for the good work.

Cheers,
Mark

Original issue reported on code.google.com by harmer.m...@googlemail.com on 4 Oct 2011 at 10:18

GoogleCodeExporter commented 9 years ago
Hi Mark,

I can't find a problem with the latest version (0.17), although I don't 
remember any recent changes being made to the theta functions.

Can you be more specific, i.e. can you provide a point where the function value 
seems to be wrong?

If I understood the problem correctly, the following should show a 
discontinuity, but it looks fine to me:

plot(lambda t: jtheta(1, 0, exp(j*pi*(1+t*j)), 1), [0,5])

If you can't get mpmath plotting to work, it's probably an issue with 
matplotlib. Your best bet would be to try the matplotlib support channels. If 
matplotlib works but mpmath plotting doesn't, please provide more details.

q-factorials are available in the latest version.

Original comment by fredrik....@gmail.com on 4 Oct 2011 at 4:30

GoogleCodeExporter commented 9 years ago
Hi Fredrik,

Try

plot(lambda t: jtheta(1, 0, exp(j*pi*(1+t+j)), 1), -0.2,0.2])

(it is across the line Real (tau)=1, not along it), although I didn't notice 
the problem (if indeed there is one) this way. Rather I was trying to evaluate 
functions of the Dedekind eta function at certain points and kept getting weird 
answers.

Mark

Original comment by harmer.m...@googlemail.com on 4 Oct 2011 at 7:15

GoogleCodeExporter commented 9 years ago
Yes, there is a discontinuity. However, I tried plotting the function in 
Mathematica, and it shows the same thing.

This doesn't seem unreasonable: the definition of theta_1 as a q-series 
involves a fractional power of q, so there should be a branch cut discontinuity 
somewhere.

The function can't figure out that the argument is an exponential (just as if 
you evaluate log(exp(x)), it doesn't generally give x).

You probably have to rewrite the formula you are using somehow to avoid this.

Original comment by fredrik....@gmail.com on 5 Oct 2011 at 3:33

GoogleCodeExporter commented 9 years ago
The most user-friendly solution, of course, would be to let you type jtheta(1, 
0, tau=t, nd=1) and have the implementation choose branches so as to make the 
function continuous.

Patches are welcome :)

Original comment by fredrik....@gmail.com on 5 Oct 2011 at 3:36

GoogleCodeExporter commented 9 years ago
I am afraid I disagree for the following reasons:

>This doesn't seem unreasonable: the definition of theta_1 as a q-series 
involves a fractional power of q, so >there should be a branch cut 
discontinuity somewhere.

1. The Jacobi theta function is only defined for 'tau' in the upper half plane 
-- the branch cut, if you insist on considering it, should be on the real axis. 
Alternatively jtheta is only defined for the nome |q|<1.

2. As I noted in the original query there are discontinuities across Real(tau) 
= 1 and Real(tau) = -1, in fact across (all) the lines Real(tau) is odd (ok, I 
didn't check all the lines). To quote Oscar Wilde 'To have one discontinuity 
may be regarded as a misfortune; to have two looks like carelessness; to 
describe an infinite number as a feature can only be pulled off by microsoft'. 

3. The function I consider in my example (jtheta(1, 0, exp(j*pi*(1+t+j)), 1)) 
is exactly the Dedekind eta function (cubed). This definitely does not have any 
discontinuities in the upper half plane.

The good news is there is no need to consider an implementation that allows the 
user to select a branch (a messy and (point 1.) unnecessary process). The other 
good news is that I guess point 2. indicates where the bug is: I would guess 
that jtheta only evaluates inside -1<Real(tau)<1 and then maps the result to 
the rest of the upper half plane using the periodicity of jtheta(tau). It is 
this mapping to the rest of the upper half plane that is broken, at least for 
the derivative of jtheta.

Original comment by harmer.m...@googlemail.com on 6 Oct 2011 at 12:07

GoogleCodeExporter commented 9 years ago
> plotting the function in Mathematica, and it shows the same thing.

Then, IMHO Mathematica have a bug.

Original comment by harmer.m...@googlemail.com on 6 Oct 2011 at 12:21