Proof of Landsberg-Schaar relation From the Wikipedia page, Landsberg-Schaar relation is the following equation:
$$\frac{1}{\sqrt{p}}\sum_{n=0}^{p-1}\exp(\frac{2\pi i n^2 q}{p})=\frac{e^{\pi i/4}}{\sqrt{2q}}\sum_{n=0}^{2q-1}\exp (-\frac{\pi i n^2 p}{2q}).$$
Here $p$ and $q$ are positive integers.
The wiki page says that the standard way to prove it is to use the functional equation of theta function:
$$\sum_{n=-\infty}^\infty e^{-\pi n^2 z}=\frac{1}{\sqrt{z}}\sum_{n=-\infty}^{\infty}e^{-\pi n^2/z}.$$
Put $z=2iq/p+\varepsilon$ with $\varepsilon>0$ and then let $\varepsilon\to 0$. But I don't see how this implies the Landsberg-Schaar relation, can anyone give some details?
 A: Using the Jacobi theta 3 functional equation, valid for $z$ in the open right-hand complex half-plane, (where $z=\epsilon-\frac{2iq}{p} $), we have $$\sum_{n\in\mathbb{Z}}\exp\left(-\pi n^{2}\left(\epsilon-\frac{2iq}{p}\right)\right)=\frac{1}{\sqrt{\epsilon-2iq/p}}\sum_{n\in\mathbb{Z}}\exp\left(-\pi n^{2}\left(\frac{1}{\epsilon-2iq/p}\right)\right).\tag{1}$$
In the LHS of $(1)$ we have $$\sum_{n\in\mathbb{Z}}\exp\left(-\pi n^{2}\epsilon\right)\exp\left(\pi n^{2}\frac{2iq}{p}\right)=\epsilon^{-1/2}\left(\frac{1}{p}\sum_{n=0}^{p-1}\exp\left(\pi n^{2}\frac{2iq}{p}\right)+o\left(1\right)\right)\tag{2}
 $$ since $\exp\left(\pi n^{2}\frac{2iq}{p}\right)$ is a PERIODIC FUNCTION of period $p$ (as function of $n$) and because$$ \sum_{n\in\mathbb{Z}}\exp\left(-\pi n^{2}\epsilon\right)=\epsilon^{-1/2}\left(1+o\left(1\right)\right).
 $$The RHS of $(1)$ is, for the same reasons, $$\frac{1}{\sqrt{\epsilon-2iq/p}}\sum_{n\in\mathbb{Z}}\exp\left(-\frac{\pi n^{2}\epsilon}{\epsilon^{2}+4q^{2}/p^{2}}\right)\exp\left(-\frac{2\pi in^{2}q/p}{\epsilon^{2}+4q^{2}/p^{2}}\right)$$ $$=\frac{1}{\sqrt{-2iq/p}}\left(\frac{4q^{2}}{\epsilon p}\right)^{1/2}\left(\frac{1}{2q}\sum_{n=0}^{2q-1}\exp\left(-\frac{\pi in^{2}p}{2q}\right)
 +o\left(1\right)\right).\tag{3}
 $$ Equating $(2)$ and $(3)$ we obtain the result. 
A: The Landsberg-Schaar relation (LS) admits not only analytic proof. The article A proof of the Landsberg-Schaar relation by finite methods by Ben Moore gives an elementary proof of the LS. But this proof is unreasonably complicated. The LS can be proven in two steps.
It is well known that an arbitrary complex-valued function
$f$
is represented by its finite (discrete) Fourier series
$$f(x)=\sum\limits_{k=0}^{n-1}\widehat{f}_n(k)e\left(\frac{kx}{n}\right)\qquad(0\le x<n),$$
with finite Fourier coefficients
$$\widehat{f}_n(k)=\dfrac{1}{n}\sum\limits_{x=0}^{n-1}f(x)e\left(-\frac{kx}{n}\right)\qquad(0\le k<n)$$
where  $e(t)=e^{2\pi it}$. The first step is  “A Discrete Analog of the Poisson Summation Formula”: if
$n=n_1n_2$ then
$$\sum\limits_{x=0}^{n_2-1}f(n_1x)=n_2
\sum\limits_{x=0}^{n_1-1}\widehat{f}_n(n_2x).$$
It follows directly from the formula for $\widehat{f}_n(k)$.
The function $f(x)=e\left(x^2/( 4pq)\right)$ is periodic with the period $n=2pq$ and
\begin{align*}
\widehat{f}_{2pq}(k)=&\frac{1}{ 2pq}\sum_{y=0}^{2pq-1}e\left(\frac{y^2-2ky}{ 4pq}\right)=\frac{1}{ 2pq}\sum_{y=0}^{2pq-1}e\left(\frac{(y-k)^2-k^2}{ 4pq}\right)=\\=&
\frac{1}{ 2pq}e\left(-\frac{k^2}{ 4pq}\right)\sum_{y=0}^{2pq-1}e\left(-\frac{y^2}{ 4pq}\right)=\frac{1}{ 2pq}e\left(-\frac{k^2}{ 4pq}\right)\cdot\frac{S(4pq)}{ 2},
\end{align*}
where
$$S(p)=\sum\limits_{x=1}^{p}e(x^2/p)=\frac{1+i^{-p}}{1+i^{-1}}\cdot\sqrt{p}$$
is a Gauss sum.
So (the second step) applying the discrete Poisson summation formula to $f$ with $n_1=2q$,  $n_2=p$ and $n=n_1n_2=2pq$ we get the formula
$$\sum_{x=0}^{p-1}e\left(\frac{qx^2}{ p}\right)=\frac{S(4pq)}{4q}\sum_{x=0}^{2q-1}e\left(-\frac{px^2}{ 4q}\right),$$
which is equivalent to LS.
