Note that there is a difference between the example in the original email and 
the answers: The original email was about is_prime(something) not 
something.is_prime(). I do not know the mechanisms behind is_prime(something) 
but would it be possible that in this case the behavior is slightly different, 
say that the input is coerced to ZZ if possible? It would be more user friendly 
I guess. 

Bruno 


On 5 février 2016 19:59:53 HNEC, William Stein <wst...@gmail.com> wrote:
>On Friday, February 5, 2016, David Roe <roed.m...@gmail.com> wrote:
>
>>
>>
>> On Fri, Feb 5, 2016 at 1:20 PM, Vincent Delecroix <
>> 20100.delecr...@gmail.com
>> <javascript:_e(%7B%7D,'cvml','20100.delecr...@gmail.com');>> 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 sage-devel+unsubscr...@googlegroups.com
>>>
><javascript:_e(%7B%7D,'cvml','sage-devel%2bunsubscr...@googlegroups.com');>
>>> .
>>> To post to this group, send email to sage-devel@googlegroups.com
>>> <javascript:_e(%7B%7D,'cvml','sage-devel@googlegroups.com');>.
>>> 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 sage-devel+unsubscr...@googlegroups.com
>>
><javascript:_e(%7B%7D,'cvml','sage-devel%2bunsubscr...@googlegroups.com');>
>> .
>> To post to this group, send email to sage-devel@googlegroups.com
>> <javascript:_e(%7B%7D,'cvml','sage-devel@googlegroups.com');>.
>> 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 sage-devel+unsubscr...@googlegroups.com.
>To post to this group, send email to sage-devel@googlegroups.com.
>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 sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to