15
$\begingroup$

For every integer $x$ the equation Mod[x, 1] == 0 holds. While

Simplify[Mod[x, 1] == 0, Element[x,Integers]] 

gives True,

Reduce[Mod[x, 1] == 0, x, Integers] 

gives False. Why?

$\endgroup$
  • 2
    $\begingroup$ Welcome to Mathematica @ StackExchange! Please consider registering your account so that any upvotes you get on this question are added to those you might get on future questions and answers. That way, over time you will be able to do more on the site (post graphics, edit things, etc). Also, I have formatted your code to make it easier to read. This link will show you how it's done for next time. And welcome again! $\endgroup$ – Verbeia Aug 16 '12 at 23:14
  • 4
    $\begingroup$ @NasserM.Abbasi I think this is because the documentation is usually written by the same person that coded the functionality. While an economical approach, it's not necessarily the best for expository value: the author will already have internalized the purpose and semantics of the code, so describing it to others in an unbiased way is that much harder for them. I don't blame the developers for that, of course--I'm a terrible example of this myself. $\endgroup$ – Oleksandr R. Aug 17 '12 at 1:03
  • $\begingroup$ @OleksandrR. I think you just described my papers :D $\endgroup$ – rm -rf Aug 17 '12 at 4:14
10
$\begingroup$

Reduce works fine for a slightly more sophisticated expression, e.g. :

Reduce[ ForAll[ x, x ∈ Integers, Mod[ x, 1] == 0], x]
True

however there is a bug in Solve :

Solve[ Mod[x, 1] == 0, x, Integers]
{}

therefore it is not surprising we have an analogical issue in Reduce :

Reduce[ Mod[x, 1] == 0, x, Integers] 
False 

Seemingly there has not been much clamor therefore it has not been a high priority to improve it.

One can work around these problems :

Reduce[ Mod[ a x, a] == 0 && a == 1, x, Integers]
C[1] ∈ Integers && a == 1 && x == C[1]

or simply

Reduce[ Mod[ x, 1] == a, x, Integers]
C[1] ∈ Integers && a == 0 && x == C[1]
Solve[ Mod[ x, 1] == a, x, Integers]
{{x -> ConditionalExpression[C[1], C[1] ∈ Integers && a == 0]}}

Edit

The above problems with Reduce and Solve were found in Mathematica 8. Before there had been :

ver. 7

Solve[ Mod[x, 1] == 0, x, Integers]
Solve::ifun: Inverse functions are being used by Solve, so some solutions may not
be found; use Reduce for complete solution information. >> 

{{x -> InverseFunction[Mod, 1, 2][0, 1]}}
Reduce[ Mod[x, 1] == 0, x, Integers]
False

Now these bugs have been fixed :

ver. 9

Solve[ Mod[x, 1] == 0, x, Integers]
{{x -> ConditionalExpression[C[1], C[1] ∈ Integers]}}
Reduce[ Mod[x, 1] == 0, x, Integers]
C[1] ∈ Integers && x == C[1]
$\endgroup$
  • 2
    $\begingroup$ Congrats on 10k! $\endgroup$ – rcollyer Aug 17 '12 at 4:23
  • 1
    $\begingroup$ Worth noting that this issue has been fixed in Mathematica 9, where Solve now gives the correct result. $\endgroup$ – Oleksandr R. Dec 9 '12 at 18:00
  • $\begingroup$ @OleksandrR. Thanks, updated. $\endgroup$ – Artes Dec 10 '12 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.