On Friday, February 5, 2016, David Roe <[email protected]> wrote: > > > On Fri, Feb 5, 2016 at 1:20 PM, Vincent Delecroix < > [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote: > >> Hello, >> >> Indeed, the definition given in the documentation of "is_prime" does not >> coincide with what the method is doing. >> >> The mathematical definition of prime *depends* on the ring. An element of >> a ring is prime if the ideal it generates is prime. And the ideal (3) is >> prime in ZZ but not in QQ. A less stupid example >> >> sage: K = ZZ[I] >> sage: K(3).is_prime() >> True >> sage: K(5).is_prime() >> False >> >> The Sage behavior of the function is_prime is perfectly coherent with >> respect to this definition. >> >> I would rather make a patch to modify the documentation and warns the >> user about the difference between prime element in a ring and prime number. > > > +1 > David >
Maybe is_prime for field elements should just raise an exception? > >> >> Vincent >> >> >> On 05/02/16 14:50, David Wong wrote: >> >>> prime_number = bignumber / 2 >>> is_prime(prime_number) # -> False >>> >>> prime_number = bignumber // 2 >>> is_prime(prime_number) # -> True >>> >>> prime_number = ZZ(bignumber / 2) >>> is_prime(prime_number) # -> True >>> >>> >>> I've spent a couple of days arguing with people about a number (not) >>> being >>> a prime. Turns out it fails silently if you're in the wrong field. >>> >>> I guess a fix would be to ZZ() the number first in the function is_prime. >>> If you guys agree I can submit a patch or something (never touched at >>> Sage's codebase and that would be a good opportunity) >>> >>> David >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "sage-devel" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] >> <javascript:_e(%7B%7D,'cvml','sage-devel%[email protected]');> >> . >> To post to this group, send email to [email protected] >> <javascript:_e(%7B%7D,'cvml','[email protected]');>. >> Visit this group at https://groups.google.com/group/sage-devel. >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <javascript:_e(%7B%7D,'cvml','sage-devel%[email protected]');> > . > To post to this group, send email to [email protected] > <javascript:_e(%7B%7D,'cvml','[email protected]');>. > Visit this group at https://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. > -- Sent from my massive iPhone 6 plus. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
