You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all,
the calculation of the Jacobi theta functions for certain arguments (|q|->1) is critical, since the convergence for these arguments is very slow, see the documentation for the mpmath jtheta function here: https://mpmath.org/doc/current/functions/elliptic.html#jtheta.
I have programmed a much faster version of the Jacobi theta functions, see code at the end of this posting. For demonstration, I used a critical set of arguments with q=0.599999+0.8j and z=0.5+1j. The imaginary part of z makes convergence even slower. Feel free to try other arguments. Here is a sample output of a test run:
n = 2
z = (0.5 + 1.0j)
q = (0.599999 + 0.8j)
Precision: 200 digits
theta = (2.9177_(187)_30027968e+723825 - 6.4828_(187)_82484441e+723825j) in 4.53 ms
jtheta = (2.9177_(187)_30027968e+723825 - 6.4828_(187)_82484441e+723825j) in 13578.12 ms
Factor 2994.49
As one can see, both functions yield the same result (output is being abbreviated by means of the function "shortnum" which shows only a few digits after the point and the very last digits, "_(187)_" in the middle means 187 digits have been hidden).
While the mpmath jtheta function takes more than 13 seconds to calculate the value once, the new theta function just takes 4.53 milliseconds, which is roughly 3000 times faster (tested on an i7 8th gen processor). Even at 1000 digits, the new theta takes only 78ms, jtheta takes more than 5000 times longer (7 minutes).
The set of arguments given in the documentation n = 1, z = 10, q = 0.99999999 * exp(0.5*j) where jtheta raises a ValueError can be calculated in 18 milliseconds at a precision of 1000 digits.
An explanation of the algorithm can be found here: https://matheplanet.de/matheplanet/nuke/html/viewtopic.php?rd2&topic=258531&start=0#p1877370
(The code there is slightly different, facilitating the calculation of the natural logarithm of theta at "regular" double precision within microseconds.)
Hi all,
the calculation of the Jacobi theta functions for certain arguments (|q|->1) is critical, since the convergence for these arguments is very slow, see the documentation for the mpmath jtheta function here: https://mpmath.org/doc/current/functions/elliptic.html#jtheta.
I have programmed a much faster version of the Jacobi theta functions, see code at the end of this posting. For demonstration, I used a critical set of arguments with q=0.599999+0.8j and z=0.5+1j. The imaginary part of z makes convergence even slower. Feel free to try other arguments. Here is a sample output of a test run:
As one can see, both functions yield the same result (output is being abbreviated by means of the function "shortnum" which shows only a few digits after the point and the very last digits, "_(187)_" in the middle means 187 digits have been hidden).
While the mpmath jtheta function takes more than 13 seconds to calculate the value once, the new theta function just takes 4.53 milliseconds, which is roughly 3000 times faster (tested on an i7 8th gen processor). Even at 1000 digits, the new theta takes only 78ms, jtheta takes more than 5000 times longer (7 minutes).
The set of arguments given in the documentation n = 1, z = 10, q = 0.99999999 * exp(0.5*j) where jtheta raises a ValueError can be calculated in 18 milliseconds at a precision of 1000 digits.
An explanation of the algorithm can be found here:
https://matheplanet.de/matheplanet/nuke/html/viewtopic.php?rd2&topic=258531&start=0#p1877370
(The code there is slightly different, facilitating the calculation of the natural logarithm of theta at "regular" double precision within microseconds.)
The text was updated successfully, but these errors were encountered: