![]() |
![]() |
#1 |
Dec 2008
you know...around...
2·52·17 Posts |
![]()
Now, we all know that if n=4m+1 is prime it can be expressed as the sum of two squares in only one way.
I was wondering if this is also true the other way round, i.e. if n=4m+1 can be written as the sum of two squares in only one way (Edit: and gcd(a;b)=1), does that mean n is prime? And if so, how efficient would that test be? I mean, checking the possibilities of a²+b²=n. Surely not as fast as APR-CL or ECPP, but I think it could be more efficient than trial division? Last fiddled with by mart_r on 2009-01-10 at 23:41 |
![]() |
![]() |
![]() |
#2 | |
Aug 2006
5,987 Posts |
![]() Quote:
Checking each possibility as the sum of two squares takes O(sqrt (n) * log n). |
|
![]() |
![]() |
![]() |
#3 | |
Dec 2008
179 Posts |
![]() Quote:
|
|
![]() |
![]() |
![]() |
#4 | |
Dec 2008
you know...around...
2×52×17 Posts |
![]()
Aha. Good to know.
Quote:
And surely there are even finer techniques to find sums of squares. But I don't know very much about it. Last fiddled with by mart_r on 2009-01-11 at 16:08 |
|
![]() |
![]() |
![]() |
#5 |
Aug 2006
5,987 Posts |
![]()
If you only need to test 1% of the possibilities, that's O(sqrt n * log n).
|
![]() |
![]() |
![]() |
#6 |
Dec 2008
you know...around...
11010100102 Posts |
![]() |
![]() |
![]() |
![]() |
#7 |
Aug 2006
5,987 Posts |
![]()
Basically, yes. The dominant term is sqrt(n), just like for trial division. Both have a large number of possible optimizations, so it's not clear which would be practically faster, but neither could be used for large numbers.
|
![]() |
![]() |
![]() |
#8 |
"Phil"
Sep 2002
Tracktown, U.S.A.
100011000002 Posts |
![]()
Euler, for the record, did use this as a primality proving method. In practice, you can sieve out which n-x^2 are not squares modulo 2, 3, 5, 7, etc. very quickly. In the end, you need test very few numbers of this form to see if they are actually perfect squares. I do not have the details at hand, but I recall studying this problem a few years ago and coming to the conclusion that finding all representations of n as a sum of squares x^2+y^2 was of approximate order O(n^1/4), although an extra factor of ln n or so would not surprise me. Obviously, we could use this as either a primality proving method or a factoring method.
|
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Short Assignments | Unregistered | Information & Answers | 5 | 2009-03-02 17:29 |
Back from a short hiatus... | mdettweiler | No Prime Left Behind | 2 | 2009-02-20 16:26 |
Can I cut an ECM assignment short? | Mr. P-1 | Information & Answers | 7 | 2009-02-19 15:05 |
Short term goal | em99010pepe | No Prime Left Behind | 94 | 2008-03-24 21:02 |
Short-term goal | em99010pepe | Operation Billion Digits | 8 | 2005-11-26 22:53 |