# SiegelTheta throws errors from calling Range with complex arguments

Bug introduced in 8.0 or earlier and persists through 11.0.1 or later

This may or may not be related to the bug reported in this question.

I was trying to verify the results of this challenge over on Code Golf with the following code:

p = {{5., 2., 0., 0.}, {2., 5., 2., -2.}, {0., 2., 5., 0.}, {0., -2., 0., 5.}}
SiegelTheta[I*p/Pi, ConstantArray[0, Length@p]]


While I do get the correct result, SiegelTheta throws a bunch of of messages via Range along the lines of:

Range::range: "Range specification in Range[-I,I] does not have appropriate bounds."

I've verified this with all of the example matrices in the linked challenge - the larger the matrix, the more of these messages are thrown. The same happens when I generate random positive definite matrices myself with the following code:

n = 5;
m = RandomChoice[{-1, 1}, {n, n}]
p = N@IdentityMatrix[n] + m\[Transpose].m;
PositiveDefiniteMatrixQ@p
SiegelTheta[I*p/Pi, ConstantArray[0, n]]


I have contacted Wolfram Support and they confirmed that this is a bug. If anyone can reproduce it in earlier Mathematica version, feel free to update the header.

• Using TracePrint[SiegelTheta[(* stuff *)], Range[__], TraceInternal -> True] reveals that an internal auxiliary routine is making the bad Range[] call, so I would consider this a bug. Comparison with the result from version 5.2 (when SiegelTheta[] was a package function as opposed to a built-in) shows consistent results, so the sum is being computed correctly despite the bug. Please file a report when you find the time. – J. M. will be back soon Apr 5 '16 at 12:04
• P.S. if you want to scare the people at code golf with the complexity of the problem, link them to this paper. – J. M. will be back soon Apr 5 '16 at 12:07