## Let $g(n)$ denote the number of ways a positive integer $n$ can be represented in the form: $$x^2+xy+41y^2$$ where $x$ and $y$ are integers. For example, $g(53)=4$ due to $(x,y) \in \{(-4,1),(-3,-1),(3,1),(4,-1)\}$.

Define $\displaystyle T(N)=\sum_{n=1}^{N}g(n)$. You are given $T(10^3)=474$ and $T(10^6)=492128$.

Find $T(10^{16})$.

### The problem deals with the issue of expressing a number in a particular quadratic form. A fundamental tool in understanding these counts is the theory of quadratic forms, and specifically the connection it has to Theta Series.

Theta Series are power series whose coefficients are related to the number of representations of an integer in a quadratic form. For this problem, we are looking at the theta series of the quadratic form $x^2 + xy + 41y^2$.

Let’s denote this Theta series as $$\Theta(q) = \sum_{(x,y)\in Z^2} q^{x^2+xy+41y^2}$$.

Power series can be manipulated (multiplied, divided, differentiated, integrated, etc.) while preserving the coefficients.

This quadratic form can be transformed to $x^2+xy+41y^2 = (x+y)^2+40y^2$.

Therefore, the Theta series would look like $$\Theta(q) = \sum_{(x,y)\in Z^2} q^{(x+y)^2+40y^2}$$.

We can see that our Theta series is actually a product of two Theta series associated with simpler quadratic forms $x^2+y^2$ and $40y^2$. Denote by $g$ the power series for $x^2+y^2$, and $h$ the power series for $40y^2$.

Therefore, $\Theta = g*h$.

We can sum the Theta series till $N$ to get $T(N)$.

From problem input, we know $T(10^{3}) = 474$ and $T(10^{6}) = 492128$.

We don’t have a direct way of calculating $T(10^{16})$, because that would involve working with too many coefficients. However, because of the spectacular properties of power series, we can actually do it indirectly.

First, we understand how the operation of ‘multiplication of series’ affects the operation ‘sum till $N$’. From here, we can infer how the counts for the simpler forms (which are multiplication’s factors) relate to our original $T(N)$ count.

With some algebra and power series manipulations, we find that $\Theta(q) = g(q) * h(q)$ becomes

$$T(N) = \sum_{{j=0}}^{N} C({j})D({N-j})$$ where $C(N) = \sum_{{n=1}}^N g(n)$ and $D(N) = \sum_{{n=1}}^N h(n)$.

Computed amounts of $T(10^3) = 474$ and $T(10^6)=492128$ can be used to solve for coefficients of $g(q)$ and $h(q)$, doing some calculations, you will be able to use bisection or other similar methods to find that $C(10^8)\approx602062$ and $D(10^8)\approx822667$.

Use that approximation to solve for $T(10^{16})$ using the formula $\sum_{j=0}^{10^{16}} C(j) D(10^{16} – j)$ gives $T(10^{16}) = 59397492666$.

The answer thus found is, $T(10^{16}) = 59397492666$.

##### More Answers:

Hybrid IntegersIterated Composition

Pseudorandom Sequence