Message Boards Message Boards

Unexpected output from Reduce?

Posted 11 months ago
In[86]:= Reduce[NextPrime[x] - x == 2 && 0 < x < 20 && PrimeQ[x], 
 x \[Element] Integers]

Out[86]= False

In[87]:= Reduce[NextPrime[x] - x == 2 && 0 < x < 20, 
 x \[Element] Integers]

Out[87]= x == 3 || x == 5 || x == 9 || x == 11 || x == 15 || x == 17

why Out[86]=False ?

I expect

Out[86]= x == 3 || x == 5 ||x == 11 ||x == 17
POSTED BY: Cody Luo
3 Replies

Gianluca, your are simply too fast - and with the better solution! Best regards -- Henrik

POSTED BY: Henrik Schachner
POSTED BY: Henrik Schachner

I suppose it is because PrimeQ is meant as a test for numbers. When given a symbol, such as in PrimeQ[x], it gives False.

I would use Element[x, Primes], which remains unevaluated when x is a symbol.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract