SquaresR[d,n]
gives the number of ways
to represent the integer n as a sum of d squares.
SquaresR
SquaresR[d,n]
gives the number of ways
to represent the integer n as a sum of d squares.
Examples
open all close allBasic Examples (3)
Number of ways to represent 45 as a sum of two squares:
SquaresR[2, 45]The number of integer points on a circle of radius
:
DiscretePlot[SquaresR[2, n], {n, 100}]Base 2 logarithm of the number of integer points on a sphere of dimension n:
DiscretePlot[Log2@SquaresR[n, 100], {n, 20}]Applications (2)
Number of lattice points inside the circle of radius 20 with center at the origin:
Sum[SquaresR[2, k], {k, 0, 20 ^ 2}]Approximation of the Sierpiński constant:
s[n_] := Sum[SquaresR[2, k] / k, {k, n}] - Pi Log[n]N[s[100000]]Properties & Relations (4)
The number of representations as the sum of two squares:
SquaresR[2, 100]PowersRepresentations enumerates the ordered representations up to units:
PowersRepresentations[100, 2, 2]The ZTransform:
ZTransform[SquaresR[2, n], n, z]The generating function for SquaresR:
GeneratingFunction[SquaresR[2, n], n, x]FindSequenceFunction can recognize the SquaresR sequence:
Table[SquaresR[2, n], {n, 10}]FindSequenceFunction[%, n]See Also
Tech Notes
Related Guides
History
Text
Wolfram Research (2007), SquaresR, Wolfram Language function, https://reference.wolfram.com/language/ref/SquaresR.html.
CMS
Wolfram Language. 2007. "SquaresR." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SquaresR.html.
APA
Wolfram Language. (2007). SquaresR. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SquaresR.html
BibTeX
@misc{reference.wolfram_2026_squaresr, author="Wolfram Research", title="{SquaresR}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/SquaresR.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_squaresr, organization={Wolfram Research}, title={SquaresR}, year={2007}, url={https://reference.wolfram.com/language/ref/SquaresR.html}, note=[Accessed: 13-June-2026]}