<<

Sums of Squares and Triangular Numbers

Hershel M. Farkas Institute of Mathematics The Hebrew University Jerusalem

Submitted: July 7, 2005; Accepted: December 5, 2005; Published: May 5, 2006

Abstract In this note we use the theory of theta functions to discover formulas for the number of representations of N as a sum of three squares and for the number of representations of N as a sum of three triangular numbers. We discover various new relations between these functions and short, motivated proofs of well known formulas of related combinatorial and number-theoretic interest.

1 Introduction

There has been lots of work on the problem of writing a non negative integer as a sum of squares. For references to the literature and background information we refer to the book [G] by E. Grosswald and the article [M] by S. Milne. One of the facts that one learns from these texts is that the problem is much harder when we wish information and the number of summands is an odd integer. In this note we consider the case of sums of 3 squares and develop some formulas for this case. Let Sk(n) denote the number of ways one can write n as a sum of k squares or the number of solutions to the diophantine equation 2 2 2 x1 + x2 + ··· + xk = n. It is well known that for k = 2, 4 Jacobi gave a formula for this number in terms of the of n. Jacobi’s formulae are

S2(n) = 4(d1(n) − d3(n)) 0 S4(n) = 8σ (n) 0 where di(n) is the number of divisors of n congruent to i mod 4, and σ (n) is the sum of the divisors of n not congruent to 0 mod 4. It follows from Jacobi’s formula that

S2(4k + 3) = 0,S2(2k) = S2(k). These facts, of course, do not require Jacobi’s formula and can be proven in a simple way without it. If one defines Tk(n) to be the number of ways one can write n as a sum of k triangular numbers or the number of solutions of the diophantine equation x2 + x x2 + x x2 + x 1 1 + 2 2 + ··· + k k = n 2 2 2 an additional easy fact that can be shown is that

T2(n) = S2(4n + 1).

Online Journal of Analytic Combinatorics, Issue 1 (2006), #1 1    Definition 1. The with characteristic ∈ R2, 0 ζ ∈ C, τ ∈ H is defined by ∞    X 1   0 θ (ζ, τ) = exp(2πi[ (n + )2τ + (n + )(ζ + )]) 0 2 2 2 2 n=−∞ where H is the upper half plane and C is the complex plane. The theta function satisfies many identities among them the following  0   0   1  θ2 (0, τ) = θ2 (0, 2τ) + θ2 (0, 2τ) (1) 0 0 0

 0   0   1  θ2 (0, τ) = θ2 (0, 2τ) − θ2 (0, 2τ) (2) 1 0 0  1   0   1  θ2 (0, τ) = 2θ (0, 2τ)θ (0, 2τ) (3) 0 0 0 The above three identities are enough for example to give the well known Jacobi quartic identity  0   0   1  θ4 (0, τ) = θ4 (0, τ) + θ4 (0, τ). (4) 0 1 0 In terms of the variable x = exp(πiτ) we have   ∞   ∞ 2 0 X n 2 1 1 X 2n θ (0, τ) = S (n)x , θ (0, τ) = x 4 T (n)x , 0 2 0 2 n=0 n=0 so that (1) above translates to the identity

∞ ∞ ∞ X n X 2n X 4n+1 S2(n)x = S2(n)x + T2(n)x . n=0 n=0 n=0

The three properties we recorded above which are satisfied by S2(n) are all consequences of this quite elementary theta identity. The purpose of this note is to find theta identities which will do for the function S3(n) what equation (1) did for S2(n). In addition we shall obtain some interesting formulas for S3(n) which will depend on the congruence class of n mod 8. A byproduct of this investigation is the following. It is well known that not every positive integer can be written as a sum of 3 squares. In fact it is known that those positive integers congruent to 7 mod 8 are ”not” so expressible and that these are the only ones not so expressible. On the other hand it is also known that every positive integer is expressilble as the sum of three triangular numbers. We recall that k2+k a triangular number is a number of the form 2 . Hence 3 squares do not suffice and 3 triangulars do. Here we reprove a result which seems to have been forgotten [L],[R]. Theorem 1. Every positive integer can be written as the sum of two squares plus one trian- gular number and every positive integer can be written as the sum of two triangular numbers plus one square.

Online Journal of Analytic Combinatorics, Issue 1 (2006), #1 2 2 Theta constant identities

In this section we record some theta constant identities which we will need in the sequel. A reference for this section is the book [FK] where the reader can find the proofs of the statements not proved here. A rather simple identity is the following

k−1    X  +2l  θ (ζ, τ) = θ k (kζ, k2τ). (5) 0 k0 l=0 There are several simple consequences of this general identity. We list 4 instances of it corresponding to k = 2, 3.  0   0   1  θ (0, τ) = θ (0, 4τ) + θ (0, 4τ) (6) 0 0 0

 0   0   1  θ (0, τ) = θ (0, 4τ) − θ (0, 4τ) (7) 1 0 0  1   1   1  θ (0, τ) = 2θ 3 (0, 9τ) + θ (0, 9τ). (8) 0 0 0  1   5  In the above we have used the fact that θ 3 (0, 9τ) = θ 3 (0, 9τ). Our last instance 0 0 is the identity  0   2   0  θ (0, τ) = 2θ 3 (0, 9τ) + θ (0, 9τ). (9) 0 0 0  4   2  In the last identity we have used θ 3 (0, 9τ) = θ 3 (0, 9τ). We now begin to use these 0 0 elementary identities to prove Lemma 1. For all τ in the upper half plane it is true that  0   0  θ3 (0, τ) + θ3 (0, τ) = 0 1

 0   0   1  2θ3 (0, 4τ) + 6θ (0, 4τ)θ2 (0, 4τ) 0 0 0  0   0  θ3 (0, τ) − θ3 (0, τ) = 0 1  1   0   1  2θ3 (0, 4τ) + 6θ2 (0, 4τ)θ (0, 4τ) 0 0 0 Proof. Cubing equation (6), gives  0   0   0   1  θ3 (0, τ) = θ3 (0, 4τ) + 3θ2 (0, 4τ)θ (0, 4τ)+ (10) 0 0 0 0

 1   0   1  3θ2 (0, 4τ)θ (0, 4τ) + θ3 (0, 4τ). 0 0 0

Online Journal of Analytic Combinatorics, Issue 1 (2006), #1 3 Cubing equation (7) gives a similar expression only with alternating signs and the equa- tions of the lemma are obtained by adding and subtracting the expressions obtained by the cubing process. We now make the elementary observation that in the variable x = exp(πiτ), the left hand sides of the identities in the lemma are simply

∞ ∞ X 2n X 2n+1 2 S3(2n)x , 2 S3(2n + 1)x . n=0 n=0  0  This follows from the elementary fact that in the variable x, if we set θ (0, τ) = f(x), 0  0  then θ (0, τ) = f(−x). With this in hand we have 1

Corollary 1. The function S3(n) satisfies the following equations.

S3(4k) = S3(k),S3(8k + 7) = 0,S3(8k + 3) = T3(k) Proof. Writing the equations of the lemma in the variable x we have

∞ ∞ ∞ ∞ X 2n X 4n 2 X 4n2 X 8n 2 S3(2n)x = 2 S3(n)x + 6x x T2(n)x (11) n=0 n=0 n=−∞ n=0

∞ ∞ ∞ ∞ 2 X 2n+1 3 X 8n X 8 n +n X 4n 2 S3(2n + 1)x = 2x T3(n)x + 6x x 2 S2(n)x . (12) n=0 n=0 n=−∞ n=0 The first statement of the corollary follows from equation (11), while the second and third statements follow from equation (12). Remark 1. The results of the corollary are well known and not hard to prove. Our objective was getting them all as a consequence of a theta identity. We now will show that once we have the identity things that we may not have thought of before become obvious and lend themselves to a natural process of discovery. The third statement for example which is due to Gauss and which does have a very elementary proof could have been missed by a lesser person. Here it calls attention to itself.

3 Sums of triangulars

The above was deduced from the identity which followed from equation (6). Let us now see what we can get from equation (8). Cubing equation (8) we have

 1   1   1   1  θ3 (0, τ) = 8θ3 3 (0, 9τ) + 12θ2 3 (0, 9τ)θ (0, 9τ)+ (13) 0 0 0 0

 1   1   1  6θ 3 (0, 9τ)θ2 (0, 9τ) + θ3 (0, 9τ). 0 0 0

Online Journal of Analytic Combinatorics, Issue 1 (2006), #1 4 When we write equation (13) in the variable x = exp(πiτ), make the obvious simplifications 1 and replace x by x 2 , we obtain

∞ ∞ ∞ ∞ 2 2 2 2 X n +n 3 X 3 3n +n 3 X 3 3n +n 2 X 9 n +n ( x 2 ) = 8( x 2 ) + 12x( x 2 ) x 2 + (14) n=−∞ n=−∞ n=−∞ n=−∞

∞ ∞ ∞ 2 2 2 2 X 3 3n +n X 9 n +n 2 3 X 9 n +n 3 6x x 2 ( x 2 ) + x ( x 2 ) . n=−∞ n=−∞ n=−∞

Definition 2. Let Pk(n) denote the number of solutions of the diophantine equation 3x2 + x 3x2 + x 1 1 + ··· + k k = n. 2 2

Clearly Pk(n) is the number of ways n can be written as a sum of k generalized pentagonal 3k2−k numbers. We recall that a is a number of the form 2 with k non negative. We now can write equation (14) as

∞ ∞ ∞ ∞ 2 X n X 3n X 3n X 9 n +n T3(n)x = 8 P3(n)x + 12x P2(n)x x 2 + (15) n=0 n=0 n=0 n=−∞

∞ ∞ ∞ 2 2 X 9n X 3 3n +n 3 X 9n 6x T2(n)x x 2 + x T3(n)x . n=0 n=−∞ n=0 As a consequence of equation (15) we obtain Corollary 2. For all integers k we have k − 1 T (3k) = 8P (k) + T ( ) 3 3 3 3 where Tk is defined to be 0 whenever the variable is not a non negative integer. Hence T3(3k) = 8P3(k) unless k ≡ 1 mod 3. Remark 2. The result of the corollary is of course immediate from equation (15). The result is also proveable without the identity. It is really a consequence of the fact that a number congruent to 0 mod 3 can be written as the sum of 3 triangular numbers in two ways. Either as a sum of triangular numbers each one congruent to 0 mod three or as a sum of 3 triangular numbers each congruent to 1 mod 3. We leave the details to the reader. Our point once again is that using theta identities gives the identity automatically. Continuing in this vein we also from equation (15) immediately obtain Corollary 3. For all integers k we have

2 X k − 3l +l T (3k + 2) = 6 T ( 2 ) 3 2 3 l∈Z

and in particular T3(3k + 2) is congruent to 0 mod 24. Every non negative integer can be written as a sum of 2 numbers congruent to 0 mod 3 and a generalized pentagonal number where the numbers congruent to 0 mod 3 are 3 times a triangular number.

Online Journal of Analytic Combinatorics, Issue 1 (2006), #1 5 Proof. The exponents in the power given by the left hand side of equation (15) which ∞ 3n2+n ∞ 2 P 3 2 P 9n are congruent to 2 mod 3 all come from the expression 6x n=−∞ x n=0 T2(n)x . ∞ 3n2+n ∞ 2 P 3 2 P n This can be written as 6x n=−∞ x n=0 T2(n/9)x and the Cauchy product of these 2 2 3N−3 3k +k N− 3k +k P 2 P 2 gives the coefficient of 3N + 2 as 6 k∈Z T2( 9 ) = 6 k∈Z T2( 3 ) . This is the first statement in the corollary. The second statement follows since T2(n) is always congruent to 0 mod 4. The last statement follows from the fact that every non negative integer is expressible as a sum of 3 triangular numbers. This means that T3(3N + 2) is always positive. This means 3k2+k N− 2 that for at least one k, T2( 3 ) is positive. This of course says that for this k we have 2 3k +k 2 N− 2 3k +k 3 = t1 + t2 where ti are triangular numbers. Hence we have N = 3t1 + 3t2 + 2 which is the final statement.

4 Sums of squares

In this section we continue our investigations of the function S3(n). We remind the reader that it is well known that every number is a sum of 3 triangulars but not a sum of 3 squares. We shall show however that 2 squares and a triangular suffice and that 2 triangulars and a square also suffice. We return to equation (10) and observe that by using equation (6) it can be rewritten as

 0   0   1  θ3 (0, τ) = θ3 (0, 4τ) + θ3 (0, 4τ)+ (16) 0 0 0

 0   1   0  3θ (0, 4τ)θ (0, 4τ)θ (0, τ). 0 0 0 Using now equation (3) we can rewrite equation (16) as

 0   0   1  θ3 (0, τ) = θ3 (0, 4τ) + θ3 (0, 4τ)+ (17) 0 0 0

3  0   1  θ (0, τ)θ2 (0, 2τ). 2 0 0 This is our main identity in this paper from which the rest of the results will flow. As is usual by now, replacing τ with the variable x = exp(πiτ) equation (17) becomes

∞ ∞ ∞ X n X 4n 3 X 8n S3(n)x = S3(n)x + x T3(n)x + (18) n=0 n=0 n=0

∞ ∞ 3 X 2 X x xn T (n)x4n. 2 2 n=−∞ n=0 We notice immediately that equation (18) repeats the information we already knew namely that S3(4n) = S3(n),S3(8n + 7) = 0,S3(8n + 3) = T3(n)

Online Journal of Analytic Combinatorics, Issue 1 (2006), #1 6 but there is more imbedded in the remaining term ∞ ∞ 3 X 2 X x xn T (n)x4n. 2 2 n=−∞ n=0 In order to extract the information we rewrite the last term in equation (18) in the following way. ∞ ∞ ∞ 3 X 2 X 2 X x(1 + 2 x(2n) + 2 x(2n+1) )( T (n)x4n) 2 2 n=1 n=0 n=0 This has given us a sum ∞ ∞ ∞ ∞ 3 X 2 X X 2 X x(1 + 2x(2n) )( T (n/4)xn) + 3/2x( 2x(2n+1) )( T (n/4)xn). 2 2 2 n=1 n=0 n=0 n=0 In the above the first power series contains all the exponents congruent to 1 mod 4 while the second contains all the exponents congruent to 2 mod 4. Theorem 2. ∞ 3 X S (4N + 1) = ( 2T (N − k2) + T (N)) 3 2 2 2 k=1 ∞ X 2 S3(4N + 2) = 3( T2(N − (k + k)) k=0

so that S3(4N + 1) is congruent to 0 mod 6 and S3(4N + 2) is congruent to 0 mod 12. Moreover, every non negative integer is expressible as a sum of 2 triangular numbers plus a square. Proof. The first two statements follow from computing the Cauchy product and obtaining ∞ X 4N − 4k2 S (4N + 1) = 3/2( 2T ( ) + T (N)) 3 2 4 2 k=1 which is clearly the same as the first statement. Similarly the second statement is obtained by writing the Cauchy product ∞ X 4N − (4k2 + 4k) S (4N + 2) = 3/2( 2T ( ). 3 2 4 k=0

Since T2(n) is congruent to 0 mod 4 we get also the congruence statements. Finally since S3(4N + 1) is positive it means the right hand side is positive. This means that at least for 2 2 x2+x y2+y one k we have T2(N −k ) is positive. This of course says that for this k, N −k = 2 + 2 which is the last statement. Remark 3. Note that the last statement of the theorem is already half of Theorem 1. We now return to equation (12) and rewrite it as ∞ ∞ ∞ ∞ 2 X 2n+1 3 X 8n X n X 8 n +n S3(2n + 1)x = x T3(n)x + 6x S2(n/4)x x 2 n=0 n=0 n=0 n=0 and conclude from this that

Online Journal of Analytic Combinatorics, Issue 1 (2006), #1 7 Theorem 3. For all non negative k we have

∞ ∞ X 4N − 4(k2 + k) X S (4N + 1) = 6 S ( ) = 6 S (N − (k2 + k)). 3 2 4 2 k=0 k=0 In particular we therefore have

∞ X k2 + k S (8N + 1) = 6 S (N − ). 3 2 2 k=0 Proof. The proof of the first statement is just computing the coefficient of 4N + 1 in the Cauchy product of the power series for the rewritten equation (12). The second statement follows by letting M=2N in the first statement so that

∞ ∞ X X k2 + k S (8N + 1) = 6 S (2M − (k2 + k)) = 6 S (M − ), 3 2 2 2 k=0 k=0

the last equality being a consequence of the fact that S2(2M) = S2(M). Remark 4. We note that the last statement is the proof of the second half of Theorem 1 so that we have now completed the proof of that Theorem.

5 Some further identities

In this section we show how to obtain some further identities involving S3(N). We shall show how equation(9) leads to an identity connecting S3(N) with L3(N) where L3(N) is defined as

Definition 3. Lk(N) will denote the number of solutions to the diophantine equation N = 3x1(3x1 + 2) + ··· + 3xk(3xk + 2). Theorem 4. If N is not congruent to 0 mod 3 then

S3(3N) = 8L3(3(N − 1)). If N is congruent to 0 mod 3 then

S3(3N) = 8L3(3(N − 1)) + S3(N/3). Proof. We use equation (9) to obtain  0   2   2   0  θ3 (0, τ) = 8θ3 3 (0, 9τ) + 12θ2 3 (0, 9τ)θ (0, 9τ)+ 0 0 0 0

 2   0   0  6θ 3 (0, 9τ)θ2 (0, 9τ) + θ3 (0, 9τ). 0 0 0 In the variable x = exp(πiτ) we have

 2  ∞ X 2 θ 3 (0, 9τ) = x x9n +6n 0 n=−∞

Online Journal of Analytic Combinatorics, Issue 1 (2006), #1 8 so that our identity above can be rewritten as

∞ ∞ ∞ X n X 3n+3 X 9n S3(n)x = 8 L3(3n)x + S3(n)x + n=−∞ n=0 n=0

n=∞ ∞ ∞ ∞ 2 X 3n X 9n2 X 9n2+6n X 9n 12x L2(3n)x x + 6x x S2(n)x . n=0 n=−∞ n=−∞ n=0 The proof of the Theorem is now immediate from the the first two terms in the above identity.

We could of course also compute S3(3n + 1),S3(3n + 2) from the above identity and congruence relations for them but leave this to the reader.

6 Averaging

Our objective was to show how from a suitable theta constant identity we could obtain information about S3(N). The idea was to start with zero knowlege and see what we would get. We obtained Corollaries 1-3 and Theorems 2 and 3. We however do have some advance information and know that the function S3(N) should in some way depend on the congruence class of N mod 8. We could therefore, had we wished, adopted a more direct approach which we now briefly describe. For m a positive integer, 1 ≤ m ≤ 7 consider the average

7 X l  0  l exp[(πiτ)(m + )]θ3 (0, τ + ). 4 0 4 l=0 Using the elementary fact, see [FK], that

 0   0  θ (0, τ + 1) = θ (0, τ) 0 1 the above average can be rewritten as

3 X πilm  0  l  0  l exp(πimτ) exp( )(θ3 (0, τ + ) + (−1)mθ3 (0, τ + )). 4 0 4 1 4 l=0 We now use the identity we derived in Lemma 1. Assuming m is odd we get

3 X πilm  1   0   1  exp((πimτ) exp( )(2θ3 (0, 4τ + l) + 6θ2 (04τ + l)θ (0, 4τ + l)), 4 0 0 0 l=0 while if m is even we obtain

3 X πilm  0   1   0  exp((πimτ) exp( )(2θ3 (0, 4τ + l) + 6θ2 (0, 4τ + l)θ (0, 4τ + l). 4 0 0 0 l=0

Online Journal of Analytic Combinatorics, Issue 1 (2006), #1 9 We now require another elementary fact and that is that  1  πi  1  θ (0, τ + 1) = exp( )θ (0, τ). 0 4 0  0   0  We now note that θ (0, 4τ + l) is either equal to θ (0, 4τ) when l is even or equal 0 0  0  to θ (0, 4τ) when l is odd. We thus see that the average we have can be written for m 1 odd as 3  1  X πil(m + 3) exp(πimτ)[2θ3 (0, 4τ) exp( + 0 4 l=0  0   1  πi(m + 1) 6θ2 (0, 4τ)θ (0, 4τ)(1 + exp( ))+ 0 0 2  0   1  πi(m + 1) 3πi(m + 1) 6θ2 (0, 4τ)θ (0, 4τ)(exp( ) + exp( )]. 1 0 4 4 A little thought however will show the reader that what we are computing in this average  0  in the variable x = exp(πiτ) is simply the power series expansion of θ3 (0, τ) where 0 only the terms with exponent congruent to 0 mod 8 appear. In other words the result of this averaging process yields ∞ X 8n+8 8 S3(8n + 8 − m)x . n=0 As a consequence of the above computation we obtain Lemma 2. The result of the averaging process is as follows: For m=1 we obtain the identically zero power series. For m=3 we obtain  1   0   0  12exp(3πiτ)θ (0, 4τ)[θ2 (0, 4τ) − θ2 (0, 4τ)]. 0 0 1 For m=5 we obtain  1  8exp(5πiτ)θ3 (0, 4τ) 0 and for m=7 we obtain  1   0   0  12exp(7πiτ)θ (0, 4τ)[θ2 (0, 4τ) + θ2 (0, 4τ)]. 0 0 1 Proof. The proof is simply by substituting the value of m into the averaging process. By the remark made prior to the statement of the lemma we have as a consequence many of the results obtained previously. We enumerate some of these. The case m=1 gives immediately that S3(8n+7) = 0. The case m=5 yields immediately that S3(8n+3) = T3(n). The cases m=3,7 yield respectively ∞ X 8n+8 8 S3(8n + 5)x = n=0

Online Journal of Analytic Combinatorics, Issue 1 (2006), #1 10  1   0   0  12exp(3πiτ)θ (0, 4τ)[θ2 (0, 4τ) − θ2 (0, 4τ)] 0 0 1 and ∞ X 8n+8 8 S3(8n + 1)x = n=0  1   0   0  12exp(7πiτ)θ (0, 4τ)[θ2 (0, 4τ) + θ2 (0, 4τ)]. 0 0 1 By analyzing these last two equations we can also see that we have the following formulas for S3(n). X k2 + k S (8n + 1) = 6 S (n − ) 3 2 2 k≥0 a formula we already have obtained and

X k2 + k S (8n + 5) = 6 S (2(n − ) + 1) 3 2 2 k≥0 a new formula. One can now do the same computation for the even values of m. We leave this for the reader.

References

[FK] H. M. Farkas and I. Kra, Theta Constants, Riemann Surfaces and the Modular Group,Graduate Studies in Mathematics, vol. 37, American Mathematical Society, 2001. [G] E. Grosswald, Representation of Integers as Sums of Squares, Springer Verlag, New York 1985 . [L] V. A. Lebesgue Questions 1059,1060,1061 (Lionnet), Nouv. Ann. Math. , pp. 516-519, 1872. [M] S. Milne, Infinite Families of Exact Sums of Squares Formulas, Jacobi elliptic Functions, Continued Fractions, and Schur Functions, The Ramanujan Jopurnal, vol. 6, pp.7-149, 2002. [R] M. S. Realis Scolies pour un Theoreme D’Arithmetique, Nouv. Ann. Math. pp. 212-217, 1873.

Online Journal of Analytic Combinatorics, Issue 1 (2006), #1 11