Let $Q$ be a four-variable positive-definite quadratic form with integer coefficients and let $r\_{Q}(n)$ be the number of representations of $n$ by $Q$. The theory of modular forms explains how $r\_{Q}(n) = a\_{E}(n) + a\_{C}(n)$ is broken into the Eisenstein series piece, and the cusp form piece. Knowing what numbers are represented by $Q$ boils down to getting a formula for $a\_{E}(n)$ which is of size ''about'' $n$ (as long as local conditions are satified - the formula of Siegel makes this precise), and bounding $|a\_{C}(n)|$ (which is $\leq C\_{Q} d(n) \sqrt{n}$, where $d(n)$ is the number of divisors of $n$). The hardest part of this is determining $C\_{Q}$, and all the methods for doing this rely on bounds for $r\_{Q}(n)$.


My question is



> 
> If $n$ is a fixed positive integer, what is ${\rm max}\_{Q}~r\_{Q}(n)$? Here the max runs over all 4-variable positive-definite integral quadratic forms.
> 
> 
> 


My suspicion is that this max always occurs for a form $Q$ with low discriminant, and in particular I would guess the max is always $\leq 24 \sigma(n)$. Equality is achieved for odd $n$ with $Q = x^{2} + y^{2} + z^{2} + w^{2} + xw + yw + zw$, the smallest discriminant quaternary form. (Edit: There are some $n$ that are represented more ways with a form of discrimiant $5$. It seems the right conjecture is $r\_{Q}(n) \leq 30 \sigma(n)$.)


I would even be satisfied with a bound of the type $r\_{Q}(n) \leq C n \log(n)$ with a value of $C$ that doesn't depend on $Q$. It's possible that one could prove something like this for quadratic polynomials by induction on the number of variables, but I don't see how to make that work. (It seems that $2$ variables is the naturally starting point.)


Another possible approach is something like the circle method, which can recover similar bounds to those which the theory of modular forms gives. In the papers on this subject though, the dependence on the form in the error term seems to make a result of the type I seek difficult.



Which quaternary quadratic form represents $n$ the greatest number of times?
**Theorem.** Let $Q(x\_1,\dots,x\_k)$ be a positive definite integral quadratic form in $k\geq 2$ variables. Then the number of integral representations $Q(x\_1,\dots,x\_k)=n$ satisfies 
$$r\_Q(n)\ll\_{k,\epsilon}n^{k/2-1+\epsilon}.$$ 
The implied constant depends only on $k$ and $\epsilon$, so it is independent of the actual coefficients of $Q$.


*Remark.* The "Added 1" section, posted with the permission of Valentin Blomer, contains a more precise result for $k=4$.


**Proof.** We induct on $k$, and for simplicity we do not indicate the dependence of implied constants on $k$. The case $k=2$ is classical and goes back to Gauss (see the "Added 2" section for more details). So let $k\geq 3$, and assume that the statement holds with $k-1$ in place of $k$. We can assume that
$$ Q(x\_1,\dots,x\_k)=\sum\_{1\leq i,j\leq k} a\_{ij}x\_ix\_j$$
is Minkowski reduced. In particular, $a\_{ij}=a\_{ji}$ and
$$ 0<a\_{11}\leq a\_{22}\leq\dots\leq a\_{kk}. $$
Then we have a decomposition
$$ Q(x\_1,\dots,x\_k)=\sum\_{i=1}^k h\_i\left(\sum\_{i\leq j\leq k}c\_{ij}x\_j\right)^2,$$
where $h\_i\asymp a\_{ii}$, $c\_{ii}=1$ and $c\_{ij}\ll 1$ (see Theorem 3.1 and Lemma 1.3 in Chapter 12 of Cassels: Rational quadratic forms). In particular, the coefficients of $Q$ satisfy
$$ a\_{11}\dots a\_{kk}\asymp h\_1\dots h\_k=\det(Q),$$
hence also $a\_{ij}\ll a\_{kk}\ll\det(Q)$ and $h\_k\asymp a\_{kk}\gg\det(Q)^{1/k}$.


We fix the positive integer $n$, and we consider the integral representations $Q(x\_1,\dots,x\_k)=n$. The number of representations with $x\_k=0$ is 
$\ll\_{\epsilon}n^{k/2-3/2+\epsilon}$ by the induction hypothesis, so we can focus on the representations with $x\_k\neq 0$. From the above, we see immediately that $x\_k\ll\sqrt{n}\det(Q)^{-1/(2k)}$, and then also that $x\_{k-1}\ll\sqrt{n}$, then $x\_{k-2}\ll\sqrt{n}$, and so on, finally $x\_3\ll\sqrt{n}$. It follows that there are $\ll n^{(k-2)/2}\det(Q)^{-1/(2k)}$ choices for the $(k-2)$-tuple $(x\_3,\dots,x\_k)$ such that $x\_k\neq 0$. Fixing such a tuple, 
we are left with an inhomogeneous binary representation problem
$$ a\_{11}x\_1^2 + 2a\_{12}x\_1x\_2 + a\_{22}x\_2^2 + d\_1 x\_1 + d\_2 x\_2 + e = 0 $$
with fixed integral coefficients $d\_1,d\_2\ll\sqrt{n}\det(Q)$ and $e\ll n\det(Q)$. Using Lemma 8 in [this paper](https://arxiv.org/abs/1402.4635) of Blomer and Pohl, it follows that the number of choices for $(x\_1,x\_2)$ is $\ll\_\epsilon n^\epsilon\det(Q)^\epsilon$. Summing up, we get
$$ r\_Q(n)\ll\_{\epsilon} n^{k/2-3/2+\epsilon} + n^{(k-2)/2+\epsilon}\det(Q)^{-1/(2k)+\epsilon} \ll n^{k/2-1+\epsilon},$$
and we are done.


**Added 1.** I have been in touch with Valentin Blomer about the original question, and my answer above incorporated a key input from him. More importantly, he realized that the above argument together with some automorphic input allows one to prove, for the case of $k=4$ variables, the striking uniform upper bound (with an absolute implied constant)
$$r\_Q(n) \ll \sigma(n).$$ 
Here is the argument of Valentin Blomer, posted with his permission.
For $n\leq\det(Q)^{10}$, the last line of the inductive proof above gives
$$ r\_Q(n)\ll\_{\epsilon} n^{1/2+\epsilon} + n^{1+\epsilon}\det(Q)^{-1/8+\epsilon} \ll n^{79/80+2\epsilon},$$
so we can (and we shall) assume that $n>\det(Q)^{10}$. We decompose the $\theta$-series of $Q$ uniquely as
$$\theta\_Q(z) = E(z) +S(z) = \sum\_{n=1}^\infty a(n) e(nz) + \sum\_{n=1}^\infty b(n) e(nz)$$ into an Eisenstein series and a cusp form of weight $2$ and level $N$, which is the level of $Q$. Accordingly, $r\_Q(n)=a(n)+b(n)$, so it suffices to show that
$a(n)\ll\sigma(n)$ and $b(n)\ll\sigma(n)$. The first bound was proved by Gogishvili (Georgian Math. J. 13 (2006), 687-691.), as follows from (2) and (13)-(14) in his paper. Therefore, it suffices to prove the second bound. We write
$$S = \sum\_{f \in B} c(f) f$$
in terms of an orthonormal Hecke eigenbasis $B$ for $S\_2(N, \chi)$, where $\chi$ is a quadratic character and the inner product is given by
$$(f, g) = \int\_{\Gamma\_0(N)\backslash \mathcal{H}} f(z)\bar{g}(z) \frac {dx\, dy}{y^2}.$$
We write $f(z) = \sum\_n \lambda\_f(n) e(nz)$, so that $b(n) = \sum\_f c(f) \lambda\_f(n)$. We avoid any use of Eichler/Deligne, among other things because it would require us to deal with oldforms carefully. Instead, we use the Petersson formula and Weil's bound for Kloosterman sums (together with Cauchy-Schwarz and Parseval):
$$\begin{split}
|b(n) |^2 \| S \|\_2^{-2} n^{-1} & \leq n^{-1} \sum\_f |\lambda\_f(n)|^2 \ll 1 + \sum\_{c} \frac{1}{c} S\_{\chi}(n, n, c) J\_1\left(\frac{4\pi n}{c}\right)\\
& \ll 1 + \sum\_{c} \frac{(n, c)^{1/2}\tau(c)}{c^{1/2}} \min\left(\frac{n}{c}, \frac{c^{1/2}}{n^{1/2}}\right) \ll\_\epsilon n^{1/2 + \epsilon},
\end{split}$$
so that
$$b(n) \ll\_\epsilon \| S \|\_2 n^{3/4 + \epsilon}.$$
We have, by Lemma 4.2 of Blomer (Acta Arith. 114 (2004), 1-21.),
$$\| S \|\_2 \ll\_\epsilon \det(Q)^{2+\epsilon},$$
whence in the end
$$b(n) \ll\_\epsilon \det(Q)^{2+\epsilon} n^{3/4 + \epsilon} \leq n^{19/20+2\epsilon}.$$
This concludes the proof. We note that for the twisted Kloosterman sum, the Weil-Estermann bound is not always true for higher prime powers, see Section 9 of Knightly-Li (Mem. Amer. Math. Soc. 224 (2013), no. 1055), but it is true for the case of quadratic characters that we are using here.


**Added 2.** Let me provide the details for the case $k=2$. Without loss of generality, 
$$Q(x,y)=ax^2+bxy+cy^2$$
is a reduced form. That is,
$$|b|\leq a\leq c,\qquad\text{whence also}\qquad a\ll\det(Q)^{1/2}.$$
The equation $Q(x,y)=n$ can be rewritten as
$$(2ax+by)^2+4\det(Q)y^2=4an.$$
We can assume that there are (integral) solutions with nonzero $y$, for otherwise there are at most two solutions. In this case,
$$n\geq\det(Q)/a\gg a.$$
The equation factors in the ring of integers of an imaginary quadratic number field, hence a standard divisor bound argument combined with the previous display yields that the number of solutions is 
$$\ll\_\epsilon(an)^\epsilon\ll\_\epsilon n^{2\epsilon}.$$


