Representing a number as a sum of at most $k$ squares Fix an integer $k >0 $ and would like to know the maximum number of different ways that a number $n$ can be expressed as a sum of $k$ squares, i.e. the number of integer solutions to
$$ n = x_1^2 + x_2^2 + \dots + x_k^2$$
with $x_1 \ge x_2 \ge \dots \ge x_k$ and $x_i \ge 0$ for every $i$.
What I'd really like to know about is the asymptotics as $n \to \infty$.
I asked a number theorist once about the case $k=2$, and if I remember correctly, he said that there are numbers $n$ which can be expressed as a sum of two squares in at least $$n^{c/\log \log n}$$ different ways, for some constant $c > 0$, and this is more-or-less best possible. This is the kind of answer I am seeking for larger $k$.
Clarification:
What I mean by maximum is the following.  I want functions $f_k(x)$, as large as possible, such that there exists some sequence of integers $\{ a_i \}$ with $a_i \to \infty$,
and such that $a_i$ can be written as the sum of $k$ squares in at least $f_k(a_i)$ ways.

This is an example of "Waring's problem" - expressing integers as the sum of $k$ $p$th powers of integers. In the case of squares, when $k\ge5$ the asymptotics of the number of representations (as a function of $n$) have been known for some time (I believe Hua proved this in the 1930s). When $k\ge5$, the number of ways to write $n$ as the sum of $k$ squares of positive integers is asymptotic to
$$
\frac{\Gamma(3/2)^k}{\Gamma(k/2)}n^{k/2-1} S(n),
$$
where $\Gamma$ is the Gamma function that interpolates the values of factorials, and $S(n) = S_k(n)$ is the "singular series" that depends upon $n$ but is bounded above and below.
One can find expositions of Waring's problem and the "circle method" (aimed at many different levels) in various places on the web, such as here and here.
