pa2b2 small oddity - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: pa2b2 small oddity (/thread-584.html) |
pa2b2 small oddity - Helge Gabert - 01-31-2014 08:58 PM 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. RE: pa2b2 small oddity - Mark Hardman - 01-31-2014 11:24 PM (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 RE: pa2b2 small oddity - Helge Gabert - 02-01-2014 12:23 AM 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. RE: pa2b2 small oddity - Mark Hardman - 02-01-2014 03:38 AM (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 RE: pa2b2 small oddity - Helge Gabert - 02-01-2014 04:19 AM 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. RE: pa2b2 small oddity - Mark Hardman - 02-01-2014 07:35 AM (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 RE: pa2b2 small oddity - parisse - 02-02-2014 07:33 AM I'm modifying pa2b2(2), it will return [1,1]. RE: pa2b2 small oddity - Helge Gabert - 02-02-2014 07:25 PM 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! RE: pa2b2 small oddity - parisse - 02-03-2014 08:22 AM Ok, let's do an irem before calling legendre, and the same for jacobi. RE: pa2b2 small oddity - Helge Gabert - 02-03-2014 04:57 PM That would make sense, if irem was missing! |