The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation. Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A004018 Theta series of square lattice (or number of ways of writing n as a sum of 2 squares). Often denoted by r(n) or r_2(n). (Formerly M3218) 112

%I M3218

%S 1,4,4,0,4,8,0,0,4,4,8,0,0,8,0,0,4,8,4,0,8,0,0,0,0,12,8,0,0,8,0,0,4,0,

%T 8,0,4,8,0,0,8,8,0,0,0,8,0,0,0,4,12,0,8,8,0,0,0,0,8,0,0,8,0,0,4,16,0,

%U 0,8,0,0,0,4,8,8,0,0,0,0,0,8,4,8,0,0,16,0,0,0,8,8,0,0,0,0,0,0,8,4,0,12,8

%N Theta series of square lattice (or number of ways of writing n as a sum of 2 squares). Often denoted by r(n) or r_2(n).

%C Number of points in square lattice on the circle of radius sqrt(n). Equivalently, number of Gaussian integers of norm n (cf. Conway-Sloane, p. 106).

%C Let b(n)=A004403(n), then Sum_{k=1..n} a(k)*b(n-k) = 1. - _John W. Layman_

%C Theta series of D_2 lattice.

%C Number 6 of the 74 eta-quotients listed in Table I of Martin (1996).

%C Ramanujan theta functions: f(q) (see A121373), phi(q) (A000122), psi(q) (A010054), chi(q) (A000700).

%C The zeros in this sequence correspond to those integers with an equal number of 4k+1 and 4k+3 divisors, or equivalently to those that have at least one 4k+3 prime factor with an odd exponent (A022544). - _Ant King_, Mar 12 2013

%C If A(q) = 1 + 4*q + 4*q^2 + 4*q^4 + 8*q^5 + ... denotes the o.g.f. of this sequence then the function F(q) := 1/4*(A(q^2) - A(q^4)) = ( Sum_{n >= 0} q^(2*n+1)^2 )^2 is the o.g.f. for counting the ways a positive integer n can be written as the sum of two positive odd squares. - _Peter Bala_, Dec 13 2013

%C Expansion coefficients of (2/Pi)*K, with the real quarter period K of elliptic functions, as series of the Jacobi nome q, due to (2/Pi)*K = theta_3(0,q)^2. See, e.g., Whittaker-Watson, p. 486. - _Wolfdieter Lang_, Jul 15 2016

%C Sum_{k=0..n} a(n) = A057655(n). _Robert G. Wilson v_, Dec 22 2016

%C Lim_{n-> infinity} (a(n)/n - Pi*log(n)) = A062089: Sierpinski's constant. - _Robert G. Wilson v_, Dec 22 2016

%C The mean value of a(n) is Pi, see A057655 for more details. - _M. F. Hasler_, Mar 20 2017

%D L. Comtet, Advanced Combinatorics, Reidel, 1974, p. 162, #16 (7), r(n).

%D J. H. Conway and N. J. A. Sloane, "Sphere Packings, Lattices and Groups", Springer-Verlag, p. 106.

%D N. J. Fine, Basic Hypergeometric Series and Applications, Amer. Math. Soc., 1988; p. 78, Eq. (32.23).

%D E. Grosswald, Representations of Integers as Sums of Squares. Springer-Verlag, NY, 1985, p. 15, p. 32, Lemma 2 (with the proof), p. 116, (9.10) first formula.

%D G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers. 3rd ed., Oxford Univ. Press, 1954, p. 240, r(n).

%D W. König and J. Sprekels, Karl Weierstraß (1815-1897), Springer Spektrum, Wiesbaden, 2016, p. 186-187 and p. 280-281.

%D C. D. Olds, A. Lax and G. P. Davidoff, The Geometry of Numbers, Math. Assoc. Amer., 2000, p. 51.

%D N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

%D E. T. Whittaker and G. N. Watson, A Course of Modern Analysis, fourth edition, reprinted, 1958, Cambridge at the University Press.

%H T. D. Noe, <a href="/A004018/b004018.txt">Table of n, a(n) for n = 0..10000</a>

%H G. E. Andrews, R. Lewis and Z.-G. Liu, <a href="http://dx.doi.org/10.1112/blms/33.1.25">An identity relating a theta series to a sum of Lambert series</a>, Bull. London Math. Soc., 33 (2001), 25-31.

%H H. H. Chan and C. Krattenthaler, <a href="https://arxiv.org/abs/math/0407061">Recent progress in the study of representations of integers as sums of squares</a>, arXiv:math/0407061 [math.NT], 2004.

%H S. Cooper and M. Hirschhorn, <a href="http://www.emis.de/journals/INTEGERS/papers/e9/e9.Abstract.html">A combinatorial proof of a result from number theory</a>, Integers 4 (2004), #A09.

%H Michael Gilleland, <a href="/selfsimilar.html">Some Self-Similar Integer Sequences</a>

%H J. W. L. Glaisher, <a href="https://books.google.com/books?id=bLs9AQAAMAAJ&amp;pg=RA1-PA1">On the representations of a number as the sum of two, four, six, eight, ten, and twelve squares</a>, Quart. J. Math. 38 (1907), 1-62. (This sequence is called rho, see page 6)

%H M. D. Hirschhorn, <a href="http://web.maths.unsw.edu.au/~mikeh/webpapers/paper58.pdf">Jacobi's Two-Square Theorem and Related Identities</a>

%H M. D. Hirschhorn, <a href="http://web.maths.unsw.edu.au/~mikeh/webpapers/paper67.pdf">Arithmetic Consequences of Jacobi's Two-Squares Theorem</a>

%H M. D. Hirschhorn, <a href="http://dx.doi.org/10.1016/j.disc.2004.08.045">The number of representations of a number by various forms</a>, Discrete Mathematics 298 (2005), 205-211.

%H Jacobi-Legendre letters, <a href="http://www.digizeitschriften.de/dms/img/?PID=GDZPPN002156199">Correspondance mathématique entre Legendre et Jacobi</a>, J. Reine Angew. Math. 80 (1875) 205-279, letter of September 9, 1828, p. 240-243, formula for 2K/Pi on p. 242.

%H Christian Kassel and Christophe Reutenauer, <a href="https://arxiv.org/abs/1505.07229v3">The zeta function of the Hilbert scheme of n points on a two-dimensional torus</a>, arXiv:1505.07229v3 [math.AG], 2015. [Note that a later version of this paper has a different title and different contents, and the number-theoretical part of the paper was moved to the publication which is next in this list.]

%H Christian Kassel and Christophe Reutenauer, <a href="https://arxiv.org/abs/1610.07793">Complete determination of the zeta function of the Hilbert scheme of n points on a two-dimensional torus</a>, arXiv:1610.07793 [math.NT], 2016.

%H Christian Kassel, Christophe Reutenauer, <a href="http://arxiv.org/abs/1603.06357">The Fourier expansion of eta(z)eta(2z)eta(3z)/eta(6z)</a>, arXiv:1603.06357 [math.NT], 2016.

%H M. Kontsevich and D. Zagier, <a href="http://www.ihes.fr/~maxim/TEXTS/Periods.pdf">Periods</a>, Institut des Hautes Etudes Scientifiques 2001 IHES/M/01/22. Published in B. Engquist and W. Schmid, editors, Mathematics Unlimited - 2001 and Beyond, 2 vols., Springer-Verlag, 2001, pp. 771-808, section 2.3. Example 3.

%H Y. Martin, <a href="http://dx.doi.org/10.1090/S0002-9947-96-01743-6">Multiplicative eta-quotients</a>, Trans. Amer. Math. Soc. 348 (1996), no. 12, 4825-4856, see page 4852 Table I.

%H G. Nebe and N. J. A. Sloane, <a href="http://www.math.rwth-aachen.de/~Gabriele.Nebe/LATTICES/D2.html">Home page for this lattice</a>

%H F. Richman, <a href="http://math.fau.edu/Richman/gausdisk.htm">Counting Gaussian integers in a disk</a>

%H Grant Sanderson, <a href="https://www.youtube.com/watch?v=NaL_Cb42WyY">Pi hiding in prime regularities</a>, 3Blue1Brown video (2017).

%H N. J. A. Sloane et al., <a href="https://oeis.org/wiki/Binary_Quadratic_Forms_and_OEIS">Binary Quadratic Forms and OEIS</a> (Index to related sequences, programs, references)

%H Michael Somos, <a href="/A030203/a030203.txt">Index to Yves Martin's list of 74 multiplicative eta-quotients and their A-numbers</a>

%H Michael Somos, <a href="/A010815/a010815.txt">Introduction to Ramanujan theta functions</a>

%H G. Villemin, <a href="http://villemin.gerard.free.fr/Wwwgvmm/Addition/NoSoCaPr.htm#De1a15">Sommes de 2 carrés</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Barnes-WallLattice.html">Barnes-Wall Lattice</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/MoebiusTransform.html">Moebius Transform</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/RamanujanThetaFunctions.html">Ramanujan Theta Functions</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/SumofSquaresFunction.html">Sum of Squares Function</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/ThetaSeries.html">Theta Series</a>

%H G. Xiao, <a href="http://wims.unice.fr/~wims/en_tool~number~twosquares.en.html">Two squares</a>

%H <a href="/index/Su#ssq">Index entries for sequences related to sums of squares</a>

%H <a href="/index/Ge#Glaisher">Index entries for sequences mentioned by Glaisher</a>

%H <a href="/index/Cor#core">Index entries for "core" sequences</a>

%F Expansion of theta_3(q)^2 = (Sum_{n=-inf..+inf} q^(n^2))^2 = Product_{m>=1} (1-q^(2*m))^2 * (1+q^(2*m-1))^4.

%F Factor n as n = p1^a1 * p2^a2 * ... * q1^b1 * q2^b2 * ... * 2^c, where the p's are primes == 1 (mod 4) and the q's are primes == 3 (mod 4). Then a(n) = 0 if any b is odd, otherwise a(n) = 4*(1 + a1)*(1 + a2)*...

%F G.f. = s(2)^10/(s(1)^4*s(4)^4), where s(k) := subs(q=q^k, eta(q)) and eta(q) is Dedekind's function, cf. A010815. [Fine]

%F a(n) = 4*A002654(n), n > 0.

%F Expansion of eta(q^2)^10 / (eta(q) * eta(q^4))^4 in powers of q. - _Michael Somos_, Jul 19 2004

%F Expansion of ( phi(q)^2 + phi(-q)^2 ) / 2 in powers of q^2 where phi() is a Ramanujan theta function.

%F G.f. A(x) satisfies 0 = f(A(x), A(x^2), A(x^4)) where f(u, v, w) = (u - v)^2 - (v - w) * 4 * w. - _Michael Somos_, Jul 19 2004

%F Euler transform of period 4 sequence [4, -6, 4, -2, ...]. - _Michael Somos_, Jul 19 2004

%F Moebius transform is period 4 sequence [4, 0, -4, 0, ...]. - _Michael Somos_, Sep 17 2007

%F G.f. is a period 1 Fourier series which satisfies f(-1 / (4 t)) = 2 (t/i) f(t) where q = exp(2 Pi i t).

%F The constant sqrt(Pi)/GAMMA(3/4)^2 produces the first 324 terms of the sequence when expanded in base exp(Pi), 450 digits of the constant are necessary. - _Simon Plouffe_, Mar 03 2011

%F a(n) = A004531(4*n). a(n) = 2*A105673(n), if n>0.

%F Let s = 16*q*(E1*E4^2/E2^3)^8 where Ek = Product_{n>=1} (1-q^(k*n)) (s=k^2 where k is elliptic k), then the g.f. is hypergeom([+1/2, +1/2], [+1], s) (expansion of 2/Pi*ellipticK(k) in powers of q). - _Joerg Arndt_, Aug 15 2011

%F Dirichlet g.f. Sum_{n>=1} a(n)/n^s = 4*zeta(s)*L_(-4)(s), where L is the D.g.f. of the (shifted) A056594. [Raman. J. 7 (2003) 95-127]. - _R. J. Mathar_, Jul 02 2012

%F a(n) = floor(1/(n+1)) + 4*floor(cos(Pi*sqrt(n))^2) - 4*floor(cos(Pi*sqrt(n/2))^2) + 8*Sum_{i=1..floor(n/2)} floor(cos(Pi*sqrt(i))^2)*floor(cos(Pi*sqrt(n-i))^2). - _Wesley Ivan Hurt_, Jan 09 2013

%F From _Wolfdieter Lang_, Aug 01 2016: (Start)

%F A Jacobi identity: theta_3(0, q)^2 = 1 + 4*Sum_{r>=0} (-1)^r*q^(2*r+1)/(1 - q^(2*r+1)). See, e.g., the Grosswald reference (p. 15, p. 116, but p. 32, Lemma 2 with the proof, has the typo r >= 1 instead of r >= 0 in the sum, also in the proof). See the link with the Jacobi-Legendre letter.

%F Identity used by Weierstraß (see the König-Sprekels book, p. 187, eq. (5.12) and p. 281, with references, but there F(x) from (5.11) on p. 186 should start with nu =1 not 0): theta_3(0, q)^2 = 1 + 4*Sum_{n>=1} q^n/(1 + q^(2*n)). Proof: similar to the one of the preceding Jacobi identity. (End)

%F a(n) = (4/n)*Sum_{k=1..n} A186690(k)*a(n-k), a(0) = 1. - _Seiichi Manyama_, May 27 2017

%F G.f.: Theta_3(q)^2 = hypergeometric([1/2, 1/2],,lambda(q)), with lambda(q) = Sum_{j>=1} A115977(j)*q^j. See the Kontsevich and Zagier link, with Theta -> Theta_3, z -> 2*z and q -> q^2. - _Wolfdieter Lang_, May 27 2018

%e G.f. = 1 + 4*q + 4*q^2 + 4*q^4 + 8*q^5 + 4*q^8 + 4*q^9 + 8*q^10 + 8*q^13 + 4*q^16 + 8*q^17 + 4*q^18 + 8*q^20 + 12*q^25 + 8*q^26 + ... . - _John Cannon_, Dec 30 2006

%p (sum(x^(m^2),m=-10..10))^2;

%p # Alternative:

%p A004018list := proc(len) series(JacobiTheta3(0, x)^2, x, len+1);

%p seq(coeff(%, x, j), j=0..len-1) end:

%p t1 := A004018list(102);

%p r2 := n -> t1[n+1]; # _Peter Luschny_, Oct 02 2018

%t SquaresR[2,Range[0,110]] (* _Harvey P. Dale_, Oct 10 2011 *)

%t a[ n_] := SquaresR[ 2, n]; (* _Michael Somos_, Nov 15 2011 *)

%t a[ n_] := SeriesCoefficient[ EllipticTheta[ 3, 0, q]^2, {q, 0, n}]; (* _Michael Somos_, Nov 15 2011 *)

%t a[ n_] := With[{m = InverseEllipticNomeQ @ q}, SeriesCoefficient[ EllipticK[ m] / (Pi/2), {q, 0, n}]]; (* _Michael Somos_, Jun 10 2014 *)

%t a[ n_] := If[ n < 1, Boole[n == 0], 4 Sum[ KroneckerSymbol[-4, d], {d, Divisors@n}]]; (* or *) a[ n_] := SeriesCoefficient[ QPochhammer[ q^2]^10/(QPochhammer[ q] QPochhammer[ q^4])^4, {q, 0, n}]; (* _Michael Somos_, May 17 2015 *)

%o (PARI) {a(n) = polcoeff( 1 + 4 * sum( k=1, n, x^k / (1 + x^(2*k)), x * O(x^n)), n)}; /* _Michael Somos, Mar 14 2003 */

%o (PARI) {a(n) = if( n<1, n==0, 4 * sumdiv( n, d, (d%4==1) - (d%4==3)))}; /* _Michael Somos_, Jul 19 2004 */

%o (PARI) {a(n) = if( n<1, n==0, 2 * qfrep([ 1, 0; 0, 1], n)[n])}; /* _Michael Somos_, May 13 2005 */

%o (PARI) a(n)=if(n==0,return(1)); my(f=factor(n)); 4*prod(i=1,#f~, if(f[i,1]%4==1, f[i,2]+1, if(f[i,2]%2 && f[i,1]>2, 0, 1))) \\ _Charles R Greathouse IV_, Sep 02 2015

%o (MAGMA) Basis( ModularForms( Gamma1(4), 1), 100) ; /* _Michael Somos_, Jun 10 2014 */

%o (Sage)

%o Q = DiagonalQuadraticForm(ZZ, *2)

%o Q.representation_number_list(102) # _Peter Luschny_, Jun 20 2014

%o (Julia) # JacobiTheta3 is defined in A000122.

%o A004018List(len) = JacobiTheta3(len, 2)

%o A004018List(102) |> println # _Peter Luschny_, Mar 12 2018

%Y Row d=2 of A122141 and of A319574, 2nd column of A286815.

%Y Partial sums - 1 give A014198.

%Y A071385 gives records; A071383 gives where records occur.

%Y Cf. A001481, A004020, A005883, A057655 (partial sums), A057961, A057962, A002654,

%Y A104271, A105673.

%K nonn,easy,nice,core

%O 0,2

%A _N. J. A. Sloane_

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified April 20 06:59 EDT 2021. Contains 343125 sequences. (Running on oeis4.)