pa2b2 small oddity
01-31-2014, 08:58 PM
Post: #1
 Helge Gabert Senior Member Posts: 467 Joined: Dec 2013
pa2b2 small oddity
I noticed that pa2b2 does not return a solution for the prime p=2. "Error bad argument value." Why should that be, as the solution is [1 1], or (1+i)*CONJ(1+i), and clearly a sum of two squares. It is no big deal, but I am curious as to why the restriction for pa2b2 is only for primes congruent to 1 mod 4, and not also for p=2.
01-31-2014, 11:24 PM (This post was last modified: 01-31-2014 11:30 PM by Mark Hardman.)
Post: #2
 Mark Hardman Senior Member Posts: 525 Joined: Dec 2013
RE: pa2b2 small oddity
(01-31-2014 08:58 PM)Helge Gabert Wrote:  ...why the restriction for pa2b2 is only for primes congruent to 1 mod 4, and not also for p=2.

This is a requirement of Fermat's theorem on sums of two squares.

For the Prime Team:

The example in the online help is: pa2b2(209). Which also returns, "Error: Bad Argument Value" because 209 is not prime (11 x 19).

Mark Hardman

Ceci n'est pas une signature.
02-01-2014, 12:23 AM
Post: #3
 Helge Gabert Senior Member Posts: 467 Joined: Dec 2013
RE: pa2b2 small oddity
Yes of course, I am aware of Fermat's theorem, but that was not my point.

Everything works nicely for primes congruent to 1 mod 4 (as it should!), but why not include p=2 for the pa2b2 command? That is all I am asking.
02-01-2014, 03:38 AM
Post: #4
 Mark Hardman Senior Member Posts: 525 Joined: Dec 2013
RE: pa2b2 small oddity
(02-01-2014 12:23 AM)Helge Gabert Wrote:  but why not include p=2 for the pa2b2 command? That is all I am asking.

I can see your point that, based on the help text, p=2 could be allowed.

Considering that the function explicitly states that the prime must meet the condition: $$p\equiv 1 \left ( mod\; 4 \right )$$.

I am left to believe that it is a function for determining the two integers that solve Fermat's theorem on sums of two squares:

$$p=a^{2}+b^{2}$$

In addition to the requirement that $$p\equiv 1 \left ( mod\; 4 \right )$$, the theorem also stipulates that p must be an odd prime number.

Mark Hardman

Ceci n'est pas une signature.
02-01-2014, 04:19 AM
Post: #5
 Helge Gabert Senior Member Posts: 467 Joined: Dec 2013
RE: pa2b2 small oddity
P=2 can be factored into (1+i)*(1-i), and can be written as a sum of squares, namely sq(1)+sq(1), so pa2b2 could be modified to allow for the solution of [1 1] if the user enters pa2b2(2). That's it.

So my suggestion is that pa2b2 would allow for arguments to include all primes congruent to 1 modulus 4, as well as the even prime 2.
02-01-2014, 07:35 AM
Post: #6
 Mark Hardman Senior Member Posts: 525 Joined: Dec 2013
RE: pa2b2 small oddity
(02-01-2014 04:19 AM)Helge Gabert Wrote:  So my suggestion is that pa2b2 would allow for arguments to include all primes congruent to 1 modulus 4, as well as the even prime 2.

I concede the point.

The On-Line Encyclopedia of Integer Sequences includes p=2 in A002313. Though Wolfram in its article Fermat's 4n+1 Theorem does describe the case of p=2 as "a degenerate case with x=y=1."

Mark Hardman

Ceci n'est pas une signature.
02-02-2014, 07:33 AM
Post: #7
 parisse Senior Member Posts: 1,313 Joined: Dec 2013
RE: pa2b2 small oddity
I'm modifying pa2b2(2), it will return [1,1].
02-02-2014, 07:25 PM
Post: #8
 Helge Gabert Senior Member Posts: 467 Joined: Dec 2013
RE: pa2b2 small oddity
Oh, thank you very much!

I also noticed that legendre_symbol(a,p) seems to return odd values sometimes, e.g., legendre_symbol(-23,83) returns 809331400 ??? But legendre_symbol(a,p) should only return values {-1,0,1}.

In this case, legendre_symbol(-23,83) should equal legendre_symbol(60,83), and that does get handled correctly, returning -1.

Thanks for looking into that!
02-03-2014, 08:22 AM
Post: #9
 parisse Senior Member Posts: 1,313 Joined: Dec 2013
RE: pa2b2 small oddity
Ok, let's do an irem before calling legendre, and the same for jacobi.
02-03-2014, 04:57 PM
Post: #10
 Helge Gabert Senior Member Posts: 467 Joined: Dec 2013
RE: pa2b2 small oddity
That would make sense, if irem was missing!
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)