OFFSET
0,2
COMMENTS
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).
Let b(n)=A004403(n), then Sum_{k=1..n} a(k)*b(n-k) = 1. - John W. Layman
Theta series of D_2 lattice.
Number 6 of the 74 eta-quotients listed in Table I of Martin (1996).
Ramanujan theta functions: f(q) (see A121373), phi(q) (A000122), psi(q) (A010054), chi(q) (A000700).
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
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
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
Sum_{k=0..n} a(n) = A057655(n). Robert G. Wilson v, Dec 22 2016
Limit_{n->oo} (a(n)/n - Pi*log(n)) = A062089: Sierpinski's constant. - Robert G. Wilson v, Dec 22 2016
The mean value of a(n) is Pi, see A057655 for more details. - M. F. Hasler, Mar 20 2017
REFERENCES
L. Comtet, Advanced Combinatorics, Reidel, 1974, p. 162, #16 (7), r(n).
J. H. Conway and N. J. A. Sloane, "Sphere Packings, Lattices and Groups", Springer-Verlag, p. 106.
N. J. Fine, Basic Hypergeometric Series and Applications, Amer. Math. Soc., 1988; p. 78, Eq. (32.23).
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.
G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers. 3rd ed., Oxford Univ. Press, 1954, p. 240, r(n).
W. König and J. Sprekels, Karl Weierstraß (1815-1897), Springer Spektrum, Wiesbaden, 2016, p. 186-187 and p. 280-281.
C. D. Olds, A. Lax and G. P. Davidoff, The Geometry of Numbers, Math. Assoc. Amer., 2000, p. 51.
N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
E. T. Whittaker and G. N. Watson, A Course of Modern Analysis, fourth edition, reprinted, 1958, Cambridge at the University Press.
LINKS
T. D. Noe, Table of n, a(n) for n = 0..10000
G. E. Andrews, R. Lewis and Z.-G. Liu, An identity relating a theta series to a sum of Lambert series, Bull. London Math. Soc., 33 (2001), 25-31.
H. H. Chan and C. Krattenthaler, Recent progress in the study of representations of integers as sums of squares, arXiv:math/0407061 [math.NT], 2004.
S. Cooper and M. Hirschhorn, A combinatorial proof of a result from number theory, Integers 4 (2004), #A09.
Michael Gilleland, Some Self-Similar Integer Sequences
J. W. L. Glaisher, On the representations of a number as the sum of two, four, six, eight, ten, and twelve squares, Quart. J. Math. 38 (1907), 1-62. (This sequence is called rho, see page 6)
M. D. Hirschhorn, Jacobi's Two-Square Theorem and Related Identities
M. D. Hirschhorn, Arithmetic Consequences of Jacobi's Two-Squares Theorem
M. D. Hirschhorn, The number of representations of a number by various forms, Discrete Mathematics 298 (2005), 205-211.
Jacobi-Legendre letters, Correspondance mathématique entre Legendre et Jacobi, J. Reine Angew. Math. 80 (1875) 205-279, letter of September 9, 1828, p. 240-243, formula for 2K/Pi on p. 242.
Christian Kassel and Christophe Reutenauer, The zeta function of the Hilbert scheme of n points on a two-dimensional torus, 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.]
Christian Kassel and Christophe Reutenauer, Complete determination of the zeta function of the Hilbert scheme of n points on a two-dimensional torus, arXiv:1610.07793 [math.NT], 2016.
Christian Kassel, Christophe Reutenauer, The Fourier expansion of eta(z)eta(2z)eta(3z)/eta(6z), arXiv:1603.06357 [math.NT], 2016.
M. Kontsevich and D. Zagier, Periods, 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.
Y. Martin, Multiplicative eta-quotients, Trans. Amer. Math. Soc. 348 (1996), no. 12, 4825-4856, see page 4852 Table I.
G. Nebe and N. J. A. Sloane, Home page for this lattice
F. Richman, Counting Gaussian integers in a disk
Grant Sanderson, Pi hiding in prime regularities, 3Blue1Brown video (2017).
N. J. A. Sloane et al., Binary Quadratic Forms and OEIS (Index to related sequences, programs, references)
Michael Somos, Introduction to Ramanujan theta functions
G. Villemin, Sommes de 2 carrés
Eric Weisstein's World of Mathematics, Barnes-Wall Lattice
Eric Weisstein's World of Mathematics, Moebius Transform
Eric Weisstein's World of Mathematics, Ramanujan Theta Functions
Eric Weisstein's World of Mathematics, Sum of Squares Function
Eric Weisstein's World of Mathematics, Theta Series
Zach Wissner-Gross a.k.a. The Riddler, Riddler Express: Can You Climb Your Way To Victory?, FiveThirtyEight, Sep 24 2021.
G. Xiao, Two squares
FORMULA
Expansion of theta_3(q)^2 = (Sum_{n=-oo..+oo} q^(n^2))^2 = Product_{m>=1} (1-q^(2*m))^2 * (1+q^(2*m-1))^4.
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)*...
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]
a(n) = 4*A002654(n), n > 0.
Expansion of eta(q^2)^10 / (eta(q) * eta(q^4))^4 in powers of q. - Michael Somos, Jul 19 2004
Expansion of ( phi(q)^2 + phi(-q)^2 ) / 2 in powers of q^2 where phi() is a Ramanujan theta function.
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
Euler transform of period 4 sequence [4, -6, 4, -2, ...]. - Michael Somos, Jul 19 2004
Moebius transform is period 4 sequence [4, 0, -4, 0, ...]. - Michael Somos, Sep 17 2007
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).
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
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
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
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
From Wolfdieter Lang, Aug 01 2016: (Start)
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.
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)
a(n) = (4/n)*Sum_{k=1..n} A186690(k)*a(n-k), a(0) = 1. - Seiichi Manyama, May 27 2017
G.f.: Theta_3(q)^2 = hypergeometric([1/2, 1/2],[1],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
EXAMPLE
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
MAPLE
(sum(x^(m^2), m=-10..10))^2;
# Alternative:
A004018list := proc(len) series(JacobiTheta3(0, x)^2, x, len+1);
seq(coeff(%, x, j), j=0..len-1) end:
t1 := A004018list(102);
r2 := n -> t1[n+1]; # Peter Luschny, Oct 02 2018
MATHEMATICA
SquaresR[2, Range[0, 110]] (* Harvey P. Dale, Oct 10 2011 *)
a[ n_] := SquaresR[ 2, n]; (* Michael Somos, Nov 15 2011 *)
a[ n_] := SeriesCoefficient[ EllipticTheta[ 3, 0, q]^2, {q, 0, n}]; (* Michael Somos, Nov 15 2011 *)
a[ n_] := With[{m = InverseEllipticNomeQ @ q}, SeriesCoefficient[ EllipticK[ m] / (Pi/2), {q, 0, n}]]; (* Michael Somos, Jun 10 2014 *)
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 *)
PROG
(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 */
(PARI) {a(n) = if( n<1, n==0, 4 * sumdiv( n, d, (d%4==1) - (d%4==3)))}; /* Michael Somos, Jul 19 2004 */
(PARI) {a(n) = if( n<1, n==0, 2 * qfrep([ 1, 0; 0, 1], n)[n])}; /* Michael Somos, May 13 2005 */
(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
(Magma) Basis( ModularForms( Gamma1(4), 1), 100) [1]; /* Michael Somos, Jun 10 2014 */
(Sage)
Q = DiagonalQuadraticForm(ZZ, [1]*2)
Q.representation_number_list(102) # Peter Luschny, Jun 20 2014
(Julia) # JacobiTheta3 is defined in A000122.
A004018List(len) = JacobiTheta3(len, 2)
A004018List(102) |> println # Peter Luschny, Mar 12 2018
(Python)
from sympy import factorint
def a(n):
if n == 0: return 1
an = 4
for pi, ei in factorint(n).items():
if pi%4 == 1: an *= ei+1
elif pi%4 == 3 and ei%2: return 0
return an
print([a(n) for n in range(102)]) # Michael S. Branicky, Sep 24 2021
(Python)
from math import prod
from sympy import factorint
def A004018(n): return prod(1 if p==2 else (e+1 if p&3==1 else (e+1)&1) for p, e in factorint(n).items())<<2 # Chai Wah Wu, Jul 07 2022
CROSSREFS
Partial sums - 1 give A014198.
KEYWORD
nonn,easy,nice,core
AUTHOR
STATUS
editing