HP Forums

Full Version: pa2b2 small oddity
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 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
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 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
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 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
I'm modifying pa2b2(2), it will return [1,1].
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!
Ok, let's do an irem before calling legendre, and the same for jacobi.
That would make sense, if irem was missing! Smile
Reference URL's