![]() |
![]() |
#1 |
Aug 2006
597210 Posts |
![]()
There's a well-known formula for the number of ways that a number can be expressed as the sum of two squares: the product of one more than the exponents of the primes = 1 mod 4, assuming that all primes = 3 mod 4 appear to an even power (and 0 if any appear to an odd power).
Is there a similarly nice formula for sums of three squares? I was trying to do some calculations with them but the inefficiency of my current program makes that difficult. I'm able to use some properties of such numbers (removing factors of 4, checking mod 8, using an efficient sum of two primes subroutine to remove some cases) but it's still slow -- getting to ten million will take all night, where with sums of two primes that would take 25 seconds. |
![]() |
![]() |
![]() |
#2 | |
Nov 2003
22·5·373 Posts |
![]() Quote:
Last fiddled with by R.D. Silverman on 2009-11-05 at 12:52 Reason: typo |
|
![]() |
![]() |
![]() |
#3 |
Feb 2005
3748 Posts |
![]()
See formula (35) at http://mathworld.wolfram.com/SumofSquaresFunction.html
|
![]() |
![]() |
![]() |
#4 |
Aug 2006
22×1,493 Posts |
![]()
Let me look at that formula and see if there is a good way to translate between it and my problem (essential solutions, not including sign and ordering).
Since this formula applies only for squarefrees, how do I solve r_3(n * s^2)? Is there a good upper bound on the number of representations? Even a weak one like r_3(n) < n would be nice. Last fiddled with by CRGreathouse on 2009-11-06 at 14:55 |
![]() |
![]() |
![]() |
#5 | |
Dec 2008
15018 Posts |
![]() Quote:
I should note that the methods used to achieve an upper bound on the number of representations as the sum of three squares of primes can be modified without much difficulty to provide a corresponding estimate (of the same quality, at worst) for the sum of three squares. The reason for this is that the situation becomes harder if we restrict some variables to primes. Thus, I am sure that the problem of the sum of three squares of primes (or a variant of this problem, at best) is treated in the H-R text. Last fiddled with by flouran on 2009-11-06 at 17:49 |
|
![]() |
![]() |
![]() |
#6 | |
Feb 2005
22×32×7 Posts |
![]() Quote:
Ordering is also possible to take into account by considering cases with distinct/equal squares. |
|
![]() |
![]() |
![]() |
#7 | |
Aug 2006
22·1,493 Posts |
![]() Quote:
If n is a square, there are 6 representations (1 unique) of the number as 0^2 + 0^2 + a^2. If n is twice a square, there are 12 representations (1 unique) of the number as 0^2 + a^2 + b^2, |a| = |b|. So I guess I can use these and the algorithm for unique representations as two squares to determine the number of unique and nonunique representations as the sum of three squares, the least of which must be 0. So using the formula for r_3 I can determine the number of nonunique representations of n as the sum of three nonzero squares (and the corresponding number of unique representations skipped). The number of representations as a^2 + b^2 + c^2 with |a| = |b| but |c| distinct from |a| and |b| can be counted directly. The number of representations as a^2 + b^2 + c^2 with |a| = |b| = |c| is 8 if n is thrice a square and 0 otherwise. The total can be subtracted from the above and divided by 48 to get the number of unique representations of the form a^2 + b^2 + c^2 with 0 < a < b < c; the skipped totals can be added on and I'm done. Computational analysis: r_3(n) can be computed in time O(n^.25) with Shanks' method. r_2(n) can be computed in time O(n^o(1)). The case with two equal squares can be computed in time O(sqrt(n) log(n)^2) -- the log term is improvable but realistically at the small sizes this is practical at the square root is likely to be quadratic rather than Karatsuba or Toom. So this case dominates the analysis. Is there a better way to count this case? |
|
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sums of all Squares | davar55 | Puzzles | 183 | 2019-12-12 22:31 |
Regarding Squares | a1call | Miscellaneous Math | 42 | 2017-02-03 01:29 |
Basic Number Theory 12: sums of two squares | Nick | Number Theory Discussion Group | 0 | 2016-12-11 11:30 |
squares or not squares | m_f_h | Puzzles | 45 | 2007-06-15 17:46 |
Fibonacci sums? | TTn | Math | 2 | 2002-10-25 21:47 |